aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-world/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 08:43:49 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 08:43:49 +0300
commit176b377c8d4406161ff206a8cb5ac8c8359877cf (patch)
tree99394195838de49cd8c820d7efc6fa7936217131 /crates/fparkan-world/src/lib.rs
parentacc5af7cc79a5ee2132c5d10528ca1cf06186832 (diff)
downloadfparkan-176b377c8d4406161ff206a8cb5ac8c8359877cf.tar.xz
fparkan-176b377c8d4406161ff206a8cb5ac8c8359877cf.zip
feat(runtime): engage hostile robots in AutoDemo
Diffstat (limited to 'crates/fparkan-world/src/lib.rs')
-rw-r--r--crates/fparkan-world/src/lib.rs20
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 {