Open ImmutableOctet opened 4 months ago
To add to this: state
and prev_state
should be accessible in some way from an 'EntitySelfInterface' referencing another entity.
In other words, you should be able to write things like:
if (auto some_entity = co_await get_entity("some_entity"_hs))
{
some_entity.state = "some_entity_state"_hs; // <-- State assigned through generated event, but `some_entity.state` may not reflect state change until later.
// Explicitly wait until `some_entity` has this `some_entity_state` state active.
// While we're suspended, the `some_entity` lock will be deactivated.
co_await until([&some_entity](){ return some_entity.state == "some_entity_state"_hs; });
// Wait 1.5 seconds.
co_await 1500ms;
// Set `some_entity`'s state with the `set_state` API instead, `co_await`-ing on the condition-based awaitable provided.
co_await some_entity.set_state("some_other_entity_state"_hs); // NOTE: `set_state` should be marked as `[[nodiscard]]`.
// `some_entity` should now have `some_other_entity_state` active.
// In addition, since we're no longer suspended, `some_entity`'s lock has be reactivated appropriately.
// Wait for more time.
co_await 3000ms;
// Do the same `co_await` as before, but with the assignment API instead.
co_await (some_entity.state = "another_entity_state"_hs); // NOTE: Not marked as `[[nodiscard]]` like `set_state`, but has the same effect.
}
//
Implement an interface that allows for variable-like semantics. Something like this:
Something similar can be done for the previous state as well, possibly sharing a common base-class.