tibia-client/src/client/tile.h

136 lines
4.4 KiB
C
Raw Normal View History

2011-08-28 15:17:58 +02:00
/*
* Copyright (c) 2010-2013 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"
#include "mapview.h"
2012-07-29 14:04:47 +02:00
#include "effect.h"
#include "creature.h"
#include "item.h"
#include <framework/luaengine/luaobject.h>
2011-08-15 16:11:24 +02:00
2012-06-21 04:31:29 +02:00
enum tileflags_t
{
TILESTATE_NONE = 0,
TILESTATE_PROTECTIONZONE = 1 << 0,
TILESTATE_TRASHED = 1 << 1,
TILESTATE_OPTIONALZONE = 1 << 2,
TILESTATE_NOLOGOUT = 1 << 3,
TILESTATE_HARDCOREZONE = 1 << 4,
TILESTATE_REFRESH = 1 << 5,
2012-06-21 04:31:29 +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,
TILESTATE_DEPOT = 1 << 22,
TILESTATE_TRANSLUECENT_LIGHT = 1 << 23
2012-06-21 04:31:29 +02:00
};
#pragma pack(push,1) // disable memory alignment
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
void draw(const Point& dest, float scaleFactor, int drawFlags, LightView *lightView = nullptr);
2012-01-30 01:00:12 +01:00
public:
void clean();
2011-08-15 21:15:49 +02:00
void addWalkingCreature(const CreaturePtr& creature);
void removeWalkingCreature(const CreaturePtr& creature);
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);
bool hasThing(const ThingPtr& thing);
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();
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; }
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; }
std::vector<ThingPtr> getThings() { return m_things; }
2011-08-31 22:22:57 +02:00
ItemPtr getGround();
int getGroundSpeed();
uint8 getMinimapColorByte();
2012-02-02 21:10:14 +01:00
int getThingCount() { return m_things.size() + m_effects.size(); }
bool isPathable();
2011-11-05 21:34:49 +01:00
bool isWalkable();
bool changesFloor();
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();
bool isDrawable();
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();
bool limitsFloorsView();
2012-02-02 21:10:14 +01:00
bool canErase();
2012-08-02 03:33:56 +02:00
bool hasElevation(int elevation = 1);
void setFlags(tileflags_t flags) { m_flags |= (uint32)flags; }
uint32 getFlags() { return m_flags; }
2012-08-19 17:41:03 +02:00
void setHouseId(uint32 hid) { m_houseId = hid; }
uint32 getHouseId() { return m_houseId; }
2012-08-20 00:30:49 +02:00
bool isHouseTile() const { return (m_flags & TILESTATE_HOUSE) == TILESTATE_HOUSE; }
2011-09-01 16:49:51 +02:00
TilePtr asTile() { return static_self_cast<Tile>(); }
2011-08-15 16:11:24 +02:00
private:
void checkTranslucentLight();
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;
uint32 m_flags, m_houseId;
2011-08-15 16:11:24 +02:00
};
#pragma pack(pop)
2011-08-15 16:11:24 +02:00
#endif