crafting system and improveemnts to mousetweaks
This commit is contained in:
parent
64d6e72407
commit
ccb15800a3
6 changed files with 45 additions and 5 deletions
|
|
@ -33,19 +33,39 @@ func _notification(what: int) -> void:
|
|||
func check_recipes():
|
||||
print("checking now")
|
||||
# write checking logic
|
||||
var possible_recipes : Array[CraftRecipe] = craft_recipes.duplicate()
|
||||
for x in range(9):
|
||||
for recipe in possible_recipes:
|
||||
if recipe.ingredients[x] and slots[x].item:
|
||||
if recipe.ingredients[x].item_name != slots[x].item.item_name:
|
||||
possible_recipes.erase(recipe)
|
||||
elif recipe.ingredients[x] or slots[x].item:
|
||||
possible_recipes.erase(recipe)
|
||||
print("Possible recipes: " + str(possible_recipes.size()))
|
||||
if possible_recipes.size() == 1:
|
||||
print("found our recipe!")
|
||||
style_assemble()
|
||||
else:
|
||||
style_none()
|
||||
pass
|
||||
|
||||
func style_assemble():
|
||||
action_button.add_theme_stylebox_override("normal",assemble_style)
|
||||
action_button.add_theme_stylebox_override("hover",assemble_style_hover)
|
||||
action_button.add_theme_stylebox_override("pressed",assemble_style_pressed)
|
||||
action_button.text = "Assemble!"
|
||||
action_button.disabled = false
|
||||
|
||||
func style_scavenge():
|
||||
action_button.add_theme_stylebox_override("normal",scavenge_style)
|
||||
action_button.add_theme_stylebox_override("hover",scavenge_style_hover)
|
||||
action_button.add_theme_stylebox_override("pressed",scavenge_style_pressed)
|
||||
action_button.text = "Scavenge!"
|
||||
action_button.disabled = false
|
||||
|
||||
func style_none():
|
||||
action_button.remove_theme_stylebox_override("normal")
|
||||
action_button.remove_theme_stylebox_override("hover")
|
||||
action_button.remove_theme_stylebox_override("pressed")
|
||||
action_button.text = "no matching recipe"
|
||||
action_button.disabled = true
|
||||
|
|
|
|||
|
|
@ -46,3 +46,9 @@ func add_item(item : ItemData) -> bool:
|
|||
return true # item placed successfully
|
||||
return false # theres no space to add the item
|
||||
|
||||
func filled_slots() -> int:
|
||||
var count : int = 0
|
||||
for slot in slots:
|
||||
if slot.item:
|
||||
count += 1
|
||||
return count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue