Decompiled source of BiggerMinimapDiscoveryRadius v3.6.17

BiggerMinimapDiscoveryRadius.dll

Decompiled 8 months ago
using 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 HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BiggerMinimapDiscoveryRadius")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BiggerMinimapDiscoveryRadius")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b347f62d-b22e-48ac-b439-d690130f2e47")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BiggerMinimapDiscoveryRadius;

[HarmonyPatch(typeof(Minimap), "Explore", new Type[]
{
	typeof(Vector3),
	typeof(float)
})]
public class MinimapDiscoveryRadiusMod
{
	public const string Old_OnFootSaveNameKey = "MinimapDiscoveryRadiusMod";

	public const string OnFootSaveNameKey = "MinimapDiscoveryRadiusOnFootMod";

	public const string OnBoatSaveNameKey = "MinimapDiscoveryRadiusOnBoatMod";

	public const string WeatherEnabledSaveNameKey = "MinimapDiscoveryRadiusWeatherEnabled";

	public const string TimeEnabledSaveNameKey = "MinimapDiscoveryRadiusTimeEnabled";

	public static void Prefix(ref Vector3 p, ref float radius)
	{
		radius = radius * GetLocomotionModifier() * GetWeatherModifier() * GetTimeOfDayModifier();
	}

	public static float GetLocomotionModifier()
	{
		if (PlayerIsOnControlledBoat())
		{
			return GetLocomotionOnBoatModifier();
		}
		return GetLocomotionOnFootModifier();
	}

	public static float GetLocomotionOnFootModifier()
	{
		int @int = PlayerPrefs.GetInt("MinimapDiscoveryRadiusMod", 0);
		if (@int != 0)
		{
			PlayerPrefs.SetInt("MinimapDiscoveryRadiusOnFootMod", @int);
			PlayerPrefs.SetInt("MinimapDiscoveryRadiusMod", 0);
		}
		return PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnFootMod", 0) switch
		{
			1 => 2f, 
			2 => 3f, 
			3 => 5f, 
			_ => 1f, 
		};
	}

	public static float GetLocomotionOnBoatModifier()
	{
		return PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnBoatMod", 3) switch
		{
			0 => GetLocomotionOnFootModifier(), 
			1 => 2f, 
			2 => 3f, 
			3 => 5f, 
			4 => 7f, 
			5 => 10f, 
			_ => 1f, 
		};
	}

	public static bool PlayerIsOnControlledBoat()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
		{
			return false;
		}
		if (((Character)Player.m_localPlayer).IsAttachedToShip() || Object.op_Implicit((Object)(object)Player.m_localPlayer.GetControlledShip()))
		{
			return true;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		foreach (Player allPlayer in Player.GetAllPlayers())
		{
			if (!((Object)(object)allPlayer == (Object)(object)Player.m_localPlayer) && (((Character)allPlayer).IsAttachedToShip() || Object.op_Implicit((Object)(object)allPlayer.GetControlledShip())))
			{
				Vector3 val = ((Component)allPlayer).transform.position - position;
				if (!(((Vector3)(ref val)).sqrMagnitude > 20f))
				{
					return true;
				}
			}
		}
		return false;
	}

	public static float GetWeatherModifier()
	{
		if (PlayerPrefs.GetInt("MinimapDiscoveryRadiusWeatherEnabled", 0) == 0)
		{
			return 1f;
		}
		switch (EnvMan.instance.GetCurrentEnvironment().m_name)
		{
		case "Rain":
		case "LightRain":
		case "SwampRain":
		case "Ashrain":
			return PluginEntryPoint.GetConfigWeatherModifierInRain();
		case "Misty":
		case "DeepForest Mist":
			return PluginEntryPoint.GetConfigWeatherModifierInMist();
		case "Snow":
		case "Twilight_Snow":
			return PluginEntryPoint.GetConfigWeatherModifierInSnow();
		case "ThunderStorm":
		case "SnowStorm":
		case "Twilight_SnowStorm":
			return PluginEntryPoint.GetConfigWeatherModifierInStorm();
		case "Darklands_dark":
			return PluginEntryPoint.GetConfigWeatherModifierInDarklands();
		default:
			return 1f;
		}
	}

