Skip to content
ct

Class

SpendByIdRule

Generated GDScript class reference for GridPlacement.SpendByIdRule.

Status
Draft
Version
v6.0
Updated
Development docs generated from GDScript source

This is unreleased documentation in active development. APIs, class names, and behavior may change before the final release.

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 SpendCostRuleBase