thing.h

main 158 lines · 7.5 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1/*
2 * Copyright (c) 2010-2017 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"
29#include <framework/luaengine/luaobject.h>
30#include <framework/graphics/drawqueue.h>
31
32// @bindclass
33#pragma pack(push,1) // disable memory alignment
34class Thing : public LuaObject
35{
36public:
37 Thing();
38 virtual ~Thing();
39
40 virtual void draw(const Point& dest, bool animate = true, LightView* lightView = nullptr) { }
41
42 virtual void setId(uint32 id) { }
43 void setPosition(const Position& position);
44
45 virtual uint32 getId() { return 0; }
46 Position getPosition() { return m_position; }
47 int getStackPriority();
48 virtual const TilePtr& getTile();
49 ContainerPtr getParentContainer();
50 int getStackPos();
51
52 void setMarked(const std::string& color) {
53 if (color.empty()) {
54 m_marked = false;
55 return;
56 }
57 m_marked = true;
58 m_markedColor = Color(color);
59 }
60 Color updatedMarkedColor();
61
62 virtual bool isItem() { return false; }
63 virtual bool isEffect() { return false; }
64 virtual bool isMissile() { return false; }
65 virtual bool isCreature() { return false; }
66 virtual bool isNpc() { return false; }
67 virtual bool isMonster() { return false; }
68 virtual bool isPlayer() { return false; }
69 virtual bool isLocalPlayer() { return false; }
70 virtual bool isAnimatedText() { return false; }
71 virtual bool isStaticText() { return false; }
72
73 // type shortcuts
74 virtual const ThingTypePtr& getThingType();
75 virtual ThingType *rawGetThingType();
76 Size getSize() { return rawGetThingType()->getSize(); }
77 int getWidth() { return rawGetThingType()->getWidth(); }
78 int getHeight() { return rawGetThingType()->getHeight(); }
79 virtual Point getDisplacement() { return rawGetThingType()->getDisplacement(); }
80 virtual int getDisplacementX() { return rawGetThingType()->getDisplacementX(); }
81 virtual int getDisplacementY() { return rawGetThingType()->getDisplacementY(); }
82 virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase) { return rawGetThingType()->getExactSize(layer, xPattern, yPattern, zPattern, animationPhase); }
83 int getLayers() { return rawGetThingType()->getLayers(); }
84 int getNumPatternX() { return rawGetThingType()->getNumPatternX(); }
85 int getNumPatternY() { return rawGetThingType()->getNumPatternY(); }
86 int getNumPatternZ() { return rawGetThingType()->getNumPatternZ(); }
87 int getAnimationPhases() { return rawGetThingType()->getAnimationPhases(); }
88 AnimatorPtr getAnimator() { return rawGetThingType()->getAnimator(); }
89 AnimatorPtr getIdleAnimator() { return rawGetThingType()->getIdleAnimator(); }
90 int getGroundSpeed() { return rawGetThingType()->getGroundSpeed(); }
91 int getMaxTextLength() { return rawGetThingType()->getMaxTextLength(); }
92 Light getLight() { return rawGetThingType()->getLight(); }
93 int getMinimapColor() { return rawGetThingType()->getMinimapColor(); }
94 int getLensHelp() { return rawGetThingType()->getLensHelp(); }
95 int getClothSlot() { return rawGetThingType()->getClothSlot(); }
96 int getElevation() { return rawGetThingType()->getElevation(); }
97 bool isGround() { return rawGetThingType()->isGround(); }
98 bool isGroundBorder() { return rawGetThingType()->isGroundBorder(); }
99 bool isOnBottom() { return rawGetThingType()->isOnBottom(); }
100 bool isOnTop() { return rawGetThingType()->isOnTop(); }
101 bool isContainer() { return rawGetThingType()->isContainer(); }
102 bool isStackable() { return rawGetThingType()->isStackable(); }
103 bool isForceUse() { return rawGetThingType()->isForceUse(); }
104 bool isMultiUse() { return rawGetThingType()->isMultiUse(); }
105 bool isWritable() { return rawGetThingType()->isWritable(); }
106 bool isChargeable() { return rawGetThingType()->isChargeable(); }
107 bool isWritableOnce() { return rawGetThingType()->isWritableOnce(); }
108 bool isFluidContainer() { return rawGetThingType()->isFluidContainer(); }
109 bool isSplash() { return rawGetThingType()->isSplash(); }
110 bool isNotWalkable() { return rawGetThingType()->isNotWalkable(); }
111 bool isNotMoveable() { return rawGetThingType()->isNotMoveable(); }
112 bool blockProjectile() { return rawGetThingType()->blockProjectile(); }
113 bool isNotPathable() { return rawGetThingType()->isNotPathable(); }
114 bool isPickupable() { return rawGetThingType()->isPickupable(); }
115 bool isHangable() { return rawGetThingType()->isHangable(); }
116 bool isHookSouth() { return rawGetThingType()->isHookSouth(); }
117 bool isHookEast() { return rawGetThingType()->isHookEast(); }
118 bool isRotateable() { return rawGetThingType()->isRotateable(); }
119 bool hasLight() { return rawGetThingType()->hasLight(); }
120 bool isDontHide() { return rawGetThingType()->isDontHide(); }
121 bool isTranslucent() { return rawGetThingType()->isTranslucent(); }
122 bool hasDisplacement() { return rawGetThingType()->hasDisplacement(); }
123 bool hasElevation() { return rawGetThingType()->hasElevation(); }
124 bool isLyingCorpse() { return rawGetThingType()->isLyingCorpse(); }
125 bool isAnimateAlways() { return rawGetThingType()->isAnimateAlways(); }
126 bool hasMiniMapColor() { return rawGetThingType()->hasMiniMapColor(); }
127 bool hasLensHelp() { return rawGetThingType()->hasLensHelp(); }
128 bool isFullGround() { return rawGetThingType()->isFullGround(); }
129 bool isIgnoreLook() { return rawGetThingType()->isIgnoreLook(); }
130 bool isCloth() { return rawGetThingType()->isCloth(); }
131 bool isMarketable() { return rawGetThingType()->isMarketable(); }
132 bool isUsable() { return rawGetThingType()->isUsable(); }
133 bool isWrapable() { return rawGetThingType()->isWrapable(); }
134 bool isUnwrapable() { return rawGetThingType()->isUnwrapable(); }
135 bool isTopEffect() { return rawGetThingType()->isTopEffect(); }
136 MarketData getMarketData() { return rawGetThingType()->getMarketData(); }
137
138 void hide() { m_hidden = true; }
139 void show() { m_hidden = false; }
140 void setHidden(bool value) { m_hidden = value; }
141 bool isHidden() { return m_hidden; }
142
143 virtual void onPositionChange(const Position& newPos, const Position& oldPos) { }
144 virtual void onAppear() { }
145 virtual void onDisappear() { }
146
147protected:
148 Position m_position;
149 uint16 m_datId;
150 bool m_marked = false;
151 bool m_hidden = false;
152 Color m_markedColor;
153};
154#pragma pack(pop)
155
156#endif
157
158
Top