SpendMaterialsRuleGeneric

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Generic material spending rule for placement validation.

Source File: addons/grid_building/placement/placement_rules/template_rules/spend_materials_rule_generic.gd

Extends: PlacementRule

Exported Properties

  • Property: resource_stacks_to_spend : Array[ResourceStack] = []

    How many of each type need to be spent for the building rule to pass Resource should have fields type and count defined

  • Property: locator : [NodeLocator](./node-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

Private Properties

  • Property: _mat_container : Object : (private) - The target container to search for materials to spend
  • Property: _owner_root : Node (private) - The spender root node where the material container should be located for spending resources from

Public Methods

setup

1
setup(p_gts : GridTargetingState) -> Array[String]

apply

1
apply() -> Array[String]

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

1
tear_down()

validate_placement

1
validate_placement() -> RuleResult

Checks to see if there are enough resources to build item


check_missing_resources

1
check_missing_resources(p_owner_root_container) -> Array[ResourceStack]

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


Private Methods

_get_material_container_from_user

1
_get_material_container_from_user(user : Node) -> Node

Flags: private

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

1
_get_pre_setup_issues(p_gts : GridTargetingState) -> Array[String]

Flags: private


_get_post_setup_issues

1
_get_post_setup_issues() -> Array[String]

Flags: private


_get_material_name

1
_get_material_name(p_material : Resource) -> String

Flags: private