105 |
|
|
106 |
typedef std::vector<LaserStone*> InstanceList; |
typedef std::vector<LaserStone*> InstanceList; |
107 |
static InstanceList instances; |
static InstanceList instances; |
108 |
Object *clone() { |
Object *clone() { |
109 |
LaserStone *o = new LaserStone(*this); |
LaserStone *o = new LaserStone(*this); |
110 |
instances.push_back(o); |
instances.push_back(o); |
111 |
return o; |
return o; |
112 |
} |
} |
113 |
void dispose() { |
void dispose() { |
116 |
} |
} |
117 |
|
|
118 |
// LaserEmitter interface |
// LaserEmitter interface |
119 |
DirectionBits emission_directions() const; |
DirectionBits emission_directions() const; |
120 |
|
|
121 |
// OnOffStone interface. |
// OnOffStone interface. |
122 |
void notify_onoff(bool on); |
void notify_onoff(bool on); |
263 |
may_pass = st->on_laserhit(d); |
may_pass = st->on_laserhit(d); |
264 |
|
|
265 |
if (may_pass) { |
if (may_pass) { |
266 |
if (Item *it = GetItem(p)) |
if (Item *it = GetItem(p)) |
267 |
it->on_laserhit(d); |
it->on_laserhit(d); |
268 |
else { |
else { |
269 |
LaserBeam *lb = new LaserBeam(d); |
LaserBeam *lb = new LaserBeam(d); |
313 |
//---------------------------------------- |
//---------------------------------------- |
314 |
LaserStone::InstanceList LaserStone::instances; |
LaserStone::InstanceList LaserStone::instances; |
315 |
|
|
316 |
LaserStone::LaserStone (Direction dir) |
LaserStone::LaserStone (Direction dir) |
317 |
: OnOffStone("st-laser") |
: OnOffStone("st-laser") |
318 |
{ |
{ |
319 |
set_attrib("dir", Value(dir)); |
set_attrib("dir", Value(dir)); |
320 |
} |
} |
321 |
|
|
322 |
DirectionBits |
DirectionBits |
323 |
LaserStone::emission_directions() const |
LaserStone::emission_directions() const |
324 |
{ |
{ |
325 |
if (is_on()) { |
if (is_on()) { |
326 |
return to_bits(get_dir()); |
return to_bits(get_dir()); |
484 |
class PlaneMirror : public MirrorStone { |
class PlaneMirror : public MirrorStone { |
485 |
CLONEOBJ(PlaneMirror); |
CLONEOBJ(PlaneMirror); |
486 |
public: |
public: |
487 |
PlaneMirror(char orientation='/', bool movable=false, bool transparent=false) |
PlaneMirror(char orientation='/', bool movable=false, bool transparent=false) |
488 |
: MirrorStone("st-pmirror", movable, transparent) |
: MirrorStone("st-pmirror", movable, transparent) |
489 |
{ |
{ |
490 |
set_orientation(orientation); |
set_orientation(orientation); |
491 |
} |
} |
492 |
private: |
private: |
493 |
void set_orientation(char o) { |
void set_orientation(char o) { |
494 |
char *a = " -\\|/"; |
const char *a = " -\\|/"; |
495 |
MirrorStone::set_orientation(strchr(a,o)-a); |
MirrorStone::set_orientation(strchr(a,o)-a); |
496 |
} |
} |
497 |
char get_orientation() { |
char get_orientation() { |
498 |
char *a = " -\\|/"; |
const char *a = " -\\|/"; |
499 |
return a[MirrorStone::get_orientation()]; |
return a[MirrorStone::get_orientation()]; |
500 |
} |
} |
501 |
bool on_laserhit(Direction dir); |
bool on_laserhit(Direction dir); |
507 |
{ |
{ |
508 |
char orientation = get_orientation(); |
char orientation = get_orientation(); |
509 |
bool transparent = is_transparent(); |
bool transparent = is_transparent(); |
510 |
|
|
511 |
switch (orientation) { |
switch (orientation) { |
512 |
case '|': |
case '|': |
513 |
if (dir==EAST || dir==WEST) { |
if (dir==EAST || dir==WEST) { |
562 |
class TriangleMirror : public MirrorStone { |
class TriangleMirror : public MirrorStone { |
563 |
CLONEOBJ(TriangleMirror); |
CLONEOBJ(TriangleMirror); |
564 |
public: |
public: |
565 |
TriangleMirror(Direction dir=NORTH) |
TriangleMirror(Direction dir=NORTH) |
566 |
: MirrorStone("st-3mirror") |
: MirrorStone("st-3mirror") |
567 |
{ |
{ |
568 |
set_orientation(dir+1); |
set_orientation(dir+1); |
569 |
} |
} |