This commit is contained in:
snider committed 2022-08-15 21:42:48 -07:00
1 parent 83fc7e5924
commit 4c8a337a2d
12 files changed
+344 -3

No files matched your search

+16 -2
View File
@@ -3,18 +3,28 @@ extends Spatial
const StateIdle = preload("res://scripts/oven/state/idle.gd")
const StateCooking = preload("res://scripts/oven/state/cooking.gd")
const StateHoldingItem = preload("res://scripts/oven/state/holding_item.gd")
const StateBroken = preload("res://scripts/oven/state/broken.gd")
export var cook_time: float = 2.0
export var broken: bool = false setget set_broken
var state = null
func _ready():
$cook_timer.wait_time = cook_time
state = StateIdle.new()
if broken:
state = StateBroken.new()
else:
state = StateIdle.new()
state.ctx = self
state.enter_from(null)
print("oven: NULL -> ", state.NAME)
func set_broken(new_value: bool):
if broken == new_value:
return
broken == new_value
state.on_broken(broken)
func change_state(new_state):
print("oven: ", state.NAME, " -> ", new_state.NAME)
new_state.ctx = self
@@ -30,3 +40,7 @@ func _on_cook_timer_timeout():
func _on_item_holder_item_changed(item):
state.on_item_holder_item_changed(item)
func _on_item_dump_item_dump_completed():
pass # Replace with function body.
+34
View File
@@ -0,0 +1,34 @@
extends Reference
const NAME = "broken"
var ctx = null
func _init():
pass
func enter_from(state):
ctx.get_node("item_dump").enabled = true
ctx.get_node("item_dump").reset()
ctx.get_node("coin_machine").enabled = false
ctx.get_node("%item_holder").add_enabled = false
ctx.get_node("%item_holder").remove_enabled = false
ctx.get_node("status_light").fail()
func exit_to(state):
pass
func on_break():
assert(false, "should be impossible while broken")
func on_fix():
ctx.change_state(ctx.StateIdle.new())
func on_coin_machine_coin_requirement_met(player):
assert(false, "should be impossible while broken")
func on_cook_timer_timeout():
assert(false, "should be impossible while broken")
func on_item_holder_item_changed(item):
assert(false, "should be impossible while broken")
+2
View File
@@ -16,6 +16,8 @@ func enter_from(state):
ctx.get_node("cook_timer").start()
ctx.get_node("%coil").set_surface_material(0, mat)
ctx.get_node("status_light").light_color = Color.green
ctx.get_node("status_light").activate()
func exit_to(state):
ctx.get_node("%coil").set_surface_material(0, null)
+2
View File
@@ -13,10 +13,12 @@ func enter_from(state):
ctx.get_node("coin_machine").enabled = true
ctx.get_node("%item_holder").add_enabled = false
ctx.get_node("%item_holder").remove_enabled = false
ctx.get_node("status_light").prime()
else:
ctx.get_node("coin_machine").enabled = false
ctx.get_node("%item_holder").add_enabled = true
ctx.get_node("%item_holder").remove_enabled = true
ctx.get_node("status_light").warn()
func exit_to(state):
pass
+1
View File
@@ -11,6 +11,7 @@ func enter_from(state):
ctx.get_node("coin_machine").enabled = false
ctx.get_node("%item_holder").add_enabled = true
ctx.get_node("%item_holder").remove_enabled = false # not possible
ctx.get_node("status_light").light_color = Color.white
func exit_to(state):
pass