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
@@ -108,7 +108,7 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
||||
[
|
||||
"Registering object with empty global_id.",
|
||||
"Using node's full path as global_id: %s"
|
||||
% object.node.global_id
|
||||
% object.node.global_id
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -268,7 +268,10 @@ func init_room(room: ESCRoom) -> void:
|
||||
# #### Parameters
|
||||
#
|
||||
# - 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
|
||||
# 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
|
||||
@@ -277,7 +280,7 @@ func _perform_script_events(room: ESCRoom):
|
||||
and escoria.event_manager.get_running_event(
|
||||
escoria.event_manager.CHANNEL_FRONT
|
||||
).name == escoria.event_manager.EVENT_LOAD:
|
||||
_make_new_room_visible(room)
|
||||
escoria.main.set_scene_finish(room)
|
||||
else:
|
||||
# If the room was loaded from change_scene and automatic transitions
|
||||
# are not disabled, do the transition out now
|
||||
@@ -325,9 +328,20 @@ func _perform_script_events(room: ESCRoom):
|
||||
if rc[0] != ESCExecution.RC_OK:
|
||||
return rc[0]
|
||||
|
||||
# Switch the rooms (resources are freed at end of change_scene and in
|
||||
# clear_scene).
|
||||
_make_new_room_visible(room)
|
||||
escoria.main.set_scene_finish()
|
||||
|
||||
# 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 \
|
||||
or (
|
||||
@@ -386,20 +400,8 @@ func _perform_script_events(room: ESCRoom):
|
||||
if escoria.main.current_scene != null else "",
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
# 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
|
||||
var current_scene: Node
|
||||
|
||||
# Scene that was previously the current scene.
|
||||
var previous_scene: Node
|
||||
|
||||
# The Escoria context currently in wait state
|
||||
var wait_level
|
||||
|
||||
@@ -37,46 +40,56 @@ func set_scene(p_scene: Node) -> void:
|
||||
if !p_scene:
|
||||
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
||||
|
||||
previous_scene = current_scene
|
||||
|
||||
if not p_scene.is_inside_tree():
|
||||
# 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
|
||||
# _ready() method will ensure that the room is visible when
|
||||
# :setup is complete.
|
||||
# same one as the current room.
|
||||
if not _is_same_scene(current_scene, p_scene):
|
||||
p_scene.visible = false
|
||||
|
||||
#p_scene.z_index = -100
|
||||
escoria.object_manager.set_current_room(p_scene)
|
||||
add_child(p_scene)
|
||||
|
||||
# This actually moves the scene closest to the root node, but will
|
||||
# still be drawn behind the next node, which should be the previous
|
||||
# room.
|
||||
move_child(p_scene, 0)
|
||||
|
||||
if current_scene != null:
|
||||
clear_scene()
|
||||
|
||||
current_scene = p_scene
|
||||
|
||||
check_game_scene_methods()
|
||||
|
||||
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")
|
||||
|
||||
|
||||
# Cleanup the current scene
|
||||
# Cleanup the previous scene
|
||||
func clear_scene() -> void:
|
||||
if current_scene == null:
|
||||
if previous_scene == null:
|
||||
return
|
||||
|
||||
escoria.action_manager.clear_current_action()
|
||||
escoria.action_manager.clear_current_tool()
|
||||
|
||||
if escoria.game_scene.get_parent() == current_scene:
|
||||
current_scene.remove_child(escoria.game_scene)
|
||||
if escoria.game_scene.get_parent() == previous_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()
|
||||
current_scene = null
|
||||
previous_scene.queue_free()
|
||||
previous_scene = null
|
||||
|
||||
|
||||
# Triggered, when the wait has finished
|
||||
|
||||
@@ -180,7 +180,6 @@ pause_mode = 1
|
||||
script = ExtResource( 5 )
|
||||
global_id = "trigger_talk"
|
||||
esc_script = "res://game/rooms/room01/esc/trigger.esc"
|
||||
is_trigger = true
|
||||
player_orients_on_arrival = false
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
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/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 )
|
||||
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 ) ]
|
||||
|
||||
[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 )
|
||||
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 ) ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 39, 39.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=7]
|
||||
[sub_resource type="RectangleShape2D" id=4]
|
||||
extents = Vector2( 39, 39.5 )
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
[sub_resource type="Animation" id=5]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||
@@ -80,8 +80,7 @@ tracks/3/keys = {
|
||||
"values": [ Vector2( 786, 650 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "bridge_close"
|
||||
[sub_resource type="Animation" id=6]
|
||||
length = 1.6
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||
@@ -132,8 +131,7 @@ tracks/3/keys = {
|
||||
"values": [ Vector2( 696, 650 ), Vector2( 696, 650 ), Vector2( 696, 450 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "bridge_open"
|
||||
[sub_resource type="Animation" id=7]
|
||||
length = 1.6
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("ESCBackground/Floor1:position")
|
||||
@@ -316,11 +314,11 @@ debug_mode = 1
|
||||
|
||||
[node name="bridge_open" type="NavigationPolygonInstance" parent="walkable_area"]
|
||||
visible = false
|
||||
navpoly = SubResource( 4 )
|
||||
navpoly = SubResource( 1 )
|
||||
|
||||
[node name="bridge_closed" type="NavigationPolygonInstance" parent="walkable_area"]
|
||||
visible = false
|
||||
navpoly = SubResource( 5 )
|
||||
navpoly = SubResource( 2 )
|
||||
enabled = false
|
||||
|
||||
[node name="button_left" type="Area2D" parent="."]
|
||||
@@ -337,7 +335,7 @@ animations = null
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_left"]
|
||||
position = Vector2( 370, 190.5 )
|
||||
shape = SubResource( 6 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="ESCLocation" type="Position2D" parent="button_left"]
|
||||
position = Vector2( 369, 375 )
|
||||
@@ -357,7 +355,7 @@ animations = null
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="button_right2"]
|
||||
position = Vector2( 911, 190.5 )
|
||||
shape = SubResource( 7 )
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[node name="ESCLocation" type="Position2D" parent="button_right2"]
|
||||
position = Vector2( 914, 378 )
|
||||
@@ -372,9 +370,9 @@ animations = null
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="bridge"]
|
||||
root_node = NodePath("../..")
|
||||
anims/RESET = SubResource( 1 )
|
||||
anims/bridge_close = SubResource( 3 )
|
||||
anims/bridge_open = SubResource( 2 )
|
||||
anims/RESET = SubResource( 5 )
|
||||
anims/bridge_close = SubResource( 6 )
|
||||
anims/bridge_open = SubResource( 7 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="bridge"]
|
||||
shape = SubResource( 8 )
|
||||
|
||||
@@ -4,4 +4,4 @@ say player "Fade black"
|
||||
transition fade_black out
|
||||
wait 1
|
||||
transition fade_black in
|
||||
accept_input ALL
|
||||
accept_input ALL
|
||||
|
||||
@@ -319,6 +319,16 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"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",
|
||||
"class": "ESCSaveGame",
|
||||
"language": "GDScript",
|
||||
@@ -632,6 +642,8 @@ _global_script_class_icons={
|
||||
"ESCResourceDescriptor": "",
|
||||
"ESCRoom": "res://addons/escoria-core/design/esc_room.svg",
|
||||
"ESCRoomManager": "",
|
||||
"ESCRoomObjects": "",
|
||||
"ESCRoomObjectsKey": "",
|
||||
"ESCSaveGame": "",
|
||||
"ESCSaveManager": "",
|
||||
"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"
|
||||
sound/speech_folder="res://game/speech"
|
||||
sound/speech_extension="ogg"
|
||||
ui/default_transition="curtain"
|
||||
ui/default_transition="instant"
|
||||
ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders/" ]
|
||||
ui/inventory_item_size=Vector2( 72, 72 )
|
||||
debug/enable_room_selector=true
|
||||
@@ -767,7 +779,7 @@ main/game_migration_path=""
|
||||
|
||||
esc_show_debug_prompt={
|
||||
"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={
|
||||
|
||||
Reference in New Issue
Block a user