33 lines
929 B
GDScript
33 lines
929 B
GDScript
extends Spatial
|
|
|
|
const StateIdle = preload("res://scripts/hydroponics_station/state/idle.gd")
|
|
const StateGrowing = preload("res://scripts/hydroponics_station/state/growing.gd")
|
|
const StateBlocked = preload("res://scripts/hydroponics_station/state/blocked.gd")
|
|
|
|
export var grow_time: float = 2.0
|
|
var state = null
|
|
|
|
func _ready():
|
|
$grow_timer.wait_time = grow_time
|
|
|
|
state = StateIdle.new()
|
|
state.ctx = self
|
|
state.enter_from(null)
|
|
print("hydroponics_station: NULL -> ", state.NAME)
|
|
|
|
func change_state(new_state):
|
|
print("hydroponics_station: ", 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_grow_timer_timeout():
|
|
state.on_grow_timer_timeout()
|
|
|
|
func _on_item_holder_item_changed(item):
|
|
state.on_item_holder_item_changed(item)
|