From a789ba4db158b1c9c350e4b1d32f9727074e8ef8 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Tue, 16 Dec 2025 20:16:24 +0100 Subject: [PATCH 01/10] add changes to make compilable for hk 1.5.12301 --- Assembly-CSharp/Assembly-CSharp.csproj | 47 ++----------------- Assembly-CSharp/Menu/MenuUtils.cs | 2 +- Assembly-CSharp/Mod.cs | 1 + Assembly-CSharp/ModHooks.cs | 12 ++--- Assembly-CSharp/ModListMenu.cs | 2 +- Assembly-CSharp/Patches/GameManager.cs | 1 + Assembly-CSharp/Patches/HeroController.cs | 3 +- Assembly-CSharp/Patches/Language.cs | 55 ++++++++++++----------- 8 files changed, 45 insertions(+), 78 deletions(-) diff --git a/Assembly-CSharp/Assembly-CSharp.csproj b/Assembly-CSharp/Assembly-CSharp.csproj index 337c16c9..d9493277 100644 --- a/Assembly-CSharp/Assembly-CSharp.csproj +++ b/Assembly-CSharp/Assembly-CSharp.csproj @@ -148,7 +148,7 @@ ..\override\mscorlib.dll - + ../Vanilla/netstandard.dll @@ -158,47 +158,8 @@ ../Vanilla/PlayMaker.dll False - - ../Vanilla/UnityEngine.dll - - - ../Vanilla/UnityEngine.AnimationModule.dll - - - ../Vanilla/UnityEngine.AssetBundleModule.dll - - - ../Vanilla/UnityEngine.AudioModule.dll - - - ../Vanilla/UnityEngine.CoreModule.dll - - - ../Vanilla/UnityEngine.ImageConversionModule.dll - - - ../Vanilla/UnityEngine.IMGUIModule.dll - - - ../Vanilla/UnityEngine.InputLegacyModule.dll - - - ../Vanilla/UnityEngine.JSONSerializeModule.dll - - - ../Vanilla/UnityEngine.ParticleSystemModule.dll - - - ../Vanilla/UnityEngine.Physics2DModule.dll - - - ../Vanilla/UnityEngine.TextRenderingModule.dll - - - ../Vanilla/UnityEngine.UI.dll - - - ../Vanilla/UnityEngine.UIModule.dll - + + + diff --git a/Assembly-CSharp/Menu/MenuUtils.cs b/Assembly-CSharp/Menu/MenuUtils.cs index af0a1de8..0bd47d9a 100644 --- a/Assembly-CSharp/Menu/MenuUtils.cs +++ b/Assembly-CSharp/Menu/MenuUtils.cs @@ -8,7 +8,7 @@ using UnityEngine; using UnityEngine.UI; using Patch = Modding.Patches; -using Lang = Language.Language; +using Lang = TeamCherry.Localization.Language; namespace Modding.Menu diff --git a/Assembly-CSharp/Mod.cs b/Assembly-CSharp/Mod.cs index 3e476940..c64f4abf 100644 --- a/Assembly-CSharp/Mod.cs +++ b/Assembly-CSharp/Mod.cs @@ -10,6 +10,7 @@ using MonoMod.Utils; using System.Linq; using Newtonsoft.Json.Linq; +using Language = TeamCherry.Localization; // ReSharper disable file UnusedMember.Global diff --git a/Assembly-CSharp/ModHooks.cs b/Assembly-CSharp/ModHooks.cs index 1ba7815f..1364fc68 100644 --- a/Assembly-CSharp/ModHooks.cs +++ b/Assembly-CSharp/ModHooks.cs @@ -61,10 +61,10 @@ static ModHooks() { string[] versionNums = Constants.GAME_VERSION.Split('.'); - gameVersion.major = Convert.ToInt32(versionNums[0]); - gameVersion.minor = Convert.ToInt32(versionNums[1]); - gameVersion.revision = Convert.ToInt32(versionNums[2]); - gameVersion.package = Convert.ToInt32(versionNums[3]); + gameVersion.major = versionNums.Length > 0 ? Convert.ToInt32(versionNums[0]) : 0; + gameVersion.minor = versionNums.Length > 1 ? Convert.ToInt32(versionNums[1]) : 0; + gameVersion.revision = versionNums.Length > 2 ? Convert.ToInt32(versionNums[2]) : 0; + gameVersion.package = versionNums.Length > 3 ? Convert.ToInt32(versionNums[3]) : 0; } catch (Exception e) { @@ -225,7 +225,9 @@ internal static void LogConsole(string message, LogLevel level) /// N/A internal static string LanguageGet(string key, string sheet) { - string res = Patches.Language.GetInternal(key, sheet); + // todo: fixme: yea i think you know what would need fixing + // string res = Patches.Language.GetInternal(key, sheet); + string res = TeamCherry.Localization.Language.Get(key, sheet); if (LanguageGetHook == null) return res; diff --git a/Assembly-CSharp/ModListMenu.cs b/Assembly-CSharp/ModListMenu.cs index fec0f388..0a7b6082 100644 --- a/Assembly-CSharp/ModListMenu.cs +++ b/Assembly-CSharp/ModListMenu.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; using static Modding.ModLoader; using Patch = Modding.Patches; -using Lang = Language.Language; +using Lang = TeamCherry.Localization.Language; namespace Modding { diff --git a/Assembly-CSharp/Patches/GameManager.cs b/Assembly-CSharp/Patches/GameManager.cs index 9510c2d5..90e6d013 100644 --- a/Assembly-CSharp/Patches/GameManager.cs +++ b/Assembly-CSharp/Patches/GameManager.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; +using Encryption = TeamCherry.SharedUtils.Encryption; // ReSharper disable all #pragma warning disable 1591, 649, 414, 169, CS0108, CS0626 diff --git a/Assembly-CSharp/Patches/HeroController.cs b/Assembly-CSharp/Patches/HeroController.cs index 8d9bee86..cf98aec6 100644 --- a/Assembly-CSharp/Patches/HeroController.cs +++ b/Assembly-CSharp/Patches/HeroController.cs @@ -528,6 +528,7 @@ private void LookForQueueInput() [MonoModIgnore] public event HeroController.TakeDamageEvent OnTakenDamage; + // todo: fixme: this had changes in the method, check if more shit changed [MonoModReplace] public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount, int hazardType) { @@ -667,7 +668,7 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount if (this.cState.wallSliding) { this.cState.wallSliding = false; - this.wallSlideVibrationPlayer.Stop(); + this.vibrationCtrl.StopWallSlide(); } if (this.cState.touchingWall) diff --git a/Assembly-CSharp/Patches/Language.cs b/Assembly-CSharp/Patches/Language.cs index 5fbd34c2..093f62b9 100644 --- a/Assembly-CSharp/Patches/Language.cs +++ b/Assembly-CSharp/Patches/Language.cs @@ -7,31 +7,32 @@ namespace Modding.Patches { - [MonoModPatch("global::Language.Language")] - public static class Language - { - [MonoModIgnore] - private static Dictionary> currentEntrySheets; - - public static string GetInternal(string key, string sheetTitle) - { - if (currentEntrySheets == null || !currentEntrySheets.ContainsKey(sheetTitle)) - { - Debug.LogError($"The sheet with title \"{sheetTitle}\" does not exist!"); - return string.Empty; - } - - if (currentEntrySheets[sheetTitle].ContainsKey(key)) - { - return currentEntrySheets[sheetTitle][key]; - } - - return "#!#" + key + "#!#"; - } - - public static string Get(string key, string sheetTitle) - { - return ModHooks.LanguageGet(key, sheetTitle); - } - } + // todo: fixme: yea i think you know what would need fixing +// [MonoModPatch("global::Language.Language")] +// public static class Language +// { +// [MonoModIgnore] +// private static Dictionary> currentEntrySheets; +// +// public static string GetInternal(string key, string sheetTitle) +// { +// if (currentEntrySheets == null || !currentEntrySheets.ContainsKey(sheetTitle)) +// { +// Debug.LogError($"The sheet with title \"{sheetTitle}\" does not exist!"); +// return string.Empty; +// } +// +// if (currentEntrySheets[sheetTitle].ContainsKey(key)) +// { +// return currentEntrySheets[sheetTitle][key]; +// } +// +// return "#!#" + key + "#!#"; +// } +// +// public static string Get(string key, string sheetTitle) +// { +// return ModHooks.LanguageGet(key, sheetTitle); +// } +// } } \ No newline at end of file From ad0ffab370efc022b69ebdc1b49fcbb68816e40b Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Tue, 16 Dec 2025 20:35:55 +0100 Subject: [PATCH 02/10] it wasn't public, it was private --- Assembly-CSharp/Patches/HeroController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assembly-CSharp/Patches/HeroController.cs b/Assembly-CSharp/Patches/HeroController.cs index cf98aec6..2ad6fffe 100644 --- a/Assembly-CSharp/Patches/HeroController.cs +++ b/Assembly-CSharp/Patches/HeroController.cs @@ -668,7 +668,7 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount if (this.cState.wallSliding) { this.cState.wallSliding = false; - this.vibrationCtrl.StopWallSlide(); + ReflectionHelper.GetField("vibrationCtrl").StopWallSlide(); } if (this.cState.touchingWall) From bad9b709332acd10f980fe626af145e85668a9ba Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:05:39 +0100 Subject: [PATCH 03/10] do fancy private stuff --- Assembly-CSharp/Patches/HeroController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assembly-CSharp/Patches/HeroController.cs b/Assembly-CSharp/Patches/HeroController.cs index 2ad6fffe..c4926810 100644 --- a/Assembly-CSharp/Patches/HeroController.cs +++ b/Assembly-CSharp/Patches/HeroController.cs @@ -528,6 +528,9 @@ private void LookForQueueInput() [MonoModIgnore] public event HeroController.TakeDamageEvent OnTakenDamage; + [MonoModIgnore] + private HeroVibrationController vibrationCtrl; + // todo: fixme: this had changes in the method, check if more shit changed [MonoModReplace] public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount, int hazardType) @@ -668,7 +671,7 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount if (this.cState.wallSliding) { this.cState.wallSliding = false; - ReflectionHelper.GetField("vibrationCtrl").StopWallSlide(); + this.vibrationCtrl.StopWallSlide(); } if (this.cState.touchingWall) From dcfaa9f4e8ebcbc2737d928421a684eb49642d24 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Wed, 17 Dec 2025 01:55:53 +0100 Subject: [PATCH 04/10] language doesn't need to get patched if it doesn't exist in the first place, so it can just be created - no clue what to do with `Language.Language.Get(key)` though --- Assembly-CSharp/Language/Language.cs | 33 ++++++++++++++++++++++++ Assembly-CSharp/Menu/MenuUtils.cs | 2 +- Assembly-CSharp/Mod.cs | 1 - Assembly-CSharp/ModHooks.cs | 4 +-- Assembly-CSharp/ModListMenu.cs | 2 +- Assembly-CSharp/Patches/Language.cs | 38 ---------------------------- 6 files changed, 36 insertions(+), 44 deletions(-) create mode 100644 Assembly-CSharp/Language/Language.cs delete mode 100644 Assembly-CSharp/Patches/Language.cs diff --git a/Assembly-CSharp/Language/Language.cs b/Assembly-CSharp/Language/Language.cs new file mode 100644 index 00000000..763b59cd --- /dev/null +++ b/Assembly-CSharp/Language/Language.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using Modding; +using TeamCherry.Localization; +using UnityEngine; +using UObject = UnityEngine.Object; +using TLLanguage = TeamCherry.Localization.Language; + +namespace Language; + +public static class Language +{ + public static void LoadLanguage() => TLLanguage.LoadLanguage(); + public static void LoadAvailableLanguages() => TLLanguage.LoadAvailableLanguages(); + public static string[] GetLanguages() => TLLanguage.GetLanguages(); + public static bool SwitchLanguage(string langCode) => TLLanguage.SwitchLanguage(langCode); + public static bool SwitchLanguage(LanguageCode code) => TLLanguage.SwitchLanguage(code); + public static UObject GetAsset(string name) => TLLanguage.GetAsset(name); + public static LanguageCode CurrentLanguage() => TLLanguage.CurrentLanguage(); + public static string Get(string key) => TLLanguage.Get(key); + //public static string Get(string key, string sheetTitle) => TLLanguage.Get(key, sheetTitle); + public static IEnumerable GetSheets() => TLLanguage.GetSheets(); + public static IEnumerable GetKeys(string sheetTitle) => TLLanguage.GetKeys(sheetTitle); + public static bool Has(string key) => TLLanguage.Has(key); + public static bool Has(string key, string sheet) => TLLanguage.Has(key, sheet); + public static bool HasSheet(string sheet) => TLLanguage.HasSheet(sheet); + public static LanguageCode LanguageNameToCode(SystemLanguage name) => TLLanguage.LanguageNameToCode(name); + + public static string GetInternal(string key, string sheetTitle) => TLLanguage.Get(key, sheetTitle); + public static string Get(string key, string sheetTitle) + { + return ModHooks.LanguageGet(key, sheetTitle); + } +} diff --git a/Assembly-CSharp/Menu/MenuUtils.cs b/Assembly-CSharp/Menu/MenuUtils.cs index 0bd47d9a..af0a1de8 100644 --- a/Assembly-CSharp/Menu/MenuUtils.cs +++ b/Assembly-CSharp/Menu/MenuUtils.cs @@ -8,7 +8,7 @@ using UnityEngine; using UnityEngine.UI; using Patch = Modding.Patches; -using Lang = TeamCherry.Localization.Language; +using Lang = Language.Language; namespace Modding.Menu diff --git a/Assembly-CSharp/Mod.cs b/Assembly-CSharp/Mod.cs index c64f4abf..3e476940 100644 --- a/Assembly-CSharp/Mod.cs +++ b/Assembly-CSharp/Mod.cs @@ -10,7 +10,6 @@ using MonoMod.Utils; using System.Linq; using Newtonsoft.Json.Linq; -using Language = TeamCherry.Localization; // ReSharper disable file UnusedMember.Global diff --git a/Assembly-CSharp/ModHooks.cs b/Assembly-CSharp/ModHooks.cs index 1364fc68..0ea986d3 100644 --- a/Assembly-CSharp/ModHooks.cs +++ b/Assembly-CSharp/ModHooks.cs @@ -225,9 +225,7 @@ internal static void LogConsole(string message, LogLevel level) /// N/A internal static string LanguageGet(string key, string sheet) { - // todo: fixme: yea i think you know what would need fixing - // string res = Patches.Language.GetInternal(key, sheet); - string res = TeamCherry.Localization.Language.Get(key, sheet); + string res = Language.Language.GetInternal(key, sheet); if (LanguageGetHook == null) return res; diff --git a/Assembly-CSharp/ModListMenu.cs b/Assembly-CSharp/ModListMenu.cs index 0a7b6082..fec0f388 100644 --- a/Assembly-CSharp/ModListMenu.cs +++ b/Assembly-CSharp/ModListMenu.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; using static Modding.ModLoader; using Patch = Modding.Patches; -using Lang = TeamCherry.Localization.Language; +using Lang = Language.Language; namespace Modding { diff --git a/Assembly-CSharp/Patches/Language.cs b/Assembly-CSharp/Patches/Language.cs deleted file mode 100644 index 093f62b9..00000000 --- a/Assembly-CSharp/Patches/Language.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using MonoMod; -using UnityEngine; - -// ReSharper disable All -#pragma warning disable 1591, CS0649 - -namespace Modding.Patches -{ - // todo: fixme: yea i think you know what would need fixing -// [MonoModPatch("global::Language.Language")] -// public static class Language -// { -// [MonoModIgnore] -// private static Dictionary> currentEntrySheets; -// -// public static string GetInternal(string key, string sheetTitle) -// { -// if (currentEntrySheets == null || !currentEntrySheets.ContainsKey(sheetTitle)) -// { -// Debug.LogError($"The sheet with title \"{sheetTitle}\" does not exist!"); -// return string.Empty; -// } -// -// if (currentEntrySheets[sheetTitle].ContainsKey(key)) -// { -// return currentEntrySheets[sheetTitle][key]; -// } -// -// return "#!#" + key + "#!#"; -// } -// -// public static string Get(string key, string sheetTitle) -// { -// return ModHooks.LanguageGet(key, sheetTitle); -// } -// } -} \ No newline at end of file From e4e10bc77adb57fcb5d8b5c647cb7692e120d111 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Thu, 18 Dec 2025 18:35:05 +0100 Subject: [PATCH 05/10] use `MonoMod.MonoModLinkFrom` - but that requires all `TeamCherry.Localization.Language` to be done dynamically, via strings, as *all* references to it are replaced, even ones manually written here --- Assembly-CSharp/Language/Language.cs | 95 +++++++++++++++++++++------- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/Assembly-CSharp/Language/Language.cs b/Assembly-CSharp/Language/Language.cs index 763b59cd..00f8bdc1 100644 --- a/Assembly-CSharp/Language/Language.cs +++ b/Assembly-CSharp/Language/Language.cs @@ -1,33 +1,80 @@ +using System; using System.Collections.Generic; -using Modding; -using TeamCherry.Localization; -using UnityEngine; +using System.Reflection; using UObject = UnityEngine.Object; -using TLLanguage = TeamCherry.Localization.Language; +using USystemLanguage = UnityEngine.SystemLanguage; namespace Language; +// for backwards compatibility +[MonoMod.MonoModLinkFrom("TeamCherry.Localization.Language")] public static class Language { - public static void LoadLanguage() => TLLanguage.LoadLanguage(); - public static void LoadAvailableLanguages() => TLLanguage.LoadAvailableLanguages(); - public static string[] GetLanguages() => TLLanguage.GetLanguages(); - public static bool SwitchLanguage(string langCode) => TLLanguage.SwitchLanguage(langCode); - public static bool SwitchLanguage(LanguageCode code) => TLLanguage.SwitchLanguage(code); - public static UObject GetAsset(string name) => TLLanguage.GetAsset(name); - public static LanguageCode CurrentLanguage() => TLLanguage.CurrentLanguage(); - public static string Get(string key) => TLLanguage.Get(key); - //public static string Get(string key, string sheetTitle) => TLLanguage.Get(key, sheetTitle); - public static IEnumerable GetSheets() => TLLanguage.GetSheets(); - public static IEnumerable GetKeys(string sheetTitle) => TLLanguage.GetKeys(sheetTitle); - public static bool Has(string key) => TLLanguage.Has(key); - public static bool Has(string key, string sheet) => TLLanguage.Has(key, sheet); - public static bool HasSheet(string sheet) => TLLanguage.HasSheet(sheet); - public static LanguageCode LanguageNameToCode(SystemLanguage name) => TLLanguage.LanguageNameToCode(name); - - public static string GetInternal(string key, string sheetTitle) => TLLanguage.Get(key, sheetTitle); - public static string Get(string key, string sheetTitle) + static Language() { - return ModHooks.LanguageGet(key, sheetTitle); + TllType = Type.GetType("TeamCherry.Localization.Language, TeamCherry.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); + TllLoadLanguage = TllType.GetMethod("LoadLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty(), Array.Empty()); + TllLoadAvailableLanguages = TllType.GetMethod("LoadAvailableLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty(), Array.Empty()); + TllGetLanguages = TllType.GetMethod("GetLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty(), Array.Empty()); + TllSwitchLanguageStr = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllSwitchLanguageLc = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(TeamCherry.Localization.LanguageCode) }, Array.Empty()); + TllGetAsset = TllType.GetMethod("GetAsset", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllCurrentLanguage = TllType.GetMethod("CurrentLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty(), Array.Empty()); + TllGet1 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllGetSheets = TllType.GetMethod("GetSheets", BindingFlags.Public | BindingFlags.Static, null, Array.Empty(), Array.Empty()); + TllGetKeys = TllType.GetMethod("GetKeys", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllHas1 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllHas2 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty()); + TllHasSheet = TllType.GetMethod("HasSheet", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty()); + TllLanguageNameToCode = TllType.GetMethod("LanguageNameToCode", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(USystemLanguage) }, Array.Empty()); + TllGet2 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty()); } -} + private static readonly Type TllType; + + private static readonly MethodInfo TllLoadLanguage; + public static void LoadLanguage() => TllLoadLanguage.Invoke(null, Array.Empty()); + + private static readonly MethodInfo TllLoadAvailableLanguages; + public static void LoadAvailableLanguages() => TllLoadAvailableLanguages.Invoke(null, Array.Empty()); + + private static readonly MethodInfo TllGetLanguages; + public static string[] GetLanguages() => (string[])(TllGetLanguages.Invoke(null, Array.Empty())); + + private static readonly MethodInfo TllSwitchLanguageStr; + public static bool SwitchLanguage(string langCode) => (bool)(TllSwitchLanguageStr.Invoke(null, new object[] { langCode })); + + private static readonly MethodInfo TllSwitchLanguageLc; + public static bool SwitchLanguage(TeamCherry.Localization.LanguageCode code) => (bool)(TllSwitchLanguageLc.Invoke(null, new object[] { code })); + + private static readonly MethodInfo TllGetAsset; + public static UObject GetAsset(string name) => (UObject)(TllGetAsset.Invoke(null, new object[] { name })); + + private static readonly MethodInfo TllCurrentLanguage; + public static TeamCherry.Localization.LanguageCode CurrentLanguage() => (TeamCherry.Localization.LanguageCode)(TllCurrentLanguage.Invoke(null, Array.Empty())); + + private static readonly MethodInfo TllGet1; + public static string Get(string key) => (string)(TllGet1.Invoke(null, new object[] { key })); + + private static readonly MethodInfo TllGetSheets; + public static IEnumerable GetSheets() => (IEnumerable)(TllGetSheets.Invoke(null, Array.Empty())); + + private static readonly MethodInfo TllGetKeys; + public static IEnumerable GetKeys(string sheetTitle) => (IEnumerable)(TllGetKeys.Invoke(null, new object[] { sheetTitle })); + + private static readonly MethodInfo TllHas1; + public static bool Has(string key) => (bool)(TllHas1.Invoke(null, new object[] { key })); + + private static readonly MethodInfo TllHas2; + public static bool Has(string key, string sheet) => (bool)(TllHas2.Invoke(null, new object[] { key, sheet })); + + private static readonly MethodInfo TllHasSheet; + public static bool HasSheet(string sheet) => (bool)(TllHasSheet.Invoke(null, new object[] { sheet })); + + private static readonly MethodInfo TllLanguageNameToCode; + public static TeamCherry.Localization.LanguageCode LanguageNameToCode(USystemLanguage name) => (TeamCherry.Localization.LanguageCode)(TllLanguageNameToCode.Invoke(null, new object[] { name })); + + private static readonly MethodInfo TllGet2; + public static string GetInternal(string key, string sheetTitle) => (string)(TllGet2.Invoke(null, new object[] { key, sheetTitle })); + + public static string Get(string key, string sheetTitle) => Modding.ModHooks.LanguageGet(key, sheetTitle); +} \ No newline at end of file From 7a06e1279e0f72160fdcc2d237e3e4120cd66aaa Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Tue, 23 Dec 2025 17:25:22 +0100 Subject: [PATCH 06/10] adjust patches to methods how they appear in dnspy v6.2.0 --- Assembly-CSharp/Patches/GameManager.cs | 74 +++++----- Assembly-CSharp/Patches/HeroController.cs | 136 +++++++++++------- Assembly-CSharp/Patches/InputHandler.cs | 16 +-- Assembly-CSharp/Patches/MenuSetting.cs | 10 +- Assembly-CSharp/Patches/OnScreenDebugInfo.cs | 40 ------ .../Patches/PlayMakerUnity2DProxy.cs | 2 +- Assembly-CSharp/Patches/SceneManager.cs | 65 +++++---- Assembly-CSharp/Patches/StartManager.cs | 87 ++++++++++- Assembly-CSharp/Patches/TakeDamage.cs | 3 +- Assembly-CSharp/Patches/UIManager.cs | 2 + 10 files changed, 268 insertions(+), 167 deletions(-) delete mode 100644 Assembly-CSharp/Patches/OnScreenDebugInfo.cs diff --git a/Assembly-CSharp/Patches/GameManager.cs b/Assembly-CSharp/Patches/GameManager.cs index 90e6d013..99526b73 100644 --- a/Assembly-CSharp/Patches/GameManager.cs +++ b/Assembly-CSharp/Patches/GameManager.cs @@ -197,9 +197,7 @@ public void SaveGame(int saveSlot, Action callback) text = JsonUtility.ToJson(obj); } - bool flag = this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected; - - if (flag) + if (this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected) { string graph = Encryption.Encrypt(text); BinaryFormatter binaryFormatter = new BinaryFormatter(); @@ -579,12 +577,12 @@ public IEnumerator LoadSceneAdditive(string destScene) AsyncOperation loadop = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(destScene, LoadSceneMode.Additive); loadop.allowSceneActivation = true; yield return loadop; - yield return UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(exitingScene); + UnityEngine.SceneManagement.SceneManager.UnloadScene(exitingScene); ModHooks.OnSceneChanged(destScene); this.RefreshTilemapInfo(destScene); if (this.IsUnloadAssetsRequired(exitingScene, destScene)) { - Debug.LogFormat(this, "Unloading assets due to zone transition", new object[0]); + Debug.LogFormat(this, "Unloading assets due to zone transition", Array.Empty()); yield return Resources.UnloadUnusedAssets(); } @@ -629,48 +627,46 @@ public void OnWillActivateFirstLevel() [MonoModIgnore] public extern void SetTimeScale(float timescale); + [MonoModIgnore] + private extern void SetPausedState(bool value); + // code has been copied from PauseGameToggle public IEnumerator PauseToggleDynamicMenu(MenuScreen screen, bool allowUnpause = false) { - if (!this.TimeSlowed) + if (this.TimeSlowed) + { + yield break; + } + if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING) { - if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING) + this.isPaused = true; + this.ui.SetState(GlobalEnums.UIState.PAUSED); + this.SetPausedState(true); + this.SetState(GlobalEnums.GameState.PAUSED); + if (HeroController.instance != null) { - this.gameCams.StopCameraShake(); - this.inputHandler.PreventPause(); - this.inputHandler.StopUIInput(); - this.actorSnapshotPaused.TransitionTo(0f); - this.isPaused = true; - this.SetState(GlobalEnums.GameState.PAUSED); - this.ui.AudioGoToPauseMenu(0.2f); - this.ui.UIPauseToDynamicMenu(screen); - if (HeroController.instance != null) - { - HeroController.instance.Pause(); - } - this.gameCams.MoveMenuToHUDCamera(); - this.SetTimeScale(0f); - yield return new WaitForSecondsRealtime(0.8f); - this.inputHandler.AllowPause(); + HeroController.instance.Pause(); } - else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED) + this.gameCams.MoveMenuToHUDCamera(); + this.inputHandler.PreventPause(); + this.inputHandler.StopUIInput(); + yield return new WaitForSecondsRealtime(0.3f); + this.inputHandler.AllowPause(); + } + else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED) + { + this.isPaused = false; + this.inputHandler.PreventPause(); + this.ui.SetState(GlobalEnums.UIState.PLAYING); + this.SetPausedState(false); + this.SetState(GlobalEnums.GameState.PLAYING); + if (HeroController.instance != null) { - this.gameCams.ResumeCameraShake(); - this.inputHandler.PreventPause(); - this.actorSnapshotUnpaused.TransitionTo(0f); - this.isPaused = false; - this.ui.AudioGoToGameplay(0.2f); - this.ui.SetState( GlobalEnums.UIState.PLAYING); - this.SetState( GlobalEnums.GameState.PLAYING); - if (HeroController.instance != null) - { - HeroController.instance.UnPause(); - } - MenuButtonList.ClearAllLastSelected(); - this.SetTimeScale(1f); - yield return new WaitForSecondsRealtime(0.8f); - this.inputHandler.AllowPause(); + HeroController.instance.UnPause(); } + MenuButtonList.ClearAllLastSelected(); + yield return new WaitForSecondsRealtime(0.3f); + this.inputHandler.AllowPause(); } yield break; } diff --git a/Assembly-CSharp/Patches/HeroController.cs b/Assembly-CSharp/Patches/HeroController.cs index c4926810..29306aed 100644 --- a/Assembly-CSharp/Patches/HeroController.cs +++ b/Assembly-CSharp/Patches/HeroController.cs @@ -73,6 +73,47 @@ public void Attack(AttackDirection attackDir) this.wallSlashing = true; this.slashComponent = this.wallSlash; this.slashFsm = this.wallSlashFsm; + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_35))) + { + if ((this.playerData.GetInt(nameof(PlayerData.health)) == this.playerData.GetInt(nameof(PlayerData.CurrentMaxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) + { + if (this.transform.localScale.x > 0f) + { + this.grubberFlyBeam = this.grubberFlyBeamPrefabR.Spawn(this.transform.position); + } + else + { + this.grubberFlyBeam = this.grubberFlyBeamPrefabL.Spawn(this.transform.position); + } + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_13))) + { + this.grubberFlyBeam.transform.SetScaleY(this.MANTIS_CHARM_SCALE); + } + else + { + this.grubberFlyBeam.transform.SetScaleY(1f); + } + } + if (this.playerData.GetInt(nameof(PlayerData.health)) == 1 && this.playerData.GetBool(nameof(PlayerData.equippedCharm_6)) && this.playerData.GetInt(nameof(PlayerData.healthBlue)) < 1) + { + if (this.transform.localScale.x > 0f) + { + this.grubberFlyBeam = this.grubberFlyBeamPrefabR_fury.Spawn(this.transform.position); + } + else + { + this.grubberFlyBeam = this.grubberFlyBeamPrefabL_fury.Spawn(this.transform.position); + } + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_13))) + { + this.grubberFlyBeam.transform.SetScaleY(this.MANTIS_CHARM_SCALE); + } + else + { + this.grubberFlyBeam.transform.SetScaleY(1f); + } + } + } } else { @@ -94,7 +135,7 @@ public void Attack(AttackDirection attackDir) if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_35))) { - if ((this.playerData.GetInt(nameof(PlayerData.health)) == this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) + if ((this.playerData.GetInt(nameof(PlayerData.health)) >= this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) { if (this.transform.localScale.x < 0f) { @@ -144,7 +185,7 @@ public void Attack(AttackDirection attackDir) this.cState.upAttacking = true; if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_35))) { - if ((this.playerData.GetInt(nameof(PlayerData.health)) == this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) + if ((this.playerData.GetInt(nameof(PlayerData.health)) >= this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) { this.grubberFlyBeam = this.grubberFlyBeamPrefabU.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); @@ -174,7 +215,7 @@ public void Attack(AttackDirection attackDir) this.cState.downAttacking = true; if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_35))) { - if ((this.playerData.GetInt(nameof(PlayerData.health)) == this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) + if ((this.playerData.GetInt(nameof(PlayerData.health)) >= this.playerData.GetInt(nameof(PlayerData.maxHealth)) && !this.playerData.GetBool(nameof(PlayerData.equippedCharm_27))) || (this.joniBeam && this.playerData.GetBool(nameof(PlayerData.equippedCharm_27)))) { this.grubberFlyBeam = this.grubberFlyBeamPrefabD.Spawn(this.transform.position); this.grubberFlyBeam.transform.SetScaleY(this.transform.localScale.x); @@ -247,17 +288,16 @@ public void Attack(AttackDirection attackDir) [MonoModReplace] public void SoulGain() { - int mpcharge = this.playerData.GetInt("MPCharge"); int num; - if (mpcharge < this.playerData.GetInt("maxMP")) + if (this.playerData.GetInt(nameof(PlayerData.MPCharge)) < this.playerData.GetInt(nameof(PlayerData.maxMP))) { num = 11; - if (this.playerData.GetBool("equippedCharm_20")) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_20))) { num += 3; } - if (this.playerData.GetBool("equippedCharm_21")) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_21))) { num += 8; } @@ -265,22 +305,22 @@ public void SoulGain() else { num = 6; - if (this.playerData.GetBool("equippedCharm_20")) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_20))) { num += 2; } - if (this.playerData.GetBool("equippedCharm_21")) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_21))) { num += 6; } } - int mpreserve = this.playerData.GetInt("MPReserve"); + int mpreserve = this.playerData.GetInt(nameof(PlayerData.MPReserve)); num = Modding.ModHooks.OnSoulGain(num); this.playerData.AddMPCharge(num); GameCameras.instance.soulOrbFSM.SendEvent("MP GAIN"); - if (this.playerData.GetInt("MPReserve") != mpreserve) + if (this.playerData.GetInt(nameof(PlayerData.MPReserve)) != mpreserve) { this.gm.soulVessel_fsm.SendEvent("MP RESERVE UP"); } @@ -475,8 +515,7 @@ private void LookForQueueInput() && this.dashQueueSteps <= this.DASH_QUEUE_STEPS && this.CanDash() && this.dashQueuing - && !ModHooks.OnDashPressed() - && this.CanDash()) + && !ModHooks.OnDashPressed()) { this.HeroDash(); } @@ -531,7 +570,6 @@ private void LookForQueueInput() [MonoModIgnore] private HeroVibrationController vibrationCtrl; - // todo: fixme: this had changes in the method, check if more shit changed [MonoModReplace] public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount, int hazardType) { @@ -578,7 +616,7 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount mixer.StopAllEmissionsWithTag("heroAction"); } - bool flag = false; + bool carefreeShouldStopDamage = false; if (this.carefreeShieldEquipped && hazardType == 1) { if (this.hitsSinceShielded > 7) @@ -591,58 +629,58 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount case 1: if ((float) UnityEngine.Random.Range(1, 100) <= 10f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 2: if ((float) UnityEngine.Random.Range(1, 100) <= 20f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 3: if ((float) UnityEngine.Random.Range(1, 100) <= 30f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 4: if ((float) UnityEngine.Random.Range(1, 100) <= 50f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 5: if ((float) UnityEngine.Random.Range(1, 100) <= 70f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 6: if ((float) UnityEngine.Random.Range(1, 100) <= 80f) { - flag = true; + carefreeShouldStopDamage = true; } break; case 7: if ((float) UnityEngine.Random.Range(1, 100) <= 90f) { - flag = true; + carefreeShouldStopDamage = true; } break; default: - flag = false; + carefreeShouldStopDamage = false; break; } - if (flag) + if (carefreeShouldStopDamage) { this.hitsSinceShielded = 0; this.carefreeShield.SetActive(true); @@ -655,7 +693,7 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount } } - if (this.playerData.GetBool("equippedCharm_5") && this.playerData.GetInt("blockerHits") > 0 && hazardType == 1 && this.cState.focusing && !flag) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_5)) && this.playerData.GetInt(nameof(PlayerData.blockerHits)) > 0 && hazardType == 1 && this.cState.focusing && !carefreeShouldStopDamage) { this.proxyFSM.SendEvent("HeroCtrl-TookBlockerHit"); this.audioSource.PlayOneShot(this.blockerImpact, 1f); @@ -687,24 +725,24 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount if (this.cState.bouncing) { this.CancelBounce(); - this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f); + this.rb2d.linearVelocity = new Vector2(this.rb2d.linearVelocity.x, 0f); } if (this.cState.shroomBouncing) { this.CancelBounce(); - this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f); + this.rb2d.linearVelocity = new Vector2(this.rb2d.linearVelocity.x, 0f); } - if (!flag) + if (!carefreeShouldStopDamage) { this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT); } damageAmount = ModHooks.AfterTakeDamage(hazardType, damageAmount); - if (!this.takeNoDamage && !this.playerData.GetBool("invinciTest")) + if (!this.takeNoDamage && !this.playerData.GetBool(nameof(PlayerData.invinciTest))) { - if (this.playerData.GetBool("overcharmed")) + if (this.playerData.GetBool(nameof(PlayerData.overcharmed))) { this.playerData.TakeHealth(damageAmount * 2); } @@ -714,9 +752,9 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount } } - if (this.playerData.GetBool("equippedCharm_3") && damageAmount > 0) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_3)) && damageAmount > 0) { - if (this.playerData.GetBool("equippedCharm_35")) + if (this.playerData.GetBool(nameof(PlayerData.equippedCharm_35))) { this.AddMPCharge(this.GRUB_SOUL_MP_COMBO); } @@ -742,32 +780,35 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount this.OnTakenDamage(); } - if (this.playerData.GetInt("health") == 0) + if (this.playerData.GetInt(nameof(PlayerData.health)) == 0) { base.StartCoroutine(this.Die()); + return; } else if (hazardType == 2) { base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z)); + return; } else if (hazardType == 3) { base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f)); + return; } else if (hazardType == 4) { Debug.Log("Lava death"); + return; } else if (hazardType == 5) { base.StartCoroutine(this.DieFromHazard(HazardType.PIT, 0f)); + return; } - else - { - base.StartCoroutine(this.StartRecoil(damageSide, spawnDamageEffect, damageAmount)); - } + base.StartCoroutine(this.StartRecoil(damageSide, spawnDamageEffect, damageAmount)); + return; } - else if (this.cState.invulnerable && !this.cState.hazardDeath && !this.playerData.GetBool("isInvincible")) + else if (this.cState.invulnerable && !this.cState.hazardDeath && !this.playerData.GetBool(nameof(PlayerData.isInvincible))) { if (hazardType == 2) { @@ -784,8 +825,8 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount } else { - this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT); - base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z)); + this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT, false); + base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (go != null) ? go.transform.rotation.z : 0f)); } } else if (hazardType == 3) @@ -793,14 +834,13 @@ public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount damageAmount = ModHooks.AfterTakeDamage(hazardType, damageAmount); this.playerData.TakeHealth(damageAmount); this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged"); - if (this.playerData.GetInt("health") == 0) + if (this.playerData.GetInt(nameof(PlayerData.health)) == 0) { base.StartCoroutine(this.Die()); + return; } - else - { - base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f)); - } + base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f)); + return; } else if (hazardType == 4) { @@ -875,7 +915,7 @@ private Vector2 OrigDashVector() origVector = new Vector2 ( velocity, - (!this.cState.onGround) ? BUMP_VELOCITY_DASH : BUMP_VELOCITY + this.cState.onGround ? BUMP_VELOCITY : BUMP_VELOCITY_DASH ); } else @@ -888,7 +928,7 @@ private Vector2 OrigDashVector() origVector = new Vector2 ( -velocity, - (!this.cState.onGround) ? BUMP_VELOCITY_DASH : BUMP_VELOCITY + this.cState.onGround ? BUMP_VELOCITY : BUMP_VELOCITY_DASH ); } else @@ -912,7 +952,7 @@ private void Dash() Vector2 vector = OrigDashVector(); vector = ModHooks.DashVelocityChange(vector); - rb2d.velocity = vector; + rb2d.linearVelocity = vector; dash_timer += Time.deltaTime; } diff --git a/Assembly-CSharp/Patches/InputHandler.cs b/Assembly-CSharp/Patches/InputHandler.cs index 3e5a18b4..51cf80e0 100644 --- a/Assembly-CSharp/Patches/InputHandler.cs +++ b/Assembly-CSharp/Patches/InputHandler.cs @@ -21,30 +21,30 @@ public class InputHandler : global::InputHandler [MonoModIgnore] private GameManager gm; + [MonoModIgnore] + private extern void SetCursorVisible(bool value); + // Reverted cursor behavior [MonoModReplace] private void OnGUI() { Cursor.lockState = CursorLockMode.None; - if (isTitleScreenScene) + if (this.isTitleScreenScene) { Cursor.visible = false; return; } - - if (!isMenuScene) + if (this.isMenuScene) { - ModHooks.OnCursor(gm); + Cursor.visible = !this.controllerPressed; return; } - - if (controllerPressed) + if (!this.gm.isPaused) { Cursor.visible = false; return; } - - Cursor.visible = true; + Cursor.visible = !this.controllerPressed; } } } \ No newline at end of file diff --git a/Assembly-CSharp/Patches/MenuSetting.cs b/Assembly-CSharp/Patches/MenuSetting.cs index 51f1b298..6f989f5b 100644 --- a/Assembly-CSharp/Patches/MenuSetting.cs +++ b/Assembly-CSharp/Patches/MenuSetting.cs @@ -55,15 +55,21 @@ public enum MenuSettingType VSync, // where did 13 go MonitorSelect = 14, - FrameCap, + SwitchFrameCap, ParticleLevel, ShaderQuality, + Dithering, + Noise, // HUH???? GameLanguage = 33, GameBackerCredits, NativeAchievements, + ControllerRumble = 37, + HudVisibility = 39, + CameraShake, NativeInput, - ControllerRumble, + XInput, + MFi, // peepoHappy CustomSetting } diff --git a/Assembly-CSharp/Patches/OnScreenDebugInfo.cs b/Assembly-CSharp/Patches/OnScreenDebugInfo.cs deleted file mode 100644 index a04d41a0..00000000 --- a/Assembly-CSharp/Patches/OnScreenDebugInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Threading; -using MonoMod; -using UnityEngine; - -// ReSharper disable All -#pragma warning disable 1591, CS0626 - -namespace Modding.Patches -{ - [MonoModPatch("global::OnScreenDebugInfo")] - public class OnScreenDebugInfo : global::OnScreenDebugInfo - { - private extern void orig_Awake(); - - private void Awake() - { - if (ModLoader.LoadState == ModLoader.ModLoadState.NotStarted) - { - Logger.APILogger.Log("Main menu loading"); - ModLoader.LoadState = ModLoader.ModLoadState.Started; - - GameObject obj = new GameObject(); - DontDestroyOnLoad(obj); - - // Preload reflection - new Thread(ReflectionHelper.PreloadCommonTypes).Start(); - - // NonBouncer does absolutely nothing, which makes it a good dummy to run the loader - obj.AddComponent().StartCoroutine(ModLoader.LoadModsInit(obj)); - } - else - { - // Debug log because this is the expected code path - Logger.APILogger.LogDebug($"OnScreenDebugInfo: Already begun mod loading (state {ModLoader.LoadState})"); - } - - orig_Awake(); - } - } -} \ No newline at end of file diff --git a/Assembly-CSharp/Patches/PlayMakerUnity2DProxy.cs b/Assembly-CSharp/Patches/PlayMakerUnity2DProxy.cs index 9cd2d27b..5209f962 100644 --- a/Assembly-CSharp/Patches/PlayMakerUnity2DProxy.cs +++ b/Assembly-CSharp/Patches/PlayMakerUnity2DProxy.cs @@ -23,7 +23,7 @@ public void Start() } ModHooks.OnColliderCreate(gameObject); - RefreshImplementation(); + this.RefreshImplementation(); } } } \ No newline at end of file diff --git a/Assembly-CSharp/Patches/SceneManager.cs b/Assembly-CSharp/Patches/SceneManager.cs index 677dfbbd..efc9876d 100644 --- a/Assembly-CSharp/Patches/SceneManager.cs +++ b/Assembly-CSharp/Patches/SceneManager.cs @@ -20,12 +20,14 @@ public class SceneManager : global::SceneManager [MonoModIgnore] private bool heroInfoSent; + // [MonoModIgnore] private extern void orig_Update(); [MonoModIgnore] private GameManager gm; //Added checks for null and an attempt to fix any missing references + // [MonoModReplace] private void Update() { if (this.gameplayScene) @@ -40,40 +42,51 @@ private void Update() orig_Update(); } + [MonoModIgnore] + private Transform borderLeft; + + [MonoModIgnore] + private Transform borderRight; + + [MonoModIgnore] + private Transform borderUp; + + [MonoModIgnore] + private Transform borderDown; + + // [MonoModIgnore] + private extern void orig_OnCameraAspectChanged(float aspect); + //add modhook to send the newly created borders to any mods that want them - [MonoModReplace] - private void DrawBlackBorders() + // [MonoModReplace] + private void OnCameraAspectChanged(float aspect) { - List borders = new List(); - GameObject gameObject = UnityEngine.Object.Instantiate(this.borderPrefab); - gameObject.transform.SetPosition2D(this.gm.sceneWidth + 10f, this.gm.sceneHeight / 2f); - gameObject.transform.localScale = new Vector2(20f, this.gm.sceneHeight + 40f); - borders.Add(gameObject); - - gameObject = UnityEngine.Object.Instantiate(this.borderPrefab); - gameObject.transform.SetPosition2D(-10f, this.gm.sceneHeight / 2f); - gameObject.transform.localScale = new Vector2(20f, this.gm.sceneHeight + 40f); - borders.Add(gameObject); - - gameObject = UnityEngine.Object.Instantiate(this.borderPrefab); - gameObject.transform.SetPosition2D(this.gm.sceneWidth / 2f, this.gm.sceneHeight + 10f); - gameObject.transform.localScale = new Vector2(40f + this.gm.sceneWidth, 20f); - borders.Add(gameObject); - - gameObject = UnityEngine.Object.Instantiate(this.borderPrefab); - gameObject.transform.SetPosition2D(this.gm.sceneWidth / 2f, -10f); - gameObject.transform.localScale = new Vector2(40f + this.gm.sceneWidth, 20f); - borders.Add(gameObject); + orig_OnCameraAspectChanged(aspect); - ModHooks.OnDrawBlackBorders(borders); - - foreach (var border in borders) + List borders = new List(); + if (this.borderLeft != null) + { + borders.Add(this.borderLeft.gameObject); + } + if (this.borderRight != null) + { + borders.Add(this.borderRight.gameObject); + } + if (this.borderUp != null) + { + borders.Add(this.borderUp.gameObject); + } + if (this.borderDown != null) { - UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(border, base.gameObject.scene); + borders.Add(this.borderDown.gameObject); } + ModHooks.OnDrawBlackBorders(borders); } + // [MonoModIgnore] private extern void orig_Start(); + + // [MonoModReplace] private void Start() { try diff --git a/Assembly-CSharp/Patches/StartManager.cs b/Assembly-CSharp/Patches/StartManager.cs index 01b8dbb1..da475c89 100644 --- a/Assembly-CSharp/Patches/StartManager.cs +++ b/Assembly-CSharp/Patches/StartManager.cs @@ -1,6 +1,9 @@ -using System.Collections; +using System; +using System.Collections; +using System.Threading; using MonoMod; using UnityEngine; +using UObject = UnityEngine.Object; // ReSharper disable All #pragma warning disable 1591, CS0649 @@ -12,6 +15,33 @@ namespace Modding.Patches [MonoModPatch("global::StartManager")] public class StartManager : global::StartManager { + private extern void orig_Awake(); + + private void Awake() + { + orig_Awake(); + + if (ModLoader.LoadState == ModLoader.ModLoadState.NotStarted) + { + Logger.APILogger.Log("Main menu loading"); + ModLoader.LoadState = ModLoader.ModLoadState.Started; + + GameObject obj = new GameObject(); + DontDestroyOnLoad(obj); + + // Preload reflection + new Thread(ReflectionHelper.PreloadCommonTypes).Start(); + + // NonBouncer does absolutely nothing, which makes it a good dummy to run the loader + obj.AddComponent().StartCoroutine(ModLoader.LoadModsInit(obj)); + } + else + { + // Debug log because this is the expected code path + Logger.APILogger.LogDebug($"StartManager: Already begun mod loading (state {ModLoader.LoadState})"); + } + } + [MonoModIgnore] private bool confirmedLanguage; @@ -35,6 +65,7 @@ private IEnumerator Start() this.controllerImage.sprite = this.GetControllerSpriteForPlatform(this.platform); AsyncOperation loadOperation = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("Menu_Title"); loadOperation.allowSceneActivation = false; + Platform.Current.SetSceneLoadState(true, false); bool showLanguageSelect = !this.CheckIsLanguageSet(); if (showLanguageSelect && Platform.Current.ShowLanguageSelect) { @@ -46,12 +77,64 @@ private IEnumerator Start() yield return base.StartCoroutine(this.LanguageSettingDone()); } - + TeamCherry.Localization.LanguageCode currentLanguage = Language.Language.CurrentLanguage(); + while (!Platform.Current.IsSharedDataMounted) + { + yield return null; + } + bool flag = false; + string text; + if (TeamCherry.Localization.LocalizationProjectSettings.TryGetSavedLanguageCode(out text)) + { + TeamCherry.Localization.LanguageCode languageEnum = TeamCherry.Localization.LocalizationSettings.GetLanguageEnum(text); + if (currentLanguage != languageEnum) + { + flag = true; + } + } + if (flag) + { + Language.Language.LoadLanguage(); + ChangeFontByLanguage[] array = UObject.FindObjectsByType(FindObjectsSortMode.None); + for (int i = 0; i < array.Length; i++) + { + array[i].SetFont(); + } + SetTextMeshProGameText[] componentsInChildren = base.GetComponentsInChildren(true); + for (int i = 0; i < componentsInChildren.Length; i++) + { + componentsInChildren[i].UpdateText(); + } + LogoLanguage[] componentsInChildren2 = base.GetComponentsInChildren(true); + for (int i = 0; i < componentsInChildren2.Length; i++) + { + componentsInChildren2[i].SetSprite(); + } + } this.startManagerAnimator.SetBool("WillShowControllerNotice", false); this.startManagerAnimator.SetBool("WillShowQuote", true); StandaloneLoadingSpinner loadSpinner = UnityEngine.Object.Instantiate(this.loadSpinnerPrefab); loadSpinner.Setup(null); + bool didWaitForPlayerPrefs = false; + while (!Platform.Current.IsPlayerPrefsLoaded) + { + if (!didWaitForPlayerPrefs) + { + didWaitForPlayerPrefs = true; + Debug.LogFormat("Waiting for PlayerPrefs load...", Array.Empty()); + } + yield return null; + } + if (!didWaitForPlayerPrefs) + { + Debug.LogFormat("Didn't need to wait for PlayerPrefs load.", Array.Empty()); + } + else + { + Debug.LogFormat("Finished waiting for PlayerPrefs load.", Array.Empty()); + } + Platform.Current.SetSceneLoadState(true, true); loadOperation.allowSceneActivation = true; yield return loadOperation; yield break; diff --git a/Assembly-CSharp/Patches/TakeDamage.cs b/Assembly-CSharp/Patches/TakeDamage.cs index fdd497ae..3210812e 100644 --- a/Assembly-CSharp/Patches/TakeDamage.cs +++ b/Assembly-CSharp/Patches/TakeDamage.cs @@ -11,6 +11,7 @@ public class TakeDamage : HutongGames.PlayMaker.Actions.TakeDamage [MonoModReplace] public override void OnEnter() { + base.OnEnter(); HitInstance hit = new HitInstance { Source = base.Owner, @@ -22,7 +23,7 @@ public override void OnEnter() MagnitudeMultiplier = this.MagnitudeMultiplier.Value, MoveAngle = this.MoveAngle.Value, MoveDirection = this.MoveDirection.Value, - Multiplier = ((!this.Multiplier.IsNone) ? this.Multiplier.Value : 1f), + Multiplier = (this.Multiplier.IsNone ? 1f : this.Multiplier.Value), SpecialType = (SpecialTypes) this.SpecialType.Value, IsExtraDamage = false }; diff --git a/Assembly-CSharp/Patches/UIManager.cs b/Assembly-CSharp/Patches/UIManager.cs index 0de510dd..b79be999 100644 --- a/Assembly-CSharp/Patches/UIManager.cs +++ b/Assembly-CSharp/Patches/UIManager.cs @@ -194,10 +194,12 @@ public enum MainMenuState MAIN_MENU, OPTIONS_MENU, GAMEPAD_MENU, + ADVANCED_GAMEPAD_MENU, KEYBOARD_MENU, SAVE_PROFILES, AUDIO_MENU, VIDEO_MENU, + ADVANCED_VIDEO_MENU, EXIT_PROMPT, OVERSCAN_MENU, GAME_OPTIONS_MENU, From e0e6d67a00058b2a8c2ebf1af1cb89393baed3cf Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Tue, 23 Dec 2025 18:26:03 +0100 Subject: [PATCH 07/10] make use of game's vanilla binaries & don't have newtonsoft and mscorlib in output --- Assembly-CSharp/Assembly-CSharp.csproj | 31 +++++++++----------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Assembly-CSharp/Assembly-CSharp.csproj b/Assembly-CSharp/Assembly-CSharp.csproj index d9493277..7a5ae4fe 100644 --- a/Assembly-CSharp/Assembly-CSharp.csproj +++ b/Assembly-CSharp/Assembly-CSharp.csproj @@ -10,6 +10,7 @@ true packages latest + true @@ -17,7 +18,6 @@ - @@ -72,10 +72,8 @@ - + - - @@ -141,25 +139,16 @@ - - ../Vanilla/Assembly-CSharp.dll - False - - - ..\override\mscorlib.dll - - - ../Vanilla/netstandard.dll - - - ../JsonNet/Newtonsoft.Json.dll - - - ../Vanilla/PlayMaker.dll - False - + + + + + + + + From e91596fa6e2471e4535fcb306f75f689fa925e47 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:07:33 +0100 Subject: [PATCH 08/10] remove unused method --- Assembly-CSharp/Patches/InputHandler.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Assembly-CSharp/Patches/InputHandler.cs b/Assembly-CSharp/Patches/InputHandler.cs index 51cf80e0..2dd48dcf 100644 --- a/Assembly-CSharp/Patches/InputHandler.cs +++ b/Assembly-CSharp/Patches/InputHandler.cs @@ -21,9 +21,6 @@ public class InputHandler : global::InputHandler [MonoModIgnore] private GameManager gm; - [MonoModIgnore] - private extern void SetCursorVisible(bool value); - // Reverted cursor behavior [MonoModReplace] private void OnGUI() From bff85a4e58141f4958b9daf0bb703a8f32ee5269 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:07:53 +0100 Subject: [PATCH 09/10] remove base onenter --- Assembly-CSharp/Patches/TakeDamage.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assembly-CSharp/Patches/TakeDamage.cs b/Assembly-CSharp/Patches/TakeDamage.cs index 3210812e..5a55ff7e 100644 --- a/Assembly-CSharp/Patches/TakeDamage.cs +++ b/Assembly-CSharp/Patches/TakeDamage.cs @@ -11,7 +11,6 @@ public class TakeDamage : HutongGames.PlayMaker.Actions.TakeDamage [MonoModReplace] public override void OnEnter() { - base.OnEnter(); HitInstance hit = new HitInstance { Source = base.Owner, From 7b64c07950b80c6b086b6e8f717788086bca6313 Mon Sep 17 00:00:00 2001 From: SFGrenade <25555417+SFGrenade@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:24:32 +0100 Subject: [PATCH 10/10] made loading work better --- Assembly-CSharp/Patches/StartManager.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Assembly-CSharp/Patches/StartManager.cs b/Assembly-CSharp/Patches/StartManager.cs index da475c89..933e1000 100644 --- a/Assembly-CSharp/Patches/StartManager.cs +++ b/Assembly-CSharp/Patches/StartManager.cs @@ -15,15 +15,16 @@ namespace Modding.Patches [MonoModPatch("global::StartManager")] public class StartManager : global::StartManager { + private bool startedPreloading = false; + private extern void orig_Awake(); private void Awake() { - orig_Awake(); - if (ModLoader.LoadState == ModLoader.ModLoadState.NotStarted) { Logger.APILogger.Log("Main menu loading"); + startedPreloading = true; ModLoader.LoadState = ModLoader.ModLoadState.Started; GameObject obj = new GameObject(); @@ -40,6 +41,8 @@ private void Awake() // Debug log because this is the expected code path Logger.APILogger.LogDebug($"StartManager: Already begun mod loading (state {ModLoader.LoadState})"); } + + orig_Awake(); } [MonoModIgnore] @@ -60,11 +63,17 @@ private void Awake() [MonoModIgnore] private extern IEnumerator LanguageSettingDone(); + [MonoModReplace] private IEnumerator Start() { this.controllerImage.sprite = this.GetControllerSpriteForPlatform(this.platform); - AsyncOperation loadOperation = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("Menu_Title"); - loadOperation.allowSceneActivation = false; + + AsyncOperation loadOperation = null; + if (!startedPreloading) + { + loadOperation = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("Menu_Title"); + loadOperation.allowSceneActivation = false; + } Platform.Current.SetSceneLoadState(true, false); bool showLanguageSelect = !this.CheckIsLanguageSet(); if (showLanguageSelect && Platform.Current.ShowLanguageSelect) @@ -135,8 +144,11 @@ private IEnumerator Start() Debug.LogFormat("Finished waiting for PlayerPrefs load.", Array.Empty()); } Platform.Current.SetSceneLoadState(true, true); - loadOperation.allowSceneActivation = true; - yield return loadOperation; + if (!startedPreloading) + { + loadOperation.allowSceneActivation = true; + yield return loadOperation; + } yield break; } }