diff options
Diffstat (limited to 'crates/fparkan-world/src/lib.rs')
| -rw-r--r-- | crates/fparkan-world/src/lib.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/fparkan-world/src/lib.rs b/crates/fparkan-world/src/lib.rs index 41c20389..4d0319fd 100644 --- a/crates/fparkan-world/src/lib.rs +++ b/crates/fparkan-world/src/lib.rs @@ -456,13 +456,7 @@ where } world.tick.0 = world.tick.0.saturating_add(1); world.phase = WorldPhase::PublishingSnapshot; - let snapshot = WorldSnapshot { - tick: world.tick, - objects: live_registered(world), - transforms: live_registered_with_transforms(world), - events, - hash: canonical_state_hash(world), - }; + let snapshot = world_snapshot(world, events); world.phase = WorldPhase::Idle; Ok(snapshot) })(); @@ -474,6 +468,18 @@ where result } +/// Publishes the current live objects, transforms and hash with the given step events. +#[must_use] +pub fn world_snapshot(world: &World, events: Vec<WorldEvent>) -> WorldSnapshot { + WorldSnapshot { + tick: world.tick, + objects: live_registered(world), + transforms: live_registered_with_transforms(world), + events, + hash: canonical_state_hash(world), + } +} + /// Computes canonical state hash. #[must_use] pub fn canonical_state_hash(world: &World) -> StateHash { |
