Repository navigation
Expand file tree
/
Copy pathArmor.cpp
More file actions
242 lines (219 loc) · 5.34 KB
/
Copy pathArmor.cpp
File metadata and controls
242 lines (219 loc) · 5.34 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
* Copyright 2010-2014 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom 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.
*
* OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Armor.h"
namespace OpenXcom
{
/**
* Creates a blank ruleset for a certain
* type of armor.
* @param type String defining the type.
*/
Armor::Armor(const std::string &type) : _type(type), _spriteSheet(""), _spriteInv(""), _corpseGeo(""), _storeItem(""), _corpseBattle(), _frontArmor(0), _sideArmor(0), _rearArmor(0), _underArmor(0), _drawingRoutine(0), _movementType(MT_WALK), _size(1), _weight(0)
{
for (int i=0; i < DAMAGE_TYPES; i++)
_damageModifier[i] = 1.0f;
}
/**
*
*/
Armor::~Armor()
{
}
/**
* Loads the armor from a YAML file.
* @param node YAML node.
*/
void Armor::load(const YAML::Node &node)
{
_type = node["type"].as<std::string>(_type);
_spriteSheet = node["spriteSheet"].as<std::string>(_spriteSheet);
_spriteInv = node["spriteInv"].as<std::string>(_spriteInv);
if (node["corpseItem"])
{
_corpseBattle.clear();
_corpseBattle.push_back(node["corpseItem"].as<std::string>());
_corpseGeo = _corpseBattle[0];
}
else if (node["corpseBattle"])
{
_corpseBattle = node["corpseBattle"].as< std::vector<std::string> >();
_corpseGeo = _corpseBattle[0];
}
_corpseGeo = node["corpseGeo"].as<std::string>(_corpseGeo);
_storeItem = node["storeItem"].as<std::string>(_storeItem);
_frontArmor = node["frontArmor"].as<int>(_frontArmor);
_sideArmor = node["sideArmor"].as<int>(_sideArmor);
_rearArmor = node["rearArmor"].as<int>(_rearArmor);
_underArmor = node["underArmor"].as<int>(_underArmor);
_drawingRoutine = node["drawingRoutine"].as<int>(_drawingRoutine);
_movementType = (MovementType)node["movementType"].as<int>(_movementType);
_size = node["size"].as<int>(_size);
_weight = node["weight"].as<int>(_weight);
_stats.merge(node["stats"].as<UnitStats>(_stats));
if (const YAML::Node &dmg = node["damageModifier"])
{
for (size_t i = 0; i < dmg.size() && i < DAMAGE_TYPES; ++i)
{
_damageModifier[i] = dmg[i].as<float>();
}
}
_loftempsSet = node["loftempsSet"].as< std::vector<int> >(_loftempsSet);
if (node["loftemps"])
_loftempsSet.push_back(node["loftemps"].as<int>());
}
/**
* Returns the language string that names
* this armor. Each armor has a unique name. Coveralls, Power Suit,...
* @return The armor name.
*/
std::string Armor::getType() const
{
return _type;
}
/**
* Gets the unit's sprite sheet.
* @return The sprite sheet name.
*/
std::string Armor::getSpriteSheet() const
{
return _spriteSheet;
}
/**
* Gets the unit's inventory sprite.
* @return The inventory sprite name.
*/
std::string Armor::getSpriteInventory() const
{
return _spriteInv;
}
/**
* Gets the front armor level.
* @return The front armor level.
*/
int Armor::getFrontArmor() const
{
return _frontArmor;
}
/**
* Gets the side armor level.
* @return The side armor level.
*/
int Armor::getSideArmor() const
{
return _sideArmor;
}
/**
* Gets the rear armor level.
* @return The rear armor level.
*/
int Armor::getRearArmor() const
{
return _rearArmor;
}
/**
* Gets the under armor level.
* @return The under armor level.
*/
int Armor::getUnderArmor() const
{
return _underArmor;
}
/**
* Gets the corpse item used in the Geoscape.
* @return The name of the corpse item.
*/
std::string Armor::getCorpseGeoscape() const
{
return _corpseGeo;
}
/**
* Gets the list of corpse items dropped by the unit
* in the Battlescape (one per unit tile).
* @return The list of corpse items.
*/
const std::vector<std::string> &Armor::getCorpseBattlescape() const
{
return _corpseBattle;
}
/**
* Gets the storage item needed to equip this.
* @return The name of the store item.
*/
std::string Armor::getStoreItem() const
{
return _storeItem;
}
/**
* Gets the drawing routine ID.
* @return The drawing routine ID.
*/
int Armor::getDrawingRoutine() const
{
return _drawingRoutine;
}
/**
* Gets the movement type of this armor.
* Useful for determining whether the armor can fly.
* @return The movement type.
*/
MovementType Armor::getMovementType() const
{
return _movementType;
}
/**
* Gets the size of the unit. Normally this is 1 (small) or 2 (big).
* @return The unit's size.
*/
int Armor::getSize() const
{
return _size;
}
/**
* Gets the damage modifier for a certain damage type.
* @param dt The damageType.
* @return The damage modifier 0->1.
*/
float Armor::getDamageModifier(ItemDamageType dt)
{
return _damageModifier[(int)dt];
}
/** Gets the loftempSet.
* @return The loftempsSet.
*/
std::vector<int> Armor::getLoftempsSet() const
{
return _loftempsSet;
}
/**
* Gets pointer to the armor's stats.
* @return stats Pointer to the armor's stats.
*/
UnitStats *Armor::getStats()
{
return &_stats;
}
/**
* Gets the armor's weight.
* @return the weight of the armor.
*/
int Armor::getWeight()
{
return _weight;
}
}