Added comms array
This commit is contained in:
1 parent
eeb34f9372
commit
3a72e066ea
6 files changed
+169
-4
No files matched your search
@@ -0,0 +1,37 @@
|
||||
extends Spatial
|
||||
|
||||
const StateIdle = preload("res://scripts/comm_station/state/idle.gd")
|
||||
const StateBlocked = preload("res://scripts/comm_station/state/blocked.gd")
|
||||
|
||||
var state = null
|
||||
|
||||
signal comms_established
|
||||
|
||||
onready var coin_machine = $"%coin_machine"
|
||||
onready var item_dump = $"%item_dump"
|
||||
onready var status_text = $"%status_text"
|
||||
|
||||
func _ready():
|
||||
state = StateBlocked.new()
|
||||
state.ctx = self
|
||||
state.enter_from(null)
|
||||
print("comms_station: NULL -> ", state.NAME)
|
||||
|
||||
func change_state(new_state):
|
||||
print("comms_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_item_dump_item_dump_completed():
|
||||
state.on_item_dump_item_dump_completed()
|
||||
|
||||
func _on_item_dump_item_dumped():
|
||||
state.on_item_dump_item_dumped()
|
||||
|
||||
func emit_signal_comms_established():
|
||||
emit_signal("comms_established")
|
||||
@@ -0,0 +1,25 @@
|
||||
extends Reference
|
||||
|
||||
const NAME = "blocked"
|
||||
|
||||
var ctx = null
|
||||
|
||||
func _init():
|
||||
pass
|
||||
|
||||
func enter_from(state):
|
||||
ctx.coin_machine.enabled = false
|
||||
ctx.item_dump.enabled = true
|
||||
ctx.status_text.text = "Offline. Needs Repair"
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
|
||||
func on_coin_machine_coin_requirement_met(player):
|
||||
assert(false, "coin machine should be disabled in blocked state")
|
||||
|
||||
func on_item_dump_item_dump_completed():
|
||||
ctx.change_state(ctx.StateIdle.new())
|
||||
|
||||
func on_item_dump_item_dumped():
|
||||
print("item dumped")
|
||||
@@ -0,0 +1,25 @@
|
||||
extends Reference
|
||||
|
||||
const NAME = "idle"
|
||||
|
||||
var ctx = null
|
||||
|
||||
func _init():
|
||||
pass
|
||||
|
||||
func enter_from(state):
|
||||
ctx.coin_machine.enabled = true
|
||||
ctx.item_dump.enabled = false
|
||||
ctx.status_text.text = "Online"
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
|
||||
func on_coin_machine_coin_requirement_met(player):
|
||||
ctx.emit_signal_comms_established()
|
||||
|
||||
func on_item_dump_item_dump_completed():
|
||||
assert(false, "item dump should be disabled in idle state")
|
||||
|
||||
func _on_item_dump_item_dumped():
|
||||
assert(false, "item dump should be disabled in idle state")
|
||||
Reference in new issue
Block a user