Decompiled source of NukeLib v0.11.0

plugins/NukeLib.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NukeLib.Text;
using NukeLib.Utils;
using TMPro;
using ULTRAKILL.Portal;
using ULTRAKILL.Portal.Geometry;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NukeLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+29c458e2a36b4e68436d235b779a755fb21bd1bd")]
[assembly: AssemblyProduct("NukeLib")]
[assembly: AssemblyTitle("NukeLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 NukeLib
{
	[BepInPlugin("com.github.end-4.nukeLib", "NukeLib", "0.11.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin? Instance;

		internal static ManualLogSource Log;

		public static string workingPath = Assembly.GetExecutingAssembly().Location;

		public static string workingDir = Path.GetDirectoryName(workingPath);

		public const string PluginGUID = "com.github.end-4.nukeLib";

		public const string PluginName = "NukeLib";

		public const string PluginVersion = "0.11.0";

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = this;
				Log = ((BaseUnityPlugin)this).Logger;
				new Harmony("com.github.end-4.nukeLib").PatchAll();
			}
		}
	}
}
namespace NukeLib.Utils
{
	public static class ColorUtils
	{
		private static readonly float MeaningfulColorDiffThreshold = 0.0039f;

		private static readonly float[] M_OKLAB_TO_LMSG = new float[9] { 1f, 0.39633778f, 0.21580376f, 1f, -0.105561346f, -0.06385417f, 1f, -0.08948418f, -1.2914855f };

		private static readonly float[] M_LMS_TO_XYZ = new float[9] { 1.2268798f, -0.557815f, 0.28139105f, -0.040575746f, 1.1122868f, -0.071711056f, -0.07637294f, -0.42149332f, 1.5869241f };

		private static readonly float[] M_XYZ_TO_LMS = new float[9] { 0.8190224f, 0.36190626f, -0.12887378f, 0.032983653f, 0.92928684f, 0.036144666f, 0.04817719f, 0.26423952f, 0.63354784f };

		private static readonly float[] M_LMSG_TO_OKLAB = new float[9] { 0.21045427f, 0.7936178f, -0.004072043f, 1.9779985f, -2.4285922f, 0.4505937f, 0.025904043f, 0.7827717f, -0.80867577f };

		private static readonly float[] M_XYZ_TO_RGB_LINEAR = new float[9] { 3.24097f, -1.5373832f, -0.49861076f, -0.96924365f, 1.8759675f, 0.04155506f, 0.05563008f, -0.20397696f, 1.0569715f };

		private static readonly float[] M_RGB_LINEAR_TO_XYZ = new float[9] { 0.4123908f, 0.35758433f, 0.1804808f, 0.212639f, 0.71516865f, 0.07219232f, 0.019330818f, 0.11919478f, 0.95053214f };

		public static float PerceivedLightness(this Color color)
		{
			//IL_0005: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			return 0.299f * color.r + 0.587f * color.g + 0.114f * color.b;
		}

		public static Color Transparentize(this Color color, float value = 1f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.r, color.g, color.b, color.a * (1f - value));
		}

		public static float[] GetValues(this Color color)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			return new float[4] { color.r, color.g, color.b, color.a };
		}

		public static bool Approximately(this Color color, Color other)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0032: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			if (Mathf.Abs(color.r - other.r) < MeaningfulColorDiffThreshold && Mathf.Abs(color.g - other.g) < MeaningfulColorDiffThreshold && Mathf.Abs(color.b - other.b) < MeaningfulColorDiffThreshold)
			{
				return Mathf.Abs(color.a - other.a) < MeaningfulColorDiffThreshold;
			}
			return false;
		}

		public static Color GetWeaponVariantColor(int variantIndex)
		{
			//IL_001d: 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)
			Color[] array = MonoSingleton<ColorBlindSettings>.Instance?.variationColors;
			if (array != null)
			{
				return array[variantIndex];
			}
			return Color.white;
		}

		public static Color GetContrastedColor(this Color color)
		{
			//IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!((double)color.PerceivedLightness() > 0.5))
			{
				return Color.white;
			}
			return Color.black;
		}

		public static Color Mix(this Color color, Color other, float weight = 0.5f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Color.Lerp(color, other, weight);
		}

		public static Color32 ToColor32(this uint hex)
		{
			//IL_0058: 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)
			if (hex <= 16777215)
			{
				return new Color32((byte)((hex >> 16) & 0xFF), (byte)((hex >> 8) & 0xFF), (byte)(hex & 0xFF), byte.MaxValue);
			}
			return new Color32((byte)((hex >> 24) & 0xFF), (byte)((hex >> 16) & 0xFF), (byte)((hex >> 8) & 0xFF), (byte)(hex & 0xFF));
		}

		public static Color32 ToColor32(this int hex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((uint)hex).ToColor32();
		}

		public static Color ToColor(this uint hex)
		{
			//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)
			return Color32.op_Implicit(hex.ToColor32());
		}

		public static Color ToColor(this int hex)
		{
			//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)
			return Color32.op_Implicit(hex.ToColor32());
		}

		public static float[] MultiplyMatrices(float[] matrix, float[] vector)
		{
			return new float[3]
			{
				matrix[0] * vector[0] + matrix[1] * vector[1] + matrix[2] * vector[2],
				matrix[3] * vector[0] + matrix[4] * vector[1] + matrix[5] * vector[2],
				matrix[6] * vector[0] + matrix[7] * vector[1] + matrix[8] * vector[2]
			};
		}

		public static Vector3 MultiplyMatrix3x3(float[] matrix, Vector3 vector)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0023: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(matrix[0] * vector.x + matrix[1] * vector.y + matrix[2] * vector.z, matrix[3] * vector.x + matrix[4] * vector.y + matrix[5] * vector.z, matrix[6] * vector.x + matrix[7] * vector.y + matrix[8] * vector.z);
		}

		public static Vector3 OklchToOklab(Vector3 oklch)
		{
			//IL_0000: 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)
			//IL_000e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			float x = oklch.x;
			float y = oklch.y;
			float z = oklch.z;
			if (float.IsNaN(z) || y <= 0f)
			{
				return new Vector3(x, 0f, 0f);
			}
			float num = z * 2f * MathF.PI;
			return new Vector3(x, y * Mathf.Cos(num), y * Mathf.Sin(num));
		}

		public static Vector3 OklabToOklch(Vector3 oklab)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			float x = oklab.x;
			float y = oklab.y;
			float z = oklab.z;
			float num = Mathf.Sqrt(y * y + z * z);
			float num2 = ((!(Mathf.Abs(y) < 0.0002f) || !(Mathf.Abs(z) < 0.0002f)) ? ((Mathf.Atan2(z, y) / (MathF.PI * 2f) % 1f + 1f) % 1f) : float.NaN);
			return new Vector3(x, num, num2);
		}

		public static float RgbToSrgbLinear(float c)
		{
			float num = Mathf.Abs(c);
			float num2 = ((num <= 0.04045f) ? (num / 12.92f) : Mathf.Pow((num + 0.055f) / 1.055f, 2.4f));
			if (!(c < 0f))
			{
				return num2;
			}
			return 0f - num2;
		}

		public static Vector3 RgbToSrgbLinear(Vector3 rgb)
		{
			//IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(RgbToSrgbLinear(rgb.x), RgbToSrgbLinear(rgb.y), RgbToSrgbLinear(rgb.z));
		}

		public static Color RgbToSrgbLinear(this Color rgb)
		{
			//IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)
			return new Color(RgbToSrgbLinear(rgb.r), RgbToSrgbLinear(rgb.g), RgbToSrgbLinear(rgb.b), rgb.a);
		}

		public static float SrgbLinearToRgb(float c)
		{
			float num = Mathf.Abs(c);
			float num2 = ((num > 0.0031308f) ? (1.055f * Mathf.Pow(num, 5f / 12f) - 0.055f) : (12.92f * num));
			if (!(c < 0f))
			{
				return num2;
			}
			return 0f - num2;
		}

		public static Vector3 SrgbLinearToRgb(Vector3 rgbLinear)
		{
			//IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(SrgbLinearToRgb(rgbLinear.x), SrgbLinearToRgb(rgbLinear.y), SrgbLinearToRgb(rgbLinear.z));
		}

		public static Color SrgbLinearToRgb(this Color rgbLinear)
		{
			//IL_0000: 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_0020: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			return new Color(Mathf.Clamp01(SrgbLinearToRgb(rgbLinear.r)), Mathf.Clamp01(SrgbLinearToRgb(rgbLinear.g)), Mathf.Clamp01(SrgbLinearToRgb(rgbLinear.b)), rgbLinear.a);
		}

		public static Vector3 OklabToXyz(Vector3 oklab)
		{
			//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_000b: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_003c: 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_0054: 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)
			Vector3 val = MultiplyMatrix3x3(M_OKLAB_TO_LMSG, oklab);
			Vector3 vector = default(Vector3);
			((Vector3)(ref vector))..ctor(val.x * val.x * val.x, val.y * val.y * val.y, val.z * val.z * val.z);
			return MultiplyMatrix3x3(M_LMS_TO_XYZ, vector);
		}

		public static Vector3 XyzToOklab(Vector3 xyz)
		{
			//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_000b: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = MultiplyMatrix3x3(M_XYZ_TO_LMS, xyz);
			Vector3 vector = default(Vector3);
			((Vector3)(ref vector))..ctor(MathF.Cbrt(val.x), MathF.Cbrt(val.y), MathF.Cbrt(val.z));
			return MultiplyMatrix3x3(M_LMSG_TO_OKLAB, vector);
		}

		public static Vector3 XyzToRgbLinear(Vector3 xyz)
		{
			//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)
			return MultiplyMatrix3x3(M_XYZ_TO_RGB_LINEAR, xyz);
		}

		public static Vector3 RgbLinearToXyz(Vector3 rgbLinear)
		{
			//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)
			return MultiplyMatrix3x3(M_RGB_LINEAR_TO_XYZ, rgbLinear);
		}

		private static bool IsInSrgbGamut(Vector3 rgbLinear, float epsilon = 0.0001f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			if (rgbLinear.x >= 0f - epsilon && rgbLinear.x <= 1f + epsilon && rgbLinear.y >= 0f - epsilon && rgbLinear.y <= 1f + epsilon && rgbLinear.z >= 0f - epsilon)
			{
				return rgbLinear.z <= 1f + epsilon;
			}
			return false;
		}

		public static Color OklchToRgb(Vector3 oklch, float alpha = 1f)
		{
			//IL_0000: 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)
			//IL_000e: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			float x = oklch.x;
			float y = oklch.y;
			float z = oklch.z;
			if (x >= 1f)
			{
				return new Color(1f, 1f, 1f, Mathf.Clamp01(alpha));
			}
			if (x <= 0f)
			{
				return new Color(0f, 0f, 0f, Mathf.Clamp01(alpha));
			}
			Vector3 val = XyzToRgbLinear(OklabToXyz(OklchToOklab(new Vector3(x, y, z))));
			if (IsInSrgbGamut(val))
			{
				Vector3 val2 = SrgbLinearToRgb(val);
				return new Color(Mathf.Clamp01(val2.x), Mathf.Clamp01(val2.y), Mathf.Clamp01(val2.z), Mathf.Clamp01(alpha));
			}
			float num = 0f;
			float num2 = y;
			Vector3 rgbLinear = val;
			for (int i = 0; i < 16; i++)
			{
				float num3 = (num + num2) * 0.5f;
				Vector3 val3 = XyzToRgbLinear(OklabToXyz(OklchToOklab(new Vector3(x, num3, z))));
				if (IsInSrgbGamut(val3))
				{
					rgbLinear = val3;
					num = num3;
				}
				else
				{
					num2 = num3;
				}
			}
			Vector3 val4 = SrgbLinearToRgb(rgbLinear);
			return new Color(Mathf.Clamp01(val4.x), Mathf.Clamp01(val4.y), Mathf.Clamp01(val4.z), Mathf.Clamp01(alpha));
		}

		public static Color OklchToRgb(float l, float c, float h, float alpha = 1f)
		{
			//IL_0003: 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)
			return OklchToRgb(new Vector3(l, c, h), alpha);
		}

		public static Vector3 RgbToOklch(this Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtils.RgbToOklch(new Vector3(color.r, color.g, color.b));
		}

		public static Vector3 RgbToOklch(Vector3 rgb)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_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)
			return OklabToOklch(XyzToOklab(RgbLinearToXyz(RgbToSrgbLinear(rgb))));
		}

		public static Vector3 RgbToOklch(float r, float g, float b)
		{
			//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)
			return ColorUtils.RgbToOklch(new Vector3(r, g, b));
		}

		public static Color OKLCHToRGB(float L, float C, float H, float alpha = 1f)
		{
			//IL_0003: 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)
			return OklchToRgb(new Vector3(L, C, H), alpha);
		}

		public static void RGBToOKLCH(this Color rgbColor, out float L, out float C, out float H)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_0008: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = rgbColor.RgbToOklch();
			L = val.x;
			C = val.y;
			H = val.z;
		}
	}
	public static class DebugUtils
	{
		public static string Stringify<T>(this T[] array, string delimiter = ", ", string prefix = "[", string suffix = "]")
		{
			string text = prefix;
			for (int i = 0; i < array.Length; i++)
			{
				text += array[i].ToString();
				if (i < array.Length - 1)
				{
					text += delimiter;
				}
			}
			return text + suffix;
		}
	}
	public static class ExecutionUtils
	{
		public static void RunNextFrame(Action action)
		{
			Plugin? instance = Plugin.Instance;
			if (instance != null)
			{
				((MonoBehaviour)instance).StartCoroutine(RunNextFrameRoutine(action));
			}
		}

		private static IEnumerator RunNextFrameRoutine(Action action)
		{
			yield return null;
			action?.Invoke();
		}

		public static void RunAfterFrames(int frameCount, Action action)
		{
			Plugin? instance = Plugin.Instance;
			if (instance != null)
			{
				((MonoBehaviour)instance).StartCoroutine(RunAfterFramesRoutine(frameCount, action));
			}
		}

		private static IEnumerator RunAfterFramesRoutine(int frameCount, Action action)
		{
			for (int i = 0; i < frameCount; i++)
			{
				yield return null;
			}
			action?.Invoke();
		}
	}
	public static class FileAssetUtils
	{
		public static Sprite LoadNewSprite(string filePath, float pixelsPerUnit = 100f, SpriteMeshType spriteType = (SpriteMeshType)1)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			Texture2D val = LoadTexture(filePath);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), pixelsPerUnit, 0u, spriteType);
		}

		public static Sprite ConvertTextureToSprite(Texture2D texture, float pixelsPerUnit = 100f, SpriteMeshType spriteType = (SpriteMeshType)1)
		{
			//IL_0019: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0f, 0f), pixelsPerUnit, 0u, spriteType);
		}

		public static Texture2D LoadTexture(string FilePath)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (File.Exists(FilePath))
			{
				byte[] array = File.ReadAllBytes(FilePath);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					return val;
				}
			}
			return null;
		}

		public static async Task<Texture2D> LoadTextureAsync(string filePath)
		{
			if (!File.Exists(filePath))
			{
				return null;
			}
			string text = "file://" + filePath;
			UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(text);
			try
			{
				UnityWebRequestAsyncOperation operation = uwr.SendWebRequest();
				while (!((AsyncOperation)operation).isDone)
				{
					await Task.Yield();
				}
				if ((int)uwr.result != 1)
				{
					return null;
				}
				return DownloadHandlerTexture.GetContent(uwr);
			}
			finally
			{
				((IDisposable)uwr)?.Dispose();
			}
		}
	}
	public static class FileUtils
	{
		public static IReadOnlyList<DirectoryInfo> GetPathItems(this DirectoryInfo directory)
		{
			if (directory == null)
			{
				return Array.Empty<DirectoryInfo>();
			}
			List<DirectoryInfo> list = new List<DirectoryInfo>();
			for (DirectoryInfo directoryInfo = directory; directoryInfo != null; directoryInfo = directoryInfo.Parent)
			{
				list.Add(directoryInfo);
			}
			list.Reverse();
			return list;
		}
	}
	public static class ImageUtils
	{
		private struct CacheItem
		{
			public string FilePath;

			public Color DominantColor;
		}

		private static readonly string[] SupportedExtensions = new string[3] { ".png", ".jpg", ".jpeg" };

		private static int _maxCacheSize = 1000;

		private static readonly Dictionary<string, LinkedListNode<CacheItem>> _cacheDict = new Dictionary<string, LinkedListNode<CacheItem>>();

		private static readonly LinkedList<CacheItem> _lruList = new LinkedList<CacheItem>();

		public static int MaxCacheSize
		{
			get
			{
				return _maxCacheSize;
			}
			set
			{
				_maxCacheSize = Mathf.Max(0, value);
				TrimCache();
			}
		}

		public static void ClearCache()
		{
			_cacheDict.Clear();
			_lruList.Clear();
		}

		private static void TrimCache()
		{
			while (_cacheDict.Count > _maxCacheSize)
			{
				LinkedListNode<CacheItem> last = _lruList.Last;
				if (last != null)
				{
					_cacheDict.Remove(last.Value.FilePath);
					_lruList.RemoveLast();
				}
			}
		}

		private static bool TryGetFromCache(string filePath, out Color color)
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (_maxCacheSize > 0 && _cacheDict.TryGetValue(filePath, out LinkedListNode<CacheItem> value))
			{
				_lruList.Remove(value);
				_lruList.AddFirst(value);
				color = value.Value.DominantColor;
				return true;
			}
			color = Color.black;
			return false;
		}

		private static void AddToCache(string filePath, Color color)
		{
			//IL_0060: 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_0041: 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)
			if (_maxCacheSize > 0)
			{
				if (_cacheDict.TryGetValue(filePath, out LinkedListNode<CacheItem> value))
				{
					_lruList.Remove(value);
					_lruList.AddFirst(value);
					value.Value = new CacheItem
					{
						FilePath = filePath,
						DominantColor = color
					};
				}
				else
				{
					LinkedListNode<CacheItem> linkedListNode = new LinkedListNode<CacheItem>(new CacheItem
					{
						FilePath = filePath,
						DominantColor = color
					});
					_lruList.AddFirst(linkedListNode);
					_cacheDict[filePath] = linkedListNode;
					TrimCache();
				}
			}
		}

		public static Color GetDominantColor(Texture2D sourceTexture)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture temporary = RenderTexture.GetTemporary(1, 1, 0, (RenderTextureFormat)0);
			Graphics.Blit((Texture)(object)sourceTexture, temporary);
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, 1f, 1f), 0, 0);
			val.Apply();
			Color pixel = val.GetPixel(0, 0);
			RenderTexture.active = null;
			RenderTexture.ReleaseTemporary(temporary);
			Object.Destroy((Object)val);
			return pixel;
		}

		public static Color GetDominantColor(string filePath)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0014: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetFromCache(filePath, out var color))
			{
				return color;
			}
			if (!File.Exists(filePath))
			{
				return Color.black;
			}
			byte[] array = File.ReadAllBytes(filePath);
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				Object.Destroy((Object)(object)val);
				return Color.black;
			}
			Color dominantColor = GetDominantColor(val);
			Object.Destroy((Object)(object)val);
			AddToCache(filePath, dominantColor);
			return dominantColor;
		}

		public static string FindClosestColorImage(Color targetColor, string directoryPath)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0074: 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)
			if (!Directory.Exists(directoryPath))
			{
				return string.Empty;
			}
			string[] files = Directory.GetFiles(directoryPath, "*.*", SearchOption.TopDirectoryOnly);
			string result = string.Empty;
			float num = float.MaxValue;
			string[] array = files;
			foreach (string text in array)
			{
				string value = Path.GetExtension(text).ToLower();
				if (Array.IndexOf(SupportedExtensions, value) != -1)
				{
					Color dominantColor = GetDominantColor(text);
					float num2 = targetColor.r - dominantColor.r;
					float num3 = targetColor.g - dominantColor.g;
					float num4 = targetColor.b - dominantColor.b;
					float num5 = num2 * num2 + num3 * num3 + num4 * num4;
					if (num5 < num)
					{
						num = num5;
						result = text;
					}
				}
			}
			return result;
		}
	}
	public static class KeyUtils
	{
		public static readonly KeyCode[] ModifierKeys;

		public static bool IsModifier(this KeyCode key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return ModifierKeys.Contains(key);
		}

		static KeyUtils()
		{
			KeyCode[] array = new KeyCode[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			ModifierKeys = (KeyCode[])(object)array;
		}
	}
	public static class ReflectionUtils
	{
		private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly Dictionary<(Type, string), MethodInfo> MethodCache = new Dictionary<(Type, string), MethodInfo>();

		public static T GetPrivate<T>(this object obj, string fieldName)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo? field = type.GetField(fieldName, bindingAttr);
			if (field == null)
			{
				throw new ArgumentException("Field '" + fieldName + "' doesn't exist in class " + type.Name);
			}
			return (T)field.GetValue(obj);
		}

		public static void SetPrivate<T>(this object obj, string fieldName, T value)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo? field = type.GetField(fieldName, bindingAttr);
			if (field == null)
			{
				throw new ArgumentException("Field '" + fieldName + "' doesn't exist in class " + type.Name);
			}
			field.SetValue(obj, value);
		}

		public static T InvokePrivate<T>(this object obj, string methodName, params object[] parameters)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			MethodInfo? method = type.GetMethod(methodName, bindingAttr);
			if (method == null)
			{
				throw new ArgumentException("Method '" + methodName + "' doesn't exist in class " + type.Name);
			}
			return (T)method.Invoke(obj, parameters);
		}

		public static void InvokePrivate(this object obj, string methodName, params object[] parameters)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			MethodInfo? method = type.GetMethod(methodName, bindingAttr);
			if (method == null)
			{
				throw new ArgumentException("Method '" + methodName + "' doesn't exist in class " + type.Name);
			}
			method.Invoke(obj, parameters);
		}

		public static bool TryInvoke(this object obj, string methodName)
		{
			if (obj == null)
			{
				return false;
			}
			Type type = obj.GetType();
			MethodInfo methodInfo = null;
			while (type != null && methodInfo == null)
			{
				methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				type = type.BaseType;
			}
			if (methodInfo == null)
			{
				return false;
			}
			try
			{
				methodInfo.Invoke(obj, null);
				return true;
			}
			catch
			{
				return false;
			}
		}

		public static bool TryInvokeAny(this object obj, params string[] methodNames)
		{
			if (obj == null)
			{
				return false;
			}
			Type type = obj.GetType();
			foreach (string text in methodNames)
			{
				(Type, string) key = (type, text);
				if (!MethodCache.TryGetValue(key, out MethodInfo value))
				{
					Type type2 = type;
					while (type2 != null && value == null)
					{
						value = type2.GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
						type2 = type2.BaseType;
					}
					MethodCache[key] = value;
				}
				if (value != null)
				{
					try
					{
						value.Invoke(obj, null);
						return true;
					}
					catch
					{
						return false;
					}
				}
			}
			return false;
		}
	}
	public static class SceneUtils
	{
		public static event Action<Scene, LoadSceneMode> SafeSceneLoaded;

		public static event Action SafeSceneLoadedNoParam;

		public static event Action<Scene, LoadSceneMode> SafeSceneLoadedDelayed;

		public static event Action SafeSceneLoadedDelayedNoParam;

		static SceneUtils()
		{
			SceneManager.sceneLoaded += CheckScene;
		}

		public static bool IsSafe()
		{
			if (!string.IsNullOrEmpty(SceneHelper.CurrentScene) && !(SceneHelper.CurrentScene == "Bootstrap"))
			{
				return !(SceneHelper.CurrentScene == "Intro");
			}
			return false;
		}

		public static bool IsInGame()
		{
			bool flag = IsSafe();
			if (flag)
			{
				bool flag2;
				switch (SceneHelper.CurrentScene)
				{
				case "Main Menu":
				case "Level 2-S":
				case "Intermission1":
				case "Intermission2":
					flag2 = true;
					break;
				default:
					flag2 = false;
					break;
				}
				flag = !flag2;
			}
			return flag;
		}

		private static void CheckScene(Scene scene, LoadSceneMode mode)
		{
			//IL_0007: 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_000e: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (IsSafe())
				{
					SceneUtils.SafeSceneLoaded?.Invoke(scene, mode);
					SceneUtils.SafeSceneLoadedNoParam?.Invoke();
					ExecutionUtils.RunNextFrame(delegate
					{
						//IL_000c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0012: Unknown result type (might be due to invalid IL or missing references)
						SceneUtils.SafeSceneLoadedDelayed?.Invoke(scene, mode);
						SceneUtils.SafeSceneLoadedDelayedNoParam?.Invoke();
					});
				}
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error on scene load (most likely caused by mods that depend on NukeLib): {arg}");
			}
		}
	}
	public record Searchable
	{
		public string Primary;

		public Dictionary<string, string> Secondaries;
	}
	public static class Search
	{
		private const int WeightPrimary = 3;

		private const int WeightSecondary = 1;

		private const int ExactMatchBonus = 100;

		private const int PrefixBonus = 50;

		private const int WordBoundaryBonus = 30;

		private const int ConsecutiveMatchBonus = 15;

		private const int CamelCaseBonus = 20;

		private const int UnmatchedGapPenalty = -2;

		public static Searchable[] Invoke(string query, Searchable[] items)
		{
			if (items == null || items.Length == 0)
			{
				return Array.Empty<Searchable>();
			}
			if (string.IsNullOrWhiteSpace(query))
			{
				return items;
			}
			query = query.Trim();
			List<(Searchable, int)> list = new List<(Searchable, int)>();
			foreach (Searchable searchable in items)
			{
				int num = int.MinValue;
				if (!string.IsNullOrEmpty(searchable.Primary))
				{
					int num2 = CalculateFuzzyScore(query, searchable.Primary);
					if (num2 > int.MinValue)
					{
						num = Math.Max(num, num2 * 3);
					}
				}
				if (searchable.Secondaries != null)
				{
					foreach (KeyValuePair<string, string> secondary in searchable.Secondaries)
					{
						if (!string.IsNullOrEmpty(secondary.Value))
						{
							int num3 = CalculateFuzzyScore(query, secondary.Value);
							if (num3 > int.MinValue)
							{
								num = Math.Max(num, num3);
							}
						}
					}
				}
				if (num > int.MinValue)
				{
					list.Add((searchable, num));
				}
			}
			return (from r in list
				orderby r.Score descending
				select r.Item).ToArray();
		}

		private static int CalculateFuzzyScore(string query, string target)
		{
			if (string.Equals(query, target, StringComparison.OrdinalIgnoreCase))
			{
				return 200;
			}
			if (target.StartsWith(query, StringComparison.OrdinalIgnoreCase))
			{
				return 50 + query.Length * 15;
			}
			int num = 0;
			int num2 = 0;
			bool flag = false;
			for (int i = 0; i < target.Length; i++)
			{
				if (num >= query.Length)
				{
					break;
				}
				char c = target[i];
				char c2 = query[num];
				if (char.ToLowerInvariant(c) == char.ToLowerInvariant(c2))
				{
					num++;
					num2 += 10;
					if (i == 0)
					{
						num2 += 50;
					}
					else if (IsWordBoundary(target, i))
					{
						num2 += 30;
					}
					if (char.IsUpper(c) && i > 0 && char.IsLower(target[i - 1]))
					{
						num2 += 20;
					}
					if (flag)
					{
						num2 += 15;
					}
					flag = true;
				}
				else
				{
					num2 += -2;
					flag = false;
				}
			}
			if (num != query.Length)
			{
				return int.MinValue;
			}
			return num2;
		}

		private static bool IsWordBoundary(string text, int index)
		{
			if (index == 0)
			{
				return true;
			}
			char c = text[index - 1];
			if (!char.IsWhiteSpace(c) && !char.IsPunctuation(c) && c != '_')
			{
				return c == '-';
			}
			return true;
		}
	}
	public static class TextUtils
	{
		public static string ToSnakeCase(this string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			return Regex.Replace(input, "(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])", "_").ToLowerInvariant();
		}

		public static string ToSentenceCase(this string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			string text = Regex.Replace(input, "(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])", " ");
			text = text.ToLowerInvariant();
			string text2 = char.ToUpperInvariant(text[0]).ToString();
			string text3 = text;
			return text2 + text3.Substring(1, text3.Length - 1);
		}

		public static string ToTitleCase(this string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			return Regex.Replace(Regex.Replace(input, "(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])", " "), "\\b\\w", (Match m) => m.Value.ToUpperInvariant());
		}

		public static string WrapText(this string text, int lineLength)
		{
			string[] array = text.Split(' ');
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = new StringBuilder();
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (stringBuilder2.Length + text2.Length > lineLength)
				{
					if (stringBuilder2.Length == 0)
					{
						stringBuilder.AppendLine(text2);
						continue;
					}
					stringBuilder.AppendLine(stringBuilder2.ToString().TrimEnd());
					stringBuilder2.Clear();
					stringBuilder2.Append(text2).Append(" ");
				}
				else
				{
					stringBuilder2.Append(text2).Append(" ");
				}
			}
			if (stringBuilder2.Length > 0)
			{
				stringBuilder.Append(stringBuilder2.ToString().TrimEnd());
			}
			return stringBuilder.ToString();
		}

		public static string Tag(this string text, string tag)
		{
			if (string.IsNullOrWhiteSpace(text))
			{
				return "[" + tag + "]";
			}
			string pattern = "\\[\\s*" + Regex.Escape(tag) + "\\s*\\]";
			if (Regex.IsMatch(text, pattern, RegexOptions.IgnoreCase))
			{
				return text;
			}
			return text.Trim() + " [" + tag + "]";
		}

		public static string Untag(this string text, string tag)
		{
			if (string.IsNullOrWhiteSpace(text))
			{
				return string.Empty;
			}
			string pattern = "\\s*\\[\\s*" + Regex.Escape(tag) + "\\s*\\]";
			return Regex.Replace(Regex.Replace(text, pattern, string.Empty, RegexOptions.IgnoreCase).Trim(), "\\s+", " ");
		}

		public static bool HasTag(this string text, string tag)
		{
			if (string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(tag))
			{
				return false;
			}
			string pattern = "\\[\\s*" + Regex.Escape(tag) + "\\s*\\]";
			return Regex.IsMatch(text, pattern, RegexOptions.IgnoreCase);
		}

		public static int GetHashIndex(string str, int length)
		{
			if (string.IsNullOrEmpty(str) || length <= 0)
			{
				return 0;
			}
			uint num = 5381u;
			foreach (char c in str)
			{
				num = (num << 5) + num + c;
			}
			return (int)(num & 0x7FFFFFFF) % length;
		}
	}
}
namespace NukeLib.UI
{
	public class ClickHandler : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
	{
		public float DoubleClickInterval = 0.4f;

