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,56 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.ChapterSelection
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [Serializable]
12
+ [CreateAssetMenu(menuName = "DREditor/Chapter Select/Data", fileName = "Chapter Select Data")]
13
+ public class ChapterSelectData : ChapterSelectCollection<SceneDataProviderBase>
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [Header("")]
19
+ [Divider]
20
+ [Tooltip("")]
21
+ public int chapter;
22
+
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ /// <param name="queue"></param>
28
+ /// <returns></returns>
29
+ public virtual object GetChapterSelectData(Queue<int> queue)
30
+ {
31
+ int selectedScene = queue.Dequeue();
32
+
33
+ int useIndex = GetIndexOfSelectScene(selectedScene);
34
+
35
+ var data = chapterSelectDetails[useIndex];
36
+
37
+ return data;
38
+ }
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ /// <returns></returns>
44
+ protected virtual int GetIndexOfSelectScene(int selectedEnd)
45
+ {
46
+ foreach (var sceneData in chapterSelectDetails)
47
+ if (sceneData.selectScene == selectedEnd)
48
+ return chapterSelectDetails.IndexOf(sceneData);
49
+
50
+ UnityEngine.Debug.LogWarning("Chapter Select: ALERT: " +
51
+ "Using default end because it couldn't find a matching select scene!");
52
+
53
+ return selectedEnd;
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d22c19dc12cab4f47a81b9d9aecd90d1
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,29 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.ChapterSelection
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [Serializable]
12
+ [CreateAssetMenu(menuName = "DREditor/Chapter Select/Database", fileName = "Chapter Select Database")]
13
+ public class ChapterSelectDatabase : ChapterSelectCollection<ChapterSelectData>
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ /// <param name="queue"></param>
19
+ /// <returns></returns>
20
+ public virtual object GetChapterSelectData(Queue<int> queue)
21
+ {
22
+ int selectedChapter = queue.Dequeue();
23
+
24
+ var data = chapterSelectDetails[selectedChapter].GetChapterSelectData(queue);
25
+
26
+ return data;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: bcf1bac9a9d150141a81447013be69ed
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,25 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+
4
+ namespace DREditor.ChapterSelection
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public abstract class ChapterSelectFallbackEvaluator : MonoBehaviour
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ /// <returns></returns>
15
+ public abstract int GetMaxScene(ChapterSectionBase parentSection);
16
+
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ /// <param name="sceneData"></param>
21
+ /// <param name="parentSection"></param>
22
+ /// <returns></returns>
23
+ public abstract bool SceneIsValid(SceneDataProviderBase sceneData, ChapterSectionBase parentSection);
24
+ }
25
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: c8b2f118336b116488561dc5f0c059f2
@@ -0,0 +1,61 @@
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
+
6
+ namespace DREditor.ChapterSelection
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [ClassHeader(nameof(ChapterSectionBase) + ", " + nameof(IDRELoadableManager) +
12
+ "\n\n")]
13
+ public class ChapterSelectHandler : ChapterSectionBase
14
+ {
15
+ /// <inheritdoc/>
16
+ public override void OnParentSubmittedIndex(int selectedIndex) => selectedSection = selectedIndex;
17
+
18
+ /// <inheritdoc/>
19
+ public override void InitializeDefault()
20
+ {
21
+ SetMaxSection(defaultUnlockedSections);
22
+
23
+ ActivateValidChapterButtons();
24
+ }
25
+
26
+ /// <inheritdoc/>
27
+ public override void InitializeLoaded()
28
+ {
29
+ SetMaxSection(GetMaxLoadedScene());
30
+
31
+ ActivateValidChapterButtons();
32
+ }
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ /// <returns></returns>
38
+ protected int GetMaxLoadedScene()
39
+ {
40
+ ServiceLocator.HasService(out IChapterSelectData chapterSelectData);
41
+
42
+ int maxLoadedIndex = -1;
43
+
44
+ foreach (var section in chapterSelectDatabase)
45
+ foreach (var scene in section)
46
+ if (chapterSelectData is IIdentifiableValidator validator && validator.IDValid(scene.ID))
47
+ maxLoadedIndex = chapterSelectDatabase.Details.IndexOf(section);
48
+
49
+ return maxLoadedIndex != -1? maxLoadedIndex : loadedChapter;
50
+ }
51
+
52
+ /// <summary>
53
+ ///
54
+ /// </summary>
55
+ protected virtual void ActivateValidChapterButtons()
56
+ {
57
+ for (int i = 0; i < sectionButtons.Count; i++)
58
+ sectionButtons[i].gameObject.SetActive(i <= maxSection);
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4be033c20999ed448a947fba1571ac1b
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,16 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Progressing.Handling;
3
+ using DREditor.Saving;
4
+
5
+ namespace DREditor.ChapterSelection
6
+ {
7
+ /// <summary>
8
+ ///
9
+ /// </summary>
10
+ [ClassHeader(nameof(HistoricalManagerBase<IChapterSelectData, ChapterSelectHistoryManager>) +
11
+ " SERVICE for type: " + nameof(IChapterSelectData) +
12
+ "\n" + nameof(IDRESaveable) + ", " + nameof(IDRELoadableManager) + ", " +
13
+ nameof(IDRELoadable) + ", " + nameof(ILoadOnChapterSelect) +
14
+ "\n\n")]
15
+ public class ChapterSelectHistoryManager : HistoricalManagerBase<IChapterSelectData, ChapterSelectHistoryManager> { }
16
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 83e24f8e3cd433a4b815bb21733e3901
@@ -0,0 +1,197 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using DREditor.EventObjects;
4
+ using DREditor.Progressing;
5
+ using DREditor.Saving;
6
+ using DREditor.UI;
7
+ using System;
8
+ using System.Collections.Generic;
9
+ using System.Linq;
10
+ using UnityEngine;
11
+ using UnityEngine.UI;
12
+
13
+ namespace DREditor.ChapterSelection
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [ClassHeader(nameof(SceneEventListener) +
19
+ "\n\n")]
20
+ public class ChapterSelectManager : SceneEventListener
21
+ {
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ [Tooltip("")]
26
+ [SerializeField] protected ChapterSelectDatabase chapterSelectDatabase = null;
27
+
28
+ /// <summary>
29
+ ///
30
+ /// </summary>
31
+ [Tooltip("")]
32
+ [SerializeField] protected Button chapSelectButton = null;
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ [Tooltip("")]
38
+ [SerializeField] protected ProgressionDatabase progressionDatabase = null;
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ [Tooltip("")]
44
+ [SerializeField] protected List<ChapterSectionBase> chapterSections = new();
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Tooltip("")]
50
+ [SerializeField] protected BoolWithEvent hasLoadedSaveData = null;
51
+
52
+ /// <summary>
53
+ ///
54
+ /// </summary>
55
+ [Tooltip("")]
56
+ [SerializeField] protected MenuGroupBase backGroup = null;
57
+
58
+ /// <summary>
59
+ ///
60
+ /// </summary>
61
+ [Tooltip("")]
62
+ [SerializeField] protected string loadGameEventString = "LoadGameFromData";
63
+
64
+
65
+ /// <summary>
66
+ ///
67
+ /// </summary>
68
+ protected override void OnEnable()
69
+ {
70
+ base.OnEnable();
71
+
72
+ backGroup.BeforeStart.AddListener(SetChapterSelectButtonInteractibility);
73
+
74
+ chapSelectButton.onClick.AddListener(EvaluateAvailableChapterSelection);
75
+
76
+ Response?.AddListener(StartChapterSelectGame);
77
+ }
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ protected override void OnDisable()
83
+ {
84
+ base.OnDisable();
85
+
86
+ backGroup.BeforeStart.RemoveListener(SetChapterSelectButtonInteractibility);
87
+
88
+ chapSelectButton.onClick.RemoveListener(EvaluateAvailableChapterSelection);
89
+
90
+ Response?.RemoveListener(StartChapterSelectGame);
91
+ }
92
+
93
+ /// <summary>
94
+ ///
95
+ /// </summary>
96
+ protected virtual void SetChapterSelectButtonInteractibility()
97
+ => chapSelectButton.interactable = PlayerCanUseChapterSelect();
98
+
99
+ /// <summary>
100
+ ///
101
+ /// </summary>
102
+ /// <returns></returns>
103
+ protected virtual bool PlayerCanUseChapterSelect() =>
104
+ DatabaseIsValid() && (HandlersAllowChapterSelect() || PlayerHasLoadedSaveData());
105
+
106
+ /// <summary>
107
+ ///
108
+ /// </summary>
109
+ /// <returns></returns>
110
+ protected virtual bool DatabaseIsValid() => chapterSelectDatabase != null && !chapterSelectDatabase.IsEmpty();
111
+
112
+ /// <summary>
113
+ ///
114
+ /// </summary>
115
+ /// <returns></returns>
116
+ protected virtual bool HandlersAllowChapterSelect()
117
+ {
118
+ foreach (ChapterSectionBase section in chapterSections)
119
+ if (!section.AllowsChapterSelect())
120
+ return false;
121
+
122
+ return true;
123
+ }
124
+
125
+ /// <summary>
126
+ ///
127
+ /// </summary>
128
+ /// <returns></returns>
129
+ protected virtual bool PlayerHasLoadedSaveData() => hasLoadedSaveData.Value;
130
+
131
+
132
+ /// <summary>
133
+ ///
134
+ /// </summary>
135
+ /// <remarks></remarks>
136
+ public virtual void EvaluateAvailableChapterSelection()
137
+ {
138
+ foreach (ChapterSectionBase section in chapterSections)
139
+ section.OnParentSubmittedIndex(0);
140
+
141
+ if (hasLoadedSaveData.Value)
142
+ LoadedSaveChapterSelect();
143
+ else
144
+ DefaultChapterSelect();
145
+ }
146
+
147
+ /// <summary>
148
+ ///
149
+ /// </summary>
150
+ protected virtual void LoadedSaveChapterSelect()
151
+ {
152
+ UnityEngine.Debug.Log("Chapter Select: Used Load File Evaluation.");
153
+
154
+ foreach (ChapterSectionBase section in chapterSections)
155
+ section.InitializeLoaded();
156
+ }
157
+
158
+ /// <summary>
159
+ ///
160
+ /// </summary>
161
+ protected virtual void DefaultChapterSelect()
162
+ {
163
+ UnityEngine.Debug.Log("Chapter Select: Used Default Max Settings");
164
+
165
+ foreach (ChapterSectionBase section in chapterSections)
166
+ section.InitializeDefault();
167
+ }
168
+
169
+
170
+ // Investigate whether this code is to be used.
171
+
172
+ /// <summary>
173
+ ///
174
+ /// </summary>
175
+ /// <remarks>
176
+ ///
177
+ /// </remarks>
178
+ public virtual void StartChapterSelectGame()
179
+ {
180
+ Queue<int> queue = new(chapterSections.Select(section => section.GetSelectedSection()));
181
+
182
+ SceneDataProviderBase data = (SceneDataProviderBase)chapterSelectDatabase.GetChapterSelectData(queue);
183
+
184
+ try
185
+ {
186
+ DialogueEventSystem.TriggerEvent(loadGameEventString, (SerializableDictionary)data.GetData());
187
+ }
188
+ catch (Exception exception)
189
+ {
190
+ UnityEngine.Debug.LogError("Couldn't set Chapter select data: Selection order: " + string.Join(", ", queue) +
191
+ " \n " + exception.ToString());
192
+
193
+ UnityEngine.Debug.LogException(exception);
194
+ }
195
+ }
196
+ }
197
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9b8228a552a3d4748afa8844f4a338ff
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,54 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Processables;
3
+ using DREditor.Progressing;
4
+ using DREditor.Saving;
5
+ using System;
6
+ using System.Collections.Generic;
7
+
8
+ namespace DREditor.ChapterSelection
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [Serializable]
14
+ public class ChapterSelectSaveData : IChapterSelectData, IIdentifiableValidator, IPersistentData, IClearableOnNewGameSelected
15
+ {
16
+ public List<int> unlockedScenes = new();
17
+
18
+ public ChapterSelectSaveData() { }
19
+
20
+
21
+ /// <inheritdoc/>
22
+ public virtual void Add(object obj)
23
+ {
24
+ if (obj is int ID)
25
+ UnlockSceneID(ID);
26
+ else
27
+ OnUnexpectedTypeAdded(obj);
28
+ }
29
+
30
+ protected virtual void OnUnexpectedTypeAdded(object obj) =>
31
+ UnityEngine.Debug.LogWarning($"ALERT: ");
32
+
33
+ protected virtual void UnlockSceneID(int ID)
34
+ {
35
+ if (!IDValid(ID))
36
+ unlockedScenes.Add(ID);
37
+ }
38
+
39
+ /// <inheritdoc/>
40
+ public virtual bool IDValid(int ID) => unlockedScenes.Contains(ID);
41
+
42
+ /// <inheritdoc/>
43
+ public virtual void CarryOver(IPersistentData persistentData)
44
+ {
45
+ if (persistentData is ChapterSelectSaveData oldData)
46
+ unlockedScenes = oldData.unlockedScenes;
47
+ else
48
+ UnityEngine.Debug.LogWarning("ALERT: TRIED TO SET CHAPTER SELECT DATA OF A DIFFERENT TYPE!");
49
+ }
50
+
51
+ /// <inheritdoc/>
52
+ public virtual void Clear() => unlockedScenes.Clear();
53
+ }
54
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 51ffd7f1d92128a46acf521d8937185f
@@ -0,0 +1,137 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.UI;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+ using UnityEngine.Events;
6
+ using UnityEngine.InputSystem;
7
+ using static UnityEngine.InputSystem.InputAction;
8
+
9
+ namespace DREditor.ChapterSelection
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(IndexSelector) +
15
+ "\n\n")]
16
+ public class ChapterSelectUIHandler : IndexSelector
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Tooltip("")]
22
+ [SerializeField] protected InputActionReference submit = null;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ [Tooltip("")]
28
+ [SerializeField] protected InputActionReference navigate = null;
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ [Tooltip("")]
34
+ [SerializeField] protected ChapterSelectCollectionBase chapterSelectDatabase = null;
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ [Tooltip("")]
40
+ [SerializeField] protected MenuGroupBase menuGroup = null;
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ [Tooltip("")]
46
+ [SerializeField] protected ChapterSectionBase modifyingSection = null;
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ [Tooltip("")]
52
+ [SerializeField] protected List<ChapterSectionBase> chapterSections = new();
53
+
54
+
55
+ [Header("")]
56
+ [Divider]
57
+ [Header("")]
58
+ [SerializeField] protected UnityEvent OnSubmit;
59
+
60
+
61
+ public override int SelectionMaximum { get => GetMaxSection(); set => base.SelectionMaximum = value; }
62
+
63
+
64
+ /// <summary>
65
+ ///
66
+ /// </summary>
67
+ protected override void OnEnable()
68
+ {
69
+ base.OnEnable();
70
+
71
+ menuGroup.StartEvents.AddListener(ActivateControls);
72
+
73
+ menuGroup.EndEvents.AddListener(DeactivateControls);
74
+ }
75
+
76
+ /// <summary>
77
+ ///
78
+ /// </summary>
79
+ protected override void OnDisable()
80
+ {
81
+ base.OnDisable();
82
+
83
+ menuGroup.StartEvents.RemoveListener(ActivateControls);
84
+
85
+ menuGroup.EndEvents.RemoveListener(DeactivateControls);
86
+ }
87
+
88
+ /// <inheritdoc/>
89
+ public override void ActivateControls()
90
+ {
91
+ navigate.action.performed += EvaluateChapter;
92
+
93
+ submit.action.started += InvokeSubmit;
94
+ }
95
+
96
+ /// <inheritdoc/>
97
+ public override void DeactivateControls()
98
+ {
99
+ navigate.action.performed -= EvaluateChapter;
100
+
101
+ submit.action.started -= InvokeSubmit;
102
+ }
103
+
104
+ /// <summary>
105
+ ///
106
+ /// </summary>
107
+ /// <param name="ctx"></param>
108
+ protected virtual void EvaluateChapter(CallbackContext ctx) => Move((int)ctx.ReadValue<Vector2>().x);
109
+
110
+ /// <summary>
111
+ ///
112
+ /// </summary>
113
+ /// <returns></returns>
114
+ protected virtual int GetMaxSection() =>
115
+ modifyingSection != null ? modifyingSection.GetMaxSection() : chapterSelectDatabase.GetDataCount() - 1;
116
+
117
+ /// <summary>
118
+ ///
119
+ /// </summary>
120
+ /// <param name="ctx"></param>
121
+ protected virtual void InvokeSubmit(CallbackContext ctx)
122
+ {
123
+ SubmitSectionIndex();
124
+
125
+ OnSubmit.Invoke();
126
+ }
127
+
128
+ /// <summary>
129
+ ///
130
+ /// </summary>
131
+ protected virtual void SubmitSectionIndex()
132
+ {
133
+ foreach (ChapterSectionBase section in chapterSections)
134
+ section.OnParentSubmittedIndex(SelectedIndex);
135
+ }
136
+ }
137
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4af7ab2389efc884eb0d95543a08caab
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: