X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftrigger%2Ftrigger_base.hpp;h=571dac5b031ee170994f580cfe9857d8fea07b22;hb=89c801d4e00a0be36f6ad693a055505968ef9514;hp=887f413a5c5c4ccca58cdbf4533f8823ec6a4d25;hpb=a113d3bd1feddd510e3b2852b0d42522735eee40;p=supertux.git diff --git a/src/trigger/trigger_base.hpp b/src/trigger/trigger_base.hpp index 887f413a5..571dac5b0 100644 --- a/src/trigger/trigger_base.hpp +++ b/src/trigger/trigger_base.hpp @@ -20,20 +20,24 @@ #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(); @@ -47,11 +51,18 @@ public: * 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*/