		private float _lastClickTime = -1f;

		public event Action? OnPress;

		public event Action? OnMiddlePress;

		public event Action? OnRightPress;

		public event Action? OnDoubleClick;

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 2)
			{
				this.OnMiddlePress?.Invoke();
			}
			if ((int)eventData.button == 1)
			{
				this.OnRightPress?.Invoke();
			}
			if ((int)eventData.button == 0)
			{
				this.OnPress?.Invoke();
				float unscaledTime = Time.unscaledTime;
				if (unscaledTime - _lastClickTime <= DoubleClickInterval)
				{
					this.OnDoubleClick?.Invoke();
					_lastClickTime = -1f;
				}
				else
				{
					_lastClickTime = unscaledTime;
				}
			}
		}
	}
	public class EnemyIconController : MonoBehaviour
	{
		public enum IconStyle
		{
			Simple,
			Vanilla
		}

		private static bool iconsLoaded = false;

		private static bool vanillaIconsLoaded = false;

		private static readonly string BundlePath = Path.Combine(Plugin.workingDir, "assets", "nukelib_enemies.bundle");

		private static string DEFAULT_ICON = "default";

		public IconStyle style;

		private static string[] IconNames = new string[41]
		{
			"default", "big_johninator", "cancerous_rodent", "centaur_mortar", "centaur_orb", "centaur_rocket", "cerberus", "deathcatcher", "drone", "ferryman",
			"filth", "flesh_panopticon", "flesh_prison", "gabriel", "gabriel_second", "gutterman", "guttertank", "hideous_mass", "idol", "malicious_face",
			"mandalore", "mindflayer", "minos_prime", "minotaur", "mirror_reaper", "power", "providence", "puppet", "schism", "sisyphus",
			"sisyphus_prime", "soldier", "stalker", "stray", "mannequin", "streetcleaner", "swordsmachine", "turret", "v2", "very_cancerous_rodent",
			"virtue"
		};

		private static Dictionary<string, Sprite> EnemyIcons = new Dictionary<string, Sprite>();

		private static IEnumerable<SpawnableObject> vanillaEnemies;

		public EnemyIdentifier enemyIdentifier;

		public EnemyType enemyType;

		public string enemyName;

		private static void LoadSimpleIcons()
		{
			AssetBundle val = AssetBundle.LoadFromFile(BundlePath);
			for (int i = 0; i < IconNames.Length; i++)
			{
				string text = IconNames[i];
				Sprite value = val.LoadAsset<Sprite>(text);
				EnemyIcons.Add(text, value);
			}
			val.Unload(false);
		}

		private static void LoadVanillaIcons()
		{
			vanillaEnemies = Resources.FindObjectsOfTypeAll<SpawnableObjectsDatabase>().SelectMany((SpawnableObjectsDatabase db) => db.enemies);
		}

		private void Awake()
		{
			if (style == IconStyle.Simple && !iconsLoaded)
			{
				LoadSimpleIcons();
				iconsLoaded = true;
			}
			else if (style == IconStyle.Vanilla && !vanillaIconsLoaded)
			{
				LoadVanillaIcons();
				vanillaIconsLoaded = vanillaEnemies.Count() > 0;
			}
		}

		private void Start()
		{
			SetEnemyIcon();
		}

		private static string NormalizeEnemyName(string name)
		{
			return name.ToLower().Replace(" ", "_");
		}

		private static string GuessIconFromName(string name)
		{
			if (Utility.IsNullOrWhiteSpace(name))
			{
				return string.Empty;
			}
			string text = name.ToLower().Replace("_", " ");
			string text2 = NormalizeEnemyName(text);
			if (text.StartsWith("sisyphean"))
			{
				return "sisyphus";
			}
			if (text.StartsWith("sentry"))
			{
				return "turret";
			}
			if (text.StartsWith("earthmover mortar"))
			{
				return "centaur_mortar";
			}
			if (text.StartsWith("earthmover rocket launcher"))
			{
				return "centaur_rocket";
			}
			if (text.StartsWith("earthmover tower"))
			{
				return "centaur_orb";
			}
			if (text.StartsWith("<s>minotaur"))
			{
				return "minotaur";
			}
			if (text.StartsWith("mysterious druid knight"))
			{
				return "mandalore";
			}
			if (text.StartsWith("???"))
			{
				return "puppet";
			}
			if (text.StartsWith("minos prime"))
			{
				return "minos_prime";
			}
			if (text.StartsWith("big john"))
			{
				return "big_johninator";
			}
			if (text.StartsWith("v2"))
			{
				return "v2";
			}
			if (text.StartsWith("centaur"))
			{
				return "centaur_rocket";
			}
			for (int num = IconNames.Length - 1; num >= 0; num--)
			{
				string text3 = IconNames[num];
				if (!(text3 == "sisyphus"))
				{
					string value = text3.Replace("_", " ");
					if (text.StartsWith(value))
					{
						return text3;
					}
				}
			}
			if (!EnemyIcons.ContainsKey(text2))
			{
				return string.Empty;
			}
			return text2;
		}

		private void SetEnemyIcon()
		{
			if (style == IconStyle.Vanilla)
			{
				((Component)this).gameObject.GetComponent<Image>().sprite = vanillaEnemies.FirstOrDefault((Func<SpawnableObject, bool>)delegate(SpawnableObject spawnable)
				{
					//IL_0039: Unknown result type (might be due to invalid IL or missing references)
					//IL_003f: Unknown result type (might be due to invalid IL or missing references)
					EnemyIdentifier componentInChildren = spawnable.gameObject.GetComponentInChildren<EnemyIdentifier>(true);
					return ((Object)(object)enemyIdentifier != (Object)null) ? (((componentInChildren != null) ? componentInChildren.FullName : null) == enemyIdentifier.FullName) : (componentInChildren.enemyType == enemyType);
				})?.gridIcon;
				return;
			}
			string text = (((Object)(object)enemyIdentifier != (Object)null) ? ((object)Unsafe.As<EnemyType, EnemyType>(ref enemyIdentifier.enemyType)/*cast due to .constrained prefix*/).ToString() : ((object)Unsafe.As<EnemyType, EnemyType>(ref enemyType)/*cast due to .constrained prefix*/).ToString());
			string text2 = DEFAULT_ICON;
			string text3 = NukeLib.Text.TextUtils.ToSnakeCase(text);
			if (EnemyIcons.ContainsKey(text3))
			{
				text2 = text3;
			}
			if (text2 == DEFAULT_ICON)
			{
				string text4 = GuessIconFromName(text);
				if (!Utility.IsNullOrWhiteSpace(text4) && EnemyIcons.ContainsKey(text4))
				{
					text2 = text4;
				}
				EnemyIdentifier obj = enemyIdentifier;
				string text5 = GuessIconFromName(((obj != null) ? obj.FullName.ToLower() : null) ?? "");
				if (!Utility.IsNullOrWhiteSpace(text5) && EnemyIcons.ContainsKey(text5))
				{
					text2 = text5;
				}
				string text6 = GuessIconFromName(enemyName);
				if (!Utility.IsNullOrWhiteSpace(text6) && EnemyIcons.ContainsKey(text6))
				{
					text2 = text6;
				}
			}
			if (EnemyIcons.TryGetValue(text2, out Sprite value))
			{
				((Component)this).gameObject.GetComponent<Image>().sprite = value;
			}
		}
	}
	public class FreeMoveDragHandler : MonoBehaviour, IDragHandler, IEventSystemHandler
	{
		public RectTransform? target;

		protected Canvas? _canvas;

		private void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				if ((Object)(object)target == (Object)null)
				{
					target = (RectTransform)((Component)this).transform;
				}
				_canvas = ((Component)target).GetComponentInParent<Canvas>();
			}
			catch (Exception)
			{
				Plugin.Log.LogWarning((object)"[FreeMoveDragHandler] may have been added to a root element");
			}
		}

		public virtual void OnDrag(PointerEventData eventData)
		{
			//IL_0031: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			if (!((Object)(object)target == (Object)null))
			{
				float num = (((Object)(object)_canvas != (Object)null) ? _canvas.scaleFactor : 1f);
				Vector2 val = eventData.delta / num;
				RectTransform? obj = target;
				obj.anchoredPosition += val;
			}
		}
	}
	[RequireComponent(typeof(RectTransform))]
	public class ResizeController : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IDragHandler, IPointerUpHandler
	{
		private enum ResizeDirection
		{
			None,
			Top,
			Bottom,
			Left,
			Right,
			TopLeft,
			TopRight,
			BottomLeft,
			BottomRight
		}

		[Header("Settings")]
		[Tooltip("The thickness of the invisible edge area that can be grabbed.")]
		public float grabAreaThickness = 10f;

		[Tooltip("Minimum width the UI element can be resized to.")]
		public float minWidth = 50f;

		[Tooltip("Minimum height the UI element can be resized to.")]
		public float minHeight = 50f;

		private RectTransform? _rectTransform;

		private bool _isPointerOver;

		private bool _isDragging;

		private ResizeDirection _currentHoverDirection;

		private ResizeDirection _activeDragDirection;

		private Vector2 _originalSize;

		private Vector2 _originalLocalPosition;

		private Vector2 _dragStartPointerPosition;

		private static readonly string CursorBundlePath = Path.Combine(Plugin.workingDir, "assets", "nukelib_resizecursors.bundle");

		private static readonly string[] IconNames = new string[4] { "move_horizontal_cursor", "move_vertical_cursor", "move_maindiagonal_cursor", "move_subdiagonal_cursor" };

		private static Dictionary<string, Texture2D> Cursors = new Dictionary<string, Texture2D>();

		private static bool LoadedCursors = false;

		private void Start()
		{
			_rectTransform = ((Component)this).GetComponent<RectTransform>();
		}

		private static void LoadCursors()
		{
			AssetBundle val = AssetBundle.LoadFromFile(CursorBundlePath);
			for (int i = 0; i < IconNames.Length; i++)
			{
				string text = IconNames[i];
				Texture2D value = val.LoadAsset<Texture2D>(text);
				Cursors.Add(text, value);
			}
			val.Unload(false);
		}

		private Texture2D GetTexture(string name)
		{
			if (!LoadedCursors)
			{
				LoadedCursors = true;
				LoadCursors();
			}
			return Cursors[name];
		}

		private void Update()
		{
			if (_isPointerOver && !_isDragging)
			{
				UpdateHoverState();
				UpdateCursor();
			}
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			_isPointerOver = true;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			_isPointerOver = false;
			if (!_isDragging)
			{
				ResetCursor();
				_currentHoverDirection = ResizeDirection.None;
			}
		}

		private void UpdateHoverState()
		{
			//IL_0015: 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_002e: 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_0034: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_rectTransform == (Object)null))
			{
				Vector2 val = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val);
				Rect rect = _rectTransform.rect;
				bool flag = val.y >= ((Rect)(ref rect)).yMax && val.y <= ((Rect)(ref rect)).yMax + grabAreaThickness;
				bool flag2 = val.y <= ((Rect)(ref rect)).yMin && val.y >= ((Rect)(ref rect)).yMin - grabAreaThickness;
				bool flag3 = val.x <= ((Rect)(ref rect)).xMin && val.x >= ((Rect)(ref rect)).xMin - grabAreaThickness;
				bool flag4 = val.x >= ((Rect)(ref rect)).xMax && val.x <= ((Rect)(ref rect)).xMax + grabAreaThickness;
				bool flag5 = val.y >= ((Rect)(ref rect)).yMax - ((Rect)(ref rect)).height / 3f;
				bool flag6 = val.y <= ((Rect)(ref rect)).yMin + ((Rect)(ref rect)).height / 3f;
				bool flag7 = val.x <= ((Rect)(ref rect)).xMin + ((Rect)(ref rect)).width / 3f;
				bool flag8 = val.x >= ((Rect)(ref rect)).xMax - ((Rect)(ref rect)).width / 3f;
				if (flag && flag3)
				{
					_currentHoverDirection = ResizeDirection.TopLeft;
				}
				else if (flag && flag4)
				{
					_currentHoverDirection = ResizeDirection.TopRight;
				}
				else if (flag2 && flag3)
				{
					_currentHoverDirection = ResizeDirection.BottomLeft;
				}
				else if (flag2 && flag4)
				{
					_currentHoverDirection = ResizeDirection.BottomRight;
				}
				else if (flag && flag7)
				{
					_currentHoverDirection = ResizeDirection.TopLeft;
				}
				else if (flag3 && flag5)
				{
					_currentHoverDirection = ResizeDirection.TopLeft;
				}
				else if (flag && flag8)
				{
					_currentHoverDirection = ResizeDirection.TopRight;
				}
				else if (flag4 && flag5)
				{
					_currentHoverDirection = ResizeDirection.TopRight;
				}
				else if (flag2 && flag7)
				{
					_currentHoverDirection = ResizeDirection.BottomLeft;
				}
				else if (flag3 && flag6)
				{
					_currentHoverDirection = ResizeDirection.BottomLeft;
				}
				else if (flag2 && flag8)
				{
					_currentHoverDirection = ResizeDirection.BottomRight;
				}
				else if (flag4 && flag6)
				{
					_currentHoverDirection = ResizeDirection.BottomRight;
				}
				else if (flag)
				{
					_currentHoverDirection = ResizeDirection.Top;
				}
				else if (flag2)
				{
					_currentHoverDirection = ResizeDirection.Bottom;
				}
				else if (flag3)
				{
					_currentHoverDirection = ResizeDirection.Left;
				}
				else if (flag4)
				{
					_currentHoverDirection = ResizeDirection.Right;
				}
				else
				{
					_currentHoverDirection = ResizeDirection.None;
				}
			}
		}

		private void UpdateCursor()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = null;
			switch (_currentHoverDirection)
			{
			case ResizeDirection.Left:
			case ResizeDirection.Right:
				val = GetTexture("move_horizontal_cursor");
				break;
			case ResizeDirection.Top:
			case ResizeDirection.Bottom:
				val = GetTexture("move_vertical_cursor");
				break;
			case ResizeDirection.TopLeft:
			case ResizeDirection.BottomRight:
				val = GetTexture("move_maindiagonal_cursor");
				break;
			case ResizeDirection.TopRight:
			case ResizeDirection.BottomLeft:
				val = GetTexture("move_subdiagonal_cursor");
				break;
			case ResizeDirection.None:
				ResetCursor();
				return;
			}
			if (!((Object)(object)val == (Object)null))
			{
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor((float)((Texture)val).width / 2f, (float)((Texture)val).height / 2f);
				Cursor.SetCursor(val, val2, (CursorMode)0);
			}
		}

		private void ResetCursor()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0);
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			//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_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0080: Expected O, but got Unknown
			if (!((Object)(object)_rectTransform == (Object)null) && _currentHoverDirection != ResizeDirection.None)
			{
				_isDragging = true;
				_activeDragDirection = _currentHoverDirection;
				Rect rect = _rectTransform.rect;
				_originalSize = ((Rect)(ref rect)).size;
				_originalLocalPosition = Vector2.op_Implicit(((Transform)_rectTransform).localPosition);
				RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rectTransform).parent, eventData.position, eventData.pressEventCamera, ref _dragStartPointerPosition);
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_001c: 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_0034: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0045: 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_004b: 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_007f: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			if (_isDragging && _activeDragDirection != ResizeDirection.None && RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rectTransform).parent, eventData.position, eventData.pressEventCamera, ref val))
			{
				Vector2 val2 = val - _dragStartPointerPosition;
				Vector2 originalSize = _originalSize;
				Vector2 zero = Vector2.zero;
				if (_activeDragDirection == ResizeDirection.Right || _activeDragDirection == ResizeDirection.TopRight || _activeDragDirection == ResizeDirection.BottomRight)
				{
					originalSize.x = Mathf.Max(minWidth, _originalSize.x + val2.x);
					zero.x = (originalSize.x - _originalSize.x) * _rectTransform.pivot.x;
				}
				else if (_activeDragDirection == ResizeDirection.Left || _activeDragDirection == ResizeDirection.TopLeft || _activeDragDirection == ResizeDirection.BottomLeft)
				{
					originalSize.x = Mathf.Max(minWidth, _originalSize.x - val2.x);
					zero.x = (0f - (originalSize.x - _originalSize.x)) * (1f - _rectTransform.pivot.x);
				}
				if (_activeDragDirection == ResizeDirection.Top || _activeDragDirection == ResizeDirection.TopLeft || _activeDragDirection == ResizeDirection.TopRight)
				{
					originalSize.y = Mathf.Max(minHeight, _originalSize.y + val2.y);
					zero.y = (originalSize.y - _originalSize.y) * _rectTransform.pivot.y;
				}
				else if (_activeDragDirection == ResizeDirection.Bottom || _activeDragDirection == ResizeDirection.BottomLeft || _activeDragDirection == ResizeDirection.BottomRight)
				{
					originalSize.y = Mathf.Max(minHeight, _originalSize.y - val2.y);
					zero.y = (0f - (originalSize.y - _originalSize.y)) * (1f - _rectTransform.pivot.y);
				}
				_rectTransform.SetSizeWithCurrentAnchors((Axis)0, originalSize.x);
				_rectTransform.SetSizeWithCurrentAnchors((Axis)1, originalSize.y);
				((Transform)_rectTransform).localPosition = Vector2.op_Implicit(_originalLocalPosition) + new Vector3(zero.x, zero.y, 0f);
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			_isDragging = false;
			_activeDragDirection = ResizeDirection.None;
			UpdateHoverState();
			if (_currentHoverDirection == ResizeDirection.None && !_isPointerOver)
			{
				ResetCursor();
			}
		}

		private void OnDisable()
		{
			ResetCursor();
			_isDragging = false;
			_isPointerOver = false;
			_currentHoverDirection = ResizeDirection.None;
		}
	}
	public class SlideFadeToggleEffect : MonoBehaviour
	{
		private enum State
		{
			Idle,
			Entering,
			Exiting
		}

		private State currentState;

		private RectTransform rect;

		private CanvasGroup? canvasGroup;

		private float originalAlpha;

		private Vector2 originalPos;

		public float hiddenAlpha;

		public float speed = 18f;

		public Vector2 hiddenOffset = Vector2.zero;

		private float currentExitSpeed;

		private Vector2 hiddenPos => originalPos + hiddenOffset;

		public event Action OnExitComplete;

		private void Set2DLocalPosition(Vector2 newPos)
		{
			//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_0018: 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)
			((Transform)rect).localPosition = new Vector3(newPos.x, newPos.y, ((Transform)rect).localPosition.z);
		}

		private void Initialize()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)rect == (Object)null)
			{
				rect = ((Component)this).GetComponent<RectTransform>();
			}
			if ((Object)canvasGroup == (Object)null)
			{
				canvasGroup = ((Component)this).GetComponent<CanvasGroup>();
			}
			CanvasGroup? obj = canvasGroup;
			originalAlpha = ((obj != null) ? obj.alpha : 1f);
			originalPos = Vector2.op_Implicit(((Transform)rect).localPosition);
		}

		private void OnEnable()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Set2DLocalPosition(hiddenPos);
			if ((Object)(object)canvasGroup != (Object)null)
			{
				canvasGroup.alpha = hiddenAlpha;
			}
			currentState = State.Entering;
		}

		public void StartExit()
		{
			currentState = State.Exiting;
		}

		private void Awake()
		{
			Initialize();
		}

		private void Update()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (currentState == State.Idle)
			{
				return;
			}
			bool num = currentState == State.Entering;
			Vector2 val = (num ? originalPos : hiddenPos);
			float num2 = (num ? originalAlpha : hiddenAlpha);
			Vector2 val2 = Vector2.op_Implicit(((Transform)rect).localPosition);
			CanvasGroup? obj = canvasGroup;
			float num3 = ((obj != null) ? obj.alpha : 1f);
			float num5;
			float num6;
			if (num)
			{
				float num4 = Time.unscaledDeltaTime * speed;
				num5 = (Vector2.Distance(val2, val) + 0.1f) * num4;
				num6 = (Mathf.Abs(num2 - num3) + 0.1f) * num4;
				currentExitSpeed = 0f;
			}
			else
			{
				currentExitSpeed += speed * 7f * Time.unscaledDeltaTime;
				num5 = currentExitSpeed;
				num6 = currentExitSpeed * 0.01f;
			}
			Set2DLocalPosition(Vector2.MoveTowards(val2, val, num5));
			if ((Object)(object)canvasGroup != (Object)null)
			{
				canvasGroup.alpha = Mathf.MoveTowards(num3, num2, num6);
			}
			if (Vector2.op_Implicit(((Transform)rect).localPosition) == val && ((Object)(object)canvasGroup == (Object)null || Mathf.Approximately(canvasGroup.alpha, num2)))
			{
				State num7 = currentState;
				currentState = State.Idle;
				currentExitSpeed = 0f;
				if (num7 == State.Exiting)
				{
					this.OnExitComplete?.Invoke();
				}
			}
		}
	}
	public static class SlideFadeToggleEffectExtensions
	{
		public static void SetActiveAnimated(this GameObject gameObject, bool value, Vector2 hiddenOffset, float speed = 25f)
		{
			//IL_002f: 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)
			SlideFadeToggleEffect slideFadeToggleEffect = gameObject.GetComponent<SlideFadeToggleEffect>();
			if ((Object)(object)slideFadeToggleEffect == (Object)null)
			{
				slideFadeToggleEffect = gameObject.AddComponent<SlideFadeToggleEffect>();
				slideFadeToggleEffect.hiddenOffset = hiddenOffset;
				slideFadeToggleEffect.speed = speed;
				slideFadeToggleEffect.OnExitComplete += delegate
				{
					gameObject.SetActive(false);
				};
			}
			if (value)
			{
				gameObject.SetActive(true);
			}
			else if ((Object)(object)slideFadeToggleEffect != (Object)null)
			{
				slideFadeToggleEffect.StartExit();
			}
			else
			{
				gameObject.SetActive(false);
			}
		}
	}
	public class TitlebarDragHandler : FreeMoveDragHandler
	{
		private void Start()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			try
			{
				target = (RectTransform)((Component)((Component)this).transform.parent).transform;
			}
			catch (Exception)
			{
				Plugin.Log.LogWarning((object)"[TitlebarDragHandler] may have been added to a root element");
			}
		}
	}
	public static class UIUtils
	{
		public static GameObject? FindRecursive(this GameObject baseObject, string path)
		{
			Transform val = baseObject.transform;
			string[] array = path.Split("/");
			foreach (string text in array)
			{
				val = ((Component)val).transform.Find(text);
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogWarning((object)(text + " not found for object path " + ((Object)baseObject).name + "/" + path));
					return null;
				}
			}
			return ((Component)val).gameObject;
		}

		public static GameObject? FindRecursive(string path)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			int num = path.IndexOf('/');
			string firstItem = "";
			string path2 = "";
			if (num != -1)
			{
				firstItem = path.Substring(0, num);
				path2 = path.Substring(num + 1);
			}
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject val = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
				where ((Object)obj).name == firstItem
				select obj).FirstOrDefault();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Root item not found for object path " + path));
				return null;
			}
			return val.FindRecursive(path2);
		}

		public static void UnfuckLayoutHack(this GameObject uiObject)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if (!((Object)(object)uiObject == (Object)null))
			{
				LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)uiObject.transform);
			}
		}

		public static void SetLayerRecursive(this GameObject obj, int newLayer)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)obj == (Object)null)
			{
				return;
			}
			obj.layer = newLayer;
			foreach (Transform item in obj.transform)
			{
				((Component)item).gameObject.SetLayerRecursive(newLayer);
			}
		}

		public static void SetImageMaterialRecursive(this GameObject obj, Material material)
		{
			if (!((Object)(object)obj == (Object)null))
			{
				Image[] componentsInChildren = obj.GetComponentsInChildren<Image>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Graphic)componentsInChildren[i]).material = material;
				}
			}
		}

		public static void SetTextMaterialRecursive(this GameObject obj, Material material)
		{
			if (!((Object)(object)obj == (Object)null))
			{
				TextMeshProUGUI[] componentsInChildren = obj.GetComponentsInChildren<TextMeshProUGUI>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((TMP_Text)componentsInChildren[i]).fontMaterial = material;
				}
			}
		}

		public static GameObject? FindRecursive(this GameObject baseObject, string path, bool warnings = true)
		{
			Transform val = baseObject.transform;
			string[] array = path.Split("/");
			foreach (string text in array)
			{
				val = ((Component)val).transform.Find(text);
				if ((Object)(object)val == (Object)null)
				{
					if (warnings)
					{
						Plugin.Log.LogWarning((object)(text + " not found for object path " + ((Object)baseObject).name + "/" + path));
					}
					return null;
				}
			}
			return ((Component)val).gameObject;
		}

		public static GameObject? FindRecursive(string path, bool warnings = true)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			int num = path.IndexOf('/');
			string firstItem = "";
			string path2 = "";
			if (num != -1)
			{
				firstItem = path.Substring(0, num);
				path2 = path.Substring(num + 1);
			}
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject val = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
				where ((Object)obj).name == firstItem
				select obj).FirstOrDefault();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Root item not found for object path " + path));
				return null;
			}
			return val.FindRecursive(path2, warnings);
		}

		public static void PrintHierarchyTree(this Transform root, string indent = "")
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			Plugin.Log.LogInfo((object)(indent + "- " + ((Object)root).name));
			foreach (Transform item in root)
			{
				PrintHierarchyTree(item, indent + "  ");
			}
		}

		public static string GetFullPath(this GameObject go)
		{
			string text = ((Object)go).name;
			Transform val = go.transform;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
				text = ((Object)val).name + "/" + text;
			}
			return text;
		}
	}
}
namespace NukeLib.Text
{
	public static class TextUtils
	{
		public static string ToSnakeCase(this string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			return Regex.Replace(input, "(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])", "_").ToLowerInvariant();
		}

