net.dreditor.roombuilding 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 (133) hide show
  1. package/.attestation.p7m +0 -0
  2. package/DREditor.RoomBuilding.asmdef +28 -28
  3. package/DREditor.RoomBuilding.asmdef.meta +7 -7
  4. package/Editor/DREditor.RoomBuilding.Editor.asmdef +19 -19
  5. package/Editor/DREditor.RoomBuilding.Editor.asmdef.meta +7 -7
  6. package/Editor/FindCharactersInRoomsWizard.cs +55 -55
  7. package/Editor/FindCharactersInRoomsWizard.cs.meta +11 -11
  8. package/Editor/RoomBuilderContainsObjective.cs +38 -38
  9. package/Editor/RoomBuilderContainsObjective.cs.meta +11 -11
  10. package/Editor/RoomBuilderScanWizard.cs +90 -90
  11. package/Editor/RoomBuilderScanWizard.cs.meta +11 -11
  12. package/Editor/ScanRoomBuilders.cs +74 -74
  13. package/Editor/ScanRoomBuilders.cs.meta +11 -11
  14. package/Editor.meta +8 -8
  15. package/Implementation/Actors/ActorData.cs +115 -115
  16. package/Implementation/Actors/ActorData.cs.meta +11 -11
  17. package/Implementation/Actors/ActorStateData.cs +10 -10
  18. package/Implementation/Actors/ActorStateData.cs.meta +11 -11
  19. package/Implementation/Actors/ActorStateLoader.cs +344 -344
  20. package/Implementation/Actors/ActorStateLoader.cs.meta +11 -11
  21. package/Implementation/Actors/TActorData.cs +35 -35
  22. package/Implementation/Actors/TActorData.cs.meta +11 -11
  23. package/Implementation/Actors/TrialActorManager.cs +157 -157
  24. package/Implementation/Actors/TrialActorManager.cs.meta +11 -11
  25. package/Implementation/Actors.meta +8 -8
  26. package/Implementation/DoorLoader.cs +117 -117
  27. package/Implementation/DoorLoader.cs.meta +11 -11
  28. package/Implementation/DoorLoaderUtility.cs +51 -51
  29. package/Implementation/DoorLoaderUtility.cs.meta +11 -11
  30. package/Implementation/DoorStateData.cs +11 -11
  31. package/Implementation/DoorStateData.cs.meta +11 -11
  32. package/Implementation/ItemActorLoader.cs +157 -157
  33. package/Implementation/ItemActorLoader.cs.meta +11 -11
  34. package/Implementation/ItemData.cs +67 -67
  35. package/Implementation/ItemData.cs.meta +11 -11
  36. package/Implementation/ItemStateData.cs +10 -10
  37. package/Implementation/ItemStateData.cs.meta +11 -11
  38. package/Implementation/MoveLoader.cs +67 -67
  39. package/Implementation/MoveLoader.cs.meta +11 -11
  40. package/Implementation/MoveStateData.cs +11 -11
  41. package/Implementation/MoveStateData.cs.meta +11 -11
  42. package/Implementation/RoomStateHandlerBase.cs +241 -241
  43. package/Implementation/RoomStateHandlerBase.cs.meta +11 -11
  44. package/Implementation/SaveableData.cs +56 -56
  45. package/Implementation/SaveableData.cs.meta +11 -11
  46. package/Implementation/SaveableDataSet.cs +66 -66
  47. package/Implementation/SaveableDataSet.cs.meta +11 -11
  48. package/Implementation/SaveableManager.cs +70 -70
  49. package/Implementation/SaveableManager.cs.meta +11 -11
  50. package/Implementation/SaveableStateData.cs +10 -10
  51. package/Implementation/SaveableStateData.cs.meta +11 -11
  52. package/Implementation/SpawnableLoader.cs +125 -125
  53. package/Implementation/SpawnableLoader.cs.meta +11 -11
  54. package/Implementation/SpawnableStateData.cs +11 -11
  55. package/Implementation/SpawnableStateData.cs.meta +11 -11
  56. package/Implementation/StateDataAsset.cs +28 -28
  57. package/Implementation/StateDataAsset.cs.meta +11 -11
  58. package/Implementation/SubAreaLoader.cs +108 -108
  59. package/Implementation/SubAreaLoader.cs.meta +11 -11
  60. package/Implementation/SubAreaStateData.cs +11 -11
  61. package/Implementation/SubAreaStateData.cs.meta +11 -11
  62. package/Implementation/TriggerConverter.cs +137 -137
  63. package/Implementation/TriggerConverter.cs.meta +11 -11
  64. package/Implementation/TriggerLoader.cs +295 -295
  65. package/Implementation/TriggerLoader.cs.meta +11 -11
  66. package/Implementation/TriggerStateData.cs +18 -18
  67. package/Implementation/TriggerStateData.cs.meta +11 -11
  68. package/Implementation.meta +8 -8
  69. package/InstanceListWrapper.cs +23 -23
  70. package/InstanceListWrapper.cs.meta +11 -11
  71. package/Instances/ConvertInstanceData.cs +89 -89
  72. package/Instances/ConvertInstanceData.cs.meta +11 -11
  73. package/Instances/InstanceData.cs +43 -43
  74. package/Instances/InstanceData.cs.meta +11 -11
  75. package/Instances/InstanceStateData.cs +51 -51
  76. package/Instances/InstanceStateData.cs.meta +11 -11
  77. package/Instances/RoomInstanceData.cs +68 -68
  78. package/Instances/RoomInstanceData.cs.meta +11 -11
  79. package/Instances/RoomInstanceManager.cs +452 -452
  80. package/Instances/RoomInstanceManager.cs.meta +11 -11
  81. package/Instances.meta +8 -8
  82. package/LoadInvestigationRoomState.cs +53 -53
  83. package/LoadInvestigationRoomState.cs.meta +11 -11
  84. package/Old/ActorLoader.cs +382 -382
  85. package/Old/ActorLoader.cs.meta +11 -11
  86. package/Old/Room.cs +24 -24
  87. package/Old/Room.cs.meta +11 -11
  88. package/Old/RoomBuilder.cs +59 -59
  89. package/Old/RoomBuilder.cs.meta +11 -11
  90. package/Old/RoomData.cs +90 -90
  91. package/Old/RoomData.cs.meta +11 -11
  92. package/Old/RoomManager.cs +256 -256
  93. package/Old/RoomManager.cs.meta +11 -11
  94. package/Old/RoomManagerDisplayEditor.cs +72 -72
  95. package/Old/RoomManagerDisplayEditor.cs.meta +11 -11
  96. package/Old/RoomManagerEditor.cs +211 -211
  97. package/Old/RoomManagerEditor.cs.meta +11 -11
  98. package/Old/RoomManagerShellDisplayEditor.cs +48 -48
  99. package/Old/RoomManagerShellDisplayEditor.cs.meta +11 -11
  100. package/Old/RoomSection.cs +35 -35
  101. package/Old/RoomSection.cs.meta +11 -11
  102. package/Old.meta +8 -8
  103. package/RoomManagerBase.cs +84 -84
  104. package/RoomManagerBase.cs.meta +11 -11
  105. package/RoomManagerEditorBase.cs +86 -86
  106. package/RoomManagerEditorBase.cs.meta +11 -11
  107. package/RoomManagerEditorCoreBase.cs +159 -159
  108. package/RoomManagerEditorCoreBase.cs.meta +11 -11
  109. package/RoomSaveDisplayEditorBase.cs +111 -111
  110. package/RoomSaveDisplayEditorBase.cs.meta +11 -11
  111. package/RoomShellDisplayEditorBase.cs +68 -68
  112. package/RoomShellDisplayEditorBase.cs.meta +11 -11
  113. package/RoomStateBuilder.cs +53 -53
  114. package/RoomStateBuilder.cs.meta +11 -11
  115. package/RoomStateData.cs +58 -58
  116. package/RoomStateData.cs.meta +11 -11
  117. package/RoomStateManager.cs +202 -202
  118. package/RoomStateManager.cs.meta +11 -11
  119. package/RoomStateManagerEditor.cs +392 -392
  120. package/RoomStateManagerEditor.cs.meta +11 -11
  121. package/RoomStateSaveDisplayEditor.cs +175 -175
  122. package/RoomStateSaveDisplayEditor.cs.meta +11 -11
  123. package/RoomStateSection.cs +69 -69
  124. package/RoomStateSection.cs.meta +11 -11
  125. package/RoomStateShellDisplayEditor.cs +108 -108
  126. package/RoomStateShellDisplayEditor.cs.meta +11 -11
  127. package/{Samples → Samples~}/Room_State_Manager.prefab +473 -473
  128. package/{Samples → Samples~}/Room_State_Manager.prefab.meta +7 -7
  129. package/{Samples → Samples~}/Trial_Actor_Manager.prefab +51 -51
  130. package/{Samples → Samples~}/Trial_Actor_Manager.prefab.meta +7 -7
  131. package/package.json +51 -46
  132. package/package.json.meta +7 -7
  133. package/Samples.meta +0 -8
