Major refactoring - internal server state machine implemented
This commit is contained in:
1 parent
71c654e5b6
commit
66e93d46f4
48 files changed
+3948
-3696
No files matched your search
+8
-16
@@ -2,7 +2,6 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#include "quest/QuestJournal.h"
|
||||
#include "external/nlohmann/json.hpp"
|
||||
#include "ISaveable.h"
|
||||
@@ -13,7 +12,7 @@ namespace FRG {
|
||||
class Location;
|
||||
class Inventory;
|
||||
|
||||
class ScriptEngine : public ISaveable {
|
||||
class ScriptEngine {
|
||||
public:
|
||||
ScriptEngine();
|
||||
~ScriptEngine();
|
||||
@@ -25,23 +24,24 @@ public:
|
||||
//void runScript(const std::string& path);
|
||||
|
||||
void callItemPickupCallback(const std::string& objectName);
|
||||
|
||||
void callFunction(const std::string& functionName);
|
||||
void callActivateFunction(const std::string& functionName);
|
||||
|
||||
void callNpcInteractCallback(int npcIndex);
|
||||
void callNpcInteractCallback(const std::string& npcId);
|
||||
|
||||
void callTriggerEnterCallback(const std::string& zoneId);
|
||||
void callTriggerExitCallback(const std::string& zoneId);
|
||||
|
||||
// Fired when the player (moving) physically bumps into a standing NPC.
|
||||
void callNpcBumpedByPlayerCallback(int npcIndex);
|
||||
void callNpcBumpedByPlayerCallback(const std::string& npcId);
|
||||
// Fired when a moving NPC physically bumps into the standing player.
|
||||
void callNpcBumpsPlayerCallback(int npcIndex);
|
||||
void callNpcBumpsPlayerCallback(const std::string& npcId);
|
||||
|
||||
void setGlobalStore(std::unordered_map<std::string, int>* store);
|
||||
void setGlobalFloatStore(std::unordered_map<std::string, float>* store);
|
||||
void setQuestJournal(Quest::QuestJournal* journal);
|
||||
|
||||
void callLocationInitCallback();
|
||||
void callLocationEnterCallback();
|
||||
void callLocationExitCallback();
|
||||
|
||||
@@ -63,16 +63,8 @@ public:
|
||||
// has already run and registered all callbacks.
|
||||
void loadScriptGlobals(const nlohmann::json& in);
|
||||
|
||||
// Re-wires an in-flight, one-shot callback (NPC/player walk-arrival, object
|
||||
// animation-complete) that was serialized by name rather than by value.
|
||||
// Looks up `name` as a global Lua function and assigns a wrapped invoker to
|
||||
// outCallback; leaves outCallback empty and logs an error if not found.
|
||||
// Call after init() (the script must already have run) and after the owning
|
||||
// state (CharacterState / InteractiveObjectState) has been loaded.
|
||||
void rehydrateNamedCallback(const std::string& name, std::function<void()>& outCallback) const;
|
||||
|
||||
void save(nlohmann::json& out) const override { saveScriptGlobals(out); }
|
||||
void load(const nlohmann::json& in) override { loadScriptGlobals(in); }
|
||||
void save(nlohmann::json& out) const { saveScriptGlobals(out); }
|
||||
void load(const nlohmann::json& in) { loadScriptGlobals(in); }
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
|
||||
Reference in new issue
Block a user