-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathimmigrant_info.h
186 lines (151 loc) · 4.82 KB
/
immigrant_info.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
#pragma once
#include "stdafx.h"
#include "util.h"
#include "cost_info.h"
#include "minion_trait.h"
#include "enemy_factory.h"
#include "sound.h"
#include "tutorial_state.h"
#include "furniture_type.h"
#include "tech_id.h"
#include "pretty_archive.h"
#include "sunlight_info.h"
#include "keybinding.h"
#include "achievement_id.h"
class ContentFactory;
struct SpecialTraitInfo;
class SpecialTrait;
MAKE_VARIANT2(AttractionType, FurnitureType, ItemIndex);
struct AttractionInfo {
AttractionInfo(int amountClaimed, vector<AttractionType>);
AttractionInfo(int amountClaimed, AttractionType);
SERIALIZATION_DECL(AttractionInfo)
static TString getAttractionName(const ContentFactory*, const AttractionType&, int count);
int SERIAL(amountClaimed) = 0;
vector<AttractionType> SERIAL(types);
};
struct ExponentialCost {
CostInfo SERIAL(base);
int SERIAL(numToDoubleCost);
int SERIAL(numFree);
SERIALIZE_ALL(base, numToDoubleCost, numFree)
};
struct Pregnancy { SERIALIZE_EMPTY() };
class Collective;
class Game;
struct RecruitmentInfo {
vector<EnemyId> SERIAL(enemyId);
int SERIAL(minPopulation);
vector<Collective*> findEnemy(Game*) const;
vector<Creature*> getAvailableRecruits(Collective*, CreatureId) const;
SERIALIZE_ALL(enemyId, minPopulation)
};
struct TutorialRequirement {
TutorialState SERIAL(state);
SERIALIZE_ALL(state)
};
struct MinTurnRequirement {
GlobalTime SERIAL(turn);
SERIALIZE_ALL(turn)
};
class ImmigrantRequirement;
struct NegateRequirement {
HeapAllocated<ImmigrantRequirement> SERIAL(r);
SERIALIZE_ALL(r)
};
struct ImmigrantFlag {
string SERIAL(value);
SERIALIZE_ALL(value)
};
#define IMMIGRANT_REQUIREMENT_LIST\
X(AttractionInfo, 0)\
X(TechId, 1)\
X(SunlightState, 2)\
X(FurnitureType, 3)\
X(CostInfo, 4)\
X(ExponentialCost, 5)\
X(Pregnancy, 6)\
X(RecruitmentInfo, 7)\
X(TutorialRequirement, 8)\
X(MinTurnRequirement, 9)\
X(NegateRequirement, 10)\
X(ImmigrantFlag, 11)
#define VARIANT_TYPES_LIST IMMIGRANT_REQUIREMENT_LIST
#define VARIANT_NAME ImmigrantRequirement
#include "gen_variant.h"
#include "gen_variant_serialize.h"
inline
#include "gen_variant_serialize_pretty.h"
#undef VARIANT_TYPES_LIST
#undef VARIANT_NAME
struct OutsideTerritory { SERIALIZE_EMPTY() };
struct InsideTerritory { SERIALIZE_EMPTY() };
struct NearLeader { SERIALIZE_EMPTY() };
#define VARIANT_TYPES_LIST\
X(FurnitureType, 0)\
X(OutsideTerritory, 1)\
X(InsideTerritory, 2)\
X(NearLeader, 3)\
X(Pregnancy, 4)
#define VARIANT_NAME SpawnLocation
#include "gen_variant.h"
#include "gen_variant_serialize.h"
inline
#include "gen_variant_serialize_pretty.h"
#undef VARIANT_TYPES_LIST
#undef VARIANT_NAME
class ImmigrantInfo {
public:
ImmigrantInfo(CreatureId, EnumSet<MinionTrait>);
ImmigrantInfo(vector<CreatureId>, EnumSet<MinionTrait>);
STRUCT_DECLARATIONS(ImmigrantInfo)
CreatureId getId(int numCreated) const;
CreatureId getNonRandomId(int numCreated) const;
bool isAvailable(int numCreated) const;
const SpawnLocation& getSpawnLocation() const;
Range getGroupSize() const;
int getInitialRecruitment() const;
double getFrequency() const;
bool isPersistent() const;
bool isInvisible() const;
const EnumSet<MinionTrait>& getTraits() const;
optional<int> getLimit() const;
optional<Keybinding> getKeybinding() const;
optional<Sound> getSound() const;
bool isNoAuto() const;
optional<TutorialHighlight> getTutorialHighlight() const;
bool isHiddenInHelp() const;
const vector<SpecialTraitInfo>& getSpecialTraits() const;
ImmigrantInfo& addRequirement(ImmigrantRequirement);
template <typename Visitor>
void visitRequirements(const Visitor& visitor) const {
for (auto& requirement : requirements) {
requirement.type.template visit<void>(visitor);
}
}
SERIALIZATION_DECL(ImmigrantInfo)
struct RequirementInfo {
double SERIAL(candidateProb); // chance of candidate immigrant still generated if this requirement is not met.
ImmigrantRequirement SERIAL(type);
SERIALIZE_ALL(NAMED(candidateProb), NAMED(type))
};
vector<RequirementInfo> SERIAL(requirements);
bool SERIAL(stripEquipment) = true;
optional<AchievementId> SERIAL(acceptedAchievement);
private:
vector<CreatureId> SERIAL(ids);
optional<double> SERIAL(frequency);
EnumSet<MinionTrait> SERIAL(traits);
SpawnLocation SERIAL(spawnLocation) = OutsideTerritory{};
Range SERIAL(groupSize) = Range(1, 2);
int SERIAL(initialRecruitment) = 0;
bool SERIAL(consumeIds) = false;
optional<Keybinding> SERIAL(keybinding);
optional<Sound> SERIAL(sound);
bool SERIAL(noAuto) = false;
bool SERIAL(invisible) = false;
optional<TutorialHighlight> SERIAL(tutorialHighlight);
bool SERIAL(hiddenInHelp) = false;
vector<SpecialTraitInfo> SERIAL(specialTraits);
};
static_assert(std::is_nothrow_move_constructible<ImmigrantInfo>::value, "T should be noexcept MoveConstructible");