summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.h
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/view.h')
-rw-r--r--crawl-ref/source/view.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index b0e6e0c2c4..9994707b12 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -244,4 +244,51 @@ unsigned short dos_brand( unsigned short colour,
unsigned brand = CHATTR_REVERSE);
#endif
+// This class can be used to fill the entire surroundings (los_range)
+// of a monster or other position with seen/unseen values, so as to be able
+// to compare several positions within this range.
+class monster_los
+{
+public:
+ monster_los();
+ virtual ~monster_los();
+
+ // public methods
+ void set_monster(monsters *mon);
+ void set_los_centre(int x, int y);
+ void fill_los_field(void);
+ bool in_sight(int x, int y);
+
+protected:
+ // protected methods
+ coord_def pos_to_index(coord_def &p);
+ coord_def index_to_pos(coord_def &i);
+
+ void set_los_value(int x, int y, bool blocked, bool override = false);
+ int get_los_value(int x, int y);
+ bool is_blocked(int x, int y);
+ bool is_unknown(int x, int y);
+
+ void check_los_beam(int dx, int dy);
+
+ // The (fixed) size of the array.
+ static const int LSIZE = 2 * LOS_RADIUS + 1;
+
+ static const int L_VISIBLE = 1;
+ static const int L_UNKNOWN = 0;
+ static const int L_BLOCKED = -1;
+
+ // The centre of our los field.
+ int gridx, gridy;
+
+ // Habitat checks etc. should be done for this monster.
+ // Usually the monster whose LOS we're trying to calculate
+ // (if mon->x == gridx, mon->y == gridy).
+ // Else, any monster trying to move around within this los field.
+ monsters *mons;
+
+ // The array to store the LOS values.
+ int los_field[LSIZE][LSIZE];
+};
+
#endif