Chris' Tutorials
Docs/Grid Placement

Class

SpendMaterialsRuleById

Generated GDScript class reference for GridPlacement.SpendMaterialsRuleById.

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.

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 [code]Dictionary[StringName, int][/code] 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.[br][br] [b]Required provider contract[/b] (resolved via [member locator] on the owner root):[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] (rollback)[br][br] Replaces the deprecated [SpendMaterialsRuleGeneric] (ResourceStack-keyed).

Source: addons/grid_placement/placement/placement_rules/template_rules/spend_materials_rule_by_id.gd

Syntax

class SpendMaterialsRuleById extends SpendCostRuleBase

Members

NameKindSummary
locatorPropertyUsed to find the provider on the owner root passed in as a setup parameter, so the rule knows where to spend from.
get_setup_issuesMethod
issuesProperty
setupMethod
tear_downMethod

Source

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

Plugin docs root:gdscript/plugins/grid_placement_dev/docs