Add invocation queue to DrivenEngine, use it for lua source

This commit is contained in:
2023-10-23 20:57:47 -04:00
parent c4bb4bfb9d
commit 600ae7cef9
9 changed files with 50 additions and 188 deletions

View File

@@ -53,6 +53,7 @@
#include "streambuffer.hpp"
#include "enginewrapper.hpp"
#include "planemap.hpp"
#include "invocation.hpp"
class DrivenEngine;
class World;
@@ -144,12 +145,12 @@ public:
// The init callback. You may override this in a subclass.
// This will be called once at program initialization.
//
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) {}
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) = 0;
// The update callback. You may override this in a subclass.
// This will be called whenever anything changes.
//
virtual void event_update() {}
virtual void event_update() = 0;
// Specify the set of listening ports.
// This can only be used during the init routine.
@@ -210,14 +211,12 @@ public:
//
void set_console_prompt(const eng::string &prompt);
// Fetches the lua 'sourcepack'. The sourcepack is a packaged collection
// of all the lua sourcefiles, see drvutil::package_lua_source for
// documentation of the format. This also clears the sourcepack stored
// in the DrivenEngine. Returns empty string if there is no sourcepack
// in the DrivenEngine.
// Fetches the invocation queue.
//
eng::string get_lua_source_pack();
// This also clears the stored queue.
//
eng::vector<UniqueInvocation> get_queued_invocations();
// Rescan the lua source directory. The lua source directory is read once,
// automatically, at engine creation time. If you want to read it again,
// you must trigger a rescan. The rescan is not instantaneous.
@@ -283,8 +282,8 @@ public:
double drv_get_clock() const;
bool drv_get_rescan_lua_source() const;
bool drv_get_stop_driver() const;
uint64_t drv_get_actor_id() const;
void drv_get_tangibles_near(uint64_t tanid, double rx, double ry, double rz, uint32_t *count, int64_t **ids);
int64_t drv_get_actor_id() const;
void drv_get_tangibles_near(int64_t tanid, double rx, double ry, double rz, uint32_t *count, int64_t **ids);
void drv_get_animation_queues(uint32_t count, const int64_t *ids, uint32_t *lengths, const char **strings);
void drv_initialize(uint32_t srcpklen, const char *srcpk, int argc, char **argv);
@@ -316,7 +315,7 @@ private:
int64_t visible_actor_id_;
util::IdVector scan_result_;
std::vector<util::SharedStdString> anim_queues_;
eng::string lua_source_pack_;
eng::vector<UniqueInvocation> queued_invocations_;
bool rescan_lua_source_;
double clock_;
bool stop_driver_;