-
Notifications
You must be signed in to change notification settings - Fork 224
/
complexitem.h
124 lines (97 loc) · 4.24 KB
/
complexitem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
// Remere's Map Editor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#ifndef RME_CONTAINER_H_
#define RME_CONTAINER_H_
#include "position.h"
#include "item.h"
#pragma pack(1)
struct OTBM_TeleportDestination
{
uint16_t x;
uint16_t y;
uint8_t z;
};
#pragma pack()
class Container : public Item
{
public:
Container(const uint16_t type);
~Container();
Item* deepCopy() const override;
Container* getContainer() override { return this; }
Item* getItem(size_t index) const;
ItemVector& getVector() noexcept { return contents; }
size_t getItemCount() const noexcept { return contents.size(); }
size_t getVolume() const noexcept { return getItemType().volume; }
double getWeight() noexcept { return getItemType().weight; }
virtual bool unserializeItemNode_OTBM(const IOMap& maphandle, BinaryNode* node);
virtual bool serializeItemNode_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
//virtual bool unserializeItemNode_OTMM(const IOMap& maphandle, BinaryNode* node);
//virtual bool serializeItemNode_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
protected:
ItemVector contents;
};
class Teleport : public Item
{
public:
Teleport(const uint16_t type);
Item* deepCopy() const override;
Teleport* getTeleport() override { return this; }
virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
//virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
//virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
const Position& getDestination() const noexcept { return destination; }
int getX() const noexcept { return destination.x; }
int getY() const noexcept { return destination.y; }
int getZ() const noexcept { return destination.z; }
void setDestination(const Position& position) noexcept { destination = position; }
bool hasDestination() const noexcept { return destination.isValid(); }
protected:
Position destination;
};
class Door : public Item
{
public:
Door(const uint16_t type);
Item* deepCopy() const override;
Door* getDoor() override { return this; }
uint8_t getDoorID() const { return doorId; }
void setDoorID(uint8_t id) { doorId = id; }
virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
//virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
//virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
protected:
uint8_t doorId;
};
class Depot : public Item
{
public:
Depot(const uint16_t _type);
Item* deepCopy() const override;
Depot* getDepot() override { return this; }
uint8_t getDepotID() const { return depotId; }
void setDepotID(uint8_t id) { depotId = id; }
virtual void serializeItemAttributes_OTBM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
virtual bool readItemAttribute_OTBM(const IOMap& maphandle, OTBM_ItemAttribute attr, BinaryNode* node);
//virtual void serializeItemAttributes_OTMM(const IOMap& maphandle, NodeFileWriteHandle& f) const;
//virtual bool readItemAttribute_OTMM(const IOMap& maphandle, OTMM_ItemAttribute attr, BinaryNode* node);
protected:
uint8_t depotId;
};
#endif