diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-06 21:09:35 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-07 07:13:17 +0100 |
commit | 10273d633986cf417c52169acb14a12fc52cb018 (patch) | |
tree | 191d249b808d70172f72633c55e2e4979783df8c | |
parent | a8aa8b394e1419e367eda8774d47c4c79c0aa2ea (diff) | |
download | crawl-ref-10273d633986cf417c52169acb14a12fc52cb018.tar.gz crawl-ref-10273d633986cf417c52169acb14a12fc52cb018.zip |
Give actors their own LOS.
-rw-r--r-- | crawl-ref/source/actor.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/actor.h | 9 |
2 files changed, 19 insertions, 1 deletions
diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc index efc56962ef..705a492221 100644 --- a/crawl-ref/source/actor.cc +++ b/crawl-ref/source/actor.cc @@ -17,6 +17,16 @@ bool actor::observable() const return (crawl_state.arena || this == &you || you.can_see(this)); } +bool actor::see_cell(const coord_def &p) const +{ + return (los.see_cell(p)); +} + +void actor::update_los() +{ + los.update(); +} + bool actor::can_see(const actor *target) const { return (target->visible_to(this) && see_cell(target->pos())); @@ -118,4 +128,5 @@ bool actor::check_res_magic(int power) void actor::set_position(const coord_def &c) { position = c; + los.set_center(c); } diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index c18722f5c1..000eba813f 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -1,6 +1,8 @@ #ifndef ACTOR_H #define ACTOR_H +#include "los_def.h" + class actor { public: @@ -107,7 +109,9 @@ public: virtual bool visible_to(const actor *looker) const = 0; // Is the given cell within LOS of the actor? - virtual bool see_cell(const coord_def &c) const = 0; + virtual bool see_cell(const coord_def &c) const; + + virtual void update_los(); // Can the actor actually see the target? virtual bool can_see(const actor *target) const; @@ -221,6 +225,9 @@ public: virtual bool do_shaft() = 0; coord_def position; + +protected: + los_def los; }; #endif |