From 10273d633986cf417c52169acb14a12fc52cb018 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 6 Nov 2009 21:09:35 +0100 Subject: Give actors their own LOS. --- crawl-ref/source/actor.cc | 11 +++++++++++ crawl-ref/source/actor.h | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-54-g00ecf