1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00
OpenMW/apps/openmw/mwlua/globalscripts.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.6 KiB
C++
Raw Normal View History

2020-12-18 22:21:10 +00:00
#ifndef MWLUA_GLOBALSCRIPTS_H
#define MWLUA_GLOBALSCRIPTS_H
#include <memory>
#include <set>
#include <string>
#include <components/lua/luastate.hpp>
#include <components/lua/scriptscontainer.hpp>
#include "object.hpp"
namespace MWLua
{
class GlobalScripts : public LuaUtil::ScriptsContainer
{
public:
2022-05-20 19:47:13 +00:00
GlobalScripts(LuaUtil::LuaState* lua)
: LuaUtil::ScriptsContainer(lua, "Global")
2020-12-18 22:21:10 +00:00
{
registerEngineHandlers({ &mObjectActiveHandlers, &mActorActiveHandlers, &mItemActiveHandlers,
&mNewGameHandlers, &mPlayerAddedHandlers, &mOnActivateHandlers });
2020-12-18 22:21:10 +00:00
}
void newGameStarted() { callEngineHandlers(mNewGameHandlers); }
void objectActive(const GObject& obj) { callEngineHandlers(mObjectActiveHandlers, obj); }
2020-12-18 22:21:10 +00:00
void actorActive(const GObject& obj) { callEngineHandlers(mActorActiveHandlers, obj); }
void itemActive(const GObject& obj) { callEngineHandlers(mItemActiveHandlers, obj); }
2020-12-18 22:21:10 +00:00
void playerAdded(const GObject& obj) { callEngineHandlers(mPlayerAddedHandlers, obj); }
void onActivate(const GObject& obj, const GObject& actor)
{
callEngineHandlers(mOnActivateHandlers, obj, actor);
}
2020-12-18 22:21:10 +00:00
private:
EngineHandlerList mObjectActiveHandlers{ "onObjectActive" };
2020-12-18 22:21:10 +00:00
EngineHandlerList mActorActiveHandlers{ "onActorActive" };
EngineHandlerList mItemActiveHandlers{ "onItemActive" };
2020-12-18 22:21:10 +00:00
EngineHandlerList mNewGameHandlers{ "onNewGame" };
EngineHandlerList mPlayerAddedHandlers{ "onPlayerAdded" };
EngineHandlerList mOnActivateHandlers{ "onActivate" };
2020-12-18 22:21:10 +00:00
};
}
#endif // MWLUA_GLOBALSCRIPTS_H