Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,6 @@ func _new_hook_string() -> Line2D:
return new_hook_string


## Return the absolute path to the limit target of the current active camera, if it has one.
func _get_phantom_camera_limit_target() -> NodePath:
var phantom_camera_hosts := PhantomCameraManager.phantom_camera_hosts
if not phantom_camera_hosts:
return ""
var active_pcam := phantom_camera_hosts[0].get_active_pcam() as PhantomCamera2D
if not active_pcam:
return ""
if not active_pcam.limit_target:
return ""
if active_pcam.limit_target.is_absolute():
return active_pcam.limit_target
var absolute_target_path := active_pcam.get_node(active_pcam.limit_target).get_path()
return absolute_target_path


## Called when the area was hooked.
## [br][br]
## Part of group hook_listener.
Expand All @@ -168,9 +152,7 @@ func hooked(_new_hooked_to: HookableArea, is_loop: bool) -> void:
if not hook_string:
hook_string = _new_hook_string()
hook_string.add_point(p, 0)
var limit_target := _get_phantom_camera_limit_target()
if limit_target:
phantom_camera_2d.limit_target = limit_target
CameraUtilities.copy_current_camera_limits(phantom_camera_2d)
phantom_camera_2d.priority = 20
hook_ending.global_position = p
areas_hooked.append(_new_hooked_to)
Expand Down
26 changes: 26 additions & 0 deletions scenes/globals/camera_utilities/camera_utilities.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: The Threadbare Authors
# SPDX-License-Identifier: MPL-2.0
class_name CameraUtilities


## Return the absolute path to the limit target of the current active camera, if it has one.
static func _get_phantom_camera_limit_target() -> NodePath:
var phantom_camera_hosts := PhantomCameraManager.phantom_camera_hosts
if not phantom_camera_hosts:
return ""
var active_pcam := phantom_camera_hosts[0].get_active_pcam() as PhantomCamera2D
if not active_pcam:
return ""
if not active_pcam.limit_target:
return ""
if active_pcam.limit_target.is_absolute():
return active_pcam.limit_target
var absolute_target_path := active_pcam.get_node(active_pcam.limit_target).get_path()
return absolute_target_path


## Assign the camera limits of the current active camera to this camera.
static func copy_current_camera_limits(camera: PhantomCamera2D) -> void:
var limit_target := _get_phantom_camera_limit_target()
if limit_target:
camera.limit_target = limit_target
1 change: 1 addition & 0 deletions scenes/globals/camera_utilities/camera_utilities.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bplxjqdeu6w3n
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ extends Node
@export var extra_needles: Array[Node2D]
@onready var helper_camera: PhantomCamera2D = %HelperCamera

# signal needles_animation_finished


func _ready() -> void:
for n in extra_needles:
Expand All @@ -15,10 +13,12 @@ func _ready() -> void:


func add_extra_needles() -> void:
CameraUtilities.copy_current_camera_limits(helper_camera)
helper_camera.priority = 20
await get_tree().create_timer(1.0).timeout
for n in extra_needles:
n.visible = true
n.process_mode = Node.PROCESS_MODE_INHERIT
await get_tree().create_timer(1.0).timeout
helper_camera.priority = 0
await get_tree().create_timer(1.0).timeout
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ size = Vector2(52, 61)

[sub_resource type="Resource" id="Resource_pi753"]
script = ExtResource("16_dysib")
transition = 1

[sub_resource type="RectangleShape2D" id="RectangleShape2D_41yfr"]
size = Vector2(140.5, 194.5)
Expand Down Expand Up @@ -464,7 +465,7 @@ position = Vector2(0, -72)

[node name="HelperCamera" type="Node2D" parent="OnTheGround/Helper" unique_id=190625804]
unique_name_in_owner = true
position = Vector2(217, 255)
position = Vector2(292, 275)
script = ExtResource("15_374sg")
tween_resource = SubResource("Resource_pi753")
draw_limits = true
Expand Down