execution_lifetime_scope_world_access.bend
bendvy-ecs-core@0.1.0.3 · 28 lines · 6 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/world.bend as W
3import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as Layout
4import bendvy-ecs-core@0.1.0.3/execution_command_permission.bend as Permission
5import bendvy-ecs-core@0.1.0.3/execution_relation_context.bend as Context
6import bendvy-ecs-core@0.1.0.3/execution_lifetime_scope_resource_dispatch.bend as Dispatch
7import bendvy-ecs-core@0.1.0.3/execution_lifetime_scope_store.bend as Store
8import bendvy-ecs-core@0.1.0.3/execution_relation_resource_snapshot.bend as Snapshot
9import bendvy-ecs-core@0.1.0.3/execution_relation_world_publication.bend as Publication
10import bendvy-ecs-core@0.1.0.3/entity_allocator.bend as Allocator
11import bendvy-ecs-core@0.1.0.3/change_tick.bend as Tick
12
13def restored(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},frame:Publication.Frame<S,C,R,E>,result:Allocator.Allocator & (Physical & Dispatch.Outcome<S>)) -> W.World<S,C,R,E> & Dispatch.Outcome<S>:
14 match frame result:
15 case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (allocator,(owners,outcome)):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},outcome)
16def run(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Dispatch.Program(~S,~resources),context:Context.Context<S,R,resources,same>,route:Layout.Route,request:Store.Request<S>,world:W.World<S,C,R,E>,tick:Tick.Tick) -> W.World<S,C,R,E> & Dispatch.Outcome<S>:
17 match context world:
18 case Context.Context{expected} W.World{+namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:restored(S,C,R,E,Layout.resources(~S,resources),same,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(expected,namespace,allocator,Layout.checked_owner(R,Layout.resources(~S,resources),same,owners),route,request,tick))
19def apply(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection<S,resources>,context:Context.Context<S,R,resources,same>,route:Layout.Route,request:Store.Request<S>,world:W.World<S,C,R,E>,tick:Tick.Tick) -> W.World<S,C,R,E> & Dispatch.Outcome<S>:
20 run(~S,~C,~R,~E,~resources,~same,~Permission.scopes_field(S,resources,selection),context,route,request,world,tick)
21def observed(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},allocator:Allocator.Allocator,frame:Publication.Frame<S,C,R,E>,result:Physical & List<&2,Snapshot.GraphView<S>>) -> W.World<S,C,R,E> & List<&2,Snapshot.GraphView<S>>:
22 match frame result:
23 case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (owners,views):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},views)
24def gather(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Snapshot.Program(~S,~resources),world:W.World<S,C,R,E>) -> W.World<S,C,R,E> & List<&2,Snapshot.GraphView<S>>:
25 match world:
26 case W.World{namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:observed(S,C,R,E,Layout.resources(~S,resources),same,allocator,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(Layout.checked_owner(R,Layout.resources(~S,resources),same,owners)))
27def graphs(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection<S,resources>,world:W.World<S,C,R,E>) -> W.World<S,C,R,E> & List<&2,Snapshot.GraphView<S>>:
28 gather(~S,~C,~R,~E,~resources,~same,~Permission.snapshot_field(S,resources,selection),world)