Skip to content
Open
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 @@ -97,6 +97,9 @@ var hook_string: Line2D
## This can be used to pan or zoom the camera to frame the ending of the grappling hook.
@onready var hook_ending: Marker2D = $HookEnding

## A [PhantomCamera2D] at the tip of the string.
@onready var phantom_camera_2d: PhantomCamera2D = %PhantomCamera2D


func _enter_tree() -> void:
if not character and get_parent() is CharacterBody2D:
Expand Down Expand Up @@ -141,6 +144,24 @@ 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 := NodePath(
String(active_pcam.get_path()) + "/" + String(active_pcam.limit_target)
)
return absolute_target_path


## Called when the area was hooked.
## [br][br]
## Part of group hook_listener.
Expand All @@ -149,6 +170,10 @@ 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
phantom_camera_2d.priority = 20
hook_ending.global_position = p
areas_hooked.append(_new_hooked_to)
if not _new_hooked_to.hook_control:
Expand Down Expand Up @@ -217,6 +242,7 @@ func remove_string() -> void:
hook_control.release()
hook_control.state = HookControl.State.AIMING

phantom_camera_2d.priority = 0
hook_ending.global_position = global_position


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

[ext_resource type="Script" uid="uid://b7704hdflt5t8" path="res://scenes/game_elements/characters/player/components/player_hook.gd" id="1_40sye"]
[ext_resource type="PackedScene" uid="uid://b0dehcnfo68j1" path="res://scenes/game_elements/props/hook_control/hook_control.tscn" id="2_5svv0"]
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="3_wahl3"]
[ext_resource type="Script" uid="uid://8umksf8e80fw" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="4_muesi"]

[sub_resource type="Resource" id="Resource_lv7pl"]
script = ExtResource("4_muesi")

[node name="PlayerHook" type="Node2D" unique_id=1972626703 groups=["hook_listener"]]
script = ExtResource("1_40sye")
Expand All @@ -10,3 +15,16 @@ script = ExtResource("1_40sye")
state = 1

[node name="HookEnding" type="Marker2D" parent="." unique_id=123633963]

[node name="PhantomCamera2D" type="Node2D" parent="." unique_id=173768274 node_paths=PackedStringArray("follow_target")]
unique_name_in_owner = true
top_level = true
script = ExtResource("3_wahl3")
follow_mode = 5
follow_target = NodePath("../HookEnding")
tween_resource = SubResource("Resource_lv7pl")
follow_damping = true
dead_zone_width = 0.4
dead_zone_height = 0.2
draw_limits = true
metadata/_custom_type_script = "uid://bhexx6mj1xv3q"
149 changes: 0 additions & 149 deletions scenes/game_logic/camera_behaviors/frame_camera_behavior.gd

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ extends Node2D
@onready var door: Node2D = %Door
@onready var award_buttons: Node2D = %AwardButtons
@onready var player: Player = %Player
@onready var frame_camera_behavior: FrameCameraBehavior = %FrameCameraBehavior


func _ready() -> void:
frame_camera_behavior.frame_target = player.get_node("PlayerHook/HookEnding")

# When starting, hide and disable the button items to award so the player can't pick them:
for c in award_buttons.get_children():
c.process_mode = Node.PROCESS_MODE_DISABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func _on_abilities_changed() -> void:
var has_longer_thread := GameState.has_ability(Enums.PlayerAbilities.ABILITY_B_MODIFIER_1)
var camera_zoom := Vector2(0.5, 0.5) if has_longer_thread else Vector2(1.0, 1.0)
# Zoom out when the player can throw a longer thread:
var camera: Camera2D = get_viewport().get_camera_2d()
if camera.zoom != camera_zoom:
if zoom_tween:
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.tween_property(camera, "zoom", camera_zoom, 1.0)
if zoom_tween:
zoom_tween.kill()
zoom_tween = create_tween()
var cameras := PhantomCameraManager.get_phantom_camera_2ds()
for cam: PhantomCamera2D in cameras:
zoom_tween.tween_property(cam, "zoom", camera_zoom, 1.0)
Loading
Loading