diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-07-07 19:56:02 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-07-07 19:56:02 +0000 |
commit | 5996ff324d4123d1b1c6adb1c81eb16dd5e7b466 (patch) | |
tree | 92943ff0856aa4ed4accd04d9e870d96cf186a21 /src/scripting/script.hpp | |
parent | e5d4c719a52d03bfe9bfb4ea2fea0570842985bc (diff) | |
download | manaserv-5996ff324d4123d1b1c6adb1c81eb16dd5e7b466.tar.gz manaserv-5996ff324d4123d1b1c6adb1c81eb16dd5e7b466.tar.bz2 manaserv-5996ff324d4123d1b1c6adb1c81eb16dd5e7b466.tar.xz manaserv-5996ff324d4123d1b1c6adb1c81eb16dd5e7b466.zip |
Implemented death listener for scripting engine.
Diffstat (limited to 'src/scripting/script.hpp')
-rw-r--r-- | src/scripting/script.hpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp index 6a101edf..d9a8aca7 100644 --- a/src/scripting/script.hpp +++ b/src/scripting/script.hpp @@ -26,6 +26,8 @@ #include <string> +#include "game-server/eventlistener.hpp" + class MapComposite; class Thing; @@ -51,7 +53,7 @@ class Script /** * Constructor. */ - Script(): mMap(NULL) {} + Script(); /** * Destructor. @@ -124,8 +126,27 @@ class Script MapComposite *getMap() const { return mMap; } + EventListener *getScriptDeathListener() + { return &mEventListener; } + + virtual void processDeathEvent(Being* thing) = 0; + private: MapComposite *mMap; + EventListener mEventListener; /**< Tracking of being deaths. */ + + friend struct ScriptDeathEventDispatch; }; +struct ScriptDeathEventDispatch: EventDispatch +{ + ScriptDeathEventDispatch() + { + typedef EventListenerFactory< Script, &Script::mEventListener > Factory; + died = &Factory::create< Being, &Script::processDeathEvent >::function; + } +}; + +static ScriptDeathEventDispatch scriptDeathEventDispatch; + #endif |