Fix blank animqueues, and add facing=math.auto to animate

This commit is contained in:
2024-03-12 11:46:48 -04:00
parent 044bb89edf
commit 357e3766fb
9 changed files with 147 additions and 42 deletions

View File

@@ -185,12 +185,35 @@ public:
//
eng::string add_defaults(const AnimState *other);
// Apply a configuration from a lua table.
// Parse an animstate from a Lua Table.
//
// If a key already exists in the state, then type type from the table
// must match the type from the existing state.
// Table keys must be valid lua identifiers. Table values may be string,
// floats, bool, or coordinates. Persistent flags are all set the same,
// from the persistent parameter. Returns empty string on success, or an
// error message on failure.
//
// If 'allowauto' is true, then the lua table may contain a key-value
// pair of the form (key, math.auto). These keys will be stored in the
// AnimState map with mapentry.type == SimpleDynamicTag::AUTO.
// This is done to express an intent that the value should be
// automatically computer later.
//
eng::string from_lua(LuaCoreStack &LS0, LuaSlot tab, bool persistent, bool allowauto);
// Generate a merged animstate using a previous state and an update.
//
eng::string apply_lua(LuaCoreStack &LS0, LuaSlot tab, bool setpersist);
// Keys from both previous and update are combined to create this AnimState.
// Values from 'update' override values from 'previous'. Persistent flags
// are taken from 'previous'. If a key exists in both previous and update,
// and the key is persistent in 'previous', then the types must match,
// otherwise an error is generated. Returns empty string on success or
// an error message on failure.
//
// If a key in the 'update' map has type AUTO, then we will attempt to find
// a rule to compute that value automatically. Failure to find a rule
// results in an error.
//
eng::string merge(const AnimState &previous, const AnimState &update);
// Convert an animstate to a lua table.
//
@@ -294,6 +317,17 @@ public:
//
util::SharedStdString get_encoded_queue() const { return encqueue_; }
// Get a serialized representation of a blank queue.
//
// Since an animqueue must have at least one step, the blank queue
// contains a single default step.
//
static util::SharedStdString get_encoded_blank_queue() { return blankqueue_; }
// Initialize the animqueue module.
//
static void initialize_module();
private:
struct QueueRange {
int size;
@@ -343,6 +377,10 @@ private:
// can't have the graphics engine affecting the behavior of the engine heap.
//
util::SharedStdString encqueue_;
// The blank animation queue.
//
static util::SharedStdString blankqueue_;
};
#endif // ANIMQUEUE_HPP