complexitem.h

main 197 lines · 5.2 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_CONTAINER_H_
19#define RME_CONTAINER_H_
20
21#include "position.h"
22#include "item.h"
23#include "outfit.h"
24
25#pragma pack(1)
26
27struct OTBM_TeleportDestination {
28 uint16_t x;
29 uint16_t y;
30 uint8_t z;
31};
32
33#pragma pack()
34
35class Container : public Item {
36public:
37 Container(const uint16_t type);
38 ~Container();
39
40 Item* deepCopy() const;
41 Item* getItem(size_t index) const;
42
43 size_t getItemCount() const {
44 return contents.size();
45 }
46 size_t getVolume() const {
47 return g_items[id].volume;
48 }
49
50 ItemVector& getVector() {
51 return contents;
52 }
53 double getWeight();
54
55 virtual bool unserializeItemNode_OTBM(const IOMap& maphandle, BinaryNode* node);
56 virtual bool serializeItemNode_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
57 // virtual bool unserializeItemNode_OTMM(const IOMap& maphandle, BinaryNode* node);
58 // virtual bool serializeItemNode_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
59
60protected:
61 ItemVector contents;
62};
63
64class Teleport : public Item {
65public:
66 Teleport(const uint16_t type);
67
68 Item* deepCopy() const;
69
70 virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
71 virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
72 // virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
73 // virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
74
75 int32_t getX() const {
76 return destination.x;
77 }
78 int32_t getY() const {
79 return destination.y;
80 }
81 int32_t getZ() const {
82 return destination.z;
83 }
84
85 Position getDestination() const {
86 return destination;
87 }
88 void setDestination(const Position& position) {
89 destination = position;
90 }
91
92 bool hasDestination() const {
93 return destination != Position();
94 }
95
96protected:
97 // We could've made this public and skip the functions, but that would
98 // make the handling of aid/uid/text different from handling teleports,
99 // which would be weird.
100 Position destination;
101};
102
103class Door : public Item {
104public:
105 Door(const uint16_t type);
106
107 Item* deepCopy() const;
108
109 uint8_t getDoorID() const;
110 void setDoorID(uint8_t id);
111
112 virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
113 virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
114 // virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
115 // virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
116
117 DoorType getDoorType() const;
118 bool isRealDoor() const;
119
120protected:
121 uint8_t doorId;
122};
123
124class Depot : public Item {
125public:
126 Depot(const uint16_t _type);
127
128 Item* deepCopy() const;
129
130 uint8_t getDepotID() const {
131 return depotId;
132 }
133 void setDepotID(uint8_t id) {
134 depotId = id;
135 }
136
137 virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
138 virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
139 // virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
140 // virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
141
142protected:
143 uint8_t depotId;
144};
145
146class Podium : public Item {
147public:
148 Podium(const uint16_t _type);
149
150 Item* deepCopy() const;
151
152 const Outfit& getOutfit() const {
153 return outfit;
154 }
155 void setOutfit(Outfit& newOutfit) {
156 outfit = newOutfit;
157 }
158
159 const uint8_t getDirection() {
160 return direction;
161 }
162 void setDirection(uint8_t newDirection) {
163 direction = newDirection;
164 }
165
166 bool hasShowOutfit() {
167 return showOutfit && outfit.lookType != 0;
168 }
169 bool hasShowMount() {
170 return showMount && outfit.lookMount != 0;
171 }
172 bool hasShowPlatform() {
173 return showPlatform;
174 }
175
176 void setShowOutfit(bool newState) {
177 showOutfit = newState;
178 }
179 void setShowMount(bool newState) {
180 showMount = newState;
181 }
182 void setShowPlatform(bool newState) {
183 showPlatform = newState;
184 }
185
186 virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
187 virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
188
189protected:
190 Outfit outfit;
191 uint8_t direction;
192 bool showOutfit = true;
193 bool showMount = true;
194 bool showPlatform = true;
195};
196#endif
197
Top