fix: handles the case where no coroutines are run as part of room creation; also fixes a small bug in ESCCamera
This commit is contained in:
committed by
Julian Murgia
parent
503d6134dd
commit
85b86f38be
@@ -269,6 +269,10 @@ func init_room(room: ESCRoom) -> void:
|
|||||||
#
|
#
|
||||||
# - room: The ESCRoom to be initialized for use.
|
# - room: The ESCRoom to be initialized for use.
|
||||||
func _perform_script_events(room: ESCRoom) -> void:
|
func _perform_script_events(room: ESCRoom) -> void:
|
||||||
|
# Used to track whether any yields have been executed before the call to
|
||||||
|
# set_scene_finish.
|
||||||
|
var yielded: bool = false
|
||||||
|
|
||||||
if room.enabled_automatic_transitions \
|
if room.enabled_automatic_transitions \
|
||||||
and not room.is_run_directly \
|
and not room.is_run_directly \
|
||||||
and not room.exited_previous_room:
|
and not room.exited_previous_room:
|
||||||
@@ -296,6 +300,8 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
rc = yield(escoria.event_manager, "event_finished")
|
rc = yield(escoria.event_manager, "event_finished")
|
||||||
if rc[0] != ESCExecution.RC_OK:
|
if rc[0] != ESCExecution.RC_OK:
|
||||||
return rc[0]
|
return rc[0]
|
||||||
|
|
||||||
|
yielded = true
|
||||||
|
|
||||||
# Hide main and pause menus
|
# Hide main and pause menus
|
||||||
escoria.game_scene.hide_main_menu()
|
escoria.game_scene.hide_main_menu()
|
||||||
@@ -313,6 +319,11 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
if rc[0] != ESCExecution.RC_OK:
|
if rc[0] != ESCExecution.RC_OK:
|
||||||
return rc[0]
|
return rc[0]
|
||||||
|
|
||||||
|
yielded = true
|
||||||
|
|
||||||
|
if not yielded:
|
||||||
|
escoria.main.finish_current_scene_init(room)
|
||||||
|
|
||||||
escoria.main.set_scene_finish()
|
escoria.main.set_scene_finish()
|
||||||
|
|
||||||
# We know the scene has been loaded. Make its global ID available for
|
# We know the scene has been loaded. Make its global ID available for
|
||||||
@@ -360,7 +371,7 @@ func _perform_script_events(room: ESCRoom) -> void:
|
|||||||
rc = yield(escoria.event_manager, "event_finished")
|
rc = yield(escoria.event_manager, "event_finished")
|
||||||
if rc[0] != ESCExecution.RC_OK:
|
if rc[0] != ESCExecution.RC_OK:
|
||||||
return rc[0]
|
return rc[0]
|
||||||
|
|
||||||
# Now that :ready is finished, if FORCE_LAST_SCENE_NULL was true, reset it
|
# Now that :ready is finished, if FORCE_LAST_SCENE_NULL was true, reset it
|
||||||
# to false
|
# to false
|
||||||
if escoria.globals_manager.get_global( \
|
if escoria.globals_manager.get_global( \
|
||||||
|
|||||||
@@ -54,12 +54,30 @@ func set_scene(p_scene: Node) -> void:
|
|||||||
escoria.object_manager.set_current_room(p_scene)
|
escoria.object_manager.set_current_room(p_scene)
|
||||||
add_child(p_scene)
|
add_child(p_scene)
|
||||||
|
|
||||||
|
# In cases where the room being created doesn't return because of a
|
||||||
|
# coroutine, finish_current_scene_init() will already have been called
|
||||||
|
# and so we don't want to risk repeating ourselves.
|
||||||
|
if p_scene == current_scene:
|
||||||
|
return
|
||||||
|
|
||||||
# This actually moves the scene closest to the root node, but will
|
# This actually moves the scene closest to the root node, but will
|
||||||
# still be drawn behind the next node, which should be the previous
|
# still be drawn behind the next node, which should be the previous
|
||||||
# room.
|
# room.
|
||||||
move_child(p_scene, 0)
|
move_child(p_scene, 0)
|
||||||
|
|
||||||
current_scene = p_scene
|
current_scene = p_scene
|
||||||
|
|
||||||
|
check_game_scene_methods()
|
||||||
|
|
||||||
|
set_camera_limits()
|
||||||
|
|
||||||
|
|
||||||
|
# Only called by the room manager in the case where it hasn't executed a
|
||||||
|
# coroutine prior to calling set_scene_finish().
|
||||||
|
func finish_current_scene_init(p_scene: Node) -> void:
|
||||||
|
move_child(p_scene, 0)
|
||||||
|
|
||||||
|
current_scene = p_scene
|
||||||
|
|
||||||
check_game_scene_methods()
|
check_game_scene_methods()
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ func _ready():
|
|||||||
escoria.object_manager.CAMERA,
|
escoria.object_manager.CAMERA,
|
||||||
self
|
self
|
||||||
),
|
),
|
||||||
|
null,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user