		public static string WrapText(this string text, int lineLength)
		{
			if (string.IsNullOrEmpty(text) || lineLength <= 0)
			{
				return text;
			}
			string[] array = text.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = Regex.Split(array[i], "(\\s+)");
				StringBuilder stringBuilder2 = new StringBuilder();
				string[] array3 = array2;
				foreach (string text2 in array3)
				{
					if (string.IsNullOrEmpty(text2))
					{
						continue;
					}
					if (stringBuilder2.Length + text2.Length > lineLength)
					{
						if (stringBuilder2.Length > 0)
						{
							stringBuilder.AppendLine(stringBuilder2.ToString().TrimEnd());
							stringBuilder2.Clear();
							if (char.IsWhiteSpace(text2[0]))
							{
								continue;
							}
						}
						if (text2.Length >= lineLength)
						{
							stringBuilder.AppendLine(text2);
							continue;
						}
					}
					stringBuilder2.Append(text2);
				}
				if (stringBuilder2.Length > 0)
				{
					stringBuilder.Append(stringBuilder2.ToString().TrimEnd());
				}
				if (i < array.Length - 1)
				{
					stringBuilder.AppendLine();
				}
			}
			return stringBuilder.ToString();
		}
	}
}
namespace NukeLib.Reflection
{
	[Obsolete]
	public static class ReflectionUtils
	{
		[Obsolete]
		public static T GetPrivate<T>(this object obj, string fieldName)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
			FieldInfo? field = type.GetField(fieldName, bindingAttr);
			if (field == null)
			{
				throw new ArgumentException("Field '" + fieldName + "' doesn't exist in class " + type.Name);
			}
			return (T)field.GetValue(obj);
		}

