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 MapVotePlusUiFix v1.0.0
MapVotePlusUiFix.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MapVotePlusUiFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MapVotePlusUiFix")] [assembly: AssemblyTitle("MapVotePlusUiFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 MapVotePlusUiFix { [BepInPlugin("themorningstar.mapvoteplusuifix", "MapVotePlus UI Fix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "themorningstar.mapvoteplusuifix"; internal static ManualLogSource Log = null; internal static readonly Type? MapVoteType = AccessTools.TypeByName("MapVotePlus.MapVotePlus"); internal static readonly FieldInfo? VotePopupField = AccessTools.Field(MapVoteType, "VotePopup"); internal static readonly FieldInfo? VoteLevelsField = AccessTools.Field(MapVoteType, "CurrentVoteLevels"); internal static readonly FieldInfo? HideInMenuField = AccessTools.Field(MapVoteType, "HideInMenu"); internal static readonly FieldInfo? CurrentMenuPageField = AccessTools.Field(typeof(MenuManager), "currentMenuPageIndex"); internal static readonly FieldInfo? CurrentMenuStateField = AccessTools.Field(typeof(MenuManager), "currentMenuState"); internal static readonly MethodInfo? CreateVotePopupMethod = AccessTools.Method(MapVoteType, "CreateVotePopup", (Type[])null, (Type[])null); private void Awake() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; if (MapVoteType == null || VotePopupField == null || VoteLevelsField == null || HideInMenuField == null || CurrentMenuPageField == null || CurrentMenuStateField == null || CreateVotePopupMethod == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"MapVotePlus 1.3.1 UI members missing; patch not installed."); return; } try { new Harmony("themorningstar.mapvoteplusuifix").PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MapVotePlus UI Fix 1.0.0 patches applied."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("MapVotePlus UI patch failed: " + ex)); } } internal static bool IsMenuOpenOn(MenuPageIndex page) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) MenuManager instance = MenuManager.instance; if ((Object)(object)instance != (Object)null && (MenuPageIndex)CurrentMenuPageField.GetValue(instance) == page) { return (int)CurrentMenuStateField.GetValue(instance) == 0; } return false; } internal static bool IsAnotherMenuOpen() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 MenuManager instance = MenuManager.instance; if ((Object)(object)instance != (Object)null && (int)CurrentMenuStateField.GetValue(instance) == 0) { return (int)(MenuPageIndex)CurrentMenuPageField.GetValue(instance) != 8; } return false; } internal static bool HideVoteInLobby() { return ((ConfigEntry<bool>)HideInMenuField.GetValue(null)).Value; } internal static void OpenVote(bool inMenu, bool inLobby) { CreateVotePopupMethod.Invoke(null, new object[2] { inMenu, inLobby }); } } [HarmonyPatch] internal static class ClientMapSyncPatch { private static MethodBase TargetMethod() { return AccessTools.Method(Plugin.MapVoteType, "HandleOnMapsRandomized", (Type[])null, (Type[])null); } private static bool Prefix(EventData data) { if (SemiFunc.IsMasterClientOrSingleplayer()) { return false; } if (!(data.CustomData is string[] array)) { return true; } try { Plugin.VoteLevelsField.SetValue(null, new List<string>(array)); if (array.Length == 0) { return false; } if (SemiFunc.RunIsLobbyMenu()) { if (!Plugin.HideVoteInLobby() && Plugin.IsMenuOpenOn((MenuPageIndex)8)) { Plugin.OpenVote(inMenu: true, inLobby: true); } } else if (SemiFunc.RunIsLobby() && !Plugin.IsAnotherMenuOpen()) { Plugin.OpenVote(inMenu: false, inLobby: false); } } catch (Exception ex) { Plugin.Log.LogError((object)("Client map sync UI failed: " + ex)); } return false; } } [HarmonyPatch(typeof(MenuManager), "PageOpen")] internal static class MenuPageOpenPatch { [HarmonyPriority(800)] private static void Prefix(MenuPageIndex menuPageIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)menuPageIndex == 8 || (int)menuPageIndex == 9 || (int)menuPageIndex == 7) { return; } try { object? value = Plugin.VotePopupField.GetValue(null); REPOPopupPage val = (REPOPopupPage)((value is REPOPopupPage) ? value : null); if ((Object)(object)val != (Object)null) { val.ClosePage(false); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not close vote popup on menu change: " + ex.Message)); } } } }