TreeWillOWisps now hurt Tux.
SVN-Revision: 5024
HitResponse
TreeWillOWisp::collision_player(Player& player, const CollisionHit& hit)
{
- (void) player;
- (void) hit;
-
- return FORCE_MOVE;
+ //TODO: basically a no-op. Remove if this doesn't change.
+ return BadGuy::collision_player(player, hit);
}
bool
TreeWillOWisp::collides(GameObject& other, const CollisionHit& ) {
- if (dynamic_cast<Lantern*>(&other)) return true;
+ Lantern* lantern = dynamic_cast<Lantern*>(&other);
+ if (lantern && lantern->is_open()) return true;
+ if (dynamic_cast<Player*>(&other)) return true;
return false;
}
void set_color(const Color& color);
Color get_color() const;
+ virtual bool is_flammable() const { return false; }
+ virtual bool is_freezable() const { return false; }
+ virtual void kill_fall() { vanish(); }
+
protected:
virtual bool collides(GameObject& other, const CollisionHit& hit);
HitResponse collision_player(Player& player, const CollisionHit& hit);
}
void
-WillOWisp::kill_fall()
-{
-}
-
-void
WillOWisp::vanish()
{
mystate = STATE_VANISHING;
bool
WillOWisp::collides(GameObject& other, const CollisionHit& ) {
- if (dynamic_cast<Lantern*>(&other)) return true;
+ Lantern* lantern = dynamic_cast<Lantern*>(&other);
+ if (lantern && lantern->is_open()) return true;
if (dynamic_cast<Player*>(&other)) return true;
return false;
}
void write(lisp::Writer& write);
void active_update(float elapsed_time);
- void kill_fall();
+ virtual bool is_flammable() const { return false; }
+ virtual bool is_freezable() const { return false; }
+ virtual void kill_fall() { vanish(); }
/**
* make WillOWisp vanish
}
HitResponse Lantern::collision(GameObject& other, const CollisionHit& hit) {
- if ((grabbed) && lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0){
+ if (is_open()) {
WillOWisp* wow = dynamic_cast<WillOWisp*>(&other);
if (wow) {
// collided with WillOWisp while grabbed and unlit
Rock::grab(object, pos, dir);
// if lantern is not lit, draw it as opened
- if(lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0){
+ if (is_open()) {
sprite->set_action("off-open");
}
void
Lantern::ungrab(MovingObject& object, Direction dir)
{
- Rock::ungrab(object, dir);
-
// if lantern is not lit, it was drawn as opened while grabbed. Now draw it as closed again
- if(lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0){
+ if (is_open()) {
sprite->set_action("off");
}
+
+ Rock::ungrab(object, dir);
+}
+
+bool
+Lantern::is_open()
+{
+ return ((grabbed) && lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0);
}
IMPLEMENT_FACTORY(Lantern, "lantern");
void grab(MovingObject& object, const Vector& pos, Direction dir);
void ungrab(MovingObject& object, Direction dir);
+ /**
+ * returns true if lamp is currently open
+ */
+ bool is_open();
+
private:
Color lightcolor;
Sprite* lightsprite;