		[Obsolete]
		public static void SetPrivate<T>(this object obj, string fieldName, T value)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
			FieldInfo? field = type.GetField(fieldName, bindingAttr);
			if (field == null)
			{
				throw new ArgumentException("Field '" + fieldName + "' doesn't exist in class " + type.Name);
			}
			field.SetValue(obj, value);
		}

		[Obsolete]
		public static T InvokePrivate<T>(this object obj, string methodName, params object[] parameters)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
			MethodInfo? method = type.GetMethod(methodName, bindingAttr);
			if (method == null)
			{
				throw new ArgumentException("Method '" + methodName + "' doesn't exist in class " + type.Name);
			}
			return (T)method.Invoke(obj, parameters);
		}

		[Obsolete]
		public static void InvokePrivate(this object obj, string methodName, params object[] parameters)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
			MethodInfo? method = type.GetMethod(methodName, bindingAttr);
			if (method == null)
			{
				throw new ArgumentException("Method '" + methodName + "' doesn't exist in class " + type.Name);
			}
			method.Invoke(obj, parameters);
		}
	}
}
namespace NukeLib.ImageUtils
{
	[Obsolete]
	public static class ColorUtils
	{
		[Obsolete]
		public static float PerceivedLightness(this Color color)
		{
			//IL_0005: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			return 0.299f * color.r + 0.587f * color.g + 0.114f * color.b;
		}

