net.dreditor.dialogues.implementation 0.0.0-stage → 0.1.6

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.
Files changed (100) hide show
  1. package/DREditor.Dialogues.Implementation.asmdef +16 -0
  2. package/DREditor.Dialogues.Implementation.asmdef.meta +7 -0
  3. package/DialogueAssetDataClearer.cs +50 -0
  4. package/DialogueAssetDataClearer.cs.meta +11 -0
  5. package/DialogueAssetEndEventHandler.cs +58 -0
  6. package/DialogueAssetEndEventHandler.cs.meta +11 -0
  7. package/DialogueAssetEnder.cs +240 -0
  8. package/DialogueAssetEnder.cs.meta +11 -0
  9. package/DialogueAssetFinisher.cs +90 -0
  10. package/DialogueAssetFinisher.cs.meta +11 -0
  11. package/DialogueAssetFinisherBase.cs +83 -0
  12. package/DialogueAssetFinisherBase.cs.meta +11 -0
  13. package/DialogueAssetManager.cs +66 -0
  14. package/DialogueAssetManager.cs.meta +11 -0
  15. package/DialogueAssetReader.cs +378 -0
  16. package/DialogueAssetReader.cs.meta +11 -0
  17. package/DialogueAssetStarter.cs +255 -0
  18. package/DialogueAssetStarter.cs.meta +11 -0
  19. package/DialogueAssetStarterDebugger.cs +41 -0
  20. package/DialogueAssetStarterDebugger.cs.meta +11 -0
  21. package/DialogueAssetWaiter.cs +94 -0
  22. package/DialogueAssetWaiter.cs.meta +11 -0
  23. package/DialogueLineReader.cs +392 -0
  24. package/DialogueLineReader.cs.meta +11 -0
  25. package/DialogueManager.cs +84 -0
  26. package/DialogueManager.cs.meta +11 -0
  27. package/DialogueNameSaver.cs +46 -0
  28. package/DialogueNameSaver.cs.meta +11 -0
  29. package/FastForwardToLine.cs +103 -0
  30. package/FastForwardToLine.cs.meta +11 -0
  31. package/InstantDialogueEnder.cs +92 -0
  32. package/InstantDialogueEnder.cs.meta +11 -0
  33. package/InstantDialogueFinisher.cs +133 -0
  34. package/InstantDialogueFinisher.cs.meta +11 -0
  35. package/InstantDialogueStarter.cs +83 -0
  36. package/InstantDialogueStarter.cs.meta +11 -0
  37. package/NotLeavingOnDialogueFinish.cs +45 -0
  38. package/NotLeavingOnDialogueFinish.cs.meta +11 -0
  39. package/PreparableDialogueStarter.cs +89 -0
  40. package/PreparableDialogueStarter.cs.meta +11 -0
  41. package/Samples/Dialogue_Asset_End_Event_Handler.prefab +685 -0
  42. package/Samples/Dialogue_Asset_End_Event_Handler.prefab.meta +7 -0
  43. package/Samples/Dialogue_Asset_Ender.prefab +858 -0
  44. package/Samples/Dialogue_Asset_Ender.prefab.meta +7 -0
  45. package/Samples/Dialogue_Asset_Finisher.prefab +301 -0
  46. package/Samples/Dialogue_Asset_Finisher.prefab.meta +7 -0
  47. package/Samples/Dialogue_Asset_Load_Identifier.prefab +48 -0
  48. package/Samples/Dialogue_Asset_Load_Identifier.prefab.meta +7 -0
  49. package/Samples/Dialogue_Asset_Loader.prefab +231 -0
  50. package/Samples/Dialogue_Asset_Loader.prefab.meta +7 -0
  51. package/Samples/Dialogue_Asset_Reader_DRE.prefab +511 -0
  52. package/Samples/Dialogue_Asset_Reader_DRE.prefab.meta +7 -0
  53. package/Samples/Dialogue_Asset_Reader_Shell.prefab +252 -0
  54. package/Samples/Dialogue_Asset_Reader_Shell.prefab.meta +7 -0
  55. package/Samples/Dialogue_Asset_Reader_Template.prefab +193 -0
  56. package/Samples/Dialogue_Asset_Reader_Template.prefab.meta +7 -0
  57. package/Samples/Dialogue_Asset_Starter.prefab +613 -0
  58. package/Samples/Dialogue_Asset_Starter.prefab.meta +7 -0
  59. package/Samples/Dialogue_Asset_Waiter.prefab +50 -0
  60. package/Samples/Dialogue_Asset_Waiter.prefab.meta +7 -0
  61. package/Samples/Dialogue_Events_Shell.prefab +458 -0
  62. package/Samples/Dialogue_Events_Shell.prefab.meta +7 -0
  63. package/Samples/Dialogue_Events_Template.prefab +302 -0
  64. package/Samples/Dialogue_Events_Template.prefab.meta +7 -0
  65. package/Samples/Dialogue_Line_Loader.prefab +1282 -0
  66. package/Samples/Dialogue_Line_Loader.prefab.meta +7 -0
  67. package/Samples/Dialogue_Line_Reader.prefab +3688 -0
  68. package/Samples/Dialogue_Line_Reader.prefab.meta +7 -0
  69. package/Samples/Dialogue_Name_Saver.prefab +48 -0
  70. package/Samples/Dialogue_Name_Saver.prefab.meta +7 -0
  71. package/Samples/Dialogue_System_Shell.prefab +325 -0
  72. package/Samples/Dialogue_System_Shell.prefab.meta +7 -0
  73. package/Samples/Dialogue_System_Template.prefab +1138 -0
  74. package/Samples/Dialogue_System_Template.prefab.meta +7 -0
  75. package/Samples/Fast_Forward_To_Line_Tool.prefab +53 -0
  76. package/Samples/Fast_Forward_To_Line_Tool.prefab.meta +7 -0
  77. package/Samples/Instant_Dialogue_Ender.prefab +141 -0
  78. package/Samples/Instant_Dialogue_Ender.prefab.meta +7 -0
  79. package/Samples/Instant_Dialogue_Finisher.prefab +172 -0
  80. package/Samples/Instant_Dialogue_Finisher.prefab.meta +7 -0
  81. package/Samples/Instant_Dialogue_Starter.prefab +55 -0
  82. package/Samples/Instant_Dialogue_Starter.prefab.meta +7 -0
  83. package/Samples/On_Loading_Through_Scene_Transition.prefab +48 -0
  84. package/Samples/On_Loading_Through_Scene_Transition.prefab.meta +7 -0
  85. package/Samples/Scene_Event_On_Text_Display.prefab +47 -0
  86. package/Samples/Scene_Event_On_Text_Display.prefab.meta +7 -0
  87. package/Samples/Trial_Dialogue_Asset_Reader.prefab +561 -0
  88. package/Samples/Trial_Dialogue_Asset_Reader.prefab.meta +7 -0
  89. package/Samples/Trial_Dialogue_Asset_Starter.prefab +239 -0
  90. package/Samples/Trial_Dialogue_Asset_Starter.prefab.meta +7 -0
  91. package/Samples/Trial_Dialogue_Line_Loader.prefab +941 -0
  92. package/Samples/Trial_Dialogue_Line_Loader.prefab.meta +7 -0
  93. package/Samples/Trial_Dialogue_Loader.prefab +232 -0
  94. package/Samples/Trial_Dialogue_Loader.prefab.meta +7 -0
  95. package/Samples/Tween_Waiter_Handler.prefab +46 -0
  96. package/Samples/Tween_Waiter_Handler.prefab.meta +7 -0
  97. package/Samples.meta +8 -0
  98. package/package.json +34 -6
  99. package/package.json.meta +7 -0
  100. package/README.md +0 -3
