Decompiled source of SCT Endless v1.1.0

plugins/SCTEndless.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SCTCommon;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SCTEndless")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SCTEndless")]
[assembly: AssemblyTitle("SCTEndless")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SCTCommon
{
	internal static class CraftCosts
	{
		private const string OwnerKey = "sct.craft.owner";

		private const string ProvidersKey = "sct.craft.providers";

		private const float MinFactor = 0.25f;

		private const int MaxBuildId = 512;

		private static readonly Dictionary<int, int[]> Originals = new Dictionary<int, int[]>();

		private static float _appliedFactor = 1f;

		private static bool _isOwner;

		public static float Factor
		{
			get
			{
				float num = 1f;
				if (AppDomain.CurrentDomain.GetData("sct.craft.providers") is Dictionary<string, Func<float>> dictionary)
				{
					foreach (Func<float> value in dictionary.Values)
					{
						try
						{
							num *= 1f - Mathf.Clamp(value(), 0f, 0.9f);
						}
						catch (Exception)
						{
						}
					}
				}
				return Mathf.Max(0.25f, num);
			}
		}

		public static void RegisterDiscount(string id, Func<float> discount)
		{
			lock (AppDomain.CurrentDomain)
			{
				Dictionary<string, Func<float>> dictionary = (AppDomain.CurrentDomain.GetData("sct.craft.providers") as Dictionary<string, Func<float>>) ?? new Dictionary<string, Func<float>>();
				dictionary[id] = discount;
				AppDomain.CurrentDomain.SetData("sct.craft.providers", dictionary);
			}
		}

		public static void Install(Harmony harmony, string owner)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			lock (AppDomain.CurrentDomain)
			{
				if (AppDomain.CurrentDomain.GetData("sct.craft.owner") != null)
				{
					return;
				}
				AppDomain.CurrentDomain.SetData("sct.craft.owner", owner);
				_isOwner = true;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(CraftCosts), "SyncPrefix", (Type[])null);
			string[] array = new string[3] { "Open", "RefreshCostItems", "TryPurchase" };
			foreach (string text in array)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(CraftMenu), text, (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private static void SyncPrefix()
		{
			Safe.Run("Coûts de craft", Sync);
		}

		public static void Sync()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (!_isOwner)
			{
				return;
			}
			Dictionary<BuildType, List<ResourceTypeQuantity>> craftingCosts = CraftMenu._craftingCosts;
			if (craftingCosts == null)
			{
				return;
			}
			float factor = Factor;
			bool flag = !Mathf.Approximately(factor, _appliedFactor);
			for (int i = 0; i < 512; i++)
			{
				BuildType val = (BuildType)i;
				if (!craftingCosts.ContainsKey(val))
				{
					continue;
				}
				List<ResourceTypeQuantity> val2 = craftingCosts[val];
				if (!Originals.TryGetValue(i, out var value) || value.Length != val2.Count)
				{
					value = new int[val2.Count];
					for (int j = 0; j < val2.Count; j++)
					{
						value[j] = val2[j].quantity;
					}
					Originals[i] = value;
					flag = true;
				}
				if (flag)
				{
					for (int k = 0; k < val2.Count; k++)
					{
						ResourceTypeQuantity val3 = val2[k];
						val3.quantity = ((factor >= 1f) ? value[k] : Mathf.Max(1, Mathf.CeilToInt((float)value[k] * factor)));
						val2[k] = val3;
					}
				}
			}
			_appliedFactor = factor;
		}

		public static void AddRecipe(BuildType type, params (ResourceType Resource, int Quantity)[] ingredients)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<BuildType, List<ResourceTypeQuantity>> craftingCosts = CraftMenu._craftingCosts;
			List<ResourceTypeQuantity> val = new List<ResourceTypeQuantity>();
			for (int i = 0; i < ingredients.Length; i++)
			{
				var (resourceType, quantity) = ingredients[i];
				val.Add(new ResourceTypeQuantity
				{
					resourceType = resourceType,
					quantity = quantity
				});
			}
			craftingCosts[type] = val;
		}
	}
	internal static class DifficultyApi
	{
		private const string NameKey = "sct.difficulty.name";

		private const string OresKey = "sct.difficulty.ores";

		private const string LevelsKey = "sct.difficulty.levels";

		private const string SetterKey = "sct.difficulty.set";

		public const string Normal = "Normal";

		public static bool Installed => AppDomain.CurrentDomain.GetData("sct.difficulty.levels") is string[];

		public static string Name
		{
			get
			{
				if (!(AppDomain.CurrentDomain.GetData("sct.difficulty.name") is Func<string> func))
				{
					return "Normal";
				}
				return func() ?? "Normal";
			}
		}

		public static float OreFactor
		{
			get
			{
				if (!(AppDomain.CurrentDomain.GetData("sct.difficulty.ores") is Func<float> func))
				{
					return 1f;
				}
				return func();
			}
		}

		public static string[] Levels => (AppDomain.CurrentDomain.GetData("sct.difficulty.levels") as string[]) ?? Array.Empty<string>();

		public static void Set(string level)
		{
			if (AppDomain.CurrentDomain.GetData("sct.difficulty.set") is Action<string> action)
			{
				action(level);
			}
		}

		public static void Publish(Func<string> name, Func<float> ores, string[] levels, Action<string> setter)
		{
			AppDomain.CurrentDomain.SetData("sct.difficulty.name", name);
			AppDomain.CurrentDomain.SetData("sct.difficulty.ores", ores);
			AppDomain.CurrentDomain.SetData("sct.difficulty.levels", levels);
			AppDomain.CurrentDomain.SetData("sct.difficulty.set", setter);
		}

		public static int ScaleCount(int count, float factor)
		{
			if (count > 0)
			{
				return Mathf.Max(1, Mathf.RoundToInt((float)count * factor));
			}
			return count;
		}
	}
	internal static class EndlessApi
	{
		private const string TierKey = "sct.endless.tier";

		public static int Tier
		{
			get
			{
				if (!(AppDomain.CurrentDomain.GetData("sct.endless.tier") is Func<int> func))
				{
					return 0;
				}
				return func();
			}
		}

		public static int EffectiveTier(int saveTier)
		{
			return Math.Max(saveTier, Tier);
		}

		public static void Publish(Func<int> tier)
		{
			AppDomain.CurrentDomain.SetData("sct.endless.tier", tier);
		}
	}
	internal static class GameInstance
	{
		private const string IndexKey = "sct.instance.index";

		private const string MutexKey = "sct.instance.mutex";

		private const string ErrorKey = "sct.instance.error";

		private const string MutexName = "SCT_SpaceCatDigger_Instance_";

		public const int Max = 4;

		public static int Index
		{
			get
			{
				object data = AppDomain.CurrentDomain.GetData("sct.instance.index");
				if (data is int)
				{
					return (int)data;
				}
				int i = 0;
				Mutex data2 = null;
				for (; i < 4; i++)
				{
					bool createdNew;
					Mutex mutex = new Mutex(initiallyOwned: false, "SCT_SpaceCatDigger_Instance_" + i, out createdNew);
					if (createdNew)
					{
						data2 = mutex;
						break;
					}
					mutex.Dispose();
				}
				AppDomain.CurrentDomain.SetData("sct.instance.mutex", data2);
				AppDomain.CurrentDomain.SetData("sct.instance.index", i);
				if (i > 0)
				{
					PrepareTestSaves(i);
				}
				return i;
			}
		}

		public static bool IsTest => Index > 0;

		public static string Suffix
		{
			get
			{
				if (!IsTest)
				{
					return "";
				}
				return "_test" + (Index + 1);
			}
		}

		public static string SaveDirectory => DirectoryOf(Index);

		public static string Error => AppDomain.CurrentDomain.GetData("sct.instance.error") as string;

		private static string DirectoryOf(int index)
		{
			if (index <= 0)
			{
				return Application.persistentDataPath;
			}
			return Path.Combine(Application.persistentDataPath, "coop_test_" + (index + 1));
		}

		public static int OthersRunning()
		{
			int index = Index;
			int num = 0;
			for (int i = 0; i < 4; i++)
			{
				if (i != index && Mutex.TryOpenExisting("SCT_SpaceCatDigger_Instance_" + i, out Mutex result))
				{
					result.Dispose();
					num++;
				}
			}
			return num;
		}

		private static void PrepareTestSaves(int index)
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			ManualLogSource val = Logger.CreateLogSource("SCT Instance");
			bool flag = default(bool);
			try
			{
				string persistentDataPath = Application.persistentDataPath;
				string text = DirectoryOf(index);
				Directory.CreateDirectory(text);
				string[] files = Directory.GetFiles(text);
				for (int i = 0; i < files.Length; i++)
				{
					File.Delete(files[i]);
				}
				files = Directory.GetFiles(persistentDataPath);
				foreach (string text2 in files)
				{
					string fileName = Path.GetFileName(text2);
					if (fileName == "persistent.save" || fileName.StartsWith("sct_", StringComparison.Ordinal))
					{
						File.Copy(text2, Path.Combine(text, fileName), overwrite: true);
					}
				}
				string text3 = text + "/game.save";
				string text4 = text + "/persistent.save";
				SaveSystem.GameFileName = text3;
				SaveSystem.PersistentFileName = text4;
				if (SaveSystem.GameFileName != text3 || SaveSystem.PersistentFileName != text4)
				{
					throw new InvalidOperationException("chemins de sauvegarde du jeu non modifiables");
				}
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(58, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Exemplaire n° ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(index + 1);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" du jeu sur ce PC : sauvegarde de test dans ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				val.LogInfo(val2);
			}
			catch (Exception ex)
			{
				AppDomain.CurrentDomain.SetData("sct.instance.error", ex.Message);
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(97, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Exemplaire n° ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(index + 1);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : sauvegarde de test impossible (");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("). CET EXEMPLAIRE ÉCRIT DANS LA VRAIE SAUVEGARDE.");
				}
				val.LogError(val3);
			}
		}
	}
	internal static class Il2CppUpgradeList
	{
		private static bool _layoutReady;

		private static bool _layoutValid;

		private static int _elementSize;

		private static int _offType;

		private static int _offValues;

		private static int _offCosts;

		private static int _offTiers;

		private static readonly int ArrayHeader = 4 * IntPtr.Size;

		public static bool LayoutValid
		{
			get
			{
				EnsureLayout();
				return _layoutValid;
			}
		}

		public static string Layout
		{
			get
			{
				EnsureLayout();
				return $"élément {_elementSize} octets, type +{_offType}, values +{_offValues}, costs +{_offCosts}, availableTiers +{_offTiers}, contrôle {(_layoutValid ? "OK" : "ÉCHEC")}";
			}
		}

		public static int Count => UpgradeManager.Upgrades._size;

		private static void EnsureLayout()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Invalid comparison between Unknown and I4
			if (_layoutReady)
			{
				return;
			}
			IntPtr nativeClassPtr = Il2CppClassPointerStore<UpgradeData>.NativeClassPtr;
			_elementSize = IL2CPP.il2cpp_class_array_element_size(nativeClassPtr);
			int num = 2 * IntPtr.Size;
			_offType = FieldOffset(nativeClassPtr, "upgradeType") - num;
			_offValues = FieldOffset(nativeClassPtr, "values") - num;
			_offCosts = FieldOffset(nativeClassPtr, "costs") - num;
			_offTiers = FieldOffset(nativeClassPtr, "availableTiers") - num;
			_layoutReady = true;
			_layoutValid = false;
			try
			{
				if (_elementSize >= 4 + 3 * IntPtr.Size && _offType >= 0 && _offValues >= 0 && _offCosts >= 0 && _offTiers >= 0 && Math.Max(Math.Max(_offValues, _offCosts), _offTiers) + IntPtr.Size <= _elementSize && Count > 0 && (int)TypeAt(0) == 1)
				{
					IntPtr intPtr = Marshal.ReadIntPtr(Element(0) + _offValues);
					IntPtr intPtr2 = Marshal.ReadIntPtr(Element(0) + _offCosts);
					_layoutValid = intPtr != IntPtr.Zero && intPtr2 != IntPtr.Zero && IL2CPP.il2cpp_array_length(intPtr) == IL2CPP.il2cpp_array_length(intPtr2) && IL2CPP.il2cpp_array_length(intPtr) > 1;
				}
			}
			catch (Exception)
			{
				_layoutValid = false;
			}
		}

		private static int FieldOffset(IntPtr cls, string name)
		{
			IntPtr intPtr = IL2CPP.il2cpp_class_get_field_from_name(cls, name);
			if (intPtr == IntPtr.Zero)
			{
				throw new MissingFieldException("UpgradeManager.UpgradeData", name);
			}
			return (int)IL2CPP.il2cpp_field_get_offset(intPtr);
		}

		private static IntPtr Element(int index)
		{
			EnsureLayout();
			return ((Il2CppObjectBase)UpgradeManager.Upgrades._items).Pointer + ArrayHeader + index * _elementSize;
		}

		public static UpgradeType TypeAt(int index)
		{
			return (UpgradeType)Marshal.ReadInt32(Element(index) + _offType);
		}

		public static Il2CppStructArray<int> CostsAt(int index)
		{
			IntPtr intPtr = Marshal.ReadIntPtr(Element(index) + _offCosts);
			if (!(intPtr == IntPtr.Zero))
			{
				return new Il2CppStructArray<int>(intPtr);
			}
			return null;
		}

		public static Il2CppStructArray<int> TiersAt(int index)
		{
			IntPtr intPtr = Marshal.ReadIntPtr(Element(index) + _offTiers);
			if (!(intPtr == IntPtr.Zero))
			{
				return new Il2CppStructArray<int>(intPtr);
			}
			return null;
		}

		public static int IndexOf(UpgradeType type)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			int count = Count;
			for (int i = 0; i < count; i++)
			{
				if (TypeAt(i) == type)
				{
					return i;
				}
			}
			return -1;
		}

		public static bool Append(UpgradeType type, float[] values, int[] costs, int[] availableTiers)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected I4, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Invalid comparison between I4 and Unknown
			if (!LayoutValid)
			{
				return false;
			}
			List<UpgradeData> upgrades = UpgradeManager.Upgrades;
			int size = upgrades._size;
			if (size >= (int)IL2CPP.il2cpp_array_length(((Il2CppObjectBase)upgrades._items).Pointer))
			{
				upgrades.Capacity = Math.Max(4, size * 2);
			}
			IntPtr pointer = ((Il2CppObjectBase)upgrades._items).Pointer;
			IntPtr intPtr = pointer + ArrayHeader + size * _elementSize;
			for (int i = 0; i < _elementSize; i++)
			{
				Marshal.WriteByte(intPtr, i, 0);
			}
			Il2CppStructArray<float> val = new Il2CppStructArray<float>(values);
			Il2CppStructArray<int> val2 = new Il2CppStructArray<int>(costs);
			Il2CppStructArray<int> val3 = new Il2CppStructArray<int>(availableTiers);
			Marshal.WriteInt32(intPtr + _offType, (int)type);
			IL2CPP.il2cpp_gc_wbarrier_set_field(pointer, intPtr + _offValues, ((Il2CppObjectBase)val).Pointer);
			IL2CPP.il2cpp_gc_wbarrier_set_field(pointer, intPtr + _offCosts, ((Il2CppObjectBase)val2).Pointer);
			IL2CPP.il2cpp_gc_wbarrier_set_field(pointer, intPtr + _offTiers, ((Il2CppObjectBase)val3).Pointer);
			if (Marshal.ReadInt32(intPtr + _offType) != (int)type || !(Marshal.ReadIntPtr(intPtr + _offValues) == ((Il2CppObjectBase)val).Pointer) || !(Marshal.ReadIntPtr(intPtr + _offCosts) == ((Il2CppObjectBase)val2).Pointer) || !(Marshal.ReadIntPtr(intPtr + _offTiers) == ((Il2CppObjectBase)val3).Pointer))
			{
				for (int j = 0; j < _elementSize; j++)
				{
					Marshal.WriteByte(intPtr, j, 0);
				}
				return false;
			}
			upgrades._size = size + 1;
			int version = upgrades._version;
			upgrades._version = version + 1;
			GC.KeepAlive(val);
			GC.KeepAlive(val2);
			GC.KeepAlive(val3);
			return true;
		}

		public static string InteropView(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			try
			{
				UpgradeData val = UpgradeManager.Upgrades[index];
				return $"interop lit type={(int)val.upgradeType}, values={((Il2CppArrayBase<float>)(object)val.values)?.Length}, costs={((Il2CppArrayBase<int>)(object)val.costs)?.Length}";
			}
			catch (Exception ex)
			{
				return "interop : " + ex.GetType().Name;
			}
		}
	}
	internal static class Il2CppUtil
	{
		public static bool IsPlayer(Driller driller)
		{
			if (driller != null)
			{
				return (Object)(object)((Il2CppObjectBase)driller).TryCast<Player>() != (Object)null;
			}
			return false;
		}

		public static string Guid(BasePlugin plugin)
		{
			return MetadataHelper.GetMetadata((object)plugin).GUID;
		}

		public static IEnumerable<PluginInfo> Plugins()
		{
			if (IL2CPPChainloader.Instance == null)
			{
				yield break;
			}
			foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
			{
				yield return value;
			}
		}
	}
	internal static class Safe
	{
		private static readonly ManualLogSource Log = Logger.CreateLogSource("SCT Safe");

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

		public static void Run(string where, Action action)
		{
			try
			{
				action();
			}
			catch (Exception e)
			{
				Report(where, e);
			}
		}

		public static bool Prefix(string where, Func<bool> prefix)
		{
			try
			{
				return prefix();
			}
			catch (Exception e)
			{
				Report(where, e);
				return true;
			}
		}

		private static void Report(string where, Exception e)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if (Reported.Add(where + e.GetType().Name + e.Message))
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (ignoré, le jeu continue)\n");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
				}
				Log.LogError(val);
			}
		}
	}
	internal static class Vanilla
	{
		private const string Key = "sct.vanilla";

		public static bool Active
		{
			get
			{
				object data = AppDomain.CurrentDomain.GetData("sct.vanilla");
				bool flag = default(bool);
				int num;
				if (data is bool)
				{
					flag = (bool)data;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
		}

		public static void Set(bool active)
		{
			AppDomain.CurrentDomain.SetData("sct.vanilla", active);
		}
	}
	internal static class Lang
	{
		public static bool IsFrench
		{
			get
			{
				try
				{
					Locale selectedLocale = LocalizationSettings.SelectedLocale;
					return ((selectedLocale != null) ? selectedLocale.Identifier.Code : null)?.StartsWith("fr", StringComparison.OrdinalIgnoreCase) ?? false;
				}
				catch (Exception)
				{
					return false;
				}
			}
		}

		public static string Pick(string fr, string en)
		{
			if (!IsFrench)
			{
				return en;
			}
			return fr;
		}
	}
	internal enum ColorVision
	{
		Normal,
		Protanopia,
		Deuteranopia,
		Tritanopia
	}
	internal static class Palette
	{
		public const string VisionKey = "sct.colorblind.vision";

		public const string RedundantKey = "sct.colorblind.redundant";

		private static readonly Color Black = C(0);

		private static readonly Color Orange = C(15113984);

		private static readonly Color SkyBlue = C(5682409);

		private static readonly Color Green = C(40563);

		private static readonly Color Yellow = C(15787074);

		private static readonly Color Blue = C(29362);

		private static readonly Color Vermillion = C(13983232);

		private static readonly Color Purple = C(13400487);

		private static readonly Color White = C(16777215);

		private static readonly Color Grey = C(7237230);

		public static ColorVision Vision
		{
			get
			{
				object data = AppDomain.CurrentDomain.GetData("sct.colorblind.vision");
				if (data is int)
				{
					return (ColorVision)(int)data;
				}
				return ColorVision.Normal;
			}
		}

		public static bool Adapted => Vision != ColorVision.Normal;

		public static bool Redundant
		{
			get
			{
				if (Adapted)
				{
					object data = AppDomain.CurrentDomain.GetData("sct.colorblind.redundant");
					bool flag = default(bool);
					int num;
					if (data is bool)
					{
						flag = (bool)data;
						num = 1;
					}
					else
					{
						num = 0;
					}
					return num == 0 || flag;
				}
				return false;
			}
		}

		private static bool RedGreen
		{
			get
			{
				if (Vision != ColorVision.Protanopia)
				{
					return Vision == ColorVision.Deuteranopia;
				}
				return true;
			}
		}

		public static Color Good(Color usual)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (Adapted)
			{
				if (!RedGreen)
				{
					return Green;
				}
				return SkyBlue;
			}
			return usual;
		}

		public static Color Bad(Color usual)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (Adapted)
			{
				return Vermillion;
			}
			return usual;
		}

		public static Color Warning(Color usual)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (Adapted)
			{
				if (!RedGreen)
				{
					return Orange;
				}
				return Yellow;
			}
			return usual;
		}

		public static Color Danger(Color usual)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (Adapted)
			{
				if (!RedGreen)
				{
					return C(16719904);
				}
				return Vermillion;
			}
			return usual;
		}

		public static Color Accent(Color usual)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (Adapted)
			{
				if (!RedGreen)
				{
					return Purple;
				}
				return SkyBlue;
			}
			return usual;
		}

		public static string GoodHex(string usual = "80ff80")
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!Adapted)
			{
				return usual;
			}
			return Hex(Good(White));
		}

		public static string BadHex(string usual = "ff8080")
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!Adapted)
			{
				return usual;
			}
			return Hex(Bad(White));
		}

		public static string WarningHex(string usual = "ffcc66")
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!Adapted)
			{
				return usual;
			}
			return Hex(Warning(White));
		}

		public static Color Ore(ResourceType type, Color usual)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected I4, but got Unknown
			//IL_0007: 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_0065: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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)
			if (!Adapted)
			{
				return usual;
			}
			bool flag = Vision == ColorVision.Tritanopia;
			switch (type - 2)
			{
			case 9:
				return Grey;
			case 0:
				if (!flag)
				{
					return Blue;
				}
				return Vermillion;
			case 2:
				return Orange;
			case 4:
				return White;
			case 6:
				if (!flag)
				{
					return Yellow;
				}
				return C(16756912);
			case 8:
				return SkyBlue;
			case 10:
				if (!flag)
				{
					return Purple;
				}
				return Blue;
			case 11:
				if (!flag)
				{
					return Green;
				}
				return C(8323072);
			case 12:
				if (!flag)
				{
					return Vermillion;
				}
				return Black;
			default:
				return usual;
			}
		}

		public static Color Tier(int level, Color usual)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (!Adapted || level <= 0)
			{
				return usual;
			}
			Color[] array = (Color[])(object)((Vision != ColorVision.Tritanopia) ? new Color[4] { Blue, Orange, White, Yellow } : new Color[4] { SkyBlue, Vermillion, White, Purple });
			return array[Mathf.Clamp(level, 1, array.Length) - 1];
		}

		public static Color Marker(int index, Color usual)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!Adapted)
			{
				return usual;
			}
			Color[] array = (Color[])(object)((Vision != ColorVision.Tritanopia) ? new Color[5] { Yellow, SkyBlue, Orange, White, Purple } : new Color[5]
			{
				Vermillion,
				White,
				SkyBlue,
				C(16756912),
				Green
			});
			return array[Math.Abs(index) % array.Length];
		}

		public static float Blink(float speed = 3f)
		{
			if (!Redundant)
			{
				return 1f;
			}
			return 0.45f + 0.55f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * speed));
		}

		public static string Hex(Color c)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			return $"{Mathf.RoundToInt(Mathf.Clamp01(c.r) * 255f):X2}{Mathf.RoundToInt(Mathf.Clamp01(c.g) * 255f):X2}{Mathf.RoundToInt(Mathf.Clamp01(c.b) * 255f):X2}";
		}

		private static Color C(int rgb)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f);
		}
	}
	internal static class PlayerLight
	{
		private static readonly Dictionary<IntPtr, bool> IsPlayerEmitter = new Dictionary<IntPtr, bool>();

		private static readonly List<IntPtr> Scaled = new List<IntPtr>(8);

		public static void Scale(LightEmitter emitter, float multiplier)
		{
			if (!IsPlayerEmitter.TryGetValue(((Il2CppObjectBase)emitter).Pointer, out var value))
			{
				value = (Object)(object)((Component)emitter).GetComponentInParent<Build>() == (Object)null;
				IsPlayerEmitter[((Il2CppObjectBase)emitter).Pointer] = value;
			}
			if (value)
			{
				Scaled.Clear();
				Apply((Component)(object)emitter.lightRenderer, multiplier);
				Apply((Component)(object)emitter.smallLightRenderer, multiplier);
				Apply((Component)(object)emitter.smallMask, multiplier);
				Apply((Component)(object)emitter.bigMask, multiplier);
				Apply((Component)(object)emitter.shadowMask, multiplier);
				Apply((Component)(object)emitter.backgroundMask, multiplier);
			}
		}

		private static void Apply(Component component, float multiplier)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)component == (Object)null))
			{
				Transform transform = component.transform;
				if (!Scaled.Contains(((Il2CppObjectBase)transform).Pointer))
				{
					Scaled.Add(((Il2CppObjectBase)transform).Pointer);
					transform.localScale *= multiplier;
				}
			}
		}
	}
	internal static class PngLoader
	{
		public static Texture2D LoadTexture(byte[] png)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			int width;
			int height;
			byte[] array = Decode(png, out width, out height);
			Color[] array2 = (Color[])(object)new Color[width * height];
			for (int i = 0; i < height; i++)
			{
				int num = (height - 1 - i) * width * 4;
				int num2 = i * width;
				int num3 = 0;
				while (num3 < width)
				{
					array2[num2 + num3] = new Color((float)(int)array[num] / 255f, (float)(int)array[num + 1] / 255f, (float)(int)array[num + 2] / 255f, (float)(int)array[num + 3] / 255f);
					num3++;
					num += 4;
				}
			}
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array2));
			val.Apply(false);
			return val;
		}

		public static byte[] Decode(byte[] png, out int width, out int height)
		{
			if (png.Length < 8 || png[0] != 137 || png[1] != 80 || png[2] != 78 || png[3] != 71)
			{
				throw new InvalidDataException("pas un PNG");
			}
			width = (height = 0);
			int num = -1;
			byte[] array = null;
			byte[] array2 = null;
			using MemoryStream memoryStream = new MemoryStream();
			int num3;
			int num4;
			for (int num2 = 8; num2 + 8 <= png.Length; num2 = num4 + num3 + 4)
			{
				num3 = ReadInt(png, num2);
				string text = Encoding.ASCII.GetString(png, num2 + 4, 4);
				num4 = num2 + 8;
				if (num3 < 0 || num4 + num3 > png.Length)
				{
					throw new InvalidDataException("PNG tronqué");
				}
				switch (text)
				{
				case "IHDR":
					width = ReadInt(png, num4);
					height = ReadInt(png, num4 + 4);
					num = png[num4 + 9];
					if (png[num4 + 8] == 8 && png[num4 + 12] == 0)
					{
						continue;
					}
					throw new NotSupportedException("PNG 8 bits non entrelacé attendu");
				case "PLTE":
					array = png.AsSpan(num4, num3).ToArray();
					continue;
				case "tRNS":
					array2 = png.AsSpan(num4, num3).ToArray();
					continue;
				case "IDAT":
					memoryStream.Write(png, num4, num3);
					continue;
				default:
					continue;
				case "IEND":
					break;
				}
				break;
			}
			int num5 = num switch
			{
				0 => 1, 
				2 => 3, 
				3 => 1, 
				4 => 2, 
				6 => 4, 
				_ => throw new NotSupportedException($"type de couleur PNG {num}"), 
			};
			if (width <= 0 || height <= 0)
			{
				throw new InvalidDataException("PNG sans en-tête");
			}
			if (num == 3 && array == null)
			{
				throw new InvalidDataException("PNG sans palette");
			}
			int num6 = width * num5;
			byte[] array3 = new byte[(num6 + 1) * height];
			memoryStream.Position = 0L;
			using (ZLibStream zLibStream = new ZLibStream(memoryStream, CompressionMode.Decompress))
			{
				int num7;
				for (int i = 0; i < array3.Length; i += num7)
				{
					num7 = zLibStream.Read(array3, i, array3.Length - i);
					if (num7 <= 0)
					{
						throw new InvalidDataException("données PNG incomplètes");
					}
				}
			}
			byte[] array4 = new byte[num6 * height];
			for (int j = 0; j < height; j++)
			{
				int num8 = array3[j * (num6 + 1)];
				int num9 = j * (num6 + 1) + 1;
				int num10 = j * num6;
				int num11 = num10 - num6;
				for (int k = 0; k < num6; k++)
				{
					int num12 = ((k >= num5) ? array4[num10 + k - num5] : 0);
					int num13 = ((j > 0) ? array4[num11 + k] : 0);
					int upLeft = ((j > 0 && k >= num5) ? array4[num11 + k - num5] : 0);
					int num14 = num8 switch
					{
						0 => 0, 
						1 => num12, 
						2 => num13, 
						3 => (num12 + num13) / 2, 
						4 => Paeth(num12, num13, upLeft), 
						_ => throw new InvalidDataException($"filtre PNG {num8}"), 
					};
					array4[num10 + k] = (byte)(array3[num9 + k] + num14);
				}
			}
			if (num == 6)
			{
				return array4;
			}
			byte[] array5 = new byte[width * height * 4];
			int num15 = 0;
			int num16 = 0;
			int num17 = 0;
			while (num15 < width * height)
			{
				switch (num)
				{
				case 0:
					array5[num17] = (array5[num17 + 1] = (array5[num17 + 2] = array4[num16]));
					array5[num17 + 3] = byte.MaxValue;
					break;
				case 2:
					array5[num17] = array4[num16];
					array5[num17 + 1] = array4[num16 + 1];
					array5[num17 + 2] = array4[num16 + 2];
					array5[num17 + 3] = byte.MaxValue;
					break;
				case 3:
				{
					int num18 = array4[num16];
					if (num18 * 3 + 2 >= array.Length)
					{
						throw new InvalidDataException("couleur hors palette");
					}
					array5[num17] = array[num18 * 3];
					array5[num17 + 1] = array[num18 * 3 + 1];
					array5[num17 + 2] = array[num18 * 3 + 2];
					array5[num17 + 3] = ((array2 != null && num18 < array2.Length) ? array2[num18] : byte.MaxValue);
					break;
				}
				case 4:
					array5[num17] = (array5[num17 + 1] = (array5[num17 + 2] = array4[num16]));
					array5[num17 + 3] = array4[num16 + 1];
					break;
				}
				num15++;
				num16 += num5;
				num17 += 4;
			}
			return array5;
		}

		private static int ReadInt(byte[] bytes, int offset)
		{
			return (bytes[offset] << 24) | (bytes[offset + 1] << 16) | (bytes[offset + 2] << 8) | bytes[offset + 3];
		}

		private static int Paeth(int left, int up, int upLeft)
		{
			int num = left + up - upLeft;
			int num2 = Math.Abs(num - left);
			int num3 = Math.Abs(num - up);
			int num4 = Math.Abs(num - upLeft);
			if (num2 > num3 || num2 > num4)
			{
				if (num3 > num4)
				{
					return upLeft;
				}
				return up;
			}
			return left;
		}
	}
	internal static class RefundBonus
	{
		private const string ProvidersKey = "sct.refund.providers";

		private const string ActiveKey = "sct.refund.active";

		public static bool SalvageActive
		{
			get
			{
				if (!(AppDomain.CurrentDomain.GetData("sct.refund.active") is Dictionary<string, Func<bool>> dictionary))
				{
					return false;
				}
				foreach (Func<bool> value in dictionary.Values)
				{
					try
					{
						if (value())
						{
							return true;
						}
					}
					catch (Exception)
					{
					}
				}
				return false;
			}
		}

		public static float Total
		{
			get
			{
				float num = 0f;
				if (AppDomain.CurrentDomain.GetData("sct.refund.providers") is Dictionary<string, Func<float>> dictionary)
				{
					foreach (Func<float> value in dictionary.Values)
					{
						try
						{
							num += Mathf.Max(0f, value());
						}
						catch (Exception)
						{
						}
					}
				}
				return num;
			}
		}

		public static void Register(string id, Func<float> bonus, Func<bool> active)
		{
			lock (AppDomain.CurrentDomain)
			{
				Dictionary<string, Func<float>> dictionary = (AppDomain.CurrentDomain.GetData("sct.refund.providers") as Dictionary<string, Func<float>>) ?? new Dictionary<string, Func<float>>();
				dictionary[id] = bonus;
				AppDomain.CurrentDomain.SetData("sct.refund.providers", dictionary);
				Dictionary<string, Func<bool>> dictionary2 = (AppDomain.CurrentDomain.GetData("sct.refund.active") as Dictionary<string, Func<bool>>) ?? new Dictionary<string, Func<bool>>();
				dictionary2[id] = active;
				AppDomain.CurrentDomain.SetData("sct.refund.active", dictionary2);
			}
		}
	}
	internal static class RunEnd
	{
		public static bool WillEndThisFrame(Game game)
		{
			if ((Object)(object)game != (Object)null && !game._runEnded && !game.paused && game.started && game._runTimer <= 0f)
			{
				return game._runTimerTick + Time.deltaTime >= 1f;
			}
			return false;
		}
	}
	internal static class SaveSlotApi
	{
		private const string VersionKey = "sct.saveslot.version";

		public const string Prefix = "sct_";

		public static string Directory => GameInstance.SaveDirectory;

		public static int Version
		{
			get
			{
				object data = AppDomain.CurrentDomain.GetData("sct.saveslot.version");
				if (data is int)
				{
					return (int)data;
				}
				return 0;
			}
		}

		public static string PathOf(string name)
		{
			return Path.Combine(Directory, "sct_" + name);
		}

		public static void BumpVersion()
		{
			AppDomain.CurrentDomain.SetData("sct.saveslot.version", Version + 1);
		}

		public static void Migrate(string oldPath, string name)
		{
			try
			{
				string text = PathOf(name);
				if (File.Exists(oldPath) && !File.Exists(text))
				{
					File.Move(oldPath, text);
				}
			}
			catch (Exception)
			{
			}
		}
	}
	internal static class SctGui
	{
		public const float LineHeight = 22f;

		public const float Gap = 4f;

		private static readonly ManualLogSource Log = Logger.CreateLogSource("SctGui");

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

		private static bool _useBroken;

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

		private static GUIStyle _button;

		private static GUIStyle _buttonHover;

		private static GUIStyle _buttonOn;

		private static GUIStyle _check;

		private static GUIStyle _label;

		private static GUIStyle _richBox;

		private static GUIStyle _buttonToggle;

		public static GUIStyle Label
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Expected O, but got Unknown
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				if (_label == null)
				{
					GUIStyle label = GUI.skin.label;
					_label = new GUIStyle
					{
						richText = true,
						wordWrap = false,
						alignment = (TextAnchor)3,
						fontSize = label.fontSize,
						padding = label.padding
					};
					_label.normal.textColor = label.normal.textColor;
				}
				return _label;
			}
		}

		public static GUIStyle ButtonToggle => _buttonToggle ?? (_buttonToggle = GUI.skin.button);

		public static GUIStyle RichBox => _richBox ?? (_richBox = BoxStyle(13, (TextAnchor)0));

		public static bool Contains(Rect r, Vector2 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (p.x >= ((Rect)(ref r)).x && p.x < ((Rect)(ref r)).x + ((Rect)(ref r)).width && p.y >= ((Rect)(ref r)).y)
			{
				return p.y < ((Rect)(ref r)).y + ((Rect)(ref r)).height;
			}
			return false;
		}

		public static void Use(Event e)
		{
			if (_useBroken)
			{
				return;
			}
			try
			{
				e.Use();
			}
			catch (Exception e2)
			{
				_useBroken = true;
				Report("Event.Use", e2);
			}
		}

		public static void NoteClick(int owner, Vector2 position)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (ClickLogged.Add(owner))
			{
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fenêtre ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(owner);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : premier clic reçu en (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(position.x, "0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(position.y, "0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				Log.LogInfo(val);
			}
		}

		private static GUIStyle CopyState(GUIStyle source, GUIStyleState state, TextAnchor alignment)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				alignment = alignment,
				richText = true,
				fontSize = source.fontSize,
				border = source.border,
				padding = source.padding,
				wordWrap = false
			};
			val.normal.background = state.background;
			val.normal.textColor = state.textColor;
			return val;
		}

		public static void DrawButton(Rect rect, string text, bool on)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (_button == null)
			{
				GUIStyle button = GUI.skin.button;
				_button = CopyState(button, button.normal, (TextAnchor)4);
				_buttonHover = CopyState(button, ((Object)(object)button.hover.background != (Object)null) ? button.hover : button.normal, (TextAnchor)4);
				_buttonOn = CopyState(button, ((Object)(object)button.onNormal.background != (Object)null) ? button.onNormal : button.active, (TextAnchor)4);
			}
			bool flag = GUI.enabled && Event.current != null && Contains(rect, Event.current.mousePosition);
			Color color = GUI.color;
			if (on)
			{
				GUI.color = color * new Color(0.65f, 0.9f, 1f, 1f);
			}
			else if (!GUI.enabled)
			{
				GUI.color = color * new Color(1f, 1f, 1f, 0.5f);
			}
			GUI.Box(rect, text, on ? _buttonOn : (flag ? _buttonHover : _button));
			GUI.color = color;
		}

		public static void DrawCheck(Rect rect, string text, bool on)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (_check == null)
			{
				_check = CopyState(GUI.skin.button, GUI.skin.button.normal, (TextAnchor)4);
			}
			GUI.Box(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 16f) / 2f, 16f, 16f), on ? "x" : "", _check);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 20f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 20f, ((Rect)(ref rect)).height), text, Label);
		}

		public static void Report(string where, Exception e)
		{
			string text = where + ": " + e.GetType().Name + ": " + e.Message;
			if (Reported.Add(text))
			{
				Log.LogWarning((object)(text + "\n" + e.StackTrace));
			}
		}

		public static GUIStyle BoxStyle(int fontSize, TextAnchor alignment)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0055: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			GUIStyle box = GUI.skin.box;
			GUIStyle val = new GUIStyle
			{
				alignment = alignment,
				richText = true,
				fontSize = fontSize,
				border = box.border,
				padding = box.padding,
				margin = box.margin,
				wordWrap = box.wordWrap
			};
			val.normal.background = box.normal.background;
			val.normal.textColor = box.normal.textColor;
			return val;
		}

		public static GUIStyle TextureStyle(Texture2D texture)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0010: 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_001b: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				border = new RectOffset(),
				padding = new RectOffset(),
				margin = new RectOffset()
			};
			val.normal.background = texture;
			return val;
		}

		public static void DrawTexture(Rect rect, GUIStyle textureStyle)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GUI.Box(rect, "", textureStyle);
		}

		public static float TextHeight(string text)
		{
			return (float)Math.Max(1, text.Split('\n').Length) * 18f + 4f;
		}
	}
	internal class SctWindow
	{
		private readonly int _id;

		private readonly Func<string> _title;

		private readonly Action<SctLayout> _content;

		private readonly WindowFunction _function;

		private readonly SctLayout _layout = new SctLayout();

		private readonly bool _modal;

		public Rect Rect;

		public SctWindow(int id, Rect rect, Func<string> title, Action<SctLayout> content, bool modal = false)
		{
			//IL_0019: 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)
			_id = id;
			Rect = rect;
			_title = title;
			_content = content;
			_modal = modal;
			_function = WindowFunction.op_Implicit((Action<int>)Draw);
		}

		public void OnGUI()
		{
			//IL_0034: 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_0010: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			Rect = (_modal ? GUI.ModalWindow(_id, Rect, _function, _title()) : GUI.Window(_id, Rect, _function, _title()));
		}

		private void Draw(int id)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_layout.Begin(new Rect(8f, 22f, ((Rect)(ref Rect)).width - 16f, ((Rect)(ref Rect)).height - 28f), _id);
				_content(_layout);
				_layout.End();
			}
			catch (Exception ex)
			{
				SctGui.Report("Fenêtre " + _id, ex);
				GUI.Label(new Rect(8f, 22f, ((Rect)(ref Rect)).width - 16f, 60f), "Erreur : " + ex.Message, SctGui.Label);
			}
			if (!_modal)
			{
				GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref Rect)).width, 20f));
			}
		}
	}
	internal class SctLayout
	{
		private struct Frame
		{
			public float X;

			public float Y;

			public float Width;

			public bool Horizontal;

			public float RowX;

			public float RowHeight;
		}

		private readonly Stack<Frame> _frames = new Stack<Frame>();

		private Frame _f;

		private int _owner;

		private int _counter;

		private static string _activeSlider;

		private static string _focusedField;

		private static readonly Dictionary<string, float> ScrollOffsets = new Dictionary<string, float>();

		private static readonly Dictionary<string, float> ContentHeights = new Dictionary<string, float>();

		private static readonly Dictionary<string, float> BoxHeights = new Dictionary<string, float>();

		private readonly Stack<float> _columnTops = new Stack<float>();

		private readonly Stack<(string Key, float Top)> _boxKeys = new Stack<(string, float)>();

		private readonly Stack<(string Key, float Height)> _scrollKeys = new Stack<(string, float)>();

		public float Width
		{
			get
			{
				if (!_f.Horizontal)
				{
					return _f.Width;
				}
				return _f.Width - (_f.RowX - _f.X);
			}
		}

		public static bool IsTyping => _focusedField != null;

		public void Begin(Rect area, int owner = 0)
		{
			_frames.Clear();
			_owner = owner;
			_counter = 0;
			_f = new Frame
			{
				X = ((Rect)(ref area)).x,
				Y = ((Rect)(ref area)).y,
				Width = ((Rect)(ref area)).width
			};
		}

		public void End()
		{
			if (_f.Horizontal)
			{
				EndHorizontal();
			}
		}

		private string NextKey()
		{
			return _owner + ":" + _counter++;
		}

		private Rect Next(float width, float height)
		{
			//IL_00b9: 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)
			if (_f.Horizontal)
			{
				float num = ((width < 0f) ? (_f.Width - (_f.RowX - _f.X)) : width);
				Rect result = new Rect(_f.RowX, _f.Y, num, height);
				_f.RowX += num + 4f;
				_f.RowHeight = Math.Max(_f.RowHeight, height);
				return result;
			}
			Rect result2 = new Rect(_f.X, _f.Y, (width < 0f) ? _f.Width : width, height);
			_f.Y += height + 4f;
			return result2;
		}

		public void Space(float height = 8f)
		{
			if (_f.Horizontal)
			{
				_f.RowX += height;
			}
			else
			{
				_f.Y += height;
			}
		}

		public void BeginHorizontal()
		{
			_frames.Push(_f);
			_f.Horizontal = true;
			_f.RowX = _f.X;
			_f.RowHeight = 0f;
		}

		public void EndHorizontal()
		{
			float rowHeight = _f.RowHeight;
			_f = _frames.Pop();
			_f.Y += rowHeight + 4f;
		}

		public void BeginColumn(float width = -1f)
		{
			float width2 = ((width < 0f) ? (_f.Width - (_f.RowX - _f.X)) : width);
			_frames.Push(_f);
			_columnTops.Push(_f.Y);
			_f = new Frame
			{
				X = _f.RowX,
				Y = _f.Y,
				Width = width2
			};
		}

		public void EndColumn()
		{
			float val = _f.Y - _columnTops.Pop();
			float width = _f.Width;
			_f = _frames.Pop();
			_f.RowX += width + 4f;
			_f.RowHeight = Math.Max(_f.RowHeight, val);
		}

		public void BeginBox()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			string text = NextKey();
			BoxHeights.TryGetValue(text, out var value);
			if (value > 0f)
			{
				GUI.Box(new Rect(_f.X, _f.Y, _f.Width, value), "");
			}
			_frames.Push(_f);
			_f.X += 6f;
			_f.Width -= 12f;
			_f.Y += 4f;
			_boxKeys.Push((text, _f.Y - 4f));
		}

		public void EndBox()
		{
			(string Key, float Top) tuple = _boxKeys.Pop();
			string item = tuple.Key;
			float item2 = tuple.Top;
			float y = _f.Y;
			_f = _frames.Pop();
			BoxHeights[item] = y - item2 + 2f;
			_f.Y = y + 2f + 4f;
		}

		public void Label(string text, float width = -1f)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(Next(width, text.Contains("\n") ? SctGui.TextHeight(text) : 22f), text, SctGui.Label);
		}

		private bool Clicked(Rect rect)
		{
			//IL_0013: 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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!GUI.enabled)
			{
				return false;
			}
			Event current = Event.current;
			if (current == null || (int)current.type != 0 || !SctGui.Contains(rect, current.mousePosition))
			{
				return false;
			}
			SctGui.NoteClick(_owner, current.mousePosition);
			SctGui.Use(current);
			return true;
		}

		public Rect Area(float width, float height)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Next(width, height);
		}

		public bool AreaClick(Rect rect, out Vector2 local, out int button)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			local = Vector2.zero;
			button = -1;
			Event current = Event.current;
			if (!GUI.enabled || current == null || (int)current.type != 0 || !SctGui.Contains(rect, current.mousePosition))
			{
				return false;
			}
			local = new Vector2(current.mousePosition.x - ((Rect)(ref rect)).x, current.mousePosition.y - ((Rect)(ref rect)).y);
			try
			{
				button = current.button;
			}
			catch (Exception)
			{
				button = 0;
			}
			SctGui.NoteClick(_owner, current.mousePosition);
			SctGui.Use(current);
			return true;
		}

		public bool Button(string text, float width = -1f, float height = 22f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Next(width, height);
			bool result = Clicked(rect);
			SctGui.DrawButton(rect, text, on: false);
			return result;
		}

		public bool Toggle(bool value, string text, float width = -1f)
		{
			//IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Next(width, 22f);
			if (Clicked(rect))
			{
				value = !value;
			}
			SctGui.DrawCheck(rect, text, value);
			return value;
		}

		public bool ToggleButton(bool value, string text, float width = -1f, float height = 22f)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Next(width, height);
			if (Clicked(rect))
			{
				value = !value;
			}
			SctGui.DrawButton(rect, text, value);
			return value;
		}

		public int Toolbar(int selected, string[] labels, float width = -1f)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			float width2 = (((width < 0f) ? Width : width) - 4f * (float)(labels.Length - 1)) / (float)labels.Length;
			bool horizontal = _f.Horizontal;
			if (!horizontal)
			{
				BeginHorizontal();
			}
			int num = selected;
			for (int i = 0; i < labels.Length; i++)
			{
				Rect rect = Next(width2, 22f);
				if (Clicked(rect))
				{
					num = i;
				}
				SctGui.DrawButton(rect, labels[i], i == num);
			}
			if (!horizontal)
			{
				EndHorizontal();
			}
			return num;
		}

		public float Slider(float value, float min, float max, float width = -1f)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Invalid comparison between Unknown and I4
			//IL_00c2: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Invalid comparison between Unknown and I4
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Invalid comparison between Unknown and I4
			string text = NextKey();
			Rect r = Next(width, 22f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height / 2f - 3f, ((Rect)(ref r)).width, 6f);
			float num = ((max > min) ? Mathf.Clamp01((value - min) / (max - min)) : 0f);
			GUI.Box(val, "");
			GUI.Box(new Rect(((Rect)(ref val)).x + num * (((Rect)(ref val)).width - 12f), ((Rect)(ref r)).y + 2f, 12f, ((Rect)(ref r)).height - 4f), "");
			Event current = Event.current;
			if ((int)current.type == 0 && SctGui.Contains(r, current.mousePosition))
			{
				_activeSlider = text;
				SctGui.Use(current);
			}
			else if ((int)current.type == 1 && _activeSlider == text)
			{
				_activeSlider = null;
				SctGui.Use(current);
			}
			if (_activeSlider == text && ((int)current.type == 3 || (int)current.type == 0 || (int)current.type == 12))
			{
				float num2 = Mathf.Clamp01((current.mousePosition.x - ((Rect)(ref val)).x) / Math.Max(1f, ((Rect)(ref val)).width));
				value = min + num2 * (max - min);
			}
			return value;
		}

		public string TextField(string value, int maxLength, float width = -1f)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			string text = NextKey();
			Rect val = Next(width, 22f);
			bool flag = _focusedField == text;
			Event current = Event.current;
			if ((int)current.type == 0)
			{
				if (SctGui.Contains(val, current.mousePosition))
				{
					_focusedField = text;
					flag = true;
					SctGui.Use(current);
				}
				else if (flag)
				{
					_focusedField = null;
					flag = false;
				}
			}
			value = value ?? "";
			if (flag && (int)current.type == 4)
			{
				if ((int)current.keyCode == 8)
				{
					if (value.Length > 0)
					{
						value = value.Substring(0, value.Length - 1);
					}
					SctGui.Use(current);
				}
				else if ((int)current.keyCode == 13 || (int)current.keyCode == 271 || (int)current.keyCode == 27)
				{
					_focusedField = null;
					SctGui.Use(current);
				}
				else if (current.character != 0 && !char.IsControl(current.character))
				{
					if (value.Length < maxLength)
					{
						value += current.character;
					}
					SctGui.Use(current);
				}
			}
			bool flag2 = flag && Time.realtimeSinceStartup % 1f < 0.5f;
			GUI.Box(val, "");
			GUI.Label(new Rect(((Rect)(ref val)).x + 4f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - 8f, ((Rect)(ref val)).height), value + (flag2 ? "|" : ""), SctGui.Label);
			return value;
		}

		public void BeginScroll(float height, string id = null)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_0046: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			string text = id ?? NextKey();
			Rect r = Next(-1f, height);
			ScrollOffsets.TryGetValue(text, out var value);
			ContentHeights.TryGetValue(text, out var value2);
			Event current = Event.current;
			if ((int)current.type == 6 && SctGui.Contains(r, current.mousePosition))
			{
				value += current.delta.y * 20f;
				SctGui.Use(current);
			}
			value = Mathf.Clamp(value, 0f, Math.Max(0f, value2 - height));
			ScrollOffsets[text] = value;
			if (value2 > height)
			{
				float num = Math.Max(20f, height * height / value2);
				float num2 = ((Rect)(ref r)).y + (height - num) * (value / (value2 - height));
				GUI.Box(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 6f, num2, 6f, num), "");
			}
			GUI.BeginGroup(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 8f, height));
			_frames.Push(_f);
			_scrollKeys.Push((text, height));
			_f = new Frame
			{
				X = 0f,
				Y = 0f - value,
				Width = ((Rect)(ref r)).width - 8f
			};
		}

		public void EndScroll()
		{
			string item = _scrollKeys.Pop().Key;
			ScrollOffsets.TryGetValue(item, out var value);
			ContentHeights[item] = _f.Y + value;
			GUI.EndGroup();
			_f = _frames.Pop();
		}
	}
}
namespace SCTEndless
{
	public enum DialogRule
	{
		Astuces,
		Silencieux,
		Jeu
	}
	internal static class EndlessDialogs
	{
		private const string KeyPrefix = "sct.endless.hint.";