@@ -1,393 +1,393 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- #if UNITY_EDITOR
3
- using DREditor.Progressing;
4
- using DREditor.RoomStateBuilding;
5
- using DREditor.Editor.Utility;
6
- using System.Linq;
7
- using UnityEditor;
8
- using UnityEditor.SceneManagement;
9
- using UnityEngine;
10
- using UnityEngine.SceneManagement;
11
-
12
- namespace DREditor.RoomBuilding
13
- {
14
- /// <summary>
15
- ///
16
- /// </summary>
17
- [CustomEditor(typeof(RoomStateManager))]
18
- [CanEditMultipleObjects]
19
- public class RoomStateManagerEditor : RoomManagerEditorBase
20
- {
21
- /// <summary>
22
- ///
23
- /// </summary>
24
- protected RoomStateManager manager;
25
-
26
- /// <summary>
27
- ///
28
- /// </summary>
29
- protected RoomStateBuilder builder;
30
-
31
- /// <summary>
32
- ///
33
- /// </summary>
34
- protected SerializedProperty monoBehavioursProp;
35
-
36
- /// <summary>
37
- ///
38
- /// </summary>
39
- protected RoomStateShellDisplayEditor shellEditor;
40
-
41
- /// <summary>
42
- ///
43
- /// </summary>
44
- protected RoomStateSaveDisplayEditor roomStateEditor;
45
-
46
-
47
- #region Handler Initialization
48
-
49
- /// <inheritdoc/>
50
- protected override void OnEnable()
51
- {
52
- manager = (RoomStateManager)target;
53
-
54
- manager.InitializeHandlers();
55
-
56
- monoBehavioursProp = serializedObject.FindProperty("loadHandlers");
57
-
58
- base.OnEnable();
59
-
60
- UpdateRoomBuilderField(manager);
61
-
62
- roomStateEditor = new(manager, manager.Builder);
63
-
64
- shellEditor = new(manager, manager.Builder, roomStateEditor);
65
- }
66
-
67
- /// <summary>
68
- ///
69
- /// </summary>
70
- /// <param name="manager"></param>
71
- static void UpdateRoomBuilderField(RoomStateManager manager)
72
- {
73
- if (!(!Application.isPlaying && EditorUtility.IsPersistent(manager)) && manager.Builder == null)
74
- {
75
- UnityEngine.Debug.Log("Checking if RoomStateBuilder Already exists");
76
-
77
- var found = AssetDatabase.FindAssets("t:RoomStateBuilder");
78
-
79
- if (found.Length != 0)
80
- {
81
- foreach (var asset in found)
82
- {
83
- string path = AssetDatabase.GUIDToAssetPath(asset);
84
-
85
- var roomStateBuilder = AssetDatabase.LoadAssetAtPath<RoomStateBuilder>(path);
86
-
87
- if (roomStateBuilder != null && roomStateBuilder.name == EditorSceneManager.GetActiveScene().name)
88
- manager.SetBuilder(roomStateBuilder);
89
- }
90
-
91
- if (manager.Builder == null)
92
- UnityEngine.Debug.Log("Loaded but couldn't find.");
93
-
94
- EditorUtility.SetDirty(manager);
95
- }
96
- }
97
- }
98
-
99
- #endregion
100
-
101
- #region Builder Initialization
102
-
103
- /// <inheritdoc/>
104
- protected override bool DisplayBuilderField()
105
- {
106
- using (new EditorGUILayout.HorizontalScope())
107
- {
108
- manager.SetBuilder(HandyFields.UnityField(manager.Builder, 200, 35));
109
-
110
- if (IsManagerBuilderValid() && builder == null)
111
- builder = manager.Builder;
112
-
113
- if (builder == null)
114
- if (GUILayout.Button("Initialize Builder"))
115
- InitializeBuilder();
116
- else
117
- return false;
118
-
119
- if (builder != null && (builder.Sections.Count == 0 || AllSectionsAreNull()))
120
- if (GUILayout.Button("Initialize Sections"))
121
- InitializeSections();
122
- else
123
- return false;
124
-
125
- if (GUILayout.Button("Apply Changes"))
126
- EditorUtility.SetDirty(manager);
127
-
128
- return true;
129
- }
130
- }
131
-
132
- /// <summary>
133
- ///
134
- /// </summary>
135
- /// <returns></returns>
136
- protected virtual bool AllSectionsAreNull()
137
- {
138
- foreach (var section in builder.Sections)
139
- if (section != null)
140
- return false;
141
-
142
- return true;
143
- }
144
-
145
- /// <summary>
146
- ///
147
- /// </summary>
148
- protected virtual void InitializeBuilder()
149
- {
150
- var builderAsset = ScriptableObject.CreateInstance<RoomStateBuilder>();
151
-
152
- string buildFolderPath = "Assets/RoomBuilding";
153
-
154
- if (!FolderUtility.ProjectFolderExists(buildFolderPath))
155
- AssetDatabase.CreateFolder("Assets", "RoomBuilding");
156
-
157
- string buildFolder = AssetDatabase.CreateFolder(buildFolderPath, SceneManager.GetActiveScene().name);
158
-
159
- if (buildFolder == "")
160
- {
161
- UnityEngine.Debug.LogWarning("Could not create folder. Canceling Initialization.");
162
-
163
- UnityEngine.Debug.Log("Builder Path: " + buildFolderPath);
164
-
165
- return;
166
- }
167
-
168
- string newFolderPath = AssetDatabase.GUIDToAssetPath(buildFolder);
169
-
170
- AssetDatabase.CreateAsset(builderAsset, $"{newFolderPath}/{SceneManager.GetActiveScene().name}.asset");
171
-
172
- AssetDatabase.SaveAssets();
173
-
174
- builder = builderAsset;
175
-
176
- manager.SetBuilder(builder);
177
-
178
- SetBuilderDirty();
179
-
180
- EditorUtility.SetDirty(manager);
181
-
182
- InitializeSections();
183
- }
184
-
185
- /// <summary>
186
- ///
187
- /// </summary>
188
- protected virtual void InitializeSections()
189
- {
190
- foreach (Chapter chapter in pDB.Chapters)
191
- {
192
- var sectionAsset = ScriptableObject.CreateInstance<RoomStateSection>();
193
-
194
- sectionAsset.SetChapter(chapter);
195
-
196
- string builderPath = AssetDatabase.GetAssetPath(builder);
197
-
198
- string builderPrefix = builder.name.Replace(".asset", "");
199
-
200
- string sectionPath = builderPath.Replace("/" + builder.name + ".asset", "");
201
-
202
- string sectionFolderName = builderPrefix + $"_{pDB.GetChapterIndex(chapter)}";
203
-
204
- string sectionFolder = AssetDatabase.CreateFolder(sectionPath, sectionFolderName);
205
-
206
- if (sectionFolder == "")
207
- {
208
- UnityEngine.Debug.LogWarning("Could not create folder. Canceling Initialization.");
209
-
210
- UnityEngine.Debug.Log("Builder Path: " + sectionPath);
211
-
212
- return;
213
- }
214
-
215
- string newFolderPath = AssetDatabase.GUIDToAssetPath(sectionFolder);
216
-
217
- string newAssetPath = $"{newFolderPath}/{builderPrefix}_{pDB.GetChapterIndex(chapter)}.asset";
218
-
219
- AssetDatabase.CreateAsset(sectionAsset, newAssetPath);
220
-
221
- AssetDatabase.SaveAssets();
222
-
223
- EditorUtility.SetDirty(sectionAsset);
224
-
225
- builder.Sections.Add(sectionAsset);
226
-
227
- SetBuilderDirty();
228
- }
229
- }
230
-
231
- /// <summary>
232
- ///
233
- /// </summary>
234
- protected virtual void DisplayHandlers()
235
- {
236
- serializedObject.Update();
237
-
238
- EditorGUILayout.PropertyField(monoBehavioursProp, true);
239
-
240
- manager.InitializeHandlers();
241
-
242
- serializedObject.ApplyModifiedProperties();
243
- }
244
-
245
- /// <inheritdoc/>
246
- protected override bool IsManagerBuilderValid() => manager.Builder != null;
247
-
248
- /// <inheritdoc/>
249
- protected override void DisplayChapter()
250
- {
251
- DisplayHandlers();
252
-
253
- base.DisplayChapter();
254
- }
255
-
256
- /// <inheritdoc/>
257
- protected override void SetBuilderDirty()
258
- {
259
- if (builder != null)
260
- EditorUtility.SetDirty(builder);
261
- }
262
-
263
- #endregion
264
-
265
- #region Create Room Save
266
-
267
- /// <inheritdoc/>
268
- protected override void SaveRoom(Objective pValue)
269
- {
270
- var look = builder.Sections.Where(n => n.Chapter == managerBase.Chapter).ToList();
271
-
272
- int index = manager.intChapter;
273
-
274
- if (look.Count > 0)
275
- index = builder.Sections.IndexOf(look[0]);
276
-
277
- string sectionPath = FolderUtility.GetAssetFolderPath(builder.Sections[index]);
278
-
279
- string sectionPrefix = builder.Sections[index].name.Replace(".asset", "");
280
-
281
- string roomStateName = sectionPrefix + "_" + pValue.Description;
282
-
283
- if (!FolderUtility.TryCreateFolder(ref sectionPath, roomStateName))
284
- return;
285
-
286
- string newAssetPath = $"{sectionPath}/{roomStateName}.asset";
287
-
288
- RoomStateData room = roomStateEditor.CreateRoomState(pValue, newAssetPath);
289
-
290
- UnityEngine.Debug.Log(JsonUtility.ToJson(room));
291
-
292
- builder.Sections[index].Rooms.Add(room);
293
-
294
- EditorUtility.SetDirty(builder.Sections[index]);
295
- }
296
-
297
- #endregion
298
-
299
- #region Clear Drop Down
300
-
301
- /// <inheritdoc/>
302
- protected override void OnClearFoldOut()
303
- {
304
- foreach (IRoomStateLoader loader in manager.loaders)
305
- if (GUILayout.Button("Unload " + loader.GetTypeName(), GUILayout.Width(150)))
306
- if (EditorUtility.DisplayDialog($"Unload {loader.GetTypeName()}",
307
- $"Are you sure you want to destroy/unload all {loader.GetTypeName()}?",
308
- "Yes", "No"))
309
- {
310
- loader.Unload(true);
311
-
312
- EditorUtility.SetDirty(manager);
313
- }
314
- }
315
-
316
- /// <inheritdoc/>
317
- protected override void ClearAll()
318
- {
319
- manager.UnloadAll(true);
320
-
321
- EditorUtility.SetDirty(manager);
322
- }
323
-
324
- #endregion
325
-
326
- #region Display Room States
327
-
328
- /// <inheritdoc/>
329
- protected override void DisplayShellData() => shellEditor.DisplayShellData();
330
-
331
- /// <inheritdoc/>
332
- protected override void DisplayRoomStates()
333
- {
334
- RoomStateSection current = null;
335
-
336
- for (int i = 0; i < builder.Sections.Count; i++)
337
- {
338
- RoomStateSection roomSection = builder.Sections[i];
339
-
340
- if (roomSection == null)
341
- {
342
- builder.Sections.Remove(roomSection);
343
-
344
- EditorUtility.SetDirty(builder);
345
-
346
- AssetDatabase.SaveAssetIfDirty(builder);
347
-
348
- continue;
349
- }
350
-
351
- if (roomSection.Chapter == pDB.Chapters[pDB.Chapters.IndexOf(managerBase.Chapter)])
352
- {
353
- current = roomSection;
354
-
355
- break;
356
- }
357
- }
358
-
359
- if (current == null)
360
- GUILayout.Label("Couldn't find a Room Builder Section with the related chapter. " +
361
- "Please do not create a room save while this is showing.");
362
- else
363
- DisplayRoomSaves(current);
364
- }
365
-
366
- /// <summary>
367
- ///
368
- /// </summary>
369
- /// <param name="current"></param>
370
- protected virtual void DisplayRoomSaves(RoomStateSection current)
371
- {
372
- if (current.Rooms.Count > 0)
373
- {
374
- if (roomStateEditor.saveFolds.Count != current.Rooms.Count)
375
- for (int i = 0; i < current.Rooms.Count; i++)
376
- roomStateEditor.saveFolds.Add(false);
377
-
378
- roomFold = EditorGUILayout.Foldout(roomFold, "Saved Rooms");
379
-
380
- if (roomFold)
381
- {
382
- GUILayout.Label("On Load will remove REFERENCED Actors");
383
-
384
- for (int i = 0; i < current.Rooms.Count; i++)
385
- roomStateEditor.DisplayRoomSave(current, i, current.Rooms[i], current.Rooms[i].progressionValue.Description);
386
- }
387
- }
388
- }
389
-
390
- #endregion
391
- }
392
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Progressing;
4
+ using DREditor.RoomStateBuilding;
5
+ using DREditor.Editor.Utility;
6
+ using System.Linq;
7
+ using UnityEditor;
8
+ using UnityEditor.SceneManagement;
9
+ using UnityEngine;
10
+ using UnityEngine.SceneManagement;
11
+
12
+ namespace DREditor.RoomBuilding
13
+ {
14
+ /// <summary>
15
+ ///
16
+ /// </summary>
17
+ [CustomEditor(typeof(RoomStateManager))]
18
+ [CanEditMultipleObjects]
19
+ public class RoomStateManagerEditor : RoomManagerEditorBase
20
+ {
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ protected RoomStateManager manager;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ protected RoomStateBuilder builder;
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ protected SerializedProperty monoBehavioursProp;
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ protected RoomStateShellDisplayEditor shellEditor;
40
+
41
+ /// <summary>
42
+ ///
43
+ /// </summary>
44
+ protected RoomStateSaveDisplayEditor roomStateEditor;
45
+
46
+
47
+ #region Handler Initialization
48
+
49
+ /// <inheritdoc/>
50
+ protected override void OnEnable()
51
+ {
52
+ manager = (RoomStateManager)target;
53
+
54
+ manager.InitializeHandlers();
55
+
56
+ monoBehavioursProp = serializedObject.FindProperty("loadHandlers");
57
+
58
+ base.OnEnable();
59
+
60
+ UpdateRoomBuilderField(manager);
61
+
62
+ roomStateEditor = new(manager, manager.Builder);
63
+
64
+ shellEditor = new(manager, manager.Builder, roomStateEditor);
65
+ }
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ /// <param name="manager"></param>
71
+ static void UpdateRoomBuilderField(RoomStateManager manager)
72
+ {
73
+ if (!(!Application.isPlaying && EditorUtility.IsPersistent(manager)) && manager.Builder == null)
74
+ {
75
+ UnityEngine.Debug.Log("Checking if RoomStateBuilder Already exists");
76
+
77
+ var found = AssetDatabase.FindAssets("t:RoomStateBuilder");
78
+
79
+ if (found.Length != 0)
80
+ {
81
+ foreach (var asset in found)
82
+ {
83
+ string path = AssetDatabase.GUIDToAssetPath(asset);
84
+
85
+ var roomStateBuilder = AssetDatabase.LoadAssetAtPath<RoomStateBuilder>(path);
86
+
87
+ if (roomStateBuilder != null && roomStateBuilder.name == EditorSceneManager.GetActiveScene().name)
88
+ manager.SetBuilder(roomStateBuilder);
89
+ }
90
+
91
+ if (manager.Builder == null)
92
+ UnityEngine.Debug.Log("Loaded but couldn't find.");
93
+
94
+ EditorUtility.SetDirty(manager);
95
+ }
96
+ }
97
+ }
98
+
99
+ #endregion
100
+
101
+ #region Builder Initialization
102
+
103
+ /// <inheritdoc/>
104
+ protected override bool DisplayBuilderField()
105
+ {
106
+ using (new EditorGUILayout.HorizontalScope())
107
+ {
108
+ manager.SetBuilder(HandyFields.UnityField(manager.Builder, 200, 35));
109
+
110
+ if (IsManagerBuilderValid() && builder == null)
111
+ builder = manager.Builder;
112
+
113
+ if (builder == null)
114
+ if (GUILayout.Button("Initialize Builder"))
115
+ InitializeBuilder();
116
+ else
117
+ return false;
118
+
119
+ if (builder != null && (builder.Sections.Count == 0 || AllSectionsAreNull()))
120
+ if (GUILayout.Button("Initialize Sections"))
121
+ InitializeSections();
122
+ else
123
+ return false;
124
+
125
+ if (GUILayout.Button("Apply Changes"))
126
+ EditorUtility.SetDirty(manager);
127
+
128
+ return true;
129
+ }
130
+ }
131
+
132
+ /// <summary>
133
+ ///
134
+ /// </summary>
135
+ /// <returns></returns>
136
+ protected virtual bool AllSectionsAreNull()
137
+ {
138
+ foreach (var section in builder.Sections)
139
+ if (section != null)
140
+ return false;
141
+
142
+ return true;
143
+ }
144
+
145
+ /// <summary>
146
+ ///
147
+ /// </summary>
148
+ protected virtual void InitializeBuilder()
149
+ {
150
+ var builderAsset = ScriptableObject.CreateInstance<RoomStateBuilder>();
151
+
152
+ string buildFolderPath = "Assets/RoomBuilding";
153
+
154
+ if (!FolderUtility.ProjectFolderExists(buildFolderPath))
155
+ AssetDatabase.CreateFolder("Assets", "RoomBuilding");
156
+
157
+ string buildFolder = AssetDatabase.CreateFolder(buildFolderPath, SceneManager.GetActiveScene().name);
158
+
159
+ if (buildFolder == "")
160
+ {
161
+ UnityEngine.Debug.LogWarning("Could not create folder. Canceling Initialization.");
162
+
163
+ UnityEngine.Debug.Log("Builder Path: " + buildFolderPath);
164
+
165
+ return;
166
+ }
167
+
168
+ string newFolderPath = AssetDatabase.GUIDToAssetPath(buildFolder);
169
+
170
+ AssetDatabase.CreateAsset(builderAsset, $"{newFolderPath}/{SceneManager.GetActiveScene().name}.asset");
171
+
172
+ AssetDatabase.SaveAssets();
173
+
174
+ builder = builderAsset;
175
+
176
+ manager.SetBuilder(builder);
177
+
178
+ SetBuilderDirty();
179
+
180
+ EditorUtility.SetDirty(manager);
181
+
182
+ InitializeSections();
183
+ }
184
+
185
+ /// <summary>
186
+ ///
187
+ /// </summary>
188
+ protected virtual void InitializeSections()
189
+ {
190
+ foreach (Chapter chapter in pDB.Chapters)
191
+ {
192
+ var sectionAsset = ScriptableObject.CreateInstance<RoomStateSection>();
193
+
194
+ sectionAsset.SetChapter(chapter);
195
+
196
+ string builderPath = AssetDatabase.GetAssetPath(builder);
197
+
198
+ string builderPrefix = builder.name.Replace(".asset", "");
199
+
200
+ string sectionPath = builderPath.Replace("/" + builder.name + ".asset", "");
201
+
202
+ string sectionFolderName = builderPrefix + $"_{pDB.GetChapterIndex(chapter)}";
203
+
204
+ string sectionFolder = AssetDatabase.CreateFolder(sectionPath, sectionFolderName);
205
+
206
+ if (sectionFolder == "")
207
+ {
208
+ UnityEngine.Debug.LogWarning("Could not create folder. Canceling Initialization.");
209
+
210
+ UnityEngine.Debug.Log("Builder Path: " + sectionPath);
211
+
212
+ return;
213
+ }
214
+
215
+ string newFolderPath = AssetDatabase.GUIDToAssetPath(sectionFolder);
216
+
217
+ string newAssetPath = $"{newFolderPath}/{builderPrefix}_{pDB.GetChapterIndex(chapter)}.asset";
218
+
219
+ AssetDatabase.CreateAsset(sectionAsset, newAssetPath);
220
+
221
+ AssetDatabase.SaveAssets();
222
+
223
+ EditorUtility.SetDirty(sectionAsset);
224
+
225
+ builder.Sections.Add(sectionAsset);
226
+
227
+ SetBuilderDirty();
228
+ }
229
+ }
230
+
231
+ /// <summary>
232
+ ///
233
+ /// </summary>
234
+ protected virtual void DisplayHandlers()
235
+ {
236
+ serializedObject.Update();
237
+
238
+ EditorGUILayout.PropertyField(monoBehavioursProp, true);
239
+
240
+ manager.InitializeHandlers();
241
+
242
+ serializedObject.ApplyModifiedProperties();
243
+ }
244
+
245
+ /// <inheritdoc/>
246
+ protected override bool IsManagerBuilderValid() => manager.Builder != null;
247
+
248
+ /// <inheritdoc/>
249
+ protected override void DisplayChapter()
250
+ {
251
+ DisplayHandlers();
252
+
253
+ base.DisplayChapter();
254
+ }
255
+
256
+ /// <inheritdoc/>
257
+ protected override void SetBuilderDirty()
258
+ {
259
+ if (builder != null)
260
+ EditorUtility.SetDirty(builder);
261
+ }
262
+
263
+ #endregion
264
+
265
+ #region Create Room Save
266
+
267
+ /// <inheritdoc/>
268
+ protected override void SaveRoom(Objective pValue)
269
+ {
270
+ var look = builder.Sections.Where(n => n.Chapter == managerBase.Chapter).ToList();
271
+
272
+ int index = manager.intChapter;
273
+
274
+ if (look.Count > 0)
275
+ index = builder.Sections.IndexOf(look[0]);
276
+
277
+ string sectionPath = FolderUtility.GetAssetFolderPath(builder.Sections[index]);
278
+
279
+ string sectionPrefix = builder.Sections[index].name.Replace(".asset", "");
280
+
281
+ string roomStateName = sectionPrefix + "_" + pValue.Description;
282
+
283
+ if (!FolderUtility.TryCreateFolder(ref sectionPath, roomStateName))
284
+ return;
285
+
286
+ string newAssetPath = $"{sectionPath}/{roomStateName}.asset";
287
+
288
+ RoomStateData room = roomStateEditor.CreateRoomState(pValue, newAssetPath);
289
+
290
+ UnityEngine.Debug.Log(JsonUtility.ToJson(room));
291
+
292
+ builder.Sections[index].Rooms.Add(room);
293
+
294
+ EditorUtility.SetDirty(builder.Sections[index]);
295
+ }
296
+
297
+ #endregion
298
+
299
+ #region Clear Drop Down
300
+
301
+ /// <inheritdoc/>
302
+ protected override void OnClearFoldOut()
303
+ {
304
+ foreach (IRoomStateLoader loader in manager.loaders)
305
+ if (GUILayout.Button("Unload " + loader.GetTypeName(), GUILayout.Width(150)))
306
+ if (EditorUtility.DisplayDialog($"Unload {loader.GetTypeName()}",
307
+ $"Are you sure you want to destroy/unload all {loader.GetTypeName()}?",
308
+ "Yes", "No"))
309
+ {
310
+ loader.Unload(true);
311
+
312
+ EditorUtility.SetDirty(manager);
313
+ }
314
+ }
315
+
316
+ /// <inheritdoc/>
317
+ protected override void ClearAll()
318
+ {
319
+ manager.UnloadAll(true);
320
+
321
+ EditorUtility.SetDirty(manager);
322
+ }
323
+
324
+ #endregion
325
+
326
+ #region Display Room States
327
+
328
+ /// <inheritdoc/>
329
+ protected override void DisplayShellData() => shellEditor.DisplayShellData();
330
+
331
+ /// <inheritdoc/>
332
+ protected override void DisplayRoomStates()
333
+ {
334
+ RoomStateSection current = null;
335
+
336
+ for (int i = 0; i < builder.Sections.Count; i++)
337
+ {
338
+ RoomStateSection roomSection = builder.Sections[i];
339
+
340
+ if (roomSection == null)
341
+ {
342
+ builder.Sections.Remove(roomSection);
343
+
344
+ EditorUtility.SetDirty(builder);
345
+
346
+ AssetDatabase.SaveAssetIfDirty(builder);
347
+
348
+ continue;
349
+ }
350
+
351
+ if (roomSection.Chapter == pDB.Chapters[pDB.Chapters.IndexOf(managerBase.Chapter)])
352
+ {
353
+ current = roomSection;
354
+
355
+ break;
356
+ }
357
+ }
358
+
359
+ if (current == null)
360
+ GUILayout.Label("Couldn't find a Room Builder Section with the related chapter. " +
361
+ "Please do not create a room save while this is showing.");
362
+ else
363
+ DisplayRoomSaves(current);
364
+ }
365
+
366
+ /// <summary>
367
+ ///
368
+ /// </summary>
369
+ /// <param name="current"></param>
370
+ protected virtual void DisplayRoomSaves(RoomStateSection current)
371
+ {
372
+ if (current.Rooms.Count > 0)
373
+ {
374
+ if (roomStateEditor.saveFolds.Count != current.Rooms.Count)
375
+ for (int i = 0; i < current.Rooms.Count; i++)
376
+ roomStateEditor.saveFolds.Add(false);
377
+
378
+ roomFold = EditorGUILayout.Foldout(roomFold, "Saved Rooms");
379
+
380
+ if (roomFold)
381
+ {
382
+ GUILayout.Label("On Load will remove REFERENCED Actors");
383
+
384
+ for (int i = 0; i < current.Rooms.Count; i++)
385
+ roomStateEditor.DisplayRoomSave(current, i, current.Rooms[i], current.Rooms[i].progressionValue.Description);
386
+ }
387
+ }
388
+ }
389
+
390
+ #endregion
391
+ }
392
+ }
393
393
  #endif