diff --git a/WurstMod/Runtime/Entrypoint.cs b/WurstMod/Runtime/Entrypoint.cs index f6c3c7a..95bb382 100644 --- a/WurstMod/Runtime/Entrypoint.cs +++ b/WurstMod/Runtime/Entrypoint.cs @@ -20,6 +20,9 @@ public class Entrypoint : DeliBehaviour public Entrypoint() { + // Patches + Patches.Patch(); + // Add a number of callbacks Stages.Setup += StagesOnSetup; SceneManager.sceneLoaded += SceneManager_sceneLoaded; diff --git a/WurstMod/Runtime/Loader.cs b/WurstMod/Runtime/Loader.cs index 482c64f..002531a 100644 --- a/WurstMod/Runtime/Loader.cs +++ b/WurstMod/Runtime/Loader.cs @@ -42,17 +42,8 @@ public static IEnumerator OnSceneLoad(Scene scene) if (IsLoadInProgress && LevelToLoad.HasValue) { - // We're loading the modded scene after the base scene - ScenePatcher.RunPatches(scene); - IsLoadInProgress = false; } - - if (!IsLoadInProgress && !LevelToLoad.HasValue) - { - // We're loading a base scene - ScenePatcher.RunPatches(scene); - } } /// @@ -135,7 +126,7 @@ private static IEnumerator MergeCustomScene(LevelInfo level) yield return null; // Then merge the scene into the original - SceneManager.MergeScenes(SceneManager.GetSceneAt(SceneManager.sceneCount - 1), SceneManager.GetActiveScene()); + SceneManager.MergeScenes(SceneManager.GetSceneByName(sceneName), SceneManager.GetActiveScene()); // Find the level component ObjectReferences.CustomScene = _loadedScene.GetRootGameObjects() diff --git a/WurstMod/Runtime/ScenePatchers/MainMenuScenePatcher.cs b/WurstMod/Runtime/ScenePatchers/MainMenuScenePatcher.cs deleted file mode 100644 index faa06bf..0000000 --- a/WurstMod/Runtime/ScenePatchers/MainMenuScenePatcher.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using FistVR; -using UnityEngine; -using UnityEngine.SceneManagement; -using UnityEngine.UI; -using WurstMod.Shared; - -namespace WurstMod.Runtime.ScenePatchers -{ - [ScenePatcher("MainMenu3")] - public class MainMenuScenePatcher : ScenePatcher - { - public override void PatchScene(Scene loaded) - { - // TODO: Setup new scene selector! - } - } -} \ No newline at end of file diff --git a/WurstMod/Runtime/ScenePatchers/ScenePatcher.cs b/WurstMod/Runtime/ScenePatchers/ScenePatcher.cs deleted file mode 100644 index 5ce9005..0000000 --- a/WurstMod/Runtime/ScenePatchers/ScenePatcher.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.SceneManagement; -using WurstMod.Shared; - -namespace WurstMod.Runtime -{ - public abstract class ScenePatcher - { - public abstract void PatchScene(Scene scene); - - /// - /// Enumerates a list of scene patchers for the given scene name - /// - public static void RunPatches(Scene scene) - { - var types = AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(a => a.GetTypes()) - .Where(t => t.IsSubclassOf(typeof(ScenePatcher))); - - Debug.Log("Found " + types.Count() + " patchers: " + string.Join(", ", types.Select(x => x.Name).ToArray())); - - foreach (var patcher in - from type in types - let attributes = type.GetCustomAttributes(typeof(ScenePatcherAttribute), false) - where attributes.Length != 0 - where ((ScenePatcherAttribute) attributes[0]).SceneName == scene.name - select (ScenePatcher) Activator.CreateInstance(type)) patcher.PatchScene(scene); - } - } - - /// - /// Marks a ScenePatcher class for use with a specific scene - /// - public class ScenePatcherAttribute : Attribute - { - public string SceneName { get; } - - public ScenePatcherAttribute(string sceneName) => SceneName = sceneName; - } -} \ No newline at end of file diff --git a/WurstMod/Shared/Constants.cs b/WurstMod/Shared/Constants.cs index 66fbf45..bc26c73 100644 --- a/WurstMod/Shared/Constants.cs +++ b/WurstMod/Shared/Constants.cs @@ -2,7 +2,7 @@ { internal static class Constants { - public const string LegacyLevelsDirectory = "mods/legacy/CustomLevels"; + public const string LegacyLevelsDirectory = "Deli/mods/legacy/CustomLevels"; public const string FilenameLevelData = "leveldata"; public const string FilenameLevelInfo = "info.json"; public const string FilenameLevelThumbnail = "thumb.png"; diff --git a/WurstMod/Shared/LevelInfo.cs b/WurstMod/Shared/LevelInfo.cs index bdc064f..6ae1a54 100644 --- a/WurstMod/Shared/LevelInfo.cs +++ b/WurstMod/Shared/LevelInfo.cs @@ -3,6 +3,7 @@ using FistVR; using UnityEngine; using Valve.Newtonsoft.Json; +using Valve.VR.InteractionSystem.Sample; namespace WurstMod.Shared { @@ -32,7 +33,7 @@ public Texture2D Thumbnail { get { - var stream = AssetBundlePath.OpenRead(); + var stream = ThumbnailPath.OpenRead(); var buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); var tex = new Texture2D(0, 0); diff --git a/WurstMod/WurstMod.csproj b/WurstMod/WurstMod.csproj index 26f1d89..984a35b 100644 --- a/WurstMod/WurstMod.csproj +++ b/WurstMod/WurstMod.csproj @@ -146,8 +146,6 @@ - -