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 Dictionary[StringName, int] 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.
Required provider contract (resolved via locator on the owner root):
• get_count_by_id(id: StringName) -> int
• try_remove_by_id(id: StringName, amount: int) -> int
• try_add_by_id(id: StringName, amount: int) -> int (rollback)
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 | |
setup | Method | |
tear_down | Method |