-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathbuild_info.h
101 lines (91 loc) · 3.02 KB
/
build_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
#pragma once
#include "util.h"
#include "my_containers.h"
#include "cost_info.h"
#include "enum_variant.h"
#include "zones.h"
#include "avatar_info.h"
#include "view_id.h"
#include "furniture_type.h"
#include "tech_id.h"
#include "pretty_archive.h"
#include "furniture_layer.h"
#include "tutorial_highlight.h"
namespace BuildInfoTypes {
struct Furniture {
vector<FurnitureType> SERIAL(types);
CostInfo SERIAL(cost);
bool SERIAL(noCredit) = false;
optional<int> SERIAL(limit);
SERIALIZE_ALL(NAMED(types), OPTION(cost), OPTION(noCredit), NAMED(limit))
};
using DestroyLayers = vector<FurnitureLayer>;
using ImmediateDig = EmptyStruct<struct ImmediateDigTag>;
using Dig = EmptyStruct<struct DigTag>;
using CutTree = EmptyStruct<struct CutTreeTag>;
using FillPit = EmptyStruct<struct FillPitTag>;
using ClaimTile = EmptyStruct<struct ClaimTileTag>;
using UnclaimTile = EmptyStruct<struct UnclaimTileTag>;
using Dispatch = EmptyStruct<struct DispatchTag>;
using ForbidZone = EmptyStruct<struct ForbidZoneTag>;
using Zone = ZoneId;
using PlaceMinion = EmptyStruct<struct PlaceMinionTag>;
using PlaceItem = EmptyStruct<struct PlaceItemTag>;
struct BuildType;
using Chain = vector<BuildType>;
#define VARIANT_TYPES_LIST\
X(Furniture, 0)\
X(ClaimTile, 1)\
X(UnclaimTile, 2)\
X(DestroyLayers, 3)\
X(Dig, 4)\
X(CutTree, 5)\
X(Dispatch, 6)\
X(ForbidZone, 7)\
X(PlaceMinion, 8)\
X(ImmediateDig, 9)\
X(PlaceItem, 10)\
X(Zone, 11)\
X(Chain, 12)\
X(FillPit, 13)
#define VARIANT_NAME BuildType
#include "gen_variant.h"
#include "gen_variant_serialize.h"
#define DEFAULT_ELEM "Chain"
inline
#include "gen_variant_serialize_pretty.h"
#undef DEFAULT_ELEM
#undef VARIANT_TYPES_LIST
#undef VARIANT_NAME
}
struct BuildInfo {
using DungeonLevel = int;
MAKE_VARIANT(Requirement, TechId, DungeonLevel);
static string getRequirementText(Requirement);
static bool meetsRequirement(const Collective*, Requirement);
bool canSelectRectangle() const;
BuildInfoTypes::BuildType SERIAL(type);
string SERIAL(name);
string SERIAL(groupName);
string SERIAL(help);
optional<Keybinding> SERIAL(key) = none;
vector<Requirement> SERIAL(requirements);
bool SERIAL(hotkeyOpensGroup) = false;
optional<TutorialHighlight> SERIAL(tutorialHighlight);
bool SERIAL(isBuilding) = false;
template <class Archive>
void serializeImpl(Archive& ar, const unsigned int) {
ar(NAMED(type), NAMED(name), NAMED(groupName), OPTION(help), NAMED(key), OPTION(requirements), OPTION(hotkeyOpensGroup), NAMED(tutorialHighlight), OPTION(isBuilding));
}
template <class Archive>
void serialize(Archive& ar1, const unsigned int v) {
serializeImpl(ar1, v);
}
void serialize(PrettyInputArchive& ar1, const unsigned int v) {
serializeImpl(ar1, v);
ar1(endInput());
if (groupName.empty())
ar1.error("Group name for \"" + name + "\" is empty.");
}
};
static_assert(std::is_nothrow_move_constructible<BuildInfo>::value, "T should be noexcept MoveConstructible");