net.dreditor.phraseanimations 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/AnimData.cs +42 -0
- package/AnimData.cs.meta +11 -0
- package/DREditor.PhraseAnimations.asmdef +20 -0
- package/DREditor.PhraseAnimations.asmdef.meta +7 -0
- package/Editor/CompactPhraseTypeEditor.cs +97 -0
- package/Editor/CompactPhraseTypeEditor.cs.meta +11 -0
- package/Editor/PhraseAnimationEditor.cs +180 -0
- package/Editor/PhraseAnimationEditor.cs.meta +11 -0
- package/Editor/PhraseAnimationTypeEditor.cs +25 -0
- package/Editor/PhraseAnimationTypeEditor.cs.meta +11 -0
- package/Editor/PhraseAnimationTypeList.cs +24 -0
- package/Editor/PhraseAnimationTypeList.cs.meta +11 -0
- package/Editor/PhraseFadeTypeEditor.cs +19 -0
- package/Editor/PhraseFadeTypeEditor.cs.meta +11 -0
- package/Editor/PhraseRotationTypeEditor.cs +20 -0
- package/Editor/PhraseRotationTypeEditor.cs.meta +11 -0
- package/Editor/PhraseScaleTypeEditor.cs +20 -0
- package/Editor/PhraseScaleTypeEditor.cs.meta +11 -0
- package/Editor/PhraseTransformTypeEditor.cs +19 -0
- package/Editor/PhraseTransformTypeEditor.cs.meta +11 -0
- package/Editor/PhraseTypeEditor.cs +278 -0
- package/Editor/PhraseTypeEditor.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/IPhraseAnimationType.cs +17 -0
- package/IPhraseAnimationType.cs.meta +11 -0
- package/PhraseAnimation.cs +74 -0
- package/PhraseAnimation.cs.meta +11 -0
- package/PhraseAnimationCompact.cs +45 -0
- package/PhraseAnimationCompact.cs.meta +11 -0
- package/PhraseAnimationHandler.cs +136 -0
- package/PhraseAnimationHandler.cs.meta +11 -0
- package/PhraseAnimationTypeBase.cs +54 -0
- package/PhraseAnimationTypeBase.cs.meta +11 -0
- package/PhraseFadeType.cs +20 -0
- package/PhraseFadeType.cs.meta +11 -0
- package/PhraseRotationType.cs +28 -0
- package/PhraseRotationType.cs.meta +11 -0
- package/PhraseScaleType.cs +26 -0
- package/PhraseScaleType.cs.meta +11 -0
- package/PhraseTransformType.cs +26 -0
- package/PhraseTransformType.cs.meta +11 -0
- package/package.json +40 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Editor.Utility;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations.Editor
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
public abstract class PhraseTypeEditor : ClassEditorBase
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
protected PhraseAnimationTypeBase typeBaseTarget;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/// <inheritdoc/>
|
|
21
|
+
protected override void OnInspectorGUI()
|
|
22
|
+
{
|
|
23
|
+
typeBaseTarget = baseTarget as PhraseAnimationTypeBase;
|
|
24
|
+
|
|
25
|
+
DisplayType();
|
|
26
|
+
|
|
27
|
+
using (new EditorGUILayout.HorizontalScope())
|
|
28
|
+
{
|
|
29
|
+
DisplayStartTime();
|
|
30
|
+
|
|
31
|
+
DisplayDuration();
|
|
32
|
+
|
|
33
|
+
DisplayCurveButtons();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
DisplayGenerateCurves();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
protected virtual void DisplayStartTime()
|
|
43
|
+
{
|
|
44
|
+
typeBaseTarget.SetStartTime(HandyFields.FloatField("Start Time: ", typeBaseTarget.startTime, 30));
|
|
45
|
+
|
|
46
|
+
if (typeBaseTarget.startTime < 0)
|
|
47
|
+
typeBaseTarget.SetStartTime(0);
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
protected virtual void DisplayDuration()
|
|
55
|
+
{
|
|
56
|
+
float fallBackDuration = typeBaseTarget.duration;
|
|
57
|
+
|
|
58
|
+
typeBaseTarget.SetDuration(HandyFields.FloatField("Duration: ", typeBaseTarget.duration, 30));
|
|
59
|
+
|
|
60
|
+
if (typeBaseTarget.duration <= 0)
|
|
61
|
+
{
|
|
62
|
+
if (fallBackDuration == 0)
|
|
63
|
+
typeBaseTarget.SetDuration(1);
|
|
64
|
+
else
|
|
65
|
+
typeBaseTarget.SetDuration(fallBackDuration);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
///
|
|
71
|
+
/// </summary>
|
|
72
|
+
protected virtual void DisplayCurveButtons()
|
|
73
|
+
{
|
|
74
|
+
if (typeBaseTarget.animationCurves.Count != 0)
|
|
75
|
+
{
|
|
76
|
+
if (GUILayout.Button("Update Curves"))
|
|
77
|
+
UpdateCurves();
|
|
78
|
+
|
|
79
|
+
if (GUILayout.Button("Reset Curves"))
|
|
80
|
+
ResetCurves();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
protected virtual void DisplayGenerateCurves()
|
|
88
|
+
{
|
|
89
|
+
if (typeBaseTarget.animationCurves.Count == 0)
|
|
90
|
+
{
|
|
91
|
+
if (GUILayout.Button("Generate Curves"))
|
|
92
|
+
GenerateCurves();
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
using (new EditorGUILayout.HorizontalScope())
|
|
96
|
+
DisplayCurves();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
///
|
|
101
|
+
/// </summary>
|
|
102
|
+
protected virtual void GenerateCurves()
|
|
103
|
+
{
|
|
104
|
+
for (int i = 0; i < typeBaseTarget.CurveCount; i++)
|
|
105
|
+
typeBaseTarget.animationCurves.Add(new AnimationCurve());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
///
|
|
110
|
+
/// </summary>
|
|
111
|
+
protected abstract void DisplayType();
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
///
|
|
115
|
+
/// </summary>
|
|
116
|
+
protected abstract void DisplayCurves();
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
///
|
|
120
|
+
/// </summary>
|
|
121
|
+
protected abstract void UpdateCurves();
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
///
|
|
125
|
+
/// </summary>
|
|
126
|
+
protected virtual void ResetCurves()
|
|
127
|
+
{
|
|
128
|
+
typeBaseTarget.animationCurves.Clear();
|
|
129
|
+
|
|
130
|
+
GenerateCurves();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
///
|
|
136
|
+
/// </summary>
|
|
137
|
+
/// <param name="curve"></param>
|
|
138
|
+
/// <param name="start"></param>
|
|
139
|
+
/// <param name="end"></param>
|
|
140
|
+
/// <returns></returns>
|
|
141
|
+
protected virtual AnimationCurve DisplayCurve(AnimationCurve curve, float start, float end)
|
|
142
|
+
{
|
|
143
|
+
if (curve.keys.Length == 0)
|
|
144
|
+
{
|
|
145
|
+
curve.AddKey(typeBaseTarget.startTime, start);
|
|
146
|
+
|
|
147
|
+
curve.AddKey(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try // Clicking the curve field would call an internal unity error but still works so this try is here to mitigate that.
|
|
151
|
+
{
|
|
152
|
+
curve = EditorGUILayout.CurveField(curve);
|
|
153
|
+
}
|
|
154
|
+
catch { }
|
|
155
|
+
|
|
156
|
+
return curve;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// <summary>
|
|
160
|
+
///
|
|
161
|
+
/// </summary>
|
|
162
|
+
/// <param name="curve"></param>
|
|
163
|
+
/// <param name="start"></param>
|
|
164
|
+
/// <param name="end"></param>
|
|
165
|
+
/// <returns></returns>
|
|
166
|
+
protected virtual AnimationCurve UpdateKey(AnimationCurve curve, float start, float end)
|
|
167
|
+
{
|
|
168
|
+
Keyframe oldStartTimeKey = curve.keys[0];
|
|
169
|
+
|
|
170
|
+
Keyframe oldDurationTimeKey = curve.keys[^1];
|
|
171
|
+
|
|
172
|
+
curve.keys = ValidateCurves(oldStartTimeKey, oldDurationTimeKey, curve, start, end);
|
|
173
|
+
|
|
174
|
+
return curve;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
#region Keyframe Validation
|
|
178
|
+
|
|
179
|
+
/// <summary>
|
|
180
|
+
///
|
|
181
|
+
/// </summary>
|
|
182
|
+
/// <param name="oldStart"></param>
|
|
183
|
+
/// <param name="oldDuration"></param>
|
|
184
|
+
/// <param name="curve"></param>
|
|
185
|
+
/// <param name="start"></param>
|
|
186
|
+
/// <param name="end"></param>
|
|
187
|
+
/// <returns></returns>
|
|
188
|
+
protected virtual Keyframe[] ValidateCurves(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve, float start, float end)
|
|
189
|
+
{
|
|
190
|
+
if (ValidateMovedKey(curve, start, end))
|
|
191
|
+
return curve.keys;
|
|
192
|
+
|
|
193
|
+
Keyframe[] newKeys = ValidateNewKeys(oldStart, oldDuration, curve);
|
|
194
|
+
|
|
195
|
+
newKeys[0] = new(typeBaseTarget.startTime, start);
|
|
196
|
+
|
|
197
|
+
newKeys[curve.keys.Length - 1] = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
198
|
+
|
|
199
|
+
return newKeys;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// <summary>
|
|
203
|
+
///
|
|
204
|
+
/// </summary>
|
|
205
|
+
/// <param name="curve"></param>
|
|
206
|
+
/// <param name="start"></param>
|
|
207
|
+
/// <param name="end"></param>
|
|
208
|
+
/// <returns></returns>
|
|
209
|
+
protected virtual bool ValidateMovedKey(AnimationCurve curve, float start, float end)
|
|
210
|
+
{
|
|
211
|
+
Keyframe newStart = new(typeBaseTarget.startTime, start);
|
|
212
|
+
|
|
213
|
+
Keyframe newDuration = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
214
|
+
|
|
215
|
+
if (curve.keys[^1].time == newDuration.time && curve.keys[0].time == newStart.time)
|
|
216
|
+
{
|
|
217
|
+
if (curve.keys[^1].value == newDuration.value && curve.keys[0].value == newStart.value)
|
|
218
|
+
return true;
|
|
219
|
+
else
|
|
220
|
+
{
|
|
221
|
+
curve.MoveKey(0, new(0, start));
|
|
222
|
+
|
|
223
|
+
curve.MoveKey(curve.keys.Length - 1, new(typeBaseTarget.startTime + typeBaseTarget.duration, end));
|
|
224
|
+
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// <summary>
|
|
233
|
+
///
|
|
234
|
+
/// </summary>
|
|
235
|
+
/// <param name="oldStart"></param>
|
|
236
|
+
/// <param name="oldDuration"></param>
|
|
237
|
+
/// <param name="curve"></param>
|
|
238
|
+
/// <returns></returns>
|
|
239
|
+
protected virtual Keyframe[] ValidateNewKeys(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
240
|
+
{
|
|
241
|
+
Keyframe[] newKeys = new Keyframe[curve.keys.Length];
|
|
242
|
+
|
|
243
|
+
if (curve.keys.Length > 2)
|
|
244
|
+
UpdateNewKeys(newKeys, oldStart, oldDuration, curve);
|
|
245
|
+
|
|
246
|
+
return newKeys;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// <summary>
|
|
250
|
+
///
|
|
251
|
+
/// </summary>
|
|
252
|
+
/// <param name="newKeys"></param>
|
|
253
|
+
/// <param name="oldStart"></param>
|
|
254
|
+
/// <param name="oldDuration"></param>
|
|
255
|
+
/// <param name="curve"></param>
|
|
256
|
+
protected virtual void UpdateNewKeys(Keyframe[] newKeys, Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
257
|
+
{
|
|
258
|
+
float startOffset = typeBaseTarget.startTime - oldStart.time;
|
|
259
|
+
|
|
260
|
+
float durationOffset = (typeBaseTarget.startTime + typeBaseTarget.duration) - oldDuration.time;
|
|
261
|
+
|
|
262
|
+
for (int i = 1; i <= newKeys.Length - 2; i++)
|
|
263
|
+
if (curve.keys[i].time <= typeBaseTarget.startTime)
|
|
264
|
+
newKeys[i] = new(curve.keys[i].time + startOffset, curve.keys[i].value);
|
|
265
|
+
else if (curve.keys[i].time >= typeBaseTarget.startTime + typeBaseTarget.duration)
|
|
266
|
+
newKeys[i] = new(curve.keys[i].time + durationOffset, curve.keys[i].value);
|
|
267
|
+
else
|
|
268
|
+
{
|
|
269
|
+
float behind = curve.keys[i].time - curve.keys[i - 1].time;
|
|
270
|
+
|
|
271
|
+
newKeys[i] = new(curve.keys[i].time + behind, curve.keys[i].value);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#endregion
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
#endif
|
package/Editor.meta
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.PhraseAnimations
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
public interface IPhraseAnimationType
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
/// <param name="clip"></param>
|
|
15
|
+
void Initialize(AnimationClip clip);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Minigames.Debates;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[System.Serializable]
|
|
13
|
+
public class PhraseAnimation : IPhraseAnimationArchitecture
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
public Vector3 spawnPoint;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
public Vector4 spawnAngle;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
public List<AnimData> animations = new();
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
/// <param name="spawnPoint"></param>
|
|
35
|
+
public virtual void SetSpawnPoint(Vector3 spawnPoint) => this.spawnPoint = spawnPoint;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
/// <param name="spawnAngle"></param>
|
|
41
|
+
public virtual void SetSpawnAngle(Vector4 spawnAngle) => this.spawnAngle = spawnAngle;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/// <inheritdoc/>
|
|
45
|
+
public virtual void Initialize(object o = null)
|
|
46
|
+
{
|
|
47
|
+
if (o is AnimationClip clip)
|
|
48
|
+
foreach (AnimData anim in animations)
|
|
49
|
+
anim.Initialize(clip);
|
|
50
|
+
else
|
|
51
|
+
UnityEngine.Debug.LogWarning($"ALERT: Failed to initialize animation architecture: {nameof(PhraseAnimation)}" +
|
|
52
|
+
$" because the sent value for initialization was not of type {nameof(AnimationClip)}.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// <inheritdoc/>
|
|
56
|
+
public virtual void Apply(IPhraseAnimationArchitecture architecture)
|
|
57
|
+
{
|
|
58
|
+
PhraseAnimation animation = architecture as PhraseAnimation;
|
|
59
|
+
|
|
60
|
+
spawnPoint = animation.spawnPoint;
|
|
61
|
+
|
|
62
|
+
spawnAngle = animation.spawnAngle;
|
|
63
|
+
|
|
64
|
+
foreach (var newAnimation in animation.animations)
|
|
65
|
+
{
|
|
66
|
+
if (animations.Any(animation => animation.animationType?.GetType() == newAnimation.animationType?.GetType()))
|
|
67
|
+
UnityEngine.Debug.Log("REPORT: The phrases simple animation contains duplicate types." +
|
|
68
|
+
"\nPROPOSAL: Test animation to ensure no animations conflict with each other.");
|
|
69
|
+
|
|
70
|
+
animations.Add(newAnimation);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEngine.Serialization;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.PhraseAnimations
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
/// <typeparam name="T"></typeparam>
|
|
11
|
+
[Serializable]
|
|
12
|
+
public abstract class PhraseAnimationCompact<T> : PhraseAnimationTypeBase
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[FormerlySerializedAs("startScale")]
|
|
18
|
+
[FormerlySerializedAs("startPosition")]
|
|
19
|
+
[FormerlySerializedAs("startRotation")]
|
|
20
|
+
[FormerlySerializedAs("startFade")]
|
|
21
|
+
public T startValue;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[FormerlySerializedAs("endScale")]
|
|
27
|
+
[FormerlySerializedAs("endPosition")]
|
|
28
|
+
[FormerlySerializedAs("endRotation")]
|
|
29
|
+
[FormerlySerializedAs("endFade")]
|
|
30
|
+
public T endValue;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <param name="startValue"></param>
|
|
37
|
+
public virtual void SetStartValue(T startValue) => this.startValue = startValue;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <param name="endValue"></param>
|
|
43
|
+
public virtual void SetEndValue(T endValue) => this.endValue = endValue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Minigames.Debates;
|
|
3
|
+
using DREditor.Processables;
|
|
4
|
+
using TMPro;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[ClassHeader(nameof(IPhraseAnimationComponent) + ", " + nameof(IPhraseHandlerComponent) + ", " +
|
|
13
|
+
nameof(IPhraseShatterListener) + ", " + nameof(IPhraseResetter) + ", " + nameof(IPrioritizable) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class PhraseAnimationHandler : MonoBehaviour, IPhraseAnimationComponent, IPhraseShatterListener, IPrioritizable
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected int priority = 0;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Header("")]
|
|
28
|
+
[Divider]
|
|
29
|
+
[Tooltip("")]
|
|
30
|
+
[SerializeField] protected Animation compiledAnimation;
|
|
31
|
+
|
|
32
|
+
public int Priority { get => priority; set => priority = value; }
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
protected readonly string animationClipName = "transform";
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
protected float duration;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
protected PhraseAnimation phraseAnimation = null;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
protected virtual void Awake() => compiledAnimation = GetComponent<Animation>();
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/// <inheritdoc/>
|
|
55
|
+
public virtual void StartPhrase<T>(T phrase) where T : PhraseBase
|
|
56
|
+
{
|
|
57
|
+
InitializePhraseAnimation(phrase);
|
|
58
|
+
|
|
59
|
+
if (phraseAnimation != null)
|
|
60
|
+
{
|
|
61
|
+
InitializeText();
|
|
62
|
+
|
|
63
|
+
CompilePhraseAnimation();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
/// <param name="phrase"></param>
|
|
71
|
+
protected virtual void InitializePhraseAnimation(PhraseBase phrase)
|
|
72
|
+
{
|
|
73
|
+
phraseAnimation = null;
|
|
74
|
+
|
|
75
|
+
foreach (var architecture in phrase.animations)
|
|
76
|
+
if (architecture is PhraseAnimation phraseDataAnimation)
|
|
77
|
+
phraseAnimation = phraseDataAnimation;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
protected virtual void InitializeText()
|
|
84
|
+
{
|
|
85
|
+
var tmpText = GetComponent<TMP_Text>();
|
|
86
|
+
|
|
87
|
+
tmpText.transform.localScale = Vector3.one;
|
|
88
|
+
|
|
89
|
+
//Below makes it to where using the dolly track only works once
|
|
90
|
+
if (phraseAnimation.spawnPoint == Vector3.zero || phraseAnimation.spawnPoint == null)
|
|
91
|
+
tmpText.transform.position = phraseAnimation.spawnPoint;
|
|
92
|
+
else
|
|
93
|
+
tmpText.transform.localPosition = phraseAnimation.spawnPoint;
|
|
94
|
+
|
|
95
|
+
Vector4 rot = phraseAnimation.spawnAngle;
|
|
96
|
+
|
|
97
|
+
tmpText.transform.localEulerAngles = new(rot.x, rot.y, rot.z);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
protected virtual void CompilePhraseAnimation()
|
|
104
|
+
{
|
|
105
|
+
compiledAnimation.enabled = true;
|
|
106
|
+
|
|
107
|
+
AnimationClip animationClip = new()
|
|
108
|
+
{
|
|
109
|
+
legacy = true
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
phraseAnimation.Initialize(animationClip);
|
|
113
|
+
|
|
114
|
+
compiledAnimation.AddClip(animationClip, animationClipName);
|
|
115
|
+
|
|
116
|
+
compiledAnimation.Play(animationClipName);
|
|
117
|
+
|
|
118
|
+
duration = animationClip.length;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/// <inheritdoc/>
|
|
123
|
+
public virtual void OnShattered()
|
|
124
|
+
{
|
|
125
|
+
compiledAnimation.Stop();
|
|
126
|
+
|
|
127
|
+
compiledAnimation.enabled = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// <inheritdoc/>
|
|
131
|
+
public virtual float GetPhraseDuration() => duration;
|
|
132
|
+
|
|
133
|
+
/// <inheritdoc/>
|
|
134
|
+
public virtual void Reset() => compiledAnimation.enabled = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.PhraseAnimations
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[Serializable]
|
|
12
|
+
public abstract class PhraseAnimationTypeBase : IPhraseAnimationType
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[SerializeField] public float startTime;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[SerializeField] public float duration;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
public abstract int CurveCount { get; }
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
public List<AnimationCurve> animationCurves = new();
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
/// <param name="startTime"></param>
|
|
40
|
+
public virtual void SetStartTime(float startTime) => this.startTime = startTime;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
/// <param name="duration"></param>
|
|
46
|
+
public virtual void SetDuration(float duration) => this.duration = duration;
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
///
|
|
50
|
+
/// </summary>
|
|
51
|
+
/// <param name="clip"></param>
|
|
52
|
+
public abstract void Initialize(AnimationClip clip);
|
|
53
|
+
}
|
|
54
|
+
}
|