forked from OTAcademy/RME
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomplexitem.cpp
More file actions
115 lines (99 loc) · 2.67 KB
/
complexitem.cpp
File metadata and controls
115 lines (99 loc) · 2.67 KB
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
//////////////////////////////////////////////////////////////////////
// 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/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "complexitem.h"
#include "iomap.h"
// Container
Container::Container(const uint16_t type) :
Item(type, 0) {
////
}
Container::~Container() {
for (Item* item : contents) {
delete item;
}
}
Item* Container::deepCopy() const {
Item* copy = Item::deepCopy();
Container* copyContainer = dynamic_cast<Container*>(copy);
if (copyContainer) {
for (Item* item : contents) {
copyContainer->contents.push_back(item->deepCopy());
}
}
return copy;
}
Item* Container::getItem(size_t index) const {
if (index < contents.size()) {
return contents[index];
}
return nullptr;
}
double Container::getWeight() {
return g_items[id].weight;
}
// Teleport
Teleport::Teleport(const uint16_t type) :
Item(type, 0),
destination(0, 0, 0) {
////
}
Item* Teleport::deepCopy() const {
Teleport* copy = static_cast<Teleport*>(Item::deepCopy());
copy->destination = destination;
return copy;
}
// Door
Door::Door(const uint16_t type) :
Item(type, 0),
doorId(0) {
////
}
Item* Door::deepCopy() const {
Door* copy = static_cast<Door*>(Item::deepCopy());
copy->doorId = doorId;
return copy;
}
// Depot
Depot::Depot(const uint16_t type) :
Item(type, 0),
depotId(0) {
////
}
Item* Depot::deepCopy() const {
Item* copy = Item::deepCopy();
Depot* copy_depot = dynamic_cast<Depot*>(copy);
if (copy_depot) {
copy_depot->depotId = depotId;
}
return copy;
}
// Podium
Podium::Podium(const uint16_t type) :
Item(type, 0),
outfit(Outfit()), showOutfit(true), showMount(true), showPlatform(true), direction(0) {
////
}
Item* Podium::deepCopy() const {
Podium* copy = static_cast<Podium*>(Item::deepCopy());
copy->outfit = outfit;
copy->showOutfit = showOutfit;
copy->showMount = showMount;
copy->showPlatform = showPlatform;
copy->direction = direction;
return copy;
}