net.dreditor.trackphrase 0.1.6 → 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/PhraseTrack.cs CHANGED
@@ -1,185 +1,185 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- #if CINEMACHINE
3
- using Cinemachine;
4
- using DREditor.Cameras;
5
- using DREditor.Minigames.Debates;
6
- using DREditor.Processables;
7
- using UnityEngine;
8
-
9
- namespace DREditor.TrackPhrase
10
- {
11
- /// <summary>
12
- ///
13
- /// </summary>
14
- [ClassHeader(nameof(IPhraseHandlerComponent) + ", " + nameof(IPhraseShatterListener) + ", " + nameof(IPhraseResetter) +
15
- ", " + nameof(IPrioritizable) +
16
- "\n\n")]
17
- public class PhraseTrack : MonoBehaviour, IPhraseHandlerComponent, IPhraseShatterListener, IPhraseResetter, IPrioritizable
18
- {
19
- /// <summary>
20
- ///
21
- /// </summary>
22
- [Tooltip("")]
23
- [SerializeField] protected int priority = 1;
24
-
25
-
26
- public int Priority { get => priority; set => priority = value; }
27
-
28
-
29
- /// <summary>
30
- ///
31
- /// </summary>
32
- protected TrackPath trackPath;
33
-
34
- /// <summary>
35
- ///
36
- /// </summary>
37
- protected DollyCartNSD cart;
38
-
39
- /// <summary>
40
- ///
41
- /// </summary>
42
- protected CinemachinePath path;
43
-
44
- /// <summary>
45
- ///
46
- /// </summary>
47
- protected bool usingTrack = false;
48
-
49
- /// <summary>
50
- ///
51
- /// </summary>
52
- protected GameObject pathRef;
53
-
54
- /// <summary>
55
- ///
56
- /// </summary>
57
- protected Transform cameraTransform;
58
-
59
-
60
- protected virtual void Awake() => cameraTransform = FindAnyObjectByType<DRTrialCamera>().transform;
61
-
62
-
63
- /// <inheritdoc/>
64
- public virtual void StartPhrase<T>(T phrase) where T : PhraseBase
65
- {
66
- foreach (var animation in phrase.animations)
67
- if (animation is TrackPath trackPath)
68
- this.trackPath = trackPath;
69
-
70
- if (trackPath != null && trackPath.Points.Length > 0)
71
- StartAnimation();
72
- }
73
-
74
- /// <summary>
75
- ///
76
- /// </summary>
77
- protected virtual void StartAnimation()
78
- {
79
- InitializeCart();
80
-
81
- InitializePath();
82
-
83
- PlayCart();
84
- }
85
-
86
- /// <summary>
87
- ///
88
- /// </summary>
89
- protected virtual void InitializeCart()
90
- {
91
- GameObject parent = transform.parent.gameObject;
92
-
93
- if (parent.TryGetComponent<DollyCartNSD>(out var cart))
94
- {
95
- this.cart = cart;
96
-
97
- cart.SetPath(null);
98
-
99
- cart.SetSpeed(0);
100
-
101
- cart.SetPosition(0);
102
- }
103
- else
104
- this.cart = parent.AddComponent<DollyCartNSD>();
105
- }
106
-
107
- /// <summary>
108
- ///
109
- /// </summary>
110
- protected virtual void InitializePath()
111
- {
112
- pathRef = new GameObject();
113
-
114
- GameObject ch = new();
115
-
116
- ch.transform.parent = pathRef.transform;
117
-
118
- path = ch.AddComponent<CinemachinePath>();
119
-
120
- path.gameObject.transform.localPosition = trackPath.Position;
121
-
122
- Vector4 rot = trackPath.Rotation;
123
-
124
- path.gameObject.transform.localEulerAngles = new(rot.x, rot.y, rot.z);
125
-
126
- pathRef.transform.SetPositionAndRotation(new(0, cameraTransform.position.y, 0),
127
- new Quaternion(0, cameraTransform.rotation.y, 0, cameraTransform.rotation.w));
128
-
129
- transform.localPosition = new(0, -1, 0);
130
- }
131
-
132
- /// <summary>
133
- ///
134
- /// </summary>
135
- protected virtual void PlayCart()
136
- {
137
- cart.SetPosition(0);
138
-
139
- cart.SetPositionUnits(CinemachinePathBase.PositionUnits.Normalized);
140
-
141
- cart.SetCurve(trackPath.SpeedCurve);
142
-
143
- cart.SetUseCurve(true);
144
-
145
- path.m_Waypoints = trackPath.Points;
146
-
147
- cart.SetPath(path);
148
-
149
- cart.SetSpeed(1);
150
-
151
- cart.enabled = true;
152
-
153
- usingTrack = true;
154
- }
155
-
156
- /// <summary>
157
- ///
158
- /// </summary>
159
- /// <returns></returns>
160
- public virtual bool IsUsingTrack() => usingTrack;
161
-
162
-
163
- /// <inheritdoc/>
164
- public virtual void OnShattered()
165
- {
166
- if (usingTrack)
167
- transform.parent.gameObject.GetComponent<DollyCartNSD>().enabled = false;
168
- }
169
-
170
- /// <inheritdoc/>
171
- public virtual void Reset()
172
- {
173
- if (transform.parent.gameObject.TryGetComponent<DollyCartNSD>(out var cart))
174
- Destroy(cart);
175
-
176
- if (pathRef != null)
177
- Destroy(pathRef);
178
-
179
- trackPath = null;
180
-
181
- usingTrack = false;
182
- }
183
- }
184
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if CINEMACHINE
3
+ using Cinemachine;
4
+ using DREditor.Cameras;
5
+ using DREditor.Minigames.Debates;
6
+ using DREditor.Processables;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.TrackPhrase
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(IPhraseHandlerComponent) + ", " + nameof(IPhraseShatterListener) + ", " + nameof(IPhraseResetter) +
15
+ ", " + nameof(IPrioritizable) +
16
+ "\n\n")]
17
+ public class PhraseTrack : MonoBehaviour, IPhraseHandlerComponent, IPhraseShatterListener, IPhraseResetter, IPrioritizable
18
+ {
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ [Tooltip("")]
23
+ [SerializeField] protected int priority = 1;
24
+
25
+
26
+ public int Priority { get => priority; set => priority = value; }
27
+
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ protected TrackPath trackPath;
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ protected DollyCartNSD cart;
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ protected CinemachinePath path;
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ protected bool usingTrack = false;
48
+
49
+ /// <summary>
50
+ ///
51
+ /// </summary>
52
+ protected GameObject pathRef;
53
+
54
+ /// <summary>
55
+ ///
56
+ /// </summary>
57
+ protected Transform cameraTransform;
58
+
59
+
60
+ protected virtual void Awake() => cameraTransform = FindAnyObjectByType<DRTrialCamera>().transform;
61
+
62
+
63
+ /// <inheritdoc/>
64
+ public virtual void StartPhrase<T>(T phrase) where T : PhraseBase
65
+ {
66
+ foreach (var animation in phrase.animations)
67
+ if (animation is TrackPath trackPath)
68
+ this.trackPath = trackPath;
69
+
70
+ if (trackPath != null && trackPath.Points.Length > 0)
71
+ StartAnimation();
72
+ }
73
+
74
+ /// <summary>
75
+ ///
76
+ /// </summary>
77
+ protected virtual void StartAnimation()
78
+ {
79
+ InitializeCart();
80
+
81
+ InitializePath();
82
+
83
+ PlayCart();
84
+ }
85
+
86
+ /// <summary>
87
+ ///
88
+ /// </summary>
89
+ protected virtual void InitializeCart()
90
+ {
91
+ GameObject parent = transform.parent.gameObject;
92
+
93
+ if (parent.TryGetComponent<DollyCartNSD>(out var cart))
94
+ {
95
+ this.cart = cart;
96
+
97
+ cart.SetPath(null);
98
+
99
+ cart.SetSpeed(0);
100
+
101
+ cart.SetPosition(0);
102
+ }
103
+ else
104
+ this.cart = parent.AddComponent<DollyCartNSD>();
105
+ }
106
+
107
+ /// <summary>
108
+ ///
109
+ /// </summary>
110
+ protected virtual void InitializePath()
111
+ {
112
+ pathRef = new GameObject();
113
+
114
+ GameObject ch = new();
115
+
116
+ ch.transform.parent = pathRef.transform;
117
+
118
+ path = ch.AddComponent<CinemachinePath>();
119
+
120
+ path.gameObject.transform.localPosition = trackPath.Position;
121
+
122
+ Vector4 rot = trackPath.Rotation;
123
+
124
+ path.gameObject.transform.localEulerAngles = new(rot.x, rot.y, rot.z);
125
+
126
+ pathRef.transform.SetPositionAndRotation(new(0, cameraTransform.position.y, 0),
127
+ new Quaternion(0, cameraTransform.rotation.y, 0, cameraTransform.rotation.w));
128
+
129
+ transform.localPosition = new(0, -1, 0);
130
+ }
131
+
132
+ /// <summary>
133
+ ///
134
+ /// </summary>
135
+ protected virtual void PlayCart()
136
+ {
137
+ cart.SetPosition(0);
138
+
139
+ cart.SetPositionUnits(CinemachinePathBase.PositionUnits.Normalized);
140
+
141
+ cart.SetCurve(trackPath.SpeedCurve);
142
+
143
+ cart.SetUseCurve(true);
144
+
145
+ path.m_Waypoints = trackPath.Points;
146
+
147
+ cart.SetPath(path);
148
+
149
+ cart.SetSpeed(1);
150
+
151
+ cart.enabled = true;
152
+
153
+ usingTrack = true;
154
+ }
155
+
156
+ /// <summary>
157
+ ///
158
+ /// </summary>
159
+ /// <returns></returns>
160
+ public virtual bool IsUsingTrack() => usingTrack;
161
+
162
+
163
+ /// <inheritdoc/>
164
+ public virtual void OnShattered()
165
+ {
166
+ if (usingTrack)
167
+ transform.parent.gameObject.GetComponent<DollyCartNSD>().enabled = false;
168
+ }
169
+
170
+ /// <inheritdoc/>
171
+ public virtual void Reset()
172
+ {
173
+ if (transform.parent.gameObject.TryGetComponent<DollyCartNSD>(out var cart))
174
+ Destroy(cart);
175
+
176
+ if (pathRef != null)
177
+ Destroy(pathRef);
178
+
179
+ trackPath = null;
180
+
181
+ usingTrack = false;
182
+ }
183
+ }
184
+ }
185
185
  #endif
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 3e2c7f3f41b90154187a1c6dbc13bbcc
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 3e2c7f3f41b90154187a1c6dbc13bbcc
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,94 +1,94 @@
1
- %YAML 1.1
2
- %TAG !u! tag:unity3d.com,2011:
3
- --- !u!1 &907238091587208738
4
- GameObject:
5
- m_ObjectHideFlags: 0
6
- m_CorrespondingSourceObject: {fileID: 0}
7
- m_PrefabInstance: {fileID: 0}
8
- m_PrefabAsset: {fileID: 0}
9
- serializedVersion: 6
10
- m_Component:
11
- - component: {fileID: 7942543658575344102}
12
- m_Layer: 0
13
- m_Name: Track_Parent
14
- m_TagString: Untagged
15
- m_Icon: {fileID: 0}
16
- m_NavMeshLayer: 0
17
- m_StaticEditorFlags: 0
18
- m_IsActive: 1
19
- --- !u!4 &7942543658575344102
20
- Transform:
21
- m_ObjectHideFlags: 0
22
- m_CorrespondingSourceObject: {fileID: 0}
23
- m_PrefabInstance: {fileID: 0}
24
- m_PrefabAsset: {fileID: 0}
25
- m_GameObject: {fileID: 907238091587208738}
26
- m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
27
- m_LocalPosition: {x: 0, y: 7.83, z: 0}
28
- m_LocalScale: {x: 1, y: 1, z: 1}
29
- m_ConstrainProportionsScale: 0
30
- m_Children:
31
- - {fileID: 871339856408963998}
32
- m_Father: {fileID: 0}
33
- m_RootOrder: 0
34
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35
- --- !u!1 &8289200428657646794
36
- GameObject:
37
- m_ObjectHideFlags: 0
38
- m_CorrespondingSourceObject: {fileID: 0}
39
- m_PrefabInstance: {fileID: 0}
40
- m_PrefabAsset: {fileID: 0}
41
- serializedVersion: 6
42
- m_Component:
43
- - component: {fileID: 871339856408963998}
44
- - component: {fileID: 2407333302034471369}
45
- m_Layer: 0
46
- m_Name: Path
47
- m_TagString: Untagged
48
- m_Icon: {fileID: 0}
49
- m_NavMeshLayer: 0
50
- m_StaticEditorFlags: 0
51
- m_IsActive: 1
52
- --- !u!4 &871339856408963998
53
- Transform:
54
- m_ObjectHideFlags: 0
55
- m_CorrespondingSourceObject: {fileID: 0}
56
- m_PrefabInstance: {fileID: 0}
57
- m_PrefabAsset: {fileID: 0}
58
- m_GameObject: {fileID: 8289200428657646794}
59
- m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
60
- m_LocalPosition: {x: 0, y: 0, z: 9}
61
- m_LocalScale: {x: 1, y: 1, z: 1}
62
- m_ConstrainProportionsScale: 0
63
- m_Children: []
64
- m_Father: {fileID: 7942543658575344102}
65
- m_RootOrder: 0
66
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
67
- --- !u!114 &2407333302034471369
68
- MonoBehaviour:
69
- m_ObjectHideFlags: 0
70
- m_CorrespondingSourceObject: {fileID: 0}
71
- m_PrefabInstance: {fileID: 0}
72
- m_PrefabAsset: {fileID: 0}
73
- m_GameObject: {fileID: 8289200428657646794}
74
- m_Enabled: 1
75
- m_EditorHideFlags: 0
76
- m_Script: {fileID: 11500000, guid: 2d37e5385efd7064cb1d54c94960acae, type: 3}
77
- m_Name:
78
- m_EditorClassIdentifier:
79
- m_Resolution: 20
80
- m_Appearance:
81
- pathColor: {r: 0, g: 1, b: 0, a: 1}
82
- inactivePathColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
83
- width: 0.2
84
- m_Looped: 0
85
- m_Waypoints:
86
- - position: {x: 0, y: 0, z: 0}
87
- tangent: {x: 0, y: 0, z: 0}
88
- roll: 0
89
- - position: {x: 0, y: 0, z: 0}
90
- tangent: {x: 0, y: 0, z: 0}
91
- roll: 0
92
- - position: {x: 0, y: 0, z: 0}
93
- tangent: {x: 0, y: 0, z: 0}
94
- roll: 0
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!1 &907238091587208738
4
+ GameObject:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ serializedVersion: 6
10
+ m_Component:
11
+ - component: {fileID: 7942543658575344102}
12
+ m_Layer: 0
13
+ m_Name: Track_Parent
14
+ m_TagString: Untagged
15
+ m_Icon: {fileID: 0}
16
+ m_NavMeshLayer: 0
17
+ m_StaticEditorFlags: 0
18
+ m_IsActive: 1
19
+ --- !u!4 &7942543658575344102
20
+ Transform:
21
+ m_ObjectHideFlags: 0
22
+ m_CorrespondingSourceObject: {fileID: 0}
23
+ m_PrefabInstance: {fileID: 0}
24
+ m_PrefabAsset: {fileID: 0}
25
+ m_GameObject: {fileID: 907238091587208738}
26
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
27
+ m_LocalPosition: {x: 0, y: 7.83, z: 0}
28
+ m_LocalScale: {x: 1, y: 1, z: 1}
29
+ m_ConstrainProportionsScale: 0
30
+ m_Children:
31
+ - {fileID: 871339856408963998}
32
+ m_Father: {fileID: 0}
33
+ m_RootOrder: 0
34
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35
+ --- !u!1 &8289200428657646794
36
+ GameObject:
37
+ m_ObjectHideFlags: 0
38
+ m_CorrespondingSourceObject: {fileID: 0}
39
+ m_PrefabInstance: {fileID: 0}
40
+ m_PrefabAsset: {fileID: 0}
41
+ serializedVersion: 6
42
+ m_Component:
43
+ - component: {fileID: 871339856408963998}
44
+ - component: {fileID: 2407333302034471369}
45
+ m_Layer: 0
46
+ m_Name: Path
47
+ m_TagString: Untagged
48
+ m_Icon: {fileID: 0}
49
+ m_NavMeshLayer: 0
50
+ m_StaticEditorFlags: 0
51
+ m_IsActive: 1
52
+ --- !u!4 &871339856408963998
53
+ Transform:
54
+ m_ObjectHideFlags: 0
55
+ m_CorrespondingSourceObject: {fileID: 0}
56
+ m_PrefabInstance: {fileID: 0}
57
+ m_PrefabAsset: {fileID: 0}
58
+ m_GameObject: {fileID: 8289200428657646794}
59
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
60
+ m_LocalPosition: {x: 0, y: 0, z: 9}
61
+ m_LocalScale: {x: 1, y: 1, z: 1}
62
+ m_ConstrainProportionsScale: 0
63
+ m_Children: []
64
+ m_Father: {fileID: 7942543658575344102}
65
+ m_RootOrder: 0
66
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
67
+ --- !u!114 &2407333302034471369
68
+ MonoBehaviour:
69
+ m_ObjectHideFlags: 0
70
+ m_CorrespondingSourceObject: {fileID: 0}
71
+ m_PrefabInstance: {fileID: 0}
72
+ m_PrefabAsset: {fileID: 0}
73
+ m_GameObject: {fileID: 8289200428657646794}
74
+ m_Enabled: 1
75
+ m_EditorHideFlags: 0
76
+ m_Script: {fileID: 11500000, guid: 2d37e5385efd7064cb1d54c94960acae, type: 3}
77
+ m_Name:
78
+ m_EditorClassIdentifier:
79
+ m_Resolution: 20
80
+ m_Appearance:
81
+ pathColor: {r: 0, g: 1, b: 0, a: 1}
82
+ inactivePathColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
83
+ width: 0.2
84
+ m_Looped: 0
85
+ m_Waypoints:
86
+ - position: {x: 0, y: 0, z: 0}
87
+ tangent: {x: 0, y: 0, z: 0}
88
+ roll: 0
89
+ - position: {x: 0, y: 0, z: 0}
90
+ tangent: {x: 0, y: 0, z: 0}
91
+ roll: 0
92
+ - position: {x: 0, y: 0, z: 0}
93
+ tangent: {x: 0, y: 0, z: 0}
94
+ roll: 0
@@ -1,7 +1,7 @@
1
- fileFormatVersion: 2
2
- guid: 733530f3d40d8944aadad51b883ab1d9
3
- PrefabImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 733530f3d40d8944aadad51b883ab1d9
3
+ PrefabImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: