wip: rough attempt at properly incorporating existing coroutines to correctly place room swapping.
This commit is contained in:
committed by
Julian Murgia
parent
c87e853ba6
commit
114ef2fc55
@@ -268,7 +268,10 @@ func init_room(room: ESCRoom) -> void:
|
|||||||
# #### Parameters
|
# #### Parameters
|
||||||
#
|
#
|
||||||
# - room: The ESCRoom to be initialized for use.
|
# - room: The ESCRoom to be initialized for use.
|
||||||
func _perform_script_events(room: ESCRoom):
|
#
|
||||||
|
# *Returns* ESCExecution.RC_OK when completed or the function's state in the
|
||||||
|
# case a coroutine is yielding.
|
||||||
|
func _perform_script_events(room: ESCRoom) -> int:
|
||||||
# If we're loading from a saved game, we don't want to run :setup or :ready
|
# If we're loading from a saved game, we don't want to run :setup or :ready
|
||||||
# as it could potentially alter the loaded save state; however, we still need
|
# as it could potentially alter the loaded save state; however, we still need
|
||||||
# to swap the scene in since it would ordinarily happen between :setup and
|
# to swap the scene in since it would ordinarily happen between :setup and
|
||||||
@@ -277,7 +280,7 @@ func _perform_script_events(room: ESCRoom):
|
|||||||
and escoria.event_manager.get_running_event(
|
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)
|
escoria.main.set_scene_finish(room)
|
||||||
else:
|
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
|
||||||
@@ -325,9 +328,20 @@ func _perform_script_events(room: ESCRoom):
|
|||||||
if rc[0] != ESCExecution.RC_OK:
|
if rc[0] != ESCExecution.RC_OK:
|
||||||
return rc[0]
|
return rc[0]
|
||||||
|
|
||||||
# Switch the rooms (resources are freed at end of change_scene and in
|
escoria.main.set_scene_finish()
|
||||||
# clear_scene).
|
|
||||||
_make_new_room_visible(room)
|
# We know the scene has been loaded. Make its global ID available for
|
||||||
|
# use by ESC script.
|
||||||
|
escoria.globals_manager.set_global(
|
||||||
|
escoria.room_manager.GLOBAL_CURRENT_SCENE,
|
||||||
|
room.global_id,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
# Clear queued resources
|
||||||
|
escoria.resource_cache.clear()
|
||||||
|
|
||||||
|
escoria.inputs_manager.hotspot_focused = ""
|
||||||
|
|
||||||
if room.enabled_automatic_transitions \
|
if room.enabled_automatic_transitions \
|
||||||
or (
|
or (
|
||||||
@@ -387,19 +401,7 @@ func _perform_script_events(room: ESCRoom):
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return ESCExecution.RC_OK
|
||||||
# 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.
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ var last_scene_global_id: String
|
|||||||
# Current scene room being displayed
|
# Current scene room being displayed
|
||||||
var current_scene: Node
|
var current_scene: Node
|
||||||
|
|
||||||
|
# Scene that was previously the current scene.
|
||||||
|
var previous_scene: Node
|
||||||
|
|
||||||
# The Escoria context currently in wait state
|
# The Escoria context currently in wait state
|
||||||
var wait_level
|
var wait_level
|
||||||
|
|
||||||
@@ -37,21 +40,21 @@ func set_scene(p_scene: Node) -> void:
|
|||||||
if !p_scene:
|
if !p_scene:
|
||||||
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
||||||
|
|
||||||
|
previous_scene = current_scene
|
||||||
|
|
||||||
if not p_scene.is_inside_tree():
|
if not p_scene.is_inside_tree():
|
||||||
# Set the scene's visiblity for :setup events if the new room is not the
|
# Set the scene's visiblity for :setup events if the new room is not the
|
||||||
# same one as the current room. Note that the room's
|
# same one as the current room.
|
||||||
# _ready() method will ensure that the room is visible when
|
|
||||||
# :setup is complete.
|
|
||||||
if not _is_same_scene(current_scene, p_scene):
|
if not _is_same_scene(current_scene, p_scene):
|
||||||
p_scene.visible = false
|
p_scene.visible = false
|
||||||
|
|
||||||
#p_scene.z_index = -100
|
|
||||||
escoria.object_manager.set_current_room(p_scene)
|
escoria.object_manager.set_current_room(p_scene)
|
||||||
add_child(p_scene)
|
add_child(p_scene)
|
||||||
move_child(p_scene, 0)
|
|
||||||
|
|
||||||
if current_scene != null:
|
# This actually moves the scene closest to the root node, but will
|
||||||
clear_scene()
|
# still be drawn behind the next node, which should be the previous
|
||||||
|
# room.
|
||||||
|
move_child(p_scene, 0)
|
||||||
|
|
||||||
current_scene = p_scene
|
current_scene = p_scene
|
||||||
|
|
||||||
@@ -59,24 +62,34 @@ func set_scene(p_scene: Node) -> void:
|
|||||||
|
|
||||||
set_camera_limits()
|
set_camera_limits()
|
||||||
|
|
||||||
|
|
||||||
|
# Completes the room swap and should be called by the room manager at the
|
||||||
|
# appropriate time.
|
||||||
|
func set_scene_finish() -> void:
|
||||||
|
current_scene.visible = true
|
||||||
|
|
||||||
|
if previous_scene != null:
|
||||||
|
clear_scene()
|
||||||
|
|
||||||
emit_signal("room_ready")
|
emit_signal("room_ready")
|
||||||
|
|
||||||
|
|
||||||
# Cleanup the current scene
|
# Cleanup the previous scene
|
||||||
func clear_scene() -> void:
|
func clear_scene() -> void:
|
||||||
if current_scene == null:
|
if previous_scene == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
escoria.action_manager.clear_current_action()
|
escoria.action_manager.clear_current_action()
|
||||||
escoria.action_manager.clear_current_tool()
|
escoria.action_manager.clear_current_tool()
|
||||||
|
|
||||||
if escoria.game_scene.get_parent() == current_scene:
|
if escoria.game_scene.get_parent() == previous_scene:
|
||||||
current_scene.remove_child(escoria.game_scene)
|
previous_scene.remove_child(escoria.game_scene)
|
||||||
|
|
||||||
current_scene.get_parent().remove_child(current_scene)
|
previous_scene.visible = false
|
||||||
|
previous_scene.get_parent().remove_child(previous_scene)
|
||||||
|
|
||||||
current_scene.queue_free()
|
previous_scene.queue_free()
|
||||||
current_scene = null
|
previous_scene = null
|
||||||
|
|
||||||
|
|
||||||
# Triggered, when the wait has finished
|
# Triggered, when the wait has finished
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ pause_mode = 1
|
|||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
global_id = "trigger_talk"
|
global_id = "trigger_talk"
|
||||||
esc_script = "res://game/rooms/room01/esc/trigger.esc"
|
esc_script = "res://game/rooms/room01/esc/trigger.esc"
|
||||||
is_trigger = true
|
|
||||||
player_orients_on_arrival = false
|
player_orients_on_arrival = false
|
||||||
dialog_color = Color( 1, 1, 1, 1 )
|
dialog_color = Color( 1, 1, 1, 1 )
|
||||||
animations = null
|
animations = null
|
||||||
|
|||||||
@@ -13,23 +13,23 @@
|
|||||||
[ext_resource path="res://game/rooms/room02/floor4.png" type="Texture" id=14]
|
[ext_resource path="res://game/rooms/room02/floor4.png" type="Texture" id=14]
|
||||||
[ext_resource path="res://game/rooms/room02/floor2.png" type="Texture" id=15]
|
[ext_resource path="res://game/rooms/room02/floor2.png" type="Texture" id=15]
|
||||||
|
|
||||||
[sub_resource type="NavigationPolygon" id=4]
|
[sub_resource type="NavigationPolygon" id=1]
|
||||||
vertices = PoolVector2Array( 10, 378, 86, 337, 88, 374, 8, 545, 121, 355, 488, 354, 409, 546, 1184, 373, 1185, 343, 1272, 393, 1272, 548, 875, 546, 802, 357, 1161, 358 )
|
vertices = PoolVector2Array( 10, 378, 86, 337, 88, 374, 8, 545, 121, 355, 488, 354, 409, 546, 1184, 373, 1185, 343, 1272, 393, 1272, 548, 875, 546, 802, 357, 1161, 358 )
|
||||||
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6, 3, 2 ), PoolIntArray( 7, 8, 9, 10 ), PoolIntArray( 10, 11, 12, 13, 7 ) ]
|
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6, 3, 2 ), PoolIntArray( 7, 8, 9, 10 ), PoolIntArray( 10, 11, 12, 13, 7 ) ]
|
||||||
outlines = [ PoolVector2Array( 121, 355, 488, 354, 409, 546, 8, 545, 10, 378, 86, 337, 88, 374 ), PoolVector2Array( 802, 357, 875, 546, 1272, 548, 1272, 393, 1185, 343, 1184, 373, 1161, 358 ) ]
|
outlines = [ PoolVector2Array( 121, 355, 488, 354, 409, 546, 8, 545, 10, 378, 86, 337, 88, 374 ), PoolVector2Array( 802, 357, 875, 546, 1272, 548, 1272, 393, 1185, 343, 1184, 373, 1161, 358 ) ]
|
||||||
|
|
||||||
[sub_resource type="NavigationPolygon" id=5]
|
[sub_resource type="NavigationPolygon" id=2]
|
||||||
vertices = PoolVector2Array( 10, 378, 88, 335, 86, 373, 8, 542, 1185, 374, 1185, 343, 1270, 395, 1272, 545, 114, 355, 1161, 357 )
|
vertices = PoolVector2Array( 10, 378, 88, 335, 86, 373, 8, 542, 1185, 374, 1185, 343, 1270, 395, 1272, 545, 114, 355, 1161, 357 )
|
||||||
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6 ), PoolIntArray( 6, 7, 3, 4 ), PoolIntArray( 8, 9, 4, 3, 2 ) ]
|
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6 ), PoolIntArray( 6, 7, 3, 4 ), PoolIntArray( 8, 9, 4, 3, 2 ) ]
|
||||||
outlines = [ PoolVector2Array( 88, 335, 86, 373, 114, 355, 1161, 357, 1185, 374, 1185, 343, 1270, 395, 1272, 545, 8, 542, 10, 378 ) ]
|
outlines = [ PoolVector2Array( 88, 335, 86, 373, 114, 355, 1161, 357, 1185, 374, 1185, 343, 1270, 395, 1272, 545, 8, 542, 10, 378 ) ]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=6]
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
extents = Vector2( 39, 39.5 )
|
extents = Vector2( 39, 39.5 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=7]
|
[sub_resource type="RectangleShape2D" id=4]
|
||||||
extents = Vector2( 39, 39.5 )
|
extents = Vector2( 39, 39.5 )
|
||||||
|
|
||||||
[sub_resource type="Animation" id=1]
|
[sub_resource type="Animation" id=5]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||||
@@ -80,8 +80,7 @@ tracks/3/keys = {
|
|||||||
"values": [ Vector2( 786, 650 ) ]
|
"values": [ Vector2( 786, 650 ) ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=3]
|
[sub_resource type="Animation" id=6]
|
||||||
resource_name = "bridge_close"
|
|
||||||
length = 1.6
|
length = 1.6
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||||
@@ -132,8 +131,7 @@ tracks/3/keys = {
|
|||||||
"values": [ Vector2( 696, 650 ), Vector2( 696, 650 ), Vector2( 696, 450 ) ]
|
"values": [ Vector2( 696, 650 ), Vector2( 696, 650 ), Vector2( 696, 450 ) ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=2]
|
[sub_resource type="Animation" id=7]
|
||||||
resource_name = "bridge_open"
|
|
||||||
length = 1.6
|
length = 1.6
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||||
@@ -316,11 +314,11 @@ debug_mode = 1
|
|||||||
|
|
||||||
[node name="bridge_open" type="NavigationPolygonInstance" parent="walkable_area"]
|
[node name="bridge_open" type="NavigationPolygonInstance" parent="walkable_area"]
|
||||||
visible = false
|
visible = false
|
||||||
navpoly = SubResource( 4 )
|
navpoly = SubResource( 1 )
|
||||||
|
|
||||||
[node name="bridge_closed" type="NavigationPolygonInstance" parent="walkable_area"]
|
[node name="bridge_closed" type="NavigationPolygonInstance" parent="walkable_area"]
|
||||||
visible = false
|
visible = false
|
||||||
navpoly = SubResource( 5 )
|
navpoly = SubResource( 2 )
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="button_left" type="Area2D" parent="."]
|
[node name="button_left" type="Area2D" parent="."]
|
||||||
@@ -337,7 +335,7 @@ animations = null
|
|||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_left"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_left"]
|
||||||
position = Vector2( 370, 190.5 )
|
position = Vector2( 370, 190.5 )
|
||||||
shape = SubResource( 6 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[node name="ESCLocation" type="Position2D" parent="button_left"]
|
[node name="ESCLocation" type="Position2D" parent="button_left"]
|
||||||
position = Vector2( 369, 375 )
|
position = Vector2( 369, 375 )
|
||||||
@@ -357,7 +355,7 @@ animations = null
|
|||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_right2"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_right2"]
|
||||||
position = Vector2( 911, 190.5 )
|
position = Vector2( 911, 190.5 )
|
||||||
shape = SubResource( 7 )
|
shape = SubResource( 4 )
|
||||||
|
|
||||||
[node name="ESCLocation" type="Position2D" parent="button_right2"]
|
[node name="ESCLocation" type="Position2D" parent="button_right2"]
|
||||||
position = Vector2( 914, 378 )
|
position = Vector2( 914, 378 )
|
||||||
@@ -372,9 +370,9 @@ animations = null
|
|||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="bridge"]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="bridge"]
|
||||||
root_node = NodePath("../..")
|
root_node = NodePath("../..")
|
||||||
anims/RESET = SubResource( 1 )
|
anims/RESET = SubResource( 5 )
|
||||||
anims/bridge_close = SubResource( 3 )
|
anims/bridge_close = SubResource( 6 )
|
||||||
anims/bridge_open = SubResource( 2 )
|
anims/bridge_open = SubResource( 7 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="bridge"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="bridge"]
|
||||||
shape = SubResource( 8 )
|
shape = SubResource( 8 )
|
||||||
|
|||||||
@@ -319,6 +319,16 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/esc_room_manager.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/esc_room_manager.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Reference",
|
||||||
|
"class": "ESCRoomObjects",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_room_objects.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Reference",
|
||||||
|
"class": "ESCRoomObjectsKey",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_room_objects_key.gd"
|
||||||
|
}, {
|
||||||
"base": "Resource",
|
"base": "Resource",
|
||||||
"class": "ESCSaveGame",
|
"class": "ESCSaveGame",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@@ -632,6 +642,8 @@ _global_script_class_icons={
|
|||||||
"ESCResourceDescriptor": "",
|
"ESCResourceDescriptor": "",
|
||||||
"ESCRoom": "res://addons/escoria-core/design/esc_room.svg",
|
"ESCRoom": "res://addons/escoria-core/design/esc_room.svg",
|
||||||
"ESCRoomManager": "",
|
"ESCRoomManager": "",
|
||||||
|
"ESCRoomObjects": "",
|
||||||
|
"ESCRoomObjectsKey": "",
|
||||||
"ESCSaveGame": "",
|
"ESCSaveGame": "",
|
||||||
"ESCSaveManager": "",
|
"ESCSaveManager": "",
|
||||||
"ESCSaveSettings": "",
|
"ESCSaveSettings": "",
|
||||||
@@ -745,7 +757,7 @@ ui/game_scene="res://addons/escoria-ui-9verbs/game.tscn"
|
|||||||
ui/dialogs_chooser="res://addons/escoria-core/ui_library/dialogs/text_dialog_chooser.tscn"
|
ui/dialogs_chooser="res://addons/escoria-core/ui_library/dialogs/text_dialog_chooser.tscn"
|
||||||
sound/speech_folder="res://game/speech"
|
sound/speech_folder="res://game/speech"
|
||||||
sound/speech_extension="ogg"
|
sound/speech_extension="ogg"
|
||||||
ui/default_transition="curtain"
|
ui/default_transition="instant"
|
||||||
ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders/" ]
|
ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders/" ]
|
||||||
ui/inventory_item_size=Vector2( 72, 72 )
|
ui/inventory_item_size=Vector2( 72, 72 )
|
||||||
debug/enable_room_selector=true
|
debug/enable_room_selector=true
|
||||||
@@ -767,7 +779,7 @@ main/game_migration_path=""
|
|||||||
|
|
||||||
esc_show_debug_prompt={
|
esc_show_debug_prompt={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
switch_action_verb={
|
switch_action_verb={
|
||||||
|
|||||||
Reference in New Issue
Block a user