Abstract base class for placement rules that spend id-keyed costs. Subclasses supply a provider (game-owned [Object], see [PlacementCostProvider]) and a [Dictionary] of [StringName] id -> [int] cost. The rule is agnostic about what the ids represent (currency, items, magic dust) — the game expresses its vocabulary by injecting the appropriate provider. [b]Required provider contract[/b]: the [PlacementCostProvider] protocol, reported by [method get_setup_issues]. [code]try_add_by_id[/code] is the rollback path.[br][br] [b]Atomicity[/b]: if any id cannot be spent in full, every amount already removed is refunded via [code]try_add_by_id[/code] before the failure is reported. Subclasses should not override [method apply] without preserving this contract.[br][br] This class is [code]@abstract[/code] — instantiate [SpendByIdRule] or [SpendMaterialsRuleById] instead.
Source: addons/grid_placement/placement/placement_rules/template_rules/spend_cost_rule_base.gd
Syntax
class SpendCostRuleBase extends PlacementRuleMembers
| Name | Kind | Summary |
|---|---|---|
costs | Property | Item id -> amount that must be spent for placement to succeed. |
validate_placement | Method | |
apply | Method | |
tear_down | Method | |
get_setup_issues | Method | |
get_missing_costs | Method |