		private static readonly Random Rng = new Random();

		private static string _filledLocale;

		private static int _hintCount;

		private static bool _tableFailed;

		private static readonly (string Fr, string En)[] Chatter = new(string, string)[8]
		{
			("Analyse terminée. Aucune anomalie. Enfin, presque aucune.", "Analysis complete. No anomalies. Well, almost none."),
			("As-tu pensé à t'hydrater ? Les chats aussi ont besoin d'eau.", "Have you stayed hydrated? Cats need water too."),
			("Mes circuits indiquent que tu creuses très bien. Continue.", "My circuits say you dig very well. Keep going."),
			("Rappel : les minerais ne se creusent pas tout seuls. Sauf avec des foreuses.", "Reminder: ores don't dig themselves. Unless you have drills."),
			("J'ai compté les blocs de la mine. J'ai perdu le compte.", "I counted the blocks in the mine. I lost count."),
			("Quota validé. Je reste de marbre. Intérieurement, je danse.", "Quota met. I remain stoic. Inside, I am dancing."),
			("Plus profond, plus loin, plus vite. C'est la devise du jour.", "Deeper, further, faster. Today's motto."),
			("Ma batterie est à 99 %. La tienne ?", "My battery is at 99%. Yours?")
		};

		private static readonly (string Guid, string Fr, string En)[] ModHints = new(string, string, string)[15]
		{
			("sct.quickdeposit", "Astuce : devant le conteneur principal, [G] dépose tout d'un coup.", "Tip: in front of the main container, [G] deposits everything."),
			("sct.markers", "Astuce : [B] pose un repère dans la mine. Il reste visible au bord de l'écran.", "Tip: [B] drops a marker in the mine. It stays visible at the screen edge."),
			("sct.zoom", "Astuce : Ctrl + molette pour zoomer et voir plus loin.", "Tip: Ctrl + mouse wheel to zoom out and see further."),
			("sct.keybinds", "Astuce : [F6] permet de changer toutes les touches.", "Tip: [F6] lets you rebind every key."),
			("sct.daltonien", "Astuce : [F8] ouvre les réglages d'accessibilité (daltonisme).", "Tip: [F8] opens the accessibility (color blindness) settings."),
			("sct.speedrun", "Astuce : [F4] affiche tes records, l'historique et le replay de tes runs.", "Tip: [F4] shows your records, history and run replays."),
			("sct.buildupgrade.furnace", "Astuce : debout sur un four, maintiens [U] pour l'améliorer.", "Tip: stand on a furnace and hold [U] to upgrade it."),
			("sct.buildupgrade.drill", "Astuce : les foreuses s'améliorent aussi, jusqu'à creuser en 5 x 5.", "Tip: drills can be upgraded too, up to digging 5 x 5."),
			("sct.buildupgrade.scanner", "Astuce : un scanner amélioré voit jusqu'à 24 blocs.", "Tip: an upgraded scanner reaches up to 24 blocks."),
			("sct.upgrade.teleporter", "Astuce : avec le Téléporteur, [T] te ramène à la surface.", "Tip: with the Teleporter, [T] brings you back to the surface."),
			("sct.upgrade.contract", "Astuce : un contrat réussi rapporte des DataPoints en plus.", "Tip: a completed contract pays extra DataPoints."),
			("sct.perk.workshop", "Astuce : avec l'Atelier portatif, [C] ouvre le craft n'importe où.", "Tip: with the Portable Workshop, [C] opens crafting anywhere."),
			("sct.audiocues", "Astuce : un minerai révélé sonne plus aigu s'il est précieux.", "Tip: a revealed ore sounds higher when it's valuable."),
			("sct.difficulty", "Astuce : la difficulté se règle à la nouvelle partie.", "Tip: difficulty is chosen when starting a new game."),
			("sct.saveslots", "Astuce : trois emplacements de sauvegarde t'attendent au menu principal.", "Tip: three save slots are waiting in the main menu.")
		};

