net.dreditor.talkables 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.
@@ -1,253 +1,253 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- #if DOTWEEN
3
- using DG.Tweening;
4
- #endif
5
- using DREditor.Dialogues;
6
- using DREditor.Dialogues.Ending;
7
- using DREditor.Dialogues.Events;
8
- using DREditor.Dialogues.Finishing;
9
- using DREditor.Dialogues.Starting;
10
- using DREditor.EventObjects;
11
- using DREditor.Services;
12
- using System.Collections;
13
- using UnityEngine;
14
-
15
- namespace DREditor.Talkables
16
- {
17
- /// <summary>
18
- ///
19
- /// </summary>
20
- [ClassHeader(nameof(IPreparableDialogueComponent) + ", " + nameof(IResolvableDialogueComponent) + ", "
21
- + nameof(IFinishableDialogueComponent) +
22
- "\n\n")]
23
- public class LookAtObjectOnSelection : DialogueComponent, IPreparableDialogueComponent, IResolvableDialogueComponent,
24
- IFinishableDialogueComponent, IToTitleScreen
25
- {
26
- /// <summary>
27
- ///
28
- /// </summary>
29
- [Tooltip("")]
30
- [SerializeField] protected float prepareOrder = 1;
31
-
32
- /// <summary>
33
- ///
34
- /// </summary>
35
- [Tooltip("")]
36
- [SerializeField] protected float resolveOrder = 1;
37
-
38
- /// <summary>
39
- ///
40
- /// </summary>
41
- [Tooltip("")]
42
- [SerializeField] protected float finishOrder = 4;
43
-
44
- /// <summary>
45
- ///
46
- /// </summary>
47
- [Tooltip("")]
48
- [SerializeField] protected int finishPreparerID = 2;
49
-
50
- /// <summary>
51
- ///
52
- /// </summary>
53
- [Tooltip("")]
54
- [SerializeField] protected BoolWithEvent inDialogue = null;
55
-
56
- /// <summary>
57
- ///
58
- /// </summary>
59
- [Tooltip("")]
60
- [SerializeField] protected BoolWithEvent inTPFD = null;
61
-
62
- /// <summary>
63
- ///
64
- /// </summary>
65
- [Tooltip("")]
66
- [SerializeField] protected BoolWithEvent isLoadingFile = null;
67
-
68
-
69
- /// <summary>
70
- ///
71
- /// </summary>
72
- [Header("")]
73
- [Divider]
74
- [Tooltip("")]
75
- [SerializeField] protected string dialogueCameraToMainEventString = "DialogueCameraToMainCamera";
76
-
77
- /// <summary>
78
- ///
79
- /// </summary>
80
- [Tooltip("")]
81
- [SerializeField] protected string mainCameraTag = "MainCamera";
82
-
83
- /// <summary>
84
- ///
85
- /// </summary>
86
- [Tooltip("")]
87
- [SerializeField] protected float lookAtPlayerTime = 1;
88
-
89
-
90
- /// <summary>
91
- ///
92
- /// </summary>
93
- /// <remarks>
94
- ///
95
- /// </remarks>
96
- protected bool skipOGCamLook = false;
97
-
98
- /// <summary>
99
- ///
100
- /// </summary>
101
- protected Quaternion originalCameraLookRotation;
102
-
103
-
104
- float IDialogueComponent<IPreparableDialogueComponent>.Order { get => prepareOrder; }
105
-
106
- float IDialogueComponent<IResolvableDialogueComponent>.Order { get => resolveOrder; }
107
-
108
- float IDialogueComponent<IFinishableDialogueComponent>.Order { get => finishOrder; }
109
-
110
- int IDialogueComponent<IFinishableDialogueComponent>.ExclusiveHandlerID => finishPreparerID;
111
-
112
-
113
- /// <summary>
114
- ///
115
- /// </summary>
116
- protected virtual void OnEnable() => DialogueEventSystem.StartListening("PostToTPFDFromDialogue", OnCameraSet);
117
-
118
- /// <summary>
119
- ///
120
- /// </summary>
121
- protected virtual void OnDisable() => DialogueEventSystem.StopListening("PostToTPFDFromDialogue", OnCameraSet);
122
-
123
- /// <summary>
124
- ///
125
- /// </summary>
126
- /// <param name="o"></param>
127
- protected virtual void OnCameraSet(object o = null) => SetOGLookToMainCamera();
128
-
129
- /// <summary>
130
- ///
131
- /// </summary>
132
- protected virtual void SetOGLookToMainCamera()
133
- => originalCameraLookRotation = GameObject.FindWithTag(mainCameraTag).transform.rotation;
134
-
135
- /// <summary>
136
- ///
137
- /// </summary>
138
- protected virtual void DisableSkipOGCameraLook() => skipOGCamLook = false;
139
-
140
- /// <summary>
141
- ///
142
- /// </summary>
143
- protected virtual void ReturnToOriginalPosition()
144
- {
145
- if (!skipOGCamLook)
146
- #if DOTWEEN
147
- GameObject.FindWithTag(mainCameraTag).transform.DORotateQuaternion(originalCameraLookRotation, lookAtPlayerTime);
148
- #else
149
- GameObject.FindWithTag(mainCameraTag).transform.Rotate(originalCameraLookRotation.eulerAngles);
150
- #endif
151
- else
152
- DisableSkipOGCameraLook();
153
- }
154
-
155
- /// <summary>
156
- ///
157
- /// </summary>
158
- protected virtual void CheckSkippingOGCam()
159
- {
160
- if (skipOGCamLook)
161
- DisableSkipOGCameraLook();
162
- }
163
-
164
- /// <summary>
165
- ///
166
- /// </summary>
167
- /// <returns></returns>
168
- protected virtual IEnumerator LookAtSelectedObjectProcess()
169
- {
170
- Talkable selectedObject = ServiceLocator.GetService<DialogueObjectManager>().GetStartObject() as Talkable;
171
-
172
- PrepareCameraPositionsForDialogueStart();
173
-
174
- if (!inTPFD.Value)
175
- LookAtHead(selectedObject);
176
-
177
- if (!isLoadingFile.Value)
178
- yield return new WaitForSeconds(lookAtPlayerTime);
179
-
180
- yield break;
181
- }
182
-
183
- /// <summary>
184
- ///
185
- /// </summary>
186
- protected virtual void PrepareCameraPositionsForDialogueStart()
187
- {
188
- if (isLoadingFile.Value)
189
- EnableSkipOGCameraLook();
190
- else
191
- DialogueEventSystem.TriggerEvent(dialogueCameraToMainEventString);
192
-
193
- SetOGLookToMainCamera();
194
- }
195
-
196
- /// <summary>
197
- ///
198
- /// </summary>
199
- protected virtual void EnableSkipOGCameraLook() => skipOGCamLook = true;
200
-
201
- /// <summary>
202
- ///
203
- /// </summary>
204
- /// <param name="talkable"></param>
205
- protected virtual void LookAtHead(Talkable talkable)
206
- {
207
- if (talkable == null)
208
- return;
209
-
210
- if (!talkable.head)
211
- UnityEngine.Debug.LogWarning("ALERT: " + talkable.gameObject.name + " doesn't have a head initialized.");
212
- else
213
- #if DOTWEEN
214
- GameObject.FindWithTag(mainCameraTag).transform.DOLookAt(talkable.head.position, lookAtPlayerTime);
215
- #else
216
- GameObject.FindWithTag(mainCameraTag).transform.LookAt(talkable.head.position);
217
- #endif
218
- }
219
-
220
-
221
- /// <inheritdoc/>
222
- public virtual bool UseRoutineToPrepare() => true;
223
-
224
- /// <inheritdoc/>
225
- public virtual void Prepare() => StartCoroutine(PrepareRoutine());
226
-
227
- /// <inheritdoc/>
228
- public virtual IEnumerator PrepareRoutine() => LookAtSelectedObjectProcess();
229
-
230
-
231
- /// <inheritdoc/>
232
- public virtual bool UseRoutineToResolve() => false;
233
-
234
- /// <inheritdoc/>
235
- public virtual void Resolve() => ReturnToOriginalPosition();
236
-
237
- /// <inheritdoc/>
238
- public virtual IEnumerator ResolveRoutine()
239
- {
240
- Resolve();
241
-
242
- yield break;
243
- }
244
-
245
-
246
- /// <inheritdoc/>
247
- public virtual void OnFinishDialogue() => CheckSkippingOGCam();
248
-
249
-
250
- /// <inheritdoc/>
251
- public virtual void ToTitleScreen() => DisableSkipOGCameraLook();
252
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if DOTWEEN
3
+ using DG.Tweening;
4
+ #endif
5
+ using DREditor.Dialogues;
6
+ using DREditor.Dialogues.Ending;
7
+ using DREditor.Dialogues.Events;
8
+ using DREditor.Dialogues.Finishing;
9
+ using DREditor.Dialogues.Starting;
10
+ using DREditor.EventObjects;
11
+ using DREditor.Services;
12
+ using System.Collections;
13
+ using UnityEngine;
14
+
15
+ namespace DREditor.Talkables
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [ClassHeader(nameof(IPreparableDialogueComponent) + ", " + nameof(IResolvableDialogueComponent) + ", "
21
+ + nameof(IFinishableDialogueComponent) +
22
+ "\n\n")]
23
+ public class LookAtObjectOnSelection : DialogueComponent, IPreparableDialogueComponent, IResolvableDialogueComponent,
24
+ IFinishableDialogueComponent, IToTitleScreen
25
+ {
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected float prepareOrder = 1;
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Tooltip("")]
36
+ [SerializeField] protected float resolveOrder = 1;
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ [Tooltip("")]
42
+ [SerializeField] protected float finishOrder = 4;
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ [Tooltip("")]
48
+ [SerializeField] protected int finishPreparerID = 2;
49
+
50
+ /// <summary>
51
+ ///
52
+ /// </summary>
53
+ [Tooltip("")]
54
+ [SerializeField] protected BoolWithEvent inDialogue = null;
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ [Tooltip("")]
60
+ [SerializeField] protected BoolWithEvent inTPFD = null;
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ [Tooltip("")]
66
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
67
+
68
+
69
+ /// <summary>
70
+ ///
71
+ /// </summary>
72
+ [Header("")]
73
+ [Divider]
74
+ [Tooltip("")]
75
+ [SerializeField] protected string dialogueCameraToMainEventString = "DialogueCameraToMainCamera";
76
+
77
+ /// <summary>
78
+ ///
79
+ /// </summary>
80
+ [Tooltip("")]
81
+ [SerializeField] protected string mainCameraTag = "MainCamera";
82
+
83
+ /// <summary>
84
+ ///
85
+ /// </summary>
86
+ [Tooltip("")]
87
+ [SerializeField] protected float lookAtPlayerTime = 1;
88
+
89
+
90
+ /// <summary>
91
+ ///
92
+ /// </summary>
93
+ /// <remarks>
94
+ ///
95
+ /// </remarks>
96
+ protected bool skipOGCamLook = false;
97
+
98
+ /// <summary>
99
+ ///
100
+ /// </summary>
101
+ protected Quaternion originalCameraLookRotation;
102
+
103
+
104
+ float IDialogueComponent<IPreparableDialogueComponent>.Order { get => prepareOrder; }
105
+
106
+ float IDialogueComponent<IResolvableDialogueComponent>.Order { get => resolveOrder; }
107
+
108
+ float IDialogueComponent<IFinishableDialogueComponent>.Order { get => finishOrder; }
109
+
110
+ int IDialogueComponent<IFinishableDialogueComponent>.ExclusiveHandlerID => finishPreparerID;
111
+
112
+
113
+ /// <summary>
114
+ ///
115
+ /// </summary>
116
+ protected virtual void OnEnable() => DialogueEventSystem.StartListening("PostToTPFDFromDialogue", OnCameraSet);
117
+
118
+ /// <summary>
119
+ ///
120
+ /// </summary>
121
+ protected virtual void OnDisable() => DialogueEventSystem.StopListening("PostToTPFDFromDialogue", OnCameraSet);
122
+
123
+ /// <summary>
124
+ ///
125
+ /// </summary>
126
+ /// <param name="o"></param>
127
+ protected virtual void OnCameraSet(object o = null) => SetOGLookToMainCamera();
128
+
129
+ /// <summary>
130
+ ///
131
+ /// </summary>
132
+ protected virtual void SetOGLookToMainCamera()
133
+ => originalCameraLookRotation = GameObject.FindWithTag(mainCameraTag).transform.rotation;
134
+
135
+ /// <summary>
136
+ ///
137
+ /// </summary>
138
+ protected virtual void DisableSkipOGCameraLook() => skipOGCamLook = false;
139
+
140
+ /// <summary>
141
+ ///
142
+ /// </summary>
143
+ protected virtual void ReturnToOriginalPosition()
144
+ {
145
+ if (!skipOGCamLook)
146
+ #if DOTWEEN
147
+ GameObject.FindWithTag(mainCameraTag).transform.DORotateQuaternion(originalCameraLookRotation, lookAtPlayerTime);
148
+ #else
149
+ GameObject.FindWithTag(mainCameraTag).transform.Rotate(originalCameraLookRotation.eulerAngles);
150
+ #endif
151
+ else
152
+ DisableSkipOGCameraLook();
153
+ }
154
+
155
+ /// <summary>
156
+ ///
157
+ /// </summary>
158
+ protected virtual void CheckSkippingOGCam()
159
+ {
160
+ if (skipOGCamLook)
161
+ DisableSkipOGCameraLook();
162
+ }
163
+
164
+ /// <summary>
165
+ ///
166
+ /// </summary>
167
+ /// <returns></returns>
168
+ protected virtual IEnumerator LookAtSelectedObjectProcess()
169
+ {
170
+ Talkable selectedObject = ServiceLocator.GetService<DialogueObjectManager>().GetStartObject() as Talkable;
171
+
172
+ PrepareCameraPositionsForDialogueStart();
173
+
174
+ if (!inTPFD.Value)
175
+ LookAtHead(selectedObject);
176
+
177
+ if (!isLoadingFile.Value)
178
+ yield return new WaitForSeconds(lookAtPlayerTime);
179
+
180
+ yield break;
181
+ }
182
+
183
+ /// <summary>
184
+ ///
185
+ /// </summary>
186
+ protected virtual void PrepareCameraPositionsForDialogueStart()
187
+ {
188
+ if (isLoadingFile.Value)
189
+ EnableSkipOGCameraLook();
190
+ else
191
+ DialogueEventSystem.TriggerEvent(dialogueCameraToMainEventString);
192
+
193
+ SetOGLookToMainCamera();
194
+ }
195
+
196
+ /// <summary>
197
+ ///
198
+ /// </summary>
199
+ protected virtual void EnableSkipOGCameraLook() => skipOGCamLook = true;
200
+
201
+ /// <summary>
202
+ ///
203
+ /// </summary>
204
+ /// <param name="talkable"></param>
205
+ protected virtual void LookAtHead(Talkable talkable)
206
+ {
207
+ if (talkable == null)
208
+ return;
209
+
210
+ if (!talkable.head)
211
+ UnityEngine.Debug.LogWarning("ALERT: " + talkable.gameObject.name + " doesn't have a head initialized.");
212
+ else
213
+ #if DOTWEEN
214
+ GameObject.FindWithTag(mainCameraTag).transform.DOLookAt(talkable.head.position, lookAtPlayerTime);
215
+ #else
216
+ GameObject.FindWithTag(mainCameraTag).transform.LookAt(talkable.head.position);
217
+ #endif
218
+ }
219
+
220
+
221
+ /// <inheritdoc/>
222
+ public virtual bool UseRoutineToPrepare() => true;
223
+
224
+ /// <inheritdoc/>
225
+ public virtual void Prepare() => StartCoroutine(PrepareRoutine());
226
+
227
+ /// <inheritdoc/>
228
+ public virtual IEnumerator PrepareRoutine() => LookAtSelectedObjectProcess();
229
+
230
+
231
+ /// <inheritdoc/>
232
+ public virtual bool UseRoutineToResolve() => false;
233
+
234
+ /// <inheritdoc/>
235
+ public virtual void Resolve() => ReturnToOriginalPosition();
236
+
237
+ /// <inheritdoc/>
238
+ public virtual IEnumerator ResolveRoutine()
239
+ {
240
+ Resolve();
241
+
242
+ yield break;
243
+ }
244
+
245
+
246
+ /// <inheritdoc/>
247
+ public virtual void OnFinishDialogue() => CheckSkippingOGCam();
248
+
249
+
250
+ /// <inheritdoc/>
251
+ public virtual void ToTitleScreen() => DisableSkipOGCameraLook();
252
+ }
253
253
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 3b8f413b18872e648a74a6bf8378b84c
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: 3b8f413b18872e648a74a6bf8378b84c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/MoveData.cs CHANGED
@@ -1,49 +1,49 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using System;
3
- using UnityEngine;
4
-
5
- namespace DREditor.Talkables
6
- {
7
- /// <summary>
8
- ///
9
- /// </summary>
10
- [Serializable]
11
- public class MoveData
12
- {
13
- /// <summary>
14
- ///
15
- /// </summary>
16
- [Tooltip("")]
17
- public string name;
18
-
19
- /// <summary>
20
- ///
21
- /// </summary>
22
- [Tooltip("")]
23
- public Vector3 position;
24
-
25
- /// <summary>
26
- ///
27
- /// </summary>
28
- [Tooltip("")]
29
- public Vector3 rotation;
30
-
31
-
32
- public MoveData() { }
33
-
34
- public MoveData(string name, Vector3 position, Vector3 rotation)
35
- {
36
- this.name = name;
37
-
38
- this.position = position;
39
-
40
- this.rotation = rotation;
41
- }
42
-
43
- /// <summary>
44
- ///
45
- /// </summary>
46
- /// <returns></returns>
47
- public virtual object Clone() => MemberwiseClone();
48
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System;
3
+ using UnityEngine;
4
+
5
+ namespace DREditor.Talkables
6
+ {
7
+ /// <summary>
8
+ ///
9
+ /// </summary>
10
+ [Serializable]
11
+ public class MoveData
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [Tooltip("")]
17
+ public string name;
18
+
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ [Tooltip("")]
23
+ public Vector3 position;
24
+
25
+ /// <summary>
26
+ ///
27
+ /// </summary>
28
+ [Tooltip("")]
29
+ public Vector3 rotation;
30
+
31
+
32
+ public MoveData() { }
33
+
34
+ public MoveData(string name, Vector3 position, Vector3 rotation)
35
+ {
36
+ this.name = name;
37
+
38
+ this.position = position;
39
+
40
+ this.rotation = rotation;
41
+ }
42
+
43
+ /// <summary>
44
+ ///
45
+ /// </summary>
46
+ /// <returns></returns>
47
+ public virtual object Clone() => MemberwiseClone();
48
+ }
49
49
  }
package/MoveData.cs.meta CHANGED
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: f43a0d8079584e940bf8e0c25a9401b1
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: f43a0d8079584e940bf8e0c25a9401b1
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: