Chris' Tutorials
Docs/Grid Placement

Class

SpendByIdRule

Generated GDScript class reference for GridPlacement.SpendByIdRule.

StatusDraft
Versionv6.0
UpdatedDevelopment docs generated from GDScript source

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

Draft — Unreleased:This page is in active development. APIs, class names, and behavior may change before the release is finalized. Use it as a preview of what's coming — not as a stable integration target.

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

Source

addons/grid_placement/placement/placement_rules/template_rules/spend_by_id_rule.gd

Plugin docs root:gdscript/plugins/grid_placement_dev/docs