Decompiled source of MrovLib v0.2.11

MrovLib.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using MrovLib.Compatibility;
using MrovLib.Events;
using OldLLLLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("MrovLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Common methods for my mods.")]
[assembly: AssemblyFileVersion("0.2.11.0")]
[assembly: AssemblyInformationalVersion("0.2.11+5e9992de5035f4c322a867257eff0b2b754c9933")]
[assembly: AssemblyProduct("MrovLib")]
[assembly: AssemblyTitle("MrovLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ConsoleTables
{
	public class ConsoleTable
	{
		public static readonly HashSet<Type> NumericTypes = new HashSet<Type>
		{
			typeof(int),
			typeof(double),
			typeof(decimal),
			typeof(long),
			typeof(short),
			typeof(sbyte),
			typeof(byte),
			typeof(ulong),
			typeof(ushort),
			typeof(uint),
			typeof(float)
		};

		public IList<object> Columns { get; }

		public IList<object[]> Rows { get; }

		public ConsoleTableOptions Options { get; }

		public Type[] ColumnTypes { get; private set; }

		public IList<string> Formats { get; private set; }

		public ConsoleTable(params string[] columns)
			: this(new ConsoleTableOptions
			{
				Columns = new List<string>(columns)
			})
		{
		}

		public ConsoleTable(ConsoleTableOptions options)
		{
			Options = options ?? throw new ArgumentNullException("options");
			Rows = new List<object[]>();
			Columns = new List<object>(options.Columns);
		}

		public ConsoleTable AddColumn(IEnumerable<string> names)
		{
			foreach (string name in names)
			{
				Columns.Add(name);
			}
			return this;
		}

		public ConsoleTable AddRow(params object[] values)
		{
			if (values == null)
			{
				throw new ArgumentNullException("values");
			}
			if (!Columns.Any())
			{
				throw new Exception("Please set the columns first");
			}
			if (Columns.Count != values.Length)
			{
				throw new Exception($"The number columns in the row ({Columns.Count}) does not match the values ({values.Length})");
			}
			Rows.Add(values);
			return this;
		}

		public ConsoleTable Configure(Action<ConsoleTableOptions> action)
		{
			action(Options);
			return this;
		}

		public static ConsoleTable FromDictionary(Dictionary<string, Dictionary<string, object>> values)
		{
			ConsoleTable consoleTable = new ConsoleTable();
			List<string> list = values.SelectMany((KeyValuePair<string, Dictionary<string, object>> x) => x.Value.Keys).Distinct().ToList();
			list.Insert(0, "");
			consoleTable.AddColumn(list);
			foreach (KeyValuePair<string, Dictionary<string, object>> value2 in values)
			{
				List<object> list2 = new List<object> { value2.Key };
				foreach (string item in list.Skip(1))
				{
					list2.Add(value2.Value.TryGetValue(item, out var value) ? value : "");
				}
				consoleTable.AddRow(list2.Cast<object>().ToArray());
			}
			return consoleTable;
		}

		public static ConsoleTable From<T>(IEnumerable<T> values)
		{
			ConsoleTable consoleTable = new ConsoleTable
			{
				ColumnTypes = GetColumnsType<T>().ToArray()
			};
			List<string> columns = GetColumns<T>().ToList();
			consoleTable.AddColumn(columns);
			foreach (IEnumerable<object> item in values.Select((T value) => columns.Select((string column) => GetColumnValue<T>(value, column))))
			{
				consoleTable.AddRow(item.ToArray());
			}
			return consoleTable;
		}

		public static ConsoleTable From(DataTable dataTable)
		{
			ConsoleTable consoleTable = new ConsoleTable();
			List<string> names = (from DataColumn x in dataTable.Columns
				select x.ColumnName).ToList();
			consoleTable.AddColumn(names);
			foreach (DataRow row in dataTable.Rows)
			{
				string[] array = row.ItemArray.Select((object x) => (!(x is byte[] inArray)) ? x.ToString() : Convert.ToBase64String(inArray)).ToArray();
				object[] values = array;
				consoleTable.AddRow(values);
			}
			return consoleTable;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			List<int> columnLengths = ColumnLengths();
			List<string> columnAlignment = Enumerable.Range(0, Columns.Count).Select(GetNumberAlignment).ToList();
			string format = (from i in Enumerable.Range(0, Columns.Count)
				select " | {" + i + "," + columnAlignment[i] + columnLengths[i] + "}").Aggregate((string s, string a) => s + a) + " |";
			SetFormats(ColumnLengths(), columnAlignment);
			int val = Math.Max(0, Rows.Any() ? Rows.Max((object[] row) => string.Format(format, row).Length) : 0);
			string text = string.Format(Formats[0], Columns.ToArray());
			int num = Math.Max(val, text.Length);
			List<string> list = Rows.Select((object[] row, int i) => string.Format(Formats[i + 1], row)).ToList();
			string value = " " + string.Join("", Enumerable.Repeat("-", num - 1)) + " ";
			stringBuilder.AppendLine(value);
			stringBuilder.AppendLine(text);
			foreach (string item in list)
			{
				stringBuilder.AppendLine(value);
				stringBuilder.AppendLine(item);
			}
			stringBuilder.AppendLine(value);
			if (Options.EnableCount)
			{
				stringBuilder.AppendLine("");
				stringBuilder.AppendFormat(" Count: {0}", Rows.Count);
			}
			return stringBuilder.ToString();
		}

		private void SetFormats(List<int> columnLengths, List<string> columnAlignment)
		{
			List<object[]> list = new List<object[]>();
			list.Add(Columns.ToArray());
			list.AddRange(Rows);
			Formats = list.Select((object[] d) => Enumerable.Range(0, Columns.Count).Select(delegate(int i)
			{
				string text = d[i]?.ToString() ?? "";
				int num = columnLengths[i] - (GetTextWidth(text) - text.Length);
				return " | {" + i + "," + columnAlignment[i] + num + "}";
			}).Aggregate((string s, string a) => s + a) + " |").ToList();
		}

		public static int GetTextWidth(string value)
		{
			return value?.ToCharArray().Sum((char c) => (c <= '\u007f') ? 1 : 2) ?? 0;
		}

		public string ToMarkDownString()
		{
			return ToMarkDownString('|');
		}

		private string ToMarkDownString(char delimiter)
		{
			StringBuilder builder = new StringBuilder();
			List<int> columnLengths = ColumnLengths();
			Format(columnLengths, delimiter);
			string text = string.Format(Formats[0].TrimStart(), Columns.ToArray());
			List<string> list = Rows.Select((object[] row, int i) => string.Format(Formats[i + 1].TrimStart(), row)).ToList();
			string value = Regex.Replace(text, "[^|]", "-");
			builder.AppendLine(text);
			builder.AppendLine(value);
			list.ForEach(delegate(string row)
			{
				builder.AppendLine(row);
			});
			return builder.ToString();
		}

		public string ToMinimalString()
		{
			return ToMarkDownString('\0');
		}

		public string ToStringAlternative()
		{
			StringBuilder stringBuilder = new StringBuilder();
			string text = string.Format(Formats[0].TrimStart(), Columns.ToArray());
			List<string> list = Rows.Select((object[] row, int i) => string.Format(Formats[i + 1].TrimStart(), row)).ToList();
			string value = Regex.Replace(text, "[^| ]", "-").Replace("|", "+");
			stringBuilder.AppendLine(value);
			stringBuilder.AppendLine(text);
			foreach (string item in list)
			{
				stringBuilder.AppendLine(value);
				stringBuilder.AppendLine(item);
			}
			stringBuilder.AppendLine(value);
			return stringBuilder.ToString();
		}

		public string ToStringCustomDecoration(bool header = false, bool divider = false, bool separator = false)
		{
			StringBuilder builder = new StringBuilder();
			List<int> columnLengths = ColumnLengths();
			Format(columnLengths, '\0');
			string text = string.Format(Formats[0].TrimStart(), Columns.ToArray());
			List<string> list = Rows.Select((object[] row, int i) => string.Format(separator ? Formats[i + 1].TrimStart() : Formats[i + 1].TrimStart().Replace("|", ""), row)).ToList();
			string text2 = Regex.Replace(text, "[^|]", "-");
			if (header)
			{
				builder.AppendLine(text.Replace("|", separator ? "|" : ""));
			}
			if (divider)
			{
				if (separator)
				{
					builder.AppendLine(text2);
				}
				else
				{
					builder.AppendLine(Regex.Replace(text2, "[|-]", ""));
				}
			}
			list.ForEach(delegate(string row)
			{
				builder.AppendLine(row);
			});
			return builder.ToString();
		}

		private string Format(List<int> columnLengths, char delimiter = '|')
		{
			List<string> columnAlignment = Enumerable.Range(0, Columns.Count).Select(GetNumberAlignment).ToList();
			SetFormats(columnLengths, columnAlignment);
			string delimiterStr = ((delimiter == '\0') ? string.Empty : delimiter.ToString());
			return ((from i in Enumerable.Range(0, Columns.Count)
				select " " + delimiterStr + " {" + i + "," + columnAlignment[i] + columnLengths[i] + "}").Aggregate((string s, string a) => s + a) + " " + delimiterStr).Trim();
		}

		private string GetNumberAlignment(int i)
		{
			if (Options.NumberAlignment != Alignment.Right || ColumnTypes == null || !NumericTypes.Contains(ColumnTypes[i]))
			{
				return "-";
			}
			return "";
		}

		private List<int> ColumnLengths()
		{
			return Columns.Select((object t, int i) => (from x in Rows.Select((object[] x) => x[i]).Union(new object[1] { Columns[i] })
				where x != null
				select x.ToString().ToCharArray().Sum((char c) => (c <= '\u007f') ? 1 : 2)).Max()).ToList();
		}

		public void Write(Format format = ConsoleTables.Format.Default)
		{
			SetFormats(ColumnLengths(), Enumerable.Range(0, Columns.Count).Select(GetNumberAlignment).ToList());
			switch (format)
			{
			case ConsoleTables.Format.Default:
				Options.OutputTo.WriteLine(ToString());
				break;
			case ConsoleTables.Format.MarkDown:
				Options.OutputTo.WriteLine(ToMarkDownString());
				break;
			case ConsoleTables.Format.Alternative:
				Options.OutputTo.WriteLine(ToStringAlternative());
				break;
			case ConsoleTables.Format.Minimal:
				Options.OutputTo.WriteLine(ToMinimalString());
				break;
			default:
				throw new ArgumentOutOfRangeException("format", format, null);
			}
		}

		private static IEnumerable<string> GetColumns<T>()
		{
			return (from x in typeof(T).GetProperties()
				select x.Name).ToArray();
		}

		private static object GetColumnValue<T>(object target, string column)
		{
			return typeof(T).GetProperty(column)?.GetValue(target, null);
		}

		private static IEnumerable<Type> GetColumnsType<T>()
		{
			return (from x in typeof(T).GetProperties()
				select x.PropertyType).ToArray();
		}
	}
	public class ConsoleTableOptions
	{
		public IEnumerable<string> Columns { get; set; } = new List<string>();


		public bool EnableCount { get; set; } = true;


		public Alignment NumberAlignment { get; set; }

		public TextWriter OutputTo { get; set; } = Console.Out;

	}
	public enum Format
	{
		Default,
		MarkDown,
		Alternative,
		Minimal
	}
	public enum Alignment
	{
		Left,
		Right
	}
}
namespace MrovLib
{
	public abstract class ConfigHandler<T, CT>
	{
		public virtual ConfigEntry<CT> ConfigEntry { get; set; }

		public virtual CT DefaultValue { get; set; }

		public abstract T Value { get; }
	}
	public class ConfigManager
	{
		public static ConfigFile configFile;

		public static ConfigManager Instance { get; internal set; }

		public virtual void Init(ConfigFile config)
		{
			Instance = new ConfigManager(config);
		}

		public ConfigManager(ConfigFile config)
		{
			configFile = config;
		}
	}
	public class Defaults
	{
		public static readonly List<string> VanillaLevels = new List<string>(13)
		{
			"Gordion", "Experimentation", "Assurance", "Vow", "March", "Offense", "Adamance", "Rend", "Dine", "Titan",
			"Liquidation", "Embrion", "Artifice"
		};

		public static readonly string CompanyLevel = "Gordion";

		public static readonly List<LevelWeatherType> VanillaWeathers = new List<LevelWeatherType>(7)
		{
			(LevelWeatherType)(-1),
			(LevelWeatherType)0,
			(LevelWeatherType)3,
			(LevelWeatherType)1,
			(LevelWeatherType)2,
			(LevelWeatherType)4,
			(LevelWeatherType)5
		};

		public static bool IsVanillaLevel(SelectableLevel level)
		{
			return VanillaLevels.Select((string l) => l.ToLowerInvariant()).Contains(StringResolver.GetNumberlessName(level).ToLowerInvariant());
		}
	}
	public static class EventManager
	{
		public static CustomEvent<Terminal> TerminalStart = new CustomEvent<Terminal>();

		public static CustomEvent<StartOfRound> LobbyDisabled = new CustomEvent<StartOfRound>();
	}
	public static class LevelHelper
	{
		public static List<SelectableLevel> Levels { get; private set; }

		public static List<SelectableLevel> SortedLevels { get; private set; }

		public static SelectableLevel CompanyMoon { get; private set; }

		public static void Populate()
		{
			Levels = StartOfRound.Instance.levels.ToList();
			CompanyMoon = ((IEnumerable<SelectableLevel>)Levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel level) => StringResolver.GetNumberlessName(level) == Defaults.CompanyLevel));
			SortedLevels = Levels.ToList();
			SortedLevels.Sort((SelectableLevel a, SelectableLevel b) => StringResolver.GetNumberlessName(a).CompareTo(StringResolver.GetNumberlessName(b)));
		}

		public static void Reset(StartOfRound startOfRound)
		{
			Plugin.LogDebug("LevelHelper.Reset called");
			Levels = null;
			SortedLevels = null;
			CompanyMoon = null;
		}
	}
	public class Logger
	{
		private ManualLogSource LogSource = Logger.CreateLogSource(name);

		private ConfigEntry<bool> ConfigEntry = enabled ?? Plugin.DebugLogging;

		public Logger(string name, ConfigEntry<bool> enabled = null)
		{
		}

		public void Log(LogLevel level, object data)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigEntry.Value)
			{
				LogSource.Log(level, data);
			}
		}

		public void LogInfo(object data)
		{
			Log((LogLevel)16, data);
		}

		public void LogWarning(object data)
		{
			Log((LogLevel)4, data);
		}

		public void LogError(object data)
		{
			Log((LogLevel)2, data);
		}

		public void LogDebug(object data)
		{
			Log((LogLevel)32, data);
		}

		public void LogFatal(object data)
		{
			Log((LogLevel)1, data);
		}

		public void LogMessage(object data)
		{
			Log((LogLevel)8, data);
		}
	}
	public static class PlanetChecker
	{
		public static List<string> duplicates = new List<string>();

		public static bool ContainsRepeats => duplicates.Count > 0;

		public static void CheckRepeatingPlanetNames()
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			ResolverCache<bool> resolverCache = new ResolverCache<bool>();
			SelectableLevel[] array = levels;
			foreach (SelectableLevel val in array)
			{
				if (resolverCache.Contains(val.PlanetName))
				{
					Plugin.logger.LogWarning((object)("Duplicate planet name: " + val.PlanetName));
					duplicates.Add(val.PlanetName);
				}
				resolverCache.Add(val.PlanetName, value: true);
			}
		}
	}
	[BepInPlugin("MrovLib", "MrovLib", "0.2.11")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource logger;

		internal static Logger DebugLogger;

		internal static Harmony harmony = new Harmony("MrovLib");

		internal static ConfigEntry<bool> DebugLogging;

		public static LLL LLL;

		public static LLLOldPlugin LLLOldPlugin;

		public static WeatherTweaks WeatherTweaks;

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			LocalConfigManager.Init(((BaseUnityPlugin)this).Config);
			DebugLogger = new Logger("MrovLib", DebugLogging);
			LLL = new LLL("imabatby.lethallevelloader", "1.2.0.0");
			LLLOldPlugin = new LLLOldPlugin("OldLLLLib");
			WeatherTweaks = new WeatherTweaks("WeatherTweaks");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MrovLib is loaded!");
			DebugLogger.LogWarning("Debug logs enabled!");
			EventManager.LobbyDisabled.AddListener(StringResolver.Reset);
			EventManager.LobbyDisabled.AddListener(LevelHelper.Reset);
		}

		internal static void LogDebug(string log)
		{
			DebugLogger.LogDebug(log);
		}
	}
	internal class LocalConfigManager : ConfigManager
	{
		public static ConfigEntry<bool> Debug { get; private set; }

		private LocalConfigManager(ConfigFile config)
			: base(config)
		{
			Debug = ConfigManager.configFile.Bind<bool>("General", "Debug", false, "Enable debug logging");
			Plugin.DebugLogging = Debug;
		}

		public new static void Init(ConfigFile config)
		{
			ConfigManager.Instance = new LocalConfigManager(config);
		}
	}
	public class ResolverCache<T>
	{
		private Dictionary<string, T> _cache = new Dictionary<string, T>();

		public void Add(string key, T value)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			if (_cache.ContainsKey(key))
			{
				_cache[key] = value;
			}
			else
			{
				_cache.Add(key, value);
			}
		}

		public T Get(string key)
		{
			if (_cache.TryGetValue(key, out var value))
			{
				return value;
			}
			return default(T);
		}

		public bool Contains(string key)
		{
			return _cache.ContainsKey(key);
		}

		public void Reset()
		{
			_cache.Clear();
		}
	}
	public class SharedMethods
	{
		public static string GetWeather(SelectableLevel level)
		{
			string text = (Plugin.WeatherTweaks.IsModPresent ? WeatherTweaks.CurrentWeather(level) : ((!Plugin.LLL.IsModPresent) ? ((object)(LevelWeatherType)(ref level.currentWeather)).ToString() : LLL.GetWeather(level)));
			Plugin.LogDebug("Weather: " + text);
			if (!(text == "None"))
			{
				return text;
			}
			return "";
		}

		public static string GetNumberlessPlanetName(SelectableLevel level)
		{
			return new string(level.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
		}

		public static string GetAlphanumericName(SelectableLevel level)
		{
			return new string(new Regex("^[0-9]+|[-_/\\\\\\ ]").Replace(level.PlanetName, ""));
		}

		public static List<GrabbableObject> GetShipObjects()
		{
			return GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>().ToList();
		}

		public static List<SelectableLevel> GetGameLevels()
		{
			Plugin.DebugLogger.LogDebug("GetGameLevels called");
			if (Plugin.LLL.IsModPresent)
			{
				Plugin.DebugLogger.LogDebug("LLL present");
				return LLL.GetLevels();
			}
			if (LLLOldPlugin.IsTheOldLLLActive())
			{
				Plugin.DebugLogger.LogDebug("LLLOld present");
				return LLLOldPlugin.GetSelectableLevels();
			}
			Plugin.DebugLogger.LogDebug("No LLL present");
			return LevelHelper.Levels;
		}

		public static bool IsMoonHiddenLLL(SelectableLevel level)
		{
			if (Plugin.LLL.IsModPresent)
			{
				return LLL.IsMoonHidden(level);
			}
			if (LLLOldPlugin.IsTheOldLLLActive())
			{
				return LLLOldPlugin.IsMoonHidden(level);
			}
			return false;
		}

		public static bool IsMoonLockedLLL(SelectableLevel level)
		{
			if (Plugin.LLL.IsModPresent)
			{
				return LLL.IsMooonLocked(level);
			}
			if (LLLOldPlugin.IsTheOldLLLActive())
			{
				return LLLOldPlugin.IsMoonLocked(level);
			}
			return false;
		}

		public static List<TerminalNode> GetLevelTerminalNodes(SelectableLevel level)
		{
			if (Plugin.LLL.IsModPresent)
			{
				return LLL.GetLevelTerminalNodes(level);
			}
			return new List<TerminalNode>();
		}

		public static object GetLLLMoonsCataloguePage()
		{
			if (Plugin.LLL.IsModPresent)
			{
				return LLL.GetMoonsCataloguePage();
			}
			if (LLLOldPlugin.IsTheOldLLLActive())
			{
				return LLLOldPlugin.GetMoonsCataloguePage();
			}
			return null;
		}

		public static List<SelectableLevel> GetLevelsFromLLLTag(string tag)
		{
			if (Plugin.LLL.IsModPresent)
			{
				return LLL.GetLevelsWithTag(tag);
			}
			return new List<SelectableLevel>();
		}

		public static LevelWeatherType GetLevelWeather(SelectableLevel level)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return level.currentWeather;
		}
	}
	public enum PlaceholderStringType
	{
		All,
		Company,
		Modded,
		Vanilla
	}
	public class StringResolver
	{
		private static Dictionary<string, SelectableLevel> _levelsDictionary = null;

		private static ResolverCache<SelectableLevel[]> stringToLevelsCache = new ResolverCache<SelectableLevel[]>();

		public static Dictionary<string, SelectableLevel> StringToLevel
		{
			get
			{
				if (_levelsDictionary != null)
				{
					return _levelsDictionary;
				}
				Dictionary<string, SelectableLevel> Levels = new Dictionary<string, SelectableLevel>();
				StartOfRound.Instance.levels.ToList().ForEach(delegate(SelectableLevel level)
				{
					Levels.TryAdd(GetNumberlessName(level).ToLowerInvariant(), level);
					Levels.TryAdd(GetAlphanumericName(level).ToLowerInvariant(), level);
					Levels.TryAdd(level.sceneName.ToLowerInvariant(), level);
					Levels.TryAdd(level.PlanetName.ToLowerInvariant(), level);
					Levels.TryAdd(((Object)level).name.ToLowerInvariant(), level);
				});
				_levelsDictionary = Levels;
				return Levels;
			}
			set
			{
				_levelsDictionary = value;
			}
		}

		public static string[] ConvertStringToArray(string str)
		{
			return (from s in str.Split(';')
				where !string.IsNullOrWhiteSpace(s)
				select s.Trim()).ToArray();
		}

		public static string GetNumberlessName(SelectableLevel level)
		{
			return new string(level.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray());
		}

		public static string GetAlphanumericName(SelectableLevel level)
		{
			return new string(new Regex("^[0-9]+|[-_/\\\\\\ ]").Replace(level.PlanetName, ""));
		}

		public static SelectableLevel ResolveStringToLevel(string str)
		{
			return StringToLevel.GetValueOrDefault(str.ToLowerInvariant());
		}

		public static SelectableLevel[] ResolveStringToLevels(string str)
		{
			Plugin.LogDebug("Resolving " + str + " into SelectableLevels");
			if (stringToLevelsCache.Contains(str))
			{
				return stringToLevelsCache.Get(str);
			}
			string[] array = ConvertStringToArray(str);
			List<SelectableLevel> list = new List<SelectableLevel>();
			if (array.Count() == 0)
			{
				return Array.Empty<SelectableLevel>();
			}
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (text.StartsWith("$"))
				{
					Plugin.LogDebug("String " + text + " is a LLL ContentTag");
					if (!Plugin.LLL.IsModPresent)
					{
						Plugin.LogDebug("LLL is not present, skipping");
						continue;
					}
					List<SelectableLevel> levelsWithTag = LLL.GetLevelsWithTag(text.Substring(1));
					Plugin.LogDebug("String " + text + " resolved to selectable levels: " + string.Join(',', levelsWithTag.Select((SelectableLevel l) => l.PlanetName)));
					list.AddRange(levelsWithTag);
					continue;
				}
				switch (text.ToLowerInvariant())
				{
				case "all":
				case "modded":
				case "custom":
				case "vanilla":
				{
					SelectableLevel[] array3 = ResolveStringPlaceholderLevels(text);
					Plugin.LogDebug("String " + text + " resolved to selectable levels: " + string.Join(',', array3.Select((SelectableLevel l) => l.PlanetName)));
					list.AddRange(array3);
					continue;
				}
				}
				SelectableLevel val = ResolveStringToLevel(text);
				if (!((Object)(object)val == (Object)null))
				{
					Plugin.LogDebug($"String {text} resolved to selectable level: {val}");
					if (!list.Contains(val))
					{
						list.Add(val);
					}
				}
			}
			SelectableLevel[] array4 = list.Where((SelectableLevel listItem) => (Object)(object)listItem != (Object)null).ToArray();
			stringToLevelsCache.Add(str, array4);
			return array4;
		}

		public static PlaceholderStringType GetPlaceholderType(string input)
		{
			return input.ToLowerInvariant() switch
			{
				"all" => PlaceholderStringType.All, 
				"company" => PlaceholderStringType.Company, 
				"modded" => PlaceholderStringType.Modded, 
				"custom" => PlaceholderStringType.Modded, 
				"vanilla" => PlaceholderStringType.Vanilla, 
				_ => PlaceholderStringType.All, 
			};
		}

		public static SelectableLevel[] ResolveStringPlaceholderLevels(string input)
		{
			PlaceholderStringType placeholderType = GetPlaceholderType(input);
			SelectableLevel companyLevel = ((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel level) => GetNumberlessName(level).ToLowerInvariant() == Defaults.CompanyLevel.ToLowerInvariant()));
			return (placeholderType switch
			{
				PlaceholderStringType.All => StartOfRound.Instance.levels.Where((SelectableLevel level) => (Object)(object)level != (Object)(object)companyLevel).ToArray(), 
				PlaceholderStringType.Company => (IEnumerable<SelectableLevel>)(object)new SelectableLevel[1] { companyLevel }, 
				PlaceholderStringType.Vanilla => (from level in StartOfRound.Instance.levels
					where (Object)(object)level != (Object)(object)companyLevel
					where Defaults.IsVanillaLevel(level)
					select level).ToArray(), 
				PlaceholderStringType.Modded => (from level in StartOfRound.Instance.levels
					where (Object)(object)level != (Object)(object)companyLevel
					where !Defaults.IsVanillaLevel(level)
					select level).ToArray(), 
				_ => Array.Empty<SelectableLevel>(), 
			}).ToArray();
		}

		public static void Reset(StartOfRound startOfRound)
		{
			Plugin.LogDebug("StringResolver.Reset called");
			StringToLevel = null;
			stringToLevelsCache.Reset();
		}
	}
	public class WeightHandler<T>
	{
		private Dictionary<T, int> dictionary = new Dictionary<T, int>();

		public int Count
		{
			get
			{
				int count = dictionary.Count;
				if (count == 0)
				{
					throw new InvalidOperationException("Dictionary is empty - nothing to pick from!");
				}
				return count;
			}
		}

		public int Sum
		{
			get
			{
				int num = 0;
				foreach (int value in dictionary.Values)
				{
					num += value;
				}
				if (num <= 0)
				{
					if (Count == 1)
					{
						return 1;
					}
					throw new InvalidOperationException("Sum cannot be 0 or negative");
				}
				return num;
			}
		}

		public void Add(T key, int value)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			if (Comparer<int>.Default.Compare(value, 0) < 0)
			{
				throw new ArgumentOutOfRangeException("value", "Value cannot be negative");
			}
			if (dictionary.TryGetValue(key, out var value2))
			{
				if (Comparer<int>.Default.Compare(value, value2) > 0)
				{
					dictionary[key] = value;
				}
			}
			else
			{
				dictionary.Add(key, value);
			}
		}

		public void Set(T key, int value)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			if (Comparer<int>.Default.Compare(value, 0) < 0)
			{
				throw new ArgumentOutOfRangeException("value", "Value cannot be negative");
			}
			if (dictionary.TryGetValue(key, out var _))
			{
				dictionary[key] = value;
			}
			else
			{
				dictionary.Add(key, value);
			}
		}

		public void Remove(T key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			dictionary.Remove(key);
		}

		public int Get(T key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			if (!dictionary.TryGetValue(key, out var value))
			{
				return 0;
			}
			return value;
		}

		public int RandomIndex()
		{
			return new Random().Next(0, Sum);
		}

		public T Random()
		{
			int num = RandomIndex();
			int num2 = 0;
			foreach (KeyValuePair<T, int> item in dictionary.OrderByDescending((KeyValuePair<T, int> v) => v.Value))
			{
				num2 += item.Value;
				if (num <= num2)
				{
					Plugin.DebugLogger.LogWarning($"Picked {item.Key} with a roll of {num} out of {Sum}");
					return item.Key;
				}
			}
			return dictionary.Keys.FirstOrDefault();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MrovLib";

		public const string PLUGIN_NAME = "MrovLib";

		public const string PLUGIN_VERSION = "0.2.11";
	}
}
namespace MrovLib.Patches
{
	[HarmonyPatch(typeof(HangarShipDoor), "Start")]
	internal class HangarShipDoorPatch
	{
		private static void Postfix(HangarShipDoor __instance)
		{
			PlanetChecker.CheckRepeatingPlanetNames();
			if (PlanetChecker.ContainsRepeats)
			{
				Plugin.logger.LogFatal((object)"Duplicate planet names detected - this will cause issues with the game!");
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "OnDisable")]
	internal class StartOfRoundPatch
	{
		private static void Postfix(StartOfRound __instance)
		{
			EventManager.LobbyDisabled.Invoke(__instance);
		}
	}
	[HarmonyPatch(typeof(Terminal), "Start")]
	internal class TerminalStart
	{
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void RunMeFirst(Terminal __instance)
		{
			LevelHelper.Populate();
		}

