Class BuildCost
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
Records what was spent to build a placed instance (5.1.0-D refund contract).\n\nStamped onto the placed [Manipulatable]'s metadata under [constant META_KEY] at placement time (stamping is consumer-owned — see the integration guide), then read back by [Refunder] consumers at [signal ManipulationState.pre_demolish] time so refund logic has a canonical "what was paid" record.\n\nThe canonical cost shape is keyed by [StringName] IDs, not [Resource] references: the consumer's inventory system owns the id -> Resource mapping.
class BuildCost extends Resource
Fields
META_KEY
Namespaced meta-key for stamping onto a Manipulatable. Reference this constant rather than hardcoding the string to avoid collisions with consumer metadata. Underscore-namespaced because Object.set_meta only accepts valid ASCII identifiers (a ':' separator is rejected). Uses the "placement" prefix per the plugin's public naming convention.
const META_KEY: StringName = &"placement_build_cost"
Properties
entries
Item entries: Array[Dictionary] of {id: StringName, quantity: int}. Generic — the consumer maps each id to whatever their inventory system uses (Resource, item database, runtime registry, etc).
@export var entries: Array[Dictionary] = []
currency
Non-item currency: Dictionary keyed by StringName currency id with numeric amounts.
@export var currency: Dictionary = {}
source_resource
Reference back to the resource that produced this cost (e.g. the ScenePlacementEntry that defined it). Optional; informational only — refunders do not branch on this.
@export var source_resource: Resource
rule_cost
var rule_cost = from_costs(p_manipulatable.build_cost_rule.costs)
search_root
var search_root: Node = p_manipulatable.root if p_manipulatable.root != null else p_manipulatable
instance
var instance: PlaceableInstance = PlacementSearchUtils.find_first(search_root, PlaceableInstance)
costs
var costs = instance.placeable.get_build_costs()
cost
var cost = BuildCost.new()
cost
var cost = BuildCost.new()
cost
var cost = BuildCost.new()
cost
var cost = BuildCost.new()
Methods
resolve_for
static func resolve_for(p_manipulatable: Manipulatable) -> BuildCost:
Parameters
p_manipulatable
Returns
from_costs
static func from_costs(p_costs: Dictionary) -> BuildCost:
Parameters
p_costs
Returns
from_pairs
static func from_pairs(p_pairs: Array) -> BuildCost:
Parameters
p_pairs
Returns
from_resource_stacks
static func from_resource_stacks(p_stacks: Array[ResourceStack]) -> BuildCost:
Parameters
p_stacks