Apply the new ground_level method.
[crawl.git] / crawl-ref / source / losparam.h
blobe702e129dc510a6e790365ff3fd86747576fed1e
1 /*
2 * File: losparam.h
3 * Summary: Parameters for the LOS algorithm
4 */
6 #ifndef LOSPARAM_H
7 #define LOSPARAM_H
9 // Note: find_ray relies on the fact that 2*OPC_HALF == OPC_OPAQUE.
10 // On the other hand, losight tracks this explicitly.
11 enum opacity_type
13 OPC_CLEAR = 0,
14 OPC_HALF = 1, // for opaque clouds; two or more block
15 OPC_OPAQUE = 2,
17 NUM_OPACITIES
20 class opacity_func
22 public:
23 virtual opacity_type operator()(const coord_def& p) const = 0;
24 virtual ~opacity_func() {}
25 virtual opacity_func* clone() const = 0;
28 #define CLONE(typename) \
29 typename* clone() const \
30 { \
31 return (new typename(*this)); \
34 // Default LOS rules.
35 class opacity_default : public opacity_func
37 public:
38 CLONE(opacity_default)
40 opacity_type operator()(const coord_def& p) const;
42 static opacity_default opc_default;
44 // Default LOS rules, but only consider fully opaque features blocking.
45 // In particular, clouds don't affect the result.
46 class opacity_fullyopaque : public opacity_func
48 public:
49 CLONE(opacity_fullyopaque)
51 opacity_type operator()(const coord_def& p) const;
53 static opacity_fullyopaque opc_fullyopaque;
55 // Make transparent features block in addition to normal LOS.
56 // * Translocations opacity: blink, apportation, portal projectile.
57 // * Various "I feel safe"-related stuff.
58 class opacity_no_trans : public opacity_func
60 public:
61 CLONE(opacity_no_trans)
63 opacity_type operator()(const coord_def& p) const;
65 static opacity_no_trans opc_no_trans;
67 // Make immobile monsters block in addition to no_trans.
68 // This is used for monster movement.
69 class opacity_immob : public opacity_func
71 public:
72 CLONE(opacity_immob)
74 opacity_type operator()(const coord_def& p) const;
76 static opacity_immob opc_immob;
78 // Make anything solid block in addition to normal LOS.
79 class opacity_solid : public opacity_func
81 public:
82 CLONE(opacity_solid)
84 opacity_type operator()(const coord_def& p) const;
86 static opacity_solid opc_solid;
88 // Opacity for monster movement, based on the late monster_los.
89 class opacity_monmove : public opacity_func
91 public:
92 opacity_monmove(const monster& m)
93 : mon(m)
97 CLONE(opacity_monmove)
99 opacity_type operator()(const coord_def& p) const;
100 private:
101 const monster& mon;
104 // Make any actor (as well as solid features) block.
105 // Note that the blocking actors are still "visible".
106 class opacity_no_actor : public opacity_func
108 public:
109 CLONE(opacity_no_actor)
111 opacity_type operator()(const coord_def& p) const;
113 static opacity_no_actor opc_no_actor;
115 // Subclasses of this are passed to losight() to modify the
116 // LOS calculation. Implementations will have to translate between
117 // relative coordinates (-8,-8)..(8,8) and real coordinates,
118 // specify how opaque the cells are and determine what values
119 // are written to the visible cells.
120 class los_param
122 public:
123 virtual ~los_param() {}
125 // Whether the translated coordinate lies within the map
126 // (including boundary) and within the LOS area
127 virtual bool los_bounds(const coord_def& p) const = 0;
129 virtual opacity_type opacity(const coord_def& p) const = 0;
132 #endif