_RollbackLivenessServer
Inherits: Node
Tracks subject livenesses
Description
The game state may be rolled back to ticks where certain subjects didn't exist yet, while others have already been despawned. Liveness tracking is tracking whether a given subject was active and part of the game at any given tick.
Liveness is constrained to an interval - the subject is spawned at a given tick, and then gets despawned at another. Once the subject is despawned it can't be spawned again.
Methods
| Return Type | Name |
|---|---|
| void | register(Node subject, Callable respawn_callback, Callable despawn_callback, Callable destroy_callback, int spawn_tick) |
| bool | is_registered(Node subject) |
| void | deregister(Node subject) |
| bool | is_alive(Node subject, int tick) |
| void | spawn(Node subject, int tick) |
| void | despawn(Node subject, int tick) |
| void | clear_despawn(Node subject) |
| void | restore_liveness(int tick) |
| void | destroy_old_subjects(int threshold_tick) |
Method Descriptions
void register ( Node subject, Callable respawn_callback, Callable despawn_callback, Callable destroy_callback, int spawn_tick )
Register subject for liveness tracking.
Whenever the subject needs to be (re)spawned or despawned, respawn_callback and despawn_callback will be called, respectively. Once it is sure that the subject won't be respawned, destroy_callback will be called.
Note that any Callable can be used. This could be a method on the subject itself, or on any other object, e.g. a central orchestrator.
bool is_registered ( Node subject )
Return true if subject is registered for liveness tracking.
void deregister ( Node subject )
Deregister subject from liveness tracking.
Note that its liveness will not be updated - if the subject was despawned before being deregistered, it will not be respawned.
bool is_alive ( Node subject, int tick )
Return true if subject is alive at tick.
Unknown subjects will always be considered alive.
If a subject is despawned, it will only become dead on the next tick. This allows the despawn logic to run in rollback.
void spawn ( Node subject, int tick )
Mark the subject's spawn at tick.
void despawn ( Node subject, int tick )
Mark the subject's despawn at tick.
void clear_despawn ( Node subject )
Clear any previously set despawn tick for subject.
void restore_liveness ( int tick )
Restore the liveness of all subjects as it was on tick.
void destroy_old_subjects ( int threshold_tick )
Destroy all dead subjects that won't be respawned.
threshold_tick specifies the tick beyond which no rollback will occur. By default, this is _NetworkRollback.history_start, because no ticks before that will be resimulated.