		[Obsolete]
		public static Color Transparentize(this Color color, float value = 1f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.r, color.g, color.b, color.a * (1f - value));
		}
	}
	[Obsolete]
	public static class ImageUtils
	{
		private struct CacheItem
		{
			public string FilePath;

			public Color DominantColor;
		}

		private static readonly string[] SupportedExtensions = new string[3] { ".png", ".jpg", ".jpeg" };

		private static int _maxCacheSize = 1000;

		private static readonly Dictionary<string, LinkedListNode<CacheItem>> _cacheDict = new Dictionary<string, LinkedListNode<CacheItem>>();

		private static readonly LinkedList<CacheItem> _lruList = new LinkedList<CacheItem>();

		[Obsolete]
		public static int MaxCacheSize
		{
			get
			{
				return _maxCacheSize;
			}
			set
			{
				_maxCacheSize = Mathf.Max(0, value);
				TrimCache();
			}
		}

		[Obsolete]
		public static void ClearCache()
		{
			_cacheDict.Clear();
			_lruList.Clear();
		}

		private static void TrimCache()
		{
			while (_cacheDict.Count > _maxCacheSize)
			{
				LinkedListNode<CacheItem> last = _lruList.Last;
				if (last != null)
				{
					_cacheDict.Remove(last.Value.FilePath);
					_lruList.RemoveLast();
				}
			}
		}

		private static bool TryGetFromCache(string filePath, out Color color)
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (_maxCacheSize > 0 && _cacheDict.TryGetValue(filePath, out LinkedListNode<CacheItem> value))
			{
				_lruList.Remove(value);
				_lruList.AddFirst(value);
				color = value.Value.DominantColor;
				return true;
			}
			color = Color.black;
			return false;
		}

		private static void AddToCache(string filePath, Color color)
		{
			//IL_0060: 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_0041: 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)
			if (_maxCacheSize > 0)
			{
				if (_cacheDict.TryGetValue(filePath, out LinkedListNode<CacheItem> value))
				{
					_lruList.Remove(value);
					_lruList.AddFirst(value);
					value.Value = new CacheItem
					{
						FilePath = filePath,
						DominantColor = color
					};
				}
				else
				{
					LinkedListNode<CacheItem> linkedListNode = new LinkedListNode<CacheItem>(new CacheItem
					{
						FilePath = filePath,
						DominantColor = color
					});
					_lruList.AddFirst(linkedListNode);
					_cacheDict[filePath] = linkedListNode;
					TrimCache();
				}
			}
		}

		[Obsolete]
		public static Color GetDominantColor(Texture2D sourceTexture)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture temporary = RenderTexture.GetTemporary(1, 1, 0, (RenderTextureFormat)0);
			Graphics.Blit((Texture)(object)sourceTexture, temporary);
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, 1f, 1f), 0, 0);
			val.Apply();
			Color pixel = val.GetPixel(0, 0);
			RenderTexture.active = null;
			RenderTexture.ReleaseTemporary(temporary);
			Object.Destroy((Object)val);
			return pixel;
		}

		[Obsolete]
		public static Color GetDominantColor(string filePath)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0014: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetFromCache(filePath, out var color))
			{
				return color;
			}
			if (!File.Exists(filePath))
			{
				return Color.black;
			}
			byte[] array = File.ReadAllBytes(filePath);
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				Object.Destroy((Object)(object)val);
				return Color.black;
			}
			Color dominantColor = GetDominantColor(val);
			Object.Destroy((Object)(object)val);
			AddToCache(filePath, dominantColor);
			return dominantColor;
		}

		[Obsolete]
		public static string FindClosestColorImage(Color targetColor, string directoryPath)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0074: 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)
			if (!Directory.Exists(directoryPath))
			{
				return string.Empty;
			}
			string[] files = Directory.GetFiles(directoryPath, "*.*", SearchOption.TopDirectoryOnly);
			string result = string.Empty;
			float num = float.MaxValue;
			string[] array = files;
			foreach (string text in array)
			{
				string value = Path.GetExtension(text).ToLower();
				if (Array.IndexOf(SupportedExtensions, value) != -1)
				{
					Color dominantColor = GetDominantColor(text);
					float num2 = targetColor.r - dominantColor.r;
					float num3 = targetColor.g - dominantColor.g;
					float num4 = targetColor.b - dominantColor.b;
					float num5 = num2 * num2 + num3 * num3 + num4 * num4;
					if (num5 < num)
					{
						num = num5;
						result = text;
					}
				}
			}
			return result;
		}
	}
}
namespace NukeLib.Game
{
	public static class CheckpointEvents
	{
		[HarmonyPatch(typeof(CheckPoint))]
		internal static class CheckPointPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnRespawn")]
			public static void OnRespawn_Postfix(CheckPoint __instance)
			{
				try
				{
					TriggerCheckpointRestart(__instance);
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)ex);
				}
			}
		}

		public static event Action? CheckpointLoadedNoParam;

		public static event Action<CheckPoint>? CheckpointLoaded;

		internal static void TriggerCheckpointRestart(CheckPoint checkpoint)
		{
			CheckpointEvents.CheckpointLoadedNoParam?.Invoke();
			CheckpointEvents.CheckpointLoaded?.Invoke(checkpoint);
		}
	}
	public static class EnemyEvents
	{
		[HarmonyPatch(typeof(EnemyIdentifier))]
		internal static class EnemyPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("DeliverDamage")]
			private static void DeliverDamage_Prefix(EnemyIdentifier __instance, out float __state)
			{
				__state = __instance.health;
			}

			[HarmonyPostfix]
			[HarmonyPatch("DeliverDamage")]
			private static void DeliverDamage_Postfix(EnemyIdentifier __instance, float __state)
			{
				float health = __instance.health;
				health = Math.Max(health, 0f);
				float num = __state - health;
				if (num > 0f && num < 998f)
				{
					EnemyEvents.OnDamageTaken?.Invoke(__instance, num);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("Start")]
			public static void Start_Postfix(EnemyIdentifier __instance)
			{
				try
				{
					EnemyEvents.OnSpawn?.Invoke(__instance);
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"EnemyIdentifier Start postfix failed: {arg}");
				}
			}
		}

		public static event Action<EnemyIdentifier, float> OnDamageTaken;

		public static event Action<EnemyIdentifier> OnSpawn;
	}
	public static class FinalRankHelper
	{
		[HarmonyPatch(typeof(FinalRank))]
		internal static class EnemyPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("SetInfo")]
			private static void SetInfo_Postfix(FinalRank __instance)
			{
				try
				{
					string text = GeneralExtensions.Join<string>((IEnumerable<string>)ExtraInfoLines, (Func<string, string>)null, "\n") + "\n";
					TMP_Text extraInfo = __instance.extraInfo;
					extraInfo.text += text;
					FinalRankHelper.RankShown?.Invoke();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)ex);
				}
			}
		}

		public static List<string> ExtraInfoLines;

		public static event Action? RankShown;

		static FinalRankHelper()
		{
			ExtraInfoLines = new List<string>();
			SceneUtils.SafeSceneLoadedNoParam += ResetInfo;
		}

		private static void ResetInfo()
		{
			ExtraInfoLines.Clear();
		}

		public static void AddInfoLine(string line)
		{
			if (!ExtraInfoLines.Contains(line))
			{
				ExtraInfoLines.Add(line);
			}
		}

		public static void RemoveInfoLine(string line)
		{
			int num = ExtraInfoLines.IndexOf(line);
			if (num != -1)
			{
				ExtraInfoLines.RemoveAt(num);
			}
		}
	}
	public static class GunHelper
	{
		[Obsolete]
		public static int GetVariation(GameObject weapon, int weaponIndex)
		{
			int result = -1;
			if ((Object)(object)weapon == (Object)null)
			{
				return -1;
			}
			switch (weaponIndex)
			{
			case 0:
			{
				Revolver component2 = weapon.GetComponent<Revolver>();
				if ((Object)(object)component2 != (Object)null)
				{
					result = component2.gunVariation;
				}
				break;
			}
			case 1:
			{
				Shotgun component4 = weapon.GetComponent<Shotgun>();
				if ((Object)(object)component4 != (Object)null)
				{
					result = component4.variation;
					break;
				}
				ShotgunHammer component5 = weapon.GetComponent<ShotgunHammer>();
				if ((Object)(object)component5 != (Object)null)
				{
					result = component5.variation;
				}
				break;
			}
			case 2:
			{
				Nailgun component6 = weapon.GetComponent<Nailgun>();
				if ((Object)(object)component6 != (Object)null)
				{
					result = (4 - component6.variation) % 3;
				}
				break;
			}
			case 3:
			{
				Railcannon component3 = weapon.GetComponent<Railcannon>();
				if ((Object)(object)component3 != (Object)null)
				{
					result = component3.variation;
				}
				break;
			}
			case 4:
			{
				RocketLauncher component = weapon.GetComponent<RocketLauncher>();
				if ((Object)(object)component != (Object)null)
				{
					result = component.variation;
				}
				break;
			}
			}
			return result;
		}

		public static int GetVariation(GameObject weapon)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if ((Object)(object)weapon == (Object)null)
			{
				return -1;
			}
			WeaponIcon component = weapon.GetComponent<WeaponIcon>();
			if ((Object)(object)component == (Object)null)
			{
				return -1;
			}
			return (int)component.weaponDescriptor.variationColor;
		}
	}
	public static class LeaderboardHelper
	{
		public static void DisableLeaderboards()
		{
			AssistController instance = MonoSingleton<AssistController>.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.cheatsEnabled = true;
			}
		}
	}
	public static class Pauser
	{
		public static void Pause(bool paused, string pauseKey)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (paused)
			{
				GameState val = new GameState(pauseKey);
				val.cursorLock = (LockMode)2;
				val.playerInputLock = (LockMode)1;
				val.cameraInputLock = (LockMode)1;
				val.timerModifier = 0f;
				val.priority = 69;
				GameStateManager.Instance.RegisterState(val);
				Time.timeScale = 0f;
				if ((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null)
				{
					MonoSingleton<GunControl>.Instance.activated = false;
				}
				if ((Object)(object)MonoSingleton<AudioMixerController>.Instance != (Object)null)
				{
					MonoSingleton<AudioMixerController>.Instance.allSound.SetFloat("allPitch", 0f);
					MonoSingleton<AudioMixerController>.Instance.doorSound.SetFloat("allPitch", 0f);
				}
				if ((Object)(object)MonoSingleton<MusicManager>.Instance != (Object)null)
				{
					MonoSingleton<MusicManager>.Instance.FilterMusic();
				}
				return;
			}
			GameStateManager.Instance.PopState(pauseKey);
			if (SceneHelper.CurrentScene != "Main Menu")
			{
				OptionsManager instance = MonoSingleton<OptionsManager>.Instance;
				if (instance != null)
				{
					instance.UnPause();
				}
			}
		}
	}
	public static class PortalHelper
	{
		[HarmonyPatch(typeof(Portal))]
		internal static class PortalPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnEnable")]
			private static void OnEnable_Postfix(Portal __instance)
			{
				AddPortal(__instance);
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnDisable")]
			private static void OnDisable_Postfix(Portal __instance)
			{
				RemovePortal(__instance);
			}
		}

		private static readonly HashSet<Portal> _activePortals;

		public static IReadOnlyCollection<Portal> ActivePortals => _activePortals;

		static PortalHelper()
		{
			_activePortals = new HashSet<Portal>();
			SceneManager.sceneUnloaded += delegate
			{
				_activePortals.Clear();
			};
		}

		private static void AddPortal(Portal portal)
		{
			if ((Object)(object)portal != (Object)null)
			{
				_activePortals.Add(portal);
			}
		}

		private static void RemovePortal(Portal portal)
		{
			if ((Object)(object)portal != (Object)null)
			{
				_activePortals.Remove(portal);
			}
		}

		public static void GetPortalCorners(Transform portalTransform, Portal portal, out Vector3 p0, out Vector3 p1, out Vector3 p2, out Vector3 p3, float offsetDistance, Vector3? cameraPos)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL