X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgame_object.hpp;h=7c4b59f6c8b069aa9129b07a4b69a4a02c28f930;hb=8b67b0dc71efddc4b668bde525ba94d701f622ac;hp=77c3980584058b4dba94b6d25f3615d0dcfb86c8;hpb=8a627e73d824b5a14249cfe066dc2fdc643ce28d;p=supertux.git diff --git a/src/game_object.hpp b/src/game_object.hpp index 77c398058..7c4b59f6c 100644 --- a/src/game_object.hpp +++ b/src/game_object.hpp @@ -21,27 +21,26 @@ #include #include "refcounter.hpp" -#include "lisp/lisp.hpp" class DrawingContext; class ObjectRemoveListener; /** - * This is a base class for all game objects. Each sector of a level will hold a - * list of active GameObject while the game is played. + * Base class for all the things that make up Levels' Sectors. + * + * Each sector of a level will hold a list of active GameObject while the + * game is played. * * This class is responsible for: * - Updating and Drawing the object. This should happen in the update() and * draw() functions. Both are called once per frame. * - Providing a safe way to remove the object by calling the remove_me * functions. - * - a 32bit bitset for flags... */ class GameObject : public RefCounter { public: - GameObject(std::string name = ""); - GameObject(const lisp::Lisp& lisp); + GameObject(); virtual ~GameObject(); /** This function is called once per frame and allows the object to update @@ -71,23 +70,18 @@ public: /** registers a remove listener which will be called if the object * gets removed/destroyed */ - void add_remove_listener(ObjectRemoveListener* listener) - { - RemoveListenerListEntry* entry = new RemoveListenerListEntry(); - entry->next = remove_listeners; - entry->listener = listener; - - remove_listeners = entry; - } + void add_remove_listener(ObjectRemoveListener* listener); + + /** + * unregisters a remove listener, so it will no longer be called if the object + * gets removed/destroyed + */ + void del_remove_listener(ObjectRemoveListener* listener); - std::string get_name() const + const std::string& get_name() const { return name; } - // --- BEGIN METHODS TO EXPOSE TO SQUIRREL --- // - //void set_visible(bool visible); - //bool is_visible(); - // --- END METHODS TO EXPOSE TO SQUIRREL --- // private: /** this flag indicates if the object should be removed at the end of the @@ -103,7 +97,11 @@ private: RemoveListenerListEntry* remove_listeners; protected: - std::string name; /**< user-defined name for use in scripts or empty string if not scriptable */ + /** + * a name for the gameobject, this is mostly a hint for scripts and for + * debugging, don't rely on names being set or being unique + */ + std::string name; }; #endif /*SUPERTUX_GAMEOBJECT_H*/