Basic recipe
This commit is contained in:
parent
4bae29f29f
commit
11d928c4f3
9 changed files with 59 additions and 1 deletions
22
scripts/recipe/recipe_part.gd
Normal file
22
scripts/recipe/recipe_part.gd
Normal file
|
@ -0,0 +1,22 @@
|
|||
extends Resource
|
||||
|
||||
class_name RecipePart
|
||||
|
||||
@export var item : Comparable
|
||||
@export var amount : int
|
||||
|
||||
func is_stack_sufficient(stack: Stack) -> bool:
|
||||
return item.is_equal(stack.held_item) and stack.amount >= amount
|
||||
|
||||
func consume_stack(stack: Stack) -> bool:
|
||||
if is_stack_sufficient(stack) == false:
|
||||
return false
|
||||
stack.amount -= amount
|
||||
return true
|
||||
|
||||
func create_stack() -> Stack:
|
||||
if item is Item:
|
||||
return Stack.new(item,amount)
|
||||
elif item is ItemTag:
|
||||
return Stack.new(item.items[randi_range(0,len(item.items))],amount)
|
||||
return null
|
Loading…
Add table
Add a link
Reference in a new issue