def write_grow

bendvy-ecs-core@0.1.0.3 · indexed_lifecycle.bend:30

import bendvy-ecs-core@0.1.0.3/indexed_lifecycle.bend as IndexedLifecycle
import Base
import bendvy-ecs-core@0.1.0.3/change_tick.bend as Tick
import lifecycle.bend as L

30# Factory-produced metadata starts at1 and normal targets require at most17 grows.
31def write_grow(fuel:Nat,+id:U32,stamp:L.Stamp,added:Array<Maybe<&2,Tick.Tick>>,changed:Array<Maybe<&2,Tick.Tick>>,+capacity:U32,+depth:Nat,exceptional:List<&2,L.Entry>,fits:Bool) -> Metadata:
32  match fuel fits:
33    case _ True{}: write_ready(id,added,changed,capacity,depth,exceptional,stamp)
34    case 0n False{}: Metadata{added,changed,capacity,depth,exceptional}
35    case 1n+rest False{}:
36      +next = U32.shl(capacity)
37      write_grow(rest,id,stamp,ANode{added,Array.new(Maybe<&2,Tick.Tick>,depth,None{})},ANode{changed,Array.new(Maybe<&2,Tick.Tick>,depth,None{})},next,1n+depth,exceptional,U32.is_le(id,next))

Uses (14)

Used by (1)