-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathblueprint.h
216 lines (167 loc) · 5.68 KB
/
blueprint.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
#pragma once
#include "dfhack_shared.h"
#include "room.h"
#include "plan_priorities.h"
#include "stocks.h"
#include "variable_string.h"
#include "json/json.h"
#include <functional>
class AI;
struct room_blueprint;
struct room_base
{
typedef size_t layoutindex_t;
typedef size_t roomindex_t;
typedef size_t placeholderindex_t;
struct furniture_t
{
furniture_t();
bool apply(Json::Value data, std::string & error, bool allow_placeholders = false);
void shift(layoutindex_t layout_start, roomindex_t room_start);
bool check_indexes(layoutindex_t layout_limit, roomindex_t room_limit, std::string & error) const;
bool has_placeholder;
placeholderindex_t placeholder;
layout_type::type type;
df::construction_type construction;
df::tile_dig_designation dig;
df::coord pos;
bool has_target;
layoutindex_t target;
size_t has_users;
bool ignore;
bool makeroom;
bool internal;
bool stairs_special;
variable_string comment;
variable_string::context_t context;
};
struct room_t
{
room_t();
bool apply(Json::Value data, std::string & error, bool allow_placeholders = false);
void shift(layoutindex_t layout_start, roomindex_t room_start);
bool check_indexes(layoutindex_t layout_limit, roomindex_t room_limit, std::string & error) const;
bool has_placeholder;
placeholderindex_t placeholder;
room_type::type type;
corridor_type::type corridor_type;
farm_type::type farm_type;
stockpile_type::type stockpile_type;
nobleroom_type::type nobleroom_type;
outpost_type::type outpost_type;
location_type::type location_type;
cistern_type::type cistern_type;
df::workshop_type workshop_type;
df::furnace_type furnace_type;
variable_string raw_type;
variable_string comment;
df::coord min, max;
std::vector<roomindex_t> accesspath;
std::vector<layoutindex_t> layout;
int32_t level;
int32_t noblesuite;
int32_t queue;
bool has_workshop;
roomindex_t workshop;
std::set<df::stockpile_list> stock_disable;
bool stock_specific1;
bool stock_specific2;
size_t has_users;
bool temporary;
bool outdoor;
bool single_biome;
bool require_walls;
bool require_floor;
int32_t require_grass;
bool require_stone;
bool in_corridor;
bool remove_if_unused;
bool build_when_accessible;
std::map<df::coord, std::map<std::string, std::map<std::string, variable_string>>> exits;
variable_string::context_t context;
std::string blueprint;
df::coord channel_enable;
};
~room_base();
bool apply(Json::Value data, std::string & error, bool allow_placeholders = false);
std::vector<furniture_t *> layout;
std::vector<room_t *> rooms;
};
struct room_template : public room_base
{
room_template(const std::string &, const std::string & name) : name(name), min_placeholders() {}
bool apply(Json::Value data, std::string & error);
const std::string name;
placeholderindex_t min_placeholders;
};
struct room_instance : public room_base
{
room_instance(const std::string & type, const std::string & name) : type(type), name(name), blacklist(), placeholders() {}
~room_instance();
bool apply(Json::Value data, std::string & error);
const std::string type, name;
std::set<std::string> blacklist;
std::vector<Json::Value *> placeholders;
};
struct room_blueprint
{
room_blueprint(const room_template *tmpl, const room_instance *inst);
room_blueprint(const room_blueprint & rb);
room_blueprint(const room_blueprint & rb, df::coord offset, const variable_string::context_t & context);
~room_blueprint();
df::coord origin;
const room_template *tmpl;
const room_instance *inst;
const std::string type, tmpl_name, name;
std::vector<room_base::furniture_t *> layout;
std::vector<room_base::room_t *> rooms;
int32_t max_noblesuite;
std::set<df::coord> corridor;
std::set<df::coord> interior;
std::set<df::coord> no_room;
std::set<df::coord> no_corridor;
bool apply(std::string & error);
bool warn(std::string & error);
void build_cache();
void write_layout(std::ostream & f);
};
struct blueprint_plan_template
{
blueprint_plan_template(const std::string &, const std::string & name) :
name(name),
max_retries(25),
max_failures(100),
military_min(25),
military_max(75)
{
}
const std::string name;
size_t max_retries;
size_t max_failures;
int32_t military_min;
int32_t military_max;
std::string start;
std::set<std::string> outdoor;
std::map<std::string, std::set<std::string>> tags;
std::map<std::string, std::map<std::string, size_t>> count_as;
std::map<std::string, std::pair<size_t, size_t>> limits;
std::map<std::string, std::map<std::string, std::pair<size_t, size_t>>> instance_limits;
variable_string::context_t context;
std::pair<int16_t, int16_t> padding_x;
std::pair<int16_t, int16_t> padding_y;
std::vector<plan_priority_t> priorities;
struct Watch stock_goals;
bool apply(Json::Value data, std::string & error);
};
class blueprints_t
{
public:
blueprints_t(color_ostream & out);
~blueprints_t();
bool is_valid;
void write_rooms(std::ostream & f);
private:
std::map<std::string, std::vector<room_blueprint *>> blueprints;
std::map<std::string, blueprint_plan_template *> plans;
friend class PlanSetup;
};