50 lines
1.2 KiB
GDScript
50 lines
1.2 KiB
GDScript
extends Reference
|
|
|
|
const NAME = "working"
|
|
|
|
var ctx = null
|
|
|
|
func _init():
|
|
pass
|
|
|
|
func enter_from(state):
|
|
assert(ctx.item_to_craft != null)
|
|
ctx.coin_machine.enabled = false
|
|
ctx.item_dump.enabled = false
|
|
for item_slot in ctx.item_slots:
|
|
item_slot.add_enabled = false
|
|
item_slot.remove_enabled = false
|
|
ctx.gen_timer.start()
|
|
ctx.status_light.activate()
|
|
ctx.progress_text.text = "Progress: 0%"
|
|
|
|
func exit_to(state):
|
|
ctx.gen_timer.stop()
|
|
|
|
func update(delta):
|
|
var time_left : float = ctx.gen_timer.time_left
|
|
var time_passed : float = ctx.gen_time - time_left
|
|
var percent_complete : float = (time_passed / ctx.gen_time) * 100.0
|
|
ctx.progress_text.text = "Progress: %d%%" % percent_complete
|
|
|
|
func on_coin_machine_coin_requirement_met(player):
|
|
assert(false, "coin machine should be disabled while crafting")
|
|
|
|
func on_item_dump_item_dump_completed():
|
|
pass
|
|
|
|
func on_gen_timer_timeout():
|
|
var crafted_item : Resource = ctx.item_to_craft
|
|
for item_slot in ctx.item_slots:
|
|
if item_slot.has_item():
|
|
item_slot.destroy_item()
|
|
ctx.item_slots[0].spawn_item(crafted_item)
|
|
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
|
|
|
func on_slot_item_changed(item):
|
|
pass
|
|
|
|
func on_damage_taken():
|
|
if ctx.current_hp <= 0:
|
|
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|