net.dreditor.choices 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/ChoiceManager.cs +317 -0
- package/ChoiceManager.cs.meta +11 -0
- package/ChoiceOptionUI.cs +52 -0
- package/ChoiceOptionUI.cs.meta +11 -0
- package/ChoiceSaveHandler.cs +80 -0
- package/ChoiceSaveHandler.cs.meta +11 -0
- package/DREditor.Choices.asmdef +21 -0
- package/DREditor.Choices.asmdef.meta +7 -0
- package/DialogueChoiceHandler.cs +60 -0
- package/DialogueChoiceHandler.cs.meta +11 -0
- package/IChoiceManager.cs +44 -0
- package/IChoiceManager.cs.meta +11 -0
- package/Samples~/Choice_Save_Handler.prefab +72 -0
- package/Samples~/Choice_Save_Handler.prefab.meta +7 -0
- package/Samples~/Dialogue_Choice_Handler.prefab +49 -0
- package/Samples~/Dialogue_Choice_Handler.prefab.meta +7 -0
- package/package.json +41 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
package/.attestation.p7m
ADDED
|
Binary file
|
package/ChoiceManager.cs
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using DREditor.Dialogues.Ending;
|
|
4
|
+
using DREditor.Dialogues.Events;
|
|
5
|
+
using DREditor.EventObjects;
|
|
6
|
+
using DREditor.Progressing.Handling;
|
|
7
|
+
using DREditor.Services;
|
|
8
|
+
using DREditor.UI;
|
|
9
|
+
using System;
|
|
10
|
+
using System.Collections;
|
|
11
|
+
using System.Collections.Generic;
|
|
12
|
+
using UnityEngine;
|
|
13
|
+
using UnityEngine.Events;
|
|
14
|
+
using UnityEngine.EventSystems;
|
|
15
|
+
using UnityEngine.InputSystem;
|
|
16
|
+
|
|
17
|
+
namespace DREditor.Choices
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[ClassHeader(nameof(ServiceHolder<IChoiceManager>) + " for type: " + nameof(IChoiceManager) +
|
|
23
|
+
"\n\n")]
|
|
24
|
+
public class ChoiceManager : ServiceHolder<IChoiceManager>, IChoiceManager, IDialogueInteruptable, IToTitleScreen
|
|
25
|
+
{
|
|
26
|
+
/// <summary>
|
|
27
|
+
///
|
|
28
|
+
/// </summary>
|
|
29
|
+
[Space]
|
|
30
|
+
[Divider]
|
|
31
|
+
[Space]
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected InputActionReference submit = null;
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
[Tooltip("")]
|
|
39
|
+
[SerializeField] protected BoolWithEvent isLeaving = null;
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
[Tooltip("")]
|
|
45
|
+
[SerializeField] protected BoolWithEvent fastForwardModeWasEnabled = null;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
///
|
|
50
|
+
/// </summary>
|
|
51
|
+
[Header("")]
|
|
52
|
+
[Divider]
|
|
53
|
+
[Tooltip("")]
|
|
54
|
+
[SerializeField] protected MenuGroupBase ChoiceGroup = null;
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
///
|
|
58
|
+
/// </summary>
|
|
59
|
+
[Tooltip("")]
|
|
60
|
+
[SerializeField] protected ChoiceSaveHandler choiceSaveHandler = null;
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
[Tooltip("")]
|
|
66
|
+
[SerializeField] protected float displayChoiceBufferTime = 0.3f;
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
///
|
|
70
|
+
/// </summary>
|
|
71
|
+
[Tooltip("")]
|
|
72
|
+
[SerializeField] protected List<ChoiceOptionUI> choiceOptions = new();
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
[Header("")]
|
|
76
|
+
[SerializeField] protected UnityEvent OnChoiceStarted = null;
|
|
77
|
+
|
|
78
|
+
[Header("")]
|
|
79
|
+
[SerializeField] protected UnityEvent OnChoiceConfirmed = null;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
public event Action<DialogueCore[]> OnInteruptWithNewDialogue;
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected List<Action> allChoiceActions = new();
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
protected Dialogue currentDialogue;
|
|
94
|
+
|
|
95
|
+
/// <summary>
|
|
96
|
+
///
|
|
97
|
+
/// </summary>
|
|
98
|
+
protected Action exitParentRoutine = null;
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
protected int selectedChoiceIndex = -1;
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
/// <inheritdoc/>
|
|
107
|
+
protected override void Awake()
|
|
108
|
+
{
|
|
109
|
+
base.Awake();
|
|
110
|
+
|
|
111
|
+
ClearChoiceText();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// <inheritdoc/>
|
|
115
|
+
public virtual IEnumerator ExecuteChoiceHandling(Dialogue currentDialogue, Action exitParentRoutine = null)
|
|
116
|
+
{
|
|
117
|
+
this.currentDialogue = currentDialogue;
|
|
118
|
+
|
|
119
|
+
this.exitParentRoutine = exitParentRoutine;
|
|
120
|
+
|
|
121
|
+
InitializeChoices();
|
|
122
|
+
|
|
123
|
+
if (ChoiceGroup != null)
|
|
124
|
+
{
|
|
125
|
+
if (displayChoiceBufferTime > 0)
|
|
126
|
+
yield return new WaitForSeconds(displayChoiceBufferTime);
|
|
127
|
+
|
|
128
|
+
ChoiceGroup.Show();
|
|
129
|
+
|
|
130
|
+
yield return ChoiceGroup.WaitForChangeToComplete();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
OnChoiceStarted?.Invoke();
|
|
134
|
+
|
|
135
|
+
EventSystem.current.SetSelectedGameObject(choiceOptions[0].gameObject);
|
|
136
|
+
|
|
137
|
+
yield return WaitForPlayerClick();
|
|
138
|
+
|
|
139
|
+
OnChoiceConfirmed?.Invoke();
|
|
140
|
+
|
|
141
|
+
EvaluateSelectedChoice();
|
|
142
|
+
|
|
143
|
+
EventSystem.current.SetSelectedGameObject(null);
|
|
144
|
+
|
|
145
|
+
if (ChoiceGroup != null)
|
|
146
|
+
{
|
|
147
|
+
ChoiceGroup.Hide();
|
|
148
|
+
|
|
149
|
+
yield return ChoiceGroup.WaitForChangeToComplete();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
PlayChoiceDialogue();
|
|
153
|
+
|
|
154
|
+
TriggerCustomChoiceDialogueEvent();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// <summary>
|
|
158
|
+
///
|
|
159
|
+
/// </summary>
|
|
160
|
+
protected virtual void InitializeChoices()
|
|
161
|
+
{
|
|
162
|
+
for (int i = 0; i < currentDialogue.Choices.Count; i++)
|
|
163
|
+
{
|
|
164
|
+
if (currentDialogue.Choices[i].ChoiceText != "")
|
|
165
|
+
{
|
|
166
|
+
choiceOptions[i].gameObject.SetActive(true);
|
|
167
|
+
|
|
168
|
+
choiceOptions[i].SetText(currentDialogue.Choices[i].ChoiceText);
|
|
169
|
+
}
|
|
170
|
+
else
|
|
171
|
+
choiceOptions[i].gameObject.SetActive(false);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// <summary>
|
|
176
|
+
///
|
|
177
|
+
/// </summary>
|
|
178
|
+
/// <remarks></remarks>
|
|
179
|
+
protected virtual IEnumerator WaitForPlayerClick()
|
|
180
|
+
{
|
|
181
|
+
GameObject lastSelectedGO = null;
|
|
182
|
+
|
|
183
|
+
while (!submit.action.triggered)
|
|
184
|
+
{
|
|
185
|
+
if (EventSystem.current.currentSelectedGameObject == null)
|
|
186
|
+
EventSystem.current.SetSelectedGameObject(lastSelectedGO);
|
|
187
|
+
else
|
|
188
|
+
lastSelectedGO = EventSystem.current.currentSelectedGameObject;
|
|
189
|
+
|
|
190
|
+
if (submit.action.triggered)
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
yield return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// <summary>
|
|
198
|
+
///
|
|
199
|
+
/// </summary>
|
|
200
|
+
protected virtual void EvaluateSelectedChoice()
|
|
201
|
+
{
|
|
202
|
+
var choice = EventSystem.current.currentSelectedGameObject;
|
|
203
|
+
|
|
204
|
+
for (int i = 0; i < choiceOptions.Count; i++)
|
|
205
|
+
if (choice == choiceOptions[i].gameObject)
|
|
206
|
+
choiceOptions[i].InvokeChoice();
|
|
207
|
+
|
|
208
|
+
selectedChoiceIndex = choiceOptions.IndexOf(choice.GetComponent<ChoiceOptionUI>());
|
|
209
|
+
|
|
210
|
+
UnityEngine.Debug.Log(ToString() + ": Choice Chosen Index was: " + selectedChoiceIndex);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// <summary>
|
|
214
|
+
///
|
|
215
|
+
/// </summary>
|
|
216
|
+
protected virtual void PlayChoiceDialogue()
|
|
217
|
+
{
|
|
218
|
+
if (!isLeaving.Value && currentDialogue.HasChoiceDialogueAtIndex(selectedChoiceIndex))
|
|
219
|
+
{
|
|
220
|
+
TriggerDialogueFlag();
|
|
221
|
+
|
|
222
|
+
fastForwardModeWasEnabled.SetValue(true);
|
|
223
|
+
|
|
224
|
+
Dialogue[] dialogues = { currentDialogue.Choices[selectedChoiceIndex].NextDialogue };
|
|
225
|
+
|
|
226
|
+
choiceSaveHandler.AddChoice(selectedChoiceIndex);
|
|
227
|
+
|
|
228
|
+
exitParentRoutine?.Invoke();
|
|
229
|
+
|
|
230
|
+
DialogueInterruptedInvoke(dialogues);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// <summary>
|
|
235
|
+
///
|
|
236
|
+
/// </summary>
|
|
237
|
+
protected virtual void TriggerCustomChoiceDialogueEvent()
|
|
238
|
+
{
|
|
239
|
+
if (!isLeaving.Value && currentDialogue.Choices[selectedChoiceIndex].CustomCall != "")
|
|
240
|
+
{
|
|
241
|
+
TriggerDialogueFlag();
|
|
242
|
+
|
|
243
|
+
DialogueEventSystem.TriggerEvent(currentDialogue.Choices[selectedChoiceIndex].CustomCall);
|
|
244
|
+
|
|
245
|
+
if (currentDialogue.Choices[selectedChoiceIndex].CallBreak)
|
|
246
|
+
exitParentRoutine?.Invoke();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/// <summary>
|
|
251
|
+
///
|
|
252
|
+
/// </summary>
|
|
253
|
+
protected virtual void TriggerDialogueFlag()
|
|
254
|
+
{
|
|
255
|
+
if (currentDialogue.FlagTrigger.Enabled)
|
|
256
|
+
ServiceLocator.GetService<FlagTriggerHandlerBase>().TriggerFlag(
|
|
257
|
+
currentDialogue.FlagTrigger.Chapter,
|
|
258
|
+
currentDialogue.FlagTrigger.Objective,
|
|
259
|
+
currentDialogue.FlagTrigger.Flags);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
/// <inheritdoc/>
|
|
264
|
+
public virtual void SubscribeAllChoices(Action[] actionArray)
|
|
265
|
+
{
|
|
266
|
+
for (int i = 0; i < actionArray.Length; i++)
|
|
267
|
+
SubscribeChoice(i, actionArray[i]);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// <inheritdoc/>
|
|
271
|
+
public virtual void SubscribeChoice(int index, Action action)
|
|
272
|
+
{
|
|
273
|
+
choiceOptions[index].SubscribeChoice(action);
|
|
274
|
+
|
|
275
|
+
allChoiceActions.Add(action);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/// <inheritdoc/>
|
|
279
|
+
public virtual void UnsubscribeChoice(int index, Action action)
|
|
280
|
+
{
|
|
281
|
+
choiceOptions[index].UnsubscribeChoice(action);
|
|
282
|
+
|
|
283
|
+
allChoiceActions.Remove(action);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/// <inheritdoc/>
|
|
287
|
+
public virtual void UnsubscribeAllChoices()
|
|
288
|
+
{
|
|
289
|
+
for (int i = 0; i < choiceOptions.Count; i++)
|
|
290
|
+
for (int x = 0; x < allChoiceActions.Count; x++)
|
|
291
|
+
UnsubscribeChoice(i, allChoiceActions[x]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// <inheritdoc/>
|
|
295
|
+
public virtual void ClearChoiceText()
|
|
296
|
+
{
|
|
297
|
+
foreach (var choice in choiceOptions)
|
|
298
|
+
if (choice != null)
|
|
299
|
+
choice.Clear();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
/// <inheritdoc/>
|
|
304
|
+
public virtual void DialogueInterruptedInvoke(DialogueCore[] dialogues)
|
|
305
|
+
{
|
|
306
|
+
if (OnInteruptWithNewDialogue == null)
|
|
307
|
+
UnityEngine.Debug.LogWarning("ALERT: Nothing has subscribed to intercept the chosen choices dialogue!" +
|
|
308
|
+
$"\nSomething must subscribe to this {nameof(IDialogueInteruptable)}'s {nameof(OnInteruptWithNewDialogue)} event!");
|
|
309
|
+
|
|
310
|
+
OnInteruptWithNewDialogue?.Invoke(dialogues);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
//Testing /// <inheritdoc/>
|
|
314
|
+
/// <inheritdoc/>
|
|
315
|
+
public virtual void ToTitleScreen() => isLeaving.Value = false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using TMPro;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Choices
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[ClassHeader("")]
|
|
12
|
+
public class ChoiceOptionUI : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Tooltip("")]
|
|
18
|
+
[SerializeField] protected TextMeshProUGUI choiceText = null;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
///
|
|
23
|
+
/// </summary>
|
|
24
|
+
protected event Action OnChoiceSelected;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
public virtual void InvokeChoice() => OnChoiceSelected?.Invoke();
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
///
|
|
34
|
+
/// </summary>
|
|
35
|
+
public virtual void SubscribeChoice(Action action) => OnChoiceSelected += action;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
public virtual void UnsubscribeChoice(Action action) => OnChoiceSelected -= action;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
public virtual void SetText(string text) => choiceText.text = text;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
///
|
|
49
|
+
/// </summary>
|
|
50
|
+
public virtual void Clear() => choiceText.text = "";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using DREditor.EventObjects;
|
|
4
|
+
using DREditor.Saving;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Choices
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(IDRESaveable) + ", " + nameof(IDRELoadable) + ", " + nameof(IClearDialogueSaveData) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class ChoiceSaveHandler : DialogueComponent, IDRESaveable, IDRELoadable, IClearDialogueSaveData
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected string saveKey = "Choices";
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected SceneEventListener OnPlayerDidntGivePresentChoice = null;
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected int dontGivePresentChoiceIndex = 1;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
protected List<int> choices = new();
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
protected virtual void OnEnable() => OnPlayerDidntGivePresentChoice.Response.AddListener(OnPlayerNoGivePresent);
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
///
|
|
49
|
+
/// </summary>
|
|
50
|
+
protected virtual void OnDisable() => OnPlayerDidntGivePresentChoice.Response.RemoveListener(OnPlayerNoGivePresent);
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
protected virtual void OnPlayerNoGivePresent() => AddChoice(dontGivePresentChoiceIndex);
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
/// <param name="selectedChoiceIndex"></param>
|
|
61
|
+
public virtual void AddChoice(int selectedChoiceIndex) => choices.Add(selectedChoiceIndex);
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
///
|
|
65
|
+
/// </summary>
|
|
66
|
+
/// <returns></returns>
|
|
67
|
+
/// <remarks></remarks>
|
|
68
|
+
public virtual List<int> GetChoices() => choices;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
/// <inheritdoc/>
|
|
72
|
+
public virtual void Save(Dictionary<string, object> saveData) => saveData.Set(saveKey, choices);
|
|
73
|
+
|
|
74
|
+
/// <inheritdoc/>
|
|
75
|
+
public virtual void ClearSaveData() => choices.Clear();
|
|
76
|
+
|
|
77
|
+
/// <inheritdoc/>
|
|
78
|
+
public virtual void Load(Dictionary<string, object> saveDatas) => choices = new(saveDatas.Get<List<int>>(saveKey));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Choices",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"Unity.InputSystem",
|
|
6
|
+
"Unity.TextMeshPro",
|
|
7
|
+
"DREditor",
|
|
8
|
+
"DREditor.Controls",
|
|
9
|
+
"DREditor.UI",
|
|
10
|
+
"DREditor.Progressing.Handling"
|
|
11
|
+
],
|
|
12
|
+
"includePlatforms": [],
|
|
13
|
+
"excludePlatforms": [],
|
|
14
|
+
"allowUnsafeCode": false,
|
|
15
|
+
"overrideReferences": false,
|
|
16
|
+
"precompiledReferences": [],
|
|
17
|
+
"autoReferenced": true,
|
|
18
|
+
"defineConstraints": [],
|
|
19
|
+
"versionDefines": [],
|
|
20
|
+
"noEngineReferences": false
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using DREditor.Dialogues.LineReading;
|
|
4
|
+
using DREditor.Services;
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Choices
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(DialogueComponent) + ", " + nameof(ILineEndProcess) + ", " + nameof(ILineWaitForClick) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class DialogueChoiceHandler : DialogueComponent, ILineEndProcess, ILineWaitForClick
|
|
16
|
+
{
|
|
17
|
+
public virtual bool SkipOnFastForward => false;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/// <inheritdoc/>
|
|
21
|
+
public virtual void LineEndProcess(Line currentLine = null)
|
|
22
|
+
{
|
|
23
|
+
if (ServiceLocator.HasService<IChoiceManager>())
|
|
24
|
+
ServiceLocator.GetService<IChoiceManager>()?.ClearChoiceText();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
/// <inheritdoc/>
|
|
32
|
+
public virtual IEnumerator LineWaitForClick<T>
|
|
33
|
+
(DialogueBase<T> currentDialogue, Line currentLine, Action exitParentCallback = null)
|
|
34
|
+
where T : Line
|
|
35
|
+
{
|
|
36
|
+
if (currentDialogue is not Dialogue dialogue)
|
|
37
|
+
yield break;
|
|
38
|
+
|
|
39
|
+
bool OnLastLine = dialogue.Lines.IndexOf(currentLine) == dialogue.Lines.Count - 1;
|
|
40
|
+
|
|
41
|
+
bool hasChoices = OnLastLine && dialogue.Choices.Count != 0;
|
|
42
|
+
|
|
43
|
+
if (hasChoices)
|
|
44
|
+
{
|
|
45
|
+
bool exitEarly = false;
|
|
46
|
+
|
|
47
|
+
UnityEngine.Debug.Log(ToString() + ": Dialogue: " + dialogue.name + " has choices.");
|
|
48
|
+
|
|
49
|
+
yield return ServiceLocator
|
|
50
|
+
.GetService<IChoiceManager>()
|
|
51
|
+
.ExecuteChoiceHandling(dialogue, () => { exitParentCallback?.Invoke(); exitEarly = true; });
|
|
52
|
+
|
|
53
|
+
UnityEngine.Debug.Log(ToString() + ": Exit Early is: " + exitEarly);
|
|
54
|
+
|
|
55
|
+
if (exitEarly)
|
|
56
|
+
yield break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Choices
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
public interface IChoiceManager
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
IEnumerator ExecuteChoiceHandling(Dialogue currentDialogue, Action exitParentRoutine = null);
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
/// <param name="actionArray"></param>
|
|
22
|
+
void SubscribeAllChoices(Action[] actionArray);
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
void SubscribeChoice(int index, Action action);
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
void UnsubscribeChoice(int index, Action action);
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
///
|
|
36
|
+
/// </summary>
|
|
37
|
+
void UnsubscribeAllChoices();
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
void ClearChoiceText();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!1 &6362605638772830146
|
|
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: 1990112493913278734}
|
|
12
|
+
- component: {fileID: 6490968805688521859}
|
|
13
|
+
- component: {fileID: 2208240244043241710}
|
|
14
|
+
m_Layer: 5
|
|
15
|
+
m_Name: Choice_Save_Handler
|
|
16
|
+
m_TagString: Untagged
|
|
17
|
+
m_Icon: {fileID: 0}
|
|
18
|
+
m_NavMeshLayer: 0
|
|
19
|
+
m_StaticEditorFlags: 0
|
|
20
|
+
m_IsActive: 1
|
|
21
|
+
--- !u!224 &1990112493913278734
|
|
22
|
+
RectTransform:
|
|
23
|
+
m_ObjectHideFlags: 0
|
|
24
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
25
|
+
m_PrefabInstance: {fileID: 0}
|
|
26
|
+
m_PrefabAsset: {fileID: 0}
|
|
27
|
+
m_GameObject: {fileID: 6362605638772830146}
|
|
28
|
+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
29
|
+
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
30
|
+
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
31
|
+
m_ConstrainProportionsScale: 0
|
|
32
|
+
m_Children: []
|
|
33
|
+
m_Father: {fileID: 0}
|
|
34
|
+
m_RootOrder: 0
|
|
35
|
+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
36
|
+
m_AnchorMin: {x: 0.5, y: 0.5}
|
|
37
|
+
m_AnchorMax: {x: 0.5, y: 0.5}
|
|
38
|
+
m_AnchoredPosition: {x: 0, y: 0}
|
|
39
|
+
m_SizeDelta: {x: 100, y: 100}
|
|
40
|
+
m_Pivot: {x: 0.5, y: 0.5}
|
|
41
|
+
--- !u!114 &6490968805688521859
|
|
42
|
+
MonoBehaviour:
|
|
43
|
+
m_ObjectHideFlags: 0
|
|
44
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
45
|
+
m_PrefabInstance: {fileID: 0}
|
|
46
|
+
m_PrefabAsset: {fileID: 0}
|
|
47
|
+
m_GameObject: {fileID: 6362605638772830146}
|
|
48
|
+
m_Enabled: 1
|
|
49
|
+
m_EditorHideFlags: 0
|
|
50
|
+
m_Script: {fileID: 11500000, guid: 3f6bb93956b512345ae1432c69775f0e, type: 3}
|
|
51
|
+
m_Name:
|
|
52
|
+
m_EditorClassIdentifier:
|
|
53
|
+
saveKey: Choices
|
|
54
|
+
OnPlayerDidntGivePresentChoice: {fileID: 2208240244043241710}
|
|
55
|
+
dontGivePresentChoiceIndex: 1
|
|
56
|
+
--- !u!114 &2208240244043241710
|
|
57
|
+
MonoBehaviour:
|
|
58
|
+
m_ObjectHideFlags: 0
|
|
59
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
60
|
+
m_PrefabInstance: {fileID: 0}
|
|
61
|
+
m_PrefabAsset: {fileID: 0}
|
|
62
|
+
m_GameObject: {fileID: 6362605638772830146}
|
|
63
|
+
m_Enabled: 1
|
|
64
|
+
m_EditorHideFlags: 0
|
|
65
|
+
m_Script: {fileID: 11500000, guid: 9122f094a109f78448db952c36a264a9, type: 3}
|
|
66
|
+
m_Name:
|
|
67
|
+
m_EditorClassIdentifier:
|
|
68
|
+
Event: {fileID: 11400000, guid: ef42b46fc425bd84da77d45014d59826, type: 2}
|
|
69
|
+
Response:
|
|
70
|
+
m_PersistentCalls:
|
|
71
|
+
m_Calls: []
|
|
72
|
+
Condition: {fileID: 0}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!1 &5413613079836805745
|
|
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: 5413613079836805751}
|
|
12
|
+
- component: {fileID: 5413613079836805744}
|
|
13
|
+
m_Layer: 0
|
|
14
|
+
m_Name: Dialogue_Choice_Handler
|
|
15
|
+
m_TagString: Untagged
|
|
16
|
+
m_Icon: {fileID: 0}
|
|
17
|
+
m_NavMeshLayer: 0
|
|
18
|
+
m_StaticEditorFlags: 0
|
|
19
|
+
m_IsActive: 1
|
|
20
|
+
--- !u!4 &5413613079836805751
|
|
21
|
+
Transform:
|
|
22
|
+
m_ObjectHideFlags: 0
|
|
23
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
24
|
+
m_PrefabInstance: {fileID: 0}
|
|
25
|
+
m_PrefabAsset: {fileID: 0}
|
|
26
|
+
m_GameObject: {fileID: 5413613079836805745}
|
|
27
|
+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
28
|
+
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
29
|
+
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
30
|
+
m_ConstrainProportionsScale: 0
|
|
31
|
+
m_Children: []
|
|
32
|
+
m_Father: {fileID: 0}
|
|
33
|
+
m_RootOrder: 0
|
|
34
|
+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
35
|
+
--- !u!114 &5413613079836805744
|
|
36
|
+
MonoBehaviour:
|
|
37
|
+
m_ObjectHideFlags: 0
|
|
38
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
39
|
+
m_PrefabInstance: {fileID: 0}
|
|
40
|
+
m_PrefabAsset: {fileID: 0}
|
|
41
|
+
m_GameObject: {fileID: 5413613079836805745}
|
|
42
|
+
m_Enabled: 1
|
|
43
|
+
m_EditorHideFlags: 0
|
|
44
|
+
m_Script: {fileID: 11500000, guid: e79a5f2a04464bb46a3be0cda2b29ad2, type: 3}
|
|
45
|
+
m_Name:
|
|
46
|
+
m_EditorClassIdentifier:
|
|
47
|
+
inFastForwardMode: {fileID: 11400000, guid: 38c7cacea6166a140ab9c9d7d72ff637, type: 2}
|
|
48
|
+
inInstant: {fileID: 11400000, guid: d24a1d6a6eab7514eb7afc2eccc6245a, type: 2}
|
|
49
|
+
hasMenuAccess: {fileID: 11400000, guid: d969ff2ab7dd92342a1ac9ed2767ed51, type: 2}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "net.dreditor.choices",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"displayName": "DREditor Choices",
|
|
5
|
+
"description": "The beta for DREditor. A tool to create death game style projects without having to code.",
|
|
6
|
+
"unity": "6000.4",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"com.unity.inputsystem": "1.19.0",
|
|
9
|
+
"com.unity.ugui": "2.0.0",
|
|
10
|
+
"net.dreditor.core": "0.1.7",
|
|
11
|
+
"net.dreditor.ui": "0.1.7",
|
|
12
|
+
"net.dreditor.progressing.handling": "0.1.7"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Benjamin \"Sweden\" Jillson",
|
|
19
|
+
"email": "dreditortool@gmail.com",
|
|
20
|
+
"url": "https://dreditor.net"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"editor",
|
|
24
|
+
"tool",
|
|
25
|
+
"dreditor"
|
|
26
|
+
],
|
|
27
|
+
"samples": [
|
|
28
|
+
{
|
|
29
|
+
"displayName": "Samples",
|
|
30
|
+
"description": "",
|
|
31
|
+
"path": "Samples~"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"documentationUrl": "https://dreditor.net",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"licensesUrl": "https://dreditor.net/docs/LICENSE.html",
|
|
37
|
+
"changelogUrl": "https://dreditor.net/docs/CHANGELOG.html",
|
|
38
|
+
"repository": {
|
|
39
|
+
"url": "https://github.com/CertifiedSharp/DREditor",
|
|
40
|
+
"type": "git",
|
|
41
|
+
"revision": "14ca252fbb33eb6f53557ecaed1c10902877698f"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/README.md
DELETED