		private static IntPtr _handledList;

		private static int _handledCount;

		private static bool EnsureEntries()
		{
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			if (_tableFailed)
			{
				return false;
			}
			Locale selectedLocale = LocalizationSettings.SelectedLocale;
			string text = ((selectedLocale != null) ? selectedLocale.Identifier.Code : null) ?? "";
			if (text == _filledLocale)
			{
				return _hintCount > 0;
			}
			try
			{
				StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Game"), (Locale)null);
				if ((Object)(object)table == (Object)null)
				{
					return false;
				}
				HashSet<string> installed = new HashSet<string>(from p in Il2CppUtil.Plugins()
					select p.Metadata.GUID);
				List<string> list = (from h in ModHints
					where installed.Contains(h.Guid)
					select Lang.Pick(h.Fr, h.En)).Concat(Chatter.Select(((string Fr, string En) c) => Lang.Pick(c.Fr, c.En))).ToList();
				for (int num = 0; num < list.Count; num++)
				{
					StringTableEntry entry = ((DetailedLocalizationTable<StringTableEntry>)(object)table).GetEntry("sct.endless.hint." + num);
					if (entry != null)
					{
						entry.Value = list[num];
					}
					else
					{
						((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("sct.endless.hint." + num, list[num]);
					}
				}
				_hintCount = list.Count;
				_filledLocale = text;
				return true;
			}
			catch (Exception ex)
			{
				_tableFailed = true;
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(87, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dialogues EndLess : table de traductions inaccessible (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") : dialogues retirés à la place");
				}
				logger.LogWarning(val);
				return false;
			}
		}

		public static void Update(ComputerManager computer)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)computer == (Object)null || !computer._flowInitialized || !Plugin.Active || EndlessState.Tier <= 2 || Plugin.Dialogs.Value == DialogRule.Jeu)
			{
				return;
			}
			List<FlowStep> runtimeSteps = computer._runtimeSteps;
			if (runtimeSteps == null || (((Il2CppObjectBase)runtimeSteps).Pointer == _handledList && runtimeSteps.Count == _handledCount))
			{
				return;
			}
			bool flag = Plugin.Dialogs.Value == DialogRule.Astuces && EnsureEntries();
			int currentStepIndex = computer._currentStepIndex;
			for (int num = runtimeSteps.Count - 1; num > currentStepIndex; num--)
			{
				FlowStep val = runtimeSteps[num];
				if ((int)val.stepType == 0 && !(val.dialogKey ?? "").StartsWith("sct.endless.hint."))
				{
					if (flag)
					{
						val.dialogKey = "sct.endless.hint." + Rng.Next(_hintCount);
						runtimeSteps[num] = val;
					}
					else
					{
						runtimeSteps.RemoveAt(num);
					}
				}
			}
			_handledList = ((Il2CppObjectBase)runtimeSteps).Pointer;
			_handledCount = runtimeSteps.Count;
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "Awake")]
	internal static class ComputerCapturePatch
	{
		internal static ComputerManager Computer;

		private static void Postfix(ComputerManager __instance)
		{
			Computer = __instance;
		}
	}
	public enum GameOverRule
	{
		RetourPalier3,
		Continuer
	}
	[BepInPlugin("sct.endless", "SCT EndLess", "1.1.0")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "sct.endless";

		public const string Name = "SCT EndLess";

		public const string Version = "1.1.0";

		internal const int DemoTier = 2;

		internal const int Attempts = 3;

		internal static ManualLogSource Logger;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> QuotaGrowth;

		internal static ConfigEntry<float> RunMinutesPerTier;

		internal static ConfigEntry<GameOverRule> OnGameOver;

		internal static ConfigEntry<DialogRule> Dialogs;

		internal static ConfigEntry<bool> BaseUpgradeLevels;

		internal static bool Active
		{
			get
			{
				if (Enabled.Value)
				{
					return !Vanilla.Active;
				}
				return false;
			}
		}

		public override void Load()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Enabled = ((BasePlugin)this).Config.Bind<bool>("EndLess", "Enabled", true, "Paliers au-delà du palier 2 (la fin de la démo n'arrive plus).");
			QuotaGrowth = ((BasePlugin)this).Config.Bind<float>("EndLess", "QuotaGrowth", 2f, new ConfigDescription("Au-delà du dernier palier prévu par le jeu (5), le quota est multiplié par ce facteur à chaque palier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.1f, 5f), Array.Empty<object>()));
			RunMinutesPerTier = ((BasePlugin)this).Config.Bind<float>("EndLess", "RunMinutesPerTier", 2.5f, new ConfigDescription("Chrono de run : 2,5 min + ce nombre de minutes par palier (formule du jeu).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			OnGameOver = ((BasePlugin)this).Config.Bind<GameOverRule>("EndLess", "OnGameOver", GameOverRule.RetourPalier3, "3 runs ratées sur un palier EndLess : RetourPalier3 (fin de partie, meilleur palier enregistré) ou Continuer (on retente le palier).");
			Dialogs = ((BasePlugin)this).Config.Bind<DialogRule>("EndLess", "ComputerDialogs", DialogRule.Astuces, "Dialogues du Computer pendant les paliers EndLess (ceux du jeu dévoileraient la suite) : Astuces (astuces des mods installés et phrases sans rapport), Silencieux (retirés) ou Jeu (gardés).");
			BaseUpgradeLevels = ((BasePlugin)this).Config.Bind<bool>("EndLess", "BaseUpgradeLevels", true, "Les améliorations de base du Computer (vitesse, force, minage, sac, XP, chance, four, foreuse, scanner) continuent : les niveaux prévus par le jeu pour les paliers 3, 4 et 5 s'ouvrent quand la partie EndLess atteint ces paliers.");
			EndlessApi.Publish(() => Active ? EndlessState.Tier : 0);
			Safe.Run("EndLess (améliorations de base)", delegate
			{
				BaseUpgrades.Sync();
			});
			new Harmony("sct.endless").PatchAll(typeof(Plugin).Assembly);
			((BasePlugin)this).AddComponent<EndlessBehaviour>();
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SCT EndLess");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chargé");
			}
			log.LogInfo(val);
		}

		internal static float RunSeconds(int tier)
		{
			return (2.5f + (float)tier * RunMinutesPerTier.Value) * 60f;
		}
	}
	[Serializable]
	public class EndlessSave
	{
		public int tier;

		public int bestTier;

		public int gameOvers;
	}
	internal static class EndlessState
	{
		private static readonly JsonSerializerOptions Options = new JsonSerializerOptions
		{
			IncludeFields = true,
			WriteIndented = true
		};

		private static EndlessSave _save;

		private static int _slotVersion = -1;

		private static string FilePath => SaveSlotApi.PathOf("endless.json");

		public static EndlessSave Save
		{
			get
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Expected O, but got Unknown
				if (_save != null && _slotVersion == SaveSlotApi.Version)
				{
					return _save;
				}
				_slotVersion = SaveSlotApi.Version;
				_save = null;
				try
				{
					if (File.Exists(FilePath))
					{
						_save = JsonSerializer.Deserialize<EndlessSave>(File.ReadAllText(FilePath), Options);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("sct_endless.json illisible : ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val);
				}
				return _save ?? (_save = new EndlessSave());
			}
		}

		public static int Tier => Save.tier;

		public static void Write()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			try
			{
				File.WriteAllText(FilePath, JsonSerializer.Serialize(Save, Options));
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("sct_endless.json : écriture impossible (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				logger.LogWarning(val);
			}
		}

		public static void Reset()
		{
			_save = new EndlessSave();
			try
			{
				if (File.Exists(FilePath))
				{
					File.Delete(FilePath);
				}
			}
			catch (Exception)
			{
			}
		}

		public static int Effective(int saveTier)
		{
			if (Tier <= 2)
			{
				return saveTier;
			}
			return Tier;
		}
	}
	internal static class Quotas
	{
		public static int For(ComputerManager computer, int tier)
		{
			int num = LastTableTier();
			int num2 = Math.Min(tier, num);
			int num3 = computer.GetQuotaTargetForTier(num2);
			if (tier > num)
			{
				num3 = Mathf.RoundToInt((float)num3 * Mathf.Pow(Plugin.QuotaGrowth.Value, (float)(tier - num)));
			}
			return Math.Max(1, num3);
		}

		private static int LastTableTier()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			List<TierQuota> tierQuotas = ComputerManager.TierQuotas;
			int num = 2;
			int num2 = 0;
			while (tierQuotas != null && num2 < tierQuotas.Count)
			{
				num = Math.Max(num, tierQuotas[num2].tier);
				num2++;
			}
			return num;
		}
	}
	internal static class BaseUpgrades
	{
		private const int FirstModId = 100;

		private static readonly HashSet<UpgradeType> Excluded = new HashSet<UpgradeType>
		{
			(UpgradeType)7,
			(UpgradeType)8
		};

		private static readonly Dictionary<UpgradeType, int[]> Original = new Dictionary<UpgradeType, int[]>();

		private static int _appliedTier = -1;

		private static bool _failed;

		public static int Sync()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			if (_failed)
			{
				return 0;
			}
			int num = ((Plugin.Active && Plugin.BaseUpgradeLevels.Value) ? Math.Max(EndlessState.Save.bestTier, EndlessState.Tier) : 0);
			if (num == _appliedTier)
			{
				return 0;
			}
			bool flag = default(bool);
			if (!Il2CppUpgradeList.LayoutValid)
			{
				_failed = true;
				ManualLogSource logger = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(76, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Améliorations de base : table du jeu illisible (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Il2CppUpgradeList.Layout);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), niveaux 3 à 5 non ouverts");
				}
				logger.LogWarning(val);
				return 0;
			}
			int num2 = 0;
			int count = Il2CppUpgradeList.Count;
			for (int i = 0; i < count; i++)
			{
				UpgradeType val2 = Il2CppUpgradeList.TypeAt(i);
				if ((int)val2 >= 100 || Excluded.Contains(val2))
				{
					continue;
				}
				Il2CppStructArray<int> val3 = Il2CppUpgradeList.TiersAt(i);
				if (val3 == null)
				{
					continue;
				}
				if (!Original.TryGetValue(val2, out var value))
				{
					value = new int[((Il2CppArrayBase<int>)(object)val3).Length];
					for (int j = 0; j < value.Length; j++)
					{
						value[j] = ((Il2CppArrayBase<int>)(object)val3)[j];
					}
					Original[val2] = value;
				}
				for (int k = 1; k < value.Length && k < ((Il2CppArrayBase<int>)(object)val3).Length; k++)
				{
					int num3 = value[k];
					if (num3 <= 2)
					{
						continue;
					}
					int num4 = ((num >= num3) ? 2 : num3);
					if (((Il2CppArrayBase<int>)(object)val3)[k] != num4)
					{
						((Il2CppArrayBase<int>)(object)val3)[k] = num4;
						if (num4 == 2)
						{
							num2++;
						}
					}
				}
			}
			if (_appliedTier < 0)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Améliorations de base : ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(Describe());
				}
				logger2.LogInfo(val4);
			}
			_appliedTier = num;
			if (num2 > 0)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(74, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Améliorations de base : ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num2);
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" niveau(x) ouvert(s) au Computer (palier EndLess ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")");
				}
				logger3.LogInfo(val4);
			}
			return num2;
		}

		private static string Describe()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (KeyValuePair<UpgradeType, int[]> item in Original)
			{
				List<string> list2 = new List<string>();
				for (int i = 1; i < item.Value.Length; i++)
				{
					if (item.Value[i] > 2)
					{
						list2.Add($"niv. {i} au palier {item.Value[i]}");
					}
				}
				if (list2.Count > 0)
				{
					list.Add($"{item.Key} ({string.Join(", ", list2)})");
				}
			}
			if (list.Count <= 0)
			{
				return "aucun niveau réservé aux paliers 3+ dans la table du jeu";
			}
			return string.Join(" ; ", list);
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "Awake")]
	internal static class BaseUpgradesComputerPatch
	{
		private static void Prefix()
		{
			Safe.Run("EndLess (améliorations de base)", delegate
			{
				BaseUpgrades.Sync();
			});
		}
	}
	[HarmonyPatch(typeof(UpgradeManager), "Awake")]
	internal static class BaseUpgradesRunPatch
	{
		private static void Prefix()
		{
			Safe.Run("EndLess (améliorations de base)", delegate
			{
				BaseUpgrades.Sync();
			});
		}
	}
	internal static class Messages
	{
		public static string Text;

		public static float Until;

		public static void Show(string text, float seconds = 8f)
		{
			Text = text;
			Until = Time.unscaledTime + seconds;
			Plugin.Logger.LogInfo((object)text);
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "ApplyQuotaProgress")]
	internal static class QuotaProgressPatch
	{
		private static bool Prefix(ComputerManager __instance, int gainedPoints, ref QuotaStepResult __result)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.Active)
			{
				return true;
			}
			PersistentSaveData save = __instance._persistentSaveData;
			if (save.Tier < 2)
			{
				return true;
			}
			QuotaStepResult val = default(QuotaStepResult);
			bool flag = false;
			try
			{
				val = Apply(__instance, ref save, gainedPoints);
				flag = true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(46, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EndLess, conversion : ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (règle du jeu utilisée)");
				}
				logger.LogError(val2);
			}
			if (!flag)
			{
				return true;
			}
			__instance._persistentSaveData = save;
			__result = val;
			return false;
		}

		private static QuotaStepResult Apply(ComputerManager computer, ref PersistentSaveData save, int gained)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			_ = EndlessState.Save;
			int num = EndlessState.Effective(save.Tier);
			if (save.CurrentQuotaTarget <= 0)
			{
				save.CurrentQuotaTarget = Quotas.For(computer, num);
			}
			int num2 = save.CurrentQuotaProgress + gained;
			int num3 = save.CurrentQuotaAttemptCount + 1;
			QuotaStepResult result = new QuotaStepResult
			{
				hasQuota = true,
				previousTier = num,
				newTier = num,
				displayedProgress = Math.Min(num2, save.CurrentQuotaTarget),
				displayedTarget = save.CurrentQuotaTarget,
				attemptsLeftBeforeReset = Math.Max(0, 3 - num3),
				nextQuotaTarget = 0,
				tierIncreased = false,
				failedAndReset = false
			};
			save.CurrentQuotaProgress = num2;
			save.CurrentQuotaAttemptCount = num3;
			if (num2 < save.CurrentQuotaTarget)
			{
				if (num3 >= 3)
				{
					save.CurrentQuotaProgress = 0;
					save.CurrentQuotaAttemptCount = 0;
					result.failedAndReset = true;
					if (num > 2)
					{
						GameOver(computer, ref save, num);
					}
				}
				return result;
			}
			int newTier = TierUp(computer, ref save, num);
			result.tierIncreased = true;
			result.newTier = newTier;
			result.nextQuotaTarget = save.CurrentQuotaTarget;
			return result;
		}

		internal static int TierUp(ComputerManager computer, ref PersistentSaveData save, int tier)
		{
			EndlessSave save2 = EndlessState.Save;
			int num = (save2.tier = tier + 1);
			save2.bestTier = Math.Max(save2.bestTier, num);
			EndlessState.Write();
			save.CurrentQuotaProgress = 0;
			save.CurrentQuotaAttemptCount = 0;
			save.CurrentQuotaTarget = Quotas.For(computer, num);
			bool upgrades = false;
			Safe.Run("EndLess (améliorations de base)", delegate
			{
				upgrades = BaseUpgrades.Sync() > 0;
			});
			Messages.Show(Lang.Pick($"EndLess : palier {num} ! Quota {save.CurrentQuotaTarget}, runs de {Plugin.RunSeconds(num) / 60f:0.#} min", $"EndLess: tier {num}! Quota {save.CurrentQuotaTarget}, {Plugin.RunSeconds(num) / 60f:0.#} min runs") + (upgrades ? Lang.Pick(" · nouvelles améliorations", " · new upgrades") : ""));
			return num;
		}

		internal static void GameOver(ComputerManager computer, ref PersistentSaveData save, int tier)
		{
			EndlessSave save2 = EndlessState.Save;
			save2.bestTier = Math.Max(save2.bestTier, tier);
			if (Plugin.OnGameOver.Value == GameOverRule.Continuer)
			{
				EndlessState.Write();
				Messages.Show(Lang.Pick($"EndLess : palier {tier} raté, progression remise à zéro", $"EndLess: tier {tier} failed, progress reset"));
				return;
			}
			save2.gameOvers++;
			save2.tier = 3;
			EndlessState.Write();
			save.CurrentQuotaTarget = Quotas.For(computer, save2.tier);
			Messages.Show(Lang.Pick($"Fin de la partie EndLess au palier {tier} (record : {save2.bestTier}). Retour au palier {save2.tier}.", $"EndLess run over at tier {tier} (best: {save2.bestTier}). Back to tier {save2.tier}."), 12f);
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "ProcessRunResults")]
	[HarmonyPriority(800)]
	internal static class ProcessRunResultsPatch
	{
		private static void Prefix(ComputerManager __instance, out bool __state)
		{
			bool completed = true;
			Safe.Run("EndLess (avant conversion)", delegate
			{
				completed = __instance._persistentSaveData.HasCompletedDemo;
			});
			__state = completed;
		}

		private static void Postfix(ComputerManager __instance, bool __state)
		{
			Safe.Run("EndLess (conversion)", delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				if (!(!Plugin.Active || __state))
				{
					PersistentSaveData save = __instance._persistentSaveData;
					QuotaStepResult quotaStepResult = __instance._quotaStepResult;
					int num = EndlessState.Effective(save.Tier);
					if (save.HasCompletedDemo)
					{
						save.HasCompletedDemo = false;
						save.Tier = 2;
						save.IsComputerScene = true;
						int newTier = QuotaProgressPatch.TierUp(__instance, ref save, num);
						quotaStepResult.hasQuota = true;
						quotaStepResult.previousTier = num;
						quotaStepResult.newTier = newTier;
						quotaStepResult.tierIncreased = true;
						quotaStepResult.failedAndReset = false;
						quotaStepResult.nextQuotaTarget = save.CurrentQuotaTarget;
					}
					else
					{
						if (!quotaStepResult.failedAndReset || num <= 2)
						{
							return;
						}
						QuotaProgressPatch.GameOver(__instance, ref save, num);
					}
					__instance._persistentSaveData = save;
					__instance._quotaStepResult = quotaStepResult;
					__instance.Save();
				}
			});
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "GetQuotaTargetForTier")]
	[HarmonyPriority(0)]
	internal static class QuotaTargetPatch
	{
		private static bool _inside;

		private static void Postfix(ComputerManager __instance, int tier, ref int __result)
		{
			if (_inside || !Plugin.Active || tier != 2 || EndlessState.Tier <= 2)
			{
				return;
			}
			_inside = true;
			try
			{
				__result = Quotas.For(__instance, EndlessState.Tier);
			}
			finally
			{
				_inside = false;
			}
		}
	}
	[HarmonyPatch(typeof(ComputerManager), "UpdateHeader")]
	internal static class HeaderPatch
	{
		private static readonly Regex FirstNumber = new Regex("\\d+");

		private static void Postfix(ComputerManager __instance)
		{
			if (Plugin.Active && EndlessState.Tier > 2 && !((Object)(object)__instance.headerTierText == (Object)null))
			{
				string text = ((TMP_Text)__instance.headerTierText).text ?? "";
				((