wip: moving camera setup closer to actual :setup event post-transition out to allow for more setup to be done 'under the hood'
This commit is contained in:
committed by
Julian Murgia
parent
b985c42e08
commit
eac4385b81
@@ -182,41 +182,6 @@ func init_room(room: ESCRoom) -> void:
|
||||
if escoria.main.current_scene == null:
|
||||
escoria.main.set_scene(room)
|
||||
|
||||
if room.player_scene:
|
||||
room.player = room.player_scene.instance()
|
||||
room.add_child(room.player)
|
||||
escoria.object_manager.register_object(
|
||||
ESCObject.new(
|
||||
room.player.global_id,
|
||||
room.player
|
||||
),
|
||||
room,
|
||||
true
|
||||
)
|
||||
|
||||
if escoria.globals_manager.has(
|
||||
escoria.room_manager.GLOBAL_ANIMATION_RESOURCES
|
||||
):
|
||||
var animations = escoria.globals_manager.get_global(
|
||||
escoria.room_manager.GLOBAL_ANIMATION_RESOURCES
|
||||
)
|
||||
|
||||
if room.player.global_id in animations and \
|
||||
ResourceLoader.exists(animations[room.player.global_id]):
|
||||
room.player.animations = ResourceLoader.load(
|
||||
animations[room.player.global_id]
|
||||
)
|
||||
room.player.update_idle()
|
||||
escoria.object_manager.get_object(escoria.object_manager.CAMERA).node.set_target(room.player)
|
||||
|
||||
if room.global_id.empty():
|
||||
room.global_id = room.name
|
||||
|
||||
# Manage player location at room start
|
||||
if room.player != null \
|
||||
and escoria.object_manager.get_start_location() != null:
|
||||
room.player.teleport(escoria.object_manager.get_start_location().node)
|
||||
|
||||
_perform_script_events(room)
|
||||
|
||||
|
||||
@@ -266,6 +231,49 @@ func _perform_script_events(room: ESCRoom) -> void:
|
||||
escoria.game_scene.hide_main_menu()
|
||||
escoria.game_scene.unpause_game()
|
||||
|
||||
# With the room transitioned out, finish any room prep and run :setup if
|
||||
# it exists.
|
||||
|
||||
# We must first et the camera limits, and then worry about subsequent
|
||||
# player setup since it relies on this.
|
||||
escoria.main.set_camera_limits(0, room)
|
||||
|
||||
if room.player_scene:
|
||||
room.player = room.player_scene.instance()
|
||||
room.add_child(room.player)
|
||||
escoria.object_manager.register_object(
|
||||
ESCObject.new(
|
||||
room.player.global_id,
|
||||
room.player
|
||||
),
|
||||
room,
|
||||
true
|
||||
)
|
||||
|
||||
if escoria.globals_manager.has(
|
||||
escoria.room_manager.GLOBAL_ANIMATION_RESOURCES
|
||||
):
|
||||
var animations = escoria.globals_manager.get_global(
|
||||
escoria.room_manager.GLOBAL_ANIMATION_RESOURCES
|
||||
)
|
||||
|
||||
if room.player.global_id in animations and \
|
||||
ResourceLoader.exists(animations[room.player.global_id]):
|
||||
room.player.animations = ResourceLoader.load(
|
||||
animations[room.player.global_id]
|
||||
)
|
||||
room.player.update_idle()
|
||||
|
||||
escoria.object_manager.get_object(escoria.object_manager.CAMERA).node.set_target(room.player)
|
||||
|
||||
if room.global_id.empty():
|
||||
room.global_id = room.name
|
||||
|
||||
# Manage player location at room start
|
||||
if room.player != null \
|
||||
and escoria.object_manager.get_start_location() != null:
|
||||
room.player.teleport(escoria.object_manager.get_start_location().node)
|
||||
|
||||
var setup_event_added: bool = false
|
||||
# Run the setup event, if there is one.
|
||||
setup_event_added = _run_script_event(escoria.event_manager.EVENT_SETUP, room)
|
||||
|
||||
@@ -69,7 +69,7 @@ func set_scene(p_scene: Node) -> void:
|
||||
|
||||
check_game_scene_methods()
|
||||
|
||||
set_camera_limits()
|
||||
#set_camera_limits(current_scene)
|
||||
|
||||
|
||||
# Only called by the room manager in the case where it hasn't executed a
|
||||
@@ -85,7 +85,7 @@ func finish_current_scene_init(p_scene: Node) -> void:
|
||||
|
||||
check_game_scene_methods()
|
||||
|
||||
set_camera_limits()
|
||||
# set_camera_limits(current_scene)
|
||||
|
||||
|
||||
# Completes the room swap and should be called by the room manager at the
|
||||
@@ -127,9 +127,12 @@ func _on_wait_finished() -> void:
|
||||
# #### Parameters
|
||||
#
|
||||
# * camera_limits_id: The id of the room's camera limits to set
|
||||
func set_camera_limits(camera_limit_id: int = 0) -> void:
|
||||
# * scene: The scene to set the camera limits for. We make this optional since
|
||||
# most times it'll be current_scene that needs setting; however, e.g. when
|
||||
# starting up Escoria, we might not have already set the current_scene.
|
||||
func set_camera_limits(camera_limit_id: int = 0, scene: Node = current_scene) -> void:
|
||||
var limits = {}
|
||||
var last_available_camera_limit = current_scene.camera_limits.size() - 1
|
||||
var last_available_camera_limit = scene.camera_limits.size() - 1
|
||||
if camera_limit_id > last_available_camera_limit:
|
||||
escoria.logger.report_errors(
|
||||
"main.gd:set_camera_limits()",
|
||||
@@ -140,10 +143,10 @@ func set_camera_limits(camera_limit_id: int = 0) -> void:
|
||||
]
|
||||
]
|
||||
)
|
||||
var scene_camera_limits = current_scene.camera_limits[camera_limit_id]
|
||||
var scene_camera_limits = scene.camera_limits[camera_limit_id]
|
||||
if scene_camera_limits.size.x == 0 and scene_camera_limits.size.y == 0:
|
||||
var area = Rect2()
|
||||
for child in current_scene.get_children():
|
||||
for child in scene.get_children():
|
||||
if child is ESCBackground:
|
||||
area = child.get_full_area_rect2()
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user