Abstract base class for placement rules that spend id-keyed costs. Subclasses supply a provider (duck-typed [Object]) 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] (enforced at runtime via [method get_setup_issues]):[br] [code]get_count_by_id(id: StringName) -> int[/code][br] [code]try_remove_by_id(id: StringName, amount: int) -> int[/code][br] [code]try_add_by_id(id: StringName, amount: int) -> int[/code] (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 | |
missing | Property | |
failed_message | Property | |
apply | Method | |
issues | Property | |
spent | Property | |
removed | Property | |
tear_down | Method | |
get_setup_issues | Method | |
issues | Property | |
get_missing_costs | Method | |
missing | Property | |
have | Property |
Source
addons/grid_placement/placement/placement_rules/template_rules/spend_cost_rule_base.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs