def spawn
bendvy-ecs-core@0.1.0.4 · restore_apply.bend:27
import bendvy-ecs-core@0.1.0.4/restore_apply.bend as RestoreApply
import Base
import bendvy-ecs-core@0.1.0.4/restore_lifecycle.bend as Lifecycle
import bendvy-ecs-core@0.1.0.4/restore_data.bend as R
import bendvy-ecs-core@0.1.0.4/world.bend as W
import bendvy-ecs-core@0.1.0.4/snapshot_data.bend as Snapshot
27def spawn(~S:Data,~C:Type,~Resources:Type,~E:Data,~emit:R.Change<S> -> E,entities:List<&2,Snapshot.Entity>,world:W.World<S,C,Resources,E>,bindings:List<&2,R.Binding<S>>) -> Spawned<S,C,Resources,E>:
28 match entities:
29 case []:Spawned{world,List.reverse(&2,R.Binding<S>,bindings)}
30 case Snapshot.Entity{saved,_} <> rest:reserved(~S,~C,~Resources,~E,~emit,saved,bindings,world => bindings => spawn(~S,~C,~Resources,~E,~emit,rest,world,bindings),Lifecycle.spawn(~S,~C,~Resources,~E,world))