		private static void Postfix(Terminal __instance)
		{
			EventManager.TerminalStart.Invoke(__instance);
		}
	}
}
namespace MrovLib.Events
{
	public class CustomEvent<T>
	{
		public delegate void ParameterEvent(T param);

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event ParameterEvent onParameterEvent;

		public void Invoke(T param)
		{
			this.onParameterEvent?.Invoke(param);
		}

		public void AddListener(ParameterEvent listener)
		{
			onParameterEvent += listener;
			Listeners++;
		}

		public void RemoveListener(ParameterEvent listener)
		{
			onParameterEvent -= listener;
			Listeners--;
		}
	}
	public class CustomEvent
	{
		public delegate void Event();

		public bool HasListeners => Listeners != 0;

		public int Listeners { get; internal set; }

		private event Event onEvent;

		public void Invoke()
		{
			this.onEvent?.Invoke();
		}

		public void AddListener(Event listener)
		{
			onEvent += listener;
			Listeners++;
		}

		public void RemoveListener(Event listener)
		{
			onEvent -= listener;
			Listeners--;
		}
	}
}
namespace MrovLib.Compatibility
{
	public class CompatibilityBase
	{
		private bool? _enabled;

		public string ModGUID { get; internal set; }

		public string ModVersion { get; internal set; }

