execution_relation_publication.bend
bendvy-ecs-core@0.1.0.3 · 24 lines · 4 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/entity_allocator.bend as A
3import bendvy-ecs-core@0.1.0.3/relation_types.bend as T
4import bendvy-ecs-core@0.1.0.3/execution_relation_operation.bend as O
5import bendvy-ecs-core@0.1.0.3/execution_relation_store.bend as Store
6import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as Layout
7import bendvy-ecs-core@0.1.0.3/lifecycle.bend as Life
8import bendvy-ecs-core@0.1.0.3/change_tick.bend as Tick
9
10
11
12def refreshed(~S:Data,~descriptor:T.Descriptor<S>,~key:String,~origin:Layout.Layout,allocator:A.Allocator,stamp:Life.Stamp,operation:O.Operation<S>,result:Store.Store<S,descriptor> & Store.View<S,descriptor>) -> A.Allocator & (Layout.ResourceSlot<S,Layout.Viewed<Store.Store<S,descriptor>,Store.View<S,descriptor>>,key,origin> & Store.Receipt<S>):
13 match result:
14 case (store,view):(allocator,(Layout.ResourceSlot{Layout.Viewed{store,view},stamp},Store.Applied{operation}))
15def refusal_refreshed(~S:Data,~descriptor:T.Descriptor<S>,~key:String,~origin:Layout.Layout,allocator:A.Allocator,stamp:Life.Stamp,operation:O.Operation<S>,reason:Store.Reason,result:Store.Store<S,descriptor> & Store.View<S,descriptor>) -> A.Allocator & (Layout.ResourceSlot<S,Layout.Viewed<Store.Store<S,descriptor>,Store.View<S,descriptor>>,key,origin> & Store.Receipt<S>):
16 match result:
17 case (store,view):(allocator,(Layout.ResourceSlot{Layout.Viewed{store,view},stamp},Store.Refused{operation,reason}))
18def returned(~S:Data,~descriptor:T.Descriptor<S>,~key:String,~origin:Layout.Layout,tick:Tick.Tick,stamp:Life.Stamp,priorView:Store.View<S,descriptor>,result:A.Allocator & (Store.Store<S,descriptor> & Store.Receipt<S>)) -> A.Allocator & (Layout.ResourceSlot<S,Layout.Viewed<Store.Store<S,descriptor>,Store.View<S,descriptor>>,key,origin> & Store.Receipt<S>):
19 match result:
20 case (allocator,(store,Store.Applied{operation})):refreshed(~S,~descriptor,~key,~origin,allocator,Life.after_write(True{},True{},stamp,tick),operation,Store.project(~S,~descriptor,store))
21 case (allocator,(store,Store.Refused{operation,reason})):refusal_refreshed(~S,~descriptor,~key,~origin,allocator,stamp,operation,reason,Store.project(~S,~descriptor,store))
22def apply(~S:Data,~descriptor:T.Descriptor<S>,~key:String,~origin:Layout.Layout,namespace:U32,allocator:A.Allocator,slot:Layout.ResourceSlot<S,Layout.Viewed<Store.Store<S,descriptor>,Store.View<S,descriptor>>,key,origin>,operation:O.Operation<S>,tick:Tick.Tick) -> A.Allocator & (Layout.ResourceSlot<S,Layout.Viewed<Store.Store<S,descriptor>,Store.View<S,descriptor>>,key,origin> & Store.Receipt<S>):
23 match slot:
24 case Layout.ResourceSlot{Layout.Viewed{store,view},stamp}:returned(~S,~descriptor,~key,~origin,tick,stamp,view,Store.apply(~S,~descriptor,namespace,allocator,store,operation))