	public static float GetTimeOfDayModifier()
	{
		if (PlayerPrefs.GetInt("MinimapDiscoveryRadiusTimeEnabled", 0) == 0)
		{
			return 1f;
		}
		float num = 1f;
		float configTimeModifierDuringNight = PluginEntryPoint.GetConfigTimeModifierDuringNight();
		float dayFraction = EnvMan.instance.GetDayFraction();
		if (dayFraction >= 0.2f && dayFraction <= 0.3f)
		{
			return Mathf.Lerp(configTimeModifierDuringNight, num, (dayFraction - 0.2f) / 0.1f);
		}
		if (dayFraction >= 0.7f && dayFraction <= 0.8f)
		{
			return Mathf.Lerp(num, configTimeModifierDuringNight, (dayFraction - 0.7f) / 0.1f);
		}
		if (dayFraction >= 0.25f && dayFraction <= 0.75f)
		{
			return num;
		}
		return configTimeModifierDuringNight;
	}
}
[BepInPlugin("org.bepinex.plugins.tenson.biggerminimapdiscoveryradius", "Bigger Minimap Discovery Radius", "3.6.17.0")]
public class PluginEntryPoint : BaseUnityPlugin
{
	public const string ModVersion = "3.6.17.0";

	private static ConfigEntry<float> s_ConfigWeatherModifierRain;

	private static ConfigEntry<float> s_ConfigWeatherModifierMist;

	private static ConfigEntry<float> s_ConfigWeatherModifierSnow;

	private static ConfigEntry<float> s_ConfigWeatherModifierStorm;

	private static ConfigEntry<float> s_ConfigWeatherModifierDarklands;

	private static ConfigEntry<float> s_ConfigTimeModifierNight;

	public static float GetConfigWeatherModifierInRain()
	{
		return Mathf.Clamp01(s_ConfigWeatherModifierRain.Value);
	}

	public static float GetConfigWeatherModifierInMist()
	{
		return Mathf.Clamp01(s_ConfigWeatherModifierMist.Value);
	}

	public static float GetConfigWeatherModifierInSnow()
	{
		return Mathf.Clamp01(s_ConfigWeatherModifierSnow.Value);
	}

	public static float GetConfigWeatherModifierInStorm()
	{
		return Mathf.Clamp01(s_ConfigWeatherModifierStorm.Value);
	}

	public static float GetConfigWeatherModifierInDarklands()
	{
		return Mathf.Clamp01(s_ConfigWeatherModifierDarklands.Value);
	}

	public static float GetConfigTimeModifierDuringNight()
	{
		return Mathf.Clamp01(s_ConfigTimeModifierNight.Value);
	}

	private void Start()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (Harmony.HasAnyPatches("plugins.tenson.modpack"))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Ten'son's Mod Pack present, no need for this mod to initialize.");
			return;
		}
		new Harmony("plugins.tenson.biggerminimapdiscoveryradius").PatchAll();
		s_ConfigWeatherModifierRain = ((BaseUnityPlugin)this).Config.Bind<float>("Weather Modifiers", "rain", 0.8f, "Discovery radius modifier in rain.");
		s_ConfigWeatherModifierMist = ((BaseUnityPlugin)this).Config.Bind<float>("Weather Modifiers", "mist", 0.8f, "Discovery radius modifier in mist.");
		s_ConfigWeatherModifierSnow = ((BaseUnityPlugin)this).Config.Bind<float>("Weather Modifiers", "snow", 0.8f, "Discovery radius modifier in snow.");
		s_ConfigWeatherModifierStorm = ((BaseUnityPlugin)this).Config.Bind<float>("Weather Modifiers", "storm", 0.7f, "Discovery radius modifier in storm.");
		s_ConfigWeatherModifierDarklands = ((BaseUnityPlugin)this).Config.Bind<float>("Weather Modifiers", "darklands", 0.8f, "Discovery radius modifier in darklands.");
		s_ConfigTimeModifierNight = ((BaseUnityPlugin)this).Config.Bind<float>("Time Modifiers", "night", 0.8f, "Discovery radius modifier during the night.");
	}
}
[HarmonyPatch(typeof(Settings), "Awake")]
public class SettingsMenuUIPatch
{
	public static void Postfix(Settings __instance)
	{
		Debug.Log((object)"Injecting Bigger Minimap Discovery Radius Mod UI...");
		CreateModsButton(((Component)__instance).transform.parent);
	}

