2020-12-18 22:21:10 +00:00
|
|
|
#ifndef MWLUA_GLOBALSCRIPTS_H
|
|
|
|
#define MWLUA_GLOBALSCRIPTS_H
|
|
|
|
|
|
|
|
#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
|
|
|
{
|
2023-08-18 20:55:43 +00:00
|
|
|
registerEngineHandlers({
|
|
|
|
&mObjectActiveHandlers,
|
|
|
|
&mActorActiveHandlers,
|
|
|
|
&mItemActiveHandlers,
|
|
|
|
&mNewGameHandlers,
|
|
|
|
&mPlayerAddedHandlers,
|
|
|
|
&mOnActivateHandlers,
|
|
|
|
&mOnUseItemHandlers,
|
|
|
|
&mOnNewExteriorHandlers,
|
|
|
|
});
|
2020-12-18 22:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void newGameStarted() { callEngineHandlers(mNewGameHandlers); }
|
2022-05-20 19:27:21 +00:00
|
|
|
void objectActive(const GObject& obj) { callEngineHandlers(mObjectActiveHandlers, obj); }
|
2020-12-18 22:21:10 +00:00
|
|
|
void actorActive(const GObject& obj) { callEngineHandlers(mActorActiveHandlers, obj); }
|
2022-05-20 19:27:21 +00:00
|
|
|
void itemActive(const GObject& obj) { callEngineHandlers(mItemActiveHandlers, obj); }
|
2020-12-18 22:21:10 +00:00
|
|
|
void playerAdded(const GObject& obj) { callEngineHandlers(mPlayerAddedHandlers, obj); }
|
2023-03-26 23:36:45 +00:00
|
|
|
void onActivate(const GObject& obj, const GObject& actor)
|
|
|
|
{
|
|
|
|
callEngineHandlers(mOnActivateHandlers, obj, actor);
|
|
|
|
}
|
2023-09-11 14:21:34 +00:00
|
|
|
void onUseItem(const GObject& obj, const GObject& actor, bool force)
|
|
|
|
{
|
|
|
|
callEngineHandlers(mOnUseItemHandlers, obj, actor, force);
|
|
|
|
}
|
2023-06-13 15:04:22 +00:00
|
|
|
void onNewExterior(const GCell& cell) { callEngineHandlers(mOnNewExteriorHandlers, cell); }
|
2020-12-18 22:21:10 +00:00
|
|
|
|
|
|
|
private:
|
2022-05-20 19:27:21 +00:00
|
|
|
EngineHandlerList mObjectActiveHandlers{ "onObjectActive" };
|
2020-12-18 22:21:10 +00:00
|
|
|
EngineHandlerList mActorActiveHandlers{ "onActorActive" };
|
2022-05-20 19:27:21 +00:00
|
|
|
EngineHandlerList mItemActiveHandlers{ "onItemActive" };
|
2020-12-18 22:21:10 +00:00
|
|
|
EngineHandlerList mNewGameHandlers{ "onNewGame" };
|
|
|
|
EngineHandlerList mPlayerAddedHandlers{ "onPlayerAdded" };
|
2023-03-26 23:36:45 +00:00
|
|
|
EngineHandlerList mOnActivateHandlers{ "onActivate" };
|
2023-08-18 20:55:43 +00:00
|
|
|
EngineHandlerList mOnUseItemHandlers{ "_onUseItem" };
|
2023-06-13 15:04:22 +00:00
|
|
|
EngineHandlerList mOnNewExteriorHandlers{ "onNewExterior" };
|
2020-12-18 22:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MWLUA_GLOBALSCRIPTS_H
|