net.dreditor.progressing.handling 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/ChapterTitleDisplayer.cs +41 -41
- package/ChapterTitleDisplayer.cs.meta +11 -11
- package/DREditor.Progressing.Handling.asmdef +16 -16
- package/DREditor.Progressing.Handling.asmdef.meta +7 -7
- package/FlagTriggerExtensions.cs +78 -78
- package/FlagTriggerExtensions.cs.meta +11 -11
- package/FlagTriggerHandler.cs +236 -236
- package/FlagTriggerHandler.cs.meta +11 -11
- package/FlagTriggerHandlerBase.cs +65 -65
- package/FlagTriggerHandlerBase.cs.meta +11 -11
- package/HistoricalManagerBase.cs +158 -158
- package/HistoricalManagerBase.cs.meta +1 -1
- package/IHistory.cs +100 -100
- package/IHistory.cs.meta +1 -1
- package/ProgressionData.cs +180 -180
- package/ProgressionData.cs.meta +11 -11
- package/ProgressionDebugger.cs +185 -185
- package/ProgressionDebugger.cs.meta +11 -11
- package/ProgressionFlagHandler.cs +166 -166
- package/ProgressionFlagHandler.cs.meta +11 -11
- package/ProgressionHistoryManager.cs +33 -33
- package/ProgressionHistoryManager.cs.meta +11 -11
- package/ProgressionInfo.cs +53 -53
- package/ProgressionInfo.cs.meta +11 -11
- package/ProgressionLoader.cs +128 -128
- package/ProgressionLoader.cs.meta +11 -11
- package/ProgressionManager.cs +285 -285
- package/ProgressionManager.cs.meta +11 -11
- package/ProgressionManagerBase.cs +131 -131
- package/ProgressionManagerBase.cs.meta +11 -11
- package/ProgressionSaver.cs +48 -48
- package/ProgressionSaver.cs.meta +11 -11
- package/{Samples → Samples~}/CurrentChapterIndex.asset +21 -21
- package/{Samples → Samples~}/CurrentChapterIndex.asset.meta +8 -8
- package/{Samples → Samples~}/CurrentObjectiveIndex.asset +19 -19
- package/{Samples → Samples~}/CurrentObjectiveIndex.asset.meta +8 -8
- package/{Samples → Samples~}/CurrentObjectiveName.asset +19 -19
- package/{Samples → Samples~}/CurrentObjectiveName.asset.meta +8 -8
- package/{Samples → Samples~}/FlagTriggered.asset +19 -19
- package/{Samples → Samples~}/FlagTriggered.asset.meta +8 -8
- package/{Samples → Samples~}/Flag_Trigger_Handler.prefab +194 -194
- package/{Samples → Samples~}/Flag_Trigger_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/LoadProgressionData.asset +14 -14
- package/{Samples → Samples~}/LoadProgressionData.asset.meta +8 -8
- package/{Samples → Samples~}/MoveToNextNaturalObjective.asset +14 -14
- package/{Samples → Samples~}/MoveToNextNaturalObjective.asset.meta +8 -8
- package/{Samples → Samples~}/MoveToObjective.asset +19 -19
- package/{Samples → Samples~}/MoveToObjective.asset.meta +8 -8
- package/{Samples → Samples~}/ObjectiveKeepsInstanceData.asset +19 -19
- package/{Samples → Samples~}/ObjectiveKeepsInstanceData.asset.meta +8 -8
- package/{Samples → Samples~}/OnGeneratePastData.asset +14 -14
- package/{Samples → Samples~}/OnGeneratePastData.asset.meta +8 -8
- package/{Samples → Samples~}/OnLastObjective.asset +19 -19
- package/{Samples → Samples~}/OnLastObjective.asset.meta +8 -8
- package/{Samples → Samples~}/Progression_Debugger.prefab +73 -73
- package/{Samples → Samples~}/Progression_Debugger.prefab.meta +7 -7
- package/{Samples → Samples~}/Progression_Flag_Handler.prefab +47 -47
- package/{Samples → Samples~}/Progression_Flag_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/Progression_History_Manager.prefab +107 -107
- package/{Samples → Samples~}/Progression_History_Manager.prefab.meta +7 -7
- package/{Samples → Samples~}/Progression_Loader.prefab +76 -76
- package/{Samples → Samples~}/Progression_Loader.prefab.meta +7 -7
- package/{Samples → Samples~}/Progression_Manager_ETemplate.prefab +603 -603
- package/{Samples → Samples~}/Progression_Manager_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Progression_Saver.prefab +51 -51
- package/{Samples → Samples~}/Progression_Saver.prefab.meta +7 -7
- package/{Samples → Samples~}/RequiredFlagsTriggered.asset +19 -19
- package/{Samples → Samples~}/RequiredFlagsTriggered.asset.meta +8 -8
- package/{Samples → Samples~}/TriggerAllRequiredFlags.asset +14 -14
- package/{Samples → Samples~}/TriggerAllRequiredFlags.asset.meta +8 -8
- package/package.json +40 -35
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/ProgressionManager.cs
CHANGED
|
@@ -1,286 +1,286 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.EventObjects;
|
|
3
|
-
using DREditor.Services;
|
|
4
|
-
using UnityEngine;
|
|
5
|
-
using UnityEngine.Scripting.APIUpdating;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.Progressing.Handling
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
[ClassHeader(nameof(ServiceHolder<ProgressionManagerBase>) + " for type: " + nameof(ProgressionManagerBase) +
|
|
13
|
-
"\n\n")]
|
|
14
|
-
[MovedFrom(true, "DREditor.Progression.Handling", "DREditor.Progression.Handling")]
|
|
15
|
-
public class ProgressionManager : ProgressionManagerBase
|
|
16
|
-
{
|
|
17
|
-
/// <summary>
|
|
18
|
-
///
|
|
19
|
-
/// </summary>
|
|
20
|
-
[Header("")]
|
|
21
|
-
[Divider]
|
|
22
|
-
[Tooltip("")]
|
|
23
|
-
[SerializeField] protected IntWithEvent currentChapterIndex = null;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
///
|
|
27
|
-
/// </summary>
|
|
28
|
-
[Tooltip("")]
|
|
29
|
-
[SerializeField] protected IntWithEvent currentObjectiveIndex = null;
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected BoolWithEvent onLastObjective = null;
|
|
36
|
-
|
|
37
|
-
/// <summary>
|
|
38
|
-
///
|
|
39
|
-
/// </summary>
|
|
40
|
-
[Tooltip("")]
|
|
41
|
-
[SerializeField] protected BoolWithEvent objectiveKeepsInstanceData = null;
|
|
42
|
-
|
|
43
|
-
/// <summary>
|
|
44
|
-
///
|
|
45
|
-
/// </summary>
|
|
46
|
-
[Tooltip("")]
|
|
47
|
-
[SerializeField] protected BoolWithEvent requiredFlagsTriggered = null;
|
|
48
|
-
|
|
49
|
-
/// <summary>
|
|
50
|
-
///
|
|
51
|
-
/// </summary>
|
|
52
|
-
[Tooltip("")]
|
|
53
|
-
[SerializeField] protected StringWithEvent currentObjectiveName = null;
|
|
54
|
-
|
|
55
|
-
/// <summary>
|
|
56
|
-
///
|
|
57
|
-
/// </summary>
|
|
58
|
-
[Tooltip("")]
|
|
59
|
-
[SerializeField] protected StringWithEvent moveToObjective = null;
|
|
60
|
-
|
|
61
|
-
/// <summary>
|
|
62
|
-
///
|
|
63
|
-
/// </summary>
|
|
64
|
-
[Tooltip("")]
|
|
65
|
-
[SerializeField] protected SceneEventListener newGameSelected = null;
|
|
66
|
-
|
|
67
|
-
/// <summary>
|
|
68
|
-
///
|
|
69
|
-
/// </summary>
|
|
70
|
-
[Tooltip("")]
|
|
71
|
-
[SerializeField] protected SceneEventListener startedNewGame = null;
|
|
72
|
-
|
|
73
|
-
/// <summary>
|
|
74
|
-
///
|
|
75
|
-
/// </summary>
|
|
76
|
-
[Tooltip("")]
|
|
77
|
-
[SerializeField] protected SceneEventListener moveToNextNaturalObjective = null;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/// <summary>
|
|
81
|
-
///
|
|
82
|
-
/// </summary>
|
|
83
|
-
protected virtual void OnEnable() => SubscribeToEvents();
|
|
84
|
-
|
|
85
|
-
/// <summary>
|
|
86
|
-
///
|
|
87
|
-
/// </summary>
|
|
88
|
-
protected virtual void OnDisable() => UnsubscribeToEvents();
|
|
89
|
-
|
|
90
|
-
/// <summary>
|
|
91
|
-
///
|
|
92
|
-
/// </summary>
|
|
93
|
-
protected virtual void SubscribeToEvents()
|
|
94
|
-
{
|
|
95
|
-
moveToNextNaturalObjective.Response.AddListener(MoveToNextNaturalObjective);
|
|
96
|
-
|
|
97
|
-
newGameSelected.Response.AddListener(ResetProgression);
|
|
98
|
-
|
|
99
|
-
startedNewGame.Response.AddListener(ResetProgression);
|
|
100
|
-
|
|
101
|
-
moveToObjective.AddListener(MoveToObjective);
|
|
102
|
-
|
|
103
|
-
currentChapterIndex.AddListener(SetCurrentChapterByIndex);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/// <summary>
|
|
107
|
-
///
|
|
108
|
-
/// </summary>
|
|
109
|
-
protected virtual void UnsubscribeToEvents()
|
|
110
|
-
{
|
|
111
|
-
moveToNextNaturalObjective.Response.RemoveListener(MoveToNextNaturalObjective);
|
|
112
|
-
|
|
113
|
-
newGameSelected.Response.RemoveListener(ResetProgression);
|
|
114
|
-
|
|
115
|
-
startedNewGame.Response.RemoveListener(ResetProgression);
|
|
116
|
-
|
|
117
|
-
moveToObjective.RemoveListener(MoveToObjective);
|
|
118
|
-
|
|
119
|
-
currentChapterIndex.RemoveListener(SetCurrentChapterByIndex);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/// <summary>
|
|
123
|
-
///
|
|
124
|
-
/// </summary>
|
|
125
|
-
/// <param name="index"></param>
|
|
126
|
-
/// <remarks>
|
|
127
|
-
///
|
|
128
|
-
/// </remarks>
|
|
129
|
-
protected virtual void SetCurrentChapterByIndex(int index) => SetCurrentChapter(progressionDatabase.Chapters[index]);
|
|
130
|
-
|
|
131
|
-
/// <inheritdoc/>
|
|
132
|
-
public override bool PassedPoint(int chapter, string objectiveName)
|
|
133
|
-
{
|
|
134
|
-
if (currentChapterIndex.Value > chapter)
|
|
135
|
-
return true;
|
|
136
|
-
|
|
137
|
-
if (currentChapterIndex.Value < chapter)
|
|
138
|
-
return false;
|
|
139
|
-
|
|
140
|
-
return ServiceLocator.GetService<IHistory>().ContainsObjective(objectiveName);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/// <inheritdoc/>
|
|
144
|
-
public override void SetCurrentChapter(Chapter chapter)
|
|
145
|
-
{
|
|
146
|
-
base.SetCurrentChapter(chapter);
|
|
147
|
-
|
|
148
|
-
currentChapterIndex.SetValue(progressionDatabase.Chapters.IndexOf(chapter));
|
|
149
|
-
|
|
150
|
-
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: The Chapter index has changed to {chapter}.");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/// <inheritdoc/>
|
|
154
|
-
public override void SetCurrentObjective(Objective objective)
|
|
155
|
-
{
|
|
156
|
-
base.SetCurrentObjective(objective);
|
|
157
|
-
|
|
158
|
-
bool isFinalObjective = currentObjective.Description == currentChapter.Objectives[^1].Description;
|
|
159
|
-
|
|
160
|
-
onLastObjective.SetValue(isFinalObjective);
|
|
161
|
-
|
|
162
|
-
currentObjectiveIndex.SetValue(currentChapter.Objectives.IndexOf(currentObjective));
|
|
163
|
-
|
|
164
|
-
currentObjectiveName.SetValue(currentObjective.Description);
|
|
165
|
-
|
|
166
|
-
objectiveKeepsInstanceData.SetValue(progressionDatabase.GetObjective(currentObjective.Description).KeepInstanceData);
|
|
167
|
-
|
|
168
|
-
requiredFlagsTriggered.SetValue(false);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/// <summary>
|
|
172
|
-
///
|
|
173
|
-
/// </summary>
|
|
174
|
-
protected virtual void ResetProgression()
|
|
175
|
-
{
|
|
176
|
-
SetCurrentChapter(progressionDatabase.Chapters[0]);
|
|
177
|
-
|
|
178
|
-
currentChapterIndex.SetValue(0);
|
|
179
|
-
|
|
180
|
-
SetCurrentObjective((Objective)currentChapter.Objectives[0].Clone());
|
|
181
|
-
|
|
182
|
-
ServiceLocator.GetService<IHistory>().Clear();
|
|
183
|
-
|
|
184
|
-
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: Progression Reset.");
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/// <summary>
|
|
188
|
-
///
|
|
189
|
-
/// </summary>
|
|
190
|
-
/// <param name="objective"></param>
|
|
191
|
-
/// <returns></returns>
|
|
192
|
-
protected virtual Objective GetNextObjective(Objective objective)
|
|
193
|
-
{
|
|
194
|
-
for (int i = 0; i < currentChapter.Objectives.Count; i++)
|
|
195
|
-
{
|
|
196
|
-
Objective iteratedObjective = currentChapter.Objectives[i];
|
|
197
|
-
|
|
198
|
-
if (iteratedObjective.Description == objective.Description)
|
|
199
|
-
{
|
|
200
|
-
if (i + 1 < currentChapter.Objectives.Count)
|
|
201
|
-
return currentChapter.Objectives[i + 1];
|
|
202
|
-
else
|
|
203
|
-
{
|
|
204
|
-
MoveToNextChapter();
|
|
205
|
-
|
|
206
|
-
return currentChapter.Objectives[0];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
UnityEngine.Debug.Log($"REPORT: {ToString()}: GetNextObjective Evaluated Null");
|
|
212
|
-
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/// <summary>
|
|
217
|
-
///
|
|
218
|
-
/// </summary>
|
|
219
|
-
protected virtual void MoveToNextChapter()
|
|
220
|
-
{
|
|
221
|
-
for (int i = 0; i < progressionDatabase.Chapters.Count; i++)
|
|
222
|
-
if (progressionDatabase.Chapters[i] == currentChapter && (i + 1) < progressionDatabase.Chapters.Count)
|
|
223
|
-
SetCurrentChapter(progressionDatabase.Chapters[i + 1]);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/// <summary>
|
|
227
|
-
///
|
|
228
|
-
/// </summary>
|
|
229
|
-
/// <param name="objectiveName"></param>
|
|
230
|
-
protected virtual void MoveToObjective(string objectiveName)
|
|
231
|
-
{
|
|
232
|
-
if (string.IsNullOrEmpty(objectiveName))
|
|
233
|
-
return;
|
|
234
|
-
|
|
235
|
-
ServiceLocator.GetService<IHistory>().Add(currentChapterIndex.Value, currentObjective);
|
|
236
|
-
|
|
237
|
-
Objective objective = progressionDatabase.GetObjective(objectiveName);
|
|
238
|
-
|
|
239
|
-
if (objective == null)
|
|
240
|
-
{
|
|
241
|
-
UnityEngine.Debug.LogError($"ALERT: {ToString()}: " +
|
|
242
|
-
$"The Move to Objective called name does not match any valid objectives, " +
|
|
243
|
-
$"for: " + objectiveName + " . Please make sure the string is spelled correctly and has correct case.");
|
|
244
|
-
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
else
|
|
248
|
-
{
|
|
249
|
-
ServiceLocator.GetService<IHistory>().SetPreviousObjective((Objective)currentObjective.Clone());
|
|
250
|
-
|
|
251
|
-
SetCurrentObjective((Objective)objective.Clone());
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/// <summary>
|
|
256
|
-
///
|
|
257
|
-
/// </summary>
|
|
258
|
-
protected virtual void MoveToNextNaturalObjective()
|
|
259
|
-
{
|
|
260
|
-
bool isFTEObjective = currentChapter.GetObjective(currentObjective.Description) == null;
|
|
261
|
-
|
|
262
|
-
if (isFTEObjective)
|
|
263
|
-
SetCurrentObjective((Objective)GetNextObjective(ServiceLocator.GetService<IHistory>().GetLastObjective()).Clone());
|
|
264
|
-
else
|
|
265
|
-
ChangeObjective();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/// <summary>
|
|
269
|
-
///
|
|
270
|
-
/// </summary>
|
|
271
|
-
protected virtual void ChangeObjective()
|
|
272
|
-
{
|
|
273
|
-
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: Changing objective from current objective: "
|
|
274
|
-
+ currentObjective.Description);
|
|
275
|
-
|
|
276
|
-
ServiceLocator.GetService<IHistory>().Add(currentChapterIndex.Value, currentObjective);
|
|
277
|
-
|
|
278
|
-
string overrideFlagObjectiveName = currentObjective.GetOverrideFlag();
|
|
279
|
-
|
|
280
|
-
if (!string.IsNullOrEmpty(overrideFlagObjectiveName))
|
|
281
|
-
SetCurrentObjective((Objective)progressionDatabase.GetObjective(overrideFlagObjectiveName).Clone());
|
|
282
|
-
else
|
|
283
|
-
SetCurrentObjective((Objective)GetNextObjective(currentObjective).Clone());
|
|
284
|
-
}
|
|
285
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using DREditor.Services;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.Scripting.APIUpdating;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.Progressing.Handling
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[ClassHeader(nameof(ServiceHolder<ProgressionManagerBase>) + " for type: " + nameof(ProgressionManagerBase) +
|
|
13
|
+
"\n\n")]
|
|
14
|
+
[MovedFrom(true, "DREditor.Progression.Handling", "DREditor.Progression.Handling")]
|
|
15
|
+
public class ProgressionManager : ProgressionManagerBase
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Header("")]
|
|
21
|
+
[Divider]
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected IntWithEvent currentChapterIndex = null;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected IntWithEvent currentObjectiveIndex = null;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected BoolWithEvent onLastObjective = null;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected BoolWithEvent objectiveKeepsInstanceData = null;
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
[Tooltip("")]
|
|
47
|
+
[SerializeField] protected BoolWithEvent requiredFlagsTriggered = null;
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
[Tooltip("")]
|
|
53
|
+
[SerializeField] protected StringWithEvent currentObjectiveName = null;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[Tooltip("")]
|
|
59
|
+
[SerializeField] protected StringWithEvent moveToObjective = null;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
///
|
|
63
|
+
/// </summary>
|
|
64
|
+
[Tooltip("")]
|
|
65
|
+
[SerializeField] protected SceneEventListener newGameSelected = null;
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
[Tooltip("")]
|
|
71
|
+
[SerializeField] protected SceneEventListener startedNewGame = null;
|
|
72
|
+
|
|
73
|
+
/// <summary>
|
|
74
|
+
///
|
|
75
|
+
/// </summary>
|
|
76
|
+
[Tooltip("")]
|
|
77
|
+
[SerializeField] protected SceneEventListener moveToNextNaturalObjective = null;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
protected virtual void OnEnable() => SubscribeToEvents();
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected virtual void OnDisable() => UnsubscribeToEvents();
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
protected virtual void SubscribeToEvents()
|
|
94
|
+
{
|
|
95
|
+
moveToNextNaturalObjective.Response.AddListener(MoveToNextNaturalObjective);
|
|
96
|
+
|
|
97
|
+
newGameSelected.Response.AddListener(ResetProgression);
|
|
98
|
+
|
|
99
|
+
startedNewGame.Response.AddListener(ResetProgression);
|
|
100
|
+
|
|
101
|
+
moveToObjective.AddListener(MoveToObjective);
|
|
102
|
+
|
|
103
|
+
currentChapterIndex.AddListener(SetCurrentChapterByIndex);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// <summary>
|
|
107
|
+
///
|
|
108
|
+
/// </summary>
|
|
109
|
+
protected virtual void UnsubscribeToEvents()
|
|
110
|
+
{
|
|
111
|
+
moveToNextNaturalObjective.Response.RemoveListener(MoveToNextNaturalObjective);
|
|
112
|
+
|
|
113
|
+
newGameSelected.Response.RemoveListener(ResetProgression);
|
|
114
|
+
|
|
115
|
+
startedNewGame.Response.RemoveListener(ResetProgression);
|
|
116
|
+
|
|
117
|
+
moveToObjective.RemoveListener(MoveToObjective);
|
|
118
|
+
|
|
119
|
+
currentChapterIndex.RemoveListener(SetCurrentChapterByIndex);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// <summary>
|
|
123
|
+
///
|
|
124
|
+
/// </summary>
|
|
125
|
+
/// <param name="index"></param>
|
|
126
|
+
/// <remarks>
|
|
127
|
+
///
|
|
128
|
+
/// </remarks>
|
|
129
|
+
protected virtual void SetCurrentChapterByIndex(int index) => SetCurrentChapter(progressionDatabase.Chapters[index]);
|
|
130
|
+
|
|
131
|
+
/// <inheritdoc/>
|
|
132
|
+
public override bool PassedPoint(int chapter, string objectiveName)
|
|
133
|
+
{
|
|
134
|
+
if (currentChapterIndex.Value > chapter)
|
|
135
|
+
return true;
|
|
136
|
+
|
|
137
|
+
if (currentChapterIndex.Value < chapter)
|
|
138
|
+
return false;
|
|
139
|
+
|
|
140
|
+
return ServiceLocator.GetService<IHistory>().ContainsObjective(objectiveName);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// <inheritdoc/>
|
|
144
|
+
public override void SetCurrentChapter(Chapter chapter)
|
|
145
|
+
{
|
|
146
|
+
base.SetCurrentChapter(chapter);
|
|
147
|
+
|
|
148
|
+
currentChapterIndex.SetValue(progressionDatabase.Chapters.IndexOf(chapter));
|
|
149
|
+
|
|
150
|
+
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: The Chapter index has changed to {chapter}.");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// <inheritdoc/>
|
|
154
|
+
public override void SetCurrentObjective(Objective objective)
|
|
155
|
+
{
|
|
156
|
+
base.SetCurrentObjective(objective);
|
|
157
|
+
|
|
158
|
+
bool isFinalObjective = currentObjective.Description == currentChapter.Objectives[^1].Description;
|
|
159
|
+
|
|
160
|
+
onLastObjective.SetValue(isFinalObjective);
|
|
161
|
+
|
|
162
|
+
currentObjectiveIndex.SetValue(currentChapter.Objectives.IndexOf(currentObjective));
|
|
163
|
+
|
|
164
|
+
currentObjectiveName.SetValue(currentObjective.Description);
|
|
165
|
+
|
|
166
|
+
objectiveKeepsInstanceData.SetValue(progressionDatabase.GetObjective(currentObjective.Description).KeepInstanceData);
|
|
167
|
+
|
|
168
|
+
requiredFlagsTriggered.SetValue(false);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// <summary>
|
|
172
|
+
///
|
|
173
|
+
/// </summary>
|
|
174
|
+
protected virtual void ResetProgression()
|
|
175
|
+
{
|
|
176
|
+
SetCurrentChapter(progressionDatabase.Chapters[0]);
|
|
177
|
+
|
|
178
|
+
currentChapterIndex.SetValue(0);
|
|
179
|
+
|
|
180
|
+
SetCurrentObjective((Objective)currentChapter.Objectives[0].Clone());
|
|
181
|
+
|
|
182
|
+
ServiceLocator.GetService<IHistory>().Clear();
|
|
183
|
+
|
|
184
|
+
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: Progression Reset.");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/// <summary>
|
|
188
|
+
///
|
|
189
|
+
/// </summary>
|
|
190
|
+
/// <param name="objective"></param>
|
|
191
|
+
/// <returns></returns>
|
|
192
|
+
protected virtual Objective GetNextObjective(Objective objective)
|
|
193
|
+
{
|
|
194
|
+
for (int i = 0; i < currentChapter.Objectives.Count; i++)
|
|
195
|
+
{
|
|
196
|
+
Objective iteratedObjective = currentChapter.Objectives[i];
|
|
197
|
+
|
|
198
|
+
if (iteratedObjective.Description == objective.Description)
|
|
199
|
+
{
|
|
200
|
+
if (i + 1 < currentChapter.Objectives.Count)
|
|
201
|
+
return currentChapter.Objectives[i + 1];
|
|
202
|
+
else
|
|
203
|
+
{
|
|
204
|
+
MoveToNextChapter();
|
|
205
|
+
|
|
206
|
+
return currentChapter.Objectives[0];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
UnityEngine.Debug.Log($"REPORT: {ToString()}: GetNextObjective Evaluated Null");
|
|
212
|
+
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/// <summary>
|
|
217
|
+
///
|
|
218
|
+
/// </summary>
|
|
219
|
+
protected virtual void MoveToNextChapter()
|
|
220
|
+
{
|
|
221
|
+
for (int i = 0; i < progressionDatabase.Chapters.Count; i++)
|
|
222
|
+
if (progressionDatabase.Chapters[i] == currentChapter && (i + 1) < progressionDatabase.Chapters.Count)
|
|
223
|
+
SetCurrentChapter(progressionDatabase.Chapters[i + 1]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// <summary>
|
|
227
|
+
///
|
|
228
|
+
/// </summary>
|
|
229
|
+
/// <param name="objectiveName"></param>
|
|
230
|
+
protected virtual void MoveToObjective(string objectiveName)
|
|
231
|
+
{
|
|
232
|
+
if (string.IsNullOrEmpty(objectiveName))
|
|
233
|
+
return;
|
|
234
|
+
|
|
235
|
+
ServiceLocator.GetService<IHistory>().Add(currentChapterIndex.Value, currentObjective);
|
|
236
|
+
|
|
237
|
+
Objective objective = progressionDatabase.GetObjective(objectiveName);
|
|
238
|
+
|
|
239
|
+
if (objective == null)
|
|
240
|
+
{
|
|
241
|
+
UnityEngine.Debug.LogError($"ALERT: {ToString()}: " +
|
|
242
|
+
$"The Move to Objective called name does not match any valid objectives, " +
|
|
243
|
+
$"for: " + objectiveName + " . Please make sure the string is spelled correctly and has correct case.");
|
|
244
|
+
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
else
|
|
248
|
+
{
|
|
249
|
+
ServiceLocator.GetService<IHistory>().SetPreviousObjective((Objective)currentObjective.Clone());
|
|
250
|
+
|
|
251
|
+
SetCurrentObjective((Objective)objective.Clone());
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// <summary>
|
|
256
|
+
///
|
|
257
|
+
/// </summary>
|
|
258
|
+
protected virtual void MoveToNextNaturalObjective()
|
|
259
|
+
{
|
|
260
|
+
bool isFTEObjective = currentChapter.GetObjective(currentObjective.Description) == null;
|
|
261
|
+
|
|
262
|
+
if (isFTEObjective)
|
|
263
|
+
SetCurrentObjective((Objective)GetNextObjective(ServiceLocator.GetService<IHistory>().GetLastObjective()).Clone());
|
|
264
|
+
else
|
|
265
|
+
ChangeObjective();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/// <summary>
|
|
269
|
+
///
|
|
270
|
+
/// </summary>
|
|
271
|
+
protected virtual void ChangeObjective()
|
|
272
|
+
{
|
|
273
|
+
UnityEngine.Debug.Log($"REPORT: {nameof(ProgressionManager)}: Changing objective from current objective: "
|
|
274
|
+
+ currentObjective.Description);
|
|
275
|
+
|
|
276
|
+
ServiceLocator.GetService<IHistory>().Add(currentChapterIndex.Value, currentObjective);
|
|
277
|
+
|
|
278
|
+
string overrideFlagObjectiveName = currentObjective.GetOverrideFlag();
|
|
279
|
+
|
|
280
|
+
if (!string.IsNullOrEmpty(overrideFlagObjectiveName))
|
|
281
|
+
SetCurrentObjective((Objective)progressionDatabase.GetObjective(overrideFlagObjectiveName).Clone());
|
|
282
|
+
else
|
|
283
|
+
SetCurrentObjective((Objective)GetNextObjective(currentObjective).Clone());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
286
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 5847fb198f3b4344abce3a75ffe46903
|
|
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: 5847fb198f3b4344abce3a75ffe46903
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|