@@ -0,0 +1,378 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Ending;
3
+ using DREditor.Dialogues.LineReading;
4
+ using DREditor.Dialogues.Loading;
5
+ using DREditor.EventObjects;
6
+ using DREditor.Services;
7
+ using System;
8
+ using System.Collections;
9
+ using System.Collections.Generic;
10
+ using System.Linq;
11
+ using UnityEngine;
12
+
13
+ namespace DREditor.Dialogues.Implementation
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ /// <remarks></remarks>
19
+ public class DialogueAssetReader : DialogueReader, IToTitleScreen
20
+ {
21
+ #region Fields
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Header("")]
27
+ [Divider]
28
+ [Tooltip("")]
29
+ [SerializeField] DialogueCore currentlyPlayingDialogue;
30
+
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Header("")]
36
+ [Divider]
37
+ [Tooltip("")]
38
+ [SerializeField] protected DialogueEndEventHandler DialogueEndEventHandler = null;
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ [Tooltip("")]
44
+ [SerializeField] protected DialogueEnder DialogueEnder = null;
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Tooltip("")]
50
+ [SerializeField] protected DialogueDataClearer DialogueClearer = null;
51
+
52
+ /// <summary>
53
+ ///
54
+ /// </summary>
55
+ [Tooltip("")]
56
+ [SerializeField] protected DialogueLoader DialogueLoader = null;
57
+
58
+
59
+ /// <summary>
60
+ ///
61
+ /// </summary>
62
+ [Header("")]
63
+ [Divider]
64
+ [Tooltip("")]
65
+ [SerializeField] protected IntWithEvent currentLineNum = null;
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ [Tooltip("")]
71
+ [SerializeField] protected SceneEvent updateDirectTo = null;
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ [Tooltip("")]
77
+ [SerializeField] protected BoolWithEvent isLeaving = null;
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ [Tooltip("")]
83
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
84
+
85
+ /// <summary>
86
+ ///
87
+ /// </summary>
88
+ [Tooltip("")]
89
+ [SerializeField] protected StringWithEvent saveDialogueName = null;
90
+
91
+ /// <summary>
92
+ ///
93
+ /// </summary>
94
+ [Tooltip("")]
95
+ [SerializeField] protected LineReader LineReader = null;
96
+
97
+ /// <summary>
98
+ ///
99
+ /// </summary>
100
+ [Tooltip("")]
101
+ [SerializeField] protected List<DialogueComponent> DialogueReaderInitializeComponents = new();
102
+
103
+ /// <summary>
104
+ ///
105
+ /// </summary>
106
+ [Tooltip("")]
107
+ [SerializeField] protected List<DialogueComponent> DialogueReaderCleanUpComponents = new();
108
+
109
+
110
+ /// <summary>
111
+ ///
112
+ /// </summary>
113
+ protected IEnumerable<IDialogueInteruptable> interuptables;
114
+
115
+ /// <summary>
116
+ ///
117
+ /// </summary>
118
+ protected int lastLineNum = -1;
119
+
120
+ #endregion
121
+
122
+ #region Awake/Enable/Disable/Reset
123
+
124
+
125
+ protected virtual void Awake() => interuptables = transform.root.GetComponentsInChildren<IDialogueInteruptable>();
126
+
127
+ /// <summary>
128
+ ///
129
+ /// </summary>
130
+ protected virtual void OnEnable() => SubscribeToEvents();
131
+
132
+ /// <summary>
133
+ ///
134
+ /// </summary>
135
+ protected virtual void SubscribeToEvents()
136
+ {
137
+ foreach (var interuptable in interuptables)
138
+ interuptable.OnInteruptWithNewDialogue += PlayDialogues;
139
+
140
+ DialogueEndEventHandler.SubscribeToCleanUp(CleanUp);
141
+ }
142
+
143
+
144
+ /// <summary>
145
+ ///
146
+ /// </summary>
147
+ protected virtual void OnDisable() => UnsubscribeToEvents();
148
+
149
+ /// <summary>
150
+ ///
151
+ /// </summary>
152
+ protected virtual void UnsubscribeToEvents()
153
+ {
154
+ foreach (var interuptable in interuptables)
155
+ interuptable.OnInteruptWithNewDialogue -= PlayDialogues;
156
+
157
+ DialogueEndEventHandler.UnsubscribeToCleanUp(CleanUp);
158
+ }
159
+
160
+ #endregion
161
+
162
+ #region Play Dialogues
163
+
164
+ /// <summary>
165
+ ///
166
+ /// </summary>
167
+ /// <param name="dialogues"></param>
168
+ /// <remarks></remarks>
169
+ public virtual void PlayDialogues(DialogueCore[] dialogues)
170
+ {
171
+ List<Dialogue> dias = new();
172
+
173
+ foreach(DialogueCore dialogue in dialogues)
174
+ if (dialogue is Dialogue dia)
175
+ dias.Add(dia);
176
+ else
177
+ UnityEngine.Debug.LogWarning("ALERT: ISSUE PLAYING DIALOGUE WAS NOT OF DIALOGUE TYPE");
178
+
179
+ StartCoroutine(PlayDialoguesRoutine(dias.ToArray()));
180
+ }
181
+
182
+ /// <summary>
183
+ ///
184
+ /// </summary>
185
+ /// <param name="dialogues"></param>
186
+ /// <param name="inLeave"></param>
187
+ public override void PlayDialogues<T>(DialogueBase<T>[] dialogues, bool inLeave = false) =>
188
+ StartCoroutine(PlayDialoguesRoutine<T>(dialogues, inLeave));
189
+
190
+ /// <summary>
191
+ ///
192
+ /// </summary>
193
+ /// <param name="dialogues"></param>
194
+ /// <param name="intendingToLeave"></param>
195
+ /// <returns></returns>
196
+ protected virtual IEnumerator PlayDialoguesRoutine<T>(DialogueBase<T>[] dialogues, bool intendingToLeave = false)
197
+ where T : Line
198
+ {
199
+ isLeaving.SetValue(intendingToLeave);
200
+
201
+ InitializeDialogueStarting();
202
+
203
+ for (int i = 0; i < dialogues.Length; i++)
204
+ {
205
+ DialogueBase<T> currentDialogue = dialogues[i];
206
+
207
+ if (i != 0)
208
+ updateDirectTo.Raise();
209
+
210
+ bool stopParent = false;
211
+
212
+ yield return PlayDialogue(currentDialogue, () => stopParent = true);
213
+
214
+ LineReader.ClearSaveData();
215
+
216
+ if (stopParent)
217
+ yield break;
218
+ }
219
+
220
+ CleanUp();
221
+
222
+ DialogueEnder.StopDialogue();
223
+ }
224
+
225
+ /// <summary>
226
+ ///
227
+ /// </summary>
228
+ protected virtual void InitializeDialogueStarting()
229
+ {
230
+ if (!isLoadingFile.Value)
231
+ LineReader.ClearSaveDataOnDialogueStart();
232
+
233
+ foreach (IDialogueReaderInitialize initializer in DialogueReaderInitializeComponents.Cast<IDialogueReaderInitialize>())
234
+ initializer.OnDialogueReaderInitialize();
235
+ }
236
+
237
+ /// <summary>
238
+ ///
239
+ /// </summary>
240
+ public override void CleanUp()
241
+ {
242
+ DialogueClearer.ClearSaveData();
243
+
244
+ foreach (IDialogueReaderCleanUp cleanUpComponent in DialogueReaderCleanUpComponents.Cast<IDialogueReaderCleanUp>())
245
+ cleanUpComponent?.OnDialogueReaderCleanUp();
246
+ }
247
+
248
+ #endregion
249
+
250
+ #region Play Dialogue
251
+
252
+ /// <summary>
253
+ ///
254
+ /// </summary>
255
+ /// <typeparam name="T"></typeparam>
256
+ /// <param name="currentDialogue"></param>
257
+ /// <param name="exitParentRoutine"></param>
258
+ protected virtual IEnumerator PlayDialogue<T>(DialogueBase<T> currentDialogue, Action exitParentRoutine = null)
259
+ where T : Line
260
+ {
261
+ currentlyPlayingDialogue = currentDialogue;
262
+
263
+ for (int i = 0; i < currentDialogue.Lines.Count; i++)
264
+ {
265
+ Line currentLine = currentDialogue.Lines[i];
266
+
267
+ if (isLoadingFile.Value)
268
+ yield return DialogueLoader.LoadToDialogueLine<T>(currentDialogue,
269
+ loadedIndex => { i = loadedIndex; currentLine = currentDialogue.Lines[i]; });
270
+
271
+ SetLineNumber(i);
272
+
273
+
274
+ bool exitEarly = false;
275
+
276
+ bool continueLine = false;
277
+
278
+ yield return LineReader.PlayDialogueLine(currentDialogue, currentLine, () => exitEarly = true, () => continueLine = true);
279
+
280
+ if (exitEarly)
281
+ {
282
+ exitParentRoutine?.Invoke();
283
+
284
+ yield break;
285
+ }
286
+
287
+ if (continueLine)
288
+ continue;
289
+ }
290
+
291
+ // The dialogue reader has finished reading the dialogue lines.
292
+
293
+ SetLineOutOfBounds();
294
+
295
+
296
+ bool exitParent = false;
297
+
298
+ yield return DialogueEndEventHandler.EndDialogueEventOptions(currentDialogue, () => exitParent = true);
299
+
300
+ if (exitParent)
301
+ exitParentRoutine?.Invoke();
302
+ }
303
+
304
+ /// <summary>
305
+ ///
306
+ /// </summary>
307
+ /// <param name="currentLineNum"></param>
308
+ protected virtual void SetLineNumber(int currentLineNum) => this.currentLineNum.SetValue(currentLineNum);
309
+
310
+ /// <summary>
311
+ ///
312
+ /// </summary>
313
+ protected virtual void SetLineOutOfBounds()
314
+ {
315
+ lastLineNum = currentLineNum.Value;
316
+
317
+ SetLineNumber(-1);
318
+ }
319
+
320
+ #endregion
321
+
322
+ #region Additional Public Functions
323
+
324
+ /// <inheritdoc/>
325
+ public override void MidDialogueEnterance<T>(DialogueBase<T>[] dialogues)
326
+ {
327
+ if (dialogues.Length == 0)
328
+ {
329
+ UnityEngine.Debug.LogWarning("ALERT: Tried to send MidDialogue without dialogues!");
330
+
331
+ return;
332
+ }
333
+
334
+ DialogueClearer.ClearSaveData();
335
+
336
+ saveDialogueName.SetValue(dialogues[0].name);
337
+
338
+ PlayDialogues<T>(dialogues);
339
+ }
340
+
341
+ /// <inheritdoc/>
342
+ public override bool IsOnLastLine() =>
343
+ GetCurrentDialogue() != null && GetCurrentLineNum() == GetCurrentDialogue().LineCount - 1;
344
+
345
+ /// <inheritdoc/>
346
+ public override DialogueCore GetCurrentDialogue() => currentlyPlayingDialogue;
347
+
348
+ /// <inheritdoc/>
349
+ public override int GetCurrentLineNum() => currentLineNum.Value;
350
+
351
+ /// <inheritdoc/>
352
+ public override Line GetCurrentLine()
353
+ {
354
+ int currentLineNumber = GetCurrentLineNum();
355
+
356
+ bool linesAreBeingRead = currentLineNumber != -1;
357
+
358
+ int lineNumber = linesAreBeingRead ? currentLineNumber : lastLineNum;
359
+
360
+ if (linesAreBeingRead)
361
+ lastLineNum = -1;
362
+
363
+ return GetCurrentDialogue().GetLine(lineNumber);
364
+ }
365
+
366
+ /// <summary>
367
+ ///
368
+ /// </summary>
369
+ public virtual void ToTitleScreen()
370
+ {
371
+ SetLineOutOfBounds();
372
+
373
+ StopAllCoroutines();
374
+ }
375
+
376
+ #endregion
377
+ }
378
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 5c3c35cde306d124eb430447d2f44553
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,255 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Ending;
3
+ using DREditor.Dialogues.Loading;
4
+ using DREditor.Dialogues.Starting;
5
+ using DREditor.EventObjects;
6
+ using DREditor.Services;
7
+ using System;
8
+ using System.Collections;
9
+ using UnityEngine;
10
+
11
+ namespace DREditor.Dialogues.Implementation
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [ClassHeader(nameof(PreparableDialogueStarter) + ", " + nameof(IDialogueStartEvent) + ", " +
17
+ nameof(PreparableDialogueStarter) + ", " + nameof(DialogueStarter) + ", " + nameof(IDialoguePrepareEvent) +
18
+ "\n\n")]
19
+ public class DialogueAssetStarter : PreparableDialogueStarter, IDialogueStartEvent
20
+ {
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ [Header("")]
25
+ [Divider]
26
+ [Tooltip("")]
27
+ [SerializeField] protected BoolWithEvent inDialogue = null;
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Tooltip("")]
33
+ [SerializeField] protected BoolWithEvent isLeaving = null;
34
+
35
+ /// <summary>
36
+ ///
37
+ /// </summary>
38
+ [Tooltip("")]
39
+ [SerializeField] protected StringWithEvent currentControlsKey = null;
40
+
41
+ /// <summary>
42
+ ///
43
+ /// </summary>
44
+ [Tooltip("")]
45
+ [SerializeField] protected BoolWithEvent hasMenuAccess = null;
46
+
47
+ /// <summary>
48
+ ///
49
+ /// </summary>
50
+ [Tooltip("")]
51
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ [Tooltip("")]
57
+ [SerializeField] protected StringWithEvent saveDialogueName = null;
58
+
59
+
60
+ /// <summary>
61
+ ///
62
+ /// </summary>
63
+ [Header("")]
64
+ [Divider]
65
+ [Tooltip("")]
66
+ [SerializeField] protected DialogueWaiter DialogueWaiter = null;
67
+
68
+ /// <summary>
69
+ ///
70
+ /// </summary>
71
+ [Tooltip("")]
72
+ [SerializeField] protected DialogueStarter InstantDialogueStarter = null;
73
+
74
+
75
+ /// <summary>
76
+ ///
77
+ /// </summary>
78
+ [Header("")]
79
+ [Divider]
80
+ [Tooltip("")]
81
+ [SerializeField] protected string setDialogueControlKey = "dialogue";
82
+
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ public event Action<DialogueCore> OnDialogueStarted;
88
+
89
+
90
+ #region Start Dialogue
91
+
92
+ /// <inheritdoc/>
93
+ public override void StartDialogue<T>(SelectableObject actor, DialogueBase<T>[] dialogues, bool inleaving = false)
94
+ => StartDialogueProcess(actor, dialogues, inleaving);
95
+
96
+ public override void StartDialogue<T>(SelectableObject actor, DialogueBase<T> dialogue, bool inleaving = false)
97
+ => StartDialogue(actor, new DialogueBase<T>[1] { dialogue }, inleaving);
98
+
99
+ /// <summary>
100
+ ///
101
+ /// </summary>
102
+ /// <param name="coreActor"></param>
103
+ /// <param name="coreDialogues"></param>
104
+ /// <param name="inleaving"></param>
105
+ protected virtual void StartDialogueProcess<T>(SelectableObject coreActor, DialogueBase<T>[] coreDialogues,
106
+ bool inleaving = false)
107
+ where T : Line
108
+ {
109
+ if (SentDialoguesEmpty(coreDialogues))
110
+ return;
111
+
112
+ UnityEngine.Debug.Log($"{ToString()}: Starting Dialogue is named: " + coreDialogues[0].name);
113
+
114
+ saveDialogueName.SetValue(coreDialogues[0].name);
115
+
116
+ SetValueWithEvents(inleaving);
117
+
118
+ if (coreDialogues[0] is IInstantAbleDialogue instantable && instantable.GetInstant())
119
+ EvaluateInstantDialogue(coreActor, coreDialogues, inleaving);
120
+ else
121
+ StartCoroutine(BeginDialoguePreparations(coreActor, coreDialogues, inleaving));
122
+ }
123
+
124
+ /// <summary>
125
+ ///
126
+ /// </summary>
127
+ /// <param name="intendingToLeave"></param>
128
+ protected virtual void SetValueWithEvents(bool intendingToLeave = false)
129
+ {
130
+ currentControlsKey.SetValue(setDialogueControlKey);
131
+
132
+ hasMenuAccess.SetValue(false);
133
+
134
+ isLeaving.SetValue(intendingToLeave);
135
+
136
+ // Added 4-30-2026 Moving to a place that starts dialogue on load showed the reticle when it shouldn't, this fixes that.
137
+ // The reason the other call in this script hasn't been removed is because it's unclear as to whether there would
138
+ // be any adverse affects from doing so, I mean without the call here, the issue mentioned wouldn't be happening.
139
+ // If there are any adverse effects of inDialogue being active too early, then the issue mentioned must also be
140
+ // fixed if this line is to be removed.
141
+ inDialogue.SetValue(true);
142
+ }
143
+
144
+ /// <summary>
145
+ ///
146
+ /// </summary>
147
+ /// <param name="dialogues"></param>
148
+ /// <returns></returns>
149
+ protected virtual bool SentDialoguesEmpty(DialogueCore[] dialogues)
150
+ {
151
+ bool dialoguesAreEmpty = dialogues == null || dialogues.Length == 0 || dialogues[0] == null;
152
+
153
+ if (dialoguesAreEmpty)
154
+ {
155
+ ServiceLocator.GetService<IDialogueManager>().GetEnder().StopDialogue();
156
+
157
+ UnityEngine.Debug.LogWarning($"{ToString()}:Sent dialogues were empty.");
158
+ }
159
+
160
+ return dialoguesAreEmpty;
161
+ }
162
+
163
+ #endregion
164
+
165
+ #region Dialogue Preparations
166
+
167
+ /// <summary>
168
+ ///
169
+ /// </summary>
170
+ /// <param name="actor"></param>
171
+ /// <param name="dialogues"></param>
172
+ /// <param name="inleaving"></param>
173
+ protected virtual IEnumerator BeginDialoguePreparations<T>(SelectableObject actor, DialogueBase<T>[] dialogues,
174
+ bool inleaving = false)
175
+ where T : Line
176
+ {
177
+ InvokeDialoguePreparationEvent();
178
+
179
+ yield return DialogueWaiter.CheckIfInDialogueToPlay(dialogues[0]);
180
+
181
+ VerifyStartActor(actor);
182
+
183
+ inDialogue.SetValue(true);
184
+
185
+ OnDialogueStarted?.Invoke(dialogues[0]);
186
+
187
+ UnityEngine.Debug.Log($"REPORT: {nameof(DialogueAssetStarter)}: " +
188
+ $"Starting to Prepare Dialogue.");
189
+
190
+ yield return PrepareDialogueComponents();
191
+
192
+ UnityEngine.Debug.Log($"REPORT: {nameof(DialogueAssetStarter)}: " +
193
+ $"Prepared Dialogue while Loading File is: " + isLoadingFile.Value);
194
+
195
+ if (isLoadingFile.Value)
196
+ dialogues = ServiceLocator.GetService<IDialogueManager>()
197
+ .GetManagerComponent<DialogueLoader>()
198
+ .StartLoadThrough(dialogues);
199
+
200
+ ServiceLocator.GetService<IDialogueManager>()
201
+ .GetReader()
202
+ .PlayDialogues(dialogues, inleaving);
203
+ }
204
+
205
+ /// <summary>
206
+ ///
207
+ /// </summary>
208
+ /// <param name="actor"></param>
209
+ protected virtual void VerifyStartActor(SelectableObject actor)
210
+ {
211
+ if (ServiceLocator.HasService<DialogueObjectManager>())
212
+ ServiceLocator.GetService<DialogueObjectManager>().AttemptSetStartingDialogueObject(actor);
213
+ else
214
+ UnityEngine.Debug.LogWarning($"ALERT: There are no {nameof(DialogueObjectManager)}s in the scene," +
215
+ $" the starting actor will skip validity checking.");
216
+ }
217
+
218
+ #endregion
219
+
220
+ #region Instant Dialogue
221
+
222
+ /// <summary>
223
+ ///
224
+ /// </summary>
225
+ /// <param name="actor"></param>
226
+ /// <param name="dialogues"></param>
227
+ /// <param name="inleaving"></param>
228
+ protected virtual void EvaluateInstantDialogue<T>(SelectableObject actor, DialogueBase<T>[] dialogues,
229
+ bool inleaving = false)
230
+ where T : Line
231
+ {
232
+ if (InstantDialogueStarter == this)
233
+ {
234
+ UnityEngine.Debug.LogError("ALERT: ERROR: YOU CANNOT USE THE SAME DIALOGUE STARTER FOR INSTANT DIALOGUE, " +
235
+ "THIS WILL LOOP CODE. " +
236
+ "USE INSTANTDIALOGUESTARTER SCRIPT INSTEAD. REMOVING REFERENCE.");
237
+
238
+ InstantDialogueStarter = null;
239
+ }
240
+
241
+ if (InstantDialogueStarter == null)
242
+ {
243
+ UnityEngine.Debug.LogWarning("REPORT: An Instant Dialogue Starter hasn't been assigned. Using Default Starter Instead.");
244
+
245
+ StartCoroutine(BeginDialoguePreparations(actor, dialogues, inleaving));
246
+
247
+ return;
248
+ }
249
+
250
+ InstantDialogueStarter.StartDialogue(actor, dialogues, inleaving);
251
+ }
252
+
253
+ #endregion
254
+ }
255
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: be8c7a41d1f924c4a9385074386de1d2
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,41 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Starting;
3
+ using DREditor.EventObjects;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.Dialogues.Implementation
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [ClassHeader(nameof(DialogueStarterDebugger) +
12
+ "\n\n")]
13
+ [RequireComponent(typeof(DialogueStarter))]
14
+ public class DialogueAssetStarterDebugger : DialogueStarterDebugger
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ /// <param name="actor"></param>
20
+ /// <param name="DebugNoDialogue"></param>
21
+ public override void DebugNoCharacterDialogueCall(SelectableObject actor, DialogueCore DebugNoDialogue = null)
22
+ {
23
+ Dialogue dialogueDebug = (Dialogue)DebugNoDialogue;
24
+
25
+ Dialogue[] Conversation = new Dialogue[1];
26
+
27
+ Dialogue dialogue = ScriptableObject.CreateInstance<Dialogue>();
28
+
29
+ dialogue.Lines.Add(new Line());
30
+
31
+ dialogue.Lines[0].SetText("THIS CHARACTER HAS NO DIALOGUE PLUGGED IN DO NOT SAVE ON THIS LINE!");
32
+
33
+ Conversation[0] = dialogue;
34
+
35
+ if (DebugNoDialogue != null)
36
+ Conversation[0] = dialogueDebug;
37
+
38
+ GetComponent<DialogueStarter>().StartDialogue(actor, Conversation);
39
+ }
40
+ }
41
+ }