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 MapUpgrade v1.0.1
REPO_MapUpgrade.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("REPO_MapUpgrade")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REPO_MapUpgrade")] [assembly: AssemblyTitle("REPO_MapUpgrade")] [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 REPO_MapUpgrade { [HarmonyPatch] internal class PlayerTrackerPatch { private static FieldInfo _mapControllerActiveField; private static FieldInfo _mapScaleField; private static FieldInfo _playerAvatarIsLocalField; private static FieldInfo _mapOverLayerParentField; private static FieldInfo _enemyStateDespawnField; private static FieldInfo _photonViewField; private static readonly Dictionary<PlayerAvatar, MapCustom> playerIcons; private static readonly Dictionary<Enemy, MapCustom> enemyIcons; static PlayerTrackerPatch() { playerIcons = new Dictionary<PlayerAvatar, MapCustom>(); enemyIcons = new Dictionary<Enemy, MapCustom>(); _mapControllerActiveField = AccessTools.Field(typeof(MapToolController), "Active"); _mapScaleField = AccessTools.Field(typeof(Map), "Scale"); _playerAvatarIsLocalField = AccessTools.Field(typeof(PlayerAvatar), "isLocal"); _mapOverLayerParentField = AccessTools.Field(typeof(Map), "OverLayerParent"); _enemyStateDespawnField = AccessTools.Field(typeof(Enemy), "StateDespawn"); _photonViewField = AccessTools.Field(typeof(MapToolController), "photonView"); } [HarmonyPostfix] [HarmonyPatch(typeof(MapToolController), "Update")] private static void UpdatePlayerMapIcons(MapToolController __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Expected O, but got Unknown //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Invalid comparison between Unknown and I4 //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Expected O, but got Unknown //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) PhotonView val = (PhotonView)_photonViewField.GetValue(__instance); if (GameManager.Multiplayer() && ((Object)(object)val == (Object)null || !val.IsMine)) { return; } if ((Object)(object)__instance == (Object)null) { return; } if (!(bool)_mapControllerActiveField.GetValue(__instance)) { if (playerIcons.Count > 0 || enemyIcons.Count > 0) { ClearAllPlayerIcons(); ClearAllEnemyIcons(); } return; } Map instance = Map.Instance; if ((Object)(object)instance == (Object)null) { return; } GameDirector gameDirector = GameDirector.instance; if ((Object)(object)gameDirector == (Object)null) { return; } List<PlayerAvatar> list = playerIcons.Keys.Where((PlayerAvatar p) => (Object)(object)p == (Object)null || !gameDirector.PlayerList.Contains(p)).ToList(); if (list.Any()) { foreach (PlayerAvatar item in list) { if (playerIcons.TryGetValue(item, out var value)) { if ((Object)(object)value != (Object)null && (Object)(object)((Component)value).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } playerIcons.Remove(item); } } } List<Enemy> list2 = enemyIcons.Keys.Where((Enemy e) => (Object)(object)e == (Object)null || (int)e.CurrentState == 11).ToList(); if (list2.Any()) { foreach (Enemy item2 in list2) { if (enemyIcons.TryGetValue(item2, out var value2)) { if ((Object)(object)value2 != (Object)null && (Object)(object)((Component)value2).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)value2).gameObject); } enemyIcons.Remove(item2); } } } if ((Object)(object)Plugin.PlayerIconSprite == (Object)null || (Object)(object)Plugin.EnemyIconSprite == (Object)null) { return; } foreach (PlayerAvatar player in gameDirector.PlayerList) { if ((Object)(object)player == (Object)null) { continue; } if (!playerIcons.TryGetValue(player, out var value3)) { GameObject val2 = new GameObject("PlayerMapIcon"); Transform val3 = (Transform)_mapOverLayerParentField.GetValue(instance); if ((Object)(object)val3 != (Object)null) { val2.transform.SetParent(val3); } value3 = val2.AddComponent<MapCustom>(); value3.sprite = Plugin.PlayerIconSprite; value3.color = Color.white; playerIcons[player] = value3; val2.SetActive(true); } if ((Object)(object)value3 != (Object)null) { ((Component)value3).transform.position = ((Component)player).transform.position; ((Component)value3).transform.rotation = ((Component)player).transform.rotation; } } Enemy[] array = Object.FindObjectsOfType<Enemy>(); Enemy[] array2 = array; foreach (Enemy val4 in array2) { if ((Object)(object)val4 == (Object)null || (int)val4.CurrentState == 11) { continue; } if (!enemyIcons.TryGetValue(val4, out var value4)) { GameObject val5 = new GameObject("EnemyMapIcon"); Transform val6 = (Transform)_mapOverLayerParentField.GetValue(instance); if ((Object)(object)val6 != (Object)null) { val5.transform.SetParent(val6); } value4 = val5.AddComponent<MapCustom>(); value4.sprite = Plugin.EnemyIconSprite; value4.color = Color.red; enemyIcons[val4] = value4; val5.SetActive(true); } if ((Object)(object)value4 != (Object)null) { ((Component)value4).transform.position = ((Component)val4).transform.position; ((Component)value4).transform.rotation = ((Component)val4).transform.rotation; } } } private static void ClearAllPlayerIcons() { if (playerIcons.Count == 0) { return; } foreach (MapCustom value in playerIcons.Values) { if ((Object)(object)value != (Object)null && (Object)(object)((Component)value).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } playerIcons.Clear(); } private static void ClearAllEnemyIcons() { if (enemyIcons.Count == 0) { return; } foreach (MapCustom value in enemyIcons.Values) { if ((Object)(object)value != (Object)null && (Object)(object)((Component)value).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } enemyIcons.Clear(); } } [BepInPlugin("REPO_MapUpgrade", "REPO_MapUpgrade", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private readonly Harmony harmony; internal static Sprite PlayerIconSprite; internal static Sprite EnemyIconSprite; static Plugin() { CreatePlayerIconSprite(); CreateEnemyIconSprite(); } public Plugin() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown harmony = new Harmony("REPO_MapUpgrade"); } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; harmony.PatchAll(typeof(PlayerTrackerPatch)); Logger.LogInfo((object)"Plugin REPO_MapUpgrade v1.0.0 is loaded!"); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private static void CreatePlayerIconSprite() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[256]; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(7.5f, 7.5f); Color white = Color.white; for (int i = 0; i < ((Texture)val).height; i++) { for (int j = 0; j < ((Texture)val).width; j++) { float num = Vector2.Distance(new Vector2((float)j, (float)i), val2); if (num < 4f) { array[i * 16 + j] = white; } else { array[i * 16 + j] = Color.clear; } } } val.SetPixels(array); val.Apply(); PlayerIconSprite = Sprite.Create(val, new Rect(0f, 0f, 16f, 16f), new Vector2(0.5f, 0.5f), 100f); Object.DontDestroyOnLoad((Object)(object)PlayerIconSprite); } private static void CreateEnemyIconSprite() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[256]; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(7.5f, 7.5f); Color val3 = default(Color); ((Color)(ref val3))..ctor(1f, 0f, 0f); for (int i = 0; i < ((Texture)val).height; i++) { for (int j = 0; j < ((Texture)val).width; j++) { float num = Vector2.Distance(new Vector2((float)j, (float)i), val2); if (num < 4f) { array[i * 16 + j] = val3; } else { array[i * 16 + j] = Color.clear; } } } val.SetPixels(array); val.Apply(); EnemyIconSprite = Sprite.Create(val, new Rect(0f, 0f, 16f, 16f), new Vector2(0.5f, 0.5f), 100f); Object.DontDestroyOnLoad((Object)(object)EnemyIconSprite); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "REPO_MapUpgrade"; public const string PLUGIN_NAME = "REPO_MapUpgrade"; public const string PLUGIN_VERSION = "1.0.0"; } }