net.dreditor.chapterselection 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 (67) hide show
  1. package/ChapterSceneByLatestObjective.cs +189 -0
  2. package/ChapterSceneByLatestObjective.cs.meta +2 -0
  3. package/ChapterSceneHandler.cs +152 -0
  4. package/ChapterSceneHandler.cs.meta +11 -0
  5. package/ChapterSectionBase.cs +140 -0
  6. package/ChapterSectionBase.cs.meta +11 -0
  7. package/ChapterSelectCollection.cs +49 -0
  8. package/ChapterSelectCollection.cs.meta +2 -0
  9. package/ChapterSelectCollectionBase.cs +72 -0
  10. package/ChapterSelectCollectionBase.cs.meta +2 -0
  11. package/ChapterSelectData.cs +56 -0
  12. package/ChapterSelectData.cs.meta +11 -0
  13. package/ChapterSelectDatabase.cs +29 -0
  14. package/ChapterSelectDatabase.cs.meta +11 -0
  15. package/ChapterSelectFallbackEvaluator.cs +25 -0
  16. package/ChapterSelectFallbackEvaluator.cs.meta +2 -0
  17. package/ChapterSelectHandler.cs +61 -0
  18. package/ChapterSelectHandler.cs.meta +11 -0
  19. package/ChapterSelectHistoryManager.cs +16 -0
  20. package/ChapterSelectHistoryManager.cs.meta +2 -0
  21. package/ChapterSelectManager.cs +197 -0
  22. package/ChapterSelectManager.cs.meta +11 -0
  23. package/ChapterSelectSaveData.cs +54 -0
  24. package/ChapterSelectSaveData.cs.meta +2 -0
  25. package/ChapterSelectUIHandler.cs +137 -0
  26. package/ChapterSelectUIHandler.cs.meta +11 -0
  27. package/ChapterSubSectionBase.cs +78 -0
  28. package/ChapterSubSectionBase.cs.meta +2 -0
  29. package/DREditor.ChapterSelection.asmdef +20 -0
  30. package/DREditor.ChapterSelection.asmdef.meta +7 -0
  31. package/IChapterSelectData.cs +15 -0
  32. package/IChapterSelectData.cs.meta +2 -0
  33. package/Samples/Animations/ChapSelect.controller +191 -0
  34. package/Samples/Animations/ChapSelect.controller.meta +8 -0
  35. package/Samples/Animations/HideChapterSelect.anim +232 -0
  36. package/Samples/Animations/HideChapterSelect.anim.meta +8 -0
  37. package/Samples/Animations.meta +8 -0
  38. package/Samples/CS_Select_Button_DRE.prefab +305 -0
  39. package/Samples/CS_Select_Button_DRE.prefab.meta +7 -0
  40. package/Samples/Chapter_Scene_UI_Canvas_Shell.prefab +393 -0
  41. package/Samples/Chapter_Scene_UI_Canvas_Shell.prefab.meta +7 -0
  42. package/Samples/Chapter_Scene_UI_Canvas_Template.prefab +771 -0
  43. package/Samples/Chapter_Scene_UI_Canvas_Template.prefab.meta +7 -0
  44. package/Samples/Chapter_Select_Difficulty_UI_Canvas_Template.prefab +226 -0
  45. package/Samples/Chapter_Select_Difficulty_UI_Canvas_Template.prefab.meta +7 -0
  46. package/Samples/Chapter_Select_History_Manager.prefab +98 -0
  47. package/Samples/Chapter_Select_History_Manager.prefab.meta +7 -0
  48. package/Samples/Chapter_Select_System_Shell.prefab +61 -0
  49. package/Samples/Chapter_Select_System_Shell.prefab.meta +7 -0
  50. package/Samples/Chapter_Select_System_Template.prefab +549 -0
  51. package/Samples/Chapter_Select_System_Template.prefab.meta +7 -0
  52. package/Samples/Chapter_Select_UI_Canvas_Shell.prefab +543 -0
  53. package/Samples/Chapter_Select_UI_Canvas_Shell.prefab.meta +7 -0
  54. package/Samples/Chapter_Select_UI_Canvas_Template.prefab +1001 -0
  55. package/Samples/Chapter_Select_UI_Canvas_Template.prefab.meta +7 -0
  56. package/Samples/StartChapterSelectGame.asset +15 -0
  57. package/Samples/StartChapterSelectGame.asset.meta +8 -0
  58. package/Samples.meta +8 -0
  59. package/SceneDataProvider.cs +26 -0
  60. package/SceneDataProvider.cs.meta +11 -0
  61. package/SceneDataProviderBase.cs +37 -0
  62. package/SceneDataProviderBase.cs.meta +11 -0
  63. package/UnlockChapterSelectScene.cs +49 -0
  64. package/UnlockChapterSelectScene.cs.meta +2 -0
  65. package/package.json +37 -6
  66. package/package.json.meta +7 -0
  67. package/README.md +0 -3
