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. [b]Provider contract[/b] (duck-typed, enforced at runtime):[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][br][br] The rule has no opinion about what the ids represent (currency, items, etc.) — the game expresses that by choosing which provider to inject. Usage: [codeblock] var provider := MyGameProvider.new() var rule := SpendByIdRule.new({&"Gold": 100}, provider) [/codeblock]
Source: addons/grid_placement/placement/placement_rules/template_rules/spend_by_id_rule.gd
Syntax
class SpendByIdRule extends SpendCostRuleBaseSource
addons/grid_placement/placement/placement_rules/template_rules/spend_by_id_rule.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs