pub struct WorldSnapshot {
pub tick: u64,
pub dt: f64,
pub entities: Vec<EntitySnapshot>,
pub groups: Vec<GroupSnapshot>,
pub stop_lookup: HashMap<StopId, usize>,
pub metrics: Metrics,
pub metric_tags: MetricTags,
pub extensions: HashMap<String, HashMap<EntityId, String>>,
pub ticks_per_second: f64,
}Expand description
Serializable snapshot of the entire simulation state.
Capture via Simulation::snapshot()
and restore via WorldSnapshot::restore(). The game chooses the serde format
(RON, JSON, bincode, etc.).
Extension components and resources are NOT included. Games must handle their own custom data separately.
Fields§
§tick: u64Current simulation tick.
dt: f64Time delta per tick.
entities: Vec<EntitySnapshot>All entities indexed by position in this vec.
EntityIds are regenerated on restore.
groups: Vec<GroupSnapshot>Elevator groups (references into entities by index).
stop_lookup: HashMap<StopId, usize>Stop ID → entity index mapping.
metrics: MetricsGlobal metrics at snapshot time.
Per-tag metric accumulators and entity-tag associations.
extensions: HashMap<String, HashMap<EntityId, String>>Serialized extension component data: name → (EntityId → RON string).
ticks_per_second: f64Ticks per second (for TimeAdapter reconstruction).
Implementations§
Source§impl WorldSnapshot
impl WorldSnapshot
Sourcepub fn restore(
self,
custom_strategy_factory: Option<&'_ dyn Fn(&str) -> Option<Box<dyn DispatchStrategy>>>,
) -> Simulation
pub fn restore( self, custom_strategy_factory: Option<&'_ dyn Fn(&str) -> Option<Box<dyn DispatchStrategy>>>, ) -> Simulation
Restore a simulation from this snapshot.
Built-in strategies (Scan, Look, NearestCar, ETD) are auto-restored.
For Custom strategies, provide a factory function that maps strategy
names to instances. Pass None if only using built-in strategies.
To restore extension components, call world.register_ext::<T>(name)
on the returned simulation’s world for each extension type, then call
Simulation::load_extensions()
with this snapshot’s extensions data.
Trait Implementations§
Source§impl Clone for WorldSnapshot
impl Clone for WorldSnapshot
Source§fn clone(&self) -> WorldSnapshot
fn clone(&self) -> WorldSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more