2023-03-22 01:27:22 +01:00
|
|
|
#ifndef MWLUA_ENGINEEVENTS_H
|
|
|
|
#define MWLUA_ENGINEEVENTS_H
|
|
|
|
|
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
#include <components/esm3/cellref.hpp> // defines RefNum that is used as a unique id
|
|
|
|
|
2023-06-13 17:04:22 +02:00
|
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
|
2023-03-22 01:27:22 +01:00
|
|
|
namespace MWLua
|
|
|
|
{
|
|
|
|
class GlobalScripts;
|
|
|
|
|
|
|
|
class EngineEvents
|
|
|
|
{
|
|
|
|
public:
|
2023-03-25 18:14:33 +01:00
|
|
|
explicit EngineEvents(GlobalScripts& globalScripts)
|
2023-03-22 01:27:22 +01:00
|
|
|
: mGlobalScripts(globalScripts)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
struct OnActive
|
|
|
|
{
|
|
|
|
ESM::RefNum mObject;
|
|
|
|
};
|
|
|
|
struct OnInactive
|
|
|
|
{
|
|
|
|
ESM::RefNum mObject;
|
|
|
|
};
|
2023-06-18 21:19:34 +02:00
|
|
|
struct OnTeleported
|
|
|
|
{
|
|
|
|
ESM::RefNum mObject;
|
|
|
|
};
|
2023-03-22 01:27:22 +01:00
|
|
|
struct OnActivate
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
ESM::RefNum mObject;
|
|
|
|
};
|
2023-08-18 22:55:43 +02:00
|
|
|
struct OnUseItem
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
ESM::RefNum mObject;
|
2023-09-11 16:21:34 +02:00
|
|
|
bool mForce;
|
2023-08-18 22:55:43 +02:00
|
|
|
};
|
2023-03-22 01:27:22 +01:00
|
|
|
struct OnConsume
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
ESM::RefNum mConsumable;
|
|
|
|
};
|
2023-06-13 17:04:22 +02:00
|
|
|
struct OnNewExterior
|
|
|
|
{
|
|
|
|
MWWorld::CellStore& mCell;
|
|
|
|
};
|
2024-01-26 21:39:33 +00:00
|
|
|
struct OnAnimationTextKey
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
std::string mGroupname;
|
|
|
|
std::string mKey;
|
|
|
|
};
|
2024-01-14 20:33:23 +01:00
|
|
|
struct OnSkillUse
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
std::string mSkill;
|
|
|
|
int useType;
|
|
|
|
float scale;
|
|
|
|
};
|
2024-01-15 21:48:19 +01:00
|
|
|
struct OnSkillLevelUp
|
|
|
|
{
|
|
|
|
ESM::RefNum mActor;
|
|
|
|
std::string mSkill;
|
|
|
|
std::string mSource;
|
|
|
|
};
|
2024-01-26 21:39:33 +00:00
|
|
|
using Event = std::variant<OnActive, OnInactive, OnConsume, OnActivate, OnUseItem, OnNewExterior, OnTeleported,
|
2024-01-15 21:48:19 +01:00
|
|
|
OnAnimationTextKey, OnSkillUse, OnSkillLevelUp>;
|
2023-03-22 01:27:22 +01:00
|
|
|
|
|
|
|
void clear() { mQueue.clear(); }
|
|
|
|
void addToQueue(Event e) { mQueue.push_back(std::move(e)); }
|
|
|
|
void callEngineHandlers();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Visitor;
|
|
|
|
|
2023-03-25 18:14:33 +01:00
|
|
|
GlobalScripts& mGlobalScripts;
|
2023-03-22 01:27:22 +01:00
|
|
|
std::vector<Event> mQueue;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MWLUA_ENGINEEVENTS_H
|