Class GGCrafting extends Node
This Crafting component crafts items using inventories.
What items can be crafted is specified by the
recipes. If auto_craft is true, the crafting component will automatically monitor the input_inventory and start crafting when it contains sufficient ingredients for any of its craftable recipes. Items are consumed from the input_inventory, crafted, and deposited into the output_inventory. Use the craft() method to craft items manually. The current_state will indicate the crafting [enum State]. If there's insufficient room in the output_inventory, crafting will remain in the DEPOSITING state until there is room.When there's nothing to do, crafting is idle.State.IDLE = 0Crafting is in progress.State.CRAFTING = 1Crafted items are being deposited.State.DEPOSITING = 2# Signals
## Emitted when crafting has started for the [param recipe].signal crafting_started## Continuously emitted as the [param recipe] is crafted. The [param progress_percent] indicates how far crafting has progressed in percent (from 0.0 - 1.0).signal crafting_progress(progress_percent: float) ## Emitted when crafting the [param recipe] has finished. The crafted items can be retrieved via the [member output] property. The signal is emitted before the items are added to the [member output_inventory]. This signal can be used to modify items after crafting.signal crafting_finished## Emitted when crafting changes state. The [param new_state] and [param old_state] will each be a [enum State].signal crafting_state_changed(new_state: intold_state: int) signal crafting_recipes_changed# Members
var enabled: bool = true## The inventory that ingredients are taken from.var input_inventory: GGInventory## The inventory that crafting results are output to.var output_inventory: GGInventory## A list of recipes that can be crafted.var recipes: GGRecipeCollectionvar crafting_strategy: GGCraftingStrategy## A larger number speeds up crafting.var speed_multiplier: float = 1.0## Automatically starts crafting if sufficient ingredients are found.var auto_craft: bool = true## How long to wait before crafting starts. This can help improve the user experience by ensuring the player sees the items they're adding to the inventory before they're consumed by crafting.var auto_craft_delay: float = 1.0## Helps resolve [code]context_id[/code]s.var entity_access_manager: GGEntityAccessManagervar crafting_policy: GGCraftingPolicyvar multiplayer_update_rate: float = 1.0## What the crafting mechanism is currently doingvar current_state: intvar current_crafter: Node## Once crafting is finished, the results are temporarily stored here before being moved to the [member output_inventory]. If the [member output_inventory] has no room, the results are held until room becomes available.var current_output: GGItemData[]## The current crafting progress. This is a value between 0 and [member current_recipe][code].work[/code].var work_progress: float = 0.0## The currently active recipe that is being crafted. [br][br][b]Note[/b]: The recipe provided must be in the [member recipes] collection. This is required for clients to correctly set the recipe on their side.var current_recipe: GGCraftingRecipe = null# Methods
## Returns whether the [param actor] can craft the [param recipe].func can_craft(recipe: GGCraftingRecipeactor: Node) -> bool## Returns whether the [param actor] can make the [param amount] of progress while crafting the [param recipe].func can_progress(recipe: GGCraftingRecipeamount: floatactor: Node) -> bool## Craft the items specified by the [param recipe]. The [param actor] is the character performing the crafting. If crafting is automatic (via [member auto_craft]), then the [param actor] is the [GGCrafting] component itself. Returns [code]true[/code] if the [member input_inventory] has the ingredients, which kicks off the crafting process. If there are insufficient ingredients, crafting will not start, and the method will return [code]false[/code].func start_crafting(recipe: GGCraftingRecipeactor: Node) -> boolfunc request_start_crafting(recipe: GGCraftingRecipecontext_id: int) -> voidfunc progress_crafting(progress: floatactor: Node) -> void## Adds [param progress] to the current crafting.func request_progress_crafting(amount: floatcontext_id: int) -> voidfunc get_subscribers() -> Array[int]func find_first_craftable_recipe() -> GGCraftingRecipefunc find_craftable_recipes() -> Array[GGCraftingRecipe]