-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCvUnitClasses.h
282 lines (251 loc) · 8.24 KB
/
CvUnitClasses.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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/* -------------------------------------------------------------------------------------------------------
© 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games.
Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software
and their respective logos are all trademarks of Take-Two interactive Software, Inc.
All other marks and trademarks are the property of their respective owners.
All rights reserved.
------------------------------------------------------------------------------------------------------- */
#pragma once
#ifndef CIV5_UNIT_CLASSES_H
#define CIV5_UNIT_CLASSES_H
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CLASS: CvUnitEntry
//! \brief A single entry from the UnitInfo XML file
//
//! Key Attributes:
//! - Used to be called CvUnitInfo
//! - Populated from XML\GameInfo\CIV5UnitInfos.xml
//! - Array of these contained in CvUnitXMLEntries class
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class CvUnitEntry: public CvBaseInfo
{
public:
CvUnitEntry(void);
~CvUnitEntry(void);
virtual bool CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility);
// Accessor Functions (Non-Arrays)
int GetProductionCost() const;
int GetHurryCostModifier() const;
int GetAdvancedStartCost() const;
int GetMinAreaSize() const;
int GetMoves() const;
bool IsImmobile() const;
int GetBaseSightRange() const;
int GetRange() const;
int GetAirUnitCap() const;
int GetNukeDamageLevel() const;
int GetWorkRate() const;
int GetNumFreeTechs () const;
int GetBaseHurry() const;
int GetHurryMultiplier() const;
bool IsRushBuilding() const;
int GetBaseGold() const;
int GetNumGoldPerEra() const;
bool IsSpreadReligion() const;
bool IsReligious() const;
int GetCombat() const;
void SetCombat(int iNum);
int GetCombatLimit() const;
int GetRangedCombat() const;
int GetRangedCombatLimit() const;
int GetXPValueAttack() const;
int GetXPValueDefense() const;
int GetSpecialCargo() const;
int GetDomainCargo() const;
int GetConscriptionValue() const;
int GetExtraMaintenanceCost() const;
bool IsNoMaintenance() const;
int GetUnhappiness() const;
int GetUnitClassType() const;
int GetSpecialUnitType() const;
int GetUnitCaptureClassType() const;
int GetUnitCombatType() const;
int GetDomainType() const;
int GetCivilianAttackPriority() const;
int GetDefaultUnitAIType() const;
int GetPrereqAndTech() const;
int GetObsoleteTech() const;
int GetGoodyHutUpgradeUnitClass() const;
int GetGroupSize() const; // the initial number of individuals in the unit group
int GetGroupDefinitions() const; // the number of UnitMeshGroups for this unit
int GetMeleeWaveSize() const;
int GetRangedWaveSize() const;
int GetNumUnitNames() const;
int GetCommandType() const;
void SetCommandType(int iNewType);
bool IsFoodProduction() const;
bool IsNoBadGoodies() const;
bool IsRivalTerritory() const;
bool IsMilitarySupport() const;
bool IsMilitaryProduction() const;
bool IsPillage() const;
bool IsFound() const;
bool IsFoundAbroad() const;
int GetCultureBombRadius() const;
int GetGoldenAgeTurns() const;
bool IsIgnoreBuildingDefense() const;
bool IsPrereqResources() const;
bool IsMechUnit() const;
bool IsSuicide() const;
bool IsCaptureWhileEmbarked() const;
bool IsRangeAttackOnlyInDomain() const;
float GetUnitMaxSpeed() const;
float GetUnitPadTime() const;
int GetProjectPrereq() const;
int GetSpaceshipProject() const;
int GetLeaderPromotion() const;
int GetLeaderExperience() const;
const char* GetUnitArtInfoTag() const;
const bool GetUnitArtInfoCulturalVariation() const;
const bool GetUnitArtInfoEraVariation() const;
int GetUnitFlagIconOffset() const;
int GetUnitPortraitOffset() const;
const char* GetUnitNames(int i) const;
// Accessor Functions (Arrays)
int GetPrereqAndTechs(int i) const;
int GetResourceQuantityRequirement(int i) const;
int GetBuildingProductionModifier(BuildingTypes eBuilding) const;
int GetProductionTraits(int i) const;
int GetFlavorValue(int i) const;
int GetUnitGroupRequired(int i) const;
bool GetUpgradeUnitClass(int i) const;
bool GetUnitAIType(int i) const;
bool GetNotUnitAIType(int i) const;
bool GetBuilds(int i) const;
bool GetGreatPeoples(int i) const;
bool GetBuildings(int i) const;
bool GetBuildingClassRequireds(int i) const;
bool GetFreePromotions(int i) const;
// Derived fields (not in XML)
int GetCargoSpace() const; // (from free promotions)
int GetPower() const;
void DoUpdatePower();
UnitMoveRate GetMoveRate(int numHexes) const;
private:
int m_iProductionCost;
int m_iHurryCostModifier;
int m_iAdvancedStartCost;
int m_iMinAreaSize;
int m_iMoves;
bool m_bMoves;
int m_iBaseSightRange;
int m_iRange;
int m_iAirUnitCap;
int m_iNukeDamageLevel;
int m_iWorkRate;
int m_iNumFreeTechs;
int m_iBaseHurry;
int m_iHurryMultiplier;
bool m_bRushBuilding;
int m_iBaseGold;
int m_iNumGoldPerEra;
bool m_bSpreadReligion;
bool m_bIsReligious;
int m_iCombat;
int m_iCombatLimit;
int m_iRangedCombat;
int m_iRangedCombatLimit;
int m_iXPValueAttack;
int m_iXPValueDefense;
int m_iSpecialCargo;
int m_iDomainCargo;
int m_iConscriptionValue;
int m_iExtraMaintenanceCost;
bool m_bNoMaintenance;
int m_iUnhappiness;
int m_iUnitClassType;
int m_iSpecialUnitType;
int m_iUnitCaptureClassType;
int m_iUnitCombatType;
int m_iDomainType;
int m_iCivilianAttackPriority;
int m_iDefaultUnitAIType;
int m_iPrereqAndTech;
int m_iObsoleteTech;
int m_iGoodyHutUpgradeUnitClass;
int m_iGroupSize;
int m_iGroupDefinitions;
int m_iUnitMeleeWaveSize;
int m_iUnitRangedWaveSize;
int m_iNumUnitNames;
int m_iCommandType;
int m_iLeaderExperience;
bool m_bFoodProduction;
bool m_bNoBadGoodies;
bool m_bRivalTerritory;
bool m_bMilitarySupport;
bool m_bMilitaryProduction;
bool m_bPillage;
bool m_bFound;
bool m_bFoundAbroad;
int m_iCultureBombRadius;
int m_iGoldenAgeTurns;
bool m_bIgnoreBuildingDefense;
bool m_bPrereqResources;
bool m_bMechanized;
bool m_bSuicide;
bool m_bCaptureWhileEmbarked;
bool m_bRangeAttackOnlyInDomain;
int m_iProjectPrereq;
int m_iSpaceshipProject;
int m_iLeaderPromotion;
// This is not loaded from XML, but cached so we don't have to recalculate every time
int m_iCachedPower;
int m_iUnitFlagIconOffset;
int m_iUnitPortraitOffset;
CvString m_strUnitArtInfoTag;
bool m_bUnitArtInfoCulturalVariation;
bool m_bUnitArtInfoEraVariation;
UnitMoveRate m_unitMoveRate[12];
// Arrays
int* m_piPrereqAndTechs;
int* m_piResourceQuantityRequirements;
int* m_piProductionTraits;
int* m_piFlavorValue;
int* m_piUnitGroupRequired;
int* m_piProductionModifierBuildings;
bool* m_pbUpgradeUnitClass;
bool* m_pbUnitAIType;
bool* m_pbNotUnitAIType;
bool* m_pbBuilds;
bool* m_pbGreatPeoples;
bool* m_pbBuildings;
bool* m_pbBuildingClassRequireds;
bool* m_pbFreePromotions;
CvString* m_paszEarlyArtDefineTags;
CvString* m_paszLateArtDefineTags;
CvString* m_paszMiddleArtDefineTags;
CvString* m_paszUnitNames;
};
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CLASS: CvUnitXMLEntries
//! \brief Game-wide information about units
//
//! Key Attributes:
//! - Plan is it will be contained in CvGameRules object within CvGame class
//! - Populated from XML\GameInfo\CIV5UnitInfos.xml
//! - Contains an array of CvUnitEntry from the above XML file
//! - One instance for the entire game
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class CvUnitXMLEntries
{
public:
CvUnitXMLEntries(void);
~CvUnitXMLEntries(void);
// Accessor functions
std::vector<CvUnitEntry*>& GetUnitEntries();
int GetNumUnits();
_Ret_maybenull_ CvUnitEntry *GetEntry(int index);
void DeleteArray();
private:
std::vector<CvUnitEntry*> m_paUnitEntries;
};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Helper Functions to serialize arrays of variable length (based on number of units defined in game)
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
namespace UnitArrayHelpers
{
void Read(FDataStream &kStream, int *paiUnitArray);
void Write(FDataStream &kStream, int *paiUnitArray, int iArraySize);
}
#endif //CIV5_UNIT_CLASSES_H