X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftrigger%2Ftrigger_base.hpp;h=571dac5b031ee170994f580cfe9857d8fea07b22;hb=89c801d4e00a0be36f6ad693a055505968ef9514;hp=f4c47955d28d36a5045b6e3cbf63a841114dfb16;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/trigger/trigger_base.hpp b/src/trigger/trigger_base.hpp index f4c47955d..571dac5b0 100644 --- a/src/trigger/trigger_base.hpp +++ b/src/trigger/trigger_base.hpp @@ -20,39 +20,49 @@ #ifndef SUPERTUX_TRIGGER_BASE_H #define SUPERTUX_TRIGGER_BASE_H +#include #include "moving_object.hpp" #include "math/rect.hpp" #include "sprite/sprite.hpp" +#include "object_remove_listener.hpp" class Player; /** This class is the base class for all objects you can interact with in some * way. There are several interaction types defined like touch and activate */ -class TriggerBase : public MovingObject +class TriggerBase : public MovingObject, public ObjectRemoveListener { public: enum EventType { - EVENT_TOUCH, EVENT_ACTIVATE + EVENT_TOUCH, /**< Object came into contact */ + EVENT_LOSETOUCH, /**< Lost contact with object */ + EVENT_ACTIVATE /**< Action button pressed */ }; - + TriggerBase(); ~TriggerBase(); void update(float elapsed_time); void draw(DrawingContext& context); HitResponse collision(GameObject& other, const CollisionHit& hit); - + /** * Receive trigger events */ virtual void event(Player& player, EventType type) = 0; + + /** + * Called by GameObject destructor of an object in losetouch_listeners + */ + virtual void object_removed(GameObject* object); private: Sprite* sprite; bool lasthit; bool hit; + + std::list losetouch_listeners; /**< Players that will be informed when we lose touch with them */ }; #endif /*SUPERTUX_INTERACTIVE_OBJECT_H*/ -