net.dreditor.subareas 0.1.6 → 0.1.8
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/DREditor.SubAreas.asmdef +23 -23
- package/DREditor.SubAreas.asmdef.meta +7 -7
- package/ISubArea.cs +24 -24
- package/ISubArea.cs.meta +11 -11
- package/{Samples → Samples~}/InSubAreaActivation.asset +21 -21
- package/{Samples → Samples~}/InSubAreaActivation.asset.meta +8 -8
- package/{Samples → Samples~}/Sub_Area_Manager_Template.prefab +426 -426
- package/{Samples → Samples~}/Sub_Area_Manager_Template.prefab.meta +7 -7
- package/SubAreaActivationHandler.cs +182 -182
- package/SubAreaActivationHandler.cs.meta +11 -11
- package/SubAreaActivator.cs +389 -389
- package/SubAreaActivator.cs.meta +31 -31
- package/SubAreaData.cs +270 -270
- package/SubAreaData.cs.meta +11 -11
- package/SubAreaDeactivator.cs +349 -349
- package/SubAreaDeactivator.cs.meta +24 -24
- package/SubAreaManager.cs +190 -190
- package/SubAreaManager.cs.meta +19 -19
- package/SubAreaManagerBase.cs +109 -109
- package/SubAreaManagerBase.cs.meta +11 -11
- package/package.json +46 -41
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/SubAreaActivator.cs
CHANGED
|
@@ -1,390 +1,390 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Cameras;
|
|
3
|
-
using DREditor.Dialogues;
|
|
4
|
-
using DREditor.Dialogues.Loading;
|
|
5
|
-
using DREditor.EventObjects;
|
|
6
|
-
using DREditor.Fading;
|
|
7
|
-
using DREditor.Services;
|
|
8
|
-
using DREditor.TwoPointFiveD;
|
|
9
|
-
using System.Collections;
|
|
10
|
-
using UnityEngine;
|
|
11
|
-
|
|
12
|
-
namespace DREditor.SubAreas
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
[RequireComponent(typeof(SceneEventListener))]
|
|
18
|
-
[ClassHeader(nameof(SubAreaActivationHandler) + ", " + nameof(IDialogueHolder) + ", " + nameof(ISceneEventListener) +
|
|
19
|
-
"\n\n")]
|
|
20
|
-
public class SubAreaActivator : SubAreaActivationHandler, IDialogueHolder, ISceneEventListener
|
|
21
|
-
{
|
|
22
|
-
/// <summary>
|
|
23
|
-
///
|
|
24
|
-
/// </summary>
|
|
25
|
-
[Tooltip("")]
|
|
26
|
-
[SerializeField] protected float fadeTime = 0.3f;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/// <summary>
|
|
30
|
-
///
|
|
31
|
-
/// </summary>
|
|
32
|
-
[Header("")]
|
|
33
|
-
[Divider]
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected SubAreaActivationHandler deactivator;
|
|
36
|
-
|
|
37
|
-
/// <summary>
|
|
38
|
-
///
|
|
39
|
-
/// </summary>
|
|
40
|
-
[Tooltip("")]
|
|
41
|
-
[SerializeField] protected SelectableObject focusedActor = null;
|
|
42
|
-
|
|
43
|
-
/// <summary>
|
|
44
|
-
///
|
|
45
|
-
/// </summary>
|
|
46
|
-
[Tooltip("")]
|
|
47
|
-
[SerializeField] protected Dialogue startDialogue = null;
|
|
48
|
-
|
|
49
|
-
/// <summary>
|
|
50
|
-
///
|
|
51
|
-
/// </summary>
|
|
52
|
-
[Tooltip("")]
|
|
53
|
-
[SerializeField] protected Dialogue autoStartDialogue = null;
|
|
54
|
-
|
|
55
|
-
/// <summary>
|
|
56
|
-
///
|
|
57
|
-
/// </summary>
|
|
58
|
-
[Tooltip("")]
|
|
59
|
-
[SerializeField] protected GameObject cameraArrowsPrefab = null;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/// <summary>
|
|
63
|
-
///
|
|
64
|
-
/// </summary>
|
|
65
|
-
[Header("")]
|
|
66
|
-
[Divider]
|
|
67
|
-
[Tooltip("")]
|
|
68
|
-
[SerializeField] protected BoolWithEvent reticleCanSelect = null;
|
|
69
|
-
|
|
70
|
-
/// <summary>
|
|
71
|
-
///
|
|
72
|
-
/// </summary>
|
|
73
|
-
[Tooltip("")]
|
|
74
|
-
[SerializeField] protected BoolWithEvent inSubAreaActivation = null;
|
|
75
|
-
|
|
76
|
-
/// <summary>
|
|
77
|
-
///
|
|
78
|
-
/// </summary>
|
|
79
|
-
[Tooltip("")]
|
|
80
|
-
[SerializeField] protected SceneEvent OnSAMActivate = null;
|
|
81
|
-
|
|
82
|
-
/// <summary>
|
|
83
|
-
///
|
|
84
|
-
/// </summary>
|
|
85
|
-
[Tooltip("")]
|
|
86
|
-
[SerializeField] protected SceneEvent OnSAMAutoStartDialogue = null;
|
|
87
|
-
|
|
88
|
-
/// <summary>
|
|
89
|
-
///
|
|
90
|
-
/// </summary>
|
|
91
|
-
[Tooltip("")]
|
|
92
|
-
[SerializeField] protected SceneEvent onFadingOutOfLoading = null;
|
|
93
|
-
|
|
94
|
-
/// <summary>
|
|
95
|
-
///
|
|
96
|
-
/// </summary>
|
|
97
|
-
[Tooltip("")]
|
|
98
|
-
[SerializeField] protected SceneEventListener onFinishedRoomTransitions = null;
|
|
99
|
-
|
|
100
|
-
/// <summary>
|
|
101
|
-
///
|
|
102
|
-
/// </summary>
|
|
103
|
-
[Tooltip("")]
|
|
104
|
-
[SerializeField] protected SubAreaData Data;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/// <summary>
|
|
108
|
-
///
|
|
109
|
-
/// </summary>
|
|
110
|
-
protected GameObject cameraArrowsRef;
|
|
111
|
-
|
|
112
|
-
/// <summary>
|
|
113
|
-
///
|
|
114
|
-
/// </summary>
|
|
115
|
-
protected bool cachedLoadingSave;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/// <summary>
|
|
119
|
-
///
|
|
120
|
-
/// </summary>
|
|
121
|
-
protected virtual void OnEnable()
|
|
122
|
-
{
|
|
123
|
-
if (deactivator != null)
|
|
124
|
-
deactivator.OnHandlerFinished += DestroyCameraArrows;
|
|
125
|
-
|
|
126
|
-
onFinishedRoomTransitions.Response.AddListener(CheckLoad);
|
|
127
|
-
|
|
128
|
-
cachedLoadingSave = isLoadingFile.Value;
|
|
129
|
-
|
|
130
|
-
onFadingOutOfLoading.RegisterListener(this);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/// <summary>
|
|
134
|
-
///
|
|
135
|
-
/// </summary>
|
|
136
|
-
protected virtual void OnDisable()
|
|
137
|
-
{
|
|
138
|
-
if (deactivator != null)
|
|
139
|
-
deactivator.OnHandlerFinished -= DestroyCameraArrows;
|
|
140
|
-
|
|
141
|
-
onFinishedRoomTransitions.Response.RemoveListener(CheckLoad);
|
|
142
|
-
|
|
143
|
-
if (Data != null && Data.isWaiting)
|
|
144
|
-
UnsubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
145
|
-
|
|
146
|
-
if (Data != null && Data.isWaitingAuto)
|
|
147
|
-
UnsubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
148
|
-
|
|
149
|
-
onFadingOutOfLoading.UnregisterListener(this);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/// <summary>
|
|
153
|
-
///
|
|
154
|
-
/// </summary>
|
|
155
|
-
protected virtual void CheckLoad()
|
|
156
|
-
{
|
|
157
|
-
if (Data.isWaiting || Data.isWaitingAuto)
|
|
158
|
-
inSubAreaActivation.SetValue(true);
|
|
159
|
-
|
|
160
|
-
if (Data.isWaiting)
|
|
161
|
-
SubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
162
|
-
|
|
163
|
-
if (Data.isWaitingAuto)
|
|
164
|
-
{
|
|
165
|
-
UnityEngine.Debug.Log(ToString() + ": Is Waiting Auto Was True");
|
|
166
|
-
|
|
167
|
-
SubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
168
|
-
|
|
169
|
-
Activate();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/// <inheritdoc/>
|
|
175
|
-
public override void Initialize(object subAreaData) => Data = (SubAreaData)subAreaData;
|
|
176
|
-
|
|
177
|
-
/// <inheritdoc/>
|
|
178
|
-
public override void BeginActivationState()
|
|
179
|
-
{
|
|
180
|
-
inSubAreaActivation.SetValue(true);
|
|
181
|
-
|
|
182
|
-
if (startDialogue != null && !Data.finishedStart)
|
|
183
|
-
{
|
|
184
|
-
TurnOffDisplayedObjectName();
|
|
185
|
-
|
|
186
|
-
dialogueManager.StartDialogue(focusedActor, startDialogue);
|
|
187
|
-
|
|
188
|
-
Data.SetIsWaiting(true);
|
|
189
|
-
|
|
190
|
-
SubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
191
|
-
|
|
192
|
-
UnityEngine.Debug.Log("Start Dialogue and Data hasn't finished start");
|
|
193
|
-
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
else
|
|
197
|
-
{
|
|
198
|
-
UnityEngine.Debug.Log("Activation else");
|
|
199
|
-
|
|
200
|
-
Activate();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/// <summary>
|
|
205
|
-
///
|
|
206
|
-
/// </summary>
|
|
207
|
-
protected virtual void ActivateSubAreaOnDialogueEnd()
|
|
208
|
-
{
|
|
209
|
-
UnsubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
210
|
-
|
|
211
|
-
//RaycastReticle.Instance.FadeOut();
|
|
212
|
-
if (autoStartDialogue && !Data.finishedAuto)
|
|
213
|
-
{
|
|
214
|
-
//RaycastReticle.Instance.FadeOut();
|
|
215
|
-
OnSAMAutoStartDialogue.Raise();
|
|
216
|
-
|
|
217
|
-
inDialogue.Value = true;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
Data.FinishedStart();
|
|
221
|
-
|
|
222
|
-
Activate();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/// <summary>
|
|
226
|
-
///
|
|
227
|
-
/// </summary>
|
|
228
|
-
protected virtual void Activate()
|
|
229
|
-
{
|
|
230
|
-
bool loadingIsWaitingAuto = Data.isWaitingAuto;
|
|
231
|
-
|
|
232
|
-
if (!isLoadingFile.Value)
|
|
233
|
-
Data.SetReturnValues(mainCamera);
|
|
234
|
-
|
|
235
|
-
subAreaCollider.enabled = false;
|
|
236
|
-
|
|
237
|
-
OnSAMActivate.Raise();
|
|
238
|
-
|
|
239
|
-
TurnOffDisplayedObjectName();
|
|
240
|
-
|
|
241
|
-
hasMenuAccess.SetValue(false);
|
|
242
|
-
|
|
243
|
-
playerSystem.EnableBehaviours(false);
|
|
244
|
-
|
|
245
|
-
playerSystem.enabled = false;
|
|
246
|
-
|
|
247
|
-
if (AlreadyInTPFD())
|
|
248
|
-
GetTPFDDoors().ForEach(door => door.RemoveDoorControl());
|
|
249
|
-
|
|
250
|
-
if (loadingIsWaitingAuto)
|
|
251
|
-
StartCoroutine(SaveLoadActivation());
|
|
252
|
-
else
|
|
253
|
-
StartCoroutine(Activation());
|
|
254
|
-
|
|
255
|
-
if (!AlreadyInTPFD())
|
|
256
|
-
{
|
|
257
|
-
cameraArrowsRef = Instantiate(cameraArrowsPrefab);
|
|
258
|
-
|
|
259
|
-
tpfdManager.InitializeTPFD();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/// <summary>
|
|
264
|
-
///
|
|
265
|
-
/// </summary>
|
|
266
|
-
protected virtual IEnumerator SaveLoadActivation()
|
|
267
|
-
{
|
|
268
|
-
yield return new WaitUntil(() => !isLoadingFile.Value);
|
|
269
|
-
|
|
270
|
-
yield return MoveToSubAreaPosition();
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/// <summary>
|
|
274
|
-
///
|
|
275
|
-
/// </summary>
|
|
276
|
-
protected virtual IEnumerator Activation()
|
|
277
|
-
{
|
|
278
|
-
if (startDialogue && autoStartDialogue && !Data.finishedAuto)
|
|
279
|
-
yield return new WaitUntil(() => hasMenuAccess.Value == false);
|
|
280
|
-
|
|
281
|
-
hasMenuAccess.SetValue(false);
|
|
282
|
-
|
|
283
|
-
if (AlreadyInTPFD() && !ServiceLocator.GetService<GlobalFade>().IsDark)
|
|
284
|
-
yield return ServiceLocator.GetService<GlobalFade>().FadeToRoutine(fadeTime);
|
|
285
|
-
|
|
286
|
-
yield return MoveToSubAreaPosition();
|
|
287
|
-
|
|
288
|
-
if (AlreadyInTPFD() && ServiceLocator.GetService<GlobalFade>().IsDark && !cachedLoadingSave)
|
|
289
|
-
yield return ServiceLocator.GetService<GlobalFade>().FadeOutRoutine(fadeTime);
|
|
290
|
-
|
|
291
|
-
EndOfActivationHandler();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/// <inheritdoc/>
|
|
295
|
-
public override void EndOfActivationHandler()
|
|
296
|
-
{
|
|
297
|
-
if (autoStartDialogue && !Data.isWaitingAuto && !Data.finishedAuto)
|
|
298
|
-
{
|
|
299
|
-
dialogueManager.StartDialogue(focusedActor, autoStartDialogue);
|
|
300
|
-
|
|
301
|
-
Data.SetIsWaitingAuto(true);
|
|
302
|
-
|
|
303
|
-
SubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
304
|
-
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (autoStartDialogue && Data.isWaitingAuto)
|
|
309
|
-
{
|
|
310
|
-
UnsubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
311
|
-
|
|
312
|
-
Data.FinishedAuto();
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
inTPFD.Value = true;
|
|
316
|
-
|
|
317
|
-
playerSystem.TPFDScript.enabled = true;
|
|
318
|
-
|
|
319
|
-
((PnCCamera)playerSystem.TPFDScript).Controllable = true;
|
|
320
|
-
|
|
321
|
-
playerSystem.RaycastScript.enabled = true;
|
|
322
|
-
|
|
323
|
-
if (!reticleCanSelect.Value)
|
|
324
|
-
reticleCanSelect.SetValue(true);
|
|
325
|
-
|
|
326
|
-
objectGroup.EnableItems(true);
|
|
327
|
-
|
|
328
|
-
hasMenuAccess.SetValue(true);
|
|
329
|
-
|
|
330
|
-
Data.SetActivated(true);
|
|
331
|
-
|
|
332
|
-
FinishHandler();
|
|
333
|
-
|
|
334
|
-
deactivator.BeginActivationState();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
/// <summary>
|
|
339
|
-
///
|
|
340
|
-
/// </summary>
|
|
341
|
-
protected virtual IEnumerator MoveToSubAreaPosition()
|
|
342
|
-
{
|
|
343
|
-
PnCCamera pnc = (PnCCamera)playerSystem.TPFDScript;
|
|
344
|
-
|
|
345
|
-
pnc.ClearPosition();
|
|
346
|
-
|
|
347
|
-
if (AlreadyInTPFD())
|
|
348
|
-
{
|
|
349
|
-
foreach (TPFDManager manager in managers)
|
|
350
|
-
manager.enabled = false;
|
|
351
|
-
|
|
352
|
-
tpfdManager.enabled = true;
|
|
353
|
-
|
|
354
|
-
tpfdManager.SetPnCCamera();
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
float duration = isLoadingFile.Value || AlreadyInTPFD() ? 0 : panToBodyTime;
|
|
358
|
-
|
|
359
|
-
yield return MoveCameraToPosition(pnc.GetCalculatedPosition(true), Vector3.zero, duration);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
/// <summary>
|
|
364
|
-
///
|
|
365
|
-
/// </summary>
|
|
366
|
-
protected virtual void DestroyCameraArrows()
|
|
367
|
-
{
|
|
368
|
-
if (!AlreadyInTPFD())
|
|
369
|
-
Destroy(cameraArrowsRef);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
/// <inheritdoc/>
|
|
374
|
-
public virtual bool CheckIfSaveDialogue()
|
|
375
|
-
=> ServiceLocator.GetService<IDialogueManager>()
|
|
376
|
-
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
377
|
-
.CheckDialogue<Line>(startDialogue)
|
|
378
|
-
||
|
|
379
|
-
ServiceLocator.GetService<IDialogueManager>()
|
|
380
|
-
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
381
|
-
.CheckDialogue<Line>(autoStartDialogue);
|
|
382
|
-
|
|
383
|
-
/// <inheritdoc/>
|
|
384
|
-
public virtual void OnEventRaised()
|
|
385
|
-
{
|
|
386
|
-
if (cachedLoadingSave)
|
|
387
|
-
cachedLoadingSave = false;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Cameras;
|
|
3
|
+
using DREditor.Dialogues;
|
|
4
|
+
using DREditor.Dialogues.Loading;
|
|
5
|
+
using DREditor.EventObjects;
|
|
6
|
+
using DREditor.Fading;
|
|
7
|
+
using DREditor.Services;
|
|
8
|
+
using DREditor.TwoPointFiveD;
|
|
9
|
+
using System.Collections;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
|
|
12
|
+
namespace DREditor.SubAreas
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[RequireComponent(typeof(SceneEventListener))]
|
|
18
|
+
[ClassHeader(nameof(SubAreaActivationHandler) + ", " + nameof(IDialogueHolder) + ", " + nameof(ISceneEventListener) +
|
|
19
|
+
"\n\n")]
|
|
20
|
+
public class SubAreaActivator : SubAreaActivationHandler, IDialogueHolder, ISceneEventListener
|
|
21
|
+
{
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected float fadeTime = 0.3f;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Header("")]
|
|
33
|
+
[Divider]
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected SubAreaActivationHandler deactivator;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected SelectableObject focusedActor = null;
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
[Tooltip("")]
|
|
47
|
+
[SerializeField] protected Dialogue startDialogue = null;
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
[Tooltip("")]
|
|
53
|
+
[SerializeField] protected Dialogue autoStartDialogue = null;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[Tooltip("")]
|
|
59
|
+
[SerializeField] protected GameObject cameraArrowsPrefab = null;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
[Header("")]
|
|
66
|
+
[Divider]
|
|
67
|
+
[Tooltip("")]
|
|
68
|
+
[SerializeField] protected BoolWithEvent reticleCanSelect = null;
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
///
|
|
72
|
+
/// </summary>
|
|
73
|
+
[Tooltip("")]
|
|
74
|
+
[SerializeField] protected BoolWithEvent inSubAreaActivation = null;
|
|
75
|
+
|
|
76
|
+
/// <summary>
|
|
77
|
+
///
|
|
78
|
+
/// </summary>
|
|
79
|
+
[Tooltip("")]
|
|
80
|
+
[SerializeField] protected SceneEvent OnSAMActivate = null;
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
///
|
|
84
|
+
/// </summary>
|
|
85
|
+
[Tooltip("")]
|
|
86
|
+
[SerializeField] protected SceneEvent OnSAMAutoStartDialogue = null;
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
///
|
|
90
|
+
/// </summary>
|
|
91
|
+
[Tooltip("")]
|
|
92
|
+
[SerializeField] protected SceneEvent onFadingOutOfLoading = null;
|
|
93
|
+
|
|
94
|
+
/// <summary>
|
|
95
|
+
///
|
|
96
|
+
/// </summary>
|
|
97
|
+
[Tooltip("")]
|
|
98
|
+
[SerializeField] protected SceneEventListener onFinishedRoomTransitions = null;
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
[Tooltip("")]
|
|
104
|
+
[SerializeField] protected SubAreaData Data;
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
///
|
|
109
|
+
/// </summary>
|
|
110
|
+
protected GameObject cameraArrowsRef;
|
|
111
|
+
|
|
112
|
+
/// <summary>
|
|
113
|
+
///
|
|
114
|
+
/// </summary>
|
|
115
|
+
protected bool cachedLoadingSave;
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
///
|
|
120
|
+
/// </summary>
|
|
121
|
+
protected virtual void OnEnable()
|
|
122
|
+
{
|
|
123
|
+
if (deactivator != null)
|
|
124
|
+
deactivator.OnHandlerFinished += DestroyCameraArrows;
|
|
125
|
+
|
|
126
|
+
onFinishedRoomTransitions.Response.AddListener(CheckLoad);
|
|
127
|
+
|
|
128
|
+
cachedLoadingSave = isLoadingFile.Value;
|
|
129
|
+
|
|
130
|
+
onFadingOutOfLoading.RegisterListener(this);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// <summary>
|
|
134
|
+
///
|
|
135
|
+
/// </summary>
|
|
136
|
+
protected virtual void OnDisable()
|
|
137
|
+
{
|
|
138
|
+
if (deactivator != null)
|
|
139
|
+
deactivator.OnHandlerFinished -= DestroyCameraArrows;
|
|
140
|
+
|
|
141
|
+
onFinishedRoomTransitions.Response.RemoveListener(CheckLoad);
|
|
142
|
+
|
|
143
|
+
if (Data != null && Data.isWaiting)
|
|
144
|
+
UnsubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
145
|
+
|
|
146
|
+
if (Data != null && Data.isWaitingAuto)
|
|
147
|
+
UnsubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
148
|
+
|
|
149
|
+
onFadingOutOfLoading.UnregisterListener(this);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
///
|
|
154
|
+
/// </summary>
|
|
155
|
+
protected virtual void CheckLoad()
|
|
156
|
+
{
|
|
157
|
+
if (Data.isWaiting || Data.isWaitingAuto)
|
|
158
|
+
inSubAreaActivation.SetValue(true);
|
|
159
|
+
|
|
160
|
+
if (Data.isWaiting)
|
|
161
|
+
SubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
162
|
+
|
|
163
|
+
if (Data.isWaitingAuto)
|
|
164
|
+
{
|
|
165
|
+
UnityEngine.Debug.Log(ToString() + ": Is Waiting Auto Was True");
|
|
166
|
+
|
|
167
|
+
SubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
168
|
+
|
|
169
|
+
Activate();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/// <inheritdoc/>
|
|
175
|
+
public override void Initialize(object subAreaData) => Data = (SubAreaData)subAreaData;
|
|
176
|
+
|
|
177
|
+
/// <inheritdoc/>
|
|
178
|
+
public override void BeginActivationState()
|
|
179
|
+
{
|
|
180
|
+
inSubAreaActivation.SetValue(true);
|
|
181
|
+
|
|
182
|
+
if (startDialogue != null && !Data.finishedStart)
|
|
183
|
+
{
|
|
184
|
+
TurnOffDisplayedObjectName();
|
|
185
|
+
|
|
186
|
+
dialogueManager.StartDialogue(focusedActor, startDialogue);
|
|
187
|
+
|
|
188
|
+
Data.SetIsWaiting(true);
|
|
189
|
+
|
|
190
|
+
SubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
191
|
+
|
|
192
|
+
UnityEngine.Debug.Log("Start Dialogue and Data hasn't finished start");
|
|
193
|
+
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
{
|
|
198
|
+
UnityEngine.Debug.Log("Activation else");
|
|
199
|
+
|
|
200
|
+
Activate();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/// <summary>
|
|
205
|
+
///
|
|
206
|
+
/// </summary>
|
|
207
|
+
protected virtual void ActivateSubAreaOnDialogueEnd()
|
|
208
|
+
{
|
|
209
|
+
UnsubscribeEndDialogueEvent(ActivateSubAreaOnDialogueEnd);
|
|
210
|
+
|
|
211
|
+
//RaycastReticle.Instance.FadeOut();
|
|
212
|
+
if (autoStartDialogue && !Data.finishedAuto)
|
|
213
|
+
{
|
|
214
|
+
//RaycastReticle.Instance.FadeOut();
|
|
215
|
+
OnSAMAutoStartDialogue.Raise();
|
|
216
|
+
|
|
217
|
+
inDialogue.Value = true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
Data.FinishedStart();
|
|
221
|
+
|
|
222
|
+
Activate();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// <summary>
|
|
226
|
+
///
|
|
227
|
+
/// </summary>
|
|
228
|
+
protected virtual void Activate()
|
|
229
|
+
{
|
|
230
|
+
bool loadingIsWaitingAuto = Data.isWaitingAuto;
|
|
231
|
+
|
|
232
|
+
if (!isLoadingFile.Value)
|
|
233
|
+
Data.SetReturnValues(mainCamera);
|
|
234
|
+
|
|
235
|
+
subAreaCollider.enabled = false;
|
|
236
|
+
|
|
237
|
+
OnSAMActivate.Raise();
|
|
238
|
+
|
|
239
|
+
TurnOffDisplayedObjectName();
|
|
240
|
+
|
|
241
|
+
hasMenuAccess.SetValue(false);
|
|
242
|
+
|
|
243
|
+
playerSystem.EnableBehaviours(false);
|
|
244
|
+
|
|
245
|
+
playerSystem.enabled = false;
|
|
246
|
+
|
|
247
|
+
if (AlreadyInTPFD())
|
|
248
|
+
GetTPFDDoors().ForEach(door => door.RemoveDoorControl());
|
|
249
|
+
|
|
250
|
+
if (loadingIsWaitingAuto)
|
|
251
|
+
StartCoroutine(SaveLoadActivation());
|
|
252
|
+
else
|
|
253
|
+
StartCoroutine(Activation());
|
|
254
|
+
|
|
255
|
+
if (!AlreadyInTPFD())
|
|
256
|
+
{
|
|
257
|
+
cameraArrowsRef = Instantiate(cameraArrowsPrefab);
|
|
258
|
+
|
|
259
|
+
tpfdManager.InitializeTPFD();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// <summary>
|
|
264
|
+
///
|
|
265
|
+
/// </summary>
|
|
266
|
+
protected virtual IEnumerator SaveLoadActivation()
|
|
267
|
+
{
|
|
268
|
+
yield return new WaitUntil(() => !isLoadingFile.Value);
|
|
269
|
+
|
|
270
|
+
yield return MoveToSubAreaPosition();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/// <summary>
|
|
274
|
+
///
|
|
275
|
+
/// </summary>
|
|
276
|
+
protected virtual IEnumerator Activation()
|
|
277
|
+
{
|
|
278
|
+
if (startDialogue && autoStartDialogue && !Data.finishedAuto)
|
|
279
|
+
yield return new WaitUntil(() => hasMenuAccess.Value == false);
|
|
280
|
+
|
|
281
|
+
hasMenuAccess.SetValue(false);
|
|
282
|
+
|
|
283
|
+
if (AlreadyInTPFD() && !ServiceLocator.GetService<GlobalFade>().IsDark)
|
|
284
|
+
yield return ServiceLocator.GetService<GlobalFade>().FadeToRoutine(fadeTime);
|
|
285
|
+
|
|
286
|
+
yield return MoveToSubAreaPosition();
|
|
287
|
+
|
|
288
|
+
if (AlreadyInTPFD() && ServiceLocator.GetService<GlobalFade>().IsDark && !cachedLoadingSave)
|
|
289
|
+
yield return ServiceLocator.GetService<GlobalFade>().FadeOutRoutine(fadeTime);
|
|
290
|
+
|
|
291
|
+
EndOfActivationHandler();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// <inheritdoc/>
|
|
295
|
+
public override void EndOfActivationHandler()
|
|
296
|
+
{
|
|
297
|
+
if (autoStartDialogue && !Data.isWaitingAuto && !Data.finishedAuto)
|
|
298
|
+
{
|
|
299
|
+
dialogueManager.StartDialogue(focusedActor, autoStartDialogue);
|
|
300
|
+
|
|
301
|
+
Data.SetIsWaitingAuto(true);
|
|
302
|
+
|
|
303
|
+
SubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
304
|
+
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (autoStartDialogue && Data.isWaitingAuto)
|
|
309
|
+
{
|
|
310
|
+
UnsubscribeEndDialogueEvent(EndOfActivationHandler);
|
|
311
|
+
|
|
312
|
+
Data.FinishedAuto();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
inTPFD.Value = true;
|
|
316
|
+
|
|
317
|
+
playerSystem.TPFDScript.enabled = true;
|
|
318
|
+
|
|
319
|
+
((PnCCamera)playerSystem.TPFDScript).Controllable = true;
|
|
320
|
+
|
|
321
|
+
playerSystem.RaycastScript.enabled = true;
|
|
322
|
+
|
|
323
|
+
if (!reticleCanSelect.Value)
|
|
324
|
+
reticleCanSelect.SetValue(true);
|
|
325
|
+
|
|
326
|
+
objectGroup.EnableItems(true);
|
|
327
|
+
|
|
328
|
+
hasMenuAccess.SetValue(true);
|
|
329
|
+
|
|
330
|
+
Data.SetActivated(true);
|
|
331
|
+
|
|
332
|
+
FinishHandler();
|
|
333
|
+
|
|
334
|
+
deactivator.BeginActivationState();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
/// <summary>
|
|
339
|
+
///
|
|
340
|
+
/// </summary>
|
|
341
|
+
protected virtual IEnumerator MoveToSubAreaPosition()
|
|
342
|
+
{
|
|
343
|
+
PnCCamera pnc = (PnCCamera)playerSystem.TPFDScript;
|
|
344
|
+
|
|
345
|
+
pnc.ClearPosition();
|
|
346
|
+
|
|
347
|
+
if (AlreadyInTPFD())
|
|
348
|
+
{
|
|
349
|
+
foreach (TPFDManager manager in managers)
|
|
350
|
+
manager.enabled = false;
|
|
351
|
+
|
|
352
|
+
tpfdManager.enabled = true;
|
|
353
|
+
|
|
354
|
+
tpfdManager.SetPnCCamera();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
float duration = isLoadingFile.Value || AlreadyInTPFD() ? 0 : panToBodyTime;
|
|
358
|
+
|
|
359
|
+
yield return MoveCameraToPosition(pnc.GetCalculatedPosition(true), Vector3.zero, duration);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
/// <summary>
|
|
364
|
+
///
|
|
365
|
+
/// </summary>
|
|
366
|
+
protected virtual void DestroyCameraArrows()
|
|
367
|
+
{
|
|
368
|
+
if (!AlreadyInTPFD())
|
|
369
|
+
Destroy(cameraArrowsRef);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
/// <inheritdoc/>
|
|
374
|
+
public virtual bool CheckIfSaveDialogue()
|
|
375
|
+
=> ServiceLocator.GetService<IDialogueManager>()
|
|
376
|
+
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
377
|
+
.CheckDialogue<Line>(startDialogue)
|
|
378
|
+
||
|
|
379
|
+
ServiceLocator.GetService<IDialogueManager>()
|
|
380
|
+
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
381
|
+
.CheckDialogue<Line>(autoStartDialogue);
|
|
382
|
+
|
|
383
|
+
/// <inheritdoc/>
|
|
384
|
+
public virtual void OnEventRaised()
|
|
385
|
+
{
|
|
386
|
+
if (cachedLoadingSave)
|
|
387
|
+
cachedLoadingSave = false;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
390
|
}
|