From 393d066045fda5beee4748dc66754d70b4c82d36 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sat, 31 Jan 2009 21:49:58 +0100 Subject: Added on_remove callback to lua API --- src/scripting/script.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/scripting/script.hpp') diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp index c87bf18..24a415e 100644 --- a/src/scripting/script.hpp +++ b/src/scripting/script.hpp @@ -124,11 +124,13 @@ class Script MapComposite *getMap() const { return mMap; } - EventListener *getScriptDeathListener() + EventListener *getScriptListener() { return &mEventListener; } virtual void processDeathEvent(Being* thing) = 0; + virtual void processRemoveEvent(Thing* thing) = 0; + protected: std::string mScriptFile; @@ -136,18 +138,19 @@ class Script MapComposite *mMap; EventListener mEventListener; /**< Tracking of being deaths. */ - friend struct ScriptDeathEventDispatch; + friend struct ScriptEventDispatch; }; -struct ScriptDeathEventDispatch: EventDispatch +struct ScriptEventDispatch: EventDispatch { - ScriptDeathEventDispatch() + ScriptEventDispatch() { typedef EventListenerFactory< Script, &Script::mEventListener > Factory; died = &Factory::create< Being, &Script::processDeathEvent >::function; + removed = &Factory::create< Thing, &Script::processRemoveEvent >::function; } }; -static ScriptDeathEventDispatch scriptDeathEventDispatch; +static ScriptEventDispatch scriptEventDispatch; #endif -- cgit