fixed recipe checking, hoping it doesnt cost too much performace
This commit is contained in:
parent
dc03f4d353
commit
09625d8285
2 changed files with 29 additions and 19 deletions
|
|
@ -54,18 +54,35 @@ func check_recipes():
|
|||
|
||||
elif filled_slots() > 1:
|
||||
# check crafting recipes
|
||||
var possible_recipes : Array[CraftRecipe] = RecipeManager.craft_recipes.duplicate()
|
||||
#var possible_recipes : Array[CraftRecipe] = RecipeManager.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!")
|
||||
#matched_recipe = possible_recipes[0]
|
||||
#style_assemble()
|
||||
#return
|
||||
for recipe in RecipeManager.craft_recipes:
|
||||
var matches : int = 0
|
||||
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)
|
||||
matches = 0
|
||||
else:
|
||||
matches += 1
|
||||
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!")
|
||||
matched_recipe = possible_recipes[0]
|
||||
matches = 0
|
||||
else:
|
||||
matches += 1
|
||||
|
||||
if matches == 9:
|
||||
matched_recipe = recipe
|
||||
style_assemble()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://f06ym5ujhdsc"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://f06ym5ujhdsc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://br4fgimf7nygr" path="res://inv_system/crafting_panel.gd" id="1_441s3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgqs20xf7l8c" path="res://inv_system/item_slot.tscn" id="2_h0v0h"]
|
||||
[ext_resource type="Script" uid="uid://b4iu5xrdf0evs" path="res://crafting/craft_recipe.gd" id="2_ytbts"]
|
||||
[ext_resource type="Resource" uid="uid://dp4hnei3ur6oe" path="res://crafting/crafts/computer_craft.tres" id="3_4h4i0"]
|
||||
[ext_resource type="Script" uid="uid://boqr1fowaqmt0" path="res://crafting/scavenge_recipe.gd" id="4_qjage"]
|
||||
[ext_resource type="Resource" uid="uid://deohei5avmspt" path="res://crafting/scavenges/large_psu_scav.tres" id="5_8c40c"]
|
||||
[ext_resource type="Resource" uid="uid://dpnp3xlwhla4h" path="res://crafting/scavenges/small_psu_scav.tres" id="6_8c40c"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_h0v0h"]
|
||||
content_margin_left = 0.0
|
||||
|
|
@ -87,8 +82,6 @@ offset_right = 962.0
|
|||
offset_bottom = 382.0
|
||||
script = ExtResource("1_441s3")
|
||||
action_button = NodePath("MarginContainer/VBoxContainer/ActionButton")
|
||||
craft_recipes = Array[ExtResource("2_ytbts")]([ExtResource("3_4h4i0")])
|
||||
scavenge_recipes = Array[ExtResource("4_qjage")]([ExtResource("5_8c40c"), ExtResource("6_8c40c")])
|
||||
assemble_style = SubResource("StyleBoxFlat_h0v0h")
|
||||
assemble_style_hover = SubResource("StyleBoxFlat_441s3")
|
||||
assemble_style_pressed = SubResource("StyleBoxFlat_h0v0h")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue