Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NeatMenu v1.0.0
NeatMenu.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using NeatMenu.MonoBehaviours; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NeatMenu")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NeatMenu")] [assembly: AssemblyTitle("NeatMenu")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NeatMenu { public static class ModStateChecker { public static bool MoreCompanyLoaded; public static bool LethalConfigLoaded; public static bool LethalPhonesLoaded; public static bool DawnLibLoaded; public static bool TwitchChatAPILoaded; public static void Init() { MoreCompanyLoaded = Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"); LethalConfigLoaded = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); LethalPhonesLoaded = Chainloader.PluginInfos.ContainsKey("LethalPhones"); DawnLibLoaded = Chainloader.PluginInfos.ContainsKey("com.github.teamxiaolan.dawnlib"); TwitchChatAPILoaded = Chainloader.PluginInfos.ContainsKey("TwitchChatAPI.LethalCompany"); } public static bool CheckAchievementStatus() { Type type = AccessTools.TypeByName("Dusk.DuskModContent"); FieldInfo fieldInfo = AccessTools.Field(type, "Achievements"); object value = fieldInfo.GetValue(null); int num = (int)AccessTools.Property(value.GetType(), "Count").GetValue(value); bool flag = num == 0; Type type2 = AccessTools.TypeByName("Dawn.Internal.DawnConfig"); FieldInfo fieldInfo2 = AccessTools.Field(type2, "DisableAchievementsButton"); bool flag2 = fieldInfo2.GetValue(null) is ConfigEntry<bool> val && val.Value; if (flag2 || flag) { Log.Debug("Removing DawnLib Achievements button due to either config or Achievement Count."); return false; } return true; } } public enum MenuButtonType { MoreCompany, LethalPhones, LethalConfig, CatButton, DawnLibAchievements, TwitchChatAPI } internal class NeatMenuLayout { public static bool catButtonEnabled; public static List<MenuButtonType> activeButtons = new List<MenuButtonType>(); public static readonly Vector3 AnchorPosition = new Vector3(386.7359f, -205.2192f, 0f); public static readonly Vector3 AnchorScale = new Vector3(0.485f, 0.485f, 0.485f); public static Vector3[] GetPositions(int buttonCount) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) return buttonCount switch { 1 => (Vector3[])(object)new Vector3[1] { new Vector3(0f, 0f, 0f) }, 2 => (Vector3[])(object)new Vector3[2] { new Vector3(0f, 0f, 0f), new Vector3(-54f, 0f, 0f) }, 3 => (Vector3[])(object)new Vector3[3] { new Vector3(0f, 0f, 0f), new Vector3(-54f, 0f, 0f), new Vector3(-108f, 0f, 0f) }, 4 => (Vector3[])(object)new Vector3[4] { new Vector3(0f, 0f, 0f), new Vector3(-54f, 0f, 0f), new Vector3(0f, 50f, 0f), new Vector3(-54f, 50f, 0f) }, 5 => (Vector3[])(object)new Vector3[5] { new Vector3(0f, 0f, 0f), new Vector3(-54f, 0f, 0f), new Vector3(-108f, 0f, 0f), new Vector3(0f, 50f, 0f), new Vector3(-54f, 50f, 0f) }, 6 => (Vector3[])(object)new Vector3[6] { new Vector3(0f, 0f, 0f), new Vector3(-54f, 0f, 0f), new Vector3(-108f, 0f, 0f), new Vector3(0f, 50f, 0f), new Vector3(-54f, 50f, 0f), new Vector3(-108f, 50f, 0f) }, _ => Array.Empty<Vector3>(), }; } public static void GenerateButtonList() { activeButtons.Add(MenuButtonType.MoreCompany); if (ModStateChecker.LethalPhonesLoaded) { activeButtons.Add(MenuButtonType.LethalPhones); } if (ModStateChecker.LethalConfigLoaded) { activeButtons.Add(MenuButtonType.LethalConfig); } if (catButtonEnabled) { activeButtons.Add(MenuButtonType.CatButton); } if (ModStateChecker.DawnLibLoaded) { activeButtons.Add(MenuButtonType.DawnLibAchievements); } if (ModStateChecker.TwitchChatAPILoaded) { activeButtons.Add(MenuButtonType.TwitchChatAPI); } } } [BepInPlugin("nikki.neatmenu", "NeatMenu", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static AssetBundle Assets; public static Sprite phoneButtonSprite; public static Sprite configButtonSprite; public static Sprite catButtonSprite; public static Sprite achievementButtonSprite; public static Sprite twitchButtonSprite; public static ManualLogSource LogSource; public string spriteDirectory = "assets/neatmenu/cat/"; public static List<Sprite> loadedCats = new List<Sprite>(); private void Awake() { LogSource = ((BaseUnityPlugin)this).Logger; Log.Info(" ███ ██ ▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄ ██▄ ▄██ ▄▄▄▄▄ ▄▄ ▄▄ ▄▄ ▄▄ "); Log.Info("▄▀▀▄ █ ██ ▀▄██ ██▄▄ ██▀██ ██ ██ ▀▀ ██ ██▄▄ ███▄██ ██ ██ ▄▀▀▄ █ "); Log.Info("▀ ▀▀ ██ ██ ██▄▄▄ ██▀██ ██ ██ ██ ██▄▄▄ ██ ▀██ ▀███▀ ▀ ▀▀"); Log.Debug("I've always wanted to do this and a menu mod seemed like a good time to."); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "neatmenuassets"); Assets = AssetBundle.LoadFromFile(text); phoneButtonSprite = Assets.LoadAsset<Sprite>("LethalPhonesIcon"); configButtonSprite = Assets.LoadAsset<Sprite>("LethalConfigIcon"); catButtonSprite = Assets.LoadAsset<Sprite>("CatButtonIcon"); achievementButtonSprite = Assets.LoadAsset<Sprite>("AchievementsIcon"); twitchButtonSprite = Assets.LoadAsset<Sprite>("TwitchAPIIcon"); LoadCatSprites(); ModStateChecker.Init(); if (ModStateChecker.MoreCompanyLoaded) { Log.Info("Detected MoreCompany."); } if (ModStateChecker.LethalConfigLoaded) { Log.Info("Detected LethalConfig."); } if (ModStateChecker.LethalPhonesLoaded) { Log.Info("Detected LethalPhones."); } if (ModStateChecker.DawnLibLoaded) { Log.Info("Detected DawnLib."); } if (ModStateChecker.TwitchChatAPILoaded) { Log.Info("Detected TwitchChatAPI."); } if (!ModStateChecker.MoreCompanyLoaded) { Log.Error("MoreCompany was not detected. NeatMenu currently requires MoreCompany for initialization. NeatMenu will not function."); return; } if (!ModStateChecker.LethalConfigLoaded && !ModStateChecker.LethalPhonesLoaded && !ModStateChecker.DawnLibLoaded && !ModStateChecker.TwitchChatAPILoaded) { Log.Error("No mods with implemented UI changes were found during NeatMenu initialization. Either something has gone wrong, or you have no relevant mods installed, and NeatMenu will not function."); } Configure(); NeatMenuLayout.GenerateButtonList(); Patch(); } private void LoadCatSprites() { loadedCats.Clear(); if ((Object)(object)Assets == (Object)null) { Log.Error("Assets not found."); return; } string[] allAssetNames = Assets.GetAllAssetNames(); string[] array = allAssetNames; foreach (string text in array) { Log.Debug(text); if (text.StartsWith(spriteDirectory.ToLower())) { Sprite val = Assets.LoadAsset<Sprite>(text); if ((Object)(object)val != (Object)null) { loadedCats.Add(val); } } } Log.Debug($"Loaded {loadedCats.Count} cat images."); } private void Patch() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("Nikki.NeatMenu"); val.PatchAll(Assembly.GetExecutingAssembly()); } private void Configure() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown Log.shouldPurgeLogs = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Debug", "Purge logs"), false, new ConfigDescription("Purges all logging from this mod except for critical errors.", (AcceptableValueBase)null, Array.Empty<object>())).Value; NeatMenuLayout.catButtonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Main", "Enable cat button"), true, new ConfigDescription("Enables the cat button.", (AcceptableValueBase)null, Array.Empty<object>())).Value; } } public static class Log { public static bool shouldPurgeLogs; public static ManualLogSource Logger = Plugin.LogSource; public static void Debug(string msg) { if (!shouldPurgeLogs) { Logger.LogDebug((object)msg); } } public static void Info(string msg) { if (!shouldPurgeLogs) { Logger.LogInfo((object)msg); } } public static void Warning(string msg) { Logger.LogWarning((object)msg); } public static void Error(string msg) { Logger.LogError((object)msg); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "NeatMenu"; public const string PLUGIN_NAME = "NeatMenu"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace NeatMenu.Patches { [HarmonyPatch] public class AchievementUICanvasPatch { public static bool Prepare() { return AccessTools.TypeByName("Dusk.AchievementUICanvas") != null; } public static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("Dusk.AchievementUICanvas"); return AccessTools.Method(type, "BackButtonOnClick", (Type[])null, (Type[])null); } [HarmonyPrefix] public static bool Prefix(object __instance) { Type type = __instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, "_menuManager"); FieldInfo fieldInfo2 = AccessTools.Field(type, "_mainButtons"); FieldInfo fieldInfo3 = AccessTools.Field(type, "_background"); object obj = fieldInfo?.GetValue(__instance); object obj2 = fieldInfo2?.GetValue(__instance); object? obj3 = fieldInfo3?.GetValue(__instance); GameObject val = (GameObject)((obj3 is GameObject) ? obj3 : null); if (obj != null && obj2 != null) { AccessTools.Method(obj.GetType(), "EnableUIPanel", (Type[])null, (Type[])null)?.Invoke(obj, new object[1] { obj2 }); } if (val != null) { val.SetActive(false); } return false; } } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPriority(0)] public static class MenuPatches { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<Button> <>9__15_0; public static Func<Button, RectTransform> <>9__15_1; public static Func<RectTransform, float> <>9__15_2; public static Func<float, float, float> <>9__15_3; public static Predicate<Button> <>9__15_4; public static UnityAction <>9__17_0; public static UnityAction <>9__17_1; public static UnityAction <>9__17_2; public static UnityAction <>9__17_4; public static UnityAction <>9__17_5; internal bool <RefactorButtons>b__15_0(Button x) { return (Object)(object)x == (Object)null; } internal RectTransform <RefactorButtons>b__15_1(Button b) { Transform transform = ((Component)b).transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } internal float <RefactorButtons>b__15_2(RectTransform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return t.anchoredPosition.y; } internal float <RefactorButtons>b__15_3(float y1, float y2) { return Mathf.Abs(y2 - y1); } internal bool <RefactorButtons>b__15_4(Button q) { return ((Object)((Component)q).gameObject).name == "QuitButton"; } internal void <CreateButton>b__17_0() { Log.Debug("NeatMenuCosmeticButton clicked!"); if ((Object)(object)cosmeticScreen == (Object)null) { cosmeticScreen = GameObject.Find("TestOverlay(Clone)/Canvas/GlobalScale/CosmeticsScreen"); } if ((Object)(object)cosmeticScreen == (Object)null) { Log.Error("CosmeticScreen not found."); } else { cosmeticScreen.SetActive(true); } } internal void <CreateButton>b__17_1() { if ((Object)(object)phoneRoot == (Object)null) { phoneRoot = GameObject.Find("CustomizationCanvas"); if ((Object)(object)phoneRoot == (Object)null) { Log.Error("CustomizationCanvas not found."); return; } Transform obj = phoneRoot.transform.Find("CustomizationPanel"); phoneMenu = ((obj != null) ? ((Component)obj).gameObject : null); } Log.Debug("NeatMenuPhoneButton clicked!"); if ((Object)(object)phoneMenu == (Object)null) { Log.Error("CustomizationPanel not found."); } else { phoneMenu.SetActive(true); } } internal void <CreateButton>b__17_2() { Log.Debug("NeatMenuConfigButton clicked!"); AccessTools.Method("LethalConfig.MonoBehaviours.Managers.ConfigMenuManager:ShowConfigMenu", (Type[])null, (Type[])null)?.Invoke(null, null); } internal void <CreateButton>b__17_4() { Log.Debug("NeatMenuAchievementButton clicked!"); Type type = AccessTools.TypeByName("Dusk.AchievementUICanvas"); if (type == null) { Log.Error("AchievementUICanvas not found."); return; } MethodInfo methodInfo = AccessTools.Method(type, "AchievementsButtonOnClick", (Type[])null, (Type[])null); object obj = AccessTools.Property(type, "Instance")?.GetValue(null); if (obj != null) { methodInfo.Invoke(obj, null); } } internal void <CreateButton>b__17_5() { Log.Debug("NeatMenuTwitchButton clicked!"); Type type = AccessTools.TypeByName("TwitchChatAPI.LethalCompany.MonoBehaviours.PluginCanvas"); if (type == null) { Log.Error("PluginCanvas not found."); return; } MethodInfo methodInfo = AccessTools.Method(type, "OpenSettingsWindow", (Type[])null, (Type[])null); object obj = AccessTools.Property(type, "Instance")?.GetValue(null); if (obj != null) { methodInfo.Invoke(obj, null); } } } [CompilerGenerated] private sealed class <>c__DisplayClass15_0 { public Button quitButton; public Func<Button, bool> <>9__5; internal bool <RefactorButtons>b__5(Button g) { return (Object)(object)g != (Object)(object)quitButton; } } [CompilerGenerated] private sealed class <GenerateButtonLayout>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private List<MenuButtonType> <activeButtons>5__1; private Vector3[] <positions>5__2; private int <i>5__3; private MenuButtonType <buttonType>5__4; private GameObject <buttonObj>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GenerateButtonLayout>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <activeButtons>5__1 = null; <positions>5__2 = null; <buttonObj>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0f); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0f); <>1__state = 2; return true; case 2: <>1__state = -1; <activeButtons>5__1 = NeatMenuLayout.activeButtons; <positions>5__2 = NeatMenuLayout.GetPositions(<activeButtons>5__1.Count); neatMenuButtonsContainer = Object.Instantiate<GameObject>(new GameObject("NeatMenuButtons"), menuContainer.transform); neatMenuButtonsContainer.transform.SetSiblingIndex(3); neatMenuButtonsContainer.AddComponent<MenuMimic>(); <i>5__3 = 0; while (<i>5__3 < <activeButtons>5__1.Count) { <buttonType>5__4 = <activeButtons>5__1[<i>5__3]; <buttonObj>5__5 = CreateButton(<buttonType>5__4); if ((Object)(object)<buttonObj>5__5 == (Object)null) { Log.Debug("Failed to generate button layout. This is probably fine (likely loading screen / UI not initialized yet)."); break; } <buttonObj>5__5.transform.localScale = NeatMenuLayout.AnchorScale; <buttonObj>5__5.transform.localPosition = NeatMenuLayout.AnchorPosition + <positions>5__2[<i>5__3]; <buttonObj>5__5 = null; <i>5__3++; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RefactorButtons>d__15 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Button[] buttons; private <>c__DisplayClass15_0 <>8__1; private List<Button> <gameObjects>5__2; private IEnumerable<float> <positions>5__3; private List<float> <enumerable>5__4; private IEnumerable<float> <offsets>5__5; private float <offset>5__6; private IEnumerator<Button> <>s__7; private Button <button>5__8; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RefactorButtons>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <gameObjects>5__2 = null; <positions>5__3 = null; <enumerable>5__4 = null; <offsets>5__5 = null; <>s__7 = null; <button>5__8 = null; <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass15_0(); <>2__current = (object)new WaitForSeconds(0f); <>1__state = 1; return true; case 1: <>1__state = -1; <gameObjects>5__2 = buttons.ToList(); <gameObjects>5__2.RemoveAll((Button x) => (Object)(object)x == (Object)null); <positions>5__3 = from t in <gameObjects>5__2.Select(delegate(Button b) { Transform transform = ((Component)b).transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); }) select t.anchoredPosition.y; <enumerable>5__4 = <positions>5__3.ToList(); <offsets>5__5 = <enumerable>5__4.Zip(<enumerable>5__4.Skip(1), (float y1, float y2) => Mathf.Abs(y2 - y1)); <offset>5__6 = <offsets>5__5.Min(); <>8__1.quitButton = <gameObjects>5__2.Find((Button q) => ((Object)((Component)q).gameObject).name == "QuitButton"); <>s__7 = <gameObjects>5__2.Where((Button g) => (Object)(object)g != (Object)(object)<>8__1.quitButton).GetEnumerator(); try { while (<>s__7.MoveNext()) { <button>5__8 = <>s__7.Current; RectTransform component = ((Component)<button>5__8).GetComponent<RectTransform>(); component.anchoredPosition -= new Vector2(0f, <offset>5__6); <button>5__8 = null; } } finally { if (<>s__7 != null) { <>s__7.Dispose(); } } <>s__7 = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitToRemoveMenuButtons>d__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MenuManager __instance; public bool refactor; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitToRemoveMenuButtons>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0f); <>1__state = 1; return true; case 1: <>1__state = -1; RemoveMenuButtons(__instance, refactor); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static GameObject cosmeticButton; public static GameObject cosmeticScreen; public static GameObject menuContainer; public static GameObject phoneRoot; public static GameObject phoneMenu; public static GameObject neatMenuButtonsContainer; public static bool achievementStatus; [HarmonyPostfix] public static void Postfix(MenuManager __instance) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) menuContainer = GameObject.Find("Canvas/MenuContainer"); if ((Object)(object)menuContainer == (Object)null) { Log.Error("MenuContainer not found. Another mod may be interfering with the main menu."); return; } if (ModStateChecker.MoreCompanyLoaded) { HandleMoreCompany(); } if (ModStateChecker.LethalPhonesLoaded) { HandleLethalPhones(__instance); } if (ModStateChecker.LethalConfigLoaded) { HandleLethalConfig(__instance); } if (ModStateChecker.DawnLibLoaded) { HandleDawnLib(__instance); } if (ModStateChecker.TwitchChatAPILoaded) { HandleTwitchChatAPI(__instance); } ((MonoBehaviour)__instance).StartCoroutine(GenerateButtonLayout()); if (!((Object)(object)cosmeticButton == (Object)null)) { Transform transform = cosmeticButton.transform; transform.localPosition += new Vector3(5000f, 0f, 0f); } } public static void HandleMoreCompany() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown cosmeticButton = GameObject.Find("TestOverlay(Clone)/Canvas/GlobalScale/ActivateButton"); if (!((Object)(object)cosmeticButton == (Object)null)) { Button component = cosmeticButton.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); } } public static void HandleLethalPhones(MenuManager __instance) { if (ModStateChecker.MoreCompanyLoaded) { if ((Object)(object)cosmeticButton == (Object)null) { Log.Debug("HandleLethalPhones skipped (likely loading screen / UI not initialized yet)."); } else { ((MonoBehaviour)__instance).StartCoroutine(WaitToRemoveMenuButtons(__instance, refactor: true)); } } } public static void HandleLethalConfig(MenuManager __instance) { if (ModStateChecker.MoreCompanyLoaded) { if ((Object)(object)cosmeticButton == (Object)null) { Log.Debug("HandleLethalConfig skipped (likely loading screen / UI not initialized yet)."); } else { ((MonoBehaviour)__instance).StartCoroutine(WaitToRemoveMenuButtons(__instance, refactor: true)); } } } public static void HandleDawnLib(MenuManager __instance) { if (ModStateChecker.MoreCompanyLoaded) { if ((Object)(object)cosmeticButton == (Object)null) { Log.Debug("HandleDawnLib skipped (likely loading screen / UI not initialized yet)."); return; } achievementStatus = ModStateChecker.CheckAchievementStatus(); ((MonoBehaviour)__instance).StartCoroutine(WaitToRemoveMenuButtons(__instance, achievementStatus)); } } public static void HandleTwitchChatAPI(MenuManager __instance) { ((MonoBehaviour)__instance).StartCoroutine(WaitToRemoveMenuButtons(__instance, refactor: false)); } [IteratorStateMachine(typeof(<WaitToRemoveMenuButtons>d__13))] public static IEnumerator WaitToRemoveMenuButtons(MenuManager __instance, bool refactor) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitToRemoveMenuButtons>d__13(0) { __instance = __instance, refactor = refactor }; } public static void RemoveMenuButtons(MenuManager __instance, bool refactor) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Canvas/MenuContainer/MainButtons"); if ((Object)(object)val == (Object)null) { Log.Warning("Menu buttons not found."); return; } if (!achievementStatus) { NeatMenuLayout.activeButtons.Remove(MenuButtonType.DawnLibAchievements); } Button[] componentsInChildren = val.GetComponentsInChildren<Button>(); Button[] array = componentsInChildren; foreach (Button val2 in array) { TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>(); if (!((Object)(object)componentInChildren == (Object)null) && (((TMP_Text)componentInChildren).text == "> Personalize Phone" || ((TMP_Text)componentInChildren).text == "> LethalConfig" || ((TMP_Text)componentInChildren).text == "> Achievements")) { Object.Destroy((Object)(object)((Component)val2).gameObject); Log.Info("Destroying menu button: " + ((TMP_Text)componentInChildren).text); } } GameObject val3 = GameObject.Find("TwitchChatAPI LethalCompany Canvas/MainMenu"); if ((Object)(object)val3 != (Object)null) { Transform transform = val3.transform; transform.localPosition += new Vector3(5000f, 0f, 0f); } if (refactor) { ((MonoBehaviour)__instance).StartCoroutine(RefactorButtons(componentsInChildren)); } } [IteratorStateMachine(typeof(<RefactorButtons>d__15))] public static IEnumerator RefactorButtons(Button[] buttons) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RefactorButtons>d__15(0) { buttons = buttons }; } [IteratorStateMachine(typeof(<GenerateButtonLayout>d__16))] public static IEnumerator GenerateButtonLayout() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GenerateButtonLayout>d__16(0); } public static GameObject CreateButton(MenuButtonType buttonType) { //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown if ((Object)(object)cosmeticButton == (Object)null || (Object)(object)neatMenuButtonsContainer == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(cosmeticButton, neatMenuButtonsContainer.transform); Button component = val.GetComponent<Button>(); Image component2 = val.GetComponent<Image>(); switch (buttonType) { case MenuButtonType.MoreCompany: { ((Object)val).name = "NeatMenuCosmeticButton"; ButtonClickedEvent onClick5 = component.onClick; object obj5 = <>c.<>9__17_0; if (obj5 == null) { UnityAction val7 = delegate { Log.Debug("NeatMenuCosmeticButton clicked!"); if ((Object)(object)cosmeticScreen == (Object)null) { cosmeticScreen = GameObject.Find("TestOverlay(Clone)/Canvas/GlobalScale/CosmeticsScreen"); } if ((Object)(object)cosmeticScreen == (Object)null) { Log.Error("CosmeticScreen not found."); } else { cosmeticScreen.SetActive(true); } }; <>c.<>9__17_0 = val7; obj5 = (object)val7; } ((UnityEvent)onClick5).AddListener((UnityAction)obj5); break; } case MenuButtonType.LethalPhones: { ((Object)val).name = "NeatMenuPhoneButton"; ButtonClickedEvent onClick4 = component.onClick; object obj4 = <>c.<>9__17_1; if (obj4 == null) { UnityAction val6 = delegate { if ((Object)(object)phoneRoot == (Object)null) { phoneRoot = GameObject.Find("CustomizationCanvas"); if ((Object)(object)phoneRoot == (Object)null) { Log.Error("CustomizationCanvas not found."); return; } Transform obj6 = phoneRoot.transform.Find("CustomizationPanel"); phoneMenu = ((obj6 != null) ? ((Component)obj6).gameObject : null); } Log.Debug("NeatMenuPhoneButton clicked!"); if ((Object)(object)phoneMenu == (Object)null) { Log.Error("CustomizationPanel not found."); } else { phoneMenu.SetActive(true); } }; <>c.<>9__17_1 = val6; obj4 = (object)val6; } ((UnityEvent)onClick4).AddListener((UnityAction)obj4); ((Graphic)component2).color = new Color(0.67f, 0.67f, 0.01f); component2.sprite = Plugin.phoneButtonSprite; break; } case MenuButtonType.LethalConfig: { ((Object)val).name = "NeatMenuConfigButton"; ButtonClickedEvent onClick2 = component.onClick; object obj2 = <>c.<>9__17_2; if (obj2 == null) { UnityAction val3 = delegate { Log.Debug("NeatMenuConfigButton clicked!"); AccessTools.Method("LethalConfig.MonoBehaviours.Managers.ConfigMenuManager:ShowConfigMenu", (Type[])null, (Type[])null)?.Invoke(null, null); }; <>c.<>9__17_2 = val3; obj2 = (object)val3; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); ((Graphic)component2).color = new Color(0.67f, 0.01f, 0.01f); component2.sprite = Plugin.configButtonSprite; break; } case MenuButtonType.CatButton: { ((Object)val).name = "NeatMenuCatButton"; CatButtonController controller = val.AddComponent<CatButtonController>(); GameObject val4 = new GameObject("FullscreenCat"); val4.transform.SetParent(menuContainer.transform, false); controller.catImage = val4.AddComponent<Image>(); controller.catImage.preserveAspect = true; ((Graphic)controller.catImage).raycastTarget = false; controller.SetImageAlpha(0f); RectTransform rectTransform = ((Graphic)controller.catImage).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.one; ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { Log.Debug("Cat Button clicked! :3"); controller.OnCatButtonClicked(); }); ((Graphic)component2).color = new Color(0.67f, 0.43f, 0.01f); component2.sprite = Plugin.catButtonSprite; break; } case MenuButtonType.DawnLibAchievements: { ((Object)val).name = "NeatMenuAchievementButton"; ButtonClickedEvent onClick3 = component.onClick; object obj3 = <>c.<>9__17_4; if (obj3 == null) { UnityAction val5 = delegate { Log.Debug("NeatMenuAchievementButton clicked!"); Type type = AccessTools.TypeByName("Dusk.AchievementUICanvas"); if (type == null) { Log.Error("AchievementUICanvas not found."); } else { MethodInfo methodInfo = AccessTools.Method(type, "AchievementsButtonOnClick", (Type[])null, (Type[])null); object obj7 = AccessTools.Property(type, "Instance")?.GetValue(null); if (obj7 != null) { methodInfo.Invoke(obj7, null); } } }; <>c.<>9__17_4 = val5; obj3 = (object)val5; } ((UnityEvent)onClick3).AddListener((UnityAction)obj3); ((Graphic)component2).color = new Color(0.67f, 0.225f, 0.43f); component2.sprite = Plugin.achievementButtonSprite; break; } case MenuButtonType.TwitchChatAPI: { ((Object)val).name = "NeatMenuTwitchButton"; ButtonClickedEvent onClick = component.onClick; object obj = <>c.<>9__17_5; if (obj == null) { UnityAction val2 = delegate { Log.Debug("NeatMenuTwitchButton clicked!"); Type type2 = AccessTools.TypeByName("TwitchChatAPI.LethalCompany.MonoBehaviours.PluginCanvas"); if (type2 == null) { Log.Error("PluginCanvas not found."); } else { MethodInfo methodInfo2 = AccessTools.Method(type2, "OpenSettingsWindow", (Type[])null, (Type[])null); object obj8 = AccessTools.Property(type2, "Instance")?.GetValue(null); if (obj8 != null) { methodInfo2.Invoke(obj8, null); } } }; <>c.<>9__17_5 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ((Graphic)component2).color = new Color(0.39f, 0.25f, 0.64f); component2.sprite = Plugin.twitchButtonSprite; break; } } return val; } } } namespace NeatMenu.MonoBehaviours { public class CatButtonController : MonoBehaviour { [CompilerGenerated] private sealed class <ShowCatRoutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Sprite sprite; public CatButtonController <>4__this; private float <timer>5__1; private float <tNorm>5__2; private float <alpha>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShowCatRoutine>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.catImage.sprite = sprite; <>4__this.SetImageAlpha(1f); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; <timer>5__1 = 0f; break; case 2: <>1__state = -1; break; } if (<timer>5__1 < <>4__this.fadeDuration) { <timer>5__1 += Time.deltaTime; <tNorm>5__2 = <timer>5__1 / <>4__this.fadeDuration; <tNorm>5__2 = Mathf.SmoothStep(0f, 1f, <tNorm>5__2); <alpha>5__3 = Mathf.Lerp(1f, 0f, <tNorm>5__2); <>4__this.SetImageAlpha(<alpha>5__3); <>2__current = null; <>1__state = 2; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public Image catImage; public float fadeDuration = 0.5f; private Coroutine currentRoutine; private void Start() { SetImageAlpha(0f); } public void OnCatButtonClicked() { List<Sprite> loadedCats = Plugin.loadedCats; if (loadedCats.Count == 0) { Log.Error("Cats failed to load."); return; } Sprite sprite = loadedCats[Random.Range(0, loadedCats.Count)]; if (currentRoutine != null) { ((MonoBehaviour)this).StopCoroutine(currentRoutine); SetImageAlpha(0f); } currentRoutine = ((MonoBehaviour)this).StartCoroutine(ShowCatRoutine(sprite)); } [IteratorStateMachine(typeof(<ShowCatRoutine>d__5))] private IEnumerator ShowCatRoutine(Sprite sprite) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShowCatRoutine>d__5(0) { <>4__this = this, sprite = sprite }; } public void SetImageAlpha(float alpha) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Color color = ((Graphic)catImage).color; color.a = alpha; ((Graphic)catImage).color = color; } } public class MenuMimic : MonoBehaviour { public GameObject mainButtons; public List<GameObject> neatMenuButtons = new List<GameObject>(); public void Start() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown mainButtons = GameObject.Find("Canvas/MenuContainer/MainButtons"); foreach (Transform item in ((Component)this).transform) { Transform val = item; neatMenuButtons.Add(((Component)val).gameObject); } } public void Update() { if ((Object)(object)mainButtons == (Object)null || neatMenuButtons.Count == 0) { return; } foreach (GameObject neatMenuButton in neatMenuButtons) { neatMenuButton.SetActive(mainButtons.activeSelf); } } } }