From 30b4da4268be47c98607ff1b17bcf9fd054c1216 Mon Sep 17 00:00:00 2001 From: IAmBatby Date: Sat, 30 Nov 2024 13:28:48 +1100 Subject: [PATCH] Release v1.3.12 --- .../LethalLevelLoaderNetworkManager.cs | 21 +++++++++++++++++++ LethalLevelLoader/Patches/SaveManager.cs | 2 +- LethalLevelLoader/Plugin.cs | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/LethalLevelLoader/Patches/LethalLevelLoaderNetworkManager.cs b/LethalLevelLoader/Patches/LethalLevelLoaderNetworkManager.cs index a97fbd5..20dfdf4 100644 --- a/LethalLevelLoader/Patches/LethalLevelLoaderNetworkManager.cs +++ b/LethalLevelLoader/Patches/LethalLevelLoaderNetworkManager.cs @@ -176,6 +176,26 @@ public static void RegisterNetworkPrefab(GameObject prefab) DebugHelper.LogWarning("Attempted To Register NetworkPrefab: " + prefab + " After GameNetworkManager Has Started!", DebugType.User); } + public static T SetupNetworkManagerObject() where T : NetworkBehaviour + { + GameObject newPrefab = new GameObject(nameof(T)); + newPrefab.hideFlags = HideFlags.HideAndDontSave; + + T instancedBehaviour = newPrefab.AddComponent(); + + NetworkObject networkObject = newPrefab.AddComponent(); + byte[] hash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetCallingAssembly().GetName().Name + nameof(T))); + networkObject.GlobalObjectIdHash = BitConverter.ToUInt32(hash, 0); + networkObject.DontDestroyWithOwner = true; + networkObject.SceneMigrationSynchronization = true; + networkObject.DestroyWithScene = true; + GameObject.DontDestroyOnLoad(newPrefab); + + NetworkManager.Singleton.AddNetworkPrefab(newPrefab); + + return (instancedBehaviour); + } + internal static void RegisterPrefabs(NetworkManager networkManager) { //DebugHelper.Log("Game NetworkManager Start"); @@ -205,6 +225,7 @@ internal static void RegisterPrefabs(NetworkManager networkManager) } + public class StringContainer : INetworkSerializable { public string SomeText; diff --git a/LethalLevelLoader/Patches/SaveManager.cs b/LethalLevelLoader/Patches/SaveManager.cs index 859d4dd..a3db57a 100644 --- a/LethalLevelLoader/Patches/SaveManager.cs +++ b/LethalLevelLoader/Patches/SaveManager.cs @@ -63,7 +63,7 @@ internal static void SaveGameValues() internal static void SaveAllLevels() { - currentSaveFile.extendedLevelSaveData.Clear(); + currentSaveFile.extendedLevelSaveData = new List(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) currentSaveFile.extendedLevelSaveData.Add(new ExtendedLevelData(extendedLevel)); } diff --git a/LethalLevelLoader/Plugin.cs b/LethalLevelLoader/Plugin.cs index da81372..a439ad5 100644 --- a/LethalLevelLoader/Plugin.cs +++ b/LethalLevelLoader/Plugin.cs @@ -24,7 +24,7 @@ public class Plugin : BaseUnityPlugin { public const string ModGUID = "imabatby.lethallevelloader"; public const string ModName = "LethalLevelLoader"; - public const string ModVersion = "1.3.11"; + public const string ModVersion = "1.3.12"; internal static Plugin Instance;