def dispatch

bendvy-ecs-core@0.1.0.4 · ordinary_machine_schedule.bend:24

import bendvy-ecs-core@0.1.0.4/ordinary_machine_schedule.bend as OrdinaryMachineSchedule
import Base
import bendvy-ecs-core@0.1.0.4/world.bend as W
import bendvy-ecs-core@0.1.0.4/system.bend as Sys

24# Advanced fixed-group router: ids 1/2/3 call apply/exit/transition; the remaining
25# case calls enter. Use with steps(), not arbitrary ids assumed validated here.
26# Closed callbacks must return actual owners/World and their failure outcome.
27def dispatch(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Error:Data,~apply:H -> W.World<S,C,R,E> -> H & Sys.Outcome<W.World<S,C,R,E>,Error,Unit>,~exit:H -> W.World<S,C,R,E> -> H & Sys.Outcome<W.World<S,C,R,E>,Error,Unit>,~transition:H -> W.World<S,C,R,E> -> H & Sys.Outcome<W.World<S,C,R,E>,Error,Unit>,~enter:H -> W.World<S,C,R,E> -> H & Sys.Outcome<W.World<S,C,R,E>,Error,Unit>,owners:H,world:W.World<S,C,R,E>,id:U32) -> H & Sys.Outcome<W.World<S,C,R,E>,Error,Unit>:
28  match id:
29    case 1:apply(owners,world)
30    case 2:exit(owners,world)
31    case 3:transition(owners,world)
32    case _:enter(owners,world)

Uses (8)

Used by (3)