Decompiled source of 3DMap v0.5.4

3DMap.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using PadAssist;
using Player;
using SNetwork;
using SemanticVersioning;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("3DMap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+df0c5b38624247da40d44e16a8301e00557f5596")]
[assembly: AssemblyProduct("3DMap")]
[assembly: AssemblyTitle("3DMap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 MirrMods
{
	internal static class ModsTab
	{
		public static class Order
		{
			public const int CouchCoop = 800;

			public const int PadAssist = 700;

			public const int Map3D = 600;

			public const int LogTracker = 500;

			public const int Boosters = 400;
		}

		[HarmonyPatch(typeof(CM_PageSettings), "CreateKeyMappingSubMenu")]
		private static class AfterGamepad
		{
			[HarmonyPriority(0)]
			private static void Postfix(CM_PageSettings __instance, eSettingsSubMenuId subMenuId)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Invalid comparison between Unknown and I4
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				if ((int)subMenuId != 7)
				{
					return;
				}
				try
				{
					Make(__instance);
				}
				catch (Exception ex)
				{
					if (_errors++ < 5)
					{
						bool flag = default(bool);
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the tab not made: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						L.LogError(val);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Text), "UpdateAllTexts")]
		private static class Texts
		{
			private static void Postfix()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Expected O, but got Unknown
				try
				{
					Named();
				}
				catch (Exception ex)
				{
					if (_errors++ < 5)
					{
						bool flag = default(bool);
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the tab's name: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						L.LogError(val);
					}
				}
			}
		}

		public const string Name = "MIRR'S MODS";

		public const eSettingsSubMenuId Id = (eSettingsSubMenuId)98000;

		private const string Marker = "MirrModsTab";

		private const uint GameText = 68u;

		private static readonly Color Frame = new Color(56f / 85f, 7f / 85f, 0.16862746f, 1f);

		private static readonly Color Text = new Color(0.8235294f, 0.101960786f, 18f / 85f, 1f);

		private static readonly ManualLogSource L = Logger.CreateLogSource(typeof(ModsTab).Assembly.GetName().Name + " settings tab");

		private static CM_PageSettings _page;

		private static int _errors;

		private static void Make(CM_PageSettings page)
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			_page = page;
			if ((Object)(object)Window() != (Object)null)
			{
				return;
			}
			HashSet<IntPtr> hashSet = new HashSet<IntPtr>();
			foreach (CM_Item componentsInChild in ((Component)page).GetComponentsInChildren<CM_Item>(true))
			{
				hashSet.Add(((Il2CppObjectBase)componentsInChild).Pointer);
			}
			page.CreateSubmenu(68u, (eSettingsSubMenuId)98000, new List<iSettingsFieldData>(), true, false);
			List<CM_ScrollWindow> allSettingsWindows = page.m_allSettingsWindows;
			CM_ScrollWindow val = ((allSettingsWindows != null && allSettingsWindows.Count > 0) ? allSettingsWindows[allSettingsWindows.Count - 1] : null);
			CM_Item val2 = null;
			foreach (CM_Item componentsInChild2 in ((Component)page).GetComponentsInChildren<CM_Item>(true))
			{
				if (!hashSet.Contains(((Il2CppObjectBase)componentsInChild2).Pointer) && !((Object)(object)((Il2CppObjectBase)componentsInChild2).TryCast<CM_ScrollWindow>() != (Object)null) && (!((Object)(object)val != (Object)null) || !((Component)componentsInChild2).transform.IsChildOf(((Component)val).transform)))
				{
					val2 = componentsInChild2;
					break;
				}
			}
			bool flag = default(bool);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(49, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("MIRR'S MODS");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": the game's new tab not found (window ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>((Object)(object)val != (Object)null);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", button ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>((Object)(object)val2 != (Object)null);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
				}
				L.LogError(val3);
			}
			else
			{
				((Object)((Component)val).gameObject).name = "MirrModsTab";
				((Object)((Component)val2).gameObject).name = "MirrModsTab";
				Named();
				Tint(val2);
				BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("MIRR'S MODS");
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": the tab made in the settings after GAMEPAD MAPPING");
				}
				L.LogInfo(val4);
			}
		}

		public static void Tint(CM_Item tab)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tab == (Object)null)
			{
				return;
			}
			try
			{
				foreach (TextMeshPro componentsInChild in ((Component)tab).GetComponentsInChildren<TextMeshPro>(true))
				{
					((Graphic)componentsInChild).color = As(Text, ((Graphic)componentsInChild).color);
				}
				foreach (SpriteRenderer componentsInChild2 in ((Component)tab).GetComponentsInChildren<SpriteRenderer>(true))
				{
					componentsInChild2.color = As(Frame, componentsInChild2.color);
				}
				if ((Object)(object)tab.m_hoverSprite != (Object)null)
				{
					tab.m_hoverSprite.color = As(Frame, tab.m_hoverSprite.color);
				}
				tab.m_spriteColorOrg = As(Frame, tab.m_spriteColorOrg);
				tab.m_spriteColorOut = As(Frame, tab.m_spriteColorOut);
				tab.m_spriteColorOver = As(Frame, tab.m_spriteColorOver);
				tab.m_customSpriteDefaultColor = As(Frame, tab.m_customSpriteDefaultColor);
				tab.m_customSpriteHoverColor = As(Frame, tab.m_customSpriteHoverColor);
				Each(tab.m_textColorOrg);
				Each(tab.m_textColorOut);
				Each(tab.m_textColorOver);
			}
			catch (Exception ex)
			{
				if (_errors++ < 5)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MIRR'S MODS");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": a tab not tinted: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					L.LogError(val);
				}
			}
		}

		private static Color As(Color tint, Color was)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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: Unknown result type (might be due to invalid IL or missing references)
			return new Color(tint.r, tint.g, tint.b, was.a);
		}

		private static void Each(Il2CppStructArray<Color> colours)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (colours != null)
			{
				for (int i = 0; i < ((Il2CppArrayBase<Color>)(object)colours).Length; i++)
				{
					((Il2CppArrayBase<Color>)(object)colours)[i] = As(Text, ((Il2CppArrayBase<Color>)(object)colours)[i]);
				}
			}
		}

		private static CM_ScrollWindow Window()
		{
			List<CM_ScrollWindow> val = (((Object)(object)_page != (Object)null && !((Il2CppObjectBase)_page).WasCollected) ? _page.m_allSettingsWindows : null);
			if (val == null)
			{
				return null;
			}
			for (int i = 0; i < val.Count; i++)
			{
				if ((Object)(object)val[i] != (Object)null && ((Object)((Component)val[i]).gameObject).name == "MirrModsTab")
				{
					return val[i];
				}
			}
			return null;
		}

		private static void Named()
		{
			CM_ScrollWindow val = Window();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			val.SetText("MIRR'S MODS");
			foreach (CM_Item componentsInChild in ((Component)_page).GetComponentsInChildren<CM_Item>(true))
			{
				if (((Object)((Component)componentsInChild).gameObject).name == "MirrModsTab" && (Object)(object)((Il2CppObjectBase)componentsInChild).TryCast<CM_ScrollWindow>() == (Object)null)
				{
					componentsInChild.SetText("MIRR'S MODS");
					break;
				}
			}
		}
	}
}
namespace Map3D
{
	internal static class AreaGrid
	{
		private struct Node
		{
			public float X;

			public float Y;

			public float Z;

			public int Area;
		}

		public const float Cell = 1f;

		private const float Reach = 2.5f;

		public const float Far = 7f;

		private const float Below = 0.05f;

		private static readonly Dictionary<long, List<Node>> Cells = new Dictionary<long, List<Node>>();

		private static int _course;

		private static int _node;

		private static float _dySum;

		private static int _dyCount;

		public static float FoundY;

		public static int Count { get; private set; }

		public static int CellCount => Cells.Count;

		public static void Clear()
		{
			Cells.Clear();
			_course = (_node = (Count = 0));
			_dySum = 0f;
			_dyCount = 0;
		}

		private static long Key(int cx, int cz)
		{
			return ((long)cx << 32) ^ (uint)cz;
		}