	private static void CreateModsButton(Transform transform)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		CreateTopRightButton(transform, "ModsButton", "MOD", Color.white, Color.black, new Vector2(500f, 100f), new UnityAction(OnModsButtonClicked));
	}

	public static void DestroyModsButton()
	{
		GameObject val = GameObject.Find("ModsButton");
		if (Object.op_Implicit((Object)(object)val))
		{
			Object.Destroy((Object)(object)val);
		}
	}

	private static Button CreateTopRightButton(Transform _parent, string _buttonName, string _text, Color _imageColor, Color _textColor, Vector2 _buttonSize, UnityAction _actionOnClick)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Expected O, but got Unknown
		GameObject val = new GameObject(_buttonName, new Type[3]
		{
			typeof(RectTransform),
			typeof(Image),
			typeof(Button)
		});
		val.transform.SetParent(_parent);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(1f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(1f, 1f);
		component.anchoredPosition = new Vector2(0f, 0f);
		component.sizeDelta = _buttonSize;
		Button component2 = val.GetComponent<Button>();
		((Selectable)component2).interactable = true;
		if (_actionOnClick != null)
		{
			((UnityEvent)component2.onClick).AddListener(_actionOnClick);
		}
		((Graphic)val.GetComponent<Image>()).color = _imageColor;
		GameObject val2 = new GameObject(_buttonName + "Text", new Type[2]
		{
			typeof(RectTransform),
			typeof(Text)
		});
		val2.transform.SetParent(val.transform);
		RectTransform component3 = val2.GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(0f, 0f);
		component3.anchorMax = new Vector2(1f, 1f);
		component3.pivot = new Vector2(0.5f, 0.5f);
		component3.anchoredPosition = new Vector2(0f, 0f);
		component3.sizeDelta = new Vector2(0f, 0f);
		Text component4 = val2.GetComponent<Text>();
		((Graphic)component4).color = _textColor;
		component4.resizeTextForBestFit = true;
		component4.resizeTextMaxSize = 72;
		component4.alignment = (TextAnchor)4;
		component4.text = _text;
		Font val4 = (component4.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"));
		((Graphic)component4).material = val4.material;
		return component2;
	}

	private static Text CreateTextComponent(Transform _parent, string _textName, string _text, TextAnchor _textAnchor, Color _textColor)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Expected O, but got Unknown
		GameObject val = new GameObject(_textName, new Type[2]
		{
			typeof(RectTransform),
			typeof(Text)
		});
		val.transform.SetParent(_parent);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(0f, 0f);
		component.sizeDelta = new Vector2(0f, 60f);
		Text component2 = val.GetComponent<Text>();
		((Graphic)component2).color = _textColor;
		component2.resizeTextForBestFit = true;
		component2.resizeTextMaxSize = 72;
		component2.alignment = _textAnchor;
		component2.text = _text;
		Font val3 = (component2.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"));
		((Graphic)component2).material = val3.material;
		return component2;
	}

	private static void OnModsButtonClicked()
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Expected O, but got Unknown
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Expected O, but got Unknown
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Expected O, but got Unknown
		//IL_0515: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_0535: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Expected O, but got Unknown
		//IL_0593: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05be: Expected O, but got Unknown
		//IL_0612: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_0633: Unknown result type (might be due to invalid IL or missing references)
		//IL_063d: Expected O, but got Unknown
		Canvas val = Object.FindObjectsOfType<Canvas>()[0];
		Canvas[] array = Object.FindObjectsOfType<Canvas>();
		foreach (Canvas val2 in array)
		{
			if (((Object)val2).name == "GUI" || ((Object)val2).name.Contains("GUI"))
			{
				val = val2;
				break;
			}
		}
		GameObject val3 = new GameObject("ModsFrame", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val3.transform.SetParent(((Component)val).transform);
		RectTransform component = val3.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 0f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = new Vector2(0f, 0f);
		component.sizeDelta = new Vector2(0f, 0f);
		((Graphic)val3.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
		GameObject val4 = new GameObject("ModsDialog", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val4.transform.SetParent(val3.transform);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 0f);
		component2.anchorMax = new Vector2(1f, 1f);
		component2.pivot = new Vector2(0.5f, 0.5f);
		component2.anchoredPosition = new Vector2(0f, 0f);
		component2.sizeDelta = new Vector2(-400f, -400f);
		((Graphic)val4.GetComponent<Image>()).color = new Color(0.5283019f, 0.2804001f, 0.1320755f, 1f);
		CreateTextComponent(val4.transform, "ModVersionText", "Minimap Discovery Radius v3.6.17.0", (TextAnchor)4, Color.black);
		CreateTopRightButton(val4.transform, "CloseModsDialogButton", "CLOSE", Color.red, Color.white, new Vector2(300f, 60f), new UnityAction(OnCloseModsFrameClicked));
		GameObject val5 = new GameObject("ModsList", new Type[1] { typeof(RectTransform) });
		val5.transform.SetParent(val4.transform);
		RectTransform component3 = val5.GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(0f, 0f);
		component3.anchorMax = new Vector2(1f, 1f);
		component3.pivot = new Vector2(0.5f, 0.5f);
		component3.anchoredPosition = new Vector2(0f, -30f);
		component3.sizeDelta = new Vector2(-40f, -80f);
		int @int = PlayerPrefs.GetInt("MinimapDiscoveryRadiusMod", 0);
		if (@int != 0)
		{
			PlayerPrefs.SetInt("MinimapDiscoveryRadiusOnFootMod", @int);
			PlayerPrefs.SetInt("MinimapDiscoveryRadiusMod", 0);
		}
		string buttonName = "MinimapDiscoveryRadiusOnFootButton";
		int int2 = PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnFootMod", 0);
		string text = "";
		for (int j = 0; j < 4; j++)
		{
			if (j == int2)
			{
				text += "<color=green>";
			}
			switch (j)
			{
			case 0:
				text += "Default";
				break;
			case 1:
				text += "2x";
				break;
			case 2:
				text += "3x";
				break;
			case 3:
				text += "5x";
				break;
			}
			if (j != 3)
			{
				text += ", ";
			}
			if (j == int2)
			{
				text += "</color>";
			}
		}
		string text2 = "Minimap Discovery Radius On Foot (" + text + ")";
		CreateTopRightButton(val5.transform, buttonName, text2, Color.white, Color.black, new Vector2(800f, 60f), new UnityAction(OnMinimapDiscoveryRadiusOnFootButtonClicked));
		string buttonName2 = "MinimapDiscoveryRadiusOnBoatButton";
		int int3 = PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnBoatMod", 3);
		string text3 = "";
		for (int k = 0; k < 6; k++)
		{
			if (k == int3)
			{
				text3 += "<color=green>";
			}
			switch (k)
			{
			case 0:
				text3 += "Same As On Foot";
				break;
			case 1:
				text3 += "2x";
				break;
			case 2:
				text3 += "3x";
				break;
			case 3:
				text3 += "5x";
				break;
			case 4:
				text3 += "7x";
				break;
			case 5:
				text3 += "10x";
				break;
			}
			if (k != 5)
			{
				text3 += ", ";
			}
			if (k == int3)
			{
				text3 += "</color>";
			}
		}
		string text4 = "Minimap Discovery Radius On Boat (" + text3 + ")";
		CreateTopRightButton(val5.transform, buttonName2, text4, Color.white, Color.black, new Vector2(800f, 60f), new UnityAction(OnMinimapDiscoveryRadiusOnBoatButtonClicked));
		string modButtonName2 = "MinimapDiscoveryRadiusWeatherButton";
		bool num = PlayerPrefs.GetInt("MinimapDiscoveryRadiusWeatherEnabled", 0) == 1;
		string text5 = "<color=green>Enabled</color>";
		if (!num)
		{
			text5 = "<color=red>Disabled</color>";
		}
		string text6 = "Weather Affects Discovery Radius (" + text5 + ")";
		CreateTopRightButton(val5.transform, modButtonName2, text6, Color.white, Color.black, new Vector2(800f, 60f), (UnityAction)delegate
		{
			OnToggleModButtonClicked(modButtonName2, "MinimapDiscoveryRadiusWeatherEnabled", "Weather Affects Discovery Radius");
		});
		string modButtonName = "MinimapDiscoveryRadiusTimeButton";
		bool num2 = PlayerPrefs.GetInt("MinimapDiscoveryRadiusTimeEnabled", 0) == 1;
		string text7 = "<color=green>Enabled</color>";
		if (!num2)
		{
			text7 = "<color=red>Disabled</color>";
		}
		string text8 = "Time Of Day Affects Discovery Radius (" + text7 + ")";
		CreateTopRightButton(val5.transform, modButtonName, text8, Color.white, Color.black, new Vector2(800f, 60f), (UnityAction)delegate
		{
			OnToggleModButtonClicked(modButtonName, "MinimapDiscoveryRadiusTimeEnabled", "Time Of Day Affects Discovery Radius");
		});
		VerticalLayoutGroup obj = val5.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 5f;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false;
		((HorizontalOrVerticalLayoutGroup)obj).childScaleWidth = false;
		((HorizontalOrVerticalLayoutGroup)obj).childScaleHeight = false;
	}

	public static void OnCloseModsFrameClicked()
	{
		GameObject val = GameObject.Find("ModsFrame");
		if (Object.op_Implicit((Object)(object)val))
		{
			Object.Destroy((Object)(object)val);
		}
	}

	private static void OnMinimapDiscoveryRadiusOnFootButtonClicked()
	{
		GameObject val = GameObject.Find("MinimapDiscoveryRadiusOnFootButton");
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		int @int = PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnFootMod", 0);
		@int = (@int + 1) % 4;
		PlayerPrefs.SetInt("MinimapDiscoveryRadiusOnFootMod", @int);
		string text = "";
		for (int i = 0; i < 4; i++)
		{
			if (i == @int)
			{
				text += "<color=green>";
			}
			switch (i)
			{
			case 0:
				text += "Default";
				break;
			case 1:
				text += "2x";
				break;
			case 2:
				text += "3x";
				break;
			case 3:
				text += "5x";
				break;
			}
			if (i != 3)
			{
				text += ", ";
			}
			if (i == @int)
			{
				text += "</color>";
			}
		}
		val.GetComponentInChildren<Text>().text = "Minimap Discovery Radius On Foot (" + text + ")";
	}

	private static void OnMinimapDiscoveryRadiusOnBoatButtonClicked()
	{
		GameObject val = GameObject.Find("MinimapDiscoveryRadiusOnBoatButton");
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		int @int = PlayerPrefs.GetInt("MinimapDiscoveryRadiusOnBoatMod", 3);
		@int = (@int + 1) % 6;
		PlayerPrefs.SetInt("MinimapDiscoveryRadiusOnBoatMod", @int);
		string text = "";
		for (int i = 0; i < 6; i++)
		{
			if (i == @int)
			{
				text += "<color=green>";
			}
			switch (i)
			{
			case 0:
				text += "Same As On Foot";
				break;
			case 1:
				text += "2x";
				break;
			case 2:
				text += "3x";
				break;
			case 3:
				text += "5x";
				break;
			case 4:
				text += "7x";
				break;
			case 5:
				text += "10x";
				break;
			}
			if (i != 5)
			{
				text += ", ";
			}
			if (i == @int)
			{
				text += "</color>";
			}
		}
		val.GetComponentInChildren<Text>().text = "Minimap Discovery Radius On Boat (" + text + ")";
	}

	private static void OnToggleModButtonClicked(string _modButtonName, string _saveName, string _text)
	{
		GameObject val = GameObject.Find(_modButtonName);
		if (Object.op_Implicit((Object)(object)val))
		{
			bool flag = PlayerPrefs.GetInt(_saveName, 0) == 1;
			flag = !flag;
			PlayerPrefs.SetInt(_saveName, flag ? 1 : 0);
			string text = "<color=green>Enabled</color>";
			if (!flag)
			{
				text = "<color=red>Disabled</color>";
			}
			val.GetComponentInChildren<Text>().text = _text + " (" + text + ")";
		}
	}
}
[HarmonyPatch(typeof(Settings), "OnBack")]
public class SettingsMenuOnBackPatch
{
	public static bool Prefix()
	{
		SettingsMenuUIPatch.OnCloseModsFrameClicked();
		SettingsMenuUIPatch.DestroyModsButton();
		return true;
	}
}
[HarmonyPatch(typeof(Settings), "OnOk")]
public class SettingsMenuOnOkPatch
{
	public static bool Prefix()
	{
		SettingsMenuUIPatch.OnCloseModsFrameClicked();
		SettingsMenuUIPatch.DestroyModsButton();
		return true;
	}
}