forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
location.cpp
69 lines (52 loc) · 1.52 KB
/
location.cpp
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
#include "stdafx.h"
#include "location.h"
#include "creature.h"
Location::Location(const string& _name, const string& desc) : name(_name), description(desc), bounds(-1, -1, 1, 1) {
}
Location::Location() : bounds(-1, -1, 1, 1) {}
Location::Location(bool s) : bounds(-1, -1, 1, 1), surprise(s) {}
bool Location::isMarkedAsSurprise() const {
return surprise;
}
string Location::getName() const {
return *name;
}
string Location::getDescription() const {
return *description;
}
bool Location::hasName() const {
return name;
}
Rectangle Location::getBounds() const {
CHECK(bounds.getPX() > -1) << "Location bounds not initialized";
return bounds;
}
void Location::setBounds(Rectangle b) {
bounds = b;
}
void Location::setLevel(const Level* l) {
level = l;
}
const Level* Location::getLevel() const {
return level;
}
class TowerTopLocation : public Location {
public:
virtual void onCreature(Creature* c) override {
if (!c->isPlayer())
return;
if (!entered.count(c) && !c->isBlind()) {
/* for (Vec2 v : c->getLevel()->getBounds())
if ((v - c->getPosition()).lengthD() < 300 && !c->getLevel()->getSquare(v)->isCovered())
c->remember(v, c->getLevel()->getSquare(v)->getViewObject());*/
c->privateMessage("You stand at the top of a very tall stone tower.");
c->privateMessage("You see distant land in all directions.");
entered.insert(c);
}
}
private:
unordered_set<Creature*> entered;
};
Location* Location::towerTopLocation() {
return new TowerTopLocation();
}