		public static bool Collect(int budget)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			List<AIG_CourseNode> s_allNodes = AIG_CourseNode.s_allNodes;
			if (s_allNodes == null)
			{
				return true;
			}
			int count = s_allNodes.Count;
			while (_course < count && budget > 0)
			{
				AIG_CourseNode val = s_allNodes[_course];
				List<AIG_INode> val2 = ((val != null && (Object)(object)val.m_area != (Object)null && val.m_nodeCluster != null) ? val.m_nodeCluster.m_nodes : null);
				if (val2 == null)
				{
					_course++;
					_node = 0;
					continue;
				}
				int area = LevelMesh.IndexFor(val.m_area);
				int count2 = val2.Count;
				while (_node < count2 && budget > 0)
				{
					AIG_INode val3 = val2[_node];
					if (val3 != null)
					{
						Vector3 position = val3.Position;
						long key = Key((int)MathF.Floor(position.x / 1f), (int)MathF.Floor(position.z / 1f));
						if (!Cells.TryGetValue(key, out var value))
						{
							value = (Cells[key] = new List<Node>(4));
						}
						value.Add(new Node
						{
							X = position.x,
							Y = position.y,
							Z = position.z,
							Area = area
						});
						Count++;
					}
					_node++;
					budget--;
				}
				if (_node >= count2)
				{
					_course++;
					_node = 0;
				}
			}
			return _course >= count;
		}

		public static int AreaAt(float x, float y, float z, bool count = true, float reach = 2.5f)
		{
			int num = (int)MathF.Floor(x / 1f);
			int num2 = (int)MathF.Floor(z / 1f);
			int num3 = (int)MathF.Ceiling(reach / 1f);
			float num4 = reach * reach;
			float num5 = 0f;
			int num6 = -1;
			for (int i = -num3; i <= num3; i++)
			{
				for (int j = -num3; j <= num3; j++)
				{
					if (!Cells.TryGetValue(Key(num + i, num2 + j), out var value))
					{
						continue;
					}
					foreach (Node item in value)
					{
						float num7 = item.X - x;
						float num8 = item.Z - z;
						float num9 = (item.Y - 0.05f - y) * 2f;
						float num10 = num7 * num7 + num8 * num8 + num9 * num9;
						if (!(num10 >= num4))
						{
							num4 = num10;
							num5 = item.Y - y;
							num6 = item.Area;
						}
					}
				}
			}
			if (num6 >= 0 && count)
			{
				_dySum += num5;
				_dyCount++;
			}
			if (num6 >= 0)
			{
				FoundY = y + num5 - 0.05f;
			}
			return num6;
		}