		public bool IsModPresent
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey(ModGUID);
				}
				if (ModVersion != null && _enabled.Value && Chainloader.PluginInfos.TryGetValue(ModGUID, out var value))
				{
					if (value.Metadata.Version.Major != new Version(ModVersion).Major)
					{
						_enabled = false;
					}
					else
					{
						_enabled = value.Metadata.Version >= new Version(ModVersion);
					}
				}
				return _enabled.Value;
			}
		}

		public Assembly GetModAssembly
		{
			get
			{
				if (!IsModPresent)
				{
					return null;
				}
				return ((object)Chainloader.PluginInfos[ModGUID].Instance).GetType().Assembly;
			}
		}

		public CompatibilityBase(string guid, string version = null)
		{
			ModGUID = guid;
			ModVersion = version;
			_enabled = null;
			Plugin.DebugLogger.LogInfo("CompatibilityBase Constructor called, GUID: " + ModGUID + ", Version: " + ModVersion);
		}
	}
	public class LLL : CompatibilityBase
	{
		public LLL(string guid, string version = null)
			: base(guid, version)
		{
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static string GetWeather(SelectableLevel level)
		{
			return TerminalManager.GetWeatherConditions(((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)level))).ToString().Replace("(", "")
				.Replace(")", "");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static List<SelectableLevel> GetLevels()
		{
			return PatchedContent.SelectableLevels;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMoonHidden(SelectableLevel level)
		{
			return ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)level)).IsRouteHidden;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMooonLocked(SelectableLevel level)
		{
			return ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)level)).IsRouteLocked;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static List<TerminalNode> GetLevelTerminalNodes(SelectableLevel level)
		{
			ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)level));
			return new List<TerminalNode>(3) { val.RouteNode, val.RouteConfirmNode, val.InfoNode };
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static MoonsCataloguePage GetMoonsCataloguePage()
		{
			return TerminalManager.currentMoonsCataloguePage;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static List<SelectableLevel> GetLevelsWithTag(string tag)
		{
			List<ExtendedContent> allExtendedContentsByTag = ContentTagManager.GetAllExtendedContentsByTag(tag);
			List<SelectableLevel> list = new List<SelectableLevel>();
			foreach (ExtendedContent item in allExtendedContentsByTag)
			{
				ExtendedLevel val = (ExtendedLevel)(object)((item is ExtendedLevel) ? item : null);
				if (val != null)
				{
					list.Add(val.SelectableLevel);
				}
			}
			return list;
		}
	}
	[Obsolete]
	public class LLLOldPlugin : CompatibilityBase
	{
		public LLLOldPlugin(string guid, string version = null)
			: base(guid, version)
		{
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsTheOldLLLActive()
		{
			return Plugin.IsOldLLLPresent;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static string GetWeather(SelectableLevel level)
		{
			return LLL.GetWeather(level);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static List<SelectableLevel> GetSelectableLevels()
		{
			return LLL.GetSelectableLevels();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMoonHidden(SelectableLevel level)
		{
			return LLL.IsMoonHidden(level);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMoonLocked(SelectableLevel level)
		{
			return LLL.IsMoonLocked(level);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static MoonsCataloguePage GetMoonsCataloguePage()
		{
			return LLL.GetMoonsCataloguePage();
		}
	}
	public class WeatherTweaks : CompatibilityBase
	{
		internal static MethodInfo GetPlanetCurrentWeather;

		public WeatherTweaks(string guid, string version = null)
			: base(guid, version)
		{
		}

		public static void GetMethodType()
		{
			Type type = Plugin.WeatherTweaks.GetModAssembly.GetType(Plugin.WeatherTweaks.ModGUID + ".Variables");
			if (type != null)
			{
				Plugin.logger.LogInfo((object)$"Type {type} found");
				GetPlanetCurrentWeather = type.GetMethod("GetPlanetCurrentWeather", BindingFlags.Static | BindingFlags.Public);
				if (GetPlanetCurrentWeather != null)
				{
					Plugin.logger.LogInfo((object)$"Method {GetPlanetCurrentWeather} found - BetaWeatherTweaks");
					return;
				}
				Plugin.logger.LogError((object)$"Method {GetPlanetCurrentWeather} not found");
				GetPlanetCurrentWeather = type.GetMethod("GetPlanetCurrentWeather", BindingFlags.Static | BindingFlags.NonPublic);
				if (GetPlanetCurrentWeather != null)
				{
					Plugin.logger.LogInfo((object)$"Method {GetPlanetCurrentWeather} found");
				}
				else
				{
					Plugin.logger.LogError((object)$"Method {GetPlanetCurrentWeather} not found");
				}
			}
			else
			{
				Plugin.LogDebug("Type " + Plugin.WeatherTweaks.ModGUID + ".Variables not found");
			}
		}

		public static string CurrentWeather(SelectableLevel level)
		{
			if (Plugin.WeatherTweaks.IsModPresent && GetPlanetCurrentWeather == null)
			{
				GetMethodType();
			}
			if (GetPlanetCurrentWeather != null)
			{
				return (string)GetPlanetCurrentWeather.Invoke(null, new object[2] { level, true });
			}
			Plugin.logger.LogError((object)"GetPlanetCurrentWeather method not found");
			return "";
		}
	}
}
namespace MrovLib.API
{
	[Obsolete]
	public class SharedMethods
	{
		public static string GetWeather(SelectableLevel level)
		{
			return MrovLib.SharedMethods.GetWeather(level);
		}

		public static string GetNumberlessPlanetName(SelectableLevel level)
		{
			return MrovLib.SharedMethods.GetNumberlessPlanetName(level);
		}

		public static List<GrabbableObject> GetShipObjects()
		{
			return MrovLib.SharedMethods.GetShipObjects();
		}

		public static List<SelectableLevel> GetGameLevels()
		{
			return MrovLib.SharedMethods.GetGameLevels();
		}

		public static bool IsMoonHiddenLLL(SelectableLevel level)
		{
			return MrovLib.SharedMethods.IsMoonHiddenLLL(level);
		}

		public static bool IsMoonLockedLLL(SelectableLevel level)
		{
			return MrovLib.SharedMethods.IsMoonLockedLLL(level);
		}

		public static List<TerminalNode> GetLevelTerminalNodes(SelectableLevel level)
		{
			return MrovLib.SharedMethods.GetLevelTerminalNodes(level);
		}

		public static object GetLLLMoonsCataloguePage()
		{
			return MrovLib.SharedMethods.GetLLLMoonsCataloguePage();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

OldLLLLib.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("OldLLLLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+bca220fd1b662d1892e4e49112887b247616839c")]
[assembly: AssemblyProduct("OldLLLLib")]
[assembly: AssemblyTitle("OldLLLLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OldLLLLib
{
	public class LLL
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static string GetWeather(SelectableLevel level)
		{
			ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.selectableLevel == (Object)(object)level));
			return typeof(TerminalManager).GetMethod("GetWeatherConditions", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[1] { val }).ToString()
				.Replace("(", "")
				.Replace(")", "");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static List<SelectableLevel> GetSelectableLevels()
		{
			return PatchedContent.SeletectableLevels;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMoonHidden(SelectableLevel level)
		{
			ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.selectableLevel == (Object)(object)level));
			return val.isHidden;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsMoonLocked(SelectableLevel level)
		{
			ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel x) => (Object)(object)x.selectableLevel == (Object)(object)level));
			return val.isLocked;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static MoonsCataloguePage GetMoonsCataloguePage()
		{
			return Traverse.Create<TerminalManager>().Field<MoonsCataloguePage>("currentMoonsCataloguePage").Value;
		}
	}
	[BepInPlugin("OldLLLLib", "OldLLLLib", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource logger;

		internal static Harmony harmony = new Harmony("OldLLLLib");

		public static bool IsOldLLLPresent = false;

		public static string GUID = "imabatby.lethallevelloader";

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey(GUID))
			{
				string text = Chainloader.PluginInfos[GUID].Metadata.Version.ToString();
				if (text == "1.1.0.6")
				{
					IsOldLLLPresent = true;
					logger.LogInfo((object)("Found OldLLL: version " + text + " (https://thunderstore.io/c/lethal-company/p/IAmBatby/LethalLevelLoader/)"));
				}
				else if (text == "2.0.0.1")
				{
					IsOldLLLPresent = true;
					logger.LogInfo((object)("Found OldLLL: version " + text + " (https://thunderstore.io/c/lethal-company/p/Pineguys/LethalLevelLoaderFixedV50/)"));
				}
				else
				{
					logger.LogInfo((object)"No OldLLL version found!");
				}
			}
			else
			{
				logger.LogInfo((object)"No LLL found!");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OldLLLLib";

		public const string PLUGIN_NAME = "OldLLLLib";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}