diff --git a/WurstMod/Runtime/Loader.cs b/WurstMod/Runtime/Loader.cs index 6d80516..f005900 100644 --- a/WurstMod/Runtime/Loader.cs +++ b/WurstMod/Runtime/Loader.cs @@ -112,7 +112,7 @@ private static IEnumerator LoadCustomScene(LevelInfo level) // Step 3: Destroy all unused objects foreach (var gameObject in objects.SelectMany(o => o.GetComponentsInChildren())) - foreach (var filter in sceneLoader.DestroyOnLoad) + foreach (var filter in sceneLoader.EnumerateDestroyOnLoad()) if (gameObject.name.Contains(filter)) Object.Destroy(gameObject.gameObject); diff --git a/WurstMod/Runtime/SceneLoaders/CustomSceneLoader.cs b/WurstMod/Runtime/SceneLoaders/CustomSceneLoader.cs index 83a0ad1..9e0f488 100644 --- a/WurstMod/Runtime/SceneLoaders/CustomSceneLoader.cs +++ b/WurstMod/Runtime/SceneLoaders/CustomSceneLoader.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using UnityEngine; using WurstMod.MappingComponents.Generic; @@ -20,12 +21,12 @@ public abstract class CustomSceneLoader /// This is implemented by the deriving class and tells the loader which scene to use as the base for the game mode /// public abstract string BaseScene { get; } - + /// /// This list contains the names of all objects that should be removed from the scene when loading a new level /// - public abstract string[] DestroyOnLoad { get; } - + public virtual IEnumerable EnumerateDestroyOnLoad() => new[] {"!ftraceLightmaps"}.AsEnumerable(); + public CustomScene LevelRoot { get; set; } /// diff --git a/WurstMod/Runtime/SceneLoaders/SandboxSceneLoader.cs b/WurstMod/Runtime/SceneLoaders/SandboxSceneLoader.cs index c968f3c..7cb69df 100644 --- a/WurstMod/Runtime/SceneLoaders/SandboxSceneLoader.cs +++ b/WurstMod/Runtime/SceneLoaders/SandboxSceneLoader.cs @@ -1,4 +1,6 @@ -using WurstMod.Runtime; +using System.Collections.Generic; +using System.Linq; +using WurstMod.Runtime; using WurstMod.Shared; namespace WurstMod.SceneLoaders @@ -8,14 +10,18 @@ public class SandboxSceneLoader : CustomSceneLoader public override string GamemodeId => Constants.GamemodeSandbox; public override string BaseScene => "ProvingGround"; - public override string[] DestroyOnLoad => new[] + public override IEnumerable EnumerateDestroyOnLoad() { - "_Animator_Spawning_", - "_Boards", - "_Env", - "AILadderTest1", - // TODO: Should probably remove all the Anvil Prefabs, but it causes errors... - //"__SpawnOnLoad", - }; + + return base.EnumerateDestroyOnLoad().Concat(new[] + { + "_Animator_Spawning_", + "_Boards", + "_Env", + "AILadderTest1", + // TODO: Should probably remove all the Anvil Prefabs, but it causes errors... + //"__SpawnOnLoad", + }); + } } } \ No newline at end of file diff --git a/WurstMod/Runtime/SceneLoaders/TakeAndHoldSceneLoader.cs b/WurstMod/Runtime/SceneLoaders/TakeAndHoldSceneLoader.cs index 44560a3..d2c787a 100644 --- a/WurstMod/Runtime/SceneLoaders/TakeAndHoldSceneLoader.cs +++ b/WurstMod/Runtime/SceneLoaders/TakeAndHoldSceneLoader.cs @@ -16,18 +16,21 @@ public class TakeAndHoldSceneLoader : CustomSceneLoader public override string GamemodeId => Constants.GamemodeTakeAndHold; public override string BaseScene => "TakeAndHoldClassic"; - public override string[] DestroyOnLoad => new[] + public override IEnumerable EnumerateDestroyOnLoad() { - // Take and Hold objects - "HoldPoint_", - "Ladders", - "Lighting", - "OpenArea", - "RampHelperCubes", - "ReflectionProbes", - "SupplyPoint_", - "Tiles" - }; + return base.EnumerateDestroyOnLoad().Concat(new[] + { + // Take and Hold objects + "HoldPoint_", + "Ladders", + "Lighting", + "OpenArea", + "RampHelperCubes", + "ReflectionProbes", + "SupplyPoint_", + "Tiles" + }); + } /// /// Base function for setting up the TNH Manager object to handle a custom level.