Updated the level.glb with new asset. Updated comm station to match the new asset and added broken state to it

This commit is contained in:
akshay committed 2022-08-19 23:11:22 -04:00
1 parent 1534a9a216
commit 4a715d9b6d
6 files changed
+43 -27

No files matched your search

+8 -3
View File
@@ -1,7 +1,7 @@
extends Spatial
extends Damageable
const StateIdle = preload("res://scripts/comm_station/state/idle.gd")
const StateBlocked = preload("res://scripts/comm_station/state/blocked.gd")
const StateBroken = preload("res://scripts/comm_station/state/broken.gd")
var state = null
@@ -10,9 +10,10 @@ signal comms_established
onready var coin_machine = $"%coin_machine"
onready var item_dump = $"%item_dump"
onready var status_text = $"%status_text"
onready var status_light = $"%status_light"
func _ready():
state = StateBlocked.new()
state = StateBroken.new() if start_broken else StateIdle.new()
state.ctx = self
state.enter_from(null)
print("comms_station: NULL -> ", state.NAME)
@@ -33,5 +34,9 @@ func _on_item_dump_item_dump_completed():
func _on_item_dump_item_dumped():
state.on_item_dump_item_dumped()
func take_damage(damage : int = 1):
.take_damage(damage)
state.on_damage_taken()
func emit_signal_comms_established():
emit_signal("comms_established")
@@ -1,6 +1,6 @@
extends Reference
const NAME = "blocked"
const NAME = "broken"
var ctx = null
@@ -11,6 +11,7 @@ func enter_from(state):
ctx.coin_machine.enabled = false
ctx.item_dump.enabled = true
ctx.status_text.text = "Offline. Needs Repair"
ctx.status_light.fail()
func exit_to(state):
pass
@@ -23,3 +24,6 @@ func on_item_dump_item_dump_completed():
func on_item_dump_item_dumped():
print("item dumped")
func on_damage_taken():
assert(false, "should be impossible in blocked state")
+6
View File
@@ -11,11 +11,13 @@ func enter_from(state):
ctx.coin_machine.enabled = true
ctx.item_dump.enabled = false
ctx.status_text.text = "Online"
ctx.status_light.idle()
func exit_to(state):
pass
func on_coin_machine_coin_requirement_met(player):
ctx.status_light.activate()
ctx.emit_signal_comms_established()
func on_item_dump_item_dump_completed():
@@ -23,3 +25,7 @@ func on_item_dump_item_dump_completed():
func _on_item_dump_item_dumped():
assert(false, "item dump should be disabled in idle state")
func on_damage_taken():
if ctx.current_hp <= 0:
ctx.change_state(ctx.StateBroken.new())