Skip to content

Class

SpendMaterialsRuleById

Generated GDScript class reference for GridPlacement.SpendMaterialsRuleById.

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

Id-keyed material spending rule with [NodeLocator]-based provider resolution. Extends [SpendCostRuleBase] — the single-rule consolidation point. This class exists as a backward-compatible alias for callers that resolve their provider through the scene tree via [NodeLocator]. New code that can inject a provider directly should prefer [SpendByIdRule]. Costs are a [code]Dictionary[StringName, int][/code] of item id -> amount. Ids decouple the placement contract from the consumer's inventory schema: the container owns the id -> item mapping and exposes it through an id-based interface. This is the same id convention used by [BuildCost] for the refund-on-demolish contract.[br][br] [b]Required provider contract[/b] (resolved via [member locator] on the owner root):[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)[br][br] Replaces the deprecated [SpendMaterialsRuleGeneric] (ResourceStack-keyed).

Source: addons/grid_placement/placement/placement_rules/template_rules/spend_materials_rule_by_id.gd

Syntax

class SpendMaterialsRuleById extends SpendCostRuleBase

Members

NameKindSummary
locatorPropertyUsed to find the provider on the owner root passed in as a setup parameter, so the rule knows where to spend from.
get_setup_issuesMethod
setupMethod
tear_downMethod