fix: forces current_state updates as options don't always yield

This commit is contained in:
Duncan Brown
2023-01-24 13:17:35 -05:00
parent c597414659
commit 0ba6c3782a

View File

@@ -81,15 +81,15 @@ func run():
"Starting dialog." "Starting dialog."
) )
# Since we're changing state, we need to remember and reset it once we're done
var previous_state = escoria.current_state
escoria.current_state = escoria.GAME_STATE.DIALOG escoria.current_state = escoria.GAME_STATE.DIALOG
if !escoria.dialog_player: if !escoria.dialog_player:
escoria.dialog_player = escoria.main.current_scene.get_node( escoria.dialog_player = escoria.main.current_scene.get_node(
"game/ui/dialog_layer/dialog_player" "game/ui/dialog_layer/dialog_player"
) )
escoria.dialog_player.start_dialog_choices(self) escoria.dialog_player.start_dialog_choices(self)
var option = yield( var option = yield(
escoria.dialog_player, escoria.dialog_player,
"option_chosen" "option_chosen"
@@ -105,8 +105,12 @@ func run():
if rc is GDScriptFunctionState: if rc is GDScriptFunctionState:
rc = yield(rc, "completed") rc = yield(rc, "completed")
if rc != ESCExecution.RC_CANCEL: if rc != ESCExecution.RC_CANCEL:
# We also set this here in case a chosen option doesn't yield, since this block
# will return normally and not allow the current_state reset at the bottom of this
# method to run.
escoria.current_state = escoria.GAME_STATE.DEFAULT
return self.run() return self.run()
escoria.current_state = previous_state escoria.current_state = escoria.GAME_STATE.DEFAULT
return rc return rc