Otclient  14/8/2020
thing.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef THING_H
24 #define THING_H
25 
26 #include "declarations.h"
27 #include "thingtype.h"
28 #include "thingtypemanager.h"
30 
31 // @bindclass
32 #pragma pack(push,1) // disable memory alignment
33 class Thing : public LuaObject
34 {
35 public:
36  Thing();
37  virtual ~Thing() { }
38 
39  virtual void draw(const Point& /*dest*/, float /*scaleFactor*/, bool /*animate*/, LightView* /*lightView*/ = nullptr) { }
40 
41  virtual void setId(uint32 /*id*/) { }
42  void setPosition(const Position& position);
43 
44  virtual uint32 getId() { return 0; }
46  int getStackPriority();
47  const TilePtr& getTile();
49  int getStackPos();
50 
51  virtual bool isItem() { return false; }
52  virtual bool isEffect() { return false; }
53  virtual bool isMissile() { return false; }
54  virtual bool isCreature() { return false; }
55  virtual bool isNpc() { return false; }
56  virtual bool isMonster() { return false; }
57  virtual bool isPlayer() { return false; }
58  virtual bool isLocalPlayer() { return false; }
59  virtual bool isAnimatedText() { return false; }
60  virtual bool isStaticText() { return false; }
61 
62  // type shortcuts
63  virtual const ThingTypePtr& getThingType();
64  virtual ThingType *rawGetThingType();
65  Size getSize() { return rawGetThingType()->getSize(); }
66  int getWidth() { return rawGetThingType()->getWidth(); }
67  int getHeight() { return rawGetThingType()->getHeight(); }
69  virtual int getDisplacementX() { return rawGetThingType()->getDisplacementX(); }
70  virtual int getDisplacementY() { return rawGetThingType()->getDisplacementY(); }
71  virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase) { return rawGetThingType()->getExactSize(layer, xPattern, yPattern, zPattern, animationPhase); }
72  int getLayers() { return rawGetThingType()->getLayers(); }
82  int getLensHelp() { return rawGetThingType()->getLensHelp(); }
83  int getClothSlot() { return rawGetThingType()->getClothSlot(); }
84  int getElevation() { return rawGetThingType()->getElevation(); }
85  bool isGround() { return rawGetThingType()->isGround(); }
87  bool isOnBottom() { return rawGetThingType()->isOnBottom(); }
88  bool isOnTop() { return rawGetThingType()->isOnTop(); }
89  bool isContainer() { return rawGetThingType()->isContainer(); }
90  bool isStackable() { return rawGetThingType()->isStackable(); }
91  bool isForceUse() { return rawGetThingType()->isForceUse(); }
92  bool isMultiUse() { return rawGetThingType()->isMultiUse(); }
93  bool isWritable() { return rawGetThingType()->isWritable(); }
94  bool isChargeable() { return rawGetThingType()->isChargeable(); }
97  bool isSplash() { return rawGetThingType()->isSplash(); }
102  bool isPickupable() { return rawGetThingType()->isPickupable(); }
103  bool isHangable() { return rawGetThingType()->isHangable(); }
104  bool isHookSouth() { return rawGetThingType()->isHookSouth(); }
105  bool isHookEast() { return rawGetThingType()->isHookEast(); }
106  bool isRotateable() { return rawGetThingType()->isRotateable(); }
107  bool hasLight() { return rawGetThingType()->hasLight(); }
108  bool isDontHide() { return rawGetThingType()->isDontHide(); }
111  bool hasElevation() { return rawGetThingType()->hasElevation(); }
115  bool hasLensHelp() { return rawGetThingType()->hasLensHelp(); }
116  bool isFullGround() { return rawGetThingType()->isFullGround(); }
117  bool isIgnoreLook() { return rawGetThingType()->isIgnoreLook(); }
118  bool isCloth() { return rawGetThingType()->isCloth(); }
119  bool isMarketable() { return rawGetThingType()->isMarketable(); }
120  bool isUsable() { return rawGetThingType()->isUsable(); }
121  bool isWrapable() { return rawGetThingType()->isWrapable(); }
122  bool isUnwrapable() { return rawGetThingType()->isUnwrapable(); }
123  bool isTopEffect() { return rawGetThingType()->isTopEffect(); }
125 
126  virtual void onPositionChange(const Position& /*newPos*/, const Position& /*oldPos*/) { }
127  virtual void onAppear() { }
128  virtual void onDisappear() { }
129 
130 protected:
133 };
134 #pragma pack(pop)
135 
136 #endif
137 
Thing::isTranslucent
bool isTranslucent()
Definition: thing.h:109
Thing::isFullGround
bool isFullGround()
Definition: thing.h:116
Thing::isWritableOnce
bool isWritableOnce()
Definition: thing.h:95
Thing::isWritable
bool isWritable()
Definition: thing.h:93
Thing::isWrapable
bool isWrapable()
Definition: thing.h:121
Thing::Thing
Thing()
Definition: thing.cpp:31
Thing::isMissile
virtual bool isMissile()
Definition: thing.h:53
thingtypemanager.h
ThingType::isWritable
bool isWritable()
Definition: thingtype.h:172
Thing::getMinimapColor
int getMinimapColor()
Definition: thing.h:81
Thing::blockProjectile
bool blockProjectile()
Definition: thing.h:100
ThingType::isHookEast
bool isHookEast()
Definition: thingtype.h:184
ThingType::isWritableOnce
bool isWritableOnce()
Definition: thingtype.h:174
Thing::getElevation
int getElevation()
Definition: thing.h:84
ThingType::getHeight
int getHeight()
Definition: thingtype.h:143
Thing::isOnBottom
bool isOnBottom()
Definition: thing.h:87
Thing::hasElevation
bool hasElevation()
Definition: thing.h:111
Thing::isHangable
bool isHangable()
Definition: thing.h:103
Thing::hasLight
bool hasLight()
Definition: thing.h:107
Thing::isCloth
bool isCloth()
Definition: thing.h:118
Thing::getTile
const TilePtr & getTile()
Definition: thing.cpp:62
ThingType::getMinimapColor
int getMinimapColor()
Definition: thingtype.h:160
ThingType::isHookSouth
bool isHookSouth()
Definition: thingtype.h:183
Thing::getLight
Light getLight()
Definition: thing.h:80
Thing::~Thing
virtual ~Thing()
Definition: thing.h:37
ThingType::isUsable
bool isUsable()
Definition: thingtype.h:199
Thing::isIgnoreLook
bool isIgnoreLook()
Definition: thing.h:117
Thing::setId
virtual void setId(uint32)
Definition: thing.h:41
Thing::getMarketData
MarketData getMarketData()
Definition: thing.h:124
Thing::isChargeable
bool isChargeable()
Definition: thing.h:94
ThingType::isSplash
bool isSplash()
Definition: thingtype.h:176
Thing::isContainer
bool isContainer()
Definition: thing.h:89
Thing::isHookEast
bool isHookEast()
Definition: thing.h:105
Thing::isNotMoveable
bool isNotMoveable()
Definition: thing.h:99
ThingType::getElevation
int getElevation()
Definition: thingtype.h:155
Thing::isHookSouth
bool isHookSouth()
Definition: thing.h:104
Thing::onAppear
virtual void onAppear()
Definition: thing.h:127
ThingType::getSize
Size getSize()
Definition: thingtype.h:141
Thing::isRotateable
bool isRotateable()
Definition: thing.h:106
uint32
uint32_t uint32
Definition: types.h:35
ThingType::getMaxTextLength
int getMaxTextLength()
Definition: thingtype.h:158
Thing::getThingType
virtual const ThingTypePtr & getThingType()
Definition: thing.cpp:88
Thing::getAnimator
AnimatorPtr getAnimator()
Definition: thing.h:77
ThingType::isMultiUse
bool isMultiUse()
Definition: thingtype.h:171
Thing::isUnwrapable
bool isUnwrapable()
Definition: thing.h:122
Thing::getAnimationPhases
int getAnimationPhases()
Definition: thing.h:76
Thing::isOnTop
bool isOnTop()
Definition: thing.h:88
ThingType::hasLight
bool hasLight()
Definition: thingtype.h:186
Thing::isLyingCorpse
bool isLyingCorpse()
Definition: thing.h:112
ThingType::isLyingCorpse
bool isLyingCorpse()
Definition: thingtype.h:191
ThingType::getWidth
int getWidth()
Definition: thingtype.h:142
ThingType::getLight
Light getLight()
Definition: thingtype.h:159
Thing::isPlayer
virtual bool isPlayer()
Definition: thing.h:57
Thing::getGroundSpeed
int getGroundSpeed()
Definition: thing.h:78
ThingType::getAnimationPhases
int getAnimationPhases()
Definition: thingtype.h:150
ThingType::getMarketData
MarketData getMarketData()
Definition: thingtype.h:163
ThingType::isOnTop
bool isOnTop()
Definition: thingtype.h:167
ThingType::isNotPathable
bool isNotPathable()
Definition: thingtype.h:180
Thing::isFluidContainer
bool isFluidContainer()
Definition: thing.h:96
Thing
Definition: thing.h:33
ThingType::isOnBottom
bool isOnBottom()
Definition: thingtype.h:166
ThingType::isTranslucent
bool isTranslucent()
Definition: thingtype.h:188
LightView
Definition: lightview.h:37
Thing::getNumPatternX
int getNumPatternX()
Definition: thing.h:73
luaobject.h
Thing::isNotWalkable
bool isNotWalkable()
Definition: thing.h:98
Thing::m_position
Position m_position
Definition: thing.h:131
uint16
uint16_t uint16
Definition: types.h:36
Thing::getLensHelp
int getLensHelp()
Definition: thing.h:82
ThingType::isFluidContainer
bool isFluidContainer()
Definition: thingtype.h:175
ThingType::getNumPatternX
int getNumPatternX()
Definition: thingtype.h:147
ThingType::hasLensHelp
bool hasLensHelp()
Definition: thingtype.h:194
Thing::isPickupable
bool isPickupable()
Definition: thing.h:102
Thing::getDisplacementX
virtual int getDisplacementX()
Definition: thing.h:69
Thing::draw
virtual void draw(const Point &, float, bool, LightView *=nullptr)
Definition: thing.h:39
Thing::isSplash
bool isSplash()
Definition: thing.h:97
declarations.h
ThingType::isRotateable
bool isRotateable()
Definition: thingtype.h:185
ThingType::isDontHide
bool isDontHide()
Definition: thingtype.h:187
Thing::onPositionChange
virtual void onPositionChange(const Position &, const Position &)
Definition: thing.h:126
ThingType::blockProjectile
bool blockProjectile()
Definition: thingtype.h:179
Thing::isGroundBorder
bool isGroundBorder()
Definition: thing.h:86
Thing::hasMiniMapColor
bool hasMiniMapColor()
Definition: thing.h:114
Thing::isCreature
virtual bool isCreature()
Definition: thing.h:54
ThingType::getGroundSpeed
int getGroundSpeed()
Definition: thingtype.h:157
ThingType::isTopEffect
bool isTopEffect()
Definition: thingtype.h:202
Position
Definition: position.h:33
Thing::isLocalPlayer
virtual bool isLocalPlayer()
Definition: thing.h:58
Thing::onDisappear
virtual void onDisappear()
Definition: thing.h:128
Thing::isMarketable
bool isMarketable()
Definition: thing.h:119
Thing::getNumPatternY
int getNumPatternY()
Definition: thing.h:74
Thing::hasLensHelp
bool hasLensHelp()
Definition: thing.h:115
ThingType::isWrapable
bool isWrapable()
Definition: thingtype.h:200
ThingType::getDisplacement
Point getDisplacement()
Definition: thingtype.h:152
ThingType::isForceUse
bool isForceUse()
Definition: thingtype.h:170
Thing::isMonster
virtual bool isMonster()
Definition: thing.h:56
ThingType::isAnimateAlways
bool isAnimateAlways()
Definition: thingtype.h:192
ThingType::hasMiniMapColor
bool hasMiniMapColor()
Definition: thingtype.h:193
ThingType::isFullGround
bool isFullGround()
Definition: thingtype.h:195
ThingType
Definition: thingtype.h:123
Thing::rawGetThingType
virtual ThingType * rawGetThingType()
Definition: thing.cpp:93
Thing::getId
virtual uint32 getId()
Definition: thing.h:44
ThingType::getLensHelp
int getLensHelp()
Definition: thingtype.h:161
ThingType::getAnimator
AnimatorPtr getAnimator()
Definition: thingtype.h:151
ThingType::isStackable
bool isStackable()
Definition: thingtype.h:169
ThingType::isPickupable
bool isPickupable()
Definition: thingtype.h:181
Thing::getClothSlot
int getClothSlot()
Definition: thing.h:83
Thing::isAnimateAlways
bool isAnimateAlways()
Definition: thing.h:113
Thing::isAnimatedText
virtual bool isAnimatedText()
Definition: thing.h:59
Thing::getDisplacementY
virtual int getDisplacementY()
Definition: thing.h:70
Thing::getStackPos
int getStackPos()
Definition: thing.cpp:76
ThingType::isChargeable
bool isChargeable()
Definition: thingtype.h:173
Thing::getSize
Size getSize()
Definition: thing.h:65
Thing::hasDisplacement
bool hasDisplacement()
Definition: thing.h:110
Thing::isTopEffect
bool isTopEffect()
Definition: thing.h:123
ThingType::isNotWalkable
bool isNotWalkable()
Definition: thingtype.h:177
ThingType::isContainer
bool isContainer()
Definition: thingtype.h:168
Thing::getDisplacement
virtual Point getDisplacement()
Definition: thing.h:68
ThingType::getClothSlot
int getClothSlot()
Definition: thingtype.h:162
Thing::getNumPatternZ
int getNumPatternZ()
Definition: thing.h:75
stdext::shared_object_ptr< Tile >
Thing::m_datId
uint16 m_datId
Definition: thing.h:132
ThingType::isGround
bool isGround()
Definition: thingtype.h:164
ThingType::isHangable
bool isHangable()
Definition: thingtype.h:182
Thing::getStackPriority
int getStackPriority()
Definition: thing.cpp:46
ThingType::hasDisplacement
bool hasDisplacement()
Definition: thingtype.h:189
Thing::getExactSize
virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
Definition: thing.h:71
ThingType::isMarketable
bool isMarketable()
Definition: thingtype.h:198
ThingType::isNotMoveable
bool isNotMoveable()
Definition: thingtype.h:178
ThingType::isCloth
bool isCloth()
Definition: thingtype.h:197
Thing::isNotPathable
bool isNotPathable()
Definition: thing.h:101
Thing::isDontHide
bool isDontHide()
Definition: thing.h:108
Thing::getMaxTextLength
int getMaxTextLength()
Definition: thing.h:79
MarketData
Definition: thingtype.h:108
Light
Definition: thingtype.h:117
Thing::getLayers
int getLayers()
Definition: thing.h:72
Thing::isNpc
virtual bool isNpc()
Definition: thing.h:55
Thing::getHeight
int getHeight()
Definition: thing.h:67
Thing::isForceUse
bool isForceUse()
Definition: thing.h:91
ThingType::hasElevation
bool hasElevation()
Definition: thingtype.h:190
Thing::isStaticText
virtual bool isStaticText()
Definition: thing.h:60
Thing::getParentContainer
ContainerPtr getParentContainer()
Definition: thing.cpp:67
ThingType::isGroundBorder
bool isGroundBorder()
Definition: thingtype.h:165
Thing::setPosition
void setPosition(const Position &position)
Definition: thing.cpp:36
Thing::isItem
virtual bool isItem()
Definition: thing.h:51
Thing::isGround
bool isGround()
Definition: thing.h:85
TPoint< int >
thingtype.h
Thing::getPosition
Position getPosition()
Definition: thing.h:45
LuaObject
LuaObject, all script-able classes have it as base.
Definition: luaobject.h:30
Thing::getWidth
int getWidth()
Definition: thing.h:66
ThingType::getDisplacementX
int getDisplacementX()
Definition: thingtype.h:153
ThingType::isIgnoreLook
bool isIgnoreLook()
Definition: thingtype.h:196
Thing::isMultiUse
bool isMultiUse()
Definition: thing.h:92
ThingType::getLayers
int getLayers()
Definition: thingtype.h:146
TSize< int >
ThingType::getDisplacementY
int getDisplacementY()
Definition: thingtype.h:154
Thing::isUsable
bool isUsable()
Definition: thing.h:120
Thing::isEffect
virtual bool isEffect()
Definition: thing.h:52
ThingType::getNumPatternZ
int getNumPatternZ()
Definition: thingtype.h:149
ThingType::getExactSize
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
Definition: thingtype.cpp:557
Thing::isStackable
bool isStackable()
Definition: thing.h:90
ThingType::isUnwrapable
bool isUnwrapable()
Definition: thingtype.h:201
ThingType::getNumPatternY
int getNumPatternY()
Definition: thingtype.h:148