net.dreditor.dialogueeventhandling 0.0.0-stage → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AnimationEventHandler.cs +188 -0
- package/AnimationEventHandler.cs.meta +11 -0
- package/CameraEvents/CamToPositionEvent.cs +287 -0
- package/CameraEvents/CamToPositionEvent.cs.meta +11 -0
- package/CameraEvents/CamerasToTPFDPosition.cs +72 -0
- package/CameraEvents/CamerasToTPFDPosition.cs.meta +11 -0
- package/CameraEvents/CaptureFrameEvent.cs +61 -0
- package/CameraEvents/CaptureFrameEvent.cs.meta +11 -0
- package/CameraEvents/CaptureFrameProtag.cs +41 -0
- package/CameraEvents/CaptureFrameProtag.cs.meta +11 -0
- package/CameraEvents/EnableCameraEvent.cs +40 -0
- package/CameraEvents/EnableCameraEvent.cs.meta +11 -0
- package/CameraEvents/EnableCamerasOnSceneEvent.cs +47 -0
- package/CameraEvents/EnableCamerasOnSceneEvent.cs.meta +11 -0
- package/CameraEvents/MoveCameraToCamera.cs +67 -0
- package/CameraEvents/MoveCameraToCamera.cs.meta +11 -0
- package/CameraEvents/PrepareCamerasTPFD.cs +69 -0
- package/CameraEvents/PrepareCamerasTPFD.cs.meta +11 -0
- package/CameraEvents/ResetCameraPosition.cs +60 -0
- package/CameraEvents/ResetCameraPosition.cs.meta +11 -0
- package/CameraEvents/SetDialogueCameraEvent.cs +32 -0
- package/CameraEvents/SetDialogueCameraEvent.cs.meta +11 -0
- package/CameraEvents/ShakeCameraEvent.cs +172 -0
- package/CameraEvents/ShakeCameraEvent.cs.meta +11 -0
- package/CameraEvents/ToggleBlurHandler.cs +37 -0
- package/CameraEvents/ToggleBlurHandler.cs.meta +2 -0
- package/CameraEvents/ToggleCameraFlagsEvent.cs +55 -0
- package/CameraEvents/ToggleCameraFlagsEvent.cs.meta +11 -0
- package/CameraEvents.meta +8 -0
- package/ChangeSelectabilityEvent.cs +47 -0
- package/ChangeSelectabilityEvent.cs.meta +11 -0
- package/CharacterIntroAnim.cs +215 -0
- package/CharacterIntroAnim.cs.meta +11 -0
- package/CustomDialogueEventHandler.cs +32 -0
- package/CustomDialogueEventHandler.cs.meta +11 -0
- package/DREditor.DialogueEventHandling.asmdef +21 -0
- package/DREditor.DialogueEventHandling.asmdef.meta +7 -0
- package/DialogueEventHandler.cs +55 -0
- package/DialogueEventHandler.cs.meta +11 -0
- package/DialogueMidEntranceDebugger.cs +88 -0
- package/DialogueMidEntranceDebugger.cs.meta +11 -0
- package/Flashing/FlashEventHandlerBase.cs +115 -0
- package/Flashing/FlashEventHandlerBase.cs.meta +11 -0
- package/Flashing/FlashEventSimpleHandlerBase.cs +35 -0
- package/Flashing/FlashEventSimpleHandlerBase.cs.meta +2 -0
- package/Flashing/FlashScreenWhiteEvent.cs +60 -0
- package/Flashing/FlashScreenWhiteEvent.cs.meta +11 -0
- package/Flashing/FlashWhiteMat.mat +141 -0
- package/Flashing/FlashWhiteMat.mat.meta +8 -0
- package/Flashing/FlashWhiteShader.shadergraph +1170 -0
- package/Flashing/FlashWhiteShader.shadergraph.meta +10 -0
- package/Flashing/FlashWhiteSpriteEventHandler.cs +138 -0
- package/Flashing/FlashWhiteSpriteEventHandler.cs.meta +11 -0
- package/Flashing/ProtagFlashWhiteEventHandler.cs +222 -0
- package/Flashing/ProtagFlashWhiteEventHandler.cs.meta +11 -0
- package/Flashing.meta +8 -0
- package/PanToObjectEvent.cs +84 -0
- package/PanToObjectEvent.cs.meta +11 -0
- package/PlayerManager.cs +208 -0
- package/PlayerManager.cs.meta +11 -0
- package/Samples~/Actor_Fade_Dialogue_Event.prefab +47 -0
- package/Samples~/Actor_Fade_Dialogue_Event.prefab.meta +7 -0
- package/Samples~/Change_Selectability_Event.prefab +47 -0
- package/Samples~/Change_Selectability_Event.prefab.meta +7 -0
- package/Samples~/Character_Intro_Canvas_ETemplate.prefab +134 -0
- package/Samples~/Character_Intro_Canvas_ETemplate.prefab.meta +7 -0
- package/Samples~/DialogueMidEntranceDebugger.prefab +48 -0
- package/Samples~/DialogueMidEntranceDebugger.prefab.meta +7 -0
- package/Samples~/Flash_Screen_White_Line_Handler.prefab +47 -0
- package/Samples~/Flash_Screen_White_Line_Handler.prefab.meta +7 -0
- package/Samples~/Flash_Sprite_Event_Handler.prefab +58 -0
- package/Samples~/Flash_Sprite_Event_Handler.prefab.meta +7 -0
- package/Samples~/Protag_Flash_Line_Handler.prefab +47 -0
- package/Samples~/Protag_Flash_Line_Handler.prefab.meta +7 -0
- package/Samples~/Sprite_Flash_Line_Handler.prefab +48 -0
- package/Samples~/Sprite_Flash_Line_Handler.prefab.meta +7 -0
- package/ShakeUIEvent.cs +54 -0
- package/ShakeUIEvent.cs.meta +11 -0
- package/package.json +40 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
package/.attestation.p7m
ADDED
|
Binary file
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using AnimationEvent = DREditor.Dialogues.Events.AnimationEvent;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.DialogueEventHandling
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class AnimationEventHandler : DialogueEventHandler
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Header("")]
|
|
18
|
+
[Divider]
|
|
19
|
+
[Tooltip("")]
|
|
20
|
+
[SerializeField] protected bool debugLogs = false;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Header("")]
|
|
27
|
+
[Divider]
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected Animator animator = null;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected int animatorLayer = 0;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected BoolWithEvent isLoadingFile = null;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
///
|
|
46
|
+
/// </summary>
|
|
47
|
+
[Header("")]
|
|
48
|
+
[Divider]
|
|
49
|
+
[Tooltip("")]
|
|
50
|
+
[SerializeField] protected string oneShotAnimName = "";
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
[Tooltip("")]
|
|
56
|
+
[SerializeField] protected bool DestroyOnLoadFile = true;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
[Tooltip("")]
|
|
62
|
+
[SerializeField] protected Animation clip = null;
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
///
|
|
66
|
+
/// </summary>
|
|
67
|
+
[Tooltip("")]
|
|
68
|
+
[SerializeField] protected bool waitForClipEnd = true;
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
///
|
|
72
|
+
/// </summary>
|
|
73
|
+
[Tooltip("")]
|
|
74
|
+
[SerializeField] protected bool DestroyOnEnd = false;
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/// <inheritdoc/>
|
|
78
|
+
protected override void OnDialogueEventTriggered(object o = null) => OnAnimationEventTriggered(o);
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
/// <param name="o"></param>
|
|
84
|
+
protected virtual void OnAnimationEventTriggered(object o = null)
|
|
85
|
+
{
|
|
86
|
+
if (debugLogs)
|
|
87
|
+
UnityEngine.Debug.Log($"{ToString()}: " + dialogueEventString + " was called.");
|
|
88
|
+
|
|
89
|
+
if (isLoadingFile.Value)
|
|
90
|
+
OnLoadingFile((AnimationEvent)o);
|
|
91
|
+
else
|
|
92
|
+
OnAnimationEvent((AnimationEvent)o);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// <summary>
|
|
96
|
+
///
|
|
97
|
+
/// </summary>
|
|
98
|
+
/// <param name="animationEvent"></param>
|
|
99
|
+
protected virtual void OnLoadingFile(AnimationEvent animationEvent)
|
|
100
|
+
{
|
|
101
|
+
if (DestroyOnLoadFile)
|
|
102
|
+
Destroy(gameObject);
|
|
103
|
+
else if (clip != null)
|
|
104
|
+
CallClip(animationEvent);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
///
|
|
109
|
+
/// </summary>
|
|
110
|
+
/// <param name="animationEvent"></param>
|
|
111
|
+
protected virtual void OnAnimationEvent(AnimationEvent animationEvent)
|
|
112
|
+
{
|
|
113
|
+
if (clip != null)
|
|
114
|
+
CallClip(animationEvent);
|
|
115
|
+
else
|
|
116
|
+
StartCoroutine(AnimationRoutine(animationEvent));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// <summary>
|
|
120
|
+
///
|
|
121
|
+
/// </summary>
|
|
122
|
+
/// <param name="animationEvent"></param>
|
|
123
|
+
/// <returns></returns>
|
|
124
|
+
protected virtual IEnumerator AnimationRoutine(AnimationEvent animationEvent)
|
|
125
|
+
{
|
|
126
|
+
if (debugLogs)
|
|
127
|
+
UnityEngine.Debug.Log($"{ToString()}: Starting Animation Routine");
|
|
128
|
+
|
|
129
|
+
if (debugLogs && oneShotAnimName != "")
|
|
130
|
+
UnityEngine.Debug.Log($"{ToString()}: calling one-shot animation: " + oneShotAnimName);
|
|
131
|
+
|
|
132
|
+
if (oneShotAnimName != "")
|
|
133
|
+
animator.Play(oneShotAnimName);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
float aLength = animator.GetCurrentAnimatorStateInfo(animatorLayer).length;
|
|
137
|
+
|
|
138
|
+
if (!float.IsPositiveInfinity(aLength))
|
|
139
|
+
yield return new WaitUntil(() =>
|
|
140
|
+
animator.GetCurrentAnimatorStateInfo(animatorLayer).normalizedTime > 1.0f);
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
animationEvent.SetFinished();
|
|
144
|
+
|
|
145
|
+
if (debugLogs)
|
|
146
|
+
UnityEngine.Debug.Log($"{ToString()}: Finished animation event: " + dialogueEventString);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/// <summary>
|
|
150
|
+
///
|
|
151
|
+
/// </summary>
|
|
152
|
+
/// <param name="animationEvent"></param>
|
|
153
|
+
protected virtual void CallClip(AnimationEvent animationEvent)
|
|
154
|
+
{
|
|
155
|
+
clip.Play();
|
|
156
|
+
|
|
157
|
+
if (waitForClipEnd)
|
|
158
|
+
StartCoroutine(WaitForClip(animationEvent));
|
|
159
|
+
else
|
|
160
|
+
animationEvent.SetFinished();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// <summary>
|
|
164
|
+
///
|
|
165
|
+
/// </summary>
|
|
166
|
+
/// <param name="animationEvent"></param>
|
|
167
|
+
protected virtual IEnumerator WaitForClip(AnimationEvent animationEvent)
|
|
168
|
+
{
|
|
169
|
+
yield return new WaitForSeconds(clip.clip.length);
|
|
170
|
+
|
|
171
|
+
animationEvent.SetFinished();
|
|
172
|
+
|
|
173
|
+
if (DestroyOnEnd)
|
|
174
|
+
Destroy(gameObject);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
/// <summary>
|
|
179
|
+
///
|
|
180
|
+
/// </summary>
|
|
181
|
+
[BehaviourButton]
|
|
182
|
+
public void TestAnimation()
|
|
183
|
+
{
|
|
184
|
+
if (Application.isPlaying)
|
|
185
|
+
OnAnimationEventTriggered(new AnimationEvent(dialogueEventString));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if DOTWEEN
|
|
3
|
+
using DG.Tweening;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
#endif
|
|
6
|
+
using DREditor.Dialogues.Events;
|
|
7
|
+
using DREditor.Dialogues.LineReading;
|
|
8
|
+
using DREditor.EventObjects;
|
|
9
|
+
using System.Collections;
|
|
10
|
+
using System.Collections.Generic;
|
|
11
|
+
using UnityEngine;
|
|
12
|
+
using UnityEngine.SceneManagement;
|
|
13
|
+
|
|
14
|
+
namespace DREditor.DialogueEventHandling.CameraEvents
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
[ClassHeader(nameof(DialogueEventHandler) + ", " + nameof(ITweenWaiter) + ", " + nameof(ISceneEventListener) +
|
|
20
|
+
"\n\n")]
|
|
21
|
+
[RequireComponent(typeof(UnityEngine.Camera))]
|
|
22
|
+
public class CamToPositionEvent : DialogueEventHandler, ITweenWaiter, ISceneEventListener
|
|
23
|
+
{
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Tooltip("")]
|
|
28
|
+
[SerializeField] protected SceneEvent resetPlayer = null;
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
[Tooltip("")]
|
|
34
|
+
[SerializeField] protected BoolWithEvent inFastForwardMode = null;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
[Tooltip("")]
|
|
40
|
+
[SerializeField] protected BoolWithEvent isLoadingFile = null;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
[Header("")]
|
|
47
|
+
[Divider]
|
|
48
|
+
[Tooltip("")]
|
|
49
|
+
[SerializeField] protected float moveToPositionDuration = 1;
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
[Tooltip("")]
|
|
55
|
+
[SerializeField] protected float moveToRotationDuration = 1;
|
|
56
|
+
#if DOTWEEN
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
[Tooltip("")]
|
|
61
|
+
[SerializeField] protected PathType pathType = PathType.CatmullRom;
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
///
|
|
66
|
+
/// </summary>
|
|
67
|
+
[Header("")]
|
|
68
|
+
[Divider]
|
|
69
|
+
[Tooltip("")]
|
|
70
|
+
[SerializeField] protected string dialogueEventStringCamAppend = "AppendToCamera";
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
///
|
|
74
|
+
/// </summary>
|
|
75
|
+
[Tooltip("")]
|
|
76
|
+
[SerializeField] protected string toggleBlurEventString = "ToggleBlur";
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
///
|
|
80
|
+
/// </summary>
|
|
81
|
+
[Tooltip("")]
|
|
82
|
+
[SerializeField] protected string checkFocusEventString = "CheckFocus";
|
|
83
|
+
|
|
84
|
+
#if DOTWEEN
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected Sequence activeCameraSequence;
|
|
89
|
+
#endif
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
protected UnityEngine.Camera dialogueCamera;
|
|
94
|
+
|
|
95
|
+
/// <summary>
|
|
96
|
+
///
|
|
97
|
+
/// </summary>
|
|
98
|
+
protected GameObject objectToMoveTo;
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
protected readonly List<Vector3> stackedPaths = new();
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
/// <inheritdoc/>
|
|
107
|
+
protected override void OnEnable()
|
|
108
|
+
{
|
|
109
|
+
base.OnEnable();
|
|
110
|
+
|
|
111
|
+
DialogueEventSystem.StartListening(dialogueEventStringCamAppend, AttemptAppendTween);
|
|
112
|
+
|
|
113
|
+
resetPlayer.RegisterListener(this);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// <inheritdoc/>
|
|
117
|
+
protected override void OnDisable()
|
|
118
|
+
{
|
|
119
|
+
base.OnDisable();
|
|
120
|
+
|
|
121
|
+
DialogueEventSystem.StopListening(dialogueEventStringCamAppend, AttemptAppendTween);
|
|
122
|
+
|
|
123
|
+
resetPlayer.UnregisterListener(this);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// <summary>
|
|
127
|
+
///
|
|
128
|
+
/// </summary>
|
|
129
|
+
protected virtual void Awake() => SetDefaultEventString("CamToPosition");
|
|
130
|
+
|
|
131
|
+
/// <summary>
|
|
132
|
+
///
|
|
133
|
+
/// </summary>
|
|
134
|
+
protected virtual void Start() => dialogueCamera = GetComponent<UnityEngine.Camera>();
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
///
|
|
139
|
+
/// </summary>
|
|
140
|
+
/// <param name="o"></param>
|
|
141
|
+
protected override void OnDialogueEventTriggered(object o = null)
|
|
142
|
+
{
|
|
143
|
+
CamToPosition data = (CamToPosition)o;
|
|
144
|
+
|
|
145
|
+
// TO-DO: In the future find a better way to locate camera positions as this is kind of a nono
|
|
146
|
+
objectToMoveTo = GameObject.Find(data.objectName);
|
|
147
|
+
|
|
148
|
+
if (!data.keepFocus)
|
|
149
|
+
TriggerUnfocusEvents();
|
|
150
|
+
|
|
151
|
+
if (!isLoadingFile.Value && PositionIsValid(objectToMoveTo, data.objectName))
|
|
152
|
+
EvaluateCameraPosition();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// <summary>
|
|
156
|
+
///
|
|
157
|
+
/// </summary>
|
|
158
|
+
protected virtual void TriggerUnfocusEvents()
|
|
159
|
+
{
|
|
160
|
+
DialogueEventSystem.TriggerEvent(toggleBlurEventString, false);
|
|
161
|
+
|
|
162
|
+
DialogueEventSystem.TriggerEvent(checkFocusEventString);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/// <summary>
|
|
166
|
+
///
|
|
167
|
+
/// </summary>
|
|
168
|
+
/// <param name="go"></param>
|
|
169
|
+
/// <param name="name"></param>
|
|
170
|
+
/// <returns></returns>
|
|
171
|
+
protected virtual bool PositionIsValid(GameObject go, string name)
|
|
172
|
+
{
|
|
173
|
+
bool result = go != null;
|
|
174
|
+
|
|
175
|
+
if (!result)
|
|
176
|
+
UnityEngine.Debug.LogWarning($"{ToString()}: Couldn't find object \"" + name + "\" In the " +
|
|
177
|
+
"current Scene: " + SceneManager.GetActiveScene().name);
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/// <summary>
|
|
183
|
+
///
|
|
184
|
+
/// </summary>
|
|
185
|
+
protected virtual void EvaluateCameraPosition()
|
|
186
|
+
{
|
|
187
|
+
if (inFastForwardMode.Value)
|
|
188
|
+
TeleportCameraToPosition();
|
|
189
|
+
#if DOTWEEN
|
|
190
|
+
else if (!CurrentlyMovingCamera())
|
|
191
|
+
StartCameraMoveSequence();
|
|
192
|
+
else
|
|
193
|
+
AddPositionToCameraSequence();
|
|
194
|
+
#endif
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// <summary>
|
|
198
|
+
///
|
|
199
|
+
/// </summary>
|
|
200
|
+
protected virtual void TeleportCameraToPosition()
|
|
201
|
+
=> dialogueCamera.transform
|
|
202
|
+
.SetPositionAndRotation(objectToMoveTo.transform.position, Quaternion.Euler(objectToMoveTo.transform.eulerAngles));
|
|
203
|
+
#if DOTWEEN
|
|
204
|
+
/// <summary>
|
|
205
|
+
///
|
|
206
|
+
/// </summary>
|
|
207
|
+
/// <returns></returns>
|
|
208
|
+
protected virtual bool CurrentlyMovingCamera()
|
|
209
|
+
=> DOTween.IsTweening(dialogueCamera.transform) || activeCameraSequence != null && activeCameraSequence.IsPlaying();
|
|
210
|
+
|
|
211
|
+
/// <summary>
|
|
212
|
+
///
|
|
213
|
+
/// </summary>
|
|
214
|
+
protected virtual void StartCameraMoveSequence()
|
|
215
|
+
{
|
|
216
|
+
stackedPaths.Add(dialogueCamera.transform.position);
|
|
217
|
+
|
|
218
|
+
activeCameraSequence = DOTween.Sequence();
|
|
219
|
+
|
|
220
|
+
activeCameraSequence.OnKill(() => activeCameraSequence = null);
|
|
221
|
+
|
|
222
|
+
activeCameraSequence
|
|
223
|
+
.Append(dialogueCamera.transform.DOMove(objectToMoveTo.transform.position, moveToPositionDuration))
|
|
224
|
+
.Join(dialogueCamera.transform.DORotate(objectToMoveTo.transform.eulerAngles, moveToRotationDuration))
|
|
225
|
+
.Play()
|
|
226
|
+
.onComplete += ClearPathStack;
|
|
227
|
+
|
|
228
|
+
stackedPaths.Add(objectToMoveTo.transform.position);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/// <summary>
|
|
232
|
+
///
|
|
233
|
+
/// </summary>
|
|
234
|
+
protected virtual void AddPositionToCameraSequence()
|
|
235
|
+
{
|
|
236
|
+
stackedPaths.Add(objectToMoveTo.transform.position);
|
|
237
|
+
|
|
238
|
+
activeCameraSequence
|
|
239
|
+
.Join(dialogueCamera.transform.DOPath(stackedPaths.ToArray(), stackedPaths.Count * moveToPositionDuration, pathType))
|
|
240
|
+
.Join(dialogueCamera.transform.DORotate(objectToMoveTo.transform.eulerAngles, moveToRotationDuration));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// <summary>
|
|
244
|
+
///
|
|
245
|
+
/// </summary>
|
|
246
|
+
protected virtual void ClearPathStack()
|
|
247
|
+
{
|
|
248
|
+
activeCameraSequence.onComplete -= ClearPathStack;
|
|
249
|
+
|
|
250
|
+
stackedPaths.Clear();
|
|
251
|
+
}
|
|
252
|
+
#endif
|
|
253
|
+
/// <summary>
|
|
254
|
+
///
|
|
255
|
+
/// </summary>
|
|
256
|
+
/// <param name="o"></param>
|
|
257
|
+
/// <remarks></remarks>
|
|
258
|
+
protected virtual void AttemptAppendTween(object o = null)
|
|
259
|
+
{
|
|
260
|
+
#if DOTWEEN
|
|
261
|
+
if (o is Tween tween)
|
|
262
|
+
activeCameraSequence?.Append(tween);
|
|
263
|
+
#endif
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
/// <inheritdoc/>
|
|
268
|
+
public virtual IEnumerator WaitForTweenToFinish()
|
|
269
|
+
{
|
|
270
|
+
#if DOTWEEN
|
|
271
|
+
if (activeCameraSequence != null && activeCameraSequence.IsActive() && activeCameraSequence.IsPlaying())
|
|
272
|
+
while (activeCameraSequence != null)
|
|
273
|
+
#endif
|
|
274
|
+
yield return null;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/// <inheritdoc/>
|
|
278
|
+
public virtual void OnEventRaised()
|
|
279
|
+
{
|
|
280
|
+
#if DOTWEEN
|
|
281
|
+
activeCameraSequence?.Kill();
|
|
282
|
+
|
|
283
|
+
activeCameraSequence = null;
|
|
284
|
+
#endif
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Cameras;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.DialogueEventHandling.CameraEvents
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[ClassHeader(nameof(DialogueEventHandler) +
|
|
13
|
+
"\n\n")]
|
|
14
|
+
public class CamerasToTPFDPosition : DialogueEventHandler
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
[Tooltip("")]
|
|
20
|
+
[SerializeField] protected List<UnityEngine.Camera> cameras = new();
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected int delayedFrames = 2;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
protected PnCCamera pnc;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
protected virtual void Start() => pnc = FindAnyObjectByType<PnCCamera>();
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
/// <param name="o"></param>
|
|
44
|
+
protected override void OnDialogueEventTriggered(object o = null) => StartCoroutine(DelayCam(o));
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
/// <param name="o"></param>
|
|
50
|
+
protected virtual IEnumerator DelayCam(object o = null)
|
|
51
|
+
{
|
|
52
|
+
for (int i = 0; i < delayedFrames; i++)
|
|
53
|
+
yield return null;
|
|
54
|
+
|
|
55
|
+
Vector3 position = pnc.GetCalculatedPosition();
|
|
56
|
+
|
|
57
|
+
Quaternion rotation = pnc.GetCalculatedRotation();
|
|
58
|
+
|
|
59
|
+
foreach (var camera in cameras)
|
|
60
|
+
camera.transform.SetPositionAndRotation(position, rotation);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
///
|
|
66
|
+
/// </summary>
|
|
67
|
+
[ContextMenu("Set Default Event")]
|
|
68
|
+
public void SetDefaultEvent() => SetDefaultEventString("ToTPFDFromDialogue");
|
|
69
|
+
|
|
70
|
+
protected virtual void Reset() => SetDefaultEventString("ToTPFDFromDialogue");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using UnityEngine.UI;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.DialogueEventHandling.CameraEvents
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class CaptureFrameEvent : DialogueEventHandler
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[Tooltip("")]
|
|
17
|
+
[SerializeField] protected UnityEngine.Camera eventCamera = null;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected BoolWithEvent cameraEnabled = null;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
///
|
|
28
|
+
/// </summary>
|
|
29
|
+
/// <param name="o"></param>
|
|
30
|
+
protected override void OnDialogueEventTriggered(object o = null)
|
|
31
|
+
{
|
|
32
|
+
bool cameraState = cameraEnabled.Value;
|
|
33
|
+
|
|
34
|
+
if (!cameraEnabled.Value)
|
|
35
|
+
{
|
|
36
|
+
UnityEngine.Debug.Log($"REPORT: PlayerManager: eventCamera: {eventCamera.gameObject.name} wasn't on before capturing.");
|
|
37
|
+
|
|
38
|
+
cameraEnabled.SetValue(true);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RenderTexture rt = new(Screen.width, Screen.height, 32);
|
|
42
|
+
|
|
43
|
+
((RawImage)o).texture = rt;
|
|
44
|
+
|
|
45
|
+
eventCamera.targetTexture = rt;
|
|
46
|
+
|
|
47
|
+
eventCamera.Render();
|
|
48
|
+
|
|
49
|
+
eventCamera.targetTexture = null;
|
|
50
|
+
|
|
51
|
+
cameraEnabled.SetValue(cameraState);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[ContextMenu("Set Default Event")]
|
|
59
|
+
public void SetDefaultEvent() => SetDefaultEventString("CaptureMainCamera"); //CaptureProtagCamera
|
|
60
|
+
}
|
|
61
|
+
}
|