		public static int AreaNear(Vector3 p)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_003f: 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)
			for (int i = 0; i < 5; i++)
			{
				int num = AreaAt(p.x, p.y - (float)i * 0.6f, p.z, count: false);
				if (num >= 0)
				{
					return num;
				}
			}
			return AreaAt(p.x, p.y + 0.6f, p.z, count: false);
		}

		public static string Describe()
		{
			return $"{Count} nodes in {Cells.Count} cells, the nearest {((_dyCount > 0) ? (_dySum / (float)_dyCount) : 0f):0.00} m above the floor on average";
		}
	}
	internal static class Explored
	{
		public enum State
		{
			Explored,
			Next,
			Rest
		}

		private static readonly HashSet<int> Been = new HashSet<int>();

		private static readonly HashSet<int> NextTo = new HashSet<int>();

		private static float _lookAt;

		private static int _errors;

		public static int Count => Been.Count;

		public static State StateOf(int area)
		{
			if (!Been.Contains(area))
			{
				if (!NextTo.Contains(area))
				{
					return State.Rest;
				}
				return State.Next;
			}
			return State.Explored;
		}

		public static void Clear()
		{
			Been.Clear();
			NextTo.Clear();
		}

		public static void Update()
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _lookAt || !LevelMesh.Ready)
			{
				return;
			}
			_lookAt = unscaledTime + 0.25f;
			bool flag2 = default(bool);
			try
			{
				bool flag = false;
				List<PlayerAgent> playerAgentsInLevel = PlayerManager.PlayerAgentsInLevel;
				int num = 0;
				while (playerAgentsInLevel != null && num < playerAgentsInLevel.Count)
				{
					PlayerAgent val = playerAgentsInLevel[num];
					AIG_CourseNode val2 = (((Object)(object)val != (Object)null) ? ((Agent)val).CourseNode : null);
					int num2 = ((val2 != null) ? LevelMesh.IndexOf(val2.m_area) : (-1));
					if (num2 >= 0 && Been.Add(num2))
					{
						flag = true;
						NextTo.Remove(num2);
						AddNeighbours(val2);
						ManualLogSource l = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(45, 4, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("explored: ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(Name(val2));
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(val.PlayerName);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("); ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(Been.Count);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" areas explored, ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(NextTo.Count);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" next to them");
						}
						l.LogInfo(val3);
					}
					num++;
				}
				if (flag)
				{
					LevelMesh.Refresh();
				}
			}
			catch (Exception ex)
			{
				if (_errors++ < 5)
				{
					ManualLogSource l2 = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(10, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("explored: ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
					}
					l2.LogError(val4);
				}
			}
		}

		private static void AddNeighbours(AIG_CourseNode node)
		{
			List<AIG_CoursePortal> portals = node.m_portals;
			int num = 0;
			while (portals != null && num < portals.Count)
			{
				AIG_CoursePortal val = portals[num];
				if (val != null)
				{
					AIG_CourseNode[] array = (AIG_CourseNode[])(object)new AIG_CourseNode[2] { val.m_nodeA, val.m_nodeB };
					foreach (AIG_CourseNode val2 in array)
					{
						if (val2 != null && !(((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)node).Pointer))
						{
							int num2 = LevelMesh.IndexOf(val2.m_area);
							if (num2 >= 0 && !Been.Contains(num2))
							{
								NextTo.Add(num2);
							}
						}
					}
				}
				num++;
			}
		}

		public static string Name(AIG_CourseNode node)
		{
			if (node == null)
			{
				return "";
			}
			LG_Zone zone = node.m_zone;
			LG_Area area = node.m_area;
			string text = (((Object)(object)zone != (Object)null && zone.NavInfo != null) ? $"{zone.NavInfo.PrefixLong} {zone.NavInfo.Number}".Trim() : "");
			string text2 = (((Object)(object)area != (Object)null && area.m_navInfo != null) ? area.m_navInfo.Suffix : "");
			if (text2.Length <= 0)
			{
				return text.ToUpperInvariant();
			}
			return text.ToUpperInvariant() + "   AREA " + text2.ToUpperInvariant();
		}
	}
	internal static class LevelMesh
	{
		public enum Sub
		{
			FloorExplored,
			FloorNext,
			FloorRest,
			WallExplored,
			WallNext,
			WallRest,
			Count
		}

		private enum Step
		{
			Idle,
			Nodes,
			Floors,
			Walls,
			Make,
			Done
		}

		[HarmonyPatch(typeof(MapDetails), "OnLevelCleanup")]
		private static class Cleanup
		{
			private static void Postfix()
			{
				Drop("the level was cleaned up");
			}
		}

		[HarmonyPatch(typeof(MapDetails), "Extract")]
		private static class Taken
		{
			private static void Postfix(MapDetails __instance)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				try
				{
					Take(((Object)(object)__instance != (Object)null) ? __instance.m_navmesh : null);
				}
				catch (Exception ex)
				{
					if (_errors++ < 5)
					{
						ManualLogSource l = Plugin.L;
						bool flag = default(bool);
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(12, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("level mesh: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						l.LogError(val);
					}
					Drop("an error");
				}
			}
		}

		public const float WallHeight = 0.6f;

		public static readonly List<LG_Area> Areas = new List<LG_Area>();

		public static float MinY;

		public static float MaxY;

		private static Step _step;

		private static Vector3[] _v;

		private static int[] _t;

		private static int _at;

		private static readonly Dictionary<IntPtr, int> AreaIndex = new Dictionary<IntPtr, int>();

		private static readonly List<Vector3> Pos = new List<Vector3>();

		private static readonly List<int> PosArea = new List<int>();

		private static readonly List<int> Tris = new List<int>();

		private static List<int>[] _floorsOf;

		private static List<int>[] _wallsOf;

		private static float[] _midX;

		private static float[] _midY;

		private static float[] _midZ;

		private static int[] _midN;

		private static string[] _names;

		private static List<(int A, int B, int Tri)> _edges;

		private static int _pieces;

		private static int _piecesNone;

		private static int _wallPieces;

		private static int _wallsNone;

		private static int _wallsOpen;

		private static Dictionary<long, List<int>> _triCells;

		private const float TriCell = 4f;

		private static readonly Stopwatch Clock = new Stopwatch();

		private static readonly Stopwatch Spent = new Stopwatch();

		private static float _startedAt;

		private static int _errors;

		private static readonly Vector3[] Tri3 = (Vector3[])(object)new Vector3[3];

		private static readonly Vector3[] Col = (Vector3[])(object)new Vector3[12];

		private static readonly Vector3[] Piece = (Vector3[])(object)new Vector3[12];

		private static readonly Vector3[] Tmp = (Vector3[])(object)new Vector3[12];

		private static readonly List<float> Cross = new List<float>();

		public static Mesh Mesh { get; private set; }

		public static bool Ready
		{
			get
			{
				if ((Object)(object)Mesh != (Object)null && !((Il2CppObjectBase)Mesh).WasCollected)
				{
					return _step == Step.Done;
				}
				return false;
			}
		}

		public static int IndexOf(LG_Area area)
		{
			if (!((Object)(object)area != (Object)null) || !AreaIndex.TryGetValue(((Il2CppObjectBase)area).Pointer, out var value))
			{
				return -1;
			}
			return value;
		}

		public static int IndexFor(LG_Area area)
		{
			if (AreaIndex.TryGetValue(((Il2CppObjectBase)area).Pointer, out var value))
			{
				return value;
			}
			value = Areas.Count;
			Areas.Add(area);
			AreaIndex[((Il2CppObjectBase)area).Pointer] = value;
			return value;
		}

		public static string Describe()
		{
			if (_step != Step.Done)
			{
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0, 2);
				defaultInterpolatedStringHandler.AppendFormatted(_step);
				object value;
				if (_step != Step.Floors)
				{
					value = "";
				}
				else
				{
					DefaultInterpolatedStringHandler defaultInterpolatedStringHandler2 = new DefaultInterpolatedStringHandler(2, 2);
					defaultInterpolatedStringHandler2.AppendLiteral(" ");
					defaultInterpolatedStringHandler2.AppendFormatted(_at);
					defaultInterpolatedStringHandler2.AppendLiteral("/");
					int[] t = _t;
					defaultInterpolatedStringHandler2.AppendFormatted((t != null) ? new int?(t.Length / 3) : ((int?)null));
					value = defaultInterpolatedStringHandler2.ToStringAndClear();
				}
				defaultInterpolatedStringHandler.AppendFormatted((string?)value);
				return defaultInterpolatedStringHandler.ToStringAndClear();
			}
			return $"{_pieces} floor pieces ({_piecesNone} in no area), {_wallPieces} wall pieces ({_wallsNone} in no area; {_wallsOpen} more left out, the floor going on behind them), {Areas.Count} areas, heights {MinY:0.#} to {MaxY:0.#}; {AreaGrid.Describe()}";
		}

		public static void Drop(string why)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (_step != Step.Idle)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("level mesh: dropped (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				l.LogInfo(val);
			}
			_step = Step.Idle;
			_v = null;
			_t = null;
			_edges = null;
			_triCells = null;
			Areas.Clear();
			AreaIndex.Clear();
			Pos.Clear();
			PosArea.Clear();
			Tris.Clear();
			_floorsOf = (_wallsOf = null);
			_midN = null;
			AreaGrid.Clear();
			try
			{
				if ((Object)(object)Mesh != (Object)null && !((Il2CppObjectBase)Mesh).WasCollected)
				{
					Object.Destroy((Object)(object)Mesh);
				}
			}
			catch
			{
			}
			Mesh = null;
			Explored.Clear();
			Things.Clear();
			BigMap.Clear();
		}

		private static void Take(Mesh nav)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			Drop("a new level");
			if ((Object)(object)nav == (Object)null || ((Il2CppObjectBase)nav).WasCollected)
			{
				Plugin.L.LogWarning((object)"level mesh: the game's map made no navmesh");
				return;
			}
			Il2CppStructArray<Vector3> vertices = nav.vertices;
			Il2CppStructArray<int> triangles = nav.triangles;
			_v = (Vector3[])(object)new Vector3[((Il2CppArrayBase<Vector3>)(object)vertices).Length];
			for (int i = 0; i < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; i++)
			{
				_v[i] = ((Il2CppArrayBase<Vector3>)(object)vertices)[i];
			}
			_t = new int[((Il2CppArrayBase<int>)(object)triangles).Length];
			for (int j = 0; j < ((Il2CppArrayBase<int>)(object)triangles).Length; j++)
			{
				_t[j] = ((Il2CppArrayBase<int>)(object)triangles)[j];
			}
			MinY = float.MaxValue;
			MaxY = float.MinValue;
			Vector3[] v = _v;
			foreach (Vector3 val in v)
			{
				MinY = Math.Min(MinY, val.y);
				MaxY = Math.Max(MaxY, val.y);
			}
			_at = 0;
			_pieces = (_piecesNone = (_wallPieces = (_wallsNone = (_wallsOpen = 0))));
			_startedAt = Time.realtimeSinceStartup;
			Spent.Reset();
			_step = Step.Nodes;
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(73, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("level mesh: the game's navmesh taken: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_v.Length);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" vertices, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_t.Length / 3);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" triangles, heights ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(MinY, "0.#");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(MaxY, "0.#");
			}
			l.LogInfo(val2);
		}

		private static bool Built()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			eGameStateName currentStateName = GameStateManager.CurrentStateName;
			if ((int)currentStateName >= 7)
			{
				return (int)currentStateName <= 10;
			}
			return false;
		}

		public static void Update()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			if (_step == Step.Idle || _step == Step.Done || !Built())
			{
				return;
			}
			try
			{
				Clock.Restart();
				Spent.Start();
				while (_step != Step.Done && Clock.Elapsed.TotalMilliseconds < 4.0)
				{
					switch (_step)
					{
					case Step.Nodes:
						if (AreaGrid.Collect(1000))
						{
							_step = Step.Floors;
							_at = 0;
							Prepare();
						}
						break;
					case Step.Floors:
						Floors();
						break;
					case Step.Walls:
						WallPieces();
						break;
					case Step.Make:
						Make();
						break;
					}
				}
				Spent.Stop();
			}
			catch (Exception ex)
			{
				Spent.Stop();
				if (_errors++ < 5)
				{
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(12, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("level mesh: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					l.LogError(val);
				}
				Drop("an error");
			}
		}

		private static void Prepare()
		{
			int num = Areas.Count + 1;
			_floorsOf = new List<int>[num];
			_wallsOf = new List<int>[num];
			for (int i = 0; i < num; i++)
			{
				_floorsOf[i] = new List<int>();
				_wallsOf[i] = new List<int>();
			}
			_midX = new float[num];
			_midY = new float[num];
			_midZ = new float[num];
			_midN = new int[num];
			_names = new string[num];
			for (int j = 0; j < Areas.Count; j++)
			{
				LG_Area val = Areas[j];
				LG_Zone zone = val.m_zone;
				string text = (((Object)(object)zone != (Object)null && zone.NavInfo != null) ? $"{zone.NavInfo.PrefixLong} {zone.NavInfo.Number}".Trim() : "");
				string text2 = ((val.m_navInfo != null) ? val.m_navInfo.Suffix : "");
				_names[j] = (text + text2).ToUpperInvariant();
			}
		}

		public static bool Middle(int area, out Vector3 at, out string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			at = default(Vector3);
			name = "";
			if (_midN == null || area < 0 || area >= Areas.Count || _midN[area] == 0)
			{
				return false;
			}
			float num = _midN[area];
			at = new Vector3
			{
				x = _midX[area] / num,
				y = _midY[area] / num + 0.5f,
				z = _midZ[area] / num
			};
			name = _names[area] ?? "";
			return true;
		}

		private static void Floors()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			int num = _t.Length / 3;
			int num2 = Math.Min(num, _at + 200);
			while (_at < num2)
			{
				int num3 = _at * 3;
				Tri3[0] = _v[_t[num3]];
				Tri3[1] = _v[_t[num3 + 1]];
				Tri3[2] = _v[_t[num3 + 2]];
				float num4 = MathF.Min(Tri3[0].x, MathF.Min(Tri3[1].x, Tri3[2].x));
				float num5 = MathF.Max(Tri3[0].x, MathF.Max(Tri3[1].x, Tri3[2].x));
				int i = (int)MathF.Floor(num4 / 1f);
				for (int num6 = (int)MathF.Floor(num5 / 1f); i <= num6; i++)
				{
					int n = Cut(Tri3, 3, Tmp, onX: true, (float)i * 1f, 1f);
					n = Cut(Tmp, n, Col, onX: true, (float)(i + 1) * 1f, -1f);
					if (n < 3)
					{
						continue;
					}
					float num7 = float.MaxValue;
					float num8 = float.MinValue;
					for (int j = 0; j < n; j++)
					{
						num7 = MathF.Min(num7, Col[j].z);
						num8 = MathF.Max(num8, Col[j].z);
					}
					int k = (int)MathF.Floor(num7 / 1f);
					for (int num9 = (int)MathF.Floor(num8 / 1f); k <= num9; k++)
					{
						int n2 = Cut(Col, n, Tmp, onX: false, (float)k * 1f, 1f);
						n2 = Cut(Tmp, n2, Piece, onX: false, (float)(k + 1) * 1f, -1f);
						if (n2 >= 3)
						{
							AddPiece(Piece, n2);
						}
					}
				}
				_at++;
			}
			if (_at >= num)
			{
				_step = Step.Walls;
				_at = 0;
				FindEdges();
			}
		}

		private static int Cut(Vector3[] src, int n, Vector3[] dst, bool onX, float at, float sign)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			int result = 0;
			for (int i = 0; i < n; i++)
			{
				Vector3 val = src[i];
				Vector3 val2 = src[(i + 1 < n) ? (i + 1) : 0];
				float num = sign * ((onX ? val.x : val.z) - at);
				float num2 = sign * ((onX ? val2.x : val2.z) - at);
				if (num >= 0f)
				{
					dst[result++] = val;
				}
				if (num >= 0f != num2 >= 0f)
				{
					float num3 = num / (num - num2);
					dst[result++] = new Vector3
					{
						x = val.x + (val2.x - val.x) * num3,
						y = val.y + (val2.y - val.y) * num3,
						z = val.z + (val2.z - val.z) * num3
					};
				}
			}
			return result;
		}

		private static void AddPiece(Vector3[] poly, int n)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			Vector3 val = poly[0];
			for (int i = 1; i + 1 < n; i++)
			{
				Vector3 val2 = poly[i];
				Vector3 val3 = poly[i + 1];
				float num5 = val2.x - val.x;
				float num6 = val2.y - val.y;
				float num7 = val2.z - val.z;
				float num8 = val3.x - val.x;
				float num9 = val3.y - val.y;
				float num10 = val3.z - val.z;
				float num11 = num6 * num10 - num7 * num9;
				float num12 = num7 * num8 - num5 * num10;
				float num13 = num5 * num9 - num6 * num8;
				num += MathF.Sqrt(num11 * num11 + num12 * num12 + num13 * num13) * 0.5f;
			}
			if (!(num < 0.0005f))
			{
				for (int j = 0; j < n; j++)
				{
					num2 += poly[j].x;
					num3 += poly[j].y;
					num4 += poly[j].z;
				}
				int num14 = AreaGrid.AreaAt(num2 / (float)n, num3 / (float)n, num4 / (float)n);
				if (num14 < 0)
				{
					num14 = AreaGrid.AreaAt(num2 / (float)n, num3 / (float)n, num4 / (float)n, count: false, 7f);
				}
				_pieces++;
				if (num14 < 0)
				{
					_piecesNone++;
				}
				else
				{
					_midX[num14] += num2 / (float)n;
					_midY[num14] += num3 / (float)n;
					_midZ[num14] += num4 / (float)n;
					_midN[num14]++;
				}
				int count = Pos.Count;
				for (int k = 0; k < n; k++)
				{
					Pos.Add(poly[k]);
					PosArea.Add(num14);
				}
				List<int> list = _floorsOf[(num14 < 0) ? Areas.Count : num14];
				for (int l = 1; l + 1 < n; l++)
				{
					list.Add(Tris.Count);
					Tris.Add(count);
					Tris.Add(count + l);
					Tris.Add(count + l + 1);
				}
			}
		}

		private static void FindEdges()
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<(int, int, int), int> dictionary = new Dictionary<(int, int, int), int>(_v.Length);
			int[] array = new int[_v.Length];
			for (int i = 0; i < _v.Length; i++)
			{
				Vector3 val = _v[i];
				(int, int, int) key = ((int)MathF.Round(val.x * 50f), (int)MathF.Round(val.y * 50f), (int)MathF.Round(val.z * 50f));
				if (!dictionary.TryGetValue(key, out var value))
				{
					value = i;
					dictionary[key] = i;
				}
				array[i] = value;
			}
			Dictionary<long, (int, int, int, int)> dictionary2 = new Dictionary<long, (int, int, int, int)>(_t.Length);
			for (int j = 0; j < _t.Length / 3; j++)
			{
				for (int k = 0; k < 3; k++)
				{
					int num = array[_t[j * 3 + k]];
					int num2 = array[_t[j * 3 + (k + 1) % 3]];
					if (num != num2)
					{
						long key2 = ((num < num2) ? (((long)num << 32) | (uint)num2) : (((long)num2 << 32) | (uint)num));
						dictionary2[key2] = (dictionary2.TryGetValue(key2, out var value2) ? (value2.Item1 + 1, value2.Item2, value2.Item3, value2.Item4) : (1, num, num2, j));
					}
				}
			}
			_edges = new List<(int, int, int)>();
			foreach (var value4 in dictionary2.Values)
			{
				if (value4.Item1 == 1)
				{
					_edges.Add((value4.Item2, value4.Item3, value4.Item4));
				}
			}
			_triCells = new Dictionary<long, List<int>>();
			for (int l = 0; l < _t.Length / 3; l++)
			{
				Vector3 val2 = _v[_t[l * 3]];
				Vector3 val3 = _v[_t[l * 3 + 1]];
				Vector3 val4 = _v[_t[l * 3 + 2]];
				int num3 = (int)MathF.Floor(MathF.Min(val2.x, MathF.Min(val3.x, val4.x)) / 4f);
				int num4 = (int)MathF.Floor(MathF.Max(val2.x, MathF.Max(val3.x, val4.x)) / 4f);
				int num5 = (int)MathF.Floor(MathF.Min(val2.z, MathF.Min(val3.z, val4.z)) / 4f);
				int num6 = (int)MathF.Floor(MathF.Max(val2.z, MathF.Max(val3.z, val4.z)) / 4f);
				for (int m = num3; m <= num4; m++)
				{
					for (int n = num5; n <= num6; n++)
					{
						long key3 = ((long)m << 32) ^ (uint)n;
						if (!_triCells.TryGetValue(key3, out var value3))
						{
							value3 = (_triCells[key3] = new List<int>(8));
						}
						value3.Add(l);
					}
				}
			}
		}

		private static bool FloorAt(float x, float y, float z, float reach)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_017f: 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)
			long key = ((long)(int)MathF.Floor(x / 4f) << 32) ^ (uint)(int)MathF.Floor(z / 4f);
			if (!_triCells.TryGetValue(key, out var value))
			{
				return false;
			}
			foreach (int item in value)
			{
				Vector3 val = _v[_t[item * 3]];
				Vector3 val2 = _v[_t[item * 3 + 1]];
				Vector3 val3 = _v[_t[item * 3 + 2]];
				float num = (val2.z - val3.z) * (val.x - val3.x) + (val3.x - val2.x) * (val.z - val3.z);
				if (!(MathF.Abs(num) < 1E-09f))
				{
					float num2 = ((val2.z - val3.z) * (x - val3.x) + (val3.x - val2.x) * (z - val3.z)) / num;
					float num3 = ((val3.z - val.z) * (x - val3.x) + (val.x - val3.x) * (z - val3.z)) / num;
					float num4 = 1f - num2 - num3;
					if (!(num2 < 0f) && !(num3 < 0f) && !(num4 < 0f) && MathF.Abs(num2 * val.y + num3 * val2.y + num4 * val3.y - y) <= reach)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static void WallPieces()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: 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)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			int num = Math.Min(_edges.Count, _at + 300);
			while (_at < num)
			{
				(int A, int B, int Tri) tuple = _edges[_at];
				int item = tuple.A;
				int item2 = tuple.B;
				int item3 = tuple.Tri;
				Vector3 val = _v[item];
				Vector3 val2 = _v[item2];
				int num2 = item3 * 3;
				Vector3 val3 = _v[_t[num2]];
				Vector3 val4 = _v[_t[num2 + 1]];
				Vector3 val5 = _v[_t[num2 + 2]];
				float num3 = (val3.x + val4.x + val5.x) / 3f;
				float num4 = (val3.z + val4.z + val5.z) / 3f;
				float num5 = 0f - (val2.z - val.z);
				float num6 = val2.x - val.x;
				float num7 = MathF.Sqrt(num5 * num5 + num6 * num6);
				if (num7 > 1E-05f)
				{
					num5 /= num7;
					num6 /= num7;
					if (num5 * (num3 - (val.x + val2.x) * 0.5f) + num6 * (num4 - (val.z + val2.z) * 0.5f) > 0f)
					{
						num5 = 0f - num5;
						num6 = 0f - num6;
					}
				}
				Cross.Clear();
				Cross.Add(0f);
				AddCrossings(val.x, val2.x, 1f);
				AddCrossings(val.z, val2.z, 1f);
				Cross.Add(1f);
				Cross.Sort();
				for (int i = 0; i + 1 < Cross.Count; i++)
				{
					float num8 = Cross[i];
					float num9 = Cross[i + 1];
					if (num9 - num8 < 0.0001f)
					{
						continue;
					}
					Vector3 val6 = Lerp(val, val2, num8);
					Vector3 val7 = Lerp(val, val2, num9);
					float num10 = (val6.x + val7.x) * 0.5f;
					float y = (val6.y + val7.y) * 0.5f;
					float num11 = (val6.z + val7.z) * 0.5f;
					if (num7 > 1E-05f && FloorAt(num10 + num5 * 0.06f, y, num11 + num6 * 0.06f, 0.5f))
					{
						_wallsOpen++;
						continue;
					}
					float num12 = num3 - num10;
					float num13 = num4 - num11;
					float num14 = MathF.Sqrt(num12 * num12 + num13 * num13);
					if (num14 > 0.0001f)
					{
						num10 += num12 / num14 * 0.35f;
						num11 += num13 / num14 * 0.35f;
					}
					int num15 = AreaGrid.AreaAt(num10, y, num11);
					if (num15 < 0)
					{
						num15 = AreaGrid.AreaAt(num10, y, num11, count: false, 7f);
					}
					_wallPieces++;
					if (num15 < 0)
					{
						_wallsNone++;
					}
					int count = Pos.Count;
					Pos.Add(val6);
					Pos.Add(val7);
					Pos.Add(new Vector3
					{
						x = val7.x,
						y = val7.y + 0.6f,
						z = val7.z
					});
					Pos.Add(new Vector3
					{
						x = val6.x,
						y = val6.y + 0.6f,
						z = val6.z
					});
					for (int j = 0; j < 4; j++)
					{
						PosArea.Add(num15);
					}
					_wallsOf[(num15 < 0) ? Areas.Count : num15].Add(Tris.Count);
					Tris.Add(count);
					Tris.Add(count + 1);
					Tris.Add(count + 2);
					Tris.Add(count);
					Tris.Add(count + 2);
					Tris.Add(count + 3);
				}
				_at++;
			}
			if (_at >= _edges.Count)
			{
				_step = Step.Make;
			}
		}

		private static void AddCrossings(float u, float w, float c)
		{
			if (MathF.Abs(w - u) < 1E-06f)
			{
				return;
			}
			float num = MathF.Min(u, w);
			float num2 = MathF.Max(u, w);
			for (float num3 = MathF.Ceiling(num / c) * c; num3 < num2; num3 += c)
			{
				float num4 = (num3 - u) / (w - u);
				if (num4 > 0f && num4 < 1f)
				{
					Cross.Add(num4);
				}
			}
		}

		private static Vector3 Lerp(Vector3 a, Vector3 b, float t)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3
			{
				x = a.x + (b.x - a.x) * t,
				y = a.y + (b.y - a.y) * t,
				z = a.z + (b.z - a.z) * t
			};
		}

		private static void Make()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			int count = Areas.Count;
			int count2 = Pos.Count;
			Color32[] array = (Color32[])(object)new Color32[count + 1];
			Color32[] array2 = (Color32[])(object)new Color32[count + 1];
			for (int i = 0; i <= count; i++)
			{
				var (h, flag) = Hue(i);
				array[i] = Linear(flag ? (R: 0.36f, G: 0.38f, B: 0.41f) : Hsv(h, 0.42f, 0.58f), 0.74f);
				array2[i] = Linear(flag ? (R: 0.7f, G: 0.73f, B: 0.76f) : Hsv(h, 0.16f, 1f), 0.96f);
			}
			Color32[] array3 = (Color32[])(object)new Color32[count2];
			bool[] array4 = new bool[count2];
			for (int j = 0; j <= count; j++)
			{
				foreach (int item in _wallsOf[j])
				{
					for (int k = 0; k < 6; k++)
					{
						array4[Tris[item + k]] = true;
					}
				}
			}
			for (int l = 0; l < count2; l++)
			{
				int num = ((PosArea[l] < 0) ? count : PosArea[l]);
				array3[l] = (array4[l] ? array2[num] : array[num]);
			}
			Mesh = new Mesh
			{
				name = "3DMap level",
				hideFlags = (HideFlags)61,
				indexFormat = (IndexFormat)1,
				vertices = Il2CppStructArray<Vector3>.op_Implicit(Pos.ToArray()),
				colors32 = Il2CppStructArray<Color32>.op_Implicit(array3),
				subMeshCount = 6,
				bounds = new Bounds(Vector3.zero, Vector3.one * 100000f)
			};
			_step = Step.Done;
			_v = null;
			_edges = null;
			_triCells = null;
			Refresh();
			ManualLogSource l2 = Plugin.L;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(61, 5, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("level mesh: made in ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(Time.realtimeSinceStartup - _startedAt, "0.00");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" s (");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(Spent.Elapsed.TotalMilliseconds, "0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms of work): ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(count2);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" vertices, ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Tris.Count / 3);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" triangles");
			}
			l2.LogInfo(val);
		}

		public static void Refresh()
		{
			if (!Ready)
			{
				return;
			}
			List<int>[] array = new List<int>[6];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new List<int>();
			}
			for (int j = 0; j <= Areas.Count; j++)
			{
				Explored.State state = ((j < Areas.Count) ? Explored.StateOf(j) : Explored.State.Rest);
				List<int>[] array2 = array;
				List<int> list = array2[state switch
				{
					Explored.State.Explored => 0, 
					Explored.State.Next => 1, 
					_ => 2, 
				}];
				array2 = array;
				List<int> list2 = array2[state switch
				{
					Explored.State.Explored => 3, 
					Explored.State.Next => 4, 
					_ => 5, 
				}];
				foreach (int item in _floorsOf[j])
				{
					list.Add(Tris[item]);
					list.Add(Tris[item + 1]);
					list.Add(Tris[item + 2]);
				}
				foreach (int item2 in _wallsOf[j])
				{
					for (int k = 0; k < 6; k++)
					{
						list2.Add(Tris[item2 + k]);
					}
				}
			}
			for (int l = 0; l < array.Length; l++)
			{
				Mesh.SetIndices(Il2CppStructArray<int>.op_Implicit(array[l].ToArray()), (MeshTopology)0, l, false);
			}
		}

		private static (float H, bool None) Hue(int area)
		{
			if (area < 0 || area >= Areas.Count)
			{
				return (H: 0f, None: true);
			}
			LG_Zone zone = Areas[area].m_zone;
			int num = (((Object)(object)zone != (Object)null && zone.NavInfo != null) ? zone.NavInfo.Number : area);
			return (H: 0.4f + (float)num * 0.6180339f % 1f * 0.38f, None: false);
		}

		private static (float R, float G, float B) Hsv(float h, float s, float v)
		{
			float num = h * 6f;
			int num2 = (int)num % 6;
			num -= MathF.Floor(num);
			float num3 = v * (1f - s);
			float num4 = v * (1f - s * num);
			float num5 = v * (1f - s * (1f - num));
			return num2 switch
			{
				0 => (R: v, G: num5, B: num3), 
				1 => (R: num4, G: v, B: num3), 
				2 => (R: num3, G: v, B: num5), 
				3 => (R: num3, G: num4, B: v), 
				4 => (R: num5, G: num3, B: v), 
				_ => (R: v, G: num3, B: num4), 
			};
		}

		private static Color32 Linear((float R, float G, float B) c, float alpha)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			return new Color32
			{
				r = Byte(ToLinear(c.R)),
				g = Byte(ToLinear(c.G)),
				b = Byte(ToLinear(c.B)),
				a = Byte(alpha)
			};
		}

		private static float ToLinear(float s)
		{
			if (!(s <= 0.04045f))
			{
				return MathF.Pow((s + 0.055f) / 1.055f, 2.4f);
			}
			return s / 12.92f;
		}

		private static byte Byte(float x)
		{
			return (byte)Math.Clamp((int)(x * 255f + 0.5f), 0, 255);
		}
	}
	internal static class LogTerminals
	{
		private static bool _looked;

		private static Func<uint, bool> _onMap;

		public static bool Linked
		{
			get
			{
				Look();
				return _onMap != null;
			}
		}

		public static bool OnMap(uint mapIcon)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (_onMap == null || mapIcon == 0)
			{
				return false;
			}
			try
			{
				return _onMap(mapIcon);
			}
			catch (Exception ex)
			{
				_onMap = null;
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("log terminals: LogTracker can't be asked, none marked: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				l.LogWarning(val);
				return false;
			}
		}

		private static void Look()
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			if (_looked)
			{
				return;
			}
			_looked = true;
			bool flag = default(bool);
			try
			{
				if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("mirr.LogTracker", out var value))
				{
					return;
				}
				MethodInfo methodInfo = Type.GetType("LogTracker.Api, LogTracker")?.GetMethod("OnMap", new Type[1] { typeof(uint) });
				BepInExInfoLogInterpolatedStringHandler val;
				if (methodInfo == null || methodInfo.ReturnType != typeof(bool))
				{
					ManualLogSource l = Plugin.L;
					val = new BepInExInfoLogInterpolatedStringHandler(97, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("log terminals: LogTracker ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Version>(value.Metadata.Version);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has nothing to ask (0.10.0 has): its log terminals are not on this map");
					}
					l.LogInfo(val);
					return;
				}
				_onMap = (Func<uint, bool>)Delegate.CreateDelegate(typeof(Func<uint, bool>), methodInfo);
				ManualLogSource l2 = Plugin.L;
				val = new BepInExInfoLogInterpolatedStringHandler(72, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("log terminals: LogTracker ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Version>(value.Metadata.Version);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" asked which terminals hold a log still needed");
				}
				l2.LogInfo(val);
			}
			catch (Exception ex)
			{
				_onMap = null;
				ManualLogSource l3 = Plugin.L;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("log terminals: LogTracker not linked: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				l3.LogWarning(val2);
			}
		}
	}
	internal static class Things
	{
		public enum Kind
		{
			Door,
			Locker,
			Box,
			Terminal,
			Ladder,
			Sign,
			Disinfection,
			Generator,
			BulkheadDc,
			Ping,
			Item,
			Spot
		}

		public sealed class Thing
		{
			public Kind Kind;

			public Vector3 Pos;

			public Vector3 Fwd;

			public float Floor;

			public string Name;

			public uint Id;

			public int AreaA = -1;

			public int AreaB = -1;

			public LG_WeakDoor Weak;

			public LG_SecurityDoor Secure;

			public eCM_GuiObjectStatus Status;

			public bool Shown;

			public bool Open;

			public bool Dim;

			public bool Locked;

			public bool Big;

			public bool Gone;

			public bool Pinged;

			public bool Log;

			public eNavMarkerStyle Style;

			public ItemInLevel Item;

			public float Until;
		}

		private struct Seen
		{
			public bool On;

			public eNavMarkerStyle Style;

			public float X;

			public float Y;

			public float Z;
		}

		private const int Kinds = 12;

		public static readonly List<Thing> All = new List<Thing>();

		private static readonly Dictionary<uint, Thing> ById = new Dictionary<uint, Thing>();

		private static bool _built;

		private static float _lookAt;

		private static float _tryAt;

		private static float _pingAt;

		private static int _errors;

		private static int _tries;

		private static readonly int[] Sampled = new int[12];

		private static readonly Seen[] Last = new Seen[8];

		private static readonly Thing[] Spots = new Thing[8];

		private static bool _primed;

		private static bool _noState;

		private static bool _noPings;

		private static int _saidPing;

		private static int _saidGone;

		private static int _saidLog;

		public static void Clear()
		{
			All.Clear();
			ById.Clear();
			_built = false;
			_tries = 0;
			_primed = false;
			_saidLog = 0;
			Array.Clear(Spots, 0, Spots.Length);
		}

		public static string Describe()
		{
			if (!_built)
			{
				return "the game's map list not read yet";
			}
			int[] array = new int[12];
			int num = 0;
			int num2 = 0;
			foreach (Thing item in All)
			{
				array[(int)item.Kind]++;
				if (item.Shown)
				{
					num++;
				}
				if (item.Log)
				{
					num2++;
				}
			}
			List<string> list = new List<string>();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i] > 0)
				{
					list.Add($"{array[i]} {i}");
				}
			}
			return $"{All.Count} things ({string.Join(", ", list)}), {num} shown{((num2 > 0) ? $", {num2} log terminal(s) of LogTracker's" : "")}";
		}

		public static void Update()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			if (!LevelMesh.Ready)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			bool flag = default(bool);
			try
			{
				if (!_built)
				{
					if (unscaledTime < _tryAt)
					{
						return;
					}
					_tryAt = unscaledTime + 1f;
					Build();
					if (!_built)
					{
						return;
					}
				}
				if (unscaledTime >= _pingAt && !_noPings)
				{
					_pingAt = unscaledTime + 0.2f;
					try
					{
						Pings(unscaledTime);
					}
					catch (Exception ex)
					{
						_noPings = true;
						ManualLogSource l = Plugin.L;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("things: the players' pings can't be read, none of them marked: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						l.LogWarning(val);
					}
				}
				if (!(unscaledTime < _lookAt))
				{
					_lookAt = unscaledTime + 0.5f;
					Refresh(unscaledTime);
				}
			}
			catch (Exception ex2)
			{
				if (_errors++ < 5)
				{
					ManualLogSource l2 = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(8, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("things: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex2);
					}
					l2.LogError(val2);
				}
			}
		}

		private static void Build()
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			MapDataManager current = MapDataManager.Current;
			List<CM_MapZoneData> val = (((Object)(object)current != (Object)null) ? current.m_mapZoneDatas : null);
			if (val == null || val.Count == 0)
			{
				if (_tries++ == 10)
				{
					Plugin.L.LogWarning((object)"things: the game's map has no zone list yet");
				}
				return;
			}
			List<string> list = new List<string>();
			for (int i = 0; i < val.Count; i++)
			{
				CM_MapZoneData val2 = val[i];
				if (val2 == null)
				{
					continue;
				}
				Il2CppReferenceArray<CM_MapAreaData> areaDatas = val2.m_areaDatas;
				int num = 0;
				while (areaDatas != null && num < ((Il2CppArrayBase<CM_MapAreaData>)(object)areaDatas).Length)
				{
					CM_MapAreaData val3 = ((Il2CppArrayBase<CM_MapAreaData>)(object)areaDatas)[num];
					if (val3 != null)
					{
						Add(val3.m_doorDatas, Kind.Door, list);
						Add(val3.m_resourceLockerDatas, Kind.Locker, list);
						Add(val3.m_resourceBoxDatas, Kind.Box, list);
						Add(val3.m_computerTerminalDatas, Kind.Terminal, list);
						Add(val3.m_ladderDatas, Kind.Ladder, list);
						Add(val3.m_signDatas, Kind.Sign, list);
						Add(val3.m_disinfectionDatas, Kind.Disinfection, list);
						Add(val3.m_powerGeneratorDatas, Kind.Generator, list);
						Add(val3.m_bulkheadDoorControllerDatas, Kind.BulkheadDc, list);
					}
					num++;
				}
			}
			_built = true;
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("things: ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(Describe());
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; e.g. ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(string.Join(", ", list));
			}
			l.LogInfo(val4);
		}

		private static void Add(Il2CppReferenceArray<CM_MapDataObj> list, Kind kind, List<string> samples)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			if (samples.Count == 0)
			{
				Array.Clear(Sampled, 0, Sampled.Length);
			}
			int num = 0;
			while (list != null && num < ((Il2CppArrayBase<CM_MapDataObj>)(object)list).Length)
			{
				CM_MapDataObj val = ((Il2CppArrayBase<CM_MapDataObj>)(object)list)[num];
				if (val != null)
				{
					Thing thing = new Thing
					{
						Kind = kind,
						Pos = val.worldPos,
						Fwd = val.worldFwd,
						Name = Clean(val.name),
						Id = val.StoredGUIObjID
					};
					GameObject revealerBase = val.RevealerBase;
					Vector3 val2 = thing.Fwd;
					val2.y = 0f;
					val2 = (thing.Fwd = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward));
					if (kind == Kind.Door)
					{
						thing.AreaB = AreaGrid.AreaNear(thing.Pos + val2 * 1.5f);
						thing.AreaA = AreaGrid.AreaNear(thing.Pos - val2 * 1.5f);
						if (thing.AreaA < 0 && thing.AreaB >= 0)
						{
							AreaGrid.AreaNear(thing.Pos + val2 * 1.5f);
						}
						if ((Object)(object)revealerBase != (Object)null)
						{
							thing.Weak = revealerBase.GetComponentInParent<LG_WeakDoor>();
							if ((Object)(object)thing.Weak == (Object)null)
							{
								thing.Secure = revealerBase.GetComponentInParent<LG_SecurityDoor>();
							}
						}
						thing.Big = (Object)(object)thing.Secure != (Object)null;
						if (thing.Name.Length == 0 && (Object)(object)thing.Secure != (Object)null)
						{
							iTerminalItem terminalItem = thing.Secure.m_terminalItem;
							thing.Name = Clean((terminalItem != null) ? terminalItem.TerminalItemKey : null);
						}
					}
					else
					{
						thing.AreaA = AreaGrid.AreaNear(thing.Pos);
						if (thing.Name.Length == 0 && (Object)(object)revealerBase != (Object)null)
						{
							Thing thing2 = thing;
							string name;
							switch (kind)
							{
							case Kind.Terminal:
							{
								LG_ComputerTerminal componentInParent2 = revealerBase.GetComponentInParent<LG_ComputerTerminal>();
								name = Clean((componentInParent2 != null) ? componentInParent2.PublicName : null);
								break;
							}
							case Kind.Generator:
							{
								LG_PowerGenerator_Core componentInParent4 = revealerBase.GetComponentInParent<LG_PowerGenerator_Core>();
								name = Clean((componentInParent4 != null) ? componentInParent4.PublicName : null);
								break;
							}
							case Kind.Disinfection:
							{
								LG_DisinfectionStation componentInParent3 = revealerBase.GetComponentInParent<LG_DisinfectionStation>();
								name = Clean((componentInParent3 != null) ? componentInParent3.m_itemKey : null);
								break;
							}
							case Kind.BulkheadDc:
							{
								LG_BulkheadDoorController_Core componentInParent = revealerBase.GetComponentInParent<LG_BulkheadDoorController_Core>();
								object s;
								if (componentInParent == null)
								{
									s = null;
								}
								else
								{
									iTerminalItem terminalItem2 = componentInParent.m_terminalItem;
									s = ((terminalItem2 != null) ? terminalItem2.TerminalItemKey : null);
								}
								name = Clean((string)s);
								break;
							}
							default:
								name = "";
								break;
							}
							thing2.Name = name;
						}
					}
					thing.Floor = ((thing.AreaA >= 0 || thing.AreaB >= 0) ? AreaGrid.FoundY : thing.Pos.y);
					if (Math.Abs(thing.Floor - thing.Pos.y) > 3.5f)
					{
						thing.Floor = thing.Pos.y;
					}
					All.Add(thing);
					if (thing.Id != 0)
					{
						ById[thing.Id] = thing;
					}
					if (Sampled[(int)kind]++ < 2)
					{
						samples.Add($"{kind} '{thing.Name}' id {thing.Id} at {thing.Pos.x:0},{thing.Pos.y:0.0},{thing.Pos.z:0} areas {thing.AreaA}/{thing.AreaB}" + ((kind == Kind.Door) ? (" " + (((Object)(object)thing.Weak != (Object)null) ? "weak" : (((Object)(object)thing.Secure != (Object)null) ? "security" : "no door found"))) : ""));
					}
				}
				num++;
			}
		}

		public static string Clean(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return "";
			}
			if (s.IndexOf('<') < 0)
			{
				return s.Trim();
			}
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			bool flag = false;
			foreach (char c in s)
			{
				switch (c)
				{
				case '<':
					flag = true;
					continue;
				case '>':
					flag = false;
					continue;
				}
				if (!flag)
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString().Trim();
		}

		private static void Refresh(float now)
		{
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Invalid comparison between Unknown and I4
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Invalid comparison between Unknown and I4
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Invalid comparison between Unknown and I4
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Invalid comparison between Unknown and I4
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Invalid comparison between Unknown and I4
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Invalid comparison between Unknown and I4
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Invalid comparison between Unknown and I4
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Invalid comparison between Unknown and I4
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Invalid comparison between Unknown and I4
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Invalid comparison between Unknown and I4
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Invalid comparison between Unknown and I4
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Invalid comparison between Unknown and I4
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Invalid comparison between Unknown and I4
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Invalid comparison between Unknown and I4
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Invalid comparison between Unknown and I4
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Invalid comparison between Unknown and I4
			MapDataManager current = MapDataManager.Current;
			Dictionary<uint, iCM_SyncedGUIObject> val = (((Object)(object)current != (Object)null) ? current.m_syncedGUIObjects : null);
			bool flag = default(bool);
			if (val != null)
			{
				Enumerator<uint, iCM_SyncedGUIObject> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<uint, iCM_SyncedGUIObject> current2 = enumerator.Current;
					iCM_SyncedGUIObject value = current2.Value;
					if (value == null)
					{
						continue;
					}
					if (ById.TryGetValue(current2.Key, out var value2))
					{
						value2.Status = value.Status;
						continue;
					}
					CM_SyncedGUIItem val2 = ((Il2CppObjectBase)value).TryCast<CM_SyncedGUIItem>();
					if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Il2CppObjectBase)val2).TryCast<CM_MapPlayerGUIItem>() != (Object)null))
					{
						CM_MapDataObj data = ((CM_MapGUIItemBase)val2).m_data;
						Thing thing = new Thing
						{
							Kind = Kind.Ping,
							Pos = value.WorldPos,
							Fwd = Vector3.forward,
							Id = current2.Key,
							Status = value.Status,
							Name = Clean((data == null) ? "" : (data.HasLocatorID ? data.LocatorKey : data.name))
						};
						thing.AreaA = AreaGrid.AreaNear(thing.Pos);
						thing.Floor = ((thing.AreaA >= 0 && Math.Abs(AreaGrid.FoundY - thing.Pos.y) < 3.5f) ? AreaGrid.FoundY : thing.Pos.y);
						All.Add(thing);
						ById[current2.Key] = thing;
						ManualLogSource l = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(49, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("things: a new icon on the game's map: '");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(thing.Name);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' (");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<eCM_GuiObjectStatus>(thing.Status);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") at ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(thing.Pos.x, "0");
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(",");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(thing.Pos.y, "0.0");
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(",");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(thing.Pos.z, "0");
						}
						l.LogInfo(val3);
					}
				}
			}
			bool flag2 = Settings.Reveal == Reveal.Whole;
			bool linked = LogTerminals.Linked;
			int num = All.RemoveAll(delegate(Thing t)
			{
				Kind kind2 = t.Kind;
				return (uint)(kind2 - 10) <= 1u && Over(t, now);
			});
			if (num > 0 && _saidGone++ < 20)
			{
				ManualLogSource l2 = Plugin.L;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(65, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("things: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" pinged mark(s) taken off (picked up, or their time over)");
				}
				l2.LogInfo(val3);
			}
			foreach (Thing item in All)
			{
				Kind kind = item.Kind;
				flag = (uint)(kind - 10) <= 1u;
				if (flag)
				{
					item.Shown = true;
					continue;
				}
				eCM_GuiObjectStatus status = item.Status;
				bool flag3 = (int)status > 0;
				bool flag4 = Explored.StateOf(item.AreaA) == Explored.State.Explored || (item.AreaB >= 0 && Explored.StateOf(item.AreaB) == Explored.State.Explored);
				if (item.Kind == Kind.Terminal)
				{
					bool flag5 = linked && LogTerminals.OnMap(item.Id);
					if (flag5 != item.Log && _saidLog++ < 40)
					{
						ManualLogSource l3 = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(9, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("things: ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(item.Name);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(flag5 ? "holds a log LogTracker still needs: marked, shown from now on" : "no longer holds a log LogTracker needs: its mark taken off");
						}
						l3.LogInfo(val3);
					}
					item.Log = flag5;
				}
				item.Shown = ((item.Kind == Kind.Ping) ? flag3 : (flag3 || flag4 || flag2 || item.Pinged || item.Log));
				Thing thing2 = item;
				flag = (((int)status == 1 || (int)status == 3 || (int)status == 14) ? true : false);
				thing2.Dim = flag;
				if (item.Kind == Kind.Door)
				{
					item.Big = (Object)(object)item.Secure != (Object)null || ((int)status >= 6 && (int)status <= 12);
					thing2 = item;
					flag = (((int)status == 4 || (int)status == 6 || (int)status == 12) ? true : false);
					thing2.Open = flag;
					item.Gone = (int)status == 3;
					thing2 = item;
					flag = ((status - 8 <= 1 || (int)status == 11) ? true : false);
					thing2.Locked = flag;
					eDoorStatus val4 = Own(item);
					if ((int)val4 != 0)
					{
						thing2 = item;
						flag = (((int)val4 == 10 || (int)val4 == 16) ? true : false);
						thing2.Open = flag;
						item.Gone = (int)val4 == 11;
						thing2 = item;
						flag = ((val4 - 3 <= 4 || (int)val4 == 15) ? true : false);
						thing2.Locked = flag;
					}
				}
			}
		}

		private static void Pings(float now)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			GuiManager current = GuiManager.Current;
			Il2CppReferenceArray<SyncedNavMarkerWrapper> val = (((Object)(object)current != (Object)null) ? current.m_playerPings : null);
			if (val == null)
			{
				return;
			}
			float num = current.m_playerPingAutoHideDelay;
			if (num < 1f || num > 120f)
			{
				num = 10f;
			}
			for (int i = 0; i < ((Il2CppArrayBase<SyncedNavMarkerWrapper>)(object)val).Length && i < Last.Length; i++)
			{
				SyncedNavMarkerWrapper val2 = ((Il2CppArrayBase<SyncedNavMarkerWrapper>)(object)val)[i];
				SNet_StateReplicator<pNavMarkerState, pNavMarkerInteraction> val3 = (((Object)(object)val2 != (Object)null) ? val2.m_stateReplicator : null);
				if (val3 == null)
				{
					continue;
				}
				pNavMarkerState state = val3.State;
				Vector3 worldPos = state.worldPos;
				Seen seen = Last[i];
				Seen seen2 = new Seen
				{
					On = ((int)state.status == 0),
					Style = state.style,
					X = worldPos.x,
					Y = worldPos.y,
					Z = worldPos.z
				};
				Last[i] = seen2;
				if (!_primed)
				{
					continue;
				}
				float num2 = seen2.X - seen.X;
				float num3 = seen2.Y - seen.Y;
				float num4 = seen2.Z - seen.Z;
				if (seen2.On != seen.On || seen2.Style != seen.Style || !(num2 * num2 + num3 * num3 + num4 * num4 < 0.0004f))
				{
					if (Spots[i] != null)
					{
						All.Remove(Spots[i]);
						Spots[i] = null;
					}
					if (seen2.On)
					{
						Pinged(i, state.style, worldPos, now, num);
					}
				}
			}
			_primed = true;
		}

		private static void Pinged(int slot, eNavMarkerStyle style, Vector3 at, float now, float lasts)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected I4, but got Unknown
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			string text;
			if ((int)style >= 22)
			{
				if ((int)style > 29)
				{
					if ((int)style != 30)
					{
						goto IL_0168;
					}
					text = ShowNearest(Kind.BulkheadDc, at, 4f);
					goto IL_016e;
				}
			}
			else
			{
				switch (style - 1)
				{
				case 8:
					break;
				case 9:
					goto IL_008a;
				case 10:
					goto IL_009c;
				case 5:
					goto IL_00ae;
				case 15:
					goto IL_00c0;
				case 16:
					goto IL_00d2;
				case 2:
				case 3:
				case 4:
				case 7:
				case 17:
				case 18:
				case 19:
				case 20:
					goto IL_00f3;
				case 0:
				case 1:
				case 6:
					goto IL_00fe;
				default:
					goto IL_0168;
				}
			}
			text = ShowNearest(Kind.Door, at, 5f);
			goto IL_016e;
			IL_016e:
			if (_saidPing++ < 40)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 6, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("things: slot ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(slot);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'s ping (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eNavMarkerStyle>(style);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") at ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(at.x, "0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(at.y, "0.0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(at.z, "0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				l.LogInfo(val);
			}
			return;
			IL_00ae:
			text = ShowNearest(Kind.Terminal, at, 3f);
			goto IL_016e;
			IL_00fe:
			Thing thing = new Thing
			{
				Kind = Kind.Spot,
				Pos = at,
				Fwd = Vector3.forward,
				Floor = at.y,
				Name = "",
				Style = style,
				Shown = true,
				Until = now + lasts
			};
			All.Add(thing);
			Spots[slot] = thing;
			text = "a mark while it shows";
			goto IL_016e;
			IL_008a:
			text = ShowNearest(Kind.Locker, at, 3f);
			goto IL_016e;
			IL_009c:
			text = ShowNearest(Kind.Box, at, 3f);
			goto IL_016e;
			IL_00c0:
			text = ShowNearest(Kind.Generator, at, 4f);
			goto IL_016e;
			IL_00d2:
			text = ShowNearest(Kind.Disinfection, at, 4f);
			goto IL_016e;
			IL_00f3:
			text = Keep(style, at, now);
			goto IL_016e;
			IL_0168:
			text = "nothing for the map";
			goto IL_016e;
		}

		private static string ShowNearest(Kind kind, Vector3 at, float reach)
		{
			//IL_002f: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Thing thing = null;
			float num = reach * reach;
			foreach (Thing item in All)
			{
				if (item.Kind == kind)
				{
					float num2 = item.Pos.x - at.x;
					float num3 = item.Pos.y - at.y;
					float num4 = item.Pos.z - at.z;
					float num5 = num2 * num2 + num3 * num3 + num4 * num4;
					if (num5 < num)
					{
						num = num5;
						thing = item;
					}
				}
			}
			if (thing != null)
			{
				bool shown = thing.Shown;
				thing.Pinged = true;
				thing.Shown = !thing.Gone;
				if (shown)
				{
					return $"{kind} '{thing.Name}' was shown already";
				}
				return $"{kind} '{thing.Name}' shown from now on";
			}
			return $"no {kind} of the game's map within {reach:0} m";
		}

		private static string Keep(eNavMarkerStyle style, Vector3 at, float now)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//I