43 lines
1.1 KiB
GDScript
43 lines
1.1 KiB
GDScript
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 start_broken: bool = false
|
|
export var max_hp: int = 1
|
|
var hp: int = max_hp
|
|
|
|
var state = null
|
|
|
|
func _ready():
|
|
$cook_timer.wait_time = cook_time
|
|
state = StateBroken.new() if start_broken else StateIdle.new()
|
|
state.ctx = self
|
|
state.enter_from(null)
|
|
print("oven: NULL -> ", state.NAME)
|
|
|
|
func change_state(new_state):
|
|
print("oven: ", state.NAME, " -> ", new_state.NAME)
|
|
new_state.ctx = self
|
|
state.exit_to(new_state)
|
|
new_state.enter_from(state)
|
|
state = new_state
|
|
|
|
func _on_coin_machine_coin_requirement_met(player):
|
|
state.on_coin_machine_coin_requirement_met(player)
|
|
|
|
func _on_cook_timer_timeout():
|
|
state.on_cook_timer_timeout()
|
|
|
|
func _on_item_holder_item_changed(item):
|
|
state.on_item_holder_item_changed(item)
|
|
|
|
func _on_item_dump_completed():
|
|
state.on_item_dump_completed()
|
|
|
|
func take_damage():
|
|
state.take_damage()
|