fix: makes the loading process more consistent by using all ESC commands; also fixes issue caused by loaded save games not executing :setup or :ready, thereby preventing proper room switching in this case
This commit is contained in:
committed by
Julian Murgia
parent
ecb7bfb528
commit
84c84d3a0f
@@ -270,14 +270,16 @@ 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):
|
func _perform_script_events(room: ESCRoom):
|
||||||
if escoria.event_manager.is_channel_free(escoria.event_manager.CHANNEL_FRONT) \
|
# If we're loading from a saved game, we don't want to run :setup or :ready
|
||||||
or (
|
# as it could potentially alter the loaded save state; however, we still need
|
||||||
not escoria.event_manager.is_channel_free(escoria.event_manager.CHANNEL_FRONT) \
|
# to swap the scene in since it would ordinarily happen between :setup and
|
||||||
and not escoria.event_manager.get_running_event(
|
# :ready. Fun, huh?
|
||||||
|
if not escoria.event_manager.is_channel_free(escoria.event_manager.CHANNEL_FRONT) \
|
||||||
|
and escoria.event_manager.get_running_event(
|
||||||
escoria.event_manager.CHANNEL_FRONT
|
escoria.event_manager.CHANNEL_FRONT
|
||||||
).name == escoria.event_manager.EVENT_LOAD
|
).name == escoria.event_manager.EVENT_LOAD:
|
||||||
):
|
_make_new_room_visible(room)
|
||||||
|
else:
|
||||||
# If the room was loaded from change_scene and automatic transitions
|
# If the room was loaded from change_scene and automatic transitions
|
||||||
# are not disabled, do the transition out now
|
# are not disabled, do the transition out now
|
||||||
if room.enabled_automatic_transitions \
|
if room.enabled_automatic_transitions \
|
||||||
@@ -326,13 +328,7 @@ func _perform_script_events(room: ESCRoom):
|
|||||||
|
|
||||||
# Switch the rooms (resources are freed at end of change_scene and in
|
# Switch the rooms (resources are freed at end of change_scene and in
|
||||||
# clear_scene).
|
# clear_scene).
|
||||||
|
_make_new_room_visible(room)
|
||||||
if room != escoria.main.current_scene:
|
|
||||||
escoria.main.current_scene.visible = false
|
|
||||||
#escoria.main.current_scene.z_index = -100
|
|
||||||
|
|
||||||
room.visible = true
|
|
||||||
#room.z_index = 0
|
|
||||||
|
|
||||||
if room.enabled_automatic_transitions \
|
if room.enabled_automatic_transitions \
|
||||||
or (
|
or (
|
||||||
@@ -393,6 +389,20 @@ func _perform_script_events(room: ESCRoom):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Switches the visibility of the "old" room and the "new" room.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - room: The ESCRoom to be made visible in place of the current one.
|
||||||
|
func _make_new_room_visible(room: ESCRoom) -> void:
|
||||||
|
if is_instance_valid(escoria.main.current_scene) and room != escoria.main.current_scene:
|
||||||
|
escoria.main.current_scene.visible = false
|
||||||
|
#escoria.main.current_scene.z_index = -100
|
||||||
|
|
||||||
|
room.visible = true
|
||||||
|
#room.z_index = 0
|
||||||
|
|
||||||
|
|
||||||
# Runs the script event from the script attached, if any.
|
# Runs the script event from the script attached, if any.
|
||||||
#
|
#
|
||||||
# #### Parameters
|
# #### Parameters
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ var _set_active: SetActiveCommand
|
|||||||
var _set_interactive: SetInteractiveCommand
|
var _set_interactive: SetInteractiveCommand
|
||||||
var _teleport_pos: TeleportPosCommand
|
var _teleport_pos: TeleportPosCommand
|
||||||
var _set_angle: SetAngleCommand
|
var _set_angle: SetAngleCommand
|
||||||
|
var _set_global: SetGlobalCommand
|
||||||
var _set_state: SetStateCommand
|
var _set_state: SetStateCommand
|
||||||
var _stop_snd: StopSndCommand
|
var _stop_snd: StopSndCommand
|
||||||
var _play_snd: PlaySndCommand
|
var _play_snd: PlaySndCommand
|
||||||
@@ -51,6 +52,7 @@ func _init():
|
|||||||
_set_interactive = SetInteractiveCommand.new()
|
_set_interactive = SetInteractiveCommand.new()
|
||||||
_teleport_pos = TeleportPosCommand.new()
|
_teleport_pos = TeleportPosCommand.new()
|
||||||
_set_angle = SetAngleCommand.new()
|
_set_angle = SetAngleCommand.new()
|
||||||
|
_set_global = SetGlobalCommand.new()
|
||||||
_set_state = SetStateCommand.new()
|
_set_state = SetStateCommand.new()
|
||||||
_stop_snd = StopSndCommand.new()
|
_stop_snd = StopSndCommand.new()
|
||||||
_play_snd = PlaySndCommand.new()
|
_play_snd = PlaySndCommand.new()
|
||||||
@@ -279,14 +281,6 @@ func load_game(id: int):
|
|||||||
ESCCommand.new("%s pause" % _hide_menu.get_command_name())
|
ESCCommand.new("%s pause" % _hide_menu.get_command_name())
|
||||||
)
|
)
|
||||||
|
|
||||||
## GLOBALS
|
|
||||||
for k in save_game.globals.keys():
|
|
||||||
escoria.globals_manager.set_global(
|
|
||||||
k,
|
|
||||||
save_game.globals[k],
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
## ROOM
|
## ROOM
|
||||||
load_statements.append(
|
load_statements.append(
|
||||||
ESCCommand.new("%s %s false" %
|
ESCCommand.new("%s %s false" %
|
||||||
@@ -297,6 +291,16 @@ func load_game(id: int):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
## GLOBALS
|
||||||
|
for k in save_game.globals.keys():
|
||||||
|
ESCCommand.new("%s %s %s" %
|
||||||
|
[
|
||||||
|
_set_global.get_command_name(),
|
||||||
|
k,
|
||||||
|
save_game.globals[k]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
## OBJECTS
|
## OBJECTS
|
||||||
for object_global_id in save_game.objects.keys():
|
for object_global_id in save_game.objects.keys():
|
||||||
if escoria.object_manager.has(object_global_id) and \
|
if escoria.object_manager.has(object_global_id) and \
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ func add_new_item_by_id(item_id: String) -> void:
|
|||||||
item_id,
|
item_id,
|
||||||
ResourceLoader.load(inventory_file).instance()
|
ResourceLoader.load(inventory_file).instance()
|
||||||
),
|
),
|
||||||
|
null,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -79,6 +80,7 @@ func add_new_item_by_id(item_id: String) -> void:
|
|||||||
item_id,
|
item_id,
|
||||||
inventory_item_button
|
inventory_item_button
|
||||||
),
|
),
|
||||||
|
null,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user