Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

reserveCost

reserveCost<Cost>(entity, reservation, cost?): void

Takes cost off what entity may spend and holds it back under reservation, so a second action cannot spend it too, until commitCost spends that hold or refundCost returns it. Each resource’s reserved is the total of every hold. checkCost first. A hold already under reservation is a mechanic that never settled its last one: a development world throws, naming the key, and a deployed one keeps the first hold and holds nothing more.

Type Parameter
Cost extends Readonly<Partial<Record<ResourceKey, number>>>
Parameter Type
entity Entity
reservation ReservationKey
cost? KeyedCost<Cost>

void