using 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 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 activeButtons = new List(); 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(), }; } 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 loadedCats = new List(); 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("LethalPhonesIcon"); configButtonSprite = Assets.LoadAsset("LethalConfigIcon"); catButtonSprite = Assets.LoadAsset("CatButtonIcon"); achievementButtonSprite = Assets.LoadAsset("AchievementsIcon"); twitchButtonSprite = Assets.LoadAsset("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(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(new ConfigDefinition("Debug", "Purge logs"), false, new ConfigDescription("Purges all logging from this mod except for critical errors.", (AcceptableValueBase)null, Array.Empty())).Value; NeatMenuLayout.catButtonEnabled = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Main", "Enable cat button"), true, new ConfigDescription("Enables the cat button.", (AcceptableValueBase)null, Array.Empty())).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