11using System . Collections ;
2+ using DG . Tweening ;
23using UnityEngine ;
34
45namespace COTL_API . Utility ;
@@ -7,6 +8,7 @@ public class CinematicCameraManager
78{
89
910 public static List < IEnumerator > ActiveFocusPoints = [ ] ;
11+ public static Quaternion defaultCameraRotation = Quaternion . Euler ( 315f , 0f , 0f ) ;
1012 public static void Zoom ( float targetZoom )
1113 {
1214 GameManager . GetInstance ( ) . CameraSetTargetZoom ( targetZoom ) ;
@@ -17,10 +19,14 @@ public static void ZoomReset()
1719 GameManager . GetInstance ( ) . CameraResetTargetZoom ( ) ;
1820 }
1921
20- public static SimpleSetCamera CreateAndActivateFocusPoint ( Vector3 position , Quaternion rotation )
22+ public static GameObject CreateAndActivateFocusPoint ( Vector3 position , Quaternion rotation )
2123 {
2224 var cam = CreateFocusPoint ( position , rotation ) ;
23- cam . Play ( ) ;
25+ SetFollowTarget ( cam ) ;
26+ DOTween . Kill ( "CinematicFocusPoint" ) ;
27+ //rotate via dotween
28+ CameraFollowTarget . Instance ? . transform . DORotate ( rotation . eulerAngles , 1f ) . SetId ( "CinematicFocusPoint" ) ;
29+
2430 return cam ;
2531 }
2632
@@ -32,19 +38,20 @@ public static void CreateAndPrepareTimedFocusPoint(Vector3 position, Quaternion
3238 private static IEnumerator CreateTimedFocusPoint ( Vector3 position , Quaternion rotation , float duration , float zoom = 1f )
3339 {
3440 var cam = CreateFocusPoint ( position , rotation ) ;
35- cam . Play ( ) ;
41+ SetFollowTarget ( cam ) ;
42+ DOTween . Kill ( "CinematicFocusPoint" ) ;
43+ //rotate via dotween
44+ CameraFollowTarget . Instance ? . transform . DORotate ( rotation . eulerAngles , 1f ) . SetId ( "CinematicFocusPoint" ) ;
3645 Zoom ( zoom ) ;
3746 yield return new WaitForSeconds ( duration ) ;
3847 }
3948
40- private static SimpleSetCamera CreateFocusPoint ( Vector3 position , Quaternion rotation )
49+ private static GameObject CreateFocusPoint ( Vector3 position , Quaternion rotation )
4150 {
4251 var cam = new GameObject ( "CinematicCameraFocusPoint" ) ;
4352 cam . transform . position = position ;
4453 cam . transform . rotation = rotation ;
45- var ssc = cam . AddComponent < SimpleSetCamera > ( ) ;
46- ssc . AutomaticallyActivate = false ;
47- return ssc ;
54+ return cam ;
4855 }
4956
5057 public static IEnumerator ActivateAllCreatedFocusPoints ( )
@@ -53,6 +60,7 @@ public static IEnumerator ActivateAllCreatedFocusPoints()
5360 {
5461 yield return cam ;
5562 }
63+ ResetAllFocusPoints ( ) ;
5664 }
5765
5866 public static void ResetAllFocusPoints ( float speed = 1f )
@@ -61,6 +69,16 @@ public static void ResetAllFocusPoints(float speed = 1f)
6169 ActiveFocusPoints . Clear ( ) ;
6270 }
6371
72+ public static void SetFollowTarget ( GameObject target )
73+ {
74+ //single target only
75+ ResetAllFocusPoints ( ) ;
76+ ResetCameraTargets ( ) ;
77+ CameraFollowTarget . Instance ? . ClearAllTargets ( ) ;
78+ CameraFollowTarget . Instance ? . CleanTargets ( ) ;
79+ CameraFollowTarget . Instance ? . AddTarget ( target , 1f ) ;
80+ }
81+
6482 public static void AddFollowTarget ( GameObject target , float weight = 1f )
6583 {
6684 CameraFollowTarget . Instance ? . AddTarget ( target , weight ) ;
@@ -71,6 +89,13 @@ public static void RemoveFollowTarget(GameObject target)
7189 CameraFollowTarget . Instance ? . RemoveTarget ( target ) ;
7290 }
7391
92+ public static void ResetCameraTargets ( )
93+ {
94+ CameraFollowTarget . Instance ? . ClearAllTargets ( ) ; //set rotation back to 315 0 0
95+ CameraFollowTarget . Instance ? . transform . DORotate ( defaultCameraRotation . eulerAngles , 1f ) ;
96+ GameManager . instance ? . AddPlayersToCamera ( ) ;
97+ }
98+
7499 public static void SetCameraLimits ( bool enabled , Bounds limits )
75100 {
76101 if ( ! enabled )
0 commit comments