Skip to content

Class

SpendCostRuleBase

Generated GDScript class reference for GridPlacement.SpendCostRuleBase.

Status
Current
Version
v6.0
Source updated
Active v6.0 guide line from Grid Placement repo
Generated on
2026-09-01

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 PlacementRule

Members

NameKindSummary
costsPropertyItem id -> amount that must be spent for placement to succeed.
validate_placementMethod
applyMethod
tear_downMethod
get_setup_issuesMethod
get_missing_costsMethod