@@ -0,0 +1,189 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Progressing;
3
+ using DREditor.Progressing.Handling;
4
+ using DREditor.Saving;
5
+ using DREditor.Services;
6
+ using System;
7
+ using System.Collections;
8
+ using System.Collections.Generic;
9
+ using UnityEngine;
10
+
11
+ namespace DREditor.ChapterSelection
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [ClassHeader(nameof(ChapterSelectFallbackEvaluator) + ", " + nameof(IDRELoadableManager) +
17
+ "\n\n")]
18
+ public class ChapterSceneByLatestObjective : ChapterSelectFallbackEvaluator, IDRELoadableManager
19
+ {
20
+ /// <summary>
21
+ ///
22
+ /// </summary>
23
+ [Tooltip("")]
24
+ [SerializeField] protected ChapterSelectDatabase chapterSelectDatabase = null;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected ProgressionDatabase progressionDatabase = null;
31
+
32
+
33
+ /// <summary>
34
+ ///
35
+ /// </summary>
36
+ [Header("")]
37
+ [Divider]
38
+ [Tooltip("")]
39
+ [SerializeField] protected string objectiveKey = "CurrentObjective";
40
+
41
+ /// <summary>
42
+ ///
43
+ /// </summary>
44
+ [Tooltip("")]
45
+ [SerializeField] protected string progressionDataKey = "ProgressionData";
46
+
47
+ /// <summary>
48
+ ///
49
+ /// </summary>
50
+ [Tooltip("")]
51
+ [SerializeField] protected string deathsKey = "deadList";
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ [Tooltip("")]
57
+ [SerializeField] protected string chapterKey = "chapter";
58
+
59
+
60
+ /// <summary>
61
+ ///
62
+ /// </summary>
63
+ protected Objective loadedCurrentObjective = null;
64
+
65
+ /// <summary>
66
+ ///
67
+ /// </summary>
68
+ protected int loadedProgressionIndex = -1;
69
+
70
+ /// <summary>
71
+ ///
72
+ /// </summary>
73
+ protected List<string> loadedDeaths = new();
74
+
75
+ /// <summary>
76
+ ///
77
+ /// </summary>
78
+ protected int loadedChapter = 0;
79
+
80
+
81
+ /// <inheritdoc/>
82
+ public virtual void LoadManager(Dictionary<string, object> saveDatas, bool inChapterSelect) =>
83
+ StartCoroutine(BufferLoad(saveDatas, inChapterSelect));
84
+
85
+ /// <summary>
86
+ ///
87
+ /// </summary>
88
+ /// <param name="saveDatas"></param>
89
+ /// <param name="inChapterSelect"></param>
90
+ protected virtual IEnumerator BufferLoad(Dictionary<string, object> saveDatas, bool inChapterSelect)
91
+ {
92
+ yield return null;
93
+
94
+ loadedChapter = saveDatas.Get<int>(chapterKey);
95
+
96
+ loadedCurrentObjective = saveDatas.Get<Objective>(objectiveKey);
97
+
98
+ loadedProgressionIndex = ServiceLocator.GetService<IHistory>().GetObjectiveCountFromHistory(loadedChapter) - 1;
99
+
100
+ if (saveDatas.TryGetValue(deathsKey, out object dead) && dead is List<string> deaths)
101
+ loadedDeaths = deaths;
102
+ }
103
+
104
+
105
+ /// <inheritdoc/>
106
+ public override int GetMaxScene(ChapterSectionBase parentSection)
107
+ {
108
+ int loadedObjectiveIndex = progressionDatabase.GetObjectiveInt(loadedChapter, loadedCurrentObjective, loadedProgressionIndex);
109
+
110
+ if (loadedObjectiveIndex < 0)
111
+ UnityEngine.Debug.LogError($"ALERT: Chapter Select: A problem has arisen in the {nameof(ChapterSceneHandler)}");
112
+
113
+ int maxChapter = parentSection.GetMaxSection();
114
+
115
+ Chapter chapter = progressionDatabase.Chapters[maxChapter];
116
+
117
+ for (int i = 0; i < chapterSelectDatabase[maxChapter].GetDataCount(); i++)
118
+ {
119
+ SceneDataProviderBase data = chapterSelectDatabase[maxChapter][i];
120
+
121
+ var saveDict = ((SerializableDictionary)data.GetData()).ToDictionary();
122
+
123
+ Objective saveObjective = chapter.GetObjective(saveDict.Get<Objective>(objectiveKey).Description);
124
+
125
+ int sceneObjectiveIndex = chapter.Objectives.IndexOf(saveObjective);
126
+
127
+ List<string> sceneDeaths = saveDict.Get<List<string>>(deathsKey);
128
+
129
+ if (sceneObjectiveIndex > loadedObjectiveIndex ||
130
+ (sceneObjectiveIndex <= loadedObjectiveIndex && HasMoreDead(sceneDeaths)))
131
+ return chapterSelectDatabase[maxChapter][i - 1].selectScene;
132
+ else if (sceneObjectiveIndex == loadedObjectiveIndex && MatchesDead(sceneDeaths))
133
+ return data.selectScene;
134
+ }
135
+
136
+ return 0;
137
+ }
138
+
139
+ /// <summary>
140
+ ///
141
+ /// </summary>
142
+ /// <param name="sceneDeaths"></param>
143
+ /// <returns></returns>
144
+ protected virtual bool HasMoreDead(List<string> sceneDeaths) => sceneDeaths == null || sceneDeaths.Count > loadedDeaths.Count;
145
+
146
+ /// <summary>
147
+ ///
148
+ /// </summary>
149
+ /// <param name="sceneDeaths"></param>
150
+ /// <returns></returns>
151
+ protected virtual bool MatchesDead(List<string> sceneDeaths) => sceneDeaths == null || sceneDeaths.Count == loadedDeaths.Count;
152
+
153
+
154
+ /// <summary>
155
+ ///
156
+ /// </summary>
157
+ /// <param name="sceneData"></param>
158
+ /// <param name="parentSection"></param>
159
+ /// <returns></returns>
160
+ public override bool SceneIsValid(SceneDataProviderBase sceneData, ChapterSectionBase parentSection)
161
+ {
162
+ if (sceneData.GetData() is SerializableDictionary dataEntries &&
163
+ dataEntries.ToDictionary() is Dictionary<string, object> sceneSaveDatas)
164
+ {
165
+ var sceneObjective = sceneSaveDatas.Get<Objective>(objectiveKey);
166
+
167
+ int sceneObjectiveIndex = progressionDatabase.GetObjectiveIndex(loadedChapter, sceneObjective);
168
+
169
+ try
170
+ {
171
+ int historyObjectiveCount = ServiceLocator.GetService<IHistory>()
172
+ .GetObjectiveCountFromHistory(parentSection.GetSelectedSection());
173
+
174
+ return loadedChapter >= parentSection.DefaultUnlockedSections && sceneObjectiveIndex <= historyObjectiveCount;
175
+ }
176
+ catch (Exception exception)
177
+ {
178
+ UnityEngine.Debug.LogWarning(ToString() + ": ALERT: There was an issue evaluating the progression history.");
179
+
180
+ UnityEngine.Debug.LogException(exception);
181
+
182
+ return false;
183
+ }
184
+ }
185
+
186
+ return false;
187
+ }
188
+ }
189
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: ec6a49c1302708c42b5b5b8752182f52
@@ -0,0 +1,152 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Processables;
3
+ using DREditor.Saving;
4
+ using DREditor.Services;
5
+ using System.Collections.Generic;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.ChapterSelection
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [ClassHeader(nameof(ChapterSubSectionBase) + ", " + nameof(ChapterSectionBase) + ", " + nameof(IDRELoadableManager) +
14
+ "\n\n")]
15
+ public class ChapterSceneHandler : ChapterSubSectionBase
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected ChapterSectionBase parentSection = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected ChapterSelectFallbackEvaluator fallbackEvaluator = null;
28
+
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ protected bool inDefaultMode = false;
34
+
35
+ /// <summary>
36
+ ///
37
+ /// </summary>
38
+ protected ChapterSelectData chapterSelectData = null;
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ protected List<int> moments = new();
44
+
45
+
46
+ /// <inheritdoc/>
47
+ public override void InitializeDefault()
48
+ {
49
+ SetMaxSection(defaultUnlockedSections);
50
+
51
+ inDefaultMode = true;
52
+ }
53
+
54
+ /// <inheritdoc/>
55
+ public override void InitializeLoaded()
56
+ {
57
+ SetMaxSection(GetMaxLoadedScene());
58
+
59
+ inDefaultMode = false;
60
+ }
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ /// <returns></returns>
66
+ protected int GetMaxLoadedScene()
67
+ {
68
+ ServiceLocator.HasService(out IChapterSelectData chapterSelectData);
69
+
70
+ var chapterScenes = chapterSelectDatabase[parentSection.GetMaxSection()].Details;
71
+
72
+ foreach (var scene in chapterScenes)
73
+ if (chapterSelectData is IIdentifiableValidator validator && validator.IDValid(scene.ID))
74
+ return chapterScenes.IndexOf(scene);
75
+
76
+ return fallbackEvaluator.GetMaxScene(parentSection);
77
+ }
78
+
79
+
80
+ #region Evaluate Chapter Scene Moment
81
+
82
+ /// <inheritdoc/>
83
+ public override void OnParentSubmittedIndex(int selectedIndex) => EvaluateChapterScene(selectedIndex);
84
+
85
+ /// <summary>
86
+ ///
87
+ /// </summary>
88
+ /// <param name="currentButtonIndex"></param>
89
+ public virtual void EvaluateChapterScene(int currentButtonIndex)
90
+ {
91
+ chapterSelectData = chapterSelectDatabase[currentButtonIndex];
92
+
93
+ moments.Clear();
94
+
95
+ EvaluateChapterSelectMoments();
96
+
97
+ ActivateValidSceneMoments();
98
+ }
99
+
100
+ /// <summary>
101
+ ///
102
+ /// </summary>
103
+ protected virtual void EvaluateChapterSelectMoments()
104
+ {
105
+ foreach (SceneDataProviderBase sceneData in chapterSelectData)
106
+ CheckValidChapterSceneData(sceneData);
107
+ }
108
+
109
+ /// <summary>
110
+ ///
111
+ /// </summary>
112
+ /// <param name="sceneData"></param>
113
+ protected virtual void CheckValidChapterSceneData(SceneDataProviderBase sceneData)
114
+ {
115
+ bool shouldAdd = chapterSelectData.chapter < parentSection.GetMaxSection() ||
116
+ (inDefaultMode && parentSection.SectionIsDefaultUnlocked() && sceneData.selectScene <= maxSection) ||
117
+ (!inDefaultMode && SceneIsValid(sceneData)) ||
118
+ (!inDefaultMode && sceneData.selectScene <= maxSection);
119
+
120
+ if (shouldAdd)
121
+ moments.Add(sceneData.selectScene);
122
+ }
123
+
124
+ /// <summary>
125
+ ///
126
+ /// </summary>
127
+ /// <param name="sceneData"></param>
128
+ /// <returns></returns>
129
+ protected virtual bool SceneIsValid(SceneDataProviderBase sceneData)
130
+ {
131
+ if (ServiceLocator.HasService(out IChapterSelectData chapterSelectData) &&
132
+ chapterSelectData is IIdentifiableValidator validator)
133
+ return validator.IDValid(sceneData.ID);
134
+
135
+ UnityEngine.Debug.LogWarning("ANALYSIS: CHAPTER SELECT IS USING ITS FALLBACK EVALUATOR.");
136
+
137
+ return fallbackEvaluator != null && fallbackEvaluator.SceneIsValid(sceneData, parentSection);
138
+ }
139
+
140
+
141
+ /// <summary>
142
+ ///
143
+ /// </summary>
144
+ protected virtual void ActivateValidSceneMoments()
145
+ {
146
+ for (int i = 0; i < sectionButtons.Count; i++)
147
+ sectionButtons[i].gameObject.SetActive(moments.Contains(i));
148
+ }
149
+
150
+ #endregion
151
+ }
152
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 412c4018fcce0a14b934b389c0874e96
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,140 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Progressing.Handling;
3
+ using DREditor.Saving;
4
+ using DREditor.Services;
5
+ using System.Collections;
6
+ using System.Collections.Generic;
7
+ using UnityEngine;
8
+ using UnityEngine.UI;
9
+
10
+ namespace DREditor.ChapterSelection
11
+ {
12
+ /// <summary>
13
+ ///
14
+ /// </summary>
15
+ public abstract class ChapterSectionBase : MonoBehaviour, IDRELoadableManager
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected ChapterSelectDatabase chapterSelectDatabase = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected string chapterKey = "chapter";
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Tooltip("")]
33
+ [SerializeField] protected int defaultUnlockedSections = -1;
34
+
35
+ /// <summary>
36
+ ///
37
+ /// </summary>
38
+ [Tooltip("")]
39
+ [SerializeField] protected List<Button> sectionButtons = new();
40
+
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ protected int maxSection = 0;
46
+
47
+ /// <summary>
48
+ ///
49
+ /// </summary>
50
+ protected int selectedSection = 0;
51
+
52
+ /// <summary>
53
+ ///
54
+ /// </summary>
55
+ protected int loadedChapter = 0;
56
+
57
+
58
+ /// <summary>
59
+ ///
60
+ /// </summary>
61
+ public virtual int DefaultUnlockedSections { get => defaultUnlockedSections; set => defaultUnlockedSections = value; }
62
+
63
+
64
+ /// <summary>
65
+ ///
66
+ /// </summary>
67
+ /// <returns></returns>
68
+ public virtual int GetSelectedSection() => selectedSection;
69
+
70
+ /// <summary>
71
+ ///
72
+ /// </summary>
73
+ /// <returns></returns>
74
+ public virtual int GetMaxSection() => maxSection;
75
+
76
+ /// <summary>
77
+ ///
78
+ /// </summary>
79
+ /// <param name="maxSection"></param>
80
+ protected virtual void SetMaxSection(int maxSection) => this.maxSection = maxSection;
81
+
82
+
83
+ /// <summary>
84
+ ///
85
+ /// </summary>
86
+ /// <param name="selectedIndex"></param>
87
+ public abstract void OnParentSubmittedIndex(int selectedIndex);
88
+
89
+ /// <summary>
90
+ ///
91
+ /// </summary>
92
+ public abstract void InitializeDefault();
93
+
94
+ /// <summary>
95
+ ///
96
+ /// </summary>
97
+ public abstract void InitializeLoaded();
98
+
99
+
100
+ /// <summary>
101
+ ///
102
+ /// </summary>
103
+ /// <returns></returns>
104
+ public virtual bool AllowsChapterSelect() => DefaultUnlockedSections >= 0;
105
+
106
+ /// <summary>
107
+ ///
108
+ /// </summary>
109
+ /// <remarks>
110
+ ///
111
+ /// </remarks>
112
+ /// <param name="button"></param>
113
+ public virtual void SetSelectedSection(Button button) => selectedSection = sectionButtons.IndexOf(button);
114
+
115
+ /// <summary>
116
+ ///
117
+ /// </summary>
118
+ /// <returns></returns>
119
+ public virtual bool SectionIsDefaultUnlocked() => selectedSection == DefaultUnlockedSections;
120
+
121
+
122
+ /// <inheritdoc/>
123
+ public virtual void LoadManager(Dictionary<string, object> saveDatas, bool inChapterSelect) =>
124
+ StartCoroutine(BufferLoad(saveDatas, inChapterSelect));
125
+
126
+ /// <summary>
127
+ ///
128
+ /// </summary>
129
+ /// <param name="saveDatas"></param>
130
+ /// <param name="inChapterSelect"></param>
131
+ protected virtual IEnumerator BufferLoad(Dictionary<string, object> saveDatas, bool inChapterSelect)
132
+ {
133
+ yield return null;
134
+
135
+ var historyChapter = ServiceLocator.GetService<IHistory>().LatestChapterIndex();
136
+
137
+ loadedChapter = historyChapter >= 0 ? historyChapter : saveDatas.Get<int>(chapterKey);
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9570f14d0f8e0d84ebbf8b135dc8f99c
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,49 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+ using UnityEngine.Serialization;
6
+
7
+ namespace DREditor.ChapterSelection
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ /// <typeparam name="T"></typeparam>
13
+ public abstract class ChapterSelectCollection<T> : ChapterSelectCollectionBase, IEnumerable<T>
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [FormerlySerializedAs("ChapterScenes")]
19
+ [FormerlySerializedAs("ChapterDatas")]
20
+ [Tooltip("")]
21
+ [SerializeField] protected List<T> chapterSelectDetails = new();
22
+
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ public virtual List<T> Details => chapterSelectDetails;
28
+
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ /// <param name="i"></param>
34
+ /// <returns></returns>
35
+ public virtual T this[int i] => chapterSelectDetails[i];
36
+
37
+
38
+ public override IList GetCollection() => Details;
39
+
40
+
41
+ public virtual IEnumerator<T> GetEnumerator()
42
+ {
43
+ foreach (var detail in chapterSelectDetails)
44
+ yield return detail;
45
+ }
46
+
47
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 5f724ca25b6a1e64d82a799bccf1eeaf
@@ -0,0 +1,72 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.ChapterSelection
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ public abstract class ChapterSelectCollectionBase : ScriptableObject
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ /// <typeparam name="T"></typeparam>
17
+ /// <param name="collection"></param>
18
+ /// <returns></returns>
19
+ public virtual bool TryGetCollection<T>(out List<T> collection)
20
+ {
21
+ collection = GetCollection() is List<T> castedCollection ? castedCollection : null;
22
+
23
+ bool result = collection != null;
24
+
25
+ if (!result)
26
+ Debug.LogWarning($"ALERT: {name}'s collection is not of type: {typeof(T).Name}!");
27
+
28
+ return result;
29
+ }
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ /// <returns></returns>
35
+ public abstract IList GetCollection();
36
+
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ /// <returns></returns>
42
+ public virtual bool IsEmpty() => CollectionCountEmpty() || ChildrenAreEmpty();
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ /// <returns></returns>
48
+ protected virtual bool ChildrenAreEmpty()
49
+ {
50
+ IList collection = GetCollection();
51
+
52
+ foreach (var item in collection)
53
+ if (item is ChapterSelectCollectionBase childCollection && childCollection.IsEmpty())
54
+ return true;
55
+
56
+ return false;
57
+ }
58
+
59
+ /// <summary>
60
+ ///
61
+ /// </summary>
62
+ /// <returns></returns>
63
+ private bool CollectionCountEmpty() => GetDataCount() == 0;
64
+
65
+
66
+ /// <summary>
67
+ ///
68
+ /// </summary>
69
+ /// <returns></returns>
70
+ public virtual int GetDataCount() => GetCollection().Count;
71
+ }
72
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 509cf55ecda99624e808590ba1447dab