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 SpendCostRuleBaseMembers
| Name | Kind | Summary |
|---|---|---|
locator | Property | Used to find the provider on the owner root passed in as a setup parameter, so the rule knows where to spend from. |
get_setup_issues | Method | |
issues | Property | |
setup | Method | |
tear_down | Method |
Source
addons/grid_placement/placement/placement_rules/template_rules/spend_materials_rule_by_id.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs