net.dreditor.roomloading 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.
Files changed (144) hide show
  1. package/.attestation.p7m +0 -0
  2. package/CheckThreeDModeDuringLoad.cs +63 -63
  3. package/CheckThreeDModeDuringLoad.cs.meta +11 -11
  4. package/DRERoomTransition.cs +115 -115
  5. package/DRERoomTransition.cs.meta +11 -11
  6. package/DREStartAloneScene.cs +178 -178
  7. package/DREStartAloneScene.cs.meta +11 -11
  8. package/DREditor.RoomLoading.asmdef +23 -23
  9. package/DREditor.RoomLoading.asmdef.meta +7 -7
  10. package/DialogueRoomLoader.cs +187 -187
  11. package/DialogueRoomLoader.cs.meta +11 -11
  12. package/FadeOnEndTransitionFromSave.cs +204 -204
  13. package/FadeOnEndTransitionFromSave.cs.meta +11 -11
  14. package/FadeOutGeneratePastOnDebugTest.cs +96 -96
  15. package/FadeOutGeneratePastOnDebugTest.cs.meta +11 -11
  16. package/FadeOutOnRoomLoad.cs +74 -74
  17. package/FadeOutOnRoomLoad.cs.meta +11 -11
  18. package/FreezeColorRoomTransition.cs +185 -185
  19. package/FreezeColorRoomTransition.cs.meta +11 -11
  20. package/IPostTransitionRoutine.cs +17 -17
  21. package/IPostTransitionRoutine.cs.meta +11 -11
  22. package/IRoomLoadResolver.cs +14 -14
  23. package/IRoomLoadResolver.cs.meta +11 -11
  24. package/IRoomLoadRoutine.cs +16 -16
  25. package/IRoomLoadRoutine.cs.meta +11 -11
  26. package/IRoomTransition.cs +38 -38
  27. package/IRoomTransition.cs.meta +11 -11
  28. package/ITeleporter.cs +23 -23
  29. package/ITeleporter.cs.meta +11 -11
  30. package/InstanceManagerBase.cs +130 -130
  31. package/InstanceManagerBase.cs.meta +11 -11
  32. package/KeepStateAfterObjective.cs +73 -73
  33. package/KeepStateAfterObjective.cs.meta +11 -11
  34. package/MoveEndOnDialogueFinish.cs +130 -130
  35. package/MoveEndOnDialogueFinish.cs.meta +11 -11
  36. package/PastPointData.cs +43 -43
  37. package/PastPointData.cs.meta +11 -11
  38. package/PrepareTPFDOnLoadingRoom.cs +67 -67
  39. package/PrepareTPFDOnLoadingRoom.cs.meta +11 -11
  40. package/ResolveRoomLoadStates.cs +94 -94
  41. package/ResolveRoomLoadStates.cs.meta +11 -11
  42. package/RoomChanger.cs +264 -264
  43. package/RoomChanger.cs.meta +11 -11
  44. package/RoomChangerBase.cs +84 -84
  45. package/RoomChangerBase.cs.meta +11 -11
  46. package/RoomChangerLoader.cs +89 -89
  47. package/RoomChangerLoader.cs.meta +11 -11
  48. package/RoomLoadComponent.cs +12 -12
  49. package/RoomLoadComponent.cs.meta +11 -11
  50. package/RoomLoadFinisher.cs +80 -80
  51. package/RoomLoadFinisher.cs.meta +11 -11
  52. package/RoomLoadOptionsAsset.cs +44 -44
  53. package/RoomLoadOptionsAsset.cs.meta +11 -11
  54. package/RoomLoader.cs +264 -264
  55. package/RoomLoader.cs.meta +11 -11
  56. package/RoomLoaderBase.cs +86 -86
  57. package/RoomLoaderBase.cs.meta +11 -11
  58. package/RoomLoaderDebugger.cs +150 -150
  59. package/RoomLoaderDebugger.cs.meta +11 -11
  60. package/RoomLoaderHolder.cs +9 -9
  61. package/RoomLoaderHolder.cs.meta +11 -11
  62. package/{Samples → Samples~}/BlackTransitionOnlyOption.asset +18 -18
  63. package/{Samples → Samples~}/BlackTransitionOnlyOption.asset.meta +8 -8
  64. package/{Samples → Samples~}/BlackTransitionToInvestigationOption.asset +18 -18
  65. package/{Samples → Samples~}/BlackTransitionToInvestigationOption.asset.meta +8 -8
  66. package/{Samples → Samples~}/Check_ThreeD_Mode_During_Load.prefab +49 -49
  67. package/{Samples → Samples~}/Check_ThreeD_Mode_During_Load.prefab.meta +7 -7
  68. package/{Samples → Samples~}/DRE_Start_Alone_Scene.prefab +148 -148
  69. package/{Samples → Samples~}/DRE_Start_Alone_Scene.prefab.meta +7 -7
  70. package/{Samples → Samples~}/Dialogue_Room_Loader.prefab +55 -55
  71. package/{Samples → Samples~}/Dialogue_Room_Loader.prefab.meta +7 -7
  72. package/{Samples → Samples~}/FadeOutBlackTransitionOption.asset +18 -18
  73. package/{Samples → Samples~}/FadeOutBlackTransitionOption.asset.meta +8 -8
  74. package/{Samples → Samples~}/Fade_On_End_Transition_From_Save.prefab +145 -145
  75. package/{Samples → Samples~}/Fade_On_End_Transition_From_Save.prefab.meta +7 -7
  76. package/{Samples → Samples~}/Fade_Out_Generate_Past_On_Debug_Test.prefab +139 -139
  77. package/{Samples → Samples~}/Fade_Out_Generate_Past_On_Debug_Test.prefab.meta +7 -7
  78. package/{Samples → Samples~}/Fade_Out_On_Room_Load.prefab +137 -137
  79. package/{Samples → Samples~}/Fade_Out_On_Room_Load.prefab.meta +7 -7
  80. package/{Samples → Samples~}/Freeze_Transition_Canvas.prefab +300 -300
  81. package/{Samples → Samples~}/Freeze_Transition_Canvas.prefab.meta +7 -7
  82. package/{Samples → Samples~}/IsLoadingToRoom.asset +19 -19
  83. package/{Samples → Samples~}/IsLoadingToRoom.asset.meta +8 -8
  84. package/{Samples → Samples~}/Move_End_On_Dialogue_Finish.prefab +52 -52
  85. package/{Samples → Samples~}/Move_End_On_Dialogue_Finish.prefab.meta +7 -7
  86. package/{Samples → Samples~}/OnFadingOutOfLoading.asset +15 -15
  87. package/{Samples → Samples~}/OnFadingOutOfLoading.asset.meta +8 -8
  88. package/{Samples → Samples~}/OnFinishedLoadingRoom.asset +14 -14
  89. package/{Samples → Samples~}/OnFinishedLoadingRoom.asset.meta +8 -8
  90. package/{Samples → Samples~}/OnLoadingThreeDRoom.asset +14 -14
  91. package/{Samples → Samples~}/OnLoadingThreeDRoom.asset.meta +8 -8
  92. package/{Samples → Samples~}/OnLoadingThreeDRoomListener.prefab +51 -51
  93. package/{Samples → Samples~}/OnLoadingThreeDRoomListener.prefab.meta +7 -7
  94. package/{Samples → Samples~}/On_Finished_Loading_Room_Listener.prefab +51 -51
  95. package/{Samples → Samples~}/On_Finished_Loading_Room_Listener.prefab.meta +7 -7
  96. package/{Samples → Samples~}/On_Finished_Loading_Room_No_Dialogue_Listener.prefab +51 -51
  97. package/{Samples → Samples~}/On_Finished_Loading_Room_No_Dialogue_Listener.prefab.meta +7 -7
  98. package/{Samples → Samples~}/On_Finished_Room_Transitions_Listener.prefab +51 -51
  99. package/{Samples → Samples~}/On_Finished_Room_Transitions_Listener.prefab.meta +7 -7
  100. package/{Samples → Samples~}/On_Loading_Room_Listener.prefab +51 -51
  101. package/{Samples → Samples~}/On_Loading_Room_Listener.prefab.meta +7 -7
  102. package/{Samples → Samples~}/On_Started_Changing_Room_Listener.prefab +51 -51
  103. package/{Samples → Samples~}/On_Started_Changing_Room_Listener.prefab.meta +7 -7
  104. package/{Samples → Samples~}/Prepare_TPFD_On_Room_Loading.prefab +142 -142
  105. package/{Samples → Samples~}/Prepare_TPFD_On_Room_Loading.prefab.meta +7 -7
  106. package/{Samples → Samples~}/Resolve_Room_Load_States.prefab +54 -54
  107. package/{Samples → Samples~}/Resolve_Room_Load_States.prefab.meta +7 -7
  108. package/{Samples → Samples~}/Room_Changer.prefab +143 -143
  109. package/{Samples → Samples~}/Room_Changer.prefab.meta +7 -7
  110. package/{Samples → Samples~}/Room_Changer_Loader.prefab +53 -53
  111. package/{Samples → Samples~}/Room_Changer_Loader.prefab.meta +7 -7
  112. package/{Samples → Samples~}/Room_Instance_Manager.prefab +78 -78
  113. package/{Samples → Samples~}/Room_Instance_Manager.prefab.meta +7 -7
  114. package/{Samples → Samples~}/Room_Load_Finisher.prefab +139 -139
  115. package/{Samples → Samples~}/Room_Load_Finisher.prefab.meta +7 -7
  116. package/{Samples → Samples~}/Room_Loader.prefab +584 -584
  117. package/{Samples → Samples~}/Room_Loader.prefab.meta +7 -7
  118. package/{Samples → Samples~}/Room_Loader_Event_Listeners.prefab +337 -337
  119. package/{Samples → Samples~}/Room_Loader_Event_Listeners.prefab.meta +7 -7
  120. package/{Samples → Samples~}/Room_Loading_System_ETemplate.prefab +398 -398
  121. package/{Samples → Samples~}/Room_Loading_System_ETemplate.prefab.meta +7 -7
  122. package/{Samples → Samples~}/SkipActivateControls.asset +19 -19
  123. package/{Samples → Samples~}/SkipActivateControls.asset.meta +8 -8
  124. package/{Samples → Samples~}/Skip_Controls_When_Loaded.prefab +156 -156
  125. package/{Samples → Samples~}/Skip_Controls_When_Loaded.prefab.meta +7 -7
  126. package/{Samples → Samples~}/TPFD_Room_Loader.prefab +215 -215
  127. package/{Samples → Samples~}/TPFD_Room_Loader.prefab.meta +7 -7
  128. package/{Samples → Samples~}/TeleportTransitionOptions.asset +18 -18
  129. package/{Samples → Samples~}/TeleportTransitionOptions.asset.meta +8 -8
  130. package/{Samples → Samples~}/Teleport_Room_Manager.prefab +84 -84
  131. package/{Samples → Samples~}/Teleport_Room_Manager.prefab.meta +7 -7
  132. package/{Samples → Samples~}/UI_Visibility_On_Scene_Events.prefab +316 -316
  133. package/{Samples → Samples~}/UI_Visibility_On_Scene_Events.prefab.meta +7 -7
  134. package/SkipControlsWhenLoaded.cs +65 -65
  135. package/SkipControlsWhenLoaded.cs.meta +11 -11
  136. package/TPFDRoomAnimation.cs +83 -83
  137. package/TPFDRoomAnimation.cs.meta +11 -11
  138. package/TPFDRoomLoader.cs +92 -92
  139. package/TPFDRoomLoader.cs.meta +11 -11
  140. package/TeleportRoomManager.cs +113 -113
  141. package/TeleportRoomManager.cs.meta +11 -11
  142. package/package.json +45 -40
  143. package/package.json.meta +7 -7
  144. package/Samples.meta +0 -8
