-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathplan_setup.h
82 lines (65 loc) · 5.17 KB
/
plan_setup.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
#pragma once
#include "ai.h"
#include "blueprint.h"
#include "stocks.h"
#include "exclusive_callback.h"
#include "modules/Screen.h"
class PlanSetup;
class viewscreen_ai_plan_setupst : public dfhack_viewscreen
{
PlanSetup & setup;
public:
viewscreen_ai_plan_setupst(PlanSetup & setup) : setup(setup) {}
std::string getFocusString();
void render();
static virtual_identity _identity;
};
class PlanSetup : public ExclusiveCallback
{
AI & ai;
int32_t next_noblesuite;
int32_t quieter_count;
std::vector<room_base::furniture_t *> layout;
std::vector<room_base::room_t *> rooms;
std::vector<plan_priority_t> priorities;
struct Watch stock_goals;
int32_t military_min, military_max;
std::map<df::coord, std::pair<room_base::roomindex_t, std::map<std::string, variable_string::context_t>>> room_connect;
std::map<df::coord, std::string> corridor;
std::map<df::coord, std::string> interior;
std::map<df::coord, std::string> no_room;
std::map<df::coord, std::string> no_corridor;
public:
std::vector<std::pair<std::string, bool>> log;
PlanSetup(AI &);
~PlanSetup();
void Run(color_ostream &);
private:
void Log(const std::string &);
void LogQuiet(const std::string &, bool);
bool build_from_blueprint(const blueprints_t & blueprints);
void create_from_blueprint(room * & fort_entrance, std::vector<room *> & real_rooms_and_corridors, std::vector<plan_priority_t> & real_priorities) const;
typedef void (PlanSetup::*find_fn)(std::vector<const room_blueprint *> &, const std::map<std::string, size_t> &, const std::map<std::string, std::map<std::string, size_t>> &, const blueprints_t &, const blueprint_plan_template &);
typedef bool (PlanSetup::*try_add_fn)(const room_blueprint &, std::map<std::string, size_t> &, std::map<std::string, std::map<std::string, size_t>> &, const blueprint_plan_template &);
bool add(const room_blueprint & rb, std::string & error, df::coord exit_location = df::coord());
bool add(const room_blueprint & rb, room_base::roomindex_t parent, std::string & error, df::coord exit_location = df::coord());
void add_count(const room_blueprint & rb, const blueprint_plan_template & plan, std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts);
bool build(const blueprints_t & blueprints, const blueprint_plan_template & plan);
void place_rooms(std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprints_t & blueprints, const blueprint_plan_template & plan, find_fn find, try_add_fn try_add);
void clear();
void find_available_blueprints(std::vector<const room_blueprint *> & available_blueprints, const std::map<std::string, size_t> & counts, const std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprints_t & blueprints, const blueprint_plan_template & plan, const std::set<std::string> & available_tags_base, const std::function<bool(const room_blueprint &)> & check);
void find_available_blueprints_start(std::vector<const room_blueprint *> & available_blueprints, const std::map<std::string, size_t> & counts, const std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprints_t & blueprints, const blueprint_plan_template & plan);
void find_available_blueprints_outdoor(std::vector<const room_blueprint *> & available_blueprints, const std::map<std::string, size_t> & counts, const std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprints_t & blueprints, const blueprint_plan_template & plan);
void find_available_blueprints_connect(std::vector<const room_blueprint *> & available_blueprints, const std::map<std::string, size_t> & counts, const std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprints_t & blueprints, const blueprint_plan_template & plan);
bool can_add_room(const room_blueprint & rb, df::coord pos);
bool try_add_room_start(const room_blueprint & rb, std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprint_plan_template & plan);
bool try_add_room_outdoor(const room_blueprint & rb, std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprint_plan_template & plan);
bool try_add_room_outdoor_shared(const room_blueprint & rb, std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprint_plan_template & plan, int16_t x, int16_t y);
bool try_add_room_connect(const room_blueprint & rb, std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprint_plan_template & plan);
bool have_minimum_requirements(std::map<std::string, size_t> & counts, std::map<std::string, std::map<std::string, size_t>> & instance_counts, const blueprint_plan_template & plan);
void remove_unused_rooms();
void handle_stairs_special();
bool distance_at_most(size_t r1, size_t r2, size_t max);
void add_extra_doors();
void handle_special_exits();
};