Decompiled source of Map Tweaks v1.0.0

FribsMapTweaks.dll

Decompiled 5 months 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.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Frib")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Changes minimap features")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FribsMapTweaks")]
[assembly: AssemblyTitle("FribsMapTweaks")]
[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 NoMinimap
{
	[HarmonyPatch(typeof(MapController), "Setup")]
	public class MapSetup
	{
		[HarmonyPrefix]
		private static void Prefix(MapController __instance)
		{
			if (NoMinimapPlugin.configHidePlayer.Value)
			{
				__instance.displayPlayerCharacter = false;
			}
		}
	}
	[HarmonyPatch(typeof(MapController), "OpenMap")]
	public class OpenMapOnlyWithCityDirectory
	{
		[HarmonyPrefix]
		private static bool Prefix(MapController __instance)
		{
			if (NoMinimapPlugin.configAllowMapAlways.Value)
			{
				return true;
			}
			GameObject val = GameObject.Find("GameCanvas/WindowCanvas/City Directory");
			if (NoMinimapPlugin.configAllowMapWithCityDirectory.Value && Object.op_Implicit((Object)(object)val) && val.activeSelf)
			{
				return true;
			}
			if (NoMinimapPlugin.configAllowMapWithCruncher.Value && Player.Instance.computerInteractable != null)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "OnPauseChange")]
	public class OnPauseChange
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			if (NoMinimapPlugin.configAllowMapAlways.Value)
			{
				return;
			}
			GameObject val = GameObject.Find("GameCanvas/ActionPanelCanvas/TopPanel/ButtonArea/MapButton");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Transform val2 = val.transform.Find("Toggle");
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return;
			}
			Image component = ((Component)val2).GetComponent<Image>();
			if (!Object.op_Implicit((Object)(object)component) || !((Behaviour)component).enabled)
			{
				return;
			}
			ButtonController component2 = val.GetComponent<ButtonController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				int persistentEventCount = ((UnityEventBase)component2.button.onClick).GetPersistentEventCount();
				for (int i = 0; i < persistentEventCount; i++)
				{
					((UnityEventBase)component2.button.onClick).SetPersistentListenerState(i, (UnityEventCallState)2);
				}
				((UnityEvent)component2.button.onClick).Invoke();
				for (int j = 0; j < persistentEventCount; j++)
				{
					((UnityEventBase)component2.button.onClick).SetPersistentListenerState(j, (UnityEventCallState)0);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MapController), "PlotPlayerRoute", new Type[] { typeof(Evidence) })]
	[HarmonyPatch(typeof(MapController), "PlotPlayerRoute", new Type[] { typeof(NewGameLocation) })]
	[HarmonyPatch(typeof(MapController), "PlotPlayerRoute", new Type[] { typeof(NewAddress) })]
	[HarmonyPatch(typeof(MapController), "PlotPlayerRoute", new Type[] { typeof(StreetController) })]
	[HarmonyPatch(typeof(MapController), "PlotPlayerRoute", new Type[]
	{
		typeof(NewNode),
		typeof(bool),
		typeof(NewGameLocation)
	})]
	public class PlotPlayerRoute
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			if (NoMinimapPlugin.configAllowRouting.Value)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(SessionData), "Awake")]
	public class SessionStuff
	{
		[HarmonyPostfix]
		private static void Postfix(SessionData __instance)
		{
			if (!NoMinimapPlugin.configAllowMapAlways.Value)
			{
				__instance.enableFirstPersonMap = false;
			}
		}
	}
	[BepInPlugin("Frib.MapTweaks", "Map Tweaks", "1.0.0")]
	public class NoMinimapPlugin : BasePlugin
	{
		public static ConfigEntry<bool> configAllowMapAlways;

		public static ConfigEntry<bool> configAllowMapWithCruncher;

		public static ConfigEntry<bool> configAllowMapWithCityDirectory;

		public static ConfigEntry<bool> configHidePlayer;

		public static ConfigEntry<bool> configAllowRouting;

		public override void Load()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			configAllowMapAlways = ((BasePlugin)this).Config.Bind<bool>("General", "AlwaysAllowMap", false, "Set this to true if you want to allow the minimap like normally, but if you want to disable other map features with this mod");
			configAllowMapWithCruncher = ((BasePlugin)this).Config.Bind<bool>("General", "AllowMapWithCruncher", true, "Allows you to view the map when interacting with a cruncher");
			configAllowMapWithCityDirectory = ((BasePlugin)this).Config.Bind<bool>("General", "AllowMapWithCityDirectory", true, "Allows you to view the map when you have a city directory open");
			configHidePlayer = ((BasePlugin)this).Config.Bind<bool>("MapFeatures", "HidePlayer", true, "Hide the player and disable player tracking");
			configAllowRouting = ((BasePlugin)this).Config.Bind<bool>("MapFeatures", "AllowRouting", false, "Allows you to view the path to a target");
			Harmony val = new Harmony("FribsMapTweaks");
			val.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FribsMapTweaks";

		public const string PLUGIN_NAME = "FribsMapTweaks";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}