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.
- package/.attestation.p7m +0 -0
- package/DREditor.RoomBuilding.asmdef +28 -28
- package/DREditor.RoomBuilding.asmdef.meta +7 -7
- package/Editor/DREditor.RoomBuilding.Editor.asmdef +19 -19
- package/Editor/DREditor.RoomBuilding.Editor.asmdef.meta +7 -7
- package/Editor/FindCharactersInRoomsWizard.cs +55 -55
- package/Editor/FindCharactersInRoomsWizard.cs.meta +11 -11
- package/Editor/RoomBuilderContainsObjective.cs +38 -38
- package/Editor/RoomBuilderContainsObjective.cs.meta +11 -11
- package/Editor/RoomBuilderScanWizard.cs +90 -90
- package/Editor/RoomBuilderScanWizard.cs.meta +11 -11
- package/Editor/ScanRoomBuilders.cs +74 -74
- package/Editor/ScanRoomBuilders.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/Implementation/Actors/ActorData.cs +115 -115
- package/Implementation/Actors/ActorData.cs.meta +11 -11
- package/Implementation/Actors/ActorStateData.cs +10 -10
- package/Implementation/Actors/ActorStateData.cs.meta +11 -11
- package/Implementation/Actors/ActorStateLoader.cs +344 -344
- package/Implementation/Actors/ActorStateLoader.cs.meta +11 -11
- package/Implementation/Actors/TActorData.cs +35 -35
- package/Implementation/Actors/TActorData.cs.meta +11 -11
- package/Implementation/Actors/TrialActorManager.cs +157 -157
- package/Implementation/Actors/TrialActorManager.cs.meta +11 -11
- package/Implementation/Actors.meta +8 -8
- package/Implementation/DoorLoader.cs +117 -117
- package/Implementation/DoorLoader.cs.meta +11 -11
- package/Implementation/DoorLoaderUtility.cs +51 -51
- package/Implementation/DoorLoaderUtility.cs.meta +11 -11
- package/Implementation/DoorStateData.cs +11 -11
- package/Implementation/DoorStateData.cs.meta +11 -11
- package/Implementation/ItemActorLoader.cs +157 -157
- package/Implementation/ItemActorLoader.cs.meta +11 -11
- package/Implementation/ItemData.cs +67 -67
- package/Implementation/ItemData.cs.meta +11 -11
- package/Implementation/ItemStateData.cs +10 -10
- package/Implementation/ItemStateData.cs.meta +11 -11
- package/Implementation/MoveLoader.cs +67 -67
- package/Implementation/MoveLoader.cs.meta +11 -11
- package/Implementation/MoveStateData.cs +11 -11
- package/Implementation/MoveStateData.cs.meta +11 -11
- package/Implementation/RoomStateHandlerBase.cs +241 -241
- package/Implementation/RoomStateHandlerBase.cs.meta +11 -11
- package/Implementation/SaveableData.cs +56 -56
- package/Implementation/SaveableData.cs.meta +11 -11
- package/Implementation/SaveableDataSet.cs +66 -66
- package/Implementation/SaveableDataSet.cs.meta +11 -11
- package/Implementation/SaveableManager.cs +70 -70
- package/Implementation/SaveableManager.cs.meta +11 -11
- package/Implementation/SaveableStateData.cs +10 -10
- package/Implementation/SaveableStateData.cs.meta +11 -11
- package/Implementation/SpawnableLoader.cs +125 -125
- package/Implementation/SpawnableLoader.cs.meta +11 -11
- package/Implementation/SpawnableStateData.cs +11 -11
- package/Implementation/SpawnableStateData.cs.meta +11 -11
- package/Implementation/StateDataAsset.cs +28 -28
- package/Implementation/StateDataAsset.cs.meta +11 -11
- package/Implementation/SubAreaLoader.cs +108 -108
- package/Implementation/SubAreaLoader.cs.meta +11 -11
- package/Implementation/SubAreaStateData.cs +11 -11
- package/Implementation/SubAreaStateData.cs.meta +11 -11
- package/Implementation/TriggerConverter.cs +137 -137
- package/Implementation/TriggerConverter.cs.meta +11 -11
- package/Implementation/TriggerLoader.cs +295 -295
- package/Implementation/TriggerLoader.cs.meta +11 -11
- package/Implementation/TriggerStateData.cs +18 -18
- package/Implementation/TriggerStateData.cs.meta +11 -11
- package/Implementation.meta +8 -8
- package/InstanceListWrapper.cs +23 -23
- package/InstanceListWrapper.cs.meta +11 -11
- package/Instances/ConvertInstanceData.cs +89 -89
- package/Instances/ConvertInstanceData.cs.meta +11 -11
- package/Instances/InstanceData.cs +43 -43
- package/Instances/InstanceData.cs.meta +11 -11
- package/Instances/InstanceStateData.cs +51 -51
- package/Instances/InstanceStateData.cs.meta +11 -11
- package/Instances/RoomInstanceData.cs +68 -68
- package/Instances/RoomInstanceData.cs.meta +11 -11
- package/Instances/RoomInstanceManager.cs +452 -452
- package/Instances/RoomInstanceManager.cs.meta +11 -11
- package/Instances.meta +8 -8
- package/LoadInvestigationRoomState.cs +53 -53
- package/LoadInvestigationRoomState.cs.meta +11 -11
- package/Old/ActorLoader.cs +382 -382
- package/Old/ActorLoader.cs.meta +11 -11
- package/Old/Room.cs +24 -24
- package/Old/Room.cs.meta +11 -11
- package/Old/RoomBuilder.cs +59 -59
- package/Old/RoomBuilder.cs.meta +11 -11
- package/Old/RoomData.cs +90 -90
- package/Old/RoomData.cs.meta +11 -11
- package/Old/RoomManager.cs +256 -256
- package/Old/RoomManager.cs.meta +11 -11
- package/Old/RoomManagerDisplayEditor.cs +72 -72
- package/Old/RoomManagerDisplayEditor.cs.meta +11 -11
- package/Old/RoomManagerEditor.cs +211 -211
- package/Old/RoomManagerEditor.cs.meta +11 -11
- package/Old/RoomManagerShellDisplayEditor.cs +48 -48
- package/Old/RoomManagerShellDisplayEditor.cs.meta +11 -11
- package/Old/RoomSection.cs +35 -35
- package/Old/RoomSection.cs.meta +11 -11
- package/Old.meta +8 -8
- package/RoomManagerBase.cs +84 -84
- package/RoomManagerBase.cs.meta +11 -11
- package/RoomManagerEditorBase.cs +86 -86
- package/RoomManagerEditorBase.cs.meta +11 -11
- package/RoomManagerEditorCoreBase.cs +159 -159
- package/RoomManagerEditorCoreBase.cs.meta +11 -11
- package/RoomSaveDisplayEditorBase.cs +111 -111
- package/RoomSaveDisplayEditorBase.cs.meta +11 -11
- package/RoomShellDisplayEditorBase.cs +68 -68
- package/RoomShellDisplayEditorBase.cs.meta +11 -11
- package/RoomStateBuilder.cs +53 -53
- package/RoomStateBuilder.cs.meta +11 -11
- package/RoomStateData.cs +58 -58
- package/RoomStateData.cs.meta +11 -11
- package/RoomStateManager.cs +202 -202
- package/RoomStateManager.cs.meta +11 -11
- package/RoomStateManagerEditor.cs +392 -392
- package/RoomStateManagerEditor.cs.meta +11 -11
- package/RoomStateSaveDisplayEditor.cs +175 -175
- package/RoomStateSaveDisplayEditor.cs.meta +11 -11
- package/RoomStateSection.cs +69 -69
- package/RoomStateSection.cs.meta +11 -11
- package/RoomStateShellDisplayEditor.cs +108 -108
- package/RoomStateShellDisplayEditor.cs.meta +11 -11
- package/{Samples → Samples~}/Room_State_Manager.prefab +473 -473
- package/{Samples → Samples~}/Room_State_Manager.prefab.meta +7 -7
- package/{Samples → Samples~}/Trial_Actor_Manager.prefab +51 -51
- package/{Samples → Samples~}/Trial_Actor_Manager.prefab.meta +7 -7
- package/package.json +51 -46
- package/package.json.meta +7 -7
- 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
|