Decompiled source of Universal Radar v1.1.0

ScienceBird.UniversalRadar.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EasyTextEffects.Editor.MyBoxCopy.Extensions;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using TerraMesh;
using TerraMesh.Utils;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ScienceBird.UniversalRadar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+f340c31b4cdd6ee6018bbbafac8f234ed5d01375")]
[assembly: AssemblyProduct("UniversalRadar")]
[assembly: AssemblyTitle("ScienceBird.UniversalRadar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 UniversalRadar
{
	[BepInPlugin("ScienceBird.UniversalRadar", "UniversalRadar", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class UniversalRadar : BaseUnityPlugin
	{
		public static AssetBundle URAssets;

		public static ConfigEntry<float> AutoLineWidth;

		public static ConfigEntry<float> AutoSpacing;

		public static ConfigEntry<float> AutoOpacity;

		public static ConfigEntry<bool> LogValues;

		public static ConfigEntry<bool> UseTerraMesh;

		public static ConfigEntry<bool> HideRadarObjects;

		public static ConfigEntry<bool> RadarWater;

		public static ConfigEntry<bool> ShowFoliage;

		public static ConfigEntry<float> RadarObjectSize;

		public static ConfigEntry<float> CameraClipExtension;

		public static ConfigEntry<bool> ExperimentationSprites;

		public static ConfigEntry<bool> AssuranceSprites;

		public static ConfigEntry<bool> VowSprites;

		public static ConfigEntry<bool> MarchSprites;

		public static ConfigEntry<bool> RendSprites;

		public static ConfigEntry<bool> DineSprites;

		public static ConfigEntry<bool> OffenseSprites;

		public static ConfigEntry<bool> TitanSprites;

		public static ConfigEntry<bool> ArtificeSprites;

		public static ConfigEntry<bool> AdamanceSprites;

		public static ConfigEntry<bool> EmbrionSprites;

		public static ConfigEntry<bool> ClearOrphans;

		public static ConfigEntry<string> ConfigVersion;

		public static Dictionary<string, GameObject> radarSpritePrefabs = new Dictionary<string, GameObject>();

		public static Material contourMaterial;

		public static Material radarFillMat0;

		public static Material radarFillMat1;

		public static Material radarWaterMat;

		public static bool batbyPresent = false;

		public static bool zaggyPresent = false;

		public static bool dopaPresent = false;

		public static bool spookyPresent = false;

		public static bool terraformerPresent = false;

		public static int[] configVersionArray = new int[3] { -1, -1, -1 };

		public static UniversalRadar Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Expected O, but got Unknown
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Expected O, but got Unknown
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Expected O, but got Unknown
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			UseTerraMesh = ((BaseUnityPlugin)this).Config.Bind<bool>("!General", "Convert Terrains To Mesh", true, "When a moon has non-mesh terrain, it will be converted in order to generate the contour map. This will mean a long initial load on maps with non-mesh terrain (this includes most of Wesley's moons), but after the first time, it will store the generated mesh for the rest of the session. If this ends up taking way too long or even causing timeouts/crashes, you can disable it here (though any moons with non-mesh terrain will no longer have contour maps).");
			HideRadarObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("!General", "Master Disable Radar Objects", false, "Overrides all individual configs and will never attempt to create radar images for non-terrain objects.");
			RadarObjectSize = ((BaseUnityPlugin)this).Config.Bind<float>("!General", "Radar Object Display Threshold", 90f, new ConfigDescription("How big objects need to be to render as an object on the radar screen (if that config is enabled on the moon). Make this bigger to display less small objects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 1000f), Array.Empty<object>()));
			RadarWater = ((BaseUnityPlugin)this).Config.Bind<bool>("!General", "Show Water On Radar", true, "Generates a special mesh for water objects on vanilla and modded moons.");
			ShowFoliage = ((BaseUnityPlugin)this).Config.Bind<bool>("!General", "Show Foliage Radar Objects", false, "Includes meshes on the foliage layer when generating radar objects.");
			AutoSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Automatic Settings", "Line Spacing", 2.5f, new ConfigDescription("Spacing between lines in automatically generated contour maps.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
			AutoLineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Automatic Settings", "Line Thickness", 6f, new ConfigDescription("Thickness of lines in automatically generated contour maps.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			AutoOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Automatic Settings", "Maximum Opacity", 0.9f, new ConfigDescription("Maximum opacity of the shading on automatically generated contour maps (how light the tallest parts of the contour map will be).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			LogValues = ((BaseUnityPlugin)this).Config.Bind<bool>("Automatic Settings", "Log Automatic Values", false, "Logs all contour map values (notably the minimum and maximum height) upon generating on a moon. Use this if you want to know the normally calculated values before manually customizing them yourself (or for other debugging purposes).");
			ExperimentationSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Experimentation", true, "Adds new radar sprites for Experimentation, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			AssuranceSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Assurance", true, "Adds new radar sprites for Assurance, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			VowSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Vow", true, "Adds new radar sprites for Vow, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			MarchSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "March", true, "Adds new radar sprites for March, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			RendSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Rend", true, "Adds new radar sprites for Rend, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			DineSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Dine", true, "Adds new radar sprites for Dine, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			OffenseSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Offense", true, "Adds new radar sprites for Offense, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			TitanSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Titan", true, "Adds new radar sprites for Titan, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			ArtificeSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Artifice", true, "Adds new radar sprites for Artifice, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			AdamanceSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Adamance", true, "Adds new radar sprites for Adamance, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			EmbrionSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Vanilla Radar Sprites", "Embrion", true, "Adds new radar sprites for Embrion, showing buildings, obstacles, catwalks, and more (will replace any existing extra radar objects).");
			CameraClipExtension = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Increased Render Distance", 20f, new ConfigDescription("When outside, the region of space captured by the camera needs to be extended for the 3D contours generated by this mod to be captured. Increasing this means more objects/scenery above and below a player will be picked up on the radar screen (set this to 0 for vanilla clipping distance).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			ClearOrphans = ((BaseUnityPlugin)this).Config.Bind<bool>("!Config Management", "Clear Orphaned Entries On Next Join", false, "This check box acts like a button which will only activate once then go back to being unchecked: after starting a game, all unused config data will be cleared. This means config entries associated with moons that are no longer installed or entries for modes which are no longer active for a given moon (e.g. if you switch a moon's mode from Manual to Automatic, the manual options will still be leftover in the file).");
			string text = "-1.-1.-1";
			ConfigDefinition key = new ConfigDefinition("!Config Management", "Config Version");
			PropertyInfo property = ((object)((BaseUnityPlugin)this).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(((BaseUnityPlugin)this).Config, null);
			if (dictionary.TryGetValue(key, out var value))
			{
				Logger.LogDebug((object)("Found config version: " + value + " > 1.1.0"));
				text = value;
			}
			ConfigVersion = ((BaseUnityPlugin)this).Config.Bind<string>("!Config Management", "Config Version", "-1.-1.-1", "Used for internal config tracking, please ignore.");
			string[] array = text.Split(".");
			if (array.Length != 3 || array.Any((string x) => !int.TryParse(x, out var _)))
			{
				Logger.LogWarning((object)"Invalid config version detected!");
				array = new string[3] { "-1", "-1", "-1" };
				ConfigVersion.Value = "-1.-1.-1";
			}
			configVersionArray = Array.ConvertAll(array, (string x) => int.Parse(x));
			batbyPresent = Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader");
			zaggyPresent = Chainloader.PluginInfos.ContainsKey("Zaggy1024.TwoRadarMaps");
			dopaPresent = Chainloader.PluginInfos.ContainsKey("dopadream.lethalcompany.rebalancedmoons");
			spookyPresent = Chainloader.PluginInfos.ContainsKey("MapImprovements");
			terraformerPresent = Chainloader.PluginInfos.ContainsKey("TonightWeDine");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			URAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "sburassets"));
			contourMaterial = (Material)URAssets.LoadAsset("ContourMat");
			radarFillMat0 = (Material)URAssets.LoadAsset("RadarGreen0");
			radarFillMat1 = (Material)URAssets.LoadAsset("RadarGreen1");
			radarWaterMat = (Material)URAssets.LoadAsset("RadarBlue");
			radarWaterMat.renderQueue = 1000;
			Patch();
			Logger.LogInfo((object)"ScienceBird.UniversalRadar v1.1.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("ScienceBird.UniversalRadar");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ScienceBird.UniversalRadar";

		public const string PLUGIN_NAME = "UniversalRadar";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace UniversalRadar.Patches
{
	[HarmonyPatch]
	public class ConfigPatch
	{
		public static List<(MaterialPropertiesConfig, (string, string))> vanillaConfigs = new List<(MaterialPropertiesConfig, (string, string))>();

		public static List<(string, string)> moonBlacklist = new List<(string, string)>();

		public static Dictionary<string, string> vanillaSceneDict = new Dictionary<string, string>();

		[HarmonyPatch(typeof(QuickMenuManager), "Start")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "imabatby.lethallevelloader", "dopadream.lethalcompany.rebalancedmoons" })]
		public static void OnStartInitialize()
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Expected O, but got Unknown
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Expected O, but got Unknown
			RadarContourPatches.loaded = false;
			vanillaSceneDict.Clear();
			vanillaSceneDict.Add("41 Experimentation", "Level1Experimentation");
			vanillaSceneDict.Add("220 Assurance", "Level2Assurance");
			vanillaSceneDict.Add("56 Vow", "Level3Vow");
			vanillaSceneDict.Add("61 March", "Level4March");
			vanillaSceneDict.Add("85 Rend", "Level5Rend");
			vanillaSceneDict.Add("7 Dine", "Level6Dine");
			vanillaSceneDict.Add("21 Offense", "Level7Offense");
			vanillaSceneDict.Add("8 Titan", "Level8Titan");
			vanillaSceneDict.Add("68 Artifice", "Level9Artifice");
			vanillaSceneDict.Add("20 Adamance", "Level10Adamance");
			vanillaSceneDict.Add("5 Embrion", "Level11Embrion");
			vanillaSceneDict.Add("71 Gordion", "CompanyBuilding");
			if (UniversalRadar.batbyPresent)
			{
				LLLConfigPatch.SceneNamePatch();
			}
			(string, string) item = ("71 Gordion", vanillaSceneDict["71 Gordion"]);
			if (!moonBlacklist.Contains(item))
			{
				moonBlacklist.Add(item);
			}
			UniversalRadar.radarSpritePrefabs.Clear();
			if (UniversalRadar.ExperimentationSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["41 Experimentation"], (GameObject)UniversalRadar.URAssets.LoadAsset("ExperimentationRadarSprites"));
			}
			if (UniversalRadar.AssuranceSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["220 Assurance"], (GameObject)UniversalRadar.URAssets.LoadAsset("AssuranceRadarSprites"));
			}
			if (UniversalRadar.VowSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["56 Vow"], (GameObject)UniversalRadar.URAssets.LoadAsset("VowRadarSprites"));
			}
			if (UniversalRadar.MarchSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["61 March"], (GameObject)UniversalRadar.URAssets.LoadAsset("MarchRadarSprites"));
			}
			if (UniversalRadar.RendSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["85 Rend"], (GameObject)UniversalRadar.URAssets.LoadAsset("RendRadarSprites"));
			}
			if (UniversalRadar.DineSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["7 Dine"], (GameObject)UniversalRadar.URAssets.LoadAsset("DineRadarSprites"));
			}
			if (UniversalRadar.OffenseSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["21 Offense"], (GameObject)UniversalRadar.URAssets.LoadAsset("OffenseRadarSprites"));
			}
			if (UniversalRadar.TitanSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["8 Titan"], (GameObject)UniversalRadar.URAssets.LoadAsset("TitanRadarSprites"));
			}
			if (UniversalRadar.ArtificeSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["68 Artifice"], (GameObject)UniversalRadar.URAssets.LoadAsset("ArtificeRadarSprites"));
			}
			if (UniversalRadar.AdamanceSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["20 Adamance"], (GameObject)UniversalRadar.URAssets.LoadAsset("AdamanceRadarSprites"));
			}
			if (UniversalRadar.EmbrionSprites.Value)
			{
				UniversalRadar.radarSpritePrefabs.Add(vanillaSceneDict["5 Embrion"], (GameObject)UniversalRadar.URAssets.LoadAsset("EmbrionRadarSprites"));
			}
			vanillaConfigs.Clear();
			vanillaConfigs.Add((new MaterialPropertiesConfig("41 Experimentation", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("41 Experimentation", vanillaSceneDict["41 Experimentation"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("220 Assurance", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("220 Assurance", vanillaSceneDict["220 Assurance"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("56 Vow", "Vanilla", "Manual", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -20f, 20f, 0.9f), ("56 Vow", vanillaSceneDict["56 Vow"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("61 March", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("61 March", vanillaSceneDict["61 March"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("85 Rend", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("85 Rend", vanillaSceneDict["85 Rend"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("7 Dine", "Vanilla", "Manual", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -27f, 17f, 0.9f), ("7 Dine", vanillaSceneDict["7 Dine"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("21 Offense", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("21 Offense", vanillaSceneDict["21 Offense"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("8 Titan", "Vanilla", "Auto", show: false, lowOpacity: false, extend: true, 0.75f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("8 Titan", vanillaSceneDict["8 Titan"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("68 Artifice", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("68 Artifice", vanillaSceneDict["68 Artifice"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("20 Adamance", "Vanilla", "Manual", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -30f, 23f, 0.9f), ("20 Adamance", vanillaSceneDict["20 Adamance"])));
			vanillaConfigs.Add((new MaterialPropertiesConfig("5 Embrion", "Vanilla", "Auto", show: false, lowOpacity: false, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -10f, 30f, 0.9f), ("5 Embrion", vanillaSceneDict["5 Embrion"])));
			foreach (var vanillaConfig in vanillaConfigs)
			{
				if (vanillaConfig.Item1.mode.Value == "Manual" || (vanillaConfig.Item1.mode.Value == "Auto" && (vanillaConfig.Item1.extendHeight.Value || !vanillaConfig.Item1.showObjects.Value || vanillaConfig.Item1.lowObjectOpacity.Value || vanillaConfig.Item1.baseColourHex.Value != "4D6A46" || vanillaConfig.Item1.opacityMult.Value != 2f)))
				{
					if (!RadarContourPatches.contourDataDict.ContainsKey(vanillaConfig.Item2))
					{
						RadarContourPatches.contourDataDict.Add(vanillaConfig.Item2, new MaterialProperties(vanillaConfig.Item1));
					}
				}
				else if (vanillaConfig.Item1.mode.Value == "Ignore" && !moonBlacklist.Contains(vanillaConfig.Item2))
				{
					moonBlacklist.Add(vanillaConfig.Item2);
				}
			}
			if (UniversalRadar.batbyPresent)
			{
				LLLConfigPatch.OnStartInitialize();
			}
			if (UniversalRadar.ClearOrphans.Value)
			{
				PropertyInfo property = ((object)((BaseUnityPlugin)UniversalRadar.Instance).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(((BaseUnityPlugin)UniversalRadar.Instance).Config, null);
				dictionary.Clear();
				UniversalRadar.ClearOrphans.Value = false;
			}
			UniversalRadar.ConfigVersion.Value = "1.1.0";
			((BaseUnityPlugin)UniversalRadar.Instance).Config.Save();
		}

		public static bool OlderConfigVersion(int[] targetVersion)
		{
			if (UniversalRadar.configVersionArray.Length == 3 && targetVersion.Length == 3)
			{
				for (int i = 0; i < 3; i++)
				{
					if (UniversalRadar.configVersionArray[i] != targetVersion[i])
					{
						if (UniversalRadar.configVersionArray[i] < targetVersion[i])
						{
							return true;
						}
						return false;
					}
				}
			}
			return false;
		}
	}
	public class MaterialPropertiesConfig
	{
		public ConfigEntry<string> mode;

		public ConfigEntry<bool> showObjects;

		public ConfigEntry<bool> lowObjectOpacity;

		public ConfigEntry<bool> extendHeight;

		public ConfigEntry<float> lineSpacing;

		public ConfigEntry<float> lineThickness;

		public ConfigEntry<float> minHeight;

		public ConfigEntry<float> maxHeight;

		public ConfigEntry<float> opacityCap;

		public ConfigEntry<float> opacityMult;

		public ConfigEntry<string> baseColourHex;

		public ConfigEntry<string> lineColourHex;

		public MaterialPropertiesConfig(string moon, string vanilla, string defaultMode, bool show, bool lowOpacity, bool extend, float multiplier, string colourHexBG, string colourHexLine, float spacing, float thickness, float min, float max, float opacity)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			string text = moon.Replace("\n", "").Replace("\t", "").Replace("\\", "")
				.Replace("\"", "")
				.Replace("'", "")
				.Replace("[", "")
				.Replace("]", "");
			mode = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text, defaultMode, new ConfigDescription("'Auto' - Automatically generate a contour map at runtime. 'Manual' - Set values yourself for generating the contour map (after setting this, create a new lobby to refresh config). 'Ignore' - Do not change this moon in any way.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "Manual", "Ignore" }), Array.Empty<object>()));
			if (mode.Value != "Ignore")
			{
				showObjects = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Show Radar Objects", show, "In addition to creating a terrain contour map, some objects on the map will be rendered on the radar screen as well.");
				lowObjectOpacity = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - More Translucent Radar Objects", lowOpacity, "Automatically generated radar objects from the above option will display with more transparency. This is recommended when a moon features extensive navigable structures that might normally make excessively bright layered radar sprites.");
				opacityMult = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Opacity Multiplier", multiplier, new ConfigDescription("Opacity multiplier of the shading on this moon's contour map (all shading levels will be multiplied by this number, set higher to make shading generally lighter/higher contrast).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			}
			if (mode.Value == "Auto")
			{
				extendHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Broader Height Range", extend, "When automatically determining this moon's height range for shading, it will cover a large range of heights than normal (try enabling this if contour shading on a moon becomes too bright too quickly).");
				baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Colour Hex Code", colourHexBG, "Colour of the contour lines and shading for this moon (hexadecimal colour code).");
			}
			else if (mode.Value == "Manual")
			{
				lineSpacing = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Spacing", spacing, new ConfigDescription("Spacing between lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
				lineThickness = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Thickness", thickness, new ConfigDescription("Thickness of lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>()));
				minHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Minimum", min, new ConfigDescription("Minimum height for contour shading (height where darkest shade starts).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				maxHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Maximum", max, new ConfigDescription("Maximum height for contour shading (height where the shade becomes lightest).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				opacityCap = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Maximum Opacity", opacity, new ConfigDescription("Maximum opacity of contour shading for this moon (how light the tallest parts of the contour map will be).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
				baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Shading Colour Hex Code", colourHexBG, "Colour of the contour shading for this moon (hexadecimal colour code).");
				lineColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Line Colour Hex Code", colourHexLine, "Colour of the contour lines for this moon (hexadecimal colour code).");
			}
		}

		public MaterialPropertiesConfig(string moon, string vanilla, LLLConfigPatch.MaterialPropertiesValues propertyValues)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Expected O, but got Unknown
			string text = moon.Replace("\n", "").Replace("\t", "").Replace("\\", "")
				.Replace("\"", "")
				.Replace("'", "")
				.Replace("[", "")
				.Replace("]", "");
			mode = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text, propertyValues.mode, new ConfigDescription("'Auto' - Automatically generate a contour map at runtime. 'Manual' - Set values yourself for generating the contour map (after setting this, create a new lobby to refresh config). 'Ignore' - Do not change this moon in any way.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "Manual", "Ignore" }), Array.Empty<object>()));
			if (mode.Value != "Ignore")
			{
				showObjects = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Show Radar Objects", propertyValues.showObjects, "In addition to creating a terrain contour map, some objects on the map will be rendered on the radar screen as well.");
				lowObjectOpacity = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - More Translucent Radar Objects", propertyValues.lowObjectOpacity, "Automatically generated radar objects from the above option will display with more transparency. This is recommended when a moon features extensive navigable structures that might normally make excessively bright layered radar sprites.");
				opacityMult = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Opacity Multiplier", propertyValues.opacityMult, new ConfigDescription("Opacity multiplier of the shading on this moon's contour map (all shading levels will be multiplied by this number, set higher to make shading generally lighter/higher contrast).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			}
			if (mode.Value == "Auto")
			{
				extendHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Broader Height Range", propertyValues.extendHeight, "When automatically determining this moon's height range for shading, it will cover a large range of heights than normal (try enabling this if contour shading on a moon becomes too bright too quickly).");
				baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Colour Hex Code", propertyValues.baseColourHex, "Colour of the contour lines and shading for this moon (hexadecimal colour code).");
			}
			else if (mode.Value == "Manual")
			{
				lineSpacing = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Spacing", propertyValues.lineSpacing, new ConfigDescription("Spacing between lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
				lineThickness = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Thickness", propertyValues.lineThickness, new ConfigDescription("Thickness of lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>()));
				minHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Minimum", propertyValues.minHeight, new ConfigDescription("Minimum height for contour shading (height where darkest shade starts).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				maxHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Maximum", propertyValues.maxHeight, new ConfigDescription("Maximum height for contour shading (height where the shade becomes lightest).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				opacityCap = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Maximum Opacity", propertyValues.opacityCap, new ConfigDescription("Maximum opacity of contour shading for this moon (how light the tallest parts of the contour map will be).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
				baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Shading Colour Hex Code", propertyValues.baseColourHex, "Colour of the contour shading for this moon (hexadecimal colour code).");
				lineColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Line Colour Hex Code", propertyValues.lineColourHex, "Colour of the contour lines for this moon (hexadecimal colour code).");
			}
		}

		public void SetValues(string moon, string vanilla, LLLConfigPatch.MaterialPropertiesValues propertyValues)
		{
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Expected O, but got Unknown
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Expected O, but got Unknown
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Expected O, but got Unknown
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Expected O, but got Unknown
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Expected O, but got Unknown
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Expected O, but got Unknown
			//IL_0768: Unknown result type (might be due to invalid IL or missing references)
			//IL_0772: Expected O, but got Unknown
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_079d: Expected O, but got Unknown
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Expected O, but got Unknown
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Expected O, but got Unknown
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Expected O, but got Unknown
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Expected O, but got Unknown
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Expected O, but got Unknown
			string text = moon.Replace("\n", "").Replace("\t", "").Replace("\\", "")
				.Replace("\"", "")
				.Replace("'", "")
				.Replace("[", "")
				.Replace("]", "");
			mode.Value = propertyValues.mode;
			if (mode.Value != "Ignore")
			{
				if (showObjects == null)
				{
					showObjects = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Show Radar Objects", propertyValues.showObjects, "In addition to creating a terrain contour map, some objects on the map will be rendered on the radar screen as well.");
				}
				if (lowObjectOpacity == null)
				{
					lowObjectOpacity = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - More Translucent Radar Objects", propertyValues.lowObjectOpacity, "Automatically generated radar objects from the above option will display with more transparency. This is recommended when a moon features extensive navigable structures that might normally make excessively bright layered radar sprites.");
				}
				if (opacityMult == null)
				{
					opacityMult = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Opacity Multiplier", propertyValues.opacityMult, new ConfigDescription("Opacity multiplier of the shading on this moon's contour map (all shading levels will be multiplied by this number, set higher to make shading generally lighter/higher contrast).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
				}
				if (baseColourHex == null && mode.Value == "Auto")
				{
					baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Colour Hex Code", propertyValues.baseColourHex, "Colour of the contour lines and shading for this moon (hexadecimal colour code).");
				}
				if (baseColourHex == null && mode.Value == "Manual")
				{
					baseColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Shading Colour Hex Code", propertyValues.baseColourHex, "Colour of the contour shading for this moon (hexadecimal colour code).");
				}
				showObjects.Value = propertyValues.showObjects;
				lowObjectOpacity.Value = propertyValues.lowObjectOpacity;
				opacityMult.Value = propertyValues.opacityMult;
				baseColourHex.Value = propertyValues.baseColourHex;
			}
			else
			{
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Show Radar Objects"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - More Translucent Radar Objects"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Opacity Multiplier"));
			}
			if (mode.Value == "Auto")
			{
				if (extendHeight == null)
				{
					extendHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<bool>("Moon Overrides - " + vanilla, text + " - Broader Height Range", propertyValues.extendHeight, "When automatically determining this moon's height range for shading, it will cover a large range of heights than normal (try enabling this if contour shading on a moon becomes too bright too quickly).");
				}
				extendHeight.Value = propertyValues.extendHeight;
			}
			else
			{
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Broader Height Range"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Colour Hex Code"));
			}
			if (mode.Value == "Manual")
			{
				if (lineSpacing == null)
				{
					lineSpacing = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Spacing", propertyValues.lineSpacing, new ConfigDescription("Spacing between lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
				}
				if (lineThickness == null)
				{
					lineThickness = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Line Thickness", propertyValues.lineThickness, new ConfigDescription("Thickness of lines on the contour map for this moon.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>()));
				}
				if (minHeight == null)
				{
					minHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Minimum", propertyValues.minHeight, new ConfigDescription("Minimum height for contour shading (height where darkest shade starts).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				}
				if (maxHeight == null)
				{
					maxHeight = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Shading Maximum", propertyValues.maxHeight, new ConfigDescription("Maximum height for contour shading (height where the shade becomes lightest).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>()));
				}
				if (opacityCap == null)
				{
					opacityCap = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<float>("Moon Overrides - " + vanilla, text + " - Maximum Opacity", propertyValues.opacityCap, new ConfigDescription("Maximum opacity of contour shading for this moon (how light the tallest parts of the contour map will be).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
				}
				if (lineColourHex == null)
				{
					lineColourHex = ((BaseUnityPlugin)UniversalRadar.Instance).Config.Bind<string>("Moon Overrides - " + vanilla, text + " - Line Colour Hex Code", propertyValues.lineColourHex, "Colour of the contour lines for this moon (hexadecimal colour code).");
				}
				lineSpacing.Value = propertyValues.lineSpacing;
				lineThickness.Value = propertyValues.lineThickness;
				minHeight.Value = propertyValues.minHeight;
				maxHeight.Value = propertyValues.maxHeight;
				lineColourHex.Value = propertyValues.lineColourHex;
			}
			else
			{
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Line Spacing"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Line Thickness"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Shading Minimum"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Shading Maximum"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Maximum Opacity"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Shading Colour Hex Code"));
				((BaseUnityPlugin)UniversalRadar.Instance).Config.Remove(new ConfigDefinition("Moon Overrides - " + vanilla, text + " - Line Colour Hex Code"));
			}
		}
	}
	public class LLLConfigPatch
	{
		public class MaterialPropertiesValues
		{
			public string mode;

			public bool showObjects;

			public bool lowObjectOpacity;

			public bool extendHeight;

			public float opacityMult;

			public string baseColourHex;

			public string lineColourHex;

			public float lineSpacing;

			public float lineThickness;

			public float minHeight;

			public float maxHeight;

			public float opacityCap;

			public MaterialPropertiesValues(string defaultMode = "Auto", bool show = true, bool lowOpacity = false, bool extend = false, float multiplier = 2f, string colourHexBG = "4D6A46", string colourHexLine = "4D6A46", float spacing = 2.5f, float thickness = 6f, float min = -10f, float max = 30f, float opacity = 0.9f)
			{
				mode = defaultMode;
				showObjects = show;
				lowObjectOpacity = lowOpacity;
				extendHeight = extend;
				lineSpacing = spacing;
				lineThickness = thickness;
				minHeight = min;
				maxHeight = max;
				opacityCap = opacity;
				opacityMult = multiplier;
				baseColourHex = colourHexBG;
				lineColourHex = colourHexLine;
			}
		}

		public static List<(MaterialPropertiesConfig, (string, string))> moddedConfigs = new List<(MaterialPropertiesConfig, (string, string))>();

		public static readonly Dictionary<(string, string), MaterialPropertiesValues> changeToIgnore1 = new Dictionary<(string, string), MaterialPropertiesValues>
		{
			{
				("115 Wither", "WitherScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("58 Hyve", "Asteroid14Scene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: false, extend: true, 1f)
			},
			{
				("48 Desolation", "DesolationScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: false, extend: true, 1f)
			},
			{
				("354 Demetrica", "DemetricaScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true, extend: true)
			},
			{
				("141 Filitrios", "FilitriosScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("76 Acidir", "AcidirScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("-42 Hyx", "HyxScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("46 Infernis", "InfernisScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("84 Junic", "JunicScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("234 Motra", "MotraScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("134 Oldred", "OldredScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("132 Trite", "TriteScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("67 Utril", "UtrilScene"),
				new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true)
			},
			{
				("135 Duckstroid-14", "Level135Duckstroid14"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("240 Alcatras", "AlcatrasScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("98 Galetry", "MusemaScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("57 Asteroid-13", "Asteroid13Scene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("44 Atlantica", "AtlanticaScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("288 Berunah", "BerunahScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("235 Calist", "CalistScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("842 Core", "CoreScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("537 Cubatres", "CubatresScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("164 Dreck", "KryteScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("555 Empra", "EmpraScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("End", "EndScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("154 Etern", "EternScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("29 Faith", "FaithScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("25 Fission-C", "FissionCScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("36 Gloom", "GloomScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("147 Gratar", "GratarScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("4 Thalasso", "HydreneScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("35 Lecaro", "LecaroScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("94 Polarus", "PolarusScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("648 Repress", "RepressScene"),
				new MaterialPropertiesValues("Ignore")
			},
			{
				("398 Roart", "RoartScene"),
				new MaterialPropertiesValues("Ignore")
			}
		};

		public static MaterialPropertiesValues GetDefaults((string, string) identifier, bool extend, bool hide, bool lowOpacity, bool ignore, string baseHex, string lineHex)
		{
			if (ignore)
			{
				return new MaterialPropertiesValues("Ignore");
			}
			if (extend || hide || lowOpacity)
			{
				bool extend2 = extend;
				bool lowOpacity2 = lowOpacity;
				return new MaterialPropertiesValues("Auto", !hide, lowOpacity2, extend2);
			}
			(string, string) tuple = identifier;
			switch (tuple.Item1)
			{
			case "72 Collateral":
			{
				string item = tuple.Item2;
				if (!(item == "CollateralScene"))
				{
					break;
				}
				return new MaterialPropertiesValues("Manual", show: true, lowOpacity: true, extend: false, 2f, "4D6A46", "4D6A46", 2.5f, 6f, -25f, 10f);
			}
			case "58 Hyve":
			{
				string item = tuple.Item2;
				if (!(item == "Asteroid14Scene"))
				{
					break;
				}
				goto IL_0e32;
			}
			case "48 Desolation":
			{
				string item = tuple.Item2;
				if (!(item == "DesolationScene"))
				{
					break;
				}
				goto IL_0e32;
			}
			case "354 Demetrica":
			{
				string item = tuple.Item2;
				if (!(item == "DemetricaScene"))
				{
					break;
				}
				return new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true, extend: true);
			}
			case "141 Filitrios":
			{
				string item = tuple.Item2;
				if (!(item == "FilitriosScene"))
				{
					break;
				}
				return new MaterialPropertiesValues("Ignore", show: true, lowOpacity: true);
			}
			case "76 Acidir":
			{
				string item = tuple.Item2;
				if (!(item == "AcidirScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "-42 Hyx":
			{
				string item = tuple.Item2;
				if (!(item == "HyxScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "46 Infernis":
			{
				string item = tuple.Item2;
				if (!(item == "InfernisScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "84 Junic":
			{
				string item = tuple.Item2;
				if (!(item == "JunicScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "234 Motra":
			{
				string item = tuple.Item2;
				if (!(item == "MotraScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "134 Oldred":
			{
				string item = tuple.Item2;
				if (!(item == "OldredScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "132 Trite":
			{
				string item = tuple.Item2;
				if (!(item == "TriteScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "67 Utril":
			{
				string item = tuple.Item2;
				if (!(item == "UtrilScene"))
				{
					break;
				}
				goto IL_0ee3;
			}
			case "115 Wither":
			{
				string item = tuple.Item2;
				if (!(item == "WitherScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "135 Duckstroid-14":
			{
				string item = tuple.Item2;
				if (!(item == "Level135Duckstroid14"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "240 Alcatras":
			{
				string item = tuple.Item2;
				if (!(item == "AlcatrasScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "98 Galetry":
			{
				string item = tuple.Item2;
				if (!(item == "MusemaScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "57 Asteroid-13":
			{
				string item = tuple.Item2;
				if (!(item == "Asteroid13Scene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "44 Atlantica":
			{
				string item = tuple.Item2;
				if (!(item == "AtlanticaScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "288 Berunah":
			{
				string item = tuple.Item2;
				if (!(item == "BerunahScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "235 Calist":
			{
				string item = tuple.Item2;
				if (!(item == "CalistScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "842 Core":
			{
				string item = tuple.Item2;
				if (!(item == "CoreScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "42 Cosmocos":
			{
				string item = tuple.Item2;
				if (!(item == "CosmocosScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "537 Cubatres":
			{
				string item = tuple.Item2;
				if (!(item == "CubatresScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "164 Dreck":
			{
				string item = tuple.Item2;
				if (!(item == "KryteScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "555 Empra":
			{
				string item = tuple.Item2;
				if (!(item == "EmpraScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "End":
			{
				string item = tuple.Item2;
				if (!(item == "EndScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "154 Etern":
			{
				string item = tuple.Item2;
				if (!(item == "EternScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "29 Faith":
			{
				string item = tuple.Item2;
				if (!(item == "FaithScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "25 Fission-C":
			{
				string item = tuple.Item2;
				if (!(item == "FissionCScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "36 Gloom":
			{
				string item = tuple.Item2;
				if (!(item == "GloomScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "147 Gratar":
			{
				string item = tuple.Item2;
				if (!(item == "GratarScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "4 Thalasso":
			{
				string item = tuple.Item2;
				if (!(item == "HydreneScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "35 Lecaro":
			{
				string item = tuple.Item2;
				if (!(item == "LecaroScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "94 Polarus":
			{
				string item = tuple.Item2;
				if (!(item == "PolarusScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "648 Repress":
			{
				string item = tuple.Item2;
				if (!(item == "RepressScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "398 Roart":
			{
				string item = tuple.Item2;
				if (!(item == "RoartScene"))
				{
					break;
				}
				goto IL_0f1e;
			}
			case "120 Corrosion":
			{
				string item = tuple.Item2;
				if (!(item == "ZenithScene"))
				{
					break;
				}
				return new MaterialPropertiesValues("Auto", show: true, lowOpacity: true, extend: true);
			}
			case "32-Rampart":
			{
				string item = tuple.Item2;
				if (!(item == "RampartScene"))
				{
					break;
				}
				goto IL_0f94;
			}
			case "89 Submersion":
			{
				string item = tuple.Item2;
				if (!(item == "SubmersionScene"))
				{
					break;
				}
				goto IL_0f94;
			}
			case "81 Icebound":
			{
				string item = tuple.Item2;
				if (!(item == "FrozenLakeScene"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "19 Hydro":
			{
				string item = tuple.Item2;
				if (!(item == "HydroScene"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "27-Calamitous":
			{
				string item = tuple.Item2;
				if (!(item == "CalamitousScene"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "33 Pinnacle":
			{
				string item = tuple.Item2;
				if (!(item == "PinnacleLevel"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "103-Precipice":
			{
				string item = tuple.Item2;
				if (!(item == "Precipice Scene"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "51-Verdance":
			{
				string item = tuple.Item2;
				if (!(item == "VerdanceScene"))
				{
					break;
				}
				goto IL_0fcf;
			}
			case "28 Celest":
			{
				string item = tuple.Item2;
				if (!(item == "CelestPlanetScene"))
				{
					break;
				}
				goto IL_100a;
			}
			case "12-Boreal":
				{
					string item = tuple.Item2;
					if (!(item == "BorealScene"))
					{
						break;
					}
					goto IL_100a;
				}
				IL_100a:
				return new MaterialPropertiesValues("Auto", show: true, lowOpacity: false, extend: false, 1f);
				IL_0fcf:
				return new MaterialPropertiesValues("Auto", show: true, lowOpacity: false, extend: true);
				IL_0f94:
				return new MaterialPropertiesValues("Auto", show: true, lowOpacity: true);
				IL_0f1e:
				return new MaterialPropertiesValues("Ignore");
				IL_0ee3:
				return new MaterialPropertiesValues("Ignore", show: true, lowOpacity: false, extend: true);
				IL_0e32:
				return new MaterialPropertiesValues("Ignore", show: true, lowOpacity: false, extend: true, 1f);
			}
			if (baseHex != "N/A" || lineHex != "N/A")
			{
				return new MaterialPropertiesValues("Auto", show: true, lowOpacity: false, extend: false, 2f, (baseHex != "N/A") ? baseHex : "4D6A46", (lineHex != "N/A") ? lineHex : "4D6A46");
			}
			return new MaterialPropertiesValues();
		}

		public static void OnStartInitialize()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			moddedConfigs.Clear();
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				if ((int)((ExtendedContent)extendedLevel).ContentType > 0)
				{
					(string, string) tuple = (extendedLevel.SelectableLevel.PlanetName, extendedLevel.SelectableLevel.sceneName);
					bool extend = ((ExtendedContent)extendedLevel).ContentTags.Exists((ContentTag x) => x.contentTagName == "UniversalRadarExtendHeight");
					bool hide = ((ExtendedContent)extendedLevel).ContentTags.Exists((ContentTag x) => x.contentTagName == "UniversalRadarHideObjects");
					bool lowOpacity = ((ExtendedContent)extendedLevel).ContentTags.Exists((ContentTag x) => x.contentTagName == "UniversalRadarLowOpacityObjects");
					bool ignore = ((ExtendedContent)extendedLevel).ContentTags.Exists((ContentTag x) => x.contentTagName == "UniversalRadarIgnore");
					string lineHex = "N/A";
					string baseHex = "N/A";
					ContentTag val = ((ExtendedContent)extendedLevel).ContentTags.Find((ContentTag x) => x.contentTagName == "UniversalRadarLineColor");
					ContentTag val2 = ((ExtendedContent)extendedLevel).ContentTags.Find((ContentTag x) => x.contentTagName == "UniversalRadarBaseColor");
					if ((Object)(object)val != (Object)null)
					{
						lineHex = RadarContourPatches.HexFromColour(val.contentTagColor);
					}
					if ((Object)(object)val2 != (Object)null)
					{
						baseHex = RadarContourPatches.HexFromColour(val2.contentTagColor);
					}
					MaterialPropertiesValues defaults = GetDefaults(tuple, extend, hide, lowOpacity, ignore, baseHex, lineHex);
					moddedConfigs.Add((new MaterialPropertiesConfig(extendedLevel.SelectableLevel.PlanetName, "LLL", defaults), tuple));
				}
			}
			foreach (var moddedConfig in moddedConfigs)
			{
				if (ConfigPatch.OlderConfigVersion(new int[3] { 1, 1, 0 }) && changeToIgnore1.TryGetValue(moddedConfig.Item2, out MaterialPropertiesValues value))
				{
					moddedConfig.Item1.SetValues(moddedConfig.Item2.Item1, "LLL", value);
				}
				if (moddedConfig.Item1.mode.Value == "Manual" || (moddedConfig.Item1.mode.Value == "Auto" && (moddedConfig.Item1.extendHeight.Value || moddedConfig.Item1.showObjects.Value || moddedConfig.Item1.lowObjectOpacity.Value || moddedConfig.Item1.baseColourHex.Value != "4D6A46" || moddedConfig.Item1.opacityMult.Value != 2f)))
				{
					if (!RadarContourPatches.contourDataDict.ContainsKey(moddedConfig.Item2))
					{
						RadarContourPatches.contourDataDict.Add(moddedConfig.Item2, new MaterialProperties(moddedConfig.Item1));
					}
				}
				else if (moddedConfig.Item1.mode.Value == "Ignore" && !ConfigPatch.moonBlacklist.Contains(moddedConfig.Item2))
				{
					ConfigPatch.moonBlacklist.Add(moddedConfig.Item2);
				}
			}
		}

		public static void SceneNamePatch()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				if ((int)((ExtendedContent)extendedLevel).ContentType == 0 && ConfigPatch.vanillaSceneDict.ContainsKey(extendedLevel.SelectableLevel.PlanetName))
				{
					ConfigPatch.vanillaSceneDict[extendedLevel.SelectableLevel.PlanetName] = extendedLevel.SelectableLevel.sceneName;
				}
			}
		}
	}
	[HarmonyPatch]
	public class RadarContourPatches
	{
		public static Material contourMaterial = UniversalRadar.contourMaterial;

		public static Material radarFillMat0 = UniversalRadar.radarFillMat0;

		public static Material radarFillMat1 = UniversalRadar.radarFillMat1;

		public static Material radarWaterMat = UniversalRadar.radarWaterMat;

		public static List<GameObject> terrainObjects = new List<GameObject>();

		public static List<GameObject> mapGeometry = new List<GameObject>();

		public static List<GameObject> unityMeshTerrains = new List<GameObject>();

		public static List<GameObject> waterObjects = new List<GameObject>();

		public static Dictionary<(string, string), MaterialProperties> contourDataDict = new Dictionary<(string, string), MaterialProperties>();

		public static Dictionary<(string, string), List<string>> terrainMemoryDict = new Dictionary<(string, string), List<string>>();

		public static Dictionary<(string, string), List<string>> geometryMemoryDict = new Dictionary<(string, string), List<string>>();

		public static Dictionary<(string, string), List<MeshTerrainInfo>> meshTerrainDict = new Dictionary<(string, string), List<MeshTerrainInfo>>();

		public static float terrainMax;

		public static float terrainMin;

		private static float stroke = UniversalRadar.AutoLineWidth.Value;

		private static float lineSpace = UniversalRadar.AutoSpacing.Value;

		private static float maxOpacity = UniversalRadar.AutoOpacity.Value;

		public static readonly Vector4 defaultGreen = new Vector4(0.3019608f, 0.4156863f, 0.2745098f, 1f);

		public static readonly Vector4 radarFillGreen = new Vector4(33f / 85f, 1f, 0.3529412f, 1f);

		public static readonly Vector3 verticalOffset = new Vector3(0f, 0.05f, 0f);

		public static readonly Vector3 shipPos = new Vector3(3f, 0f, -15f);

		public static bool loaded = false;

		private static readonly HashSet<Type> keepTypes = new HashSet<Type>
		{
			typeof(Transform),
			typeof(MeshFilter),
			typeof(MeshRenderer)
		};

		private static readonly HashSet<Type> blacklistTypes = new HashSet<Type>
		{
			typeof(NetworkObject),
			typeof(Animator),
			typeof(SkinnedMeshRenderer)
		};

		private static readonly HashSet<Type> disableTypes = new HashSet<Type>
		{
			typeof(AudioSource),
			typeof(Light),
			typeof(HDAdditionalLightData)
		};

		private static readonly bool showFoliage = UniversalRadar.ShowFoliage.Value;

		public static bool disableMoon = false;

		public static bool fullHeight;

		[HarmonyPatch(typeof(StartOfRound), "SceneManager_OnLoadComplete1")]
		[HarmonyPrefix]
		private static void OnLoadLevel(StartOfRound __instance, string sceneName)
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			if (loaded || !(sceneName == __instance.currentLevel.sceneName))
			{
				return;
			}
			disableMoon = false;
			(string, string) tuple = (__instance.currentLevel.PlanetName, sceneName);
			disableMoon = ConfigPatch.moonBlacklist.Contains(tuple);
			ClearRadarAddWater(disableMoon);
			loaded = true;
			if (disableMoon)
			{
				return;
			}
			RadarExtraPatches.AddNewRadarSprites(tuple);
			if ((Object)(object)contourMaterial == (Object)null || (Object)(object)radarFillMat0 == (Object)null || (Object)(object)radarFillMat1 == (Object)null || (Object)(object)radarWaterMat == (Object)null)
			{
				contourMaterial = (Material)UniversalRadar.URAssets.LoadAsset("ContourMat");
				radarFillMat0 = (Material)UniversalRadar.URAssets.LoadAsset("RadarGreen0");
				radarFillMat1 = (Material)UniversalRadar.URAssets.LoadAsset("RadarGreen1");
				radarWaterMat = (Material)UniversalRadar.URAssets.LoadAsset("RadarBlue");
				radarWaterMat.renderQueue = 1000;
			}
			Bounds navMeshBounds = default(Bounds);
			((Bounds)(ref navMeshBounds))..ctor(Vector3.zero, Vector3.zero);
			if (!terrainMemoryDict.ContainsKey(tuple) && !meshTerrainDict.ContainsKey(tuple))
			{
				Vector3[] vertices = NavMesh.CalculateTriangulation().vertices;
				foreach (Vector3 val in vertices)
				{
					((Bounds)(ref navMeshBounds)).Encapsulate(val);
				}
				UniversalRadar.Logger.LogDebug((object)$"NAV MAX: {((Bounds)(ref navMeshBounds)).max.y}, NAV MIN: {((Bounds)(ref navMeshBounds)).min.y}");
				if (((Bounds)(ref navMeshBounds)).size == Vector3.zero)
				{
					UniversalRadar.Logger.LogError((object)"Unable to find nav mesh!");
					return;
				}
			}
			if (contourDataDict.TryGetValue(tuple, out MaterialProperties value) && !value.auto)
			{
				FetchTerrainObjects(hasMatInfo: true, tuple, navMeshBounds);
				if (value.showObjects)
				{
					FetchMapGeometry(tuple, navMeshBounds);
				}
				else
				{
					mapGeometry.Clear();
				}
				if (terrainObjects.Count == 0 && unityMeshTerrains.Count == 0 && mapGeometry.Count == 0 && waterObjects.Count == 0)
				{
					return;
				}
				value.LogAllProperties();
				value.SetProperties(contourMaterial);
				SetupMeshes(value.lowObjectOpacity);
			}
			else
			{
				bool flag = true;
				bool flag2 = false;
				fullHeight = false;
				float multiplier = 2f;
				Vector4 baseColour = defaultGreen;
				if (value != null && value.auto)
				{
					flag = value.showObjects;
					flag2 = value.lowObjectOpacity;
					fullHeight = value.extendHeight;
					multiplier = value.opacityMult;
					baseColour = value.baseColour;
				}
				if (UniversalRadar.HideRadarObjects.Value)
				{
					flag = false;
				}
				FetchTerrainObjects(hasMatInfo: false, tuple, navMeshBounds);
				if (flag)
				{
					FetchMapGeometry(tuple, navMeshBounds);
				}
				else
				{
					mapGeometry.Clear();
				}
				if (terrainObjects.Count == 0 && unityMeshTerrains.Count == 0 && mapGeometry.Count == 0 && waterObjects.Count == 0)
				{
					return;
				}
				float min = ((terrainMin < 0f) ? (terrainMin / 2f) : 0f);
				float max = (fullHeight ? terrainMax : ((terrainMax > 100f) ? (terrainMax / (float)(Mathf.RoundToInt(terrainMax / 100f) + 2)) : (terrainMax / 2f)));
				MaterialProperties materialProperties = new MaterialProperties(flag, flag2, lineSpace, stroke, min, max, maxOpacity, multiplier, baseColour, baseColour);
				materialProperties.LogAllProperties();
				if (contourDataDict.ContainsKey(tuple))
				{
					contourDataDict.Remove(tuple);
				}
				contourDataDict.Add(tuple, materialProperties);
				materialProperties.SetProperties(contourMaterial);
				SetupMeshes(flag2);
			}
			GameObject val2 = GameObject.FindGameObjectWithTag("TerrainContourMap");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = GameObject.Find("Systems/Radar/RadarSquare");
			}
			if ((Object)(object)val2 != (Object)null && Object.op_Implicit((Object)(object)val2.GetComponent<SpriteRenderer>()))
			{
				UniversalRadar.Logger.LogDebug((object)"Disabling existing contour map!");
				((Renderer)val2.GetComponent<SpriteRenderer>()).enabled = false;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")]
		[HarmonyPostfix]
		public static void ResetLoadedFlag()
		{
			loaded = false;
		}

		public static void FetchTerrainObjects(bool hasMatInfo, (string, string) identifier, Bounds navMeshBounds)
		{
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Expected O, but got Unknown
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			terrainObjects.Clear();
			unityMeshTerrains.Clear();
			List<Terrain> list = (from x in Object.FindObjectsOfType<Terrain>()
				where ((Component)x).gameObject.activeInHierarchy && ((Behaviour)x).enabled && x.drawHeightmap && Object.op_Implicit((Object)(object)((Component)x).GetComponent<TerrainCollider>()) && ((Collider)((Component)x).GetComponent<TerrainCollider>()).enabled
				select x).ToList();
			if (terrainMemoryDict.TryGetValue(identifier, out List<string> value))
			{
				for (int i = 0; i < value.Count; i++)
				{
					GameObject val = GameObject.Find(value[i]);
					if ((Object)(object)val != (Object)null && !terrainObjects.Contains(val))
					{
						terrainObjects.Add(val);
					}
				}
			}
			else
			{
				MeshCollider[] array = Object.FindObjectsOfType<MeshCollider>();
				List<MeshRenderer> terrainRenderers = new List<MeshRenderer>();
				MyCollections.ForEach<MeshCollider>((IEnumerable<MeshCollider>)array, (Action<MeshCollider>)delegate(MeshCollider x)
				{
					CollectRenderers((Collider)(object)x, terrainRenderers, 90000f, terrain: true, 1);
				});
				if (terrainRenderers.Count == 0 && list.Count == 0)
				{
					UniversalRadar.Logger.LogWarning((object)"Unable to find any terrain objects on this moon!");
					return;
				}
				UniversalRadar.Logger.LogDebug((object)$"First time load: Fetched {terrainRenderers.Count} terrain renderers");
				terrainMax = -10000f;
				terrainMin = 10000f;
				List<int> list2 = NavMeshBest(navMeshBounds, terrainRenderers.ConvertAll((MeshRenderer x) => ((Renderer)x).bounds).ToArray(), list.Count <= 0, 10);
				UniversalRadar.Logger.LogDebug((object)$"{list2.Count} valid mesh terrains");
				List<string> list3 = new List<string>();
				for (int j = 0; j < terrainRenderers.Count; j++)
				{
					if (list2.Contains(j) && !terrainObjects.Contains(((Component)terrainRenderers[j]).gameObject))
					{
						terrainObjects.Add(((Component)terrainRenderers[j]).gameObject);
						list3.Add(GetObjectPath(((Component)terrainRenderers[j]).gameObject));
						Bounds bounds = ((Renderer)terrainRenderers[j]).bounds;
						terrainMax = Mathf.Max(((Bounds)(ref bounds)).max.y, terrainMax);
						bounds = ((Renderer)terrainRenderers[j]).bounds;
						terrainMin = Mathf.Min(((Bounds)(ref bounds)).min.y, terrainMin);
					}
				}
				if (list3.Count > 0)
				{
					UniversalRadar.Logger.LogDebug((object)("Adding terrain paths to dictionary under identifier (" + identifier.Item1 + ", " + identifier.Item2 + ")"));
					terrainMemoryDict.Add(identifier, list3);
				}
			}
			if (UniversalRadar.UseTerraMesh.Value && list.Count > 0)
			{
				if (meshTerrainDict.TryGetValue(identifier, out List<MeshTerrainInfo> value2))
				{
					for (int k = 0; k < value2.Count; k++)
					{
						GameObject val2 = new GameObject($"NewMeshTerrain{k}");
						if (!MyString.IsNullOrEmpty(value2[k].parentPath))
						{
							GameObject val3 = GameObject.Find(value2[k].parentPath);
							if ((Object)(object)val3 != (Object)null)
							{
								val2.transform.SetParent(val3.transform);
							}
						}
						MeshFilter val4 = val2.AddComponent<MeshFilter>();
						val4.sharedMesh = value2[k].mesh;
						MeshRenderer val5 = val2.AddComponent<MeshRenderer>();
						((Renderer)val5).material = contourMaterial;
						val2.transform.localPosition = value2[k].position;
						val2.transform.localRotation = value2[k].rotation;
						val2.transform.localScale = value2[k].scale;
						unityMeshTerrains.Add(val2);
					}
				}
				else
				{
					MeshifyTerrains(list, !hasMatInfo, identifier, navMeshBounds, terrainObjects.Count <= 0);
				}
			}
			if (terrainMin > terrainMax)
			{
				terrainMax = ((Bounds)(ref navMeshBounds)).max.y;
				terrainMin = ((Bounds)(ref navMeshBounds)).min.y;
			}
			else
			{
				terrainMax = Mathf.Min(((Bounds)(ref navMeshBounds)).max.y, terrainMax);
				terrainMin = Mathf.Max(((Bounds)(ref navMeshBounds)).min.y, terrainMin);
			}
			UniversalRadar.Logger.LogDebug((object)$"Terrain max: {terrainMax}, terrain min: {terrainMin} ({((Bounds)(ref navMeshBounds)).max.y}, {((Bounds)(ref navMeshBounds)).min.y})");
		}

		public static void FetchMapGeometry((string, string) identifier, Bounds navMeshBounds)
		{
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			mapGeometry.Clear();
			if (geometryMemoryDict.TryGetValue(identifier, out List<string> value))
			{
				for (int i = 0; i < value.Count; i++)
				{
					GameObject val = GameObject.Find(value[i]);
					if ((Object)(object)val != (Object)null && !mapGeometry.Contains(val) && Object.op_Implicit((Object)(object)val.GetComponent<MeshRenderer>()))
					{
						mapGeometry.Add(val);
					}
				}
				return;
			}
			Collider[] array = Object.FindObjectsOfType<Collider>();
			List<MeshRenderer> geometryRenderers = new List<MeshRenderer>();
			MyCollections.ForEach<Collider>((IEnumerable<Collider>)array, (Action<Collider>)delegate(Collider x)
			{
				CollectRenderers(x, geometryRenderers, UniversalRadar.RadarObjectSize.Value, terrain: false, 2);
			});
			UniversalRadar.Logger.LogDebug((object)$"First time load: Fetched {geometryRenderers.Count} object renderers");
			List<string> list = new List<string>();
			for (int j = 0; j < geometryRenderers.Count; j++)
			{
				if ((Object)(object)((Component)geometryRenderers[j]).gameObject != (Object)null && !mapGeometry.Contains(((Component)geometryRenderers[j]).gameObject) && !terrainObjects.Contains(((Component)geometryRenderers[j]).gameObject) && !unityMeshTerrains.Contains(((Component)geometryRenderers[j]).gameObject) && WithinNavMesh(navMeshBounds, ((Renderer)geometryRenderers[j]).bounds))
				{
					UniversalRadar.Logger.LogDebug((object)$"Adding map object {GetObjectPath(((Component)geometryRenderers[j]).gameObject)}, {Object.op_Implicit((Object)(object)((Component)geometryRenderers[j]).gameObject.GetComponent<MeshRenderer>())}");
					mapGeometry.Add(((Component)geometryRenderers[j]).gameObject);
					list.Add(GetObjectPath(((Component)geometryRenderers[j]).gameObject));
				}
			}
			if (list.Count > 0)
			{
				UniversalRadar.Logger.LogDebug((object)("Adding object paths to dictionary under identifier (" + identifier.Item1 + ", " + identifier.Item2 + ")"));
				geometryMemoryDict.Add(identifier, list);
			}
		}

		public static void ClearRadarAddWater(bool skipWater)
		{
			bool findWater = UniversalRadar.RadarWater.Value;
			waterObjects.Clear();
			MeshRenderer[] array = (from x in Object.FindObjectsOfType<MeshRenderer>()
				where ((Object)((Component)x).gameObject).name.EndsWith("_URRadarFill", StringComparison.Ordinal) || ((Object)((Component)x).gameObject).name.EndsWith("_URContourMesh", StringComparison.Ordinal) || (!skipWater && findWater && (Object)(object)((Renderer)x).sharedMaterial != (Object)null && ((Object)((Renderer)x).sharedMaterial).name.ToLower().Contains("water", StringComparison.Ordinal))
				select x).ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)((Component)array[i]).gameObject).name.EndsWith("_URRadarFill", StringComparison.Ordinal) || ((Object)((Component)array[i]).gameObject).name.EndsWith("_URContourMesh", StringComparison.Ordinal))
				{
					Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject);
				}
				else if ((Object)(object)((Renderer)array[i]).sharedMaterial != (Object)null && ((Object)((Renderer)array[i]).sharedMaterial).name.ToLower().Contains("water", StringComparison.Ordinal) && (Object)(object)((Renderer)array[i]).sharedMaterial.shader != (Object)null && ((Object)((Renderer)array[i]).sharedMaterial.shader).name.ToLower().Contains("water", StringComparison.Ordinal))
				{
					waterObjects.Add(((Component)array[i]).gameObject);
				}
			}
		}

		public static void MeshifyTerrains(List<Terrain> terrains, bool findBounds, (string, string) identifier, Bounds navMeshBounds, bool findAnyTerrain)
		{
			//IL_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("HDRP/Lit");
			Shader val2 = val;
			TerraMeshConfig val3 = new TerraMeshConfig((Bounds?)null, false, true, true, 5f, true, 1, false, false, 0u, 1, 32, 3f, -1, true, true, false, false, false, false, 1023, val2);
			List<MeshTerrainInfo> list = new List<MeshTerrainInfo>();
			List<int> list2 = NavMeshBest(navMeshBounds, terrains.ConvertAll((Terrain x) => ((Collider)((Component)x).GetComponent<TerrainCollider>()).bounds).ToArray(), findAnyTerrain, 3);
			UniversalRadar.Logger.LogDebug((object)$"{list2.Count} valid unity terrains");
			for (int i = 0; i < terrains.Count; i++)
			{
				if (!list2.Contains(i) || (Object)(object)terrains[i] == (Object)null || (Object)(object)terrains[i].terrainData == (Object)null)
				{
					continue;
				}
				GameObject val4 = TerraMeshExtensions.Meshify(terrains[i], val3);
				if ((Object)(object)val4 != (Object)null)
				{
					MeshRenderer component = val4.GetComponent<MeshRenderer>();
					if ((Object)(object)component != (Object)null && !unityMeshTerrains.Contains(val4))
					{
						if (findBounds)
						{
							Bounds bounds = ((Renderer)component).bounds;
							terrainMax = Mathf.Max(((Bounds)(ref bounds)).max.y, terrainMax);
							bounds = ((Renderer)component).bounds;
							terrainMin = Mathf.Min(((Bounds)(ref bounds)).min.y, terrainMin);
						}
						unityMeshTerrains.Add(val4);
						list.Add(new MeshTerrainInfo(val4));
					}
					else
					{
						val4.SetActive(false);
					}
				}
				((Component)terrains[i]).gameObject.SetActive(true);
				((Behaviour)terrains[i]).enabled = true;
				terrains[i].drawHeightmap = true;
				((Collider)((Component)terrains[i]).GetComponent<TerrainCollider>()).enabled = true;
			}
			if (list.Count > 0)
			{
				meshTerrainDict.Add(identifier, list);
			}
		}

		public static void CollectRenderers(Collider collider, List<MeshRenderer> renderers, float minSize, bool terrain, int searchDepth)
		{
			if (IsValidMesh(collider, minSize, terrain) && !renderers.Contains(((Component)collider).GetComponent<MeshRenderer>()))
			{
				renderers.Add(((Component)collider).GetComponent<MeshRenderer>());
			}
			else if (searchDepth >= 1 && IsValidMesh(collider, minSize, terrain, 1) && !renderers.Contains(((Component)((Component)collider).transform.parent).GetComponent<MeshRenderer>()))
			{
				renderers.Add(((Component)((Component)collider).transform.parent).GetComponent<MeshRenderer>());
			}
			else if (searchDepth >= 2 && IsValidMesh(collider, minSize, terrain, 2) && !renderers.Contains(((Component)((Component)collider).transform.parent.parent).GetComponent<MeshRenderer>()))
			{
				renderers.Add(((Component)((Component)collider).transform.parent.parent).GetComponent<MeshRenderer>());
			}
		}

		public static bool IsValidMesh(Collider collider, float minSize, bool terrain = true, int searchParents = 0)
		{
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)collider).gameObject;
			bool flag = false;
			Transform val = gameObject.transform;
			for (int i = 0; i <= searchParents; i++)
			{
				if (Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<MeshRenderer>()) && i == searchParents)
				{
					flag = true;
					break;
				}
				if ((Object)(object)val.parent != (Object)null)
				{
					val = ((Component)val).transform.parent;
					continue;
				}
				break;
			}
			if (!flag)
			{
				return false;
			}
			GameObject gameObject2 = ((Component)val).gameObject;
			MeshRenderer component = gameObject2.GetComponent<MeshRenderer>();
			if (!((Renderer)component).enabled)
			{
				return false;
			}
			if (collider.isTrigger)
			{
				return false;
			}
			if (gameObject2.layer != 8 && (gameObject2.layer != 10 || !showFoliage) && gameObject2.layer != 0 && (gameObject2.layer != 25 || !showFoliage) && (gameObject2.layer != 11 || terrain))
			{
				return false;
			}
			if (waterObjects.Contains(gameObject2))
			{
				return false;
			}
			if (((Object)gameObject2).name.Contains("_URContourMesh", StringComparison.Ordinal) || ((Object)gameObject2).name.Contains("_URRadarFill", StringComparison.Ordinal))
			{
				return false;
			}
			if (((Object)gameObject2).name.ToLower().Contains("scannode", StringComparison.Ordinal) || Object.op_Implicit((Object)(object)gameObject2.GetComponent<ScanNodeProperties>()))
			{
				return false;
			}
			if (GetObjectPath(gameObject).Contains("Environment/HangarShip/", StringComparison.Ordinal))
			{
				return false;
			}
			if (GetObjectPath(gameObject).ToLower().Contains("outofbounds", StringComparison.Ordinal))
			{
				return false;
			}
			if (!terrain && (((Object)gameObject2).name.Contains("LOD", StringComparison.Ordinal) || ((Object)gameObject2).name.ToLower().Contains("lowdetail", StringComparison.Ordinal)) && (Object)(object)gameObject2.transform.parent != (Object)null && Object.op_Implicit((Object)(object)((Component)gameObject2.transform.parent).GetComponent<LODGroup>()) && Object.op_Implicit((Object)(object)((Component)gameObject2.transform.parent).GetComponent<MeshRenderer>()))
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)gameObject2.GetComponent<MeshFilter>()))
			{
				return false;
			}
			if (terrain)
			{
				if (!Object.op_Implicit((Object)(object)gameObject2.GetComponent<MeshFilter>()) || !((Object)(object)gameObject2.GetComponent<MeshFilter>().sharedMesh != (Object)null) || !((Object)gameObject2.GetComponent<MeshFilter>().sharedMesh).name.ToLower().Contains("cube", StringComparison.Ordinal))
				{
					MeshCollider val2 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null);
					if (val2 == null || !((Object)(object)val2.sharedMesh != (Object)null) || !((Object)val2.sharedMesh).name.ToLower().Contains("cube", StringComparison.Ordinal))
					{
						goto IL_0323;
					}
				}
				return false;
			}
			goto IL_0323;
			IL_0323:
			if (gameObject2.GetComponentsInChildren<Component>(true).Any((Component x) => (Object)(object)x != (Object)null && blacklistTypes.Contains(((object)x).GetType())))
			{
				return false;
			}
			if (!terrain && (GetObjectPath(gameObject).ToLower().Contains("catwalk", StringComparison.Ordinal) || GetObjectPath(gameObject).ToLower().Contains("bridge", StringComparison.Ordinal) || ((Object)gameObject2).name.ToLower().Contains("floor", StringComparison.Ordinal)))
			{
				return true;
			}
			if (terrain && (((Object)gameObject).name.ToLower().Contains("terrain", StringComparison.Ordinal) || ((Object)gameObject2).name.ToLower().Contains("terrain", StringComparison.Ordinal)))
			{
				return true;
			}
			Bounds bounds = collider.bounds;
			float x2 = ((Bounds)(ref bounds)).size.x;
			bounds = collider.bounds;
			if (!(x2 * ((Bounds)(ref bounds)).size.z > minSize))
			{
				bounds = ((Renderer)component).bounds;
				float x3 = ((Bounds)(ref bounds)).size.x;
				bounds = ((Renderer)component).bounds;
				if (!(x3 * ((Bounds)(ref bounds)).size.z > minSize))
				{
					return false;
				}
			}
			return true;
		}

		public static bool WithinNavMesh(Bounds navBounds, Bounds objectBounds)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0077: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			if (((Bounds)(ref navBounds)).max.x > ((Bounds)(ref objectBounds)).center.x && ((Bounds)(ref navBounds)).min.x < ((Bounds)(ref objectBounds)).center.x && ((Bounds)(ref navBounds)).max.z > ((Bounds)(ref objectBounds)).center.z && ((Bounds)(ref navBounds)).min.z < ((Bounds)(ref objectBounds)).center.z)
			{
				return true;
			}
			if (((Bounds)(ref navBounds)).Intersects(objectBounds))
			{
				return true;
			}
			return false;
		}

		public static List<int> NavMeshBest(Bounds navBounds, Bounds[] boundsObjects, bool useBest, int sizeLimit)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			(int, float) value = (0, 1000000f);
			List<int> list = new List<int>();
			Dictionary<int, (int, float)> dictionary = new Dictionary<int, (int, float)>();
			for (int i = 0; i < boundsObjects.Length; i++)
			{
				Bounds val = boundsObjects[i];
				bool flag = true;
				if (!((Bounds)(ref navBounds)).Intersects(val))
				{
					flag = false;
					float num = Vector3.Distance(shipPos, ((Bounds)(ref val)).center);
					if (value.Item1 == 0 && num < value.Item2)
					{
						value = (0, num);
						dictionary.Add(i, value);
					}
					continue;
				}
				if ((((Bounds)(ref val)).max.x > ((Bounds)(ref navBounds)).max.x || ((Bounds)(ref val)).min.x < ((Bounds)(ref navBounds)).min.x) && ((Bounds)(ref val)).size.x - ((Bounds)(ref navBounds)).size.x > ((Bounds)(ref navBounds)).size.x * 15f)
				{
					flag = false;
					float num2 = ((Bounds)(ref val)).size.x - ((Bounds)(ref navBounds)).size.x;
					if (value.Item1 == 0 || num2 < value.Item2)
					{
						value = (1, num2);
					}
				}
				if ((((Bounds)(ref val)).max.z > ((Bounds)(ref navBounds)).max.z || ((Bounds)(ref val)).min.z < ((Bounds)(ref navBounds)).min.z) && ((Bounds)(ref val)).size.z - ((Bounds)(ref navBounds)).size.z > ((Bounds)(ref navBounds)).size.z * 15f)
				{
					flag = false;
					float num3 = ((Bounds)(ref val)).size.z - ((Bounds)(ref navBounds)).size.z;
					if (value.Item1 == 0 || num3 < value.Item2)
					{
						value = (1, num3);
					}
				}
				if (flag)
				{
					dictionary.Add(i, (2, Vector3.Distance(shipPos, ((Bounds)(ref val)).center)));
				}
				else
				{
					dictionary.Add(i, value);
				}
			}
			dictionary = (from x in dictionary
				orderby x.Value.Item1 descending, x.Value.Item2
				select x).ToDictionary((KeyValuePair<int, (int, float)> x) => x.Key, (KeyValuePair<int, (int, float)> x) => (x.Value.Item1, x.Value.Item2));
			foreach (KeyValuePair<int, (int, float)> item in dictionary)
			{
				if (item.Value.Item1 == 2 && list.Count < sizeLimit)
				{
					list.Add(item.Key);
				}
			}
			if (useBest && list.Count <= 0 && dictionary.Count > 0)
			{
				list.Add(dictionary.First().Key);
			}
			return list;
		}

		public static void SetupMeshes(bool altMat)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < terrainObjects.Count; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(terrainObjects[i], terrainObjects[i].transform.position, terrainObjects[i].transform.rotation, terrainObjects[i].transform.parent);
				((Object)val).name = ((Object)terrainObjects[i]).name + "_URContourMesh";
				val.layer = 14;
				CleanComponents(val);
				Material[] materials = ((Renderer)val.GetComponent<MeshRenderer>()).materials;
				for (int j = 0; j < materials.Length; j++)
				{
					materials[j] = contourMaterial;
				}
				Transform transform = val.transform;
				transform.position += verticalOffset;
				((Renderer)val.GetComponent<MeshRenderer>()).materials = materials;
			}
			for (int k = 0; k < unityMeshTerrains.Count; k++)
			{
				((Object)unityMeshTerrains[k]).name = ((Object)unityMeshTerrains[k]).name + "_URContourMesh";
				unityMeshTerrains[k].layer = 14;
				Collider[] componentsInChildren = unityMeshTerrains[k].GetComponentsInChildren<Collider>();
				for (int l = 0; l < componentsInChildren.Length; l++)
				{
					componentsInChildren[l].enabled = false;
				}
				Material[] materials2 = ((Renderer)unityMeshTerrains[k].GetComponent<MeshRenderer>()).materials;
				for (int m = 0; m < materials2.Length; m++)
				{
					materials2[m] = contourMaterial;
				}
				Transform transform2 = unityMeshTerrains[k].transform;
				transform2.position += verticalOffset;
				((Renderer)unityMeshTerrains[k].GetComponent<MeshRenderer>()).materials = materials2;
			}
			for (int n = 0; n < mapGeometry.Count; n++)
			{
				if (!((Object)(object)mapGeometry[n] == (Object)null))
				{
					GameObject val2 = Object.Instantiate<GameObject>(mapGeometry[n], mapGeometry[n].transform.position, mapGeometry[n].transform.rotation, mapGeometry[n].transform.parent);
					((Object)val2).name = ((Object)mapGeometry[n]).name + "_URRadarFill";
					val2.layer = 14;
					CleanComponents(val2);
					MeshRenderer component = val2.GetComponent<MeshRenderer>();
					Material[] materials3 = ((Renderer)component).materials;
					Material val3 = (altMat ? radarFillMat1 : radarFillMat0);
					for (int nu