Skip to main content

spawn_stepped_world_with_init

Function spawn_stepped_world_with_init 

Source
pub fn spawn_stepped_world_with_init<I, S, T>(
    host: &mut World,
    name: &'static str,
    command_capacity: usize,
    init: I,
    tick: T,
) -> WorldHandle
where I: FnOnce(&mut World) -> S + 'static, S: 'static, T: FnMut(&mut World, &ThreadControl, &mut S, f32) -> bool + 'static,
Expand description

Spawn a world the host steps, with a one-time setup step.

The world and its command queue live in the proxy component on the host entity, exactly as a threaded world’s thread does, so the entity carries the same data either way. Nothing here runs on its own: the host calls step_stepped_world to drain the queue and run the tick once.

init runs immediately, against the fresh world, before the entity is spawned, so a job sent right after the spawn already finds what it built.

name labels the world for a bridge that lists the host’s worlds; it lands on the proxy entity as a WorldName.