Updated power station to not use coin_machine and cleaned up some of my mess

This commit is contained in:
akshay committed 2022-08-14 19:45:00 -04:00
1 parent e16d192ba0
commit 11826ef9d5
4 files changed
+37 -24

No files matched your search

+8 -4
View File
@@ -5,6 +5,7 @@ export var recipes: Resource
# Called when the node enters the scene tree for the first time.
func _ready():
assert(recipes != null)
update_coin_machine_status()
func get_craft_recipe_item():
var items_in_slots = [$slot_1.item_in_hold.item_type, $slot_2.item_in_hold.item_type]
@@ -37,11 +38,14 @@ func should_enable_coin_machine():
return false
return can_craft_recipe()
func update_coin_machine_status():
$coin_machine.enabled = should_enable_coin_machine()
func _on_craft_item_holder_item_changed(item):
$coin_machine.enabled = should_enable_coin_machine()
update_coin_machine_status()
func _on_slot_1_item_changed(item):
$coin_machine.enabled = should_enable_coin_machine()
update_coin_machine_status()
func _on_slot_2_item_changed(item):
$coin_machine.enabled = should_enable_coin_machine()
update_coin_machine_status()
+7 -5
View File
@@ -30,11 +30,13 @@ func collect_charges_from_station():
self.current_holding = 0
return charges_to_return
func _on_coin_machine_coin_requirement_met(player):
func on_player_interact(player) -> bool:
assert(player.has_method("modify_inventory"))
var charges = collect_charges_from_station()
player.modify_inventory("coins", charges)
if charges > 0:
$sounds/charge_get.play()
else:
if charges <= 0:
$sounds/error.play()
return false
player.modify_inventory("coins", charges)
$sounds/charge_get.play()
return true