net.dreditor.chapterselection 0.1.6 → 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.
Files changed (67) hide show
  1. package/.attestation.p7m +0 -0
  2. package/ChapterSceneByLatestObjective.cs +188 -188
  3. package/ChapterSceneByLatestObjective.cs.meta +1 -1
  4. package/ChapterSceneHandler.cs +151 -151
  5. package/ChapterSceneHandler.cs.meta +11 -11
  6. package/ChapterSectionBase.cs +139 -139
  7. package/ChapterSectionBase.cs.meta +11 -11
  8. package/ChapterSelectCollection.cs +48 -48
  9. package/ChapterSelectCollection.cs.meta +1 -1
  10. package/ChapterSelectCollectionBase.cs +71 -71
  11. package/ChapterSelectCollectionBase.cs.meta +1 -1
  12. package/ChapterSelectData.cs +55 -55
  13. package/ChapterSelectData.cs.meta +11 -11
  14. package/ChapterSelectDatabase.cs +28 -28
  15. package/ChapterSelectDatabase.cs.meta +11 -11
  16. package/ChapterSelectFallbackEvaluator.cs +24 -24
  17. package/ChapterSelectFallbackEvaluator.cs.meta +1 -1
  18. package/ChapterSelectHandler.cs +60 -60
  19. package/ChapterSelectHandler.cs.meta +11 -11
  20. package/ChapterSelectHistoryManager.cs +15 -15
  21. package/ChapterSelectHistoryManager.cs.meta +1 -1
  22. package/ChapterSelectManager.cs +196 -196
  23. package/ChapterSelectManager.cs.meta +11 -11
  24. package/ChapterSelectSaveData.cs +53 -53
  25. package/ChapterSelectSaveData.cs.meta +1 -1
  26. package/ChapterSelectUIHandler.cs +136 -136
  27. package/ChapterSelectUIHandler.cs.meta +11 -11
  28. package/ChapterSubSectionBase.cs +77 -77
  29. package/ChapterSubSectionBase.cs.meta +1 -1
  30. package/DREditor.ChapterSelection.asmdef +19 -19
  31. package/DREditor.ChapterSelection.asmdef.meta +7 -7
  32. package/IChapterSelectData.cs +14 -14
  33. package/IChapterSelectData.cs.meta +1 -1
  34. package/{Samples → Samples~}/Animations/ChapSelect.controller +191 -191
  35. package/{Samples → Samples~}/Animations/ChapSelect.controller.meta +8 -8
  36. package/{Samples → Samples~}/Animations/HideChapterSelect.anim +232 -232
  37. package/{Samples → Samples~}/Animations/HideChapterSelect.anim.meta +8 -8
  38. package/{Samples → Samples~}/Animations.meta +8 -8
  39. package/{Samples → Samples~}/CS_Select_Button_DRE.prefab +305 -305
  40. package/{Samples → Samples~}/CS_Select_Button_DRE.prefab.meta +7 -7
  41. package/{Samples → Samples~}/Chapter_Scene_UI_Canvas_Shell.prefab +393 -393
  42. package/{Samples → Samples~}/Chapter_Scene_UI_Canvas_Shell.prefab.meta +7 -7
  43. package/{Samples → Samples~}/Chapter_Scene_UI_Canvas_Template.prefab +771 -771
  44. package/{Samples → Samples~}/Chapter_Scene_UI_Canvas_Template.prefab.meta +7 -7
  45. package/{Samples → Samples~}/Chapter_Select_Difficulty_UI_Canvas_Template.prefab +226 -226
  46. package/{Samples → Samples~}/Chapter_Select_Difficulty_UI_Canvas_Template.prefab.meta +7 -7
  47. package/{Samples → Samples~}/Chapter_Select_History_Manager.prefab +98 -98
  48. package/{Samples → Samples~}/Chapter_Select_History_Manager.prefab.meta +7 -7
  49. package/{Samples → Samples~}/Chapter_Select_System_Shell.prefab +61 -61
  50. package/{Samples → Samples~}/Chapter_Select_System_Shell.prefab.meta +7 -7
  51. package/{Samples → Samples~}/Chapter_Select_System_Template.prefab +549 -549
  52. package/{Samples → Samples~}/Chapter_Select_System_Template.prefab.meta +7 -7
  53. package/{Samples → Samples~}/Chapter_Select_UI_Canvas_Shell.prefab +543 -543
  54. package/{Samples → Samples~}/Chapter_Select_UI_Canvas_Shell.prefab.meta +7 -7
  55. package/{Samples → Samples~}/Chapter_Select_UI_Canvas_Template.prefab +1001 -1001
  56. package/{Samples → Samples~}/Chapter_Select_UI_Canvas_Template.prefab.meta +7 -7
  57. package/{Samples → Samples~}/StartChapterSelectGame.asset +15 -15
  58. package/{Samples → Samples~}/StartChapterSelectGame.asset.meta +8 -8
  59. package/SceneDataProvider.cs +25 -25
  60. package/SceneDataProvider.cs.meta +11 -11
  61. package/SceneDataProviderBase.cs +36 -36
  62. package/SceneDataProviderBase.cs.meta +11 -11
  63. package/UnlockChapterSelectScene.cs +48 -48
  64. package/UnlockChapterSelectScene.cs.meta +1 -1
  65. package/package.json +42 -37
  66. package/package.json.meta +7 -7
  67. package/Samples.meta +0 -8
Binary file
@@ -1,189 +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
- }
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
189
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: ec6a49c1302708c42b5b5b8752182f52