def receipt_find

bendvy-ecs-core@0.1.0.4 · bundle_batch.bend:45

import bendvy-ecs-core@0.1.0.4/bundle_batch.bend as BundleBatch
import Base
import entity_key.bend as K
import world.bend as W

45def receipt_find(~S:Data,~P:Type,prepared:List<Prepared<S,P>>,+target:W.Handle<S>) -> List<Prepared<S,P>> & Bool:
46  match prepared:
47    case []: ([],False{})
48    case Prepared{handle,payload,position} <> tail: receipt_join(~S,~P,Prepared{handle,payload,position},False{},receipt_find(~S,~P,tail,target))
49    case ReservationReceipt{W.Handle{+ns,+id}} <> tail:
50      match target:
51        case W.Handle{+otherNs,+otherId}: receipt_join(~S,~P,ReservationReceipt{W.Handle{ns,id}},Bool.and(U32.is_eq(ns,otherNs),K.equal(id,otherId)),receipt_find(~S,~P,tail,W.Handle{otherNs,otherId}))

Uses (10)

Used by (1)