Canonical id-keyed spend rule for direct provider injection. Extends SpendCostRuleBase to create the single concrete rule games use for id-keyed costs. Unlike SpendMaterialsRuleById, the provider is injected directly at construction time — no NodeLocator needed. Provider contract (duck-typed, enforced at runtime):
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
The rule has no opinion about what the ids represent (currency, items, etc.) — the game expresses that by choosing which provider to inject. Usage: var provider := MyGameProvider.new() var rule := SpendByIdRule.new({&"Gold": 100}, provider)
Source: addons/grid_placement/placement/placement_rules/template_rules/spend_by_id_rule.gd
Syntax
class SpendByIdRule extends SpendCostRuleBase