forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
construction_map.h
106 lines (89 loc) · 2.64 KB
/
construction_map.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
#ifndef _CONSTRUCTION_MAP_H
#define _CONSTRUCTION_MAP_H
#include "cost_info.h"
#include "util.h"
#include "square_type.h"
#include "unique_entity.h"
#include "position.h"
class ConstructionMap {
public:
class SquareInfo {
public:
SquareInfo(SquareType, CostInfo);
void setBuilt();
void reset();
void setTask(UniqueEntity<Task>::Id);
CostInfo getCost() const;
bool isBuilt() const;
UniqueEntity<Task>::Id getTask() const;
bool hasTask() const;
const SquareType& getSquareType() const;
SERIALIZATION_DECL(SquareInfo);
private:
CostInfo SERIAL(cost);
bool SERIAL(built) = false;
SquareType SERIAL(type);
optional<UniqueEntity<Task>::Id> SERIAL(task);
};
class TrapInfo {
public:
TrapInfo(TrapType);
bool isMarked() const;
bool isArmed() const;
TrapType getType() const;
void setArmed();
void setMarked();
void reset();
SERIALIZATION_DECL(TrapInfo);
private:
TrapType SERIAL(type);
bool SERIAL(armed) = false;
bool SERIAL(marked) = false;
};
class TorchInfo {
public:
TorchInfo(Dir);
Dir getAttachmentDir() const;
UniqueEntity<Task>::Id getTask() const;
bool hasTask() const;
bool isBuilt() const;
Trigger* getTrigger();
void setTask(UniqueEntity<Task>::Id);
void setBuilt(Trigger*);
SERIALIZATION_DECL(TorchInfo);
private:
bool SERIAL(built) = false;
optional<UniqueEntity<Task>::Id> SERIAL(task);
Dir SERIAL(attachmentDir);
Trigger* SERIAL(trigger) = nullptr;
};
const SquareInfo& getSquare(Position) const;
SquareInfo& getSquare(Position);
void removeSquare(Position);
void onSquareDestroyed(Position);
void addSquare(Position, const SquareInfo&);
bool containsSquare(Position) const;
int getSquareCount(SquareType) const;
const TrapInfo& getTrap(Position) const;
TrapInfo& getTrap(Position);
void removeTrap(Position);
void addTrap(Position, const TrapInfo&);
bool containsTrap(Position) const;
const TorchInfo& getTorch(Position) const;
TorchInfo& getTorch(Position);
void removeTorch(Position);
void addTorch(Position, const TorchInfo&);
bool containsTorch(Position) const;
const vector<Position>& getSquares() const;
const map<Position, TrapInfo>& getTraps() const;
const map<Position, TorchInfo>& getTorches() const;
template <class Archive>
void serialize(Archive& ar, const unsigned int version);
private:
map<Position, vector<SquareInfo>> SERIAL(squares);
vector<Position> squarePos;
unordered_map<SquareType, int> SERIAL(typeCounts);
map<Position, TrapInfo> SERIAL(traps);
map<Position, TorchInfo> SERIAL(torches);
};
#endif