crafting system and improveemnts to mousetweaks
This commit is contained in:
parent
64d6e72407
commit
ccb15800a3
6 changed files with 45 additions and 5 deletions
|
|
@ -16,8 +16,9 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
func _on_loot_button_pressed() -> void:
|
func _on_loot_button_pressed() -> void:
|
||||||
if Clock.has_time(10):
|
if Clock.has_time(10):
|
||||||
Clock.use_time(10)
|
if bin_inventory.add_item(pick_random_item()):
|
||||||
bin_inventory.add_item(pick_random_item())
|
Clock.use_time(10)
|
||||||
|
#bin_inventory.add_item(pick_random_item())
|
||||||
|
|
||||||
#loot_button.hide()
|
#loot_button.hide()
|
||||||
#bin_inventory.show()
|
#bin_inventory.show()
|
||||||
|
|
|
||||||
|
|
@ -33,19 +33,39 @@ func _notification(what: int) -> void:
|
||||||
func check_recipes():
|
func check_recipes():
|
||||||
print("checking now")
|
print("checking now")
|
||||||
# write checking logic
|
# 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
|
pass
|
||||||
|
|
||||||
func style_assemble():
|
func style_assemble():
|
||||||
action_button.add_theme_stylebox_override("normal",assemble_style)
|
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("hover",assemble_style_hover)
|
||||||
action_button.add_theme_stylebox_override("pressed",assemble_style_pressed)
|
action_button.add_theme_stylebox_override("pressed",assemble_style_pressed)
|
||||||
|
action_button.text = "Assemble!"
|
||||||
|
action_button.disabled = false
|
||||||
|
|
||||||
func style_scavenge():
|
func style_scavenge():
|
||||||
action_button.add_theme_stylebox_override("normal",scavenge_style)
|
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("hover",scavenge_style_hover)
|
||||||
action_button.add_theme_stylebox_override("pressed",scavenge_style_pressed)
|
action_button.add_theme_stylebox_override("pressed",scavenge_style_pressed)
|
||||||
|
action_button.text = "Scavenge!"
|
||||||
|
action_button.disabled = false
|
||||||
|
|
||||||
func style_none():
|
func style_none():
|
||||||
action_button.remove_theme_stylebox_override("normal")
|
action_button.remove_theme_stylebox_override("normal")
|
||||||
action_button.remove_theme_stylebox_override("hover")
|
action_button.remove_theme_stylebox_override("hover")
|
||||||
action_button.remove_theme_stylebox_override("pressed")
|
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 true # item placed successfully
|
||||||
return false # theres no space to add the item
|
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
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("quick_move") and hovered_slot:
|
if Input.is_action_pressed("quick_move") and hovered_slot:
|
||||||
# figure out what the "other" inventory is and move it
|
# figure out what the "other" inventory is and move it
|
||||||
var current_inv : String = hovered_slot.type
|
var current_inv : String = hovered_slot.type
|
||||||
var target_inv : Inventory
|
var target_inv : Inventory
|
||||||
|
|
@ -27,5 +27,7 @@ func _process(delta: float) -> void:
|
||||||
# only runs if it was able to put the item in the target inv
|
# only runs if it was able to put the item in the target inv
|
||||||
hovered_slot.item = null
|
hovered_slot.item = null
|
||||||
hovered_slot.update_ui()
|
hovered_slot.update_ui()
|
||||||
|
player_inventory.notification(NOTIFICATION_DRAG_END)
|
||||||
|
other_inventory.notification(NOTIFICATION_DRAG_END)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
@export var ewaste_button : Button
|
||||||
|
@export var computer_button : Button
|
||||||
|
@export var crafting_inv : Inventory
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -8,7 +11,12 @@ func _ready() -> void:
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
if crafting_inv.filled_slots() > 0:
|
||||||
|
ewaste_button.disabled = true
|
||||||
|
computer_button.disabled = true
|
||||||
|
else:
|
||||||
|
ewaste_button.disabled = false
|
||||||
|
computer_button.disabled = false
|
||||||
|
|
||||||
|
|
||||||
func _on_goto_ewaste_pressed() -> void:
|
func _on_goto_ewaste_pressed() -> void:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
[ext_resource type="Script" uid="uid://bla0gy2tlqwe1" path="res://scenes/workshop.gd" id="1_g1tdj"]
|
[ext_resource type="Script" uid="uid://bla0gy2tlqwe1" path="res://scenes/workshop.gd" id="1_g1tdj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://f06ym5ujhdsc" path="res://inv_system/crafting_panel.tscn" id="2_wwo6w"]
|
[ext_resource type="PackedScene" uid="uid://f06ym5ujhdsc" path="res://inv_system/crafting_panel.tscn" id="2_wwo6w"]
|
||||||
|
|
||||||
[node name="Workshop" type="Control"]
|
[node name="Workshop" type="Control" node_paths=PackedStringArray("ewaste_button", "computer_button", "crafting_inv")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -13,6 +13,9 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
script = ExtResource("1_g1tdj")
|
script = ExtResource("1_g1tdj")
|
||||||
|
ewaste_button = NodePath("GotoEwaste")
|
||||||
|
computer_button = NodePath("GotoComputer")
|
||||||
|
crafting_inv = NodePath("CraftingPanel")
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue