Decompiled source of JadeLib v1.1.0

JadeLib.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("JadeLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+6606f4a230c0cbbd18b3610b6a95b812f4fb7363")]
[assembly: AssemblyProduct("JadeLib")]
[assembly: AssemblyTitle("JadeLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JadeLib
{
	public static class ColorExtensions
	{
		public static string ToHexString(this Color clr)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			return $"#{Mathf.RoundToInt(clr.r * 255f):X2}{Mathf.RoundToInt(clr.g * 255f):X2}{Mathf.RoundToInt(clr.b * 255f):X2}{Mathf.RoundToInt(clr.a * 255f):X2}";
		}
	}
	public static class EnumerableExtensions
	{
		public static void AddToArray<T>(ref T[] array, int index, params T[] values)
		{
			T[] array2 = array;
			List<T> list = new List<T>(array2.Length);
			list.AddRange(array2);
			List<T> list2 = list;
			list2.InsertRange(Mathf.Clamp(index, 0, list2.Count), values);
			array = list2.ToArray();
		}

		public static void AddToArray<T>(ref T[] array, int index, params T[][] values)
		{
			T[] array2 = array;
			List<T> list = new List<T>(array2.Length);
			list.AddRange(array2);
			List<T> list2 = list;
			list2.InsertRange(Mathf.Clamp(index, 0, list2.Count), values.Collapse());
			array = list2.ToArray();
		}

		public static IEnumerable<T> Collapse<T>(this IEnumerable<IEnumerable<T>> source)
		{
			return source.SelectMany((IEnumerable<T> values) => values);
		}

		public static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> selector)
		{
			return from @group in source.GroupBy(selector)
				select @group.First();
		}

		public static bool None<T>(this IEnumerable<T> source, Func<T, bool> predicate = null)
		{
			if (predicate != null)
			{
				return !source.Any(predicate);
			}
			return !source.Any();
		}

		public static IEnumerable<T> SelectManyRecursive<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> selector)
		{
			IEnumerable<T> enumerable = source.SelectMany(selector);
			if (enumerable.Any())
			{
				return enumerable.Concat(enumerable.SelectManyRecursive(selector));
			}
			return enumerable;
		}

		public static IEnumerable<T> CollapseRecursive<T>(this IEnumerable<IEnumerable<T>> source)
		{
			IEnumerable<T> enumerable = source.Collapse();
			if (enumerable is IEnumerable<IEnumerable<T>> source2)
			{
				return enumerable.Concat(source2.CollapseRecursive());
			}
			return enumerable;
		}
	}
	public static class EnumExtensions
	{
		public static void Do<T>(this T _, Action<T> action) where T : Enum
		{
			foreach (T value in Enum.GetValues(typeof(T)))
			{
				action(value);
			}
		}

		public static void DoIf<T>(this T _, Func<T, bool> condition, Action<T> action) where T : Enum
		{
			foreach (T value in Enum.GetValues(typeof(T)))
			{
				if (condition(value))
				{
					action(value);
				}
			}
		}

		public static string Name<T>(this T value) where T : Enum
		{
			return Enum.GetName(typeof(T), value);
		}
	}
	public static class GenericExtensions
	{
		public static string GetRankText(int index, bool rich = false)
		{
			return index switch
			{
				0 => rich ? "<color=blue>D</color>ESTRUCTIVE" : "DESTRUCTIVE", 
				2 => rich ? "<color=green>C</color>HAOTIC" : "CHAOTIC", 
				1 => rich ? "<color=yellow>B</color>RUTAL" : "BRUTAL", 
				3 => rich ? "<color=orange>A</color>NARCHIC" : "ANARCHIC", 
				4 => rich ? "<color=red>S</color>UPREME" : "SUPREME", 
				5 => rich ? "<color=red>SS</color>ADISTIC" : "SSADISTIC", 
				6 => rich ? "<color=red>SSS</color>HITSTORM" : "SSSHITSTORM", 
				7 => rich ? "<color=orange>ULTRAKILL</color>" : "ULTRAKILL", 
				_ => rich ? "<color=red><u>UNKNOWN</u></color>" : "UNKNOWN", 
			};
		}
	}
	public static class KeyValuePairExtensions
	{
		public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)
		{
			key = kvp.Key;
			value = kvp.Value;
		}
	}
	public static class VectorExtensions
	{
		public static Vector2 SetX(this Vector2 v, float x)
		{
			//IL_0001: 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)
			return new Vector2(x, v.y);
		}

		public static Vector2 SetY(this Vector2 v, float y)
		{
			//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)
			return new Vector2(v.x, y);
		}

		public static Vector2 Sqrt(Vector2 v)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ((Vector2)(ref v)).normalized * Mathf.Sqrt(((Vector2)(ref v)).magnitude);
		}

		public static Vector3 SetX(this Vector3 v, float x)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, v.y, v.z);
		}

		public static Vector3 SetY(this Vector3 v, float y)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v.x, y, v.z);
		}

		public static Vector3 SetZ(this Vector3 v, float z)
		{
			//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)
			return new Vector3(v.x, v.y, z);
		}

		public static Vector3 Sqrt(Vector3 v)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ((Vector3)(ref v)).normalized * Mathf.Sqrt(((Vector3)(ref v)).magnitude);
		}
	}
}
namespace JadeLib.PluginConfigurator
{
	public class SpriteField : CustomConfigField
	{
		private Image currentUI;

		private Sprite sprite;

		public Sprite Sprite
		{
			get
			{
				return sprite;
			}
			set
			{
				SetSprite(sprite = value);
			}
		}

		public SpriteField(ConfigPanel parentPanel, Sprite sprite = null)
		{
			this.sprite = sprite;
			((CustomConfigField)this)..ctor(parentPanel);
		}

		protected override void OnCreateUI(RectTransform fieldUI)
		{
			currentUI = ((Component)fieldUI).gameObject.AddComponent<Image>();
			SetSprite(sprite);
		}

		private void SetSprite(Sprite sprite)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Image obj = currentUI;
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(Object.op_Implicit((Object)(object)sprite));
			}
			if (Object.op_Implicit((Object)(object)currentUI) && Object.op_Implicit((Object)(object)sprite))
			{
				Transform transform = ((Component)currentUI).transform;
				Transform obj2 = ((transform is RectTransform) ? transform : null);
				Rect rect = sprite.rect;
				Vector2 sizeDelta;
				if (!(((Rect)(ref rect)).size.x > 600f))
				{
					rect = sprite.rect;
					sizeDelta = ((Rect)(ref rect)).size;
				}
				else
				{
					rect = sprite.rect;
					Vector2 size = ((Rect)(ref rect)).size;
					rect = sprite.rect;
					sizeDelta = size * (600f / ((Rect)(ref rect)).size.x);
				}
				((RectTransform)obj2).sizeDelta = sizeDelta;
				currentUI.sprite = sprite;
			}
		}
	}
	public static class PluginConfiguratorExtensions
	{
		public static void SetEnumDisplayNames<T>(this EnumField<T> field, params string[] names) where T : struct, Enum
		{
			T[] array = Enum.GetValues(typeof(T)) as T[];
			for (int i = 0; i < Math.Min(array.Length, names.Length); i++)
			{
				field.SetEnumDisplayName(array[i], names[i]);
			}
		}
	}
}