execution_relation_buffer.bend
bendvy-ecs-core@0.1.0.3 · 29 lines · 5 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/execution_command_buffer.bend as Buffer
3import bendvy-ecs-core@0.1.0.3/execution_command_permission.bend as Permission
4import bendvy-ecs-core@0.1.0.3/execution_relation_command.bend as Commands
5import bendvy-ecs-core@0.1.0.3/execution_relation_context.bend as Context
6import bendvy-ecs-core@0.1.0.3/execution_relation_resource_dispatch.bend as Dispatch
7import bendvy-ecs-core@0.1.0.3/execution_relation_world_publication.bend as Publication
8import bendvy-ecs-core@0.1.0.3/execution_relation_operation.bend as Operation
9import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as Layout
10import bendvy-ecs-core@0.1.0.3/change_tick.bend as Tick
11import bendvy-ecs-core@0.1.0.3/world.bend as W
12import bendvy-ecs-core@0.1.0.3/entity_allocator.bend as Allocator
13
14def commands(~S:Data,~P:Type,~D:Type,~route:Layout.Route) -> Commands.HierarchyCommands<Buffer.Buffer<S,P,D>,S>:
15 Commands.hierarchy(~S,~Buffer.Buffer<S,P,D>,~route,~Buffer.relation(~S,~P,~D))
16def receipt(-S:Data,-P:Type,-D:Type,route:Layout.Route,result:Dispatch.Outcome<S>) -> Buffer.Receipt<S,P,D>:
17 match result:
18 case Dispatch.Published{receipt}:Buffer.RelationPublished{route,receipt}
19 case Dispatch.Undeclared{operation}:Buffer.RelationUndeclared{route,operation}
20def restored(-S:Data,-C:Type,-WR:Type,-E:Data,-P:Type,-D:Type,-Physical:Type,same:{WR == Physical : Type},route:Layout.Route,frame:Publication.Frame<S,C,WR,E>,result:Allocator.Allocator & (Physical & Dispatch.Outcome<S>)) -> W.World<S,C,WR,E> & Buffer.Receipt<S,P,D>:
21 match frame result:
22 case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (allocator,(owners,outcome)):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,WR,Equal.sym(Type,WR,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},receipt(S,P,D,route,outcome))
23
24
25def run(~S:Data,~C:Type,~WR:Type,~E:Data,~P:Type,~D:Type,~resources:Layout.Layout,~same:{WR == Layout.resources(~S,resources) : Type},~program:Dispatch.Program(~S,~resources),context:Context.Context<S,WR,resources,same>,+route:Layout.Route,operation:Operation.Operation<S>,world:W.World<S,C,WR,E>,tick:Tick.Tick) -> W.World<S,C,WR,E> & Buffer.Receipt<S,P,D>:
26 match context world:
27 case Context.Context{expected} W.World{+namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:restored(S,C,WR,E,P,D,Layout.resources(~S,resources),same,route,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(expected,namespace,allocator,Layout.checked_owner(WR,Layout.resources(~S,resources),same,owners),route,operation,tick))
28def apply(~S:Data,~C:Type,~WR:Type,~E:Data,~P:Type,~D:Type,~resources:Layout.Layout,~same:{WR == Layout.resources(~S,resources) : Type},~selection:Permission.Selection<S,resources>,context:Context.Context<S,WR,resources,same>,route:Layout.Route,operation:Operation.Operation<S>,world:W.World<S,C,WR,E>,tick:Tick.Tick) -> W.World<S,C,WR,E> & Buffer.Receipt<S,P,D>:
29 run(~S,~C,~WR,~E,~P,~D,~resources,~same,~Permission.selection_field(S,resources,selection),context,route,operation,world,tick)