forked from crawl/crawl
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathactor-los.cc
58 lines (48 loc) · 1.37 KB
/
actor-los.cc
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
#include "AppHdr.h"
#include "actor.h"
#include "coord.h"
#include "losglobal.h"
#include "state.h"
bool actor::observable() const
{
return crawl_state.game_is_arena() || is_player() || you.can_see(*this);
}
bool actor::see_cell(const coord_def &p) const
{
if (!in_bounds(pos()))
return false; // actor is off the map
return cell_see_cell(pos(), p, LOS_DEFAULT);
}
bool player::see_cell(const coord_def &p) const
{
if (!map_bounds(p))
return false; // Players can't see (-1,-1) but maybe can see (0,0).
if (crawl_state.game_is_arena())
return true;
if (!in_bounds(pos()))
return false; // A non-arena player at (0,0) can't see anything.
if (xray_vision)
return (pos() - p).rdist() <= current_vision;
return actor::see_cell(p);
}
bool actor::can_see(const actor &target) const
{
return target.visible_to(this) && see_cell(target.pos());
}
bool actor::see_cell_no_trans(const coord_def &p) const
{
return cell_see_cell(pos(), p, LOS_NO_TRANS);
}
bool player::trans_wall_blocking(const coord_def &p) const
{
return see_cell(p) && !see_cell_no_trans(p);
}
bool player::can_see(const actor& a) const
{
if (crawl_state.game_is_arena() || crawl_state.arena_suspended)
return see_cell(a.pos());
else if (xray_vision)
return see_cell(a.pos());
else
return actor::can_see(a);
}