Skip to content

Class

SpendCostRuleBase

Generated GDScript class reference for GridPlacement.SpendCostRuleBase.

Status
Current
Version
v6.2.1
Source updated
2026-09-24
Generated on
2026-10-22

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. Required provider contract: the PlacementCostProvider protocol, reported by get_setup_issues(). try_add_by_id is the rollback path.

Atomicity: if any id cannot be spent in full, every amount already removed is refunded via try_add_by_id before the failure is reported. Subclasses should not override apply() without preserving this contract.

This class is @abstract — 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