world_resource_owner.bend

bendvy-ecs-core@0.1.0.0 · 17 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.0/clock_state.bend as Clock
3import bendvy-ecs-core@0.1.0.0/deferred_command.bend as Deferred
4import entity_allocator.bend as Alloc
5import bendvy-ecs-core@0.1.0.0/world.bend as W
6import bendvy-ecs-core@0.1.0.0/owner_product.bend as Product
7# Canonical owner split, used only behind ordinary declaration providers.
8type Rest<S:Data,C:Type,R:Type,E:Data> is Type:
9  Rest{namespace:U32,allocator:Alloc.Allocator,store:C,events:List<&2,E>,pending:List<Deferred.Command<W.World<S,C,R,E>>>,registrations:List<&2,W.RegistrationMeta>,nextSystemId:U32,clock:Clock.State}
10def take(~S:Data,~C:Type,~R:Type,~E:Data,world:W.World<S,C,R,E>) -> Rest<S,C,R,E> & R:
11  match world:
12    case W.World{ns,allocator,store,resource,events,pending,regs,sid,clock}:(Rest{ns,allocator,store,events,pending,regs,sid,clock},resource)
13def put(~S:Data,~C:Type,~R:Type,~E:Data,rest:Rest<S,C,R,E>,resource:R) -> W.World<S,C,R,E>:
14  match rest:
15    case Rest{ns,allocator,store,events,pending,regs,sid,clock}:W.World{ns,allocator,store,resource,events,pending,regs,sid,clock}
16def lens(~S:Data,~C:Type,~R:Type,~E:Data) -> Product.Lens<W.World<S,C,R,E>,R,Rest<S,C,R,E>>:
17  Product.Lens{take(~S,~C,~R,~E),put(~S,~C,~R,~E)}