Decompiled source of LogTracker v0.9.0

LogTracker.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Collections.ObjectModel;
using InControl;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using SNetwork;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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("LogTracker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8778d2b6138e0c8e6fd60904f2dca68b603febb0")]
[assembly: AssemblyProduct("LogTracker")]
[assembly: AssemblyTitle("LogTracker")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 LogTracker
{
	internal static class Command
	{
		[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ListLogs")]
		private static class Listed
		{
			private static void Postfix(LG_ComputerTerminalCommandInterpreter __instance)
			{
				if (Settings.UnderLogs.On)
				{
					Listing(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "AddInitialTerminalOutput")]
		private static class Started
		{
			private static void Postfix(LG_ComputerTerminalCommandInterpreter __instance)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Invalid comparison between Unknown and I4
				if (Settings.StartScreens.On && Level.Scanned && (int)GameStateManager.CurrentStateName == 10)
				{
					StartLine(__instance, queued: true);
				}
			}
		}

		private sealed class Needs
		{
			public readonly List<string> Rows = new List<string>();

			public readonly HashSet<uint> InLevel = new HashSet<uint>();

			public readonly HashSet<uint> Needed = new HashSet<uint>();

			public readonly HashSet<uint> Here = new HashSet<uint>();

			public bool Others;
		}

		private const uint OneLog = 4036311054u;

		private const uint SomeLogs = 220098854u;

		private const uint WelcomeIn = 2749222011u;

		private const uint Welcome = 2198173463u;

		private static readonly HashSet<string> Written = new HashSet<string>();

		public static void StartScreens()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			if (!Settings.StartScreens.On || !Logs.Known)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			foreach (Level.Terminal terminal in Level.Terminals)
			{
				if (!((Object)(object)terminal.T == (Object)null) && terminal.T.m_command != null)
				{
					num2++;
					if (StartLine(terminal.T.m_command, queued: false))
					{
						num++;
					}
				}
			}
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("start screens: the needed logs on ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" of ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" terminals");
			}
			l.LogInfo(val);
		}

		private static Needs Find(LG_ComputerTerminal here)
		{
			Needs needs = new Needs
			{
				Others = (Settings.OthersNeed.On && Lobby.Sharing)
			};
			foreach (Level.Terminal terminal in Level.Terminals)
			{
				foreach (var (num, text) in terminal.Files)
				{
					if (!Logs.Counts(num))
					{
						continue;
					}
					needs.InLevel.Add(num);
					List<string> list = (needs.Others ? Logs.Needing(num) : (Logs.Needed(num) ? new List<string> { "you" } : null));
					if (list != null && list.Count != 0)
					{
						needs.Needed.Add(num);
						bool flag = (Object)(object)here != (Object)null && (Object)(object)terminal.T != (Object)null && ((Il2CppObjectBase)terminal.T).Pointer == ((Il2CppObjectBase)here).Pointer;
						if (flag)
						{
							needs.Here.Add(num);
						}
						string text2 = terminal.Name + (flag ? " (HERE)" : "");
						string text3 = terminal.ZoneTerm + ((terminal.Dimension != 0) ? $" (DIM {terminal.Dimension})" : "");
						needs.Rows.Add(needs.Others ? Row(text + (terminal.Listed(text) ? "" : " (unlisted)"), text2, text3, string.Join(", ", list).ToUpperInvariant()) : Row(text + (terminal.Listed(text) ? "" : " (not listed yet)"), text2, text3));
					}
				}
			}
			return needs;
		}

		private static void Listing(LG_ComputerTerminalCommandInterpreter cmd)
		{
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				LG_ComputerTerminal terminal = cmd.m_terminal;
				if (!Logs.Known || Logs.Total == 0)
				{
					cmd.AddOutput("Achievement logs: not known yet (the game hasn't logged in to its server)", true);
					return;
				}
				string text = "";
				if (Level.Scanned)
				{
					Needs needs = Find(terminal);
					cmd.AddOutput((TerminalLineType)3, "Listing achievement logs still needed in this level", 0.5f, (TerminalSoundType)0, (TerminalSoundType)0);
					cmd.AddOutput("", false);
					if (needs.Rows.Count == 0)
					{
						cmd.AddOutput(text = NoneNeeded(needs), true);
					}
					else
					{
						cmd.AddOutput(needs.Others ? Row("FILE NAME", "TERMINAL", "ZONE", "NEEDED BY") : Row("FILE NAME", "TERMINAL", "ZONE"), true);
						foreach (string row in needs.Rows)
						{
							cmd.AddOutput(row, false);
						}
						cmd.AddOutput("", false);
						text = needs.Rows[0];
					}
				}
				cmd.AddOutput($"Achievement logs read: {Logs.ReadCount} of {Logs.Total}", true);
				ManualLogSource l = Plugin.L;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LOGS on ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)terminal != (Object)null) ? terminal.PublicName : "?");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				l.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource l2 = Plugin.L;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(6, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LOGS: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				l2.LogError(val2);
			}
		}

		private static string NoneNeeded(Needs n)
		{
			if (n.InLevel.Count != 0)
			{
				return ((n.InLevel.Count == 1) ? "The achievement log in this level is read" : $"All {n.InLevel.Count} achievement logs in this level are read") + (n.Others ? (" by you, " + string.Join(", ", from m in Lobby.Others
					where m.Read != null
					select m.Name)) : "");
			}
			return "There are no achievement logs in this level";
		}

		private static string StartText(LG_ComputerTerminal here)
		{
			Needs needs = Find(here);
			if (needs.Needed.Count == 0)
			{
				return NoneNeeded(needs);
			}
			string text = ((needs.Needed.Count == 1) ? "There is 1 achievement log still needed in this level" : $"There are {needs.Needed.Count} achievement logs still needed in this level");
			if (needs.Here.Count <= 0)
			{
				return text;
			}
			return $"{text}, {needs.Here.Count} in this terminal";
		}

		private static bool StartLine(LG_ComputerTerminalCommandInterpreter cmd, bool queued)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			string text = "?";
			bool flag = default(bool);
			try
			{
				LG_ComputerTerminal terminal = cmd.m_terminal;
				if ((Object)(object)terminal == (Object)null || !Logs.Known || Logs.Total == 0)
				{
					return false;
				}
				text = terminal.PublicName;
				string text2 = StartText(terminal);
				Written.Add(text2);
				if (InQueue(cmd, terminal, text2) || (!queued && OnScreen(cmd, terminal, text2)))
				{
					return true;
				}
				ManualLogSource l = Plugin.L;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("start screen of ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": not found, no line");
				}
				l.LogInfo(val);
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource l2 = Plugin.L;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("start screen of ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				l2.LogError(val2);
				return false;
			}
		}

		private static bool InQueue(LG_ComputerTerminalCommandInterpreter cmd, LG_ComputerTerminal here, string line)
		{
			Queue<TerminalLine> outputQueue = cmd.m_outputQueue;
			if (outputQueue == null || outputQueue.Count == 0)
			{
				return false;
			}
			List<TerminalLine> list = new List<TerminalLine>(outputQueue.Count);
			while (outputQueue.Count > 0)
			{
				list.Add(outputQueue.Dequeue());
			}
			var (num, flag) = Place(list.Select((TerminalLine l) => (l == null) ? null : l.Text).ToList(), here);
			if (num < 0)
			{
				foreach (TerminalLine item in list)
				{
					outputQueue.Enqueue(item);
				}
				return false;
			}
			for (int num2 = 0; num2 < list.Count; num2++)
			{
				if (num2 == num)
				{
					if (Written.Contains(list[num2].Text))
					{
						list[num2].Text = line;
						flag = false;
					}
					else
					{
						outputQueue.Enqueue(Line(line));
						if (flag)
						{
							outputQueue.Enqueue(Line(""));
						}
					}
				}
				outputQueue.Enqueue(list[num2]);
			}
			if (num >= list.Count)
			{
				outputQueue.Enqueue(Line(line));
				if (flag)
				{
					outputQueue.Enqueue(Line(""));
				}
			}
			return true;
		}

		private static bool OnScreen(LG_ComputerTerminalCommandInterpreter cmd, LG_ComputerTerminal here, string line)
		{
			List<string> screenBuffer = cmd.m_screenBuffer;
			if (screenBuffer == null || screenBuffer.Count == 0)
			{
				return false;
			}
			List<string> list = new List<string>(screenBuffer.Count);
			for (int i = 0; i < screenBuffer.Count; i++)
			{
				list.Add(screenBuffer[i]);
			}
			var (num, flag) = Place(list, here);
			if (num < 0)
			{
				return false;
			}
			if (num < list.Count && Written.Contains(list[num]))
			{
				screenBuffer[num] = line;
			}
			else
			{
				screenBuffer.Insert(num, line);
				if (flag)
				{
					screenBuffer.Insert(num + 1, "");
				}
			}
			return true;
		}

		private static TerminalLine Line(string text)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			return new TerminalLine((TerminalLineType)0, text, 0f, (TerminalSoundType)0, (TerminalSoundType)0);
		}

		private static (int At, bool Blank) Place(List<string> lines, LG_ComputerTerminal here)
		{
			Regex regex = Pattern(Text.Get(2749222011u));
			Regex regex2 = Pattern(Text.Get(2198173463u));
			Regex regex3 = Pattern(Text.Get(220098854u));
			string text = Text.Get(4036311054u);
			string value = here.PublicName ?? "";
			for (int num = lines.Count - 1; num >= 0; num--)
			{
				string text2 = lines[num];
				if (!string.IsNullOrEmpty(text2) && text2.Contains(value) && (regex.IsMatch(text2) || regex2.IsMatch(text2)))
				{
					for (int i = num + 1; i < lines.Count && i <= num + 3; i++)
					{
						if (lines[i] != null && (lines[i] == text || regex3.IsMatch(lines[i])))
						{
							return (At: i + 1, Blank: false);
						}
					}
					return (At: Math.Min(num + 2, lines.Count), Blank: true);
				}
			}
			return (At: -1, Blank: false);
		}

		private static Regex Pattern(string text)
		{
			return new Regex("^" + string.Join(".*?", Regex.Split(text ?? "", "\\{\\d+\\}").Select(Regex.Escape)) + "$", RegexOptions.Singleline);
		}

		private static string Row(params string[] cells)
		{
			int[] at = ((cells.Length != 4) ? new int[3] { 0, 50, 75 } : new int[4] { 0, 28, 50, 68 });
			return string.Concat(cells.Select((string c, int i) => $"<pos={at[i]}%>{c}</pos>"));
		}
	}
	internal static class Level
	{
		internal sealed class Terminal
		{
			public LG_ComputerTerminal T;

			public string Name;

			public string Zone = "";

			public string ZoneTerm = "";

			public int Dimension;

			public readonly List<(uint Id, string File)> Files = new List<(uint, string)>();

			public bool Listed(string file)
			{
				if ((Object)(object)T != (Object)null)
				{
					return T.IsLogVisible(file);
				}
				return false;
			}
		}

		public static readonly List<Terminal> Terminals = new List<Terminal>();

		public static bool Scanned { get; private set; }

		public static void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			bool flag = (int)GameStateManager.CurrentStateName == 10;
			if (flag && !Scanned)
			{
				Scan();
			}
			else if (!flag && Scanned)
			{
				Terminals.Clear();
				Scanned = false;
			}
		}

		private static void Scan()
		{
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected I4, but got Unknown
			Scanned = true;
			foreach (LG_ComputerTerminal item in Object.FindObjectsOfType<LG_ComputerTerminal>())
			{
				Terminal terminal = new Terminal
				{
					T = item,
					Name = (item.PublicName ?? "").Trim().ToUpperInvariant()
				};
				LG_Zone val = ((item.SpawnNode != null) ? item.SpawnNode.m_zone : null);
				if ((Object)(object)val != (Object)null)
				{
					LG_NavInfo navInfo = val.NavInfo;
					string value = ((navInfo != null && !string.IsNullOrWhiteSpace(navInfo.PrefixLong)) ? navInfo.PrefixLong.Trim().ToUpperInvariant() : ((navInfo != null && !string.IsNullOrWhiteSpace(navInfo.PrefixShort)) ? navInfo.PrefixShort.Trim().ToUpperInvariant() : "ZONE"));
					int value2 = ((navInfo != null) ? navInfo.Number : val.Alias);
					terminal.Zone = $"{value} {value2}";
					terminal.ZoneTerm = $"{value}_{value2}";
					terminal.Dimension = (int)val.DimensionIndex;
				}
				Dictionary<string, TerminalLogFileData> localLogs = item.GetLocalLogs();
				if (localLogs != null)
				{
					Enumerator<string, TerminalLogFileData> enumerator2 = localLogs.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						KeyValuePair<string, TerminalLogFileData> current2 = enumerator2.Current;
						if (current2.Value != null && !string.IsNullOrEmpty(current2.Key))
						{
							terminal.Files.Add((current2.Value.FileContent.Id, current2.Key.Trim().ToUpperInvariant()));
						}
					}
				}
				Terminals.Add(terminal);
			}
			StringBuilder stringBuilder = new StringBuilder($"level: {Terminals.Count} terminals");
			foreach (Terminal terminal2 in Terminals)
			{
				foreach (var (id, text) in terminal2.Files)
				{
					if (Logs.Counts(id))
					{
						StringBuilder stringBuilder2 = stringBuilder;
						StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(9, 6, stringBuilder2);
						handler.AppendLiteral("; ");
						handler.AppendFormatted(terminal2.Name);
						handler.AppendLiteral(" in ");
						handler.AppendFormatted(terminal2.Zone);
						handler.AppendFormatted((terminal2.Dimension != 0) ? $" (dimension {terminal2.Dimension})" : "");
						handler.AppendLiteral(": ");
						handler.AppendFormatted(text);
						handler.AppendLiteral(" ");
						handler.AppendFormatted(Logs.Needed(id) ? "not read" : "read");
						handler.AppendFormatted(terminal2.Listed(text) ? "" : ", not listed yet");
						stringBuilder2.Append(ref handler);
					}
				}
			}
			Plugin.L.LogInfo((object)stringBuilder.ToString());
			Command.StartScreens();
		}
	}
	internal static class Lobby
	{
		internal sealed class Member
		{
			public ulong Id;

			public string Name = "?";

			public HashSet<uint> Read;

			public string Raw = "";
		}

		private const string Key = "LogTracker.read";

		public static readonly List<Member> Others = new List<Member>();

		private static ulong _sharedIn;

		private static string _shared;

		private static float _next;

		private static int _errors;

		public static int Version { get; private set; }

		public static bool Sharing => Others.Exists((Member m) => m.Read != null);

		public static void Update()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			if (Time.unscaledTime < _next)
			{
				return;
			}
			_next = Time.unscaledTime + 2f;
			try
			{
				Look();
			}
			catch (Exception ex)
			{
				if (_errors++ < 3)
				{
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(7, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("lobby: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					l.LogWarning(val);
				}
			}
		}

		private static void Look()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			ulong num = SteamLobby();
			if (!Settings.OthersNeed.On || num == 0L || !Logs.Known || Logs.Total == 0)
			{
				if (_sharedIn != 0L && _sharedIn == num)
				{
					SteamMatchmaking.SetLobbyMemberData((CSteamID)num, "LogTracker.read", "");
					Plugin.L.LogInfo((object)"lobby: the logs read taken out of the lobby");
				}
				_sharedIn = 0uL;
				_shared = null;
				if (Others.Count > 0)
				{
					Others.Clear();
					Version++;
				}
				return;
			}
			CSteamID val = (CSteamID)num;
			string text = "1:" + string.Join(",", Logs.ReadSorted());
			if (num != _sharedIn || text != _shared)
			{
				SteamMatchmaking.SetLobbyMemberData(val, "LogTracker.read", text);
				if (num != _sharedIn)
				{
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("lobby: the ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(Logs.ReadCount);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" logs read shared in the lobby");
					}
					l.LogInfo(val2);
				}
				_sharedIn = num;
				_shared = text;
			}
			ulong steamID = SteamUser.GetSteamID().m_SteamID;
			List<Member> list = new List<Member>();
			bool flag2 = false;
			int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(val);
			for (int i = 0; i < numLobbyMembers; i++)
			{
				CSteamID who = SteamMatchmaking.GetLobbyMemberByIndex(val, i);
				if (who.m_SteamID != steamID && who.m_SteamID != 0L)
				{
					string text2 = SteamMatchmaking.GetLobbyMemberData(val, who, "LogTracker.read") ?? "";
					Member member = Others.Find((Member o) => o.Id == who.m_SteamID);
					if (member == null || member.Raw != text2)
					{
						member = new Member
						{
							Id = who.m_SteamID,
							Raw = text2,
							Read = Parse(text2)
						};
						flag2 = true;
					}
					string text3 = NameOf(who);
					if (text3 != member.Name)
					{
						member.Name = text3;
						flag2 = true;
					}
					list.Add(member);
				}
			}
			if (flag2 || !list.SequenceEqual(Others))
			{
				Others.Clear();
				Others.AddRange(list);
				Version++;
				Plugin.L.LogInfo((object)("lobby: " + ((Others.Count == 0) ? "no one else" : string.Join(", ", Others.Select((Member o) => (o.Read != null) ? $"{o.Name} {o.Read.Count} of {Logs.Total} read" : (o.Name + " shares nothing"))))));
			}
		}

		private static ulong SteamLobby()
		{
			if (!SNet.IsInLobby)
			{
				return 0uL;
			}
			SNet_Lobby lobby = SNet.Lobby;
			if ((Object)(object)lobby == (Object)null || (Object)(object)((Il2CppObjectBase)lobby).TryCast<SNet_Lobby_STEAM>() == (Object)null)
			{
				return 0uL;
			}
			SNet_LobbyIdentifier identifier = lobby.Identifier;
			if (identifier == null)
			{
				return 0uL;
			}
			return identifier.ID;
		}

		private static HashSet<uint> Parse(string raw)
		{
			if (string.IsNullOrEmpty(raw) || !raw.StartsWith("1:"))
			{
				return null;
			}
			HashSet<uint> hashSet = new HashSet<uint>();
			string[] array = raw.Substring(2).Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				if (uint.TryParse(array[i], out var result) && Logs.Counts(result))
				{
					hashSet.Add(result);
				}
			}
			return hashSet;
		}

		private static string NameOf(CSteamID who)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			string text = null;
			List<SNet_Player> lobbyPlayers = SNet.LobbyPlayers;
			if (lobbyPlayers != null)
			{
				for (int i = 0; i < lobbyPlayers.Count; i++)
				{
					if (text != null)
					{
						break;
					}
					if ((Object)(object)lobbyPlayers[i] != (Object)null && lobbyPlayers[i].Lookup == who.m_SteamID)
					{
						text = lobbyPlayers[i].NickName;
					}
				}
			}
			if (string.IsNullOrWhiteSpace(text))
			{
				text = SteamFriends.GetFriendPersonaName(who);
			}
			text = (text ?? "").Replace("<", "").Replace(">", "").Trim();
			if (text.Length != 0)
			{
				return text;
			}
			return "?";
		}
	}
	internal static class Logs
	{
		internal sealed class Place
		{
			public uint Id;

			public string Where;

			public string File;
		}

		private static readonly List<Place> None = new List<Place>();

		private static readonly HashSet<uint> Counted = new HashSet<uint>();

		private static readonly HashSet<uint> ReadIds = new HashSet<uint>();

		private static readonly Dictionary<IntPtr, List<Place>> ByExpedition = new Dictionary<IntPtr, List<Place>>();

		private static readonly Dictionary<uint, List<uint>> ByRundown = new Dictionary<uint, List<uint>>();

		private static Achievement_ReadAllLogs _task;

		private static float _nextLook;

		private static int _readSeen = -1;

		private static bool _missingSaid;

		public static int Version { get; private set; }

		public static bool Known { get; private set; }

		public static int Total => Counted.Count;

		public static int ReadCount => ReadIds.Count;

		public static bool Counts(uint id)
		{
			return Counted.Contains(id);
		}

		public static bool IsRead(uint id)
		{
			return ReadIds.Contains(id);
		}

		public static bool Needed(uint id)
		{
			if (Counted.Contains(id))
			{
				return !ReadIds.Contains(id);
			}
			return false;
		}

		public static IEnumerable<uint> ReadSorted()
		{
			return ReadIds.OrderBy((uint x) => x);
		}

		public static List<string> Needing(uint id)
		{
			List<string> list = new List<string>();
			if (!Counted.Contains(id))
			{
				return list;
			}
			if (!ReadIds.Contains(id))
			{
				list.Add("you");
			}
			if (Settings.OthersNeed.On)
			{
				foreach (Lobby.Member other in Lobby.Others)
				{
					if (other.Read != null && !other.Read.Contains(id))
					{
						list.Add(other.Name);
					}
				}
			}
			return list;
		}

		public static bool Wanted(uint id)
		{
			if (Needed(id))
			{
				return true;
			}
			if (!Settings.OthersNeed.On || !Counted.Contains(id))
			{
				return false;
			}
			return Lobby.Others.Exists((Lobby.Member m) => m.Read != null && !m.Read.Contains(id));
		}

		public static void Update()
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			Achievement_ReadAllLogs val = Task();
			if (val == null)
			{
				return;
			}
			if (Counted.Count == 0)
			{
				List<uint> allLogs = val.m_allLogs;
				if (allLogs == null)
				{
					return;
				}
				for (int i = 0; i < allLogs.Count; i++)
				{
					Counted.Add(allLogs[i]);
				}
				if (Counted.Count == 0)
				{
					return;
				}
			}
			List<uint> readLogsOnStart = val.m_readLogsOnStart;
			if (readLogsOnStart == null || readLogsOnStart.Count == _readSeen)
			{
				return;
			}
			_readSeen = readLogsOnStart.Count;
			ReadIds.Clear();
			for (int j = 0; j < readLogsOnStart.Count; j++)
			{
				if (Counted.Contains(readLogsOnStart[j]))
				{
					ReadIds.Add(readLogsOnStart[j]);
				}
			}
			Version++;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2;
			if (Known)
			{
				ManualLogSource l = Plugin.L;
				val2 = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("logs: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ReadCount);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" of ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(Total);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" read");
				}
				l.LogInfo(val2);
				return;
			}
			Known = true;
			ManualLogSource l2 = Plugin.L;
			val2 = new BepInExInfoLogInterpolatedStringHandler(29, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("logs: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ReadCount);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" of ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(Total);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" read; by rundown: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Rundowns());
			}
			l2.LogInfo(val2);
		}

		private static Achievement_ReadAllLogs Task()
		{
			if (_task != null || Time.unscaledTime < _nextLook)
			{
				return _task;
			}
			_nextLook = Time.unscaledTime + 2f;
			List<AchievementTask> val = (((Object)(object)AchievementManager.Current != (Object)null) ? AchievementManager.Current.m_allAchievements : null);
			if (val == null || val.Count == 0)
			{
				return null;
			}
			for (int i = 0; i < val.Count; i++)
			{
				AchievementTask obj = val[i];
				Achievement_ReadAllLogs val2 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Achievement_ReadAllLogs>() : null);
				if (val2 != null)
				{
					_task = val2;
					Plugin.L.LogInfo((object)"logs: following the game's Achievement_ReadAllLogs");
					return val2;
				}
			}
			if (!_missingSaid)
			{
				_missingSaid = true;
				Plugin.L.LogWarning((object)"logs: no Achievement_ReadAllLogs among the game's achievements: nothing to count");
			}
			return null;
		}

		public static List<Place> In(ExpeditionInTierData e)
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected I4, but got Unknown
			if (e == null || Counted.Count == 0)
			{
				return None;
			}
			if (ByExpedition.TryGetValue(((Il2CppObjectBase)e).Pointer, out var value))
			{
				return value;
			}
			value = new List<Place>();
			Layout(value, e.LevelLayoutData, "");
			if (e.SecondaryLayerEnabled)
			{
				Layout(value, e.SecondaryLayout, "secondary ");
			}
			if (e.ThirdLayerEnabled)
			{
				Layout(value, e.ThirdLayout, "overload ");
			}
			List<DimensionInExpeditionData> dimensionDatas = e.DimensionDatas;
			if (dimensionDatas != null)
			{
				for (int i = 0; i < dimensionDatas.Count; i++)
				{
					DimensionInExpeditionData val = dimensionDatas[i];
					if (val == null || !val.Enabled || !GameDataBlockBase<DimensionDataBlock>.HasBlock(val.DimensionData))
					{
						continue;
					}
					DimensionDataBlock block = GameDataBlockBase<DimensionDataBlock>.GetBlock(val.DimensionData);
					DimensionData val2 = ((block != null) ? block.DimensionData : null);
					if (val2 == null)
					{
						continue;
					}
					string text = $"dimension {(int)val.DimensionIndex}";
					Layout(value, val2.LevelLayoutData, text + " ");
					List<TerminalPlacementData> staticTerminalPlacements = val2.StaticTerminalPlacements;
					if (staticTerminalPlacements != null)
					{
						string text2 = ((val2.StaticAliasOverride >= 0) ? $"{text} ZONE {val2.StaticAliasOverride}" : text);
						for (int j = 0; j < staticTerminalPlacements.Count; j++)
						{
							List<Place> list = value;
							TerminalPlacementData obj = staticTerminalPlacements[j];
							Files(list, (obj != null) ? obj.LocalLogFiles : null, text2);
						}
					}
				}
			}
			ByExpedition[((Il2CppObjectBase)e).Pointer] = value;
			return value;
		}

		private static void Layout(List<Place> list, uint id, string layer)
		{
			//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)
			if (id == 0 || !GameDataBlockBase<LevelLayoutDataBlock>.HasBlock(id))
			{
				return;
			}
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(id);
			List<ExpeditionZoneData> val = ((block != null) ? block.Zones : null);
			if (val == null)
			{
				return;
			}
			for (int i = 0; i < val.Count; i++)
			{
				ExpeditionZoneData val2 = val[i];
				if (val2 == null)
				{
					continue;
				}
				int value = ((val2.AliasOverride >= 0) ? val2.AliasOverride : (block.ZoneAliasStart + val2.LocalIndex));
				string value2 = ((!val2.OverrideAliasPrefix) ? "ZONE" : ((!string.IsNullOrWhiteSpace(val2.AliasPrefixOverride)) ? val2.AliasPrefixOverride.Trim().ToUpperInvariant() : ((!string.IsNullOrWhiteSpace(val2.AliasPrefixShortOverride)) ? val2.AliasPrefixShortOverride.Trim().ToUpperInvariant() : "ZONE")));
				string text = $"{layer}{value2} {value}";
				List<TerminalPlacementData> terminalPlacements = val2.TerminalPlacements;
				if (terminalPlacements != null)
				{
					for (int j = 0; j < terminalPlacements.Count; j++)
					{
						TerminalPlacementData obj = terminalPlacements[j];
						Files(list, (obj != null) ? obj.LocalLogFiles : null, text);
					}
				}
				List<SpecificTerminalSpawnData> specificTerminalSpawnDatas = val2.SpecificTerminalSpawnDatas;
				if (specificTerminalSpawnDatas != null)
				{
					for (int k = 0; k < specificTerminalSpawnDatas.Count; k++)
					{
						SpecificTerminalSpawnData obj2 = specificTerminalSpawnDatas[k];
						Files(list, (obj2 != null) ? obj2.LocalLogFiles : null, text);
					}
				}
			}
		}

		private static void Files(List<Place> list, List<TerminalLogFileData> files, string where)
		{
			if (files == null)
			{
				return;
			}
			for (int i = 0; i < files.Count; i++)
			{
				TerminalLogFileData val = files[i];
				if (val != null)
				{
					uint id = val.FileContent.Id;
					if (Counted.Contains(id))
					{
						list.Add(new Place
						{
							Id = id,
							Where = where,
							File = (val.FileName ?? "").Trim().ToUpperInvariant()
						});
					}
				}
			}
		}

		public static (int Read, int All) Count(List<Place> places, HashSet<uint> readBy = null)
		{
			if (readBy == null)
			{
				readBy = ReadIds;
			}
			HashSet<uint> hashSet = new HashSet<uint>();
			int num = 0;
			foreach (Place place in places)
			{
				if (hashSet.Add(place.Id) && readBy.Contains(place.Id))
				{
					num++;
				}
			}
			return (Read: num, All: hashSet.Count);
		}

		public static List<(ExpeditionInTierData E, string Name)> Expeditions(uint rundownId)
		{
			List<(ExpeditionInTierData, string)> list = new List<(ExpeditionInTierData, string)>();
			RundownDataBlock val = (GameDataBlockBase<RundownDataBlock>.HasBlock(rundownId) ? GameDataBlockBase<RundownDataBlock>.GetBlock(rundownId) : null);
			if (val == null)
			{
				return list;
			}
			List<ExpeditionInTierData>[] array = new List<ExpeditionInTierData>[5] { val.TierA, val.TierB, val.TierC, val.TierD, val.TierE };
			foreach (List<ExpeditionInTierData> val2 in array)
			{
				if (val2 == null)
				{
					continue;
				}
				for (int j = 0; j < val2.Count; j++)
				{
					ExpeditionInTierData val3 = val2[j];
					if (val3 != null && val3.Enabled)
					{
						DescriptiveData descriptive = val3.Descriptive;
						list.Add((val3, (((descriptive != null) ? descriptive.Prefix : null) ?? "?") + ((descriptive != null && descriptive.SkipExpNumberInName) ? "" : (j + 1).ToString())));
					}
				}
			}
			return list;
		}

		public static List<uint> RundownIds()
		{
			List<uint> list = new List<uint>();
			Il2CppArrayBase<GameSetupDataBlock> allBlocks = GameDataBlockBase<GameSetupDataBlock>.GetAllBlocks();
			List<uint> val = ((allBlocks != null && allBlocks.Length > 0) ? allBlocks[0].RundownIdsToLoad : null);
			if (val != null)
			{
				for (int i = 0; i < val.Count; i++)
				{
					list.Add(val[i]);
				}
			}
			return list;
		}

		public static (int Read, int All) InRundown(uint rundownId)
		{
			if (!ByRundown.TryGetValue(rundownId, out var value))
			{
				if (Counted.Count == 0 || !GameDataBlockBase<RundownDataBlock>.HasBlock(rundownId))
				{
					return (Read: 0, All: 0);
				}
				value = (from p in Expeditions(rundownId).SelectMany(((ExpeditionInTierData E, string Name) x) => In(x.E))
					select p.Id).Distinct().ToList();
				ByRundown[rundownId] = value;
			}
			return (Read: value.Count(ReadIds.Contains), All: value.Count);
		}

		private static string Rundowns()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (uint item in RundownIds())
			{
				var (value, num) = InRundown(item);
				if (num != 0)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(", ");
					}
					StringBuilder stringBuilder2 = stringBuilder;
					StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 3, stringBuilder2);
					handler.AppendFormatted(ShortName(item));
					handler.AppendLiteral(" ");
					handler.AppendFormatted(value);
					handler.AppendLiteral("/");
					handler.AppendFormatted(num);
					stringBuilder2.Append(ref handler);
				}
			}
			if (stringBuilder.Length <= 0)
			{
				return "?";
			}
			return stringBuilder.ToString();
		}

		public static string ShortName(uint rundownId)
		{
			RundownDataBlock val = (GameDataBlockBase<RundownDataBlock>.HasBlock(rundownId) ? GameDataBlockBase<RundownDataBlock>.GetBlock(rundownId) : null);
			if (val == null)
			{
				return rundownId.ToString();
			}
			ExpeditionInTierData obj = ((val.TierA != null && val.TierA.Count > 0) ? val.TierA[0] : null);
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				DescriptiveData descriptive = obj.Descriptive;
				obj2 = ((descriptive != null) ? descriptive.Prefix : null);
			}
			if (obj2 == null)
			{
				obj2 = "";
			}
			string text = (string)obj2;
			int num = text.Length;
			while (num > 1 && char.IsLetter(text[num - 1]))
			{
				num--;
			}
			if (num <= 1 || !text.StartsWith("R"))
			{
				return ((GameDataBlockBase<RundownDataBlock>)(object)val).name;
			}
			return text.Substring(0, num);
		}
	}
	internal static class MapMarks
	{
		private sealed class Mark
		{
			public Level.Terminal Terminal;

			public GameObject Root;

			public readonly List<SpriteRenderer> Sprites = new List<SpriteRenderer>();

			public TextMeshPro Name;

			public bool Said;
		}

		private const float Nearer = -0.05f;

		private static readonly List<Mark> Marks = new List<Mark>();

		private static bool _placed;

		private static bool _stopped;

		private static int _logsVersion;

		private static int _settingsVersion;

		private static int _lobbyVersion;

		private static float _nextLook;

		public static void Update()
		{
			if (!Settings.OnMap.On || !Level.Scanned || !Logs.Known || Logs.Total == 0)
			{
				if (_placed)
				{
					Clear();
				}
			}
			else if (!_placed)
			{
				_placed = true;
				foreach (Level.Terminal terminal in Level.Terminals)
				{
					if (terminal.Files.Any(((uint Id, string File) f) => Logs.Counts(f.Id)))
					{
						Marks.Add(new Mark
						{
							Terminal = terminal
						});
					}
				}
				Refresh();
			}
			else if (_logsVersion != Logs.Version || _settingsVersion != Settings.Version || _lobbyVersion != Lobby.Version || Time.unscaledTime >= _nextLook)
			{
				Refresh();
			}
		}

		private static void Refresh()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			_nextLook = Time.unscaledTime + 2f;
			_logsVersion = Logs.Version;
			_lobbyVersion = Lobby.Version;
			bool flag = _settingsVersion != Settings.Version;
			_settingsVersion = Settings.Version;
			bool others = Settings.OthersNeed.On && Lobby.Sharing;
			bool flag2 = default(bool);
			foreach (Mark mark in Marks)
			{
				Level.Terminal terminal = mark.Terminal;
				if (!terminal.Files.Any(((uint Id, string File) f) => (!others) ? Logs.Needed(f.Id) : Logs.Wanted(f.Id)))
				{
					if (!((Object)(object)mark.Root == (Object)null))
					{
						Remove(mark);
						ManualLogSource l = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("map: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(terminal.Name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" read, off the map");
						}
						l.LogInfo(val);
					}
				}
				else if ((Object)(object)mark.Root == (Object)null)
				{
					if (!_stopped)
					{
						Place(mark);
					}
				}
				else if (flag)
				{
					Recolour(mark);
				}
			}
		}

		private static void Place(Mark m)
		{
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Expected O, but got Unknown
			Level.Terminal terminal = m.Terminal;
			bool flag = default(bool);
			try
			{
				CM_PageMap current = CM_PageMap.Current;
				string how = (((Object)(object)terminal.T == (Object)null) ? "the terminal is gone" : "no map yet");
				CM_SyncedGUIItem val = (((Object)(object)current != (Object)null && (Object)(object)current.m_customMapIconsRoot != (Object)null && (Object)(object)terminal.T != (Object)null) ? Find(terminal, out how) : null);
				BepInExInfoLogInterpolatedStringHandler val2;
				if ((Object)(object)val == (Object)null)
				{
					if (!m.Said)
					{
						m.Said = true;
						ManualLogSource l = Plugin.L;
						val2 = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("map: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(terminal.Name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" not on the map yet: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(how);
						}
						l.LogInfo(val2);
					}
					return;
				}
				m.Root = new GameObject("LogTracker " + terminal.Name);
				Transform transform = m.Root.transform;
				m.Root.layer = ((Component)val).gameObject.layer;
				transform.SetParent(((Component)val).transform.parent, false);
				transform.localPosition = ((Component)val).transform.localPosition;
				transform.localRotation = ((Component)val).transform.localRotation;
				transform.localScale = ((Component)val).transform.localScale;
				transform.SetParent(current.m_customMapIconsRoot.transform, true);
				transform.localPosition += new Vector3(0f, 0f, -0.05f);
				GameObject gfxNormal = val.m_gfxNormal;
				if ((Object)(object)gfxNormal != (Object)null)
				{
					GameObject obj = Object.Instantiate<GameObject>(gfxNormal, transform, false);
					obj.SetActive(true);
					foreach (SpriteRenderer componentsInChild in obj.GetComponentsInChildren<SpriteRenderer>(true))
					{
						((Renderer)componentsInChild).sortingOrder = ((Renderer)componentsInChild).sortingOrder + 1;
						m.Sprites.Add(componentsInChild);
					}
				}
				TextMeshPro val3 = val.m_locatorTxt ?? val.m_additionalTxt ?? ((Component)val).GetComponentInChildren<TextMeshPro>(true);
				if ((Object)(object)val3 != (Object)null)
				{
					GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, transform, false);
					val4.SetActive(true);
					m.Name = val4.GetComponent<TextMeshPro>();
					if ((Object)(object)m.Name != (Object)null)
					{
						((TMP_Text)m.Name).text = terminal.Name;
						MeshRenderer component = ((Component)m.Name).GetComponent<MeshRenderer>();
						if ((Object)(object)component != (Object)null)
						{
							((Renderer)component).sortingOrder = ((Renderer)component).sortingOrder + 1;
						}
					}
				}
				Recolour(m);
				if ((Object)(object)m.Name != (Object)null)
				{
					((TMP_Text)m.Name).ForceMeshUpdate(false, false);
				}
				ManualLogSource l2 = Plugin.L;
				val2 = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("map: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(terminal.Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" on the map");
				}
				l2.LogInfo(val2);
			}
			catch (Exception ex)
			{
				Remove(m);
				_stopped = true;
				ManualLogSource l3 = Plugin.L;
				BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("map: stopped for this level: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex);
				}
				l3.LogError(val5);
			}
		}

		private static void Recolour(Mark m)
		{
			//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_0026: 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)
			Color markerColour = Settings.MarkerColour;
			foreach (SpriteRenderer sprite in m.Sprites)
			{
				if ((Object)(object)sprite != (Object)null)
				{
					sprite.color = markerColour;
				}
			}
			if ((Object)(object)m.Name != (Object)null)
			{
				((Graphic)m.Name).color = markerColour;
			}
		}

		private static void Remove(Mark m)
		{
			if ((Object)(object)m.Root != (Object)null)
			{
				Object.Destroy((Object)(object)m.Root);
			}
			m.Root = null;
			m.Sprites.Clear();
			m.Name = null;
		}

		private static void Clear()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			int num = Marks.Count((Mark m) => (Object)(object)m.Root != (Object)null);
			foreach (Mark mark in Marks)
			{
				Remove(mark);
			}
			if (num > 0)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("map: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" taken off");
				}
				l.LogInfo(val);
			}
			Marks.Clear();
			_placed = false;
			_stopped = false;
		}

		private static CM_SyncedGUIItem Find(Level.Terminal t, out string how)
		{
			how = "no map data yet";
			Dictionary<uint, iCM_SyncedGUIObject> val = (((Object)(object)MapDataManager.Current != (Object)null) ? MapDataManager.Current.m_syncedGUIObjects : null);
			if (val == null)
			{
				return null;
			}
			LG_ComputerTerminalMapLookatRevealer mapLookatRevealer = t.T.m_mapLookatRevealer;
			uint num = (((Object)(object)mapLookatRevealer != (Object)null) ? ((LG_MapLookatRevealerBase)mapLookatRevealer).MapGUIObjID : 0u);
			how = (((Object)(object)mapLookatRevealer == (Object)null) ? "the terminal has no map revealer" : $"no map icon under its id {num} yet");
			if (num == 0 || !val.ContainsKey(num))
			{
				return null;
			}
			how = "by its id";
			iCM_SyncedGUIObject obj = val[num];
			if (obj == null)
			{
				return null;
			}
			return ((Il2CppObjectBase)obj).TryCast<CM_SyncedGUIItem>();
		}
	}
	internal static class Markers
	{
		private sealed class Mark
		{
			public Level.Terminal Terminal;

			public NavMarker Marker;

			public string Title;

			public bool Failed;
		}

		private static readonly List<Mark> Marks = new List<Mark>();

		private static bool _placed;

		private static bool _unknownSaid;

		private static int _logsVersion;

		private static int _settingsVersion;

		private static int _lobbyVersion;

		private static float _nextLook;

		public static void Update()
		{
			if (!Settings.Markers.On || !Level.Scanned)
			{
				if (_placed)
				{
					Clear();
				}
			}
			else if (!Logs.Known || Logs.Total == 0)
			{
				if (!_unknownSaid)
				{
					_unknownSaid = true;
					Plugin.L.LogWarning((object)"markers: in a level, but the logs read aren't known (the game not logged in to its server?)");
				}
			}
			else if (!_placed)
			{
				_placed = true;
				foreach (Level.Terminal terminal in Level.Terminals)
				{
					if (terminal.Files.Any(((uint Id, string File) f) => Logs.Counts(f.Id)))
					{
						Marks.Add(new Mark
						{
							Terminal = terminal
						});
					}
				}
				Refresh();
			}
			else if (_logsVersion != Logs.Version || _settingsVersion != Settings.Version || _lobbyVersion != Lobby.Version || Time.unscaledTime >= _nextLook)
			{
				Refresh();
			}
		}

		private static void Refresh()
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			_nextLook = Time.unscaledTime + 2f;
			_logsVersion = Logs.Version;
			_lobbyVersion = Lobby.Version;
			bool flag = _settingsVersion != Settings.Version;
			_settingsVersion = Settings.Version;
			bool others = Settings.OthersNeed.On && Lobby.Sharing;
			NavMarkerLayer navMarkerLayer = GuiManager.NavMarkerLayer;
			if (navMarkerLayer == null)
			{
				return;
			}
			bool flag2 = default(bool);
			foreach (Mark mark in Marks)
			{
				if (mark.Failed)
				{
					continue;
				}
				Level.Terminal t = mark.Terminal;
				List<(uint, string)> list = t.Files.Where(((uint Id, string File) f) => (!others) ? Logs.Needed(f.Id) : Logs.Wanted(f.Id)).ToList();
				if (list.Count == 0)
				{
					if (!((Object)(object)mark.Marker == (Object)null))
					{
						Remove(mark);
						ManualLogSource l = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("markers: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(t.Name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" in ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(t.Zone);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" read, its marker gone");
						}
						l.LogInfo(val);
					}
					continue;
				}
				string text = ((list.Count == 1) ? "LOG " : "LOGS ") + string.Join(", ", list.Select<(uint, string), string>(((uint Id, string File) f) => f.File + (t.Listed(f.File) ? "" : " not listed yet"))) + ((t.Zone.Length > 0) ? (" (" + t.Zone + ")") : "");
				if (others)
				{
					text = text + " for " + string.Join(", ", list.SelectMany<(uint, string), string>(((uint Id, string File) f) => Logs.Needing(f.Id)).Distinct());
				}
				if ((Object)(object)mark.Marker == (Object)null)
				{
					Place(mark, navMarkerLayer, text);
					continue;
				}
				if (text != mark.Title)
				{
					mark.Marker.SetTitle(text);
					mark.Title = text;
				}
				if (flag)
				{
					mark.Marker.SetColor(Settings.MarkerColour);
				}
			}
		}

		private static void Place(Mark m, NavMarkerLayer layer, string title)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			Level.Terminal terminal = m.Terminal;
			if ((Object)(object)terminal.T == (Object)null)
			{
				m.Failed = true;
				return;
			}
			Component terminalItemComp = terminal.T.m_terminalItemComp;
			GameObject val = (((Object)(object)terminalItemComp != (Object)null) ? terminalItemComp.gameObject : ((Component)terminal.T).gameObject);
			m.Marker = layer.PlaceCustomMarker((NavMarkerOption)8216, val, title, 0f, false);
			if ((Object)(object)m.Marker == (Object)null)
			{
				m.Failed = true;
				return;
			}
			m.Marker.SetVisualStates((NavMarkerOption)8192, (NavMarkerOption)8216, (NavMarkerOption)0, (NavMarkerOption)0);
			m.Marker.SetColor(Settings.MarkerColour);
			m.Title = title;
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(11, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("markers: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(terminal.Name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(title);
			}
			l.LogInfo(val2);
		}

		private static void Clear()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			int num = Marks.Count((Mark m) => (Object)(object)m.Marker != (Object)null);
			foreach (Mark mark in Marks)
			{
				Remove(mark);
			}
			if (num > 0)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("markers: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" taken away");
				}
				l.LogInfo(val);
			}
			Marks.Clear();
			_placed = false;
		}

		private static void Remove(Mark m)
		{
			NavMarkerLayer navMarkerLayer = GuiManager.NavMarkerLayer;
			if ((Object)(object)m.Marker != (Object)null && navMarkerLayer != null)
			{
				navMarkerLayer.RemoveMarker(m.Marker);
			}
			m.Marker = null;
		}
	}
	internal static class Menu
	{
		private sealed class Line
		{
			public TextMeshPro Text;

			public string Shown;

			public Vector3 At;
		}

		private const string Orange = "#E8963C";

		private const string Grey = "#8A9099";

		private const string ReadLabel = "READ LOGS";

		private static readonly Dictionary<IntPtr, Line> Lines = new Dictionary<IntPtr, Line>();

		private static float _next;

		private static bool _windowSaid;

		private static CM_Item _readButton;

		private static TextMeshPro _readText;

		public static ExpeditionInTierData LastExpedition { get; private set; }

		public static void Update()
		{
			if (!(Time.unscaledTime < _next))
			{
				_next = Time.unscaledTime + 0.25f;
				MainMenuGuiLayer current = MainMenuGuiLayer.Current;
				CM_PageRundown_New val = ((current != null) ? current.PageRundownNew : null);
				if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy)
				{
					bool flag = Logs.Known && Logs.Total > 0;
					bool flag2 = Settings.Counts.On && flag;
					Icons(val, flag2);
					Summary(val, flag2);
					Window(val, flag2);
					Selections(val, flag2);
					ReadButton(val, flag);
				}
			}
		}

		private static string Count(int read, int all)
		{
			return $"<color={((read < all) ? "#E8963C" : "#8A9099")}>{read}/{all}</color>";
		}

		private static string Badge(int read, int all)
		{
			if (all > 0 && (read < all || Settings.LevelsDone.On))
			{
				return $"<color={((read < all) ? "#E8963C" : "#8A9099")}>LOGS {read}/{all}</color>";
			}
			return null;
		}

		private static void Icons(CM_PageRundown_New page, bool on)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00d3: 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_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)
			List<CM_ExpeditionIcon_New> expIconsAll = page.m_expIconsAll;
			if (expIconsAll == null)
			{
				return;
			}
			for (int i = 0; i < expIconsAll.Count; i++)
			{
				CM_ExpeditionIcon_New val = expIconsAll[i];
				TextMeshPro val2 = (((Object)(object)val != (Object)null) ? val.m_statusText : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				string text = null;
				if (on && !val.IsHidden && !Written(val2))
				{
					(int Read, int All) tuple = Logs.Count(Logs.In(val.DataBlock));
					int item = tuple.Read;
					int item2 = tuple.All;
					text = Badge(item, item2);
				}
				Line line = Get((Il2CppObjectBase)(object)val, val2, val2.transform.parent, "expedition", text != null);
				if (line != null)
				{
					TextMeshPro hostingFriendsCountText = val.m_hostingFriendsCountText;
					Vector3 localPosition = val2.transform.localPosition;
					float num = (((Object)(object)hostingFriendsCountText != (Object)null) ? (localPosition.y - hostingFriendsCountText.transform.localPosition.y) : 0f);
					if (num < 5f)
					{
						num = 30f;
					}
					Set(line, text, new Vector3(localPosition.x, localPosition.y - num * (float)((!Showing(hostingFriendsCountText)) ? 1 : 2), localPosition.z));
				}
			}
		}

		private static void Summary(CM_PageRundown_New page, bool on)
		{
			//IL_00b4: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			CM_RundownTierMarker tierMarkerSectorSummary = page.m_tierMarkerSectorSummary;
			TextMeshPro val = (((Object)(object)tierMarkerSectorSummary != (Object)null) ? tierMarkerSectorSummary.m_header : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			string text = null;
			if (on && page.m_currentRundownData != null)
			{
				(int Read, int All) tuple = Logs.InRundown(((GameDataBlockBase<RundownDataBlock>)(object)page.m_currentRundownData).persistentID);
				int item = tuple.Read;
				int item2 = tuple.All;
				text = ((item2 > 0) ? ("LOGS " + Count(item, item2) + " IN THIS RUNDOWN, ") : "LOGS ") + Count(Logs.ReadCount, Logs.Total) + " IN ALL";
			}
			Line line = Get((Il2CppObjectBase)(object)tierMarkerSectorSummary, val, val.transform.parent, "rundown summary", text != null);
			if (line != null)
			{
				float num = ((TMP_Text)val).rectTransform.sizeDelta.y * val.transform.localScale.y * 0.8f;
				if (num < 5f)
				{
					num = 35f;
				}
				Set(line, text, val.transform.localPosition + new Vector3(0f, num, 0f));
			}
		}

		private static void Window(CM_PageRundown_New page, bool on)
		{
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: 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_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: 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_0363: Expected O, but got Unknown
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			CM_ExpeditionWindow expeditionWindow = page.m_expeditionWindow;
			TextMeshPro val = (((Object)(object)expeditionWindow != (Object)null) ? expeditionWindow.m_artifactHeatTitle : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool activeInHierarchy = ((Component)expeditionWindow).gameObject.activeInHierarchy;
			if (activeInHierarchy && expeditionWindow.m_data != null)
			{
				LastExpedition = expeditionWindow.m_data;
			}
			string text = null;
			if (on && activeInHierarchy)
			{
				List<Logs.Place> places = Logs.In(expeditionWindow.m_data);
				var (value, num) = Logs.Count(places);
				if (num > 0)
				{
					text = $"Logs: <color=yellow>{value} / {num}</color>   {MissingText(places)}";
					if (Settings.OthersNeed.On && Lobby.Sharing)
					{
						List<string> list = new List<string>();
						foreach (Lobby.Member other in Lobby.Others)
						{
							if (other.Read != null)
							{
								var (read, all) = Logs.Count(places, other.Read);
								list.Add(other.Name + " " + Count(read, all));
							}
						}
						text = text + "   " + string.Join(", ", list);
					}
				}
			}
			bool flag = Lines.ContainsKey(((Il2CppObjectBase)expeditionWindow).Pointer);
			Line line = Get((Il2CppObjectBase)(object)expeditionWindow, val, val.transform, "window", text != null);
			if (line == null)
			{
				return;
			}
			TextMeshPro text2 = line.Text;
			if (!flag)
			{
				((TMP_Text)text2).enableWordWrapping = false;
				((TMP_Text)text2).fontSizeMax = ((TMP_Text)text2).fontSize;
				((TMP_Text)text2).fontSizeMin = ((TMP_Text)text2).fontSize * 0.5f;
				((TMP_Text)text2).enableAutoSizing = true;
			}
			if (text == null)
			{
				Set(line, null, Vector3.zero);
				return;
			}
			RectTransform rectTransform = ((TMP_Text)val).rectTransform;
			RectTransform rectTransform2 = ((TMP_Text)text2).rectTransform;
			RectTransform val2 = (((Object)(object)val.transform.parent != (Object)null) ? ((Il2CppObjectBase)val.transform.parent).TryCast<RectTransform>() : null);
			float num2 = 0f - rectTransform.pivot.x;
			Rect rect = rectTransform.rect;
			float num3 = num2 * ((Rect)(ref rect)).width + ((TMP_Text)val).preferredWidth + 25f;
			float num4 = Math.Max(val.transform.localScale.x, 0.01f);
			float num5;
			if ((Object)(object)val2 != (Object)null)
			{
				rect = val2.rect;
				if (((Rect)(ref rect)).width > 100f)
				{
					rect = val2.rect;
					num5 = (((Rect)(ref rect)).xMax - 5f - val.transform.localPosition.x) / num4;
					goto IL_02d7;
				}
			}
			num5 = num3 + 330f;
			goto IL_02d7;
			IL_02d7:
			float num6 = Math.Max(num5 - num3, 100f);
			if (Math.Abs(rectTransform2.sizeDelta.x - num6) > 0.5f)
			{
				rectTransform2.sizeDelta = new Vector2(num6, rectTransform2.sizeDelta.y);
			}
			Set(line, text, new Vector3(num3 + rectTransform2.pivot.x * num6, 0f, 0f));
			if (_windowSaid)
			{
				return;
			}
			_windowSaid = true;
			ManualLogSource l = Plugin.L;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(82, 5, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("menu: the window's logs from x ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num3, "0");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" to ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num3 + num6, "0");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" beside the heat line (its part ");
				float num7;
				if (!((Object)(object)val2 != (Object)null))
				{
					num7 = 0f;
				}
				else
				{
					rect = val2.rect;
					num7 = ((Rect)(ref rect)).width;
				}
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num7, "0");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" wide), font ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(((TMP_Text)text2).fontSize, "0.#");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
			}
			l.LogInfo(val3);
		}

		private static string MissingText(List<Logs.Place> places)
		{
			List<string> list = new List<string>();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			HashSet<uint> hashSet = new HashSet<uint>();
			int result;
			foreach (Logs.Place place in places)
			{
				if (Logs.Needed(place.Id) && hashSet.Add(place.Id))
				{
					if (!dictionary.ContainsKey(place.Where))
					{
						dictionary[place.Where] = 0;
						list.Add(place.Where);
					}
					result = dictionary[place.Where]++;
				}
			}
			if (list.Count == 0)
			{
				return "all read";
			}
			StringBuilder stringBuilder = new StringBuilder("missing: ");
			string text = null;
			foreach (string item in list)
			{
				int num = item.LastIndexOf(' ');
				string text2 = ((num > 0) ? item.Substring(0, num) : item);
				string text3 = ((num > 0) ? item.Substring(num + 1) : "");
				int num2;
				if (num > 0)
				{
					num2 = (int.TryParse(text3, out result) ? 1 : 0);
					if (num2 != 0 && text2 == text)
					{
						stringBuilder.Append(", ").Append(text3);
						goto IL_015c;
					}
				}
				else
				{
					num2 = 0;
				}
				if (text != null)
				{
					stringBuilder.Append(", ");
				}
				stringBuilder.Append(item);
				goto IL_015c;
				IL_015c:
				if (dictionary[item] > 1)
				{
					stringBuilder.Append(" x").Append(dictionary[item]);
				}
				text = ((num2 != 0) ? text2 : null);
			}
			return stringBuilder.ToString();
		}

		private static void Selections(CM_PageRundown_New page, bool on)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0112: 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)
			List<CM_RundownSelection> rundownSelections = page.m_rundownSelections;
			if (rundownSelections == null)
			{
				return;
			}
			for (int i = 0; i < rundownSelections.Count; i++)
			{
				CM_RundownSelection val = rundownSelections[i];
				TextMeshPro val2 = (((Object)(object)val != (Object)null) ? val.m_hostingFriendsCountText : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				string text = null;
				if (on && !Written(val.m_rundownText) && RundownId(val.RundownKey, out var id))
				{
					(int Read, int All) tuple = Logs.InRundown(id);
					int item = tuple.Read;
					int item2 = tuple.All;
					text = Badge(item, item2);
				}
				Line line = Get((Il2CppObjectBase)(object)val, val2, val2.transform.parent, "rundown button", text != null);
				if (line != null)
				{
					TextMeshPro rundownText = val.m_rundownText;
					Vector3 localPosition = val2.transform.localPosition;
					float num = (((Object)(object)rundownText != (Object)null) ? (rundownText.transform.localPosition.y - localPosition.y) : 0f);
					if (num < 5f)
					{
						num = 22f;
					}
					Set(line, text, Showing(val2) ? (localPosition - new Vector3(0f, num, 0f)) : localPosition);
				}
			}
		}

		private static void ReadButton(CM_PageRundown_New page, bool on)
		{
			//IL_0069: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: 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_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			CM_Item[] array = (CM_Item[])(object)new CM_Item[3] { page.m_creditsButton, page.m_aboutTheRundownButton, page.m_discordButton };
			CM_Item val = null;
			CM_Item[] array2 = array;
			foreach (CM_Item val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null && ((Object)(object)val == (Object)null || ((Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)val).transform.parent && ((Component)val2).transform.localPosition.y > ((Component)val).transform.localPosition.y)))
				{
					val = val2;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)_readButton == (Object)null || ((Il2CppObjectBase)_readButton).WasCollected || (Object)(object)((Component)_readButton).transform.parent != (Object)(object)((Component)val).transform.parent)
			{
				if (!on)
				{
					return;
				}
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
				((Object)val3).name = "LogTracker read logs";
				_readButton = val3.GetComponent<CM_Item>();
				if ((Object)(object)_readButton == (Object)null)
				{
					Object.Destroy((Object)(object)val3);
					return;
				}
				_readButton.m_onBtnPress = new UnityEvent();
				_readButton.OnBtnPressCallback += DelegateSupport.ConvertDelegate<Action<int>>((Delegate)(Action<int>)delegate
				{
					Reader.Open();
				});
				_readText = val3.GetComponent<TextMeshPro>() ?? val3.GetComponentInChildren<TextMeshPro>();
				float num = 68f;
				array2 = array;
				foreach (CM_Item val4 in array2)
				{
					if (!((Object)(object)val4 == (Object)null) && !(((Il2CppObjectBase)val4).Pointer == ((Il2CppObjectBase)val).Pointer) && !((Object)(object)((Component)val4).transform.parent != (Object)(object)((Component)val).transform.parent))
					{
						float num2 = ((Component)val).transform.localPosition.y - ((Component)val4).transform.localPosition.y;
						if (num2 > 30f && num2 < num)
						{
							num = num2;
						}
					}
				}
				val3.transform.localPosition = ((Component)val).transform.localPosition + new Vector3(0f, num, 0f);
				_readButton.SetText("READ LOGS");
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(21, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("menu: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>("READ LOGS");
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" added, ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(num, "0");
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" above ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val).name);
				}
				l.LogInfo(val5);
			}
			bool flag2 = on && ((Component)val).gameObject.activeInHierarchy;
			if (((Component)_readButton).gameObject.activeSelf != flag2)
			{
				((Component)_readButton).gameObject.SetActive(flag2);
			}
			if (flag2 && (Object)(object)_readText != (Object)null && ((TMP_Text)_readText).text != "READ LOGS")
			{
				_readButton.SetText("READ LOGS");
			}
		}

		private static bool RundownId(string key, out uint id)
		{
			id = 0u;
			if (string.IsNullOrEmpty(key))
			{
				return false;
			}
			int num = key.LastIndexOf('_');
			return uint.TryParse((num >= 0) ? key.Substring(num + 1) : key, out id);
		}

		private static bool Showing(TextMeshPro t)
		{
			if ((Object)(object)t != (Object)null && ((Component)t).gameObject.activeInHierarchy)
			{
				return !string.IsNullOrWhiteSpace(((TMP_Text)t).text);
			}
			return false;
		}

		private static bool Written(TextMeshPro t)
		{
			if ((Object)(object)t != (Object)null && ((TMP_Text)t).text != null)
			{
				return ((TMP_Text)t).text.IndexOf("<br>", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}

		private static Line Get(Il2CppObjectBase owner, TextMeshPro like, Transform parent, string name, bool want)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (Lines.TryGetValue(owner.Pointer, out var value) && (Object)(object)value.Text != (Object)null && (Object)(object)value.Text.transform.parent == (Object)(object)parent)
			{
				return value;
			}
			if (!want)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)like).gameObject, parent);
			((Object)val).name = "LogTracker " + name;
			value = new Line
			{
				Text = val.GetComponent<TextMeshPro>(),
				At = new Vector3(float.NaN, 0f, 0f)
			};
			if ((Object)(object)value.Text == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			Lines[owner.Pointer] = value;
			return value;
		}

		private static void Set(Line line, string text, Vector3 at)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			TextMeshPro text2 = line.Text;
			bool flag = text != null;
			if (((Component)text2).gameObject.activeSelf != flag)
			{
				((Component)text2).gameObject.SetActive(flag);
			}
			if (flag)
			{
				if (line.At != at)
				{
					text2.transform.localPosition = at;
					line.At = at;
				}
				if (line.Shown != text)
				{
					((TMP_Text)text2).text = text;
					line.Shown = text;
				}
			}
		}
	}
	[BepInPlugin("mirr.LogTracker", "LogTracker", "0.9.0")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "mirr.LogTracker";

		public const string Name = "LogTracker";

		public const string Version = "0.9.0";

		internal static ManualLogSource L;

		public override void Load()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			L = ((BasePlugin)this).Log;
			string text = Path.Combine(Paths.ConfigPath, "LogTracker.cfg");
			string text2 = Path.Combine(Paths.ConfigPath, "GTFOLogTracker.cfg");
			bool flag = default(bool);
			if (!File.Exists(text) && File.Exists(text2))
			{
				try
				{
					File.Copy(text2, text);
					L.LogInfo((object)"settings: taken from GTFOLogTracker.cfg");
				}
				catch (Exception ex)
				{
					ManualLogSource l = L;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("settings: GTFOLogTracker.cfg not taken over: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					l.LogError(val);
				}
			}
			Settings.Init(new ConfigFile(text, true, new BepInPlugin("mirr.LogTracker", "LogTracker", "0.9.0")));
			((BasePlugin)this).AddComponent<Driver>();
			Harmony val2 = new Harmony("mirr.LogTracker");
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length == 0)
				{
					continue;
				}
				try
				{
					val2.CreateClassProcessor(type).Patch();
				}
				catch (Exception ex2)
				{
					ManualLogSource l2 = L;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("patch ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.FullName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
					}
					l2.LogError(val);
				}
			}
			ManualLogSource l3 = L;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(10, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("LogTracker");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("0.9.0");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" loaded: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(Settings.Summary);
			}
			l3.LogInfo(val3);
		}
	}
	public class Driver : MonoBehaviour
	{
		private static int _errors;

		public Driver(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			Run("settings", Settings.Update);
			Run("logs", Logs.Update);
			Run("lobby", Lobby.Update);
			Run("menu", Menu.Update);
			Run("reader", Reader.Update);
			Run("level", Level.Update);
			Run("markers", Markers.Update);
			Run("map", MapMarks.Update);
		}

		private static void Run(string part, Action update)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			try
			{
				update();
			}
			catch (Exception ex)
			{
				if (_errors++ < 10)
				{
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(2, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(part);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					l.LogError(val);
				}
			}
		}
	}
	internal static class Reader
	{
		private sealed class Entry
		{
			public uint Id;

			public IntPtr Expedition;

			public string Name;

			public string Where;

			public string File;
		}

		private const int MaxChars = 20000;

		private const float FootHeight = 64f;

		private const string Grey = "#8A9099";

		private const string Keys = "Pages: left/right (D-pad, arrow keys, mouse wheel)     Logs: up/down or the bumpers     Close: B, Esc or the X";

		private static readonly List<Entry> Entries = new List<Entry>();

		private static CM_GlobalPopup _popup;

		private static TextMeshPro _head;

		private static TextMeshPro _body;

		private static TextMeshPro _foot;

		private static int _index;

		private static int _page = 1;

		private static int _pages = 1;

		private static int _unread;

		private static string _scope = "";

		public static void Open()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			try
			{
				Show();
			}
			catch (Exception ex)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(8, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("reader: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				l.LogError(val);
			}
		}

		private static void Show()
		{
			//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_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_0054: 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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			if (Showing(out var layer))
			{
				return;
			}
			if (layer != null && (Object)(object)layer.Popup != (Object)null)
			{
				Plugin.L.LogInfo((object)"reader: another popup is showing; not opened");
				return;
			}
			Collect();
			CM_GlobalPopup val = GlobalPopupMessageManager.ShowPopup(new PopupMessage
			{
				PopupType = (PopupType)0,
				BlinkInContent = false,
				BlinkTimeInterval = 0f,
				Header = "LOGS READ",
				UpperText = " ",
				LowerText = " ",
				OnCloseCallback = DelegateSupport.ConvertDelegate<Action>((Delegate)(Action)delegate
				{
				})
			});
			if ((Object)(object)val == (Object)null && layer != null)
			{
				val = layer.Popup;
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.L.LogWarning((object)"reader: the game's popup didn't open");
				return;
			}
			_popup = val;
			_head = val.m_headerText;
			_body = val.m_upperText;
			_foot = val.m_lowerText;
			if ((Object)(object)_head == (Object)null || (Object)(object)_body == (Object)null || (Object)(object)_foot == (Object)null)
			{
				_popup = null;
				Plugin.L.LogWarning((object)"reader: the popup has no texts");
				return;
			}
			Layout();
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("reader: opened on ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(_scope);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(Entries.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" logs read, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_unread);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" not");
			}
			l.LogInfo(val2);
			if (Entries.Count == 0)
			{
				Empty();
				return;
			}
			ExpeditionInTierData last = Menu.LastExpedition;
			Go(Math.Max((last != null) ? Entries.FindIndex((Entry x) => x.Expedition == ((Il2CppObjectBase)last).Pointer) : (-1), 0), lastPage: false);
		}

		private static void Collect()
		{
			Entries.Clear();
			_unread = 0;
			CM_PageRundown_New val = ((MainMenuGuiLayer.Current != null) ? MainMenuGuiLayer.Current.PageRundownNew : null);
			RundownDataBlock val2 = (((Object)(object)val != (Object)null) ? val.m_currentRundownData : null);
			List<uint> obj = ((val2 != null) ? new List<uint> { ((GameDataBlockBase<RundownDataBlock>)(object)val2).persistentID } : Logs.RundownIds());
			_scope = ((val2 != null) ? Logs.ShortName(((GameDataBlockBase<RundownDataBlock>)(object)val2).persistentID) : "all rundowns");
			HashSet<uint> hashSet = new HashSet<uint>();
			foreach (uint item in obj)
			{
				foreach (var (val3, name) in Logs.Expeditions(item))
				{
					foreach (Logs.Place item2 in Logs.In(val3))
					{
						if (hashSet.Add(item2.Id))
						{
							if (!Logs.IsRead(item2.Id))
							{
								_unread++;
								continue;
							}
							Entries.Add(new Entry
							{
								Id = item2.Id,
								Expedition = ((Il2CppObjectBase)val3).Pointer,
								Name = name,
								Where = item2.Where,
								File = item2.File
							});
						}
					}
				}
			}
		}

		private static void Layout()
		{
			RectTransform rectTransform = ((TMP_Text)_body).rectTransform;
			RectTransform rectTransform2 = ((TMP_Text)_foot).rectTransform;
			float num = Math.Max(Top(rectTransform), Top(rectTransform2));
			float num2 = Math.Min(Bottom(rectTransform), Bottom(rectTransform2));
			if (num - num2 > 200f)
			{
				Span(rectTransform, num, num2 + 64f + 8f);
				Span(rectTransform2, num2 + 64f, num2);
			}
			((TMP_Text)_body).enableAutoSizing = false;
			((TMP_Text)_body).fontSize = Mathf.Clamp(((TMP_Text)_body).fontSize, 16f, 22f);
			((TMP_Text)_body).enableWordWrapping = true;
			((TMP_Text)_body).overflowMode = (TextOverflowModes)5;
			((TMP_Text)_body).alignment = (TextAlignmentOptions)257;
			((TMP_Text)_foot).fontSizeMax = Mathf.Clamp(((TMP_Text)_foot).fontSize, 12f, 18f);
			((TMP_Text)_foot).fontSizeMin = 10f;
			((TMP_Text)_foot).enableAutoSizing = true;
			((TMP_Text)_foot).enableWordWrapping = true;
			((TMP_Text)_foot).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_foot).alignment = (TextAlignmentOptions)1025;
			((TMP_Text)_head).enableWordWrapping = false;
			((TMP_Text)_head).overflowMode = (TextOverflowModes)0;
		}

		private static float Top(RectTransform r)
		{
			//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			float y = ((Transform)r).localPosition.y;
			Rect rect = r.rect;
			return y + ((Rect)(ref rect)).yMax * ((Transform)r).localScale.y;
		}

		private static float Bottom(RectTransform r)
		{
			//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			float y = ((Transform)r).localPosition.y;
			Rect rect = r.rect;
			return y + ((Rect)(ref rect)).yMin * ((Transform)r).localScale.y;
		}

		private static void Span(RectTransform r, float top, float bottom)
		{
			//IL_0004: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0048: 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_0052: 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)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			float num = (top - bottom) / ((Transform)r).localScale.y;
			float x = r.sizeDelta.x;
			float y = r.sizeDelta.y;
			Rect rect = r.rect;
			r.sizeDelta = new Vector2(x, y + (num - ((Rect)(ref rect)).height));
			Vector3 localPosition = ((Transform)r).localPosition;
			((Transform)r).localPosition = new Vector3(localPosition.x, bottom + r.pivot.y * num * ((Transform)r).localScale.y, localPosition.z);
		}

		private static void Empty()
		{
			((TMP_Text)_body).text = ((_unread > 0) ? $"None of the {_unread} achievement logs of {_scope} is read yet.\n\nIn a level, LOGS at any terminal lists where the level's are." : (_scope + " has no achievement logs."));
			((TMP_Text)_body).pageToDisplay = 1;
			((TMP_Text)_foot).text = "<color=#8A9099>Close: B, Esc or the X</color>";
		}

		private static void Go(int index, bool lastPage)
		{
			if (index >= 0 && index < Entries.Count)
			{
				_index = index;
				Entry entry = Entries[index];
				((TMP_Text)_head).text = entry.Name + "  LOG " + entry.File;
				((TMP_Text)_body).text = TextOf(entry.Id);
				((TMP_Text)_body).pageToDisplay = 1;
				((TMP_Text)_body).ForceMeshUpdate(false, false);
				_pages = Math.Max(1, (((TMP_Text)_body).textInfo == null) ? 1 : ((TMP_Text)_body).textInfo.pageCount);
				Turn((!lastPage) ? 1 : _pages);
			}
		}

		private static void Turn(int page)
		{
			_page = Math.Max(1, Math.Min(page, _pages));
			((TMP_Text)_body).pageToDisplay = _page;
			Entry entry = Entries[_index];
			((TMP_Text)_foot).text = $"{entry.Name}, {entry.Where}   -   log {_index + 1} of {Entries.Count} read in {_scope}" + ((_unread > 0) ? $" ({_unread} not read yet)" : "") + $"   -   page {_page} of {_pages}\n<color={"#8A9099"}>{"Pages: left/right (D-pad, arrow keys, mouse wheel)     Logs: up/down or the bumpers     Close: B, Esc or the X"}</color>";
		}

		private static string TextOf(uint id)
		{
			string text = null;
			try
			{
				text = Text.Get(id);
			}
			catch
			{
			}
			if (string.IsNullOrWhiteSpace(text) && GameDataBlockBase<TextDataBlock>.HasBlock(id))
			{
				TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock(id);
				text = ((block != null) ? block.English : null);
			}
			if (string.IsNullOrWhiteSpace(text))
			{
				return "<color=#8A9099>(this log's text wasn't found)</color>";
			}
			if (text.Length <= 20000)
			{
				return text;
			}
			int num = text.LastIndexOf('\n', 20000);
			if (num < 10000)
			{
				num = 20000;
			}
			return text.Substring(0, num) + $"\n\n<color={"#8A9099"}>[the other {text.Length - num:N0} characters of this log are left out]</color>";
		}

		private static bool Showing(out GlobalPopupMessageGuiLayer layer)
		{
			layer = GuiManager.GlobalPopupMessageLayer;
			if (_popup == null)
			{
				return false;
			}
			CM_GlobalPopup val = ((layer != null) ? layer.Popup : null);
			if ((Object)(object)_popup != (Object)null && ((Component)_popup).gameObject.activeInHierarchy && (Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)_popup).Pointer)
			{
				return true;
			}
			_popup = null;
			Plugin.L.LogInfo((object)"reader: closed");
			return false;
		}

		public static void Update()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (_popup == null || !Showing(out var _))
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			bool flag = Input.GetKeyDown((KeyCode)27);
			if (Input.GetKeyDown((KeyCode)275) || Input.GetKeyDown((KeyCode)100) || Input.GetKeyDown((KeyCode)281))
			{
				num = 1;
			}
			if (Input.GetKeyDown((KeyCode)276) || Input.GetKeyDown((KeyCode)97) || Input.GetKeyDown((KeyCode)280))
			{
				num = -1;
			}
			if (Input.GetKeyDown((KeyCode)274) || Input.GetKeyDown((KeyCode)115))
			{
				num2 = 1;
			}
			if (Input.GetKeyDown((KeyCode)273) || Input.GetKeyDown((KeyCode)119))
			{
				num2 = -1;
			}
			float y = Input.mouseScrollDelta.y;
			if (y < -0.01f)
			{
				num = 1;
			}
			else if (y > 0.01f)
			{
				num = -1;
			}
			ReadOnlyCollection<InputDevice> devices = InputManager.Devices;
			if (devices != null)
			{
				for (int i = 0; i < devices.Count; i++)
				{
					InputDevice val = devices[i];
					if (val != null)
					{
						if (((OneAxisInputControl)val.DPadRight).WasPressed)
						{
							num = 1;
						}
						if (((OneAxisInputControl)val.DPadLeft).WasPressed)
						{
							num = -1;
						}
						if (((OneAxisInputControl)val.DPadDown).WasPressed || ((OneAxisInputControl)val.RightBumper).WasPressed)
						{
							num2 = 1;
						}
						if (((OneAxisInputControl)val.DPadUp).WasPressed || ((OneAxisInputControl)val.LeftBumper).WasPressed)
						{
							num2 = -1;
						}
						if (((OneAxisInputControl)val.Action2).WasPressed)
						{
							flag = true;
						}
					}
				}
			}
			if (flag)
			{
				GlobalPopupMessageManager.HidePopup();
			}
			else
			{
				if (Entries.Count == 0)
				{
					return;
				}
				if (num2 != 0)
				{
					Go(_index + num2, lastPage: false);
				}
				else if (num > 0)
				{
					if (_page < _pages)
					{
						Turn(_page + 1);
					}
					else
					{
						Go(_index + 1, lastPage: false);
					}
				}
				else if (num < 0)
				{
					if (_page > 1)
					{
						Turn(_page - 1);
					}
					else
					{
						Go(_index - 1, lastPage: true);
					}
				}
			}
		}
	}
	internal sealed class Switch
	{
		public readonly string Section;

		public readonly string Key;

		public readonly string Title;

		public readonly string Help;

		public readonly bool Default;

		public ConfigEntry<bool> Entry;

		public bool On => Entry?.Value ?? Default;

		public Switch(string section, string key, string title, string help, bool on = true)
		{
			Section = section;
			Key = key;
			Title = title;
			Help = help;
			Default = on;
		}
	}
	internal static class Settings
	{
		public static readonly Switch Markers = new Switch("Markers", "Terminals", "Markers on log terminals", "In a level: a marker on every terminal that holds an achievement log still needed. Look at it for the log's file name, its zone and the distance. It goes once the log is read. Off by default: the map shows them too.", on: false);

		public static readonly Switch OnMap = new Switch("Map", "Log terminals", "Log terminals on map", "In a level: on the map, every terminal that holds an achievement log still needed, in the markers' colour with its name, from the start: also where nobody has explored yet. It goes once the log is read.");

		public static readonly Switch OthersNeed = new Switch("Lobby", "Logs others need", "Logs others with LogTracker need", "Only with players who have LogTracker too: you see which logs they still need, with their names (on the map, the markers, under LOGS, in the expedition window), and they see yours. A log read by anyone counts for everyone in the lobby.");

		public static readonly Switch UnderLogs = new Switch("Terminal", "Needed logs under LOGS", "LOGS command", "The terminal command LOGS also lists the achievement logs still needed in the level: the file to READ, its terminal and zone. Then how many achievement logs you have read. Only on your own screen.");

		public static readonly Switch StartScreens = new Switch("Terminal", "Needed logs on start screens", "TERMINAL OS screen", "The TERMINAL OS screen a terminal starts with (Welcome to TERMINAL_...) also says how many achievement logs are still needed in the level and how many of them are in that terminal, as when the screen was written; LOGS lists them as they are now.");

		public static readonly Switch Counts = new Switch("Rundown page", "Counts", "Log counts on rundown page", "On the rundown page: under each expedition how many of its achievement logs you have read (LOGS 1/3), the rundown's and all rundowns' totals, and in an expedition's window the zones where logs are still missing.");

		public static readonly Switch LevelsDone = new Switch("Rundown page", "Levels done", "Counts of finished levels", "Expeditions whose logs you have all read show their count too, in grey. Off: only expeditions with a log still missing show one.");

		public static readonly Switch[] All = new Switch[7] { Markers, OnMap, OthersNeed, UnderLogs, StartScreens, Counts, LevelsDone };

		private const string GreenHex = "#5CE1A6";

		private static ConfigEntry<string> _colour;

		private static ConfigFile _file;

		private static DateTime _written;

		private static float _lookAt;

		public static int Version { get; private set; }

		public static Color MarkerColour { get; private set; }

		public static string MarkerHex { get; private set; }

		public static string Summary => string.Join(", ", All.Select((Switch s) => s.Title + " " + (s.On ? "on" : "off"))) + ", marker colour " + MarkerHex;

		public static void Init(ConfigFile file)
		{
			_file = file;
			Switch[] all = All;
			foreach (Switch obj in all)
			{
				obj.Entry = file.Bind<bool>(obj.Section, obj.Key, obj.Default, obj.Help);
			}
			_colour = file.Bind<string>("Markers", "Colour", "#5CE1A6", "The markers' colour, as #RRGGBB, also the log terminals' on the map. Green by default, apart from the players' ping colours.");
			Changed();
			_written = Written();
		}

		public static void Set(Switch s, bool on)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			s.Entry.Value = on;
			_written = Written();
			Changed();
			ManualLogSource l = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("settings: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(s.Title);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(on ? "on" : "off");
			}
			l.LogInfo(val);
		}

		public static void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			if (Time.unscaledTime < _lookAt)
			{
				return;
			}
			_lookAt = Time.unscaledTime + 1f;
			DateTime dateTime = Written();
			if (dateTime == _written)
			{
				return;
			}
			bool saveOnConfigSet = _file.SaveOnConfigSet;
			_file.SaveOnConfigSet = false;
			bool flag = default(bool);
			try
			{
				_file.Reload();
				_written = dateTime;
				Changed();
				ManualLogSource l = Plugin.L;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("settings read again: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Summary);
				}
				l.LogInfo(val);
			}
			catch (IOException)
			{
			}
			catch (Exception ex2)
			{
				_written = dateTime;
				ManualLogSource l2 = Plugin.L;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(10, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("settings: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
				}
				l2.LogWarning(val2);
			}
			finally
			{
				_file.SaveOnConfigSet = saveOnConfigSet;
			}
		}

		private static void Changed()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			string text = (_colour.Value ?? "").Trim().ToUpperInvariant();
			if (!text.StartsWith("#"))
			{
				text = "#" + text;
			}
			Color markerColour = default(Color);
			if (text.Length != 7 || !ColorUtility.TryParseHtmlString(text, ref markerColour))
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("settings: Colour '");
					((BepInExLogInterpolatedStringHandler)val).Appen