-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathview_index.h
114 lines (97 loc) · 3.14 KB
/
view_index.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
/* Copyright (C) 2013-2014 Michal Brzozowski ([email protected])
This file is part of KeeperRL.
KeeperRL is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/ . */
#pragma once
#include "enums.h"
#include "util.h"
#include "view_layer.h"
#include "item_counts.h"
#include "t_string.h"
class ViewObject;
class TStringId;
RICH_ENUM(HighlightType,
DIG,
CUT_TREE,
FETCH_ITEMS,
PERMANENT_FETCH_ITEMS,
RECT_SELECTION,
RECT_DESELECTION,
MEMORY,
PRIORITY_TASK,
FORBIDDEN_ZONE,
UNAVAILABLE,
CREATURE_DROP,
CLICKABLE_FURNITURE,
CLICKED_FURNITURE,
STORAGE_EQUIPMENT,
STORAGE_RESOURCES,
QUARTERS,
LEISURE,
INDOORS,
INSUFFICIENT_LIGHT,
GUARD_ZONE1,
GUARD_ZONE2,
GUARD_ZONE3,
HOSTILE_TOTEM,
ALLIED_TOTEM,
TORTURE_UNAVAILABLE,
PRISON_NOT_CLOSED,
PIGSTY_NOT_CLOSED,
TILE_BELOW
);
extern optional<TStringId> getDescription(HighlightType);
ViewId getViewId(HighlightType, bool active);
class ViewIndex {
public:
ViewIndex();
void insert(ViewObject);
bool hasObject(ViewLayer) const;
void removeObject(ViewLayer);
const ViewObject& getObject(ViewLayer) const;
ViewObject& getObject(ViewLayer);
const ViewObject* getTopObject(const vector<ViewLayer>&) const;
void mergeFromMemory(const ViewIndex& memory);
void mergeGroundBelow(const ViewIndex& memory);
bool isEmpty() const;
bool noObjects() const;
bool hasAnyHighlight() const;
~ViewIndex();
// If the tile is not visible, we still need the id of the floor tile to render connections properly.
optional<ViewId> getHiddenId() const;
void setHiddenId(ViewId);
vector<ViewObject>& getAllObjects();
const vector<ViewObject>& getAllObjects() const;
void setHighlight(HighlightType, bool = true);
void addGasAmount(TString name, Color);
void setNightAmount(double);
bool isHighlight(HighlightType) const;
double getNightAmount() const;
struct TileGasInfo {
Color SERIAL(color);
TString SERIAL(name);
SERIALIZE_ALL(color, name)
};
const vector<TileGasInfo>& getGasAmounts() const;
const ItemCounts& getItemCounts() const;
const ItemCounts& getEquipmentCounts() const;
ItemCounts& modItemCounts();
ItemCounts& modEquipmentCounts();
template <class Archive>
void serialize(Archive& ar, const unsigned int version);
private:
heap_optional<pair<ItemCounts, ItemCounts>> SERIAL(itemCounts);
std::array<char, EnumInfo<ViewLayer>::size> SERIAL(objIndex);
vector<ViewObject> SERIAL(objects);
EnumSet<HighlightType> SERIAL(highlights);
vector<TileGasInfo> SERIAL(tileGas);
std::uint8_t SERIAL(nightAmount);
bool SERIAL(anyHighlight) = false;
optional<ViewId> hiddenId;
};