Files
KickSurvivors/scripts/MergeRecipes.gd
T

51 lines
1.4 KiB
GDScript

class_name MergeRecipes
# Add new crafting recipes here.
# speed_threshold = minimum collision_speed to trigger the merge.
static var _list: Array[Dictionary] = [
{
"ingredients": ["leather", "stick"],
"result_scene": "res://scenes/LeatherBoots.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["rock", "rock"],
"result_scene": "res://scenes/Boulder.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["stick", "stick"],
"result_scene": "res://scenes/StickArmor.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["leather", "rock"],
"result_scene": "res://scenes/LeatherArmor.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["leather", "metal_plate"],
"result_scene": "res://scenes/PlateArmor.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["rock", "stick"],
"result_scene": "res://scenes/WoodenShield.tscn",
"speed_threshold": 18.0,
},
{
"ingredients": ["iron", "leather"],
"result_scene": "res://scenes/IronShield.tscn",
"speed_threshold": 18.0,
},
]
static func find(type_a: String, type_b: String, speed: float) -> Dictionary:
for r in _list:
var a: String = r["ingredients"][0]
var b: String = r["ingredients"][1]
var match_ab := (a == type_a and b == type_b) or (a == type_b and b == type_a)
if match_ab and speed >= float(r.get("speed_threshold", 3.0)):
return r
return {}