2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2014-04-01 07:36:42 +02:00
|
|
|
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#ifndef TILE_H
|
|
|
|
#define TILE_H
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#include "declarations.h"
|
2012-11-29 02:47:26 +01:00
|
|
|
#include "mapview.h"
|
2012-07-29 14:04:47 +02:00
|
|
|
#include "effect.h"
|
|
|
|
#include "creature.h"
|
|
|
|
#include "item.h"
|
2012-07-14 03:10:24 +02:00
|
|
|
#include <framework/luaengine/luaobject.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-06-21 04:31:29 +02:00
|
|
|
enum tileflags_t
|
|
|
|
{
|
2012-06-21 05:05:44 +02:00
|
|
|
TILESTATE_NONE = 0,
|
|
|
|
TILESTATE_PROTECTIONZONE = 1 << 0,
|
|
|
|
TILESTATE_TRASHED = 1 << 1,
|
|
|
|
TILESTATE_OPTIONALZONE = 1 << 2,
|
|
|
|
TILESTATE_NOLOGOUT = 1 << 3,
|
2012-07-09 08:59:16 +02:00
|
|
|
TILESTATE_HARDCOREZONE = 1 << 4,
|
2012-06-21 05:05:44 +02:00
|
|
|
TILESTATE_REFRESH = 1 << 5,
|
2012-06-21 04:31:29 +02:00
|
|
|
|
2012-06-21 05:05:44 +02:00
|
|
|
// internal usage
|
|
|
|
TILESTATE_HOUSE = 1 << 6,
|
|
|
|
TILESTATE_TELEPORT = 1 << 17,
|
|
|
|
TILESTATE_MAGICFIELD = 1 << 18,
|
|
|
|
TILESTATE_MAILBOX = 1 << 19,
|
|
|
|
TILESTATE_TRASHHOLDER = 1 << 20,
|
|
|
|
TILESTATE_BED = 1 << 21,
|
2012-11-29 22:38:39 +01:00
|
|
|
TILESTATE_DEPOT = 1 << 22,
|
2013-08-17 23:06:58 +02:00
|
|
|
TILESTATE_TRANSLUECENT_LIGHT = 1 << 23,
|
|
|
|
|
|
|
|
TILESTATE_LAST = 1 << 24
|
2012-06-21 04:31:29 +02:00
|
|
|
};
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
class Tile : public LuaObject
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-05-10 14:09:44 +02:00
|
|
|
enum {
|
|
|
|
MAX_THINGS = 10
|
|
|
|
};
|
|
|
|
|
2011-08-31 01:39:14 +02:00
|
|
|
Tile(const Position& position);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-11-29 02:47:26 +01:00
|
|
|
void draw(const Point& dest, float scaleFactor, int drawFlags, LightView *lightView = nullptr);
|
2012-01-30 01:00:12 +01:00
|
|
|
|
|
|
|
public:
|
2011-08-17 06:45:55 +02:00
|
|
|
void clean();
|
2011-08-15 21:15:49 +02:00
|
|
|
|
2012-01-30 22:28:08 +01:00
|
|
|
void addWalkingCreature(const CreaturePtr& creature);
|
|
|
|
void removeWalkingCreature(const CreaturePtr& creature);
|
|
|
|
|
2012-07-28 21:02:05 +02:00
|
|
|
void addThing(const ThingPtr& thing, int stackPos);
|
2012-02-02 21:10:14 +01:00
|
|
|
bool removeThing(ThingPtr thing);
|
2011-08-31 22:22:57 +02:00
|
|
|
ThingPtr getThing(int stackPos);
|
2012-07-15 07:46:56 +02:00
|
|
|
EffectPtr getEffect(uint16 id);
|
2012-05-10 00:19:05 +02:00
|
|
|
bool hasThing(const ThingPtr& thing);
|
2013-01-20 17:09:14 +01:00
|
|
|
int getThingStackPos(const ThingPtr& thing);
|
2012-01-03 21:41:00 +01:00
|
|
|
ThingPtr getTopThing();
|
2012-01-30 01:00:12 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
ThingPtr getTopLookThing();
|
|
|
|
ThingPtr getTopUseThing();
|
|
|
|
CreaturePtr getTopCreature();
|
2012-01-20 02:12:26 +01:00
|
|
|
ThingPtr getTopMoveThing();
|
2013-01-09 20:29:58 +01:00
|
|
|
ThingPtr getTopMultiUseThing();
|
2012-01-04 14:02:35 +01:00
|
|
|
|
2012-01-30 01:00:12 +01:00
|
|
|
const Position& getPosition() { return m_position; }
|
2011-08-31 22:22:57 +02:00
|
|
|
int getDrawElevation() { return m_drawElevation; }
|
2012-06-23 16:26:18 +02:00
|
|
|
std::vector<ItemPtr> getItems();
|
2011-08-31 22:22:57 +02:00
|
|
|
std::vector<CreaturePtr> getCreatures();
|
2012-08-22 02:27:48 +02:00
|
|
|
std::vector<CreaturePtr> getWalkingCreatures() { return m_walkingCreatures; }
|
2012-08-01 09:49:09 +02:00
|
|
|
std::vector<ThingPtr> getThings() { return m_things; }
|
2011-08-31 22:22:57 +02:00
|
|
|
ItemPtr getGround();
|
2012-01-15 22:19:52 +01:00
|
|
|
int getGroundSpeed();
|
2012-07-28 21:02:05 +02:00
|
|
|
uint8 getMinimapColorByte();
|
2012-02-02 21:10:14 +01:00
|
|
|
int getThingCount() { return m_things.size() + m_effects.size(); }
|
2012-03-24 16:22:40 +01:00
|
|
|
bool isPathable();
|
2013-01-27 17:06:47 +01:00
|
|
|
bool isWalkable(bool ignoreCreatures = false);
|
2011-09-02 00:00:46 +02:00
|
|
|
bool isFullGround();
|
2011-08-31 22:22:57 +02:00
|
|
|
bool isFullyOpaque();
|
2012-12-04 00:18:39 +01:00
|
|
|
bool isSingleDimension();
|
2011-09-02 00:00:46 +02:00
|
|
|
bool isLookPossible();
|
2012-01-04 15:30:28 +01:00
|
|
|
bool isClickable();
|
2012-01-30 01:00:12 +01:00
|
|
|
bool isEmpty();
|
2012-08-03 05:05:13 +02:00
|
|
|
bool isDrawable();
|
2012-11-29 22:38:39 +01:00
|
|
|
bool hasTranslucentLight() { return m_flags & TILESTATE_TRANSLUECENT_LIGHT; }
|
2012-02-02 17:55:42 +01:00
|
|
|
bool mustHookSouth();
|
|
|
|
bool mustHookEast();
|
2012-01-30 01:00:12 +01:00
|
|
|
bool hasCreature();
|
2013-03-15 00:57:02 +01:00
|
|
|
bool limitsFloorsView(bool isFreeView = false);
|
2012-02-02 21:10:14 +01:00
|
|
|
bool canErase();
|
2012-08-02 03:33:56 +02:00
|
|
|
bool hasElevation(int elevation = 1);
|
2013-01-22 13:01:30 +01:00
|
|
|
void overwriteMinimapColor(uint8 color) { m_minimapColor = color; }
|
2011-11-10 07:53:16 +01:00
|
|
|
|
2013-12-14 22:06:52 +01:00
|
|
|
void remFlag(uint32 flag) { m_flags &= ~flag; }
|
2013-11-12 23:07:46 +01:00
|
|
|
void setFlag(uint32 flag) { m_flags |= flag; }
|
|
|
|
void setFlags(uint32 flags) { m_flags = flags; }
|
|
|
|
bool hasFlag(uint32 flag) { return (m_flags & flag) == flag; }
|
2012-07-20 20:56:08 +02:00
|
|
|
uint32 getFlags() { return m_flags; }
|
|
|
|
|
2012-08-19 17:41:03 +02:00
|
|
|
void setHouseId(uint32 hid) { m_houseId = hid; }
|
2012-07-20 20:56:08 +02:00
|
|
|
uint32 getHouseId() { return m_houseId; }
|
2014-05-31 05:46:55 +02:00
|
|
|
bool isHouseTile() { return m_houseId != 0 && (m_flags & TILESTATE_HOUSE) == TILESTATE_HOUSE; }
|
2011-09-01 16:49:51 +02:00
|
|
|
|
2013-12-14 22:06:52 +01:00
|
|
|
void select() { m_selected = true; }
|
|
|
|
void unselect() { m_selected = false; }
|
|
|
|
bool isSelected() { return m_selected; }
|
|
|
|
|
2012-08-01 09:49:09 +02:00
|
|
|
TilePtr asTile() { return static_self_cast<Tile>(); }
|
2012-07-15 15:23:13 +02:00
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
private:
|
2012-11-29 22:38:39 +01:00
|
|
|
void checkTranslucentLight();
|
|
|
|
|
2012-08-01 09:49:09 +02:00
|
|
|
stdext::packed_vector<CreaturePtr> m_walkingCreatures;
|
|
|
|
stdext::packed_vector<EffectPtr> m_effects; // leave this outside m_things because it has no stackpos.
|
|
|
|
stdext::packed_vector<ThingPtr> m_things;
|
2012-01-30 01:00:12 +01:00
|
|
|
Position m_position;
|
2012-02-02 21:10:14 +01:00
|
|
|
uint8 m_drawElevation;
|
2013-01-22 13:01:30 +01:00
|
|
|
uint8 m_minimapColor;
|
2012-07-20 20:56:08 +02:00
|
|
|
uint32 m_flags, m_houseId;
|
2013-12-14 22:06:52 +01:00
|
|
|
|
|
|
|
stdext::boolean<false> m_selected;
|
2011-08-15 16:11:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|