SpendMaterialsRuleGeneric
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: placement/placement_rules/template_rules/spend_materials_rule_generic.gd
Version: 5.0
class_name: SpendMaterialsRuleGeneric
extends: PlacementRule
Summary
Generic material spending rule for placement validation.
Allows custom resource classes without building system inventory dependencies. Expects resource stacks with type and count properties. Looks for _mat_container on the target building node.[br][br] [b]Required inventory methods:[/b][br] • [code]try_add[/code] or [code]add[/code] - Parameters: type: Resource, count: int[br] • [code]try_remove[/code] or [code]remove[/code] - Parameters: type: Resource, count: int[br] • [code]get_count[/code] - Parameters: type: Resource - Returns: int[br][br] Alternative: inherit from VirtualItemContainer and implement the methods.
Signals
(none)
Exports
resource_stacks_to_spend- How many of each type need to be spent for the building rule to pass Resource should have fields type and count defined
locator- Used to find the inventory on the _owner_root passed in as a setup parameter so that the rule knows where to spend the resource_stacks_to_spend from
Methods
_init()setup()apply()- Tries to spend the resources from the _mat_container Returns an array of issues found during the spending process If the spending was successful, the array will be empty
tear_down()validate_placement()- Checks to see if there are enough resources to build item
check_missing_resources()- Checks the resouce _mat_container to see if it has enough of each resource type Returns ItemStacks that contain the amount missing for each type
_get_material_container_from_user()- Finds the container for the spendable materials by searching either for the matching node by name or class name Starts at the user node of the building system and then checks children nodes recursively
_get_pre_setup_issues()_get_post_setup_issues()_get_material_name()