Decompiled source of MiniMap v1.0.0

MiniMap.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UISystem;
using WildSkies.Service;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MiniMap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MiniMap")]
[assembly: AssemblyTitle("MiniMap")]
[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 MiniMap
{
	[BepInPlugin("MiniMap", "MiniMap", "1.0.0")]
	public class Plugin : BasePlugin
	{
		private class MiniMapSimpleChatCommands
		{
			public static string Toggle()
			{
				MiniMap_Enable.Value = !MiniMap_Enable.Value;
				IUIService val = SceneContextInstaller.ResolveObject<IUIService>();
				if (val == null)
				{
					return "Error resolving IUIService";
				}
				UIHudManager hUDManager = val.HUDManager;
				if (MiniMap_Enable.Value ^ hUDManager.IsHudElementShowing((UIHudType)41))
				{
					hUDManager.ToggleHudElement((UIHudType)41, (IPayload)null);
				}
				return "MiniMap " + (MiniMap_Enable.Value ? "enabled" : "disabled") + ".";
			}
		}

		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		private static ConfigEntry<bool> MiniMap_Enable;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MiniMap");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			MiniMap_Enable = ((BasePlugin)this).Config.Bind<bool>("MiniMap", "Enable", true, "MiniMap.Enable");
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		[HarmonyPatch(typeof(UIHudManager), "ShowHudElementAsync")]
		[HarmonyPostfix]
		public static void UIHudManager_ShowHudElementAsync(UIHudManager __instance, UIHudType hudType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)hudType == 31 && MiniMap_Enable.Value)
			{
				__instance.ShowHudElementAsync((UIHudType)41, (IPayload)null, (Action)null);
			}
		}

		[HarmonyPatch(typeof(UIHudManager), "HideHudElement")]
		[HarmonyPostfix]
		public static void UIHudManager_HideHudElement(UIHudManager __instance, UIHudType hudType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)hudType == 31 && MiniMap_Enable.Value)
			{
				__instance.HideHudElement((UIHudType)41);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MiniMap";

		public const string PLUGIN_NAME = "MiniMap";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}