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 BetterMap Fixer v1.1.4
BetterMapFix.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BetterMap; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BetterMapFix")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterMapFix")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f17f82e6-3261-4615-ae64-3d0c64e0ecbe")] [assembly: AssemblyFileVersion("1.1.4.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.1.4.0")] namespace BetterMapPatch; [BepInPlugin("BetterMap.Fixer", "BetterMap Fixer", "1.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BetterMapFix : BaseUnityPlugin { [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] public static class LevelGeneratorGenerateDonePatch { [HarmonyPostfix] public static void Postfix() { Manager.LevelPatch(); } } [HarmonyPatch(typeof(EnemyParent), "DespawnRPC")] public static class EnemyDespawnRPCHookPatch { [HarmonyPostfix] public static void Postfix(EnemyParent __instance) { Manager.DespawnRPCPatch(__instance); } } [HarmonyPatch(typeof(PlayerAvatar))] public static class PlayerAvatarRPCPatch { [HarmonyPatch("ReviveRPC")] [HarmonyPostfix] public static void ReviveRPC(PlayerAvatar __instance) { Manager.AddPlayerToMapFix(__instance); } [HarmonyPatch("PlayerDeathRPC")] [HarmonyPostfix] public static void PlayerDeathRPC(PlayerAvatar __instance) { if (!((Object)(object)__instance == (Object)null)) { Manager.RemovePlayerFromMapFix(__instance); } } } internal static ManualLogSource Log; private static Harmony _harmony; private void Awake() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Manager.Init(); _harmony = new Harmony("BetterMap.Fixer"); _harmony.Unpatch((MethodBase)AccessTools.Method(typeof(LevelGenerator), "GenerateDone", (Type[])null, (Type[])null), (HarmonyPatchType)0, "BetterMap"); _harmony.Unpatch((MethodBase)AccessTools.Method(typeof(EnemyParent), "DespawnRPC", (Type[])null, (Type[])null), (HarmonyPatchType)0, "BetterMap"); _harmony.Unpatch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "PlayerDeathRPC", (Type[])null, (Type[])null), (HarmonyPatchType)0, "BetterMap"); _harmony.Unpatch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "ReviveRPC", (Type[])null, (Type[])null), (HarmonyPatchType)0, "BetterMap"); _harmony.PatchAll(); Log.LogInfo((object)"BetterMap Fix Done"); } } internal class Manager { private static readonly FieldInfo EnemyField = AccessTools.Field(typeof(EnemyParent), "Enemy"); private static readonly FieldInfo EntityField = AccessTools.Field(typeof(MapCustom), "mapCustomEntity"); private static readonly FieldInfo ShowEnemies = AccessTools.Field(typeof(BetterMap), "configShowEnemies"); private static readonly FieldInfo ShowTeammates = AccessTools.Field(typeof(BetterMap), "configShowTeammates"); private static readonly FieldInfo ExploreAllRooms = AccessTools.Field(typeof(BetterMap), "configExploreAllRooms"); private static Sprite squareSprite; public static void Init() { squareSprite = CreateSquareSprite(); } public static void LevelPatch() { if (!SemiFunc.RunIsLevel()) { return; } AddAllPlayersToMap(); if (((ConfigEntry<bool>)ExploreAllRooms.GetValue(null)).Value) { RoomVolume[] array = Object.FindObjectsOfType<RoomVolume>(); for (int i = 0; i < array.Length; i++) { array[i].SetExplored(); } } } public static void DespawnRPCPatch(EnemyParent __instance) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) try { if (!((ConfigEntry<bool>)ShowEnemies.GetValue(null)).Value) { return; } object? value = EnemyField.GetValue(__instance); GameObject mapCustomGameObject = BetterMap.GetMapCustomGameObject((Enemy)((value is Enemy) ? value : null)); MapCustom val = ((mapCustomGameObject != null) ? mapCustomGameObject.GetComponent<MapCustom>() : null); if (!((Object)(object)val == (Object)null)) { object value2 = EntityField.GetValue(val); if (value2 != null) { Object.Destroy((Object)(object)((Component)value2).gameObject); } Object.Destroy((Object)(object)val); BetterMapFix.Log.LogDebug((object)"销毁敌人图标"); } } catch (Exception arg) { BetterMapFix.Log.LogError((object)$"补丁出错: {arg}"); } } private static void AddAllPlayersToMap() { if (!((ConfigEntry<bool>)ShowTeammates.GetValue(null)).Value) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { AddPlayerToMapFix(player); } } public static void RemovePlayerFromMapFix(PlayerAvatar playerAvatar) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) MapCustom component = ((Component)playerAvatar).GetComponent<MapCustom>(); if ((Object)(object)component != (Object)null) { object value = EntityField.GetValue(component); if (value != null) { Object.Destroy((Object)(object)((Component)value).gameObject); } Object.Destroy((Object)(object)component); BetterMapFix.Log.LogDebug((object)"销毁玩家图标"); } } public static void AddPlayerToMapFix(PlayerAvatar playerAvatar) { //IL_0016: 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) MapCustom obj = ((Component)playerAvatar).gameObject.AddComponent<MapCustom>(); obj.sprite = squareSprite; obj.color = Color.blue; BetterMapFix.Log.LogDebug((object)"创建玩家图标"); } private static Sprite CreateSquareSprite() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(5, 5, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[25]; for (int i = 0; i < array.Length; i++) { array[i] = Color.white; } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 5f, 5f), new Vector2(0.5f, 0.5f)); } }