@@ -1,45 +1,45 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using System;
3
- using UnityEngine;
4
-
5
- namespace DREditor.RoomLoading
6
- {
7
- /// <summary>
8
- ///
9
- /// </summary>
10
- [Serializable]
11
- [CreateAssetMenu(menuName = "DREditor/Room Loading/Room Load Options", fileName = "Room Load Options")]
12
- public class RoomLoadOptionsAsset : ScriptableObject
13
- {
14
- /// <summary>
15
- ///
16
- /// </summary>
17
- [Tooltip("")]
18
- public bool toInvestigation = false;
19
-
20
- /// <summary>
21
- ///
22
- /// </summary>
23
- [Tooltip("")]
24
- public bool blackTransition = false;
25
-
26
- /// <summary>
27
- ///
28
- /// </summary>
29
- [Tooltip("")]
30
- public bool fadeOutOnLoad = false;
31
-
32
- /// <summary>
33
- ///
34
- /// </summary>
35
- [Tooltip("")]
36
- public int toWaypoint = -1;
37
-
38
-
39
- /// <summary>
40
- ///
41
- /// </summary>
42
- /// <param name="toWaypoint"></param>
43
- public virtual void SetWaypoint(int toWaypoint) => this.toWaypoint = toWaypoint;
44
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using System;
3
+ using UnityEngine;
4
+
5
+ namespace DREditor.RoomLoading
6
+ {
7
+ /// <summary>
8
+ ///
9
+ /// </summary>
10
+ [Serializable]
11
+ [CreateAssetMenu(menuName = "DREditor/Room Loading/Room Load Options", fileName = "Room Load Options")]
12
+ public class RoomLoadOptionsAsset : ScriptableObject
13
+ {
14
+ /// <summary>
15
+ ///
16
+ /// </summary>
17
+ [Tooltip("")]
18
+ public bool toInvestigation = false;
19
+
20
+ /// <summary>
21
+ ///
22
+ /// </summary>
23
+ [Tooltip("")]
24
+ public bool blackTransition = false;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ public bool fadeOutOnLoad = false;
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Tooltip("")]
36
+ public int toWaypoint = -1;
37
+
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ /// <param name="toWaypoint"></param>
43
+ public virtual void SetWaypoint(int toWaypoint) => this.toWaypoint = toWaypoint;
44
+ }
45
45
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: e6f2e58ae8a9c27469b399a474b71cad
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: e6f2e58ae8a9c27469b399a474b71cad
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/RoomLoader.cs CHANGED
@@ -1,265 +1,265 @@
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.Fading;
5
- using DREditor.Services;
6
- using System.Collections;
7
- using System.Collections.Generic;
8
- using System.Linq;
9
- using UnityEngine;
10
- using UnityEngine.SceneManagement;
11
-
12
- namespace DREditor.RoomLoading
13
- {
14
- /// <summary>
15
- ///
16
- /// </summary>
17
- [ClassHeader(nameof(ServiceHolder<RoomLoaderBase>) + " for type: " + nameof(RoomLoaderBase) +
18
- "\n\n")]
19
- public class RoomLoader : RoomLoaderBase
20
- {
21
- /// <summary>
22
- ///
23
- /// </summary>
24
- [Tooltip("")]
25
- [SerializeField] protected SceneEvent onSetPlayerState = null;
26
-
27
- /// <summary>
28
- ///
29
- /// </summary>
30
- [Tooltip("")]
31
- [SerializeField] protected SceneEvent setControlsUIBasedOnCurrentMode = null;
32
-
33
-
34
- /// <summary>
35
- ///
36
- /// </summary>
37
- [Header("")]
38
- [Divider]
39
- [Tooltip("")]
40
- [SerializeField] bool debugLoadRoomOnStart = false;
41
-
42
-
43
- /// <summary>
44
- ///
45
- /// </summary>
46
- [Header("")]
47
- [Divider]
48
- [Tooltip("")]
49
- [SerializeField] protected List<RoomLoadComponent> roomLoadRoutines = new();
50
-
51
- /// <summary>
52
- ///
53
- /// </summary>
54
- [Tooltip("")]
55
- [SerializeField] protected List<RoomLoadComponent> roomLoadResolvers = new();
56
-
57
-
58
- /// <summary>
59
- ///
60
- /// </summary>
61
- [Header("")]
62
- [Divider]
63
- [Tooltip("")]
64
- [SerializeField] protected BoolWithEvent isLoadingToRoom = null;
65
-
66
- /// <summary>
67
- ///
68
- /// </summary>
69
- [Tooltip("")]
70
- [SerializeField] protected BoolWithEvent inDialogue = null;
71
-
72
- /// <summary>
73
- ///
74
- /// </summary>
75
- [Tooltip("")]
76
- [SerializeField] protected BoolWithEvent inTrialMode = null;
77
-
78
- /// <summary>
79
- ///
80
- /// </summary>
81
- [Tooltip("")]
82
- [SerializeField] protected BoolWithEvent skipActivateControls = null;
83
-
84
- /// <summary>
85
- ///
86
- /// </summary>
87
- [Tooltip("")]
88
- [SerializeField] protected BoolWithEvent isLoadingFile = null;
89
-
90
-
91
- /// <summary>
92
- ///
93
- /// </summary>
94
- [Header("")]
95
- [Divider]
96
- [Tooltip("")]
97
- [SerializeField] protected float setPlayerPositionBufferTime = 0.1f;
98
-
99
- /// <summary>
100
- ///
101
- /// </summary>
102
- [Tooltip("")]
103
- [SerializeField] protected string enableMonoControlsEvent = "EnableControlMonobehaviour";
104
-
105
- /// <summary>
106
- ///
107
- /// </summary>
108
- [Tooltip("")]
109
- [SerializeField] protected string disableControlsEvent = "DisableAbility";
110
-
111
-
112
- /// <summary>
113
- ///
114
- /// </summary>
115
- protected virtual void Start()
116
- {
117
- if (debugLoadRoomOnStart)
118
- LoadRoom(SceneManager.GetActiveScene(), LoadSceneMode.Single);
119
- }
120
-
121
- /// <inheritdoc/>
122
- public override void AllowRoomsToLoad() => SceneManager.sceneLoaded += LoadRoom;
123
-
124
- /// <inheritdoc/>
125
- public override void DoNotAllowRoomsToLoad() => SceneManager.sceneLoaded -= LoadRoom;
126
-
127
- /// <summary>
128
- ///
129
- /// </summary>
130
- /// <param name="scene"></param>
131
- /// <param name="mode"></param>
132
- protected virtual void LoadRoom(Scene scene, LoadSceneMode mode) => StartCoroutine(LoadIntoRoom(scene));
133
-
134
- /// <summary>
135
- ///
136
- /// </summary>
137
- /// <param name="scene"></param>
138
- protected virtual IEnumerator LoadIntoRoom(Scene scene)
139
- {
140
- if (AlreadyLoadingRoom(scene.name))
141
- yield break;
142
-
143
- isLoadingToRoom.SetValue(true);
144
-
145
- onLoadingRoom.Raise();
146
-
147
- DialogueEventSystem.TriggerEvent(disableControlsEvent);
148
-
149
- onSetPlayerState.Raise();
150
-
151
- yield return new WaitForSeconds(setPlayerPositionBufferTime);
152
-
153
- yield return OnRoomLoadRoutines();
154
-
155
- yield return DisplayEndTransitions();
156
-
157
- OnRoomLoadResolvers();
158
-
159
- EnableControlsFinishLoadingFile();
160
-
161
- FinishRoomLoadingEvents();
162
- }
163
-
164
- /// <summary>
165
- ///
166
- /// </summary>
167
- /// <param name="sceneName"></param>
168
- /// <returns></returns>
169
- protected virtual bool AlreadyLoadingRoom(string sceneName)
170
- {
171
- if (isLoadingToRoom.Value)
172
- UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: The game is already fading into the desired room.");
173
- else
174
- UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Scene: " + sceneName + " is now Loading");
175
-
176
- return isLoadingToRoom.Value;
177
- }
178
-
179
- /// <summary>
180
- ///
181
- /// </summary>
182
- protected virtual IEnumerator DisplayEndTransitions()
183
- {
184
- bool notLoadingIntoTrialOrDialogueFile = !isLoadingFile.Value && !inTrialMode.Value && !inDialogue.Value;
185
-
186
- if (notLoadingIntoTrialOrDialogueFile && !ServiceLocator.GetService<GlobalFade>().IsDark)
187
- yield return ServiceLocator.GetService<IRoomTransition>().EndTransitionRoutine();
188
-
189
- yield return DisplayPostTransitions();
190
-
191
- onFinishedRoomTransitions.Raise();
192
-
193
- UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Room Transitions finished, finishing up loading.");
194
- }
195
-
196
- /// <summary>
197
- ///
198
- /// </summary>
199
- protected virtual IEnumerator DisplayPostTransitions()
200
- {
201
- if (FindObjectsByType<MonoBehaviour>().OfType<IPostTransitionRoutine>() is IPostTransitionRoutine[] result)
202
- foreach (IPostTransitionRoutine postTransition in result)
203
- yield return postTransition.PostTransitionRoutine();
204
- }
205
-
206
- /// <summary>
207
- ///
208
- /// </summary>
209
- protected virtual void EnableControlsFinishLoadingFile()
210
- {
211
- if (!inTrialMode.Value && !skipActivateControls.Value)
212
- DialogueEventSystem.TriggerEvent(enableMonoControlsEvent);
213
-
214
- if (isLoadingFile.Value)
215
- isLoadingFile.SetValue(false);
216
- }
217
-
218
- /// <summary>
219
- ///
220
- /// </summary>
221
- protected virtual IEnumerator OnRoomLoadRoutines()
222
- {
223
- foreach (RoomLoadComponent roomLoadComponent in roomLoadRoutines)
224
- if (roomLoadComponent is IRoomLoadRoutine roomLoadRoutine)
225
- yield return roomLoadRoutine.OnRoomLoadRoutine();
226
- else
227
- UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: " +
228
- $"{roomLoadComponent.name} does not inherit the specified interface.");
229
-
230
- yield break;
231
- }
232
-
233
- /// <summary>
234
- ///
235
- /// </summary>
236
- protected virtual void OnRoomLoadResolvers()
237
- {
238
- foreach (RoomLoadComponent roomLoadComponent in roomLoadResolvers)
239
- if (roomLoadComponent is IRoomLoadResolver roomLoadResolver)
240
- roomLoadResolver.OnRoomLoadResolve();
241
- else
242
- UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: " +
243
- $"{roomLoadComponent.name} does not inherit the specified interface.");
244
- }
245
-
246
- /// <summary>
247
- ///
248
- /// </summary>
249
- protected virtual void FinishRoomLoadingEvents()
250
- {
251
- UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Finished loading room.");
252
-
253
- onFinishedLoadingRoom.Raise();
254
-
255
- if (!inDialogue.Value)
256
- {
257
- onFinishedLoadingRoomNoDialogue.Raise();
258
-
259
- setControlsUIBasedOnCurrentMode.Raise();
260
- }
261
- else
262
- UnityEngine.Debug.Log($"REPORT: {gameObject.name}: End of RoomLoader with In Dialogue True.");
263
- }
264
- }
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.Fading;
5
+ using DREditor.Services;
6
+ using System.Collections;
7
+ using System.Collections.Generic;
8
+ using System.Linq;
9
+ using UnityEngine;
10
+ using UnityEngine.SceneManagement;
11
+
12
+ namespace DREditor.RoomLoading
13
+ {
14
+ /// <summary>
15
+ ///
16
+ /// </summary>
17
+ [ClassHeader(nameof(ServiceHolder<RoomLoaderBase>) + " for type: " + nameof(RoomLoaderBase) +
18
+ "\n\n")]
19
+ public class RoomLoader : RoomLoaderBase
20
+ {
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ [Tooltip("")]
25
+ [SerializeField] protected SceneEvent onSetPlayerState = null;
26
+
27
+ /// <summary>
28
+ ///
29
+ /// </summary>
30
+ [Tooltip("")]
31
+ [SerializeField] protected SceneEvent setControlsUIBasedOnCurrentMode = null;
32
+
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ [Header("")]
38
+ [Divider]
39
+ [Tooltip("")]
40
+ [SerializeField] bool debugLoadRoomOnStart = false;
41
+
42
+
43
+ /// <summary>
44
+ ///
45
+ /// </summary>
46
+ [Header("")]
47
+ [Divider]
48
+ [Tooltip("")]
49
+ [SerializeField] protected List<RoomLoadComponent> roomLoadRoutines = new();
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ [Tooltip("")]
55
+ [SerializeField] protected List<RoomLoadComponent> roomLoadResolvers = new();
56
+
57
+
58
+ /// <summary>
59
+ ///
60
+ /// </summary>
61
+ [Header("")]
62
+ [Divider]
63
+ [Tooltip("")]
64
+ [SerializeField] protected BoolWithEvent isLoadingToRoom = null;
65
+
66
+ /// <summary>
67
+ ///
68
+ /// </summary>
69
+ [Tooltip("")]
70
+ [SerializeField] protected BoolWithEvent inDialogue = null;
71
+
72
+ /// <summary>
73
+ ///
74
+ /// </summary>
75
+ [Tooltip("")]
76
+ [SerializeField] protected BoolWithEvent inTrialMode = null;
77
+
78
+ /// <summary>
79
+ ///
80
+ /// </summary>
81
+ [Tooltip("")]
82
+ [SerializeField] protected BoolWithEvent skipActivateControls = null;
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ [Tooltip("")]
88
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
89
+
90
+
91
+ /// <summary>
92
+ ///
93
+ /// </summary>
94
+ [Header("")]
95
+ [Divider]
96
+ [Tooltip("")]
97
+ [SerializeField] protected float setPlayerPositionBufferTime = 0.1f;
98
+
99
+ /// <summary>
100
+ ///
101
+ /// </summary>
102
+ [Tooltip("")]
103
+ [SerializeField] protected string enableMonoControlsEvent = "EnableControlMonobehaviour";
104
+
105
+ /// <summary>
106
+ ///
107
+ /// </summary>
108
+ [Tooltip("")]
109
+ [SerializeField] protected string disableControlsEvent = "DisableAbility";
110
+
111
+
112
+ /// <summary>
113
+ ///
114
+ /// </summary>
115
+ protected virtual void Start()
116
+ {
117
+ if (debugLoadRoomOnStart)
118
+ LoadRoom(SceneManager.GetActiveScene(), LoadSceneMode.Single);
119
+ }
120
+
121
+ /// <inheritdoc/>
122
+ public override void AllowRoomsToLoad() => SceneManager.sceneLoaded += LoadRoom;
123
+
124
+ /// <inheritdoc/>
125
+ public override void DoNotAllowRoomsToLoad() => SceneManager.sceneLoaded -= LoadRoom;
126
+
127
+ /// <summary>
128
+ ///
129
+ /// </summary>
130
+ /// <param name="scene"></param>
131
+ /// <param name="mode"></param>
132
+ protected virtual void LoadRoom(Scene scene, LoadSceneMode mode) => StartCoroutine(LoadIntoRoom(scene));
133
+
134
+ /// <summary>
135
+ ///
136
+ /// </summary>
137
+ /// <param name="scene"></param>
138
+ protected virtual IEnumerator LoadIntoRoom(Scene scene)
139
+ {
140
+ if (AlreadyLoadingRoom(scene.name))
141
+ yield break;
142
+
143
+ isLoadingToRoom.SetValue(true);
144
+
145
+ onLoadingRoom.Raise();
146
+
147
+ DialogueEventSystem.TriggerEvent(disableControlsEvent);
148
+
149
+ onSetPlayerState.Raise();
150
+
151
+ yield return new WaitForSeconds(setPlayerPositionBufferTime);
152
+
153
+ yield return OnRoomLoadRoutines();
154
+
155
+ yield return DisplayEndTransitions();
156
+
157
+ OnRoomLoadResolvers();
158
+
159
+ EnableControlsFinishLoadingFile();
160
+
161
+ FinishRoomLoadingEvents();
162
+ }
163
+
164
+ /// <summary>
165
+ ///
166
+ /// </summary>
167
+ /// <param name="sceneName"></param>
168
+ /// <returns></returns>
169
+ protected virtual bool AlreadyLoadingRoom(string sceneName)
170
+ {
171
+ if (isLoadingToRoom.Value)
172
+ UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: The game is already fading into the desired room.");
173
+ else
174
+ UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Scene: " + sceneName + " is now Loading");
175
+
176
+ return isLoadingToRoom.Value;
177
+ }
178
+
179
+ /// <summary>
180
+ ///
181
+ /// </summary>
182
+ protected virtual IEnumerator DisplayEndTransitions()
183
+ {
184
+ bool notLoadingIntoTrialOrDialogueFile = !isLoadingFile.Value && !inTrialMode.Value && !inDialogue.Value;
185
+
186
+ if (notLoadingIntoTrialOrDialogueFile && !ServiceLocator.GetService<GlobalFade>().IsDark)
187
+ yield return ServiceLocator.GetService<IRoomTransition>().EndTransitionRoutine();
188
+
189
+ yield return DisplayPostTransitions();
190
+
191
+ onFinishedRoomTransitions.Raise();
192
+
193
+ UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Room Transitions finished, finishing up loading.");
194
+ }
195
+
196
+ /// <summary>
197
+ ///
198
+ /// </summary>
199
+ protected virtual IEnumerator DisplayPostTransitions()
200
+ {
201
+ if (FindObjectsByType<MonoBehaviour>().OfType<IPostTransitionRoutine>() is IPostTransitionRoutine[] result)
202
+ foreach (IPostTransitionRoutine postTransition in result)
203
+ yield return postTransition.PostTransitionRoutine();
204
+ }
205
+
206
+ /// <summary>
207
+ ///
208
+ /// </summary>
209
+ protected virtual void EnableControlsFinishLoadingFile()
210
+ {
211
+ if (!inTrialMode.Value && !skipActivateControls.Value)
212
+ DialogueEventSystem.TriggerEvent(enableMonoControlsEvent);
213
+
214
+ if (isLoadingFile.Value)
215
+ isLoadingFile.SetValue(false);
216
+ }
217
+
218
+ /// <summary>
219
+ ///
220
+ /// </summary>
221
+ protected virtual IEnumerator OnRoomLoadRoutines()
222
+ {
223
+ foreach (RoomLoadComponent roomLoadComponent in roomLoadRoutines)
224
+ if (roomLoadComponent is IRoomLoadRoutine roomLoadRoutine)
225
+ yield return roomLoadRoutine.OnRoomLoadRoutine();
226
+ else
227
+ UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: " +
228
+ $"{roomLoadComponent.name} does not inherit the specified interface.");
229
+
230
+ yield break;
231
+ }
232
+
233
+ /// <summary>
234
+ ///
235
+ /// </summary>
236
+ protected virtual void OnRoomLoadResolvers()
237
+ {
238
+ foreach (RoomLoadComponent roomLoadComponent in roomLoadResolvers)
239
+ if (roomLoadComponent is IRoomLoadResolver roomLoadResolver)
240
+ roomLoadResolver.OnRoomLoadResolve();
241
+ else
242
+ UnityEngine.Debug.LogWarning($"ALERT: {gameObject.name}: " +
243
+ $"{roomLoadComponent.name} does not inherit the specified interface.");
244
+ }
245
+
246
+ /// <summary>
247
+ ///
248
+ /// </summary>
249
+ protected virtual void FinishRoomLoadingEvents()
250
+ {
251
+ UnityEngine.Debug.Log($"REPORT: {gameObject.name}: Finished loading room.");
252
+
253
+ onFinishedLoadingRoom.Raise();
254
+
255
+ if (!inDialogue.Value)
256
+ {
257
+ onFinishedLoadingRoomNoDialogue.Raise();
258
+
259
+ setControlsUIBasedOnCurrentMode.Raise();
260
+ }
261
+ else
262
+ UnityEngine.Debug.Log($"REPORT: {gameObject.name}: End of RoomLoader with In Dialogue True.");
263
+ }
264
+ }
265
265
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 62af1c359592ee04797a4d52458ddf18
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: 62af1c359592ee04797a4d52458ddf18
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: