Typed view over a game-owned cost provider (inventory, wallet, stockpile). Grid Placement does not own inventory and cannot see its boundary. Any Object implementing this id-keyed protocol works as a provider:
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
This wrapper is the one place that probes for those methods, so SpendCostRuleBase and RefundCalculator call a typed API. See the placement rules guide for the limits of spending through the plugin.
Source: addons/grid_placement/placement/placement_rules/template_rules/placement_cost_provider.gd
Syntax
class PlacementCostProvider extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
METHOD_COUNT | Field | |
METHOD_REMOVE | Field | |
METHOD_ADD | Field | |
is_bound | Method | |
can_count | Method | |
can_remove | Method | |
can_add | Method | |
get_missing_methods | Method | |
get_target_class | Method | |
count | Method | |
remove | Method | |
add | Method |
Guides that use this class
Tutorials built on Grid Placement
- Godot multiplayer grid placement: one host, four sessions
- Godot 2D grid building system: paint, place, save
- Godot 3D grid building system: the runtime loop
- Godot 4 grid-building plugins: build mode vs editor tools
- 3D room placement in Godot: build rooms and stack storeys
- 3D grid placement in Godot 4: full setup tutorial
- Snap to a TileMap in Godot: 2D grid placement
- How to make a farming system in Godot
- How to snap objects to a 3D grid in Godot