Decompiled source of VheosModPack v2.0.8

BepInEx/Plugins/Vheos/Vheos.Helpers.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.SceneManagement;
using Vheos.Helpers.Common;
using Vheos.Helpers.Math;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Vheos.Helpers.UnityObjects
{
	public static class Extensions_Camera
	{
		public static Ray CursorRay(this Camera @this)
		{
			//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 @this.ScreenPointToRay(Input.mousePosition);
		}

		public static Plane ScreenPlane(this Camera @this, Vector3 a)
		{
			//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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return new Plane(((Component)@this).transform.forward.Neg(), a);
		}

		public static Plane ScreenPlane(this Camera @this, float a)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			return new Plane(((Component)@this).transform.forward.Neg(), a);
		}

		public static Vector3 CursorToWorldPoint(this Camera @this, float a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return @this.ScreenToWorldPoint(Input.mousePosition.XY().Append(a));
		}

		public static Vector3 CursorToPlanePoint(this Camera @this, Plane a)
		{
			//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_0009: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			Ray val = @this.CursorRay();
			float num = default(float);
			if (!((Plane)(ref a)).Raycast(val, ref num))
			{
				return float.NaN.ToVector3();
			}
			return ((Ray)(ref val)).GetPoint(num);
		}
	}
	public static class Extensions_MonoBehaviour
	{
		public static void Enable(this MonoBehaviour t)
		{
			((Behaviour)t).enabled = true;
		}

		public static void Disable(this MonoBehaviour t)
		{
			((Behaviour)t).enabled = false;
		}

		public static Coroutine ExecuteAfterUpdate(this MonoBehaviour @this, Action action)
		{
			return @this.StartCoroutine(AfterUpdate(action));
		}

		public static Coroutine ExecuteAfterFixedUpdate(this MonoBehaviour @this, Action action)
		{
			return @this.StartCoroutine(AfterFixedUpdate(action));
		}

		public static Coroutine ExecuteAfterCurrentUpdate(this MonoBehaviour @this, Action action)
		{
			return @this.StartCoroutine(AfterCurrentUpdate(action));
		}

		public static Coroutine ExecuteAfterSeconds(this MonoBehaviour @this, float delay, Action action)
		{
			return @this.StartCoroutine(AfterSeconds(delay, action));
		}

		public static Coroutine ExecuteAfterRealSeconds(this MonoBehaviour @this, float delay, Action action)
		{
			return @this.StartCoroutine(AfterRealSeconds(delay, action));
		}

		public static Coroutine ExecuteAfterCheck(this MonoBehaviour @this, Func<bool> test, Action action)
		{
			return @this.StartCoroutine(AfterCheck(test, action));
		}

		public static Coroutine ExecuteWhile(this MonoBehaviour @this, Func<bool> test, Action action, Action finalAction = null)
		{
			return @this.StartCoroutine(While(test, action, finalAction));
		}

		public static Coroutine ExecuteWhileNot(this MonoBehaviour @this, Func<bool> test, Action action, Action finalAction = null)
		{
			return @this.StartCoroutine(WhileNot(test, action, finalAction));
		}

		public static Coroutine ExecuteUntil(this MonoBehaviour @this, Func<bool> test, Action action, Action finalAction = null)
		{
			return @this.StartCoroutine(Until(test, action, finalAction));
		}

		public static Coroutine ExecuteUntilNot(this MonoBehaviour @this, Func<bool> test, Action action, Action finalAction = null)
		{
			return @this.StartCoroutine(UntilNot(test, action, finalAction));
		}

		private static IEnumerator AfterUpdate(Action action)
		{
			yield return (object)new WaitForEndOfFrame();
			action();
		}

		private static IEnumerator AfterFixedUpdate(Action action)
		{
			yield return (object)new WaitForFixedUpdate();
			action();
		}

		private static IEnumerator AfterCurrentUpdate(Action action)
		{
			yield return (object)(Time.inFixedTimeStep ? new WaitForFixedUpdate() : new WaitForEndOfFrame());
			action();
		}

		private static IEnumerator AfterSeconds(float delay, Action action)
		{
			yield return (object)new WaitForSeconds(delay);
			action();
		}

		private static IEnumerator AfterRealSeconds(float delay, Action action)
		{
			yield return (object)new WaitForSecondsRealtime(delay);
			action();
		}

		private static IEnumerator AfterCheck(Func<bool> check, Action action)
		{
			yield return (object)new WaitUntil(check);
			action();
		}

		private static IEnumerator While(Func<bool> test, Action action, Action finalAction = null)
		{
			while (test())
			{
				action();
				yield return null;
			}
			finalAction?.Invoke();
		}

		private static IEnumerator WhileNot(Func<bool> test, Action action, Action finalAction = null)
		{
			while (!test())
			{
				action();
				yield return null;
			}
			finalAction?.Invoke();
		}

		private static IEnumerator Until(Func<bool> test, Action action, Action finalAction = null)
		{
			do
			{
				action();
				yield return null;
			}
			while (!test());
			finalAction?.Invoke();
		}

		private static IEnumerator UntilNot(Func<bool> test, Action action, Action finalAction = null)
		{
			do
			{
				action();
				yield return null;
			}
			while (test());
			finalAction?.Invoke();
		}
	}
	public static class Extensions_Component
	{
		public static void Activate(this Component t)
		{
			t.gameObject.SetActive(true);
		}

		public static void Deactivate(this Component t)
		{
			t.gameObject.SetActive(false);
		}

		public static bool IsActive(this Component t)
		{
			return t.gameObject.activeSelf;
		}

		public static bool IsActiveInHierarchy(this Component t)
		{
			return t.gameObject.activeInHierarchy;
		}

		public static void ToggleActive(this Component t)
		{
			t.gameObject.ToggleActive();
		}

		public static void SetActive(this Component t, bool state)
		{
			t.gameObject.SetActive(state);
		}

		public static void Unparent(this Component @this, bool retainWorldTransform = false)
		{
			@this.gameObject.Unparent(retainWorldTransform);
		}

		public static void MoveToScene(this Component @this, Scene scene)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			@this.gameObject.MoveToScene(scene);
		}

		public static void BecomeSiblingOf(this Component @this, GameObject a, bool retainWorldTransform = false)
		{
			@this.gameObject.BecomeSiblingOf(a, retainWorldTransform);
		}

		public static void BecomeChildOf(this Component @this, GameObject a, bool retainWorldTransform = false)
		{
			@this.gameObject.BecomeChildOf(a, retainWorldTransform);
		}

		public static void BecomeSiblingOf(this Component @this, Component a, bool retainWorldTransform = false)
		{
			@this.gameObject.BecomeSiblingOf(a, retainWorldTransform);
		}

		public static void BecomeChildOf(this Component @this, Component a, bool retainWorldTransform = false)
		{
			@this.gameObject.BecomeChildOf(a, retainWorldTransform);
		}

		public static bool IsAtRoot(this Component @this)
		{
			return @this.gameObject.IsAtRoot();
		}

		public static bool HasParent(this Component @this)
		{
			return @this.gameObject.HasParent();
		}

		public static bool HasAnyChild(this Component @this)
		{
			return @this.gameObject.HasAnyChild();
		}

		public static bool IsParentOf(this Component @this, GameObject a)
		{
			return @this.gameObject.IsParentOf(a);
		}

		public static bool IsSiblingOf(this Component @this, GameObject a)
		{
			return @this.gameObject.IsSiblingOf(a);
		}

		public static bool IsChildOf(this Component @this, GameObject a)
		{
			return @this.gameObject.IsChildOf(a);
		}

		public static bool IsParentOf(this Component @this, Component a)
		{
			return @this.gameObject.IsParentOf(a);
		}

		public static bool IsSiblingOf(this Component @this, Component a)
		{
			return @this.gameObject.IsSiblingOf(a);
		}

		public static bool IsChildOf(this Component @this, Component a)
		{
			return @this.gameObject.IsChildOf(a);
		}

		public static GameObject FindChild(this Component @this, string a)
		{
			return @this.gameObject.FindChild(a);
		}

		public static T FindChild<T>(this Component @this, string a) where T : Component
		{
			return @this.gameObject.FindChild<T>(a);
		}

		public static GameObject GetParent(this Component @this)
		{
			return @this.gameObject.GetParent();
		}

		public static IEnumerable<GameObject> GetAncestors(this Component @this)
		{
			return @this.gameObject.GetAncestors();
		}

		public static GameObject GetRootAncestor(this Component @this)
		{
			return @this.gameObject.GetRootAncestor();
		}

		public static float DistanceTo(this Component @this, GameObject a)
		{
			return @this.gameObject.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.RayTowards(a);
		}

		public static Ray RayAwayFrom(this Component @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this Component @this, GameObject a, Camera b)
		{
			return @this.gameObject.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this Component @this, GameObject a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this Component @this, GameObject a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this Component @this, GameObject a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this Component @this, GameObject a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenDirectionAwayFrom(a, b);
		}

		public static float DistanceTo(this Component @this, Component a)
		{
			return @this.gameObject.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.RayTowards(a);
		}

		public static Ray RayAwayFrom(this Component @this, Component a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this Component @this, Component a, Camera b)
		{
			return @this.gameObject.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this Component @this, Component a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this Component @this, Component a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this Component @this, Component a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this Component @this, Component a, Camera b)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenDirectionAwayFrom(a, b);
		}

		public static float DistanceTo(this Component @this, Vector3 a)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.RayTowards(a);
		}

		public static Ray RayAwayFrom(this Component @this, Vector3 a)
		{
			//IL_0006: 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 @this.gameObject.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this Component @this, Vector3 a, Camera b)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.gameObject.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this Component @this, Vector3 a, Camera b)
		{
			//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)
			return @this.gameObject.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this Component @this, Vector3 a, Camera b)
		{
			//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)
			return @this.gameObject.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this Component @this, Vector3 a, Camera b)
		{
			//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)
			return @this.gameObject.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this Component @this, Vector3 a, Camera b)
		{
			//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)
			return @this.gameObject.ScreenDirectionAwayFrom(a, b);
		}

		public static bool HasComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.HasComponent<T>();
		}

		public static bool ParentHasComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.ParentHasComponent<T>();
		}

		public static bool ChildHasComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.ChildHasComponent<T>();
		}

		public static GameObject CreateSiblingGameObject(this Component @this, string name = null)
		{
			return @this.gameObject.CreateSiblingGameObject(name);
		}

		public static T CreateSiblingComponent<T>(this Component @this, T a, string name = null) where T : Component
		{
			return @this.gameObject.CreateSiblingComponent(a, name);
		}

		public static T CreateSiblingComponent<T>(this Component @this, string name = null) where T : Component
		{
			return @this.gameObject.CreateSiblingComponent<T>(name);
		}

		public static GameObject CreateChildGameObject(this Component @this, string name = null)
		{
			return @this.gameObject.CreateChildGameObject(name);
		}

		public static T CreateChildComponent<T>(this Component @this, T a, string name = null) where T : Component
		{
			return @this.gameObject.CreateChildComponent(a, name);
		}

		public static T CreateChildComponent<T>(this Component @this, string name = null) where T : Component
		{
			return @this.gameObject.CreateChildComponent<T>(name);
		}

		public static T GetOrAddComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.GetOrAddComponent<T>();
		}

		public static IEnumerable<GameObject> GetChildGameObjects(this Component @this)
		{
			return @this.gameObject.GetChildGameObjects();
		}

		public static IEnumerable<GameObject> GetSiblingGameObjects(this Component @this)
		{
			return @this.gameObject.GetSiblingGameObjects();
		}

		public static IEnumerable<T> GetChildComponents<T>(this Component @this) where T : Component
		{
			return @this.gameObject.GetChildComponents<T>();
		}

		public static IEnumerable<T> GetSiblingComponents<T>(this Component @this) where T : Component
		{
			return @this.gameObject.GetSiblingComponents<T>();
		}

		public static IEnumerable<GameObject> GetGameObjects<T>(this IEnumerable<T> @this) where T : Component
		{
			foreach (T item in @this)
			{
				yield return ((Component)item).gameObject;
			}
		}

		public static T GetChildComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.GetChildComponent<T>();
		}

		public static T GetSiblingComponent<T>(this Component @this) where T : Component
		{
			return @this.gameObject.GetSiblingComponent<T>();
		}

		public static bool TryGetComponent<T>(this Component @this, out T a) where T : Component
		{
			return @this.gameObject.TryGetComponent<T>(out a);
		}

		public static void Destroy(this Component @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.Destroy((Object)(object)@this);
			}
		}

		public static void DestroyInstantly(this Component @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)@this);
			}
		}

		public static void Destroy<T>(this IEnumerable<T> @this) where T : Component
		{
			foreach (T item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}

		public static void DestroyInstantly<T>(this IEnumerable<T> @this) where T : Component
		{
			foreach (T item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)item);
				}
			}
		}

		public static void DestroyObject(this Component @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.Destroy((Object)(object)@this.gameObject);
			}
		}

		public static void DestroyObjectInstantly(this Component @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)@this.gameObject);
			}
		}

		public static void DestroyObject<T>(this IEnumerable<T> @this) where T : Component
		{
			foreach (T item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)item).gameObject);
				}
			}
		}

		public static void DestroyObjectInstantly<T>(this IEnumerable<T> @this) where T : Component
		{
			foreach (T item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)item);
				}
			}
		}

		public static void SetPhysics(this Component @this, bool state)
		{
			@this.gameObject.SetPhysics(state);
		}

		public static void SetCollisions(this Component @this, bool state)
		{
			@this.gameObject.SetCollisions(state);
		}

		public static void ResetLocalTransform(this Component @this)
		{
			@this.gameObject.ResetLocalTransform();
		}

		public static void SetCollisionsWith(this Component @this, GameObject a, bool state)
		{
			@this.gameObject.SetCollisionsWith(a, state);
		}

		public static void SetCollisionsWith(this Component @this, IEnumerable<GameObject> aCollection, bool state)
		{
			@this.gameObject.SetCollisionsWith(aCollection, state);
		}

		public static void CopyTransformFrom(this Component @this, GameObject a)
		{
			@this.gameObject.CopyTransformFrom(a);
		}

		public static void CopyRigidbodyFrom(this Component @this, GameObject a, bool copyMassAndTensors = false)
		{
			@this.gameObject.CopyRigidbodyFrom(a, copyMassAndTensors);
		}

		public static void SetCollisionsWith(this Component @this, Component a, bool state)
		{
			@this.gameObject.SetCollisionsWith(a, state);
		}

		public static void SetCollisionsWith(this Component @this, IEnumerable<Component> aCollection, bool state)
		{
			@this.gameObject.SetCollisionsWith(aCollection, state);
		}

		public static void CopyTransformFrom(this Component @this, Component a)
		{
			@this.gameObject.CopyTransformFrom(a);
		}

		public static void CopyRigidbodyFrom(this Component @this, Component a, bool copyMassAndTensors = false)
		{
			@this.gameObject.CopyRigidbodyFrom(a, copyMassAndTensors);
		}
	}
	public static class Extensions_GameObject
	{
		public static void Activate(this GameObject t)
		{
			t.SetActive(true);
		}

		public static void Deactivate(this GameObject t)
		{
			t.SetActive(false);
		}

		public static bool IsActive(this GameObject t)
		{
			return t.activeSelf;
		}

		public static bool IsActiveInHierarchy(this GameObject t)
		{
			return t.activeInHierarchy;
		}

		public static void ToggleActive(this GameObject t)
		{
			t.SetActive(!t.activeSelf);
		}

		public static void Unparent(this GameObject @this, bool retainWorldTransform = false)
		{
			@this.transform.SetParent((Transform)null, retainWorldTransform);
		}

		public static void MoveToScene(this GameObject @this, Scene scene)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!(@this.gameObject.scene == scene))
			{
				@this.Unparent();
				SceneManager.MoveGameObjectToScene(@this, scene);
			}
		}

		public static void BecomeSiblingOf(this GameObject @this, GameObject a, bool retainWorldTransform = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (a.transform.parent.TryNonNull<Transform>(out var r))
			{
				@this.transform.SetParent(r, retainWorldTransform);
			}
			else
			{
				SceneManager.MoveGameObjectToScene(@this, a.scene);
			}
		}

		public static void BecomeChildOf(this GameObject @this, GameObject a, bool retainWorldTransform = false)
		{
			@this.transform.SetParent(a.transform, retainWorldTransform);
		}

		public static void BecomeSiblingOf(this GameObject @this, Component a, bool retainWorldTransform = false)
		{
			@this.BecomeSiblingOf(a.gameObject, retainWorldTransform);
		}

		public static void BecomeChildOf(this GameObject @this, Component a, bool retainWorldTransform = false)
		{
			@this.BecomeChildOf(a.gameObject, retainWorldTransform);
		}

		public static bool IsAtRoot(this GameObject @this)
		{
			return (Object)(object)@this.transform.parent == (Object)null;
		}

		public static bool HasParent(this GameObject @this)
		{
			return (Object)(object)@this.transform.parent != (Object)null;
		}

		public static bool HasAnyChild(this GameObject @this)
		{
			return @this.transform.childCount > 0;
		}

		public static bool IsParentOf(this GameObject @this, GameObject a)
		{
			return (Object)(object)@this.transform == (Object)(object)a.transform.parent;
		}

		public static bool IsSiblingOf(this GameObject @this, GameObject a)
		{
			return (Object)(object)@this.transform.parent == (Object)(object)a.transform.parent;
		}

		public static bool IsChildOf(this GameObject @this, GameObject a)
		{
			return (Object)(object)@this.transform.parent == (Object)(object)a.transform;
		}

		public static bool IsParentOf(this GameObject @this, Component a)
		{
			return @this.IsParentOf(a.gameObject);
		}

		public static bool IsSiblingOf(this GameObject @this, Component a)
		{
			return @this.IsSiblingOf(a.gameObject);
		}

		public static bool IsChildOf(this GameObject @this, Component a)
		{
			return @this.IsChildOf(a.gameObject);
		}

		public static GameObject FindChild(this GameObject @this, string a)
		{
			Transform val = @this.transform.Find(a);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return ((Component)val).gameObject;
		}

		public static T FindChild<T>(this GameObject @this, string a) where T : Component
		{
			Transform val = @this.transform.Find(a);
			if (!((Object)(object)val != (Object)null))
			{
				return default(T);
			}
			return ((Component)val).GetComponent<T>();
		}

		public static GameObject GetParent(this GameObject @this)
		{
			if (!@this.HasParent())
			{
				return null;
			}
			return ((Component)@this.transform.parent).gameObject;
		}

		public static IEnumerable<GameObject> GetAncestors(this GameObject @this)
		{
			Transform i = @this.transform.parent;
			while ((Object)(object)i != (Object)null)
			{
				yield return ((Component)i).gameObject;
				i = i.parent;
			}
		}

		public static GameObject GetRootAncestor(this GameObject @this)
		{
			Transform val = @this.transform;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
			}
			return ((Component)val).gameObject;
		}

		public static float DistanceTo(this GameObject @this, GameObject a)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.RayTowards(a);
		}

		public static Ray RayAwayFrom(this GameObject @this, GameObject a)
		{
			//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)
			return @this.transform.position.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this GameObject @this, GameObject a, Camera b)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this GameObject @this, GameObject a, Camera b)
		{
			//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 @this.transform.position.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this GameObject @this, GameObject a, Camera b)
		{
			//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 @this.transform.position.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this GameObject @this, GameObject a, Camera b)
		{
			//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 @this.transform.position.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this GameObject @this, GameObject a, Camera b)
		{
			//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 @this.transform.position.ScreenDirectionAwayFrom(a, b);
		}

		public static float DistanceTo(this GameObject @this, Component a)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.RayTowards(a);
		}

		public static Ray RayAwayFrom(this GameObject @this, Component a)
		{
			//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)
			return @this.transform.position.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this GameObject @this, Component a, Camera b)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this GameObject @this, Component a, Camera b)
		{
			//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 @this.transform.position.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this GameObject @this, Component a, Camera b)
		{
			//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 @this.transform.position.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this GameObject @this, Component a, Camera b)
		{
			//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 @this.transform.position.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this GameObject @this, Component a, Camera b)
		{
			//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 @this.transform.position.ScreenDirectionAwayFrom(a, b);
		}

		public static float DistanceTo(this GameObject @this, Vector3 a)
		{
			//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)
			return @this.transform.position.DistanceTo(a);
		}

		public static Vector3 OffsetTo(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.OffsetTo(a);
		}

		public static Vector3 OffsetFrom(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.OffsetFrom(a);
		}

		public static Vector3 DirectionTowards(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.DirectionTowards(a);
		}

		public static Vector3 DirectionAwayFrom(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.DirectionAwayFrom(a);
		}

		public static Ray RayTowards(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.RayTowards(a);
		}

		public static Ray RayAwayFrom(this GameObject @this, Vector3 a)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.RayAwayFrom(a);
		}

		public static float ScreenDistanceTo(this GameObject @this, Vector3 a, Camera b)
		{
			//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)
			return @this.transform.position.ScreenDistanceTo(a, b);
		}

		public static Vector2 ScreenOffsetTo(this GameObject @this, Vector3 a, Camera b)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenOffsetTo(a, b);
		}

		public static Vector2 ScreenOffsetFrom(this GameObject @this, Vector3 a, Camera b)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenOffsetFrom(a, b);
		}

		public static Vector2 ScreenDirectionTowards(this GameObject @this, Vector3 a, Camera b)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenDirectionTowards(a, b);
		}

		public static Vector2 ScreenDirectionAwayFrom(this GameObject @this, Vector3 a, Camera b)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			return @this.transform.position.ScreenDirectionAwayFrom(a, b);
		}

		public static bool HasComponent<T>(this GameObject @this) where T : Component
		{
			return (Object)(object)@this.GetComponent<T>() != (Object)null;
		}

		public static bool ParentHasComponent<T>(this GameObject @this) where T : Component
		{
			return (Object)(object)@this.GetParentComponent<T>() != (Object)null;
		}

		public static bool ChildHasComponent<T>(this GameObject @this) where T : Component
		{
			return (Object)(object)@this.GetChildComponent<T>() != (Object)null;
		}

		public static bool SiblingHasComponent<T>(this GameObject @this) where T : Component
		{
			return (Object)(object)@this.GetSiblingComponent<T>() != (Object)null;
		}

		public static T GetParentComponent<T>(this GameObject @this) where T : Component
		{
			if (!@this.transform.parent.TryNonNull<Transform>(out var r))
			{
				return default(T);
			}
			return ((Component)r).GetComponent<T>();
		}

		public static T GetChildComponent<T>(this GameObject @this) where T : Component
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			foreach (Transform item in @this.transform)
			{
				if (((Component)item).TryGetComponent<T>(out var a))
				{
					return a;
				}
			}
			return default(T);
		}

		public static T GetSiblingComponent<T>(this GameObject @this) where T : Component
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			foreach (Transform item in @this.transform.parent)
			{
				Transform val = item;
				if ((Object)(object)val != (Object)(object)@this.transform && ((Component)(object)val).TryGetComponent<T>(out var a))
				{
					return a;
				}
			}
			return default(T);
		}

		public static IEnumerable<T> GetParentComponents<T>(this GameObject @this) where T : Component
		{
			foreach (Transform item in @this.transform)
			{
				Transform val = item;
				T[] components = ((Component)val).GetComponents<T>();
				for (int i = 0; i < components.Length; i++)
				{
					yield return components[i];
				}
			}
		}

		public static IEnumerable<T> GetChildComponents<T>(this GameObject @this) where T : Component
		{
			foreach (Transform item in @this.transform)
			{
				Transform val = item;
				T[] components = ((Component)val).GetComponents<T>();
				for (int i = 0; i < components.Length; i++)
				{
					yield return components[i];
				}
			}
		}

		public static IEnumerable<T> GetSiblingComponents<T>(this GameObject @this) where T : Component
		{
			foreach (Transform item in @this.transform.parent)
			{
				Transform val = item;
				if ((Object)(object)val != (Object)(object)@this.transform)
				{
					T[] components = ((Component)val).GetComponents<T>();
					for (int i = 0; i < components.Length; i++)
					{
						yield return components[i];
					}
				}
			}
		}

		public static IEnumerable<GameObject> GetChildGameObjects(this GameObject @this)
		{
			foreach (Transform item in @this.transform)
			{
				Transform val = item;
				yield return ((Component)val).gameObject;
			}
		}

		public static IEnumerable<GameObject> GetSiblingGameObjects(this GameObject @this)
		{
			foreach (Transform item in @this.transform.parent)
			{
				Transform val = item;
				if ((Object)(object)val != (Object)(object)@this.transform)
				{
					yield return ((Component)val).gameObject;
				}
			}
		}

		public static GameObject CreateChildGameObject(this GameObject @this, string name = null)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			val.BecomeChildOf(@this);
			if (name != null)
			{
				((Object)val).name = name;
			}
			return val;
		}

		public static T CreateChildComponent<T>(this GameObject @this, T a, string name = null) where T : Component
		{
			T val = Object.Instantiate<T>(a, @this.transform);
			if (name != null)
			{
				((Object)(object)val).name = name;
			}
			return val;
		}

		public static T CreateChildComponent<T>(this GameObject @this, string name = null) where T : Component
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			val.BecomeChildOf(@this);
			T result = val.AddComponent<T>();
			if (name != null)
			{
				((Object)val).name = name;
			}
			return result;
		}

		public static GameObject CreateSiblingGameObject(this GameObject @this, string name = null)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			val.BecomeSiblingOf(@this);
			if (name != null)
			{
				((Object)val).name = name;
			}
			return val;
		}

		public static T CreateSiblingComponent<T>(this GameObject @this, T a, string name = null) where T : Component
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			T val = Object.Instantiate<T>(a, @this.transform.parent);
			if ((Object)(object)@this.transform.parent == (Object)null)
			{
				((Component)val).gameObject.MoveToScene(@this.scene);
			}
			if (name != null)
			{
				((Object)(object)val).name = name;
			}
			return val;
		}

		public static T CreateSiblingComponent<T>(this GameObject @this, string name = null) where T : Component
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			val.BecomeSiblingOf(@this);
			T result = val.AddComponent<T>();
			if (name != null)
			{
				((Object)val).name = name;
			}
			return result;
		}

		public static T GetOrAddComponent<T>(this GameObject @this) where T : Component
		{
			T component = @this.GetComponent<T>();
			if (!((Object)(object)component != (Object)null))
			{
				return @this.AddComponent<T>();
			}
			return component;
		}

		public static IEnumerable<T> GetComponents<T>(this IEnumerable<GameObject> @this) where T : Component
		{
			foreach (GameObject item in @this)
			{
				T[] components = item.GetComponents<T>();
				for (int i = 0; i < components.Length; i++)
				{
					yield return components[i];
				}
			}
		}

		public static bool TryGetComponent<T>(this GameObject @this, out T a) where T : Component
		{
			a = @this.GetComponent<T>();
			return (Object)(object)a != (Object)null;
		}

		public static void Destroy(this GameObject @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.Destroy((Object)(object)@this);
			}
		}

		public static void DestroyInstantly(this GameObject @this)
		{
			if ((Object)(object)@this != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)@this);
			}
		}

		public static void Destroy(this IEnumerable<GameObject> @this)
		{
			foreach (GameObject item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}

		public static void DestroyInstantly(this IEnumerable<GameObject> @this)
		{
			foreach (GameObject item in @this)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)item);
				}
			}
		}

		public static void SetPhysics(this GameObject @this, bool state)
		{
			@this.GetComponent<Rigidbody>().isKinematic = !state;
		}

		public static void SetCollisions(this GameObject @this, bool state)
		{
			Collider[] components = @this.GetComponents<Collider>();
			for (int i = 0; i < components.Length; i++)
			{
				components[i].isTrigger = !state;
			}
		}

		public static void ResetLocalTransform(this GameObject @this)
		{
			//IL_0006: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			@this.transform.localPosition = Vector3.zero;
			@this.transform.localRotation = Quaternion.identity;
			@this.transform.localScale = Vector3.one;
		}

		public static void SetCollisionsWith(this GameObject @this, GameObject a, bool state)
		{
			Collider[] components = @this.GetComponents<Collider>();
			foreach (Collider val in components)
			{
				Collider[] components2 = a.GetComponents<Collider>();
				foreach (Collider val2 in components2)
				{
					Physics.IgnoreCollision(val, val2, !state);
				}
			}
		}

		public static void SetCollisionsWith(this GameObject @this, IEnumerable<GameObject> aCollection, bool state)
		{
			foreach (GameObject item in aCollection)
			{
				@this.SetCollisionsWith(item, state);
			}
		}

		public static void CopyTransformFrom(this GameObject @this, GameObject a)
		{
			CopyLocalTransform(a.transform, @this.transform);
		}

		public static void CopyRigidbodyFrom(this GameObject @this, GameObject a, bool copyMassAndTensors = false)
		{
			CopyRigidbody(a.GetComponent<Rigidbody>(), @this.GetComponent<Rigidbody>(), copyMassAndTensors);
		}

		public static void SetCollisionsWith(this GameObject @this, Component a, bool state)
		{
			@this.SetCollisionsWith(a.gameObject, state);
		}

		public static void SetCollisionsWith(this GameObject @this, IEnumerable<Component> aCollection, bool state)
		{
			foreach (Component item in aCollection)
			{
				@this.SetCollisionsWith(item.gameObject, state);
			}
		}

		public static void CopyTransformFrom(this GameObject @this, Component a)
		{
			@this.CopyTransformFrom(a.gameObject);
		}

		public static void CopyRigidbodyFrom(this GameObject @this, Component a, bool copyMassAndTensors = false)
		{
			@this.CopyRigidbodyFrom(a.gameObject, copyMassAndTensors);
		}

		private static void CopyLocalTransform(Transform from, Transform to)
		{
			//IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			to.localPosition = from.localPosition;
			to.localRotation = from.localRotation;
			to.localScale = from.localScale;
		}

		private static void CopyRigidbody(Rigidbody from, Rigidbody to, bool copyMassAndTensors = false)
		{
			//IL_0002: 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_0056: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			to.velocity = from.velocity;
			to.drag = from.drag;
			to.angularVelocity = from.angularVelocity;
			to.angularDrag = from.angularDrag;
			to.isKinematic = from.isKinematic;
			to.useGravity = from.useGravity;
			to.freezeRotation = from.freezeRotation;
			to.constraints = from.constraints;
			to.detectCollisions = from.detectCollisions;
			to.collisionDetectionMode = from.collisionDetectionMode;
			to.interpolation = from.interpolation;
			to.maxAngularVelocity = from.maxAngularVelocity;
			to.maxDepenetrationVelocity = from.maxDepenetrationVelocity;
			to.sleepThreshold = from.sleepThreshold;
			to.mass = 1f;
			to.solverIterations = from.solverIterations;
			to.solverVelocityIterations = from.solverVelocityIterations;
			to.ResetCenterOfMass();
			to.ResetInertiaTensor();
			if (copyMassAndTensors)
			{
				to.mass = from.mass;
				to.centerOfMass = from.centerOfMass;
				to.inertiaTensor = from.inertiaTensor;
				to.inertiaTensorRotation = from.inertiaTensorRotation;
			}
		}
	}
	public static class Extensions
	{
		public static float StartValue(this AnimationCurve @this)
		{
			return ((Keyframe)(ref @this.keys[0])).value;
		}

		public static float EndValue(this AnimationCurve @this)
		{
			return ((Keyframe)(ref @this.keys[@this.keys.Length - 1])).value;
		}

		public static float StartTime(this AnimationCurve @this)
		{
			return ((Keyframe)(ref @this.keys[0])).time;
		}

		public static float EndTime(this AnimationCurve @this)
		{
			return ((Keyframe)(ref @this.keys[@this.keys.Length - 1])).time;
		}

		public static float Duration(this AnimationCurve @this)
		{
			return @this.EndTime() - @this.StartTime();
		}

		public static bool IsValid(this AnimationCurve @this)
		{
			return @this.length >= 2;
		}

		public static void AddLinearKeys(this AnimationCurve @this, params (float Time, float Value)[] a)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < a.Length; i++)
			{
				@this.AddKey(new Keyframe(a[i].Time, a[i].Value, 0f, 0f));
			}
		}

		public static bool Pressed(this KeyCode @this)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKeyDown(@this);
		}

		public static bool Released(this KeyCode @this)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKeyUp(@this);
		}

		public static bool Down(this KeyCode @this)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(@this);
		}

		public static bool Up(this KeyCode @this)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return !Input.GetKey(@this);
		}

		public static RaycastHit[] SortedByDistanceFrom(this RaycastHit[] @this, Vector3 a)
		{
			//IL_0013: 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_0025: 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)
			RaycastHit[] array = @this.MakeCopy();
			for (int i = 0; i < array.Length; i++)
			{
				int num = i;
				for (int j = i + 1; j < array.Length; j++)
				{
					if (a.DistanceTo(((RaycastHit)(ref array[j])).point) < a.DistanceTo(((RaycastHit)(ref array[num])).point))
					{
						num = j;
					}
				}
				if (num != i)
				{
					array[i].SwapWith<RaycastHit>(ref array[num]);
				}
			}
			return array;
		}

		public static RaycastHit[] SortedByDistanceFrom(this RaycastHit[] @this, GameObject a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return @this.SortedByDistanceFrom(a.transform.position);
		}

		public static RaycastHit[] SortedByDistanceFrom(this RaycastHit[] @this, Component a)
		{
			return @this.SortedByDistanceFrom(a.gameObject);
		}

		public static Vector3 Midpoint<T>(this IEnumerable<T> @this, Func<T, Vector3> positionFunc)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			Vector3 val = Vector3.zero;
			int num = 0;
			foreach (T item in @this)
			{
				val += positionFunc(item);
				num++;
			}
			return val / (float)num;
		}

		public static Vector3 Midpoint(this IEnumerable<GameObject> @this)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return @this.Midpoint((GameObject GameObject) => GameObject.transform.position);
		}

		public static Vector3 Midpoint(this IEnumerable<Component> @this)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return @this.Midpoint((Component component) => component.transform.position);
		}

		public static void SetPositionX(this Transform @this, float x)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = @this.position;
			position.x = x;
			@this.position = position;
		}

		public static void SetPositionY(this Transform @this, float y)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = @this.position;
			position.y = y;
			@this.position = position;
		}

		public static void SetPositionZ(this Transform @this, float z)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = @this.position;
			position.z = z;
			@this.position = position;
		}

		public static void SetLocalPositionX(this Transform @this, float x)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = @this.localPosition;
			localPosition.x = x;
			@this.localPosition = localPosition;
		}

		public static void SetLocalPositionY(this Transform @this, float y)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = @this.localPosition;
			localPosition.y = y;
			@this.localPosition = localPosition;
		}

		public static void SetLocalPositionZ(this Transform @this, float z)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = @this.localPosition;
			localPosition.z = z;
			@this.localPosition = localPosition;
		}

		public static void SetAngleX(this Transform @this, float x)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion rotation = @this.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			eulerAngles.x = x;
			@this.rotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetAngleY(this Transform @this, float y)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion rotation = @this.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			eulerAngles.y = y;
			@this.rotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetAngleZ(this Transform @this, float z)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion rotation = @this.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			eulerAngles.z = z;
			@this.rotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetLocalAngleX(this Transform @this, float x)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion localRotation = @this.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			eulerAngles.x = x;
			@this.localRotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetLocalAngleY(this Transform @this, float y)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion localRotation = @this.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			eulerAngles.y = y;
			@this.localRotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetLocalAngleZ(this Transform @this, float z)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Quaternion localRotation = @this.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			eulerAngles.z = z;
			@this.localRotation = Quaternion.Euler(eulerAngles);
		}

		public static void SetLocalScaleX(this Transform @this, float x)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localScale = @this.localScale;
			localScale.x = x;
			@this.localScale = localScale;
		}

		public static void SetLocalScaleY(this Transform @this, float y)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localScale = @this.localScale;
			localScale.y = y;
			@this.localScale = localScale;
		}

		public static void SetLocalScaleZ(this Transform @this, float z)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localScale = @this.localScale;
			localScale.z = z;
			@this.localScale = localScale;
		}
	}
	public static class Extensions_Sprite
	{
		public static Texture2D Texture(this Sprite @this)
		{
			return @this.texture;
		}

		public static Vector2 TextureSizePixels(this Sprite @this)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2((float)((Texture)@this.Texture()).width, (float)((Texture)@this.Texture()).height);
		}

		public static Vector2 TextureSizeUnits(this Sprite @this)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.TextureSizePixels() / @this.pixelsPerUnit;
		}

		public static Vector2 SizePixels(this Sprite @this)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = @this.rect;
			float width = ((Rect)(ref rect)).width;
			rect = @this.rect;
			return new Vector2(width, ((Rect)(ref rect)).height);
		}

		public static Vector2 SizeUnits(this Sprite @this)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.SizePixels() / @this.pixelsPerUnit;
		}

		public static Vector2 Size01(this Sprite @this)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.SizePixels().Div(@this.TextureSizePixels());
		}

		public static Vector2 OffsetPixels(this Sprite @this)
		{
			//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_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = @this.rect;
			float x = ((Rect)(ref rect)).min.x;
			rect = @this.rect;
			return new Vector2(x, ((Rect)(ref rect)).min.y);
		}

		public static Vector2 OffsetUnits(this Sprite @this)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.OffsetPixels() / @this.pixelsPerUnit;
		}

		public static Vector2 Offset01(this Sprite @this)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.OffsetPixels().Div(@this.TextureSizePixels());
		}

		public static Vector4 SizeOffsetPixels(this Sprite @this)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.SizePixels().Append(@this.OffsetPixels());
		}

		public static Vector4 SizeOffsetUnits(this Sprite @this)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.SizeUnits().Append(@this.OffsetUnits());
		}

		public static Vector4 SizeOffset01(this Sprite @this)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			return @this.Size01().Append(@this.Offset01());
		}

		public static Rect RectPixels(this Sprite @this)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return @this.rect;
		}

		public static Vector2 PositionToPixelCoords(this Sprite @this, Vector3 a, Transform b = null)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)b != (Object)null)
			{
				a = a.Untransform(b);
			}
			Rect val = @this.RectPixels();
			return Vector2Int.op_Implicit((((Rect)(ref val)).center + a.XY() * @this.pixelsPerUnit).RoundDown());
		}

		public static Color PositionToPixelColor(this Sprite @this, Vector3 a, Transform b = null)
		{
			//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)
			//IL_0008: 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_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)
			Vector2 val = @this.PositionToPixelCoords(a, b);
			return @this.Texture().GetPixel((int)val.x, (int)val.y);
		}

		public static float PositionToPixelAlpha(this Sprite @this, Vector3 a, Transform b = null)
		{
			//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 @this.PositionToPixelColor(a, b).a;
		}

		public static Vector3 PixelCoordsToPosition(this Sprite @this, Vector2 a, Transform b = null)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Rect val = @this.RectPixels();
			Vector3 val2 = Vector2.op_Implicit((a - ((Rect)(ref val)).center) / @this.pixelsPerUnit);
			if ((Object)(object)b != (Object)null)
			{
				val2 = val2.Transform(b);
			}
			return val2;
		}
	}
}
namespace Vheos.Helpers.Reflection
{
	public static class Extensions
	{
		private static BindingFlags InstanceMembers => BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static BindingFlags StaticMembers => BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static TReturn GetField<TReturn>(this object @this, string name)
		{
			return (TReturn)@this.GetType().GetField(name, InstanceMembers).GetValue(@this);
		}

		public static TReturn GetField<TReturn, TBase>(this object @this, string name)
		{
			return (TReturn)typeof(TBase).GetField(name, InstanceMembers).GetValue(@this);
		}

		public static void SetField<TValue>(this object @this, string name, TValue value)
		{
			@this.GetType().GetField(name, InstanceMembers).SetValue(@this, value);
		}

		public static void SetField<TValue, TBase>(this object @this, string name, TValue value)
		{
			typeof(TBase).GetField(name, InstanceMembers).SetValue(@this, value);
		}

		public static bool TryGetField<TReturn>(this object @this, string name, out TReturn value)
		{
			if (@this.GetType().GetField(name, InstanceMembers).TryNonNull(out FieldInfo r) && r.GetValue(@this).TryCast<TReturn>(out value))
			{
				return true;
			}
			value = default(TReturn);
			return false;
		}

		public static bool TryGetField<TReturn, TBase>(this object @this, string name, out TReturn value)
		{
			if (typeof(TBase).GetField(name, InstanceMembers).TryNonNull(out FieldInfo r) && r.GetValue(@this).TryCast<TReturn>(out value))
			{
				return true;
			}
			value = default(TReturn);
			return false;
		}

		public static bool TrySetField<TValue>(this object @this, string name, TValue value)
		{
			if (@this.GetType().GetField(name, InstanceMembers).TryNonNull(out FieldInfo r))
			{
				r.SetValue(@this, value);
				return true;
			}
			return false;
		}

		public static bool TrySetField<TValue, TBase>(this object @this, string name, TValue value)
		{
			if (typeof(TBase).GetField(name, InstanceMembers).TryNonNull(out FieldInfo r))
			{
				r.SetValue(@this, value);
				return true;
			}
			return false;
		}

		public static TReturn GetProperty<TReturn>(this object @this, string name)
		{
			return (TReturn)@this.GetType().GetProperty(name, InstanceMembers).GetValue(@this, null);
		}

		public static TReturn GetProperty<TReturn, TBase>(this object @this, string name)
		{
			return (TReturn)typeof(TBase).GetType().GetProperty(name, InstanceMembers).GetValue(@this, null);
		}

		public static void SetProperty<TValue>(this object @this, string name, TValue value)
		{
			@this.GetType().GetProperty(name, InstanceMembers).SetValue(@this, value, null);
		}

		public static void SetProperty<TValue, TBase>(this object @this, string name, TValue value)
		{
			typeof(TBase).GetProperty(name, InstanceMembers).SetValue(@this, value, null);
		}

		public static bool TryGetProperty<TReturn>(this object @this, string name, out TReturn value)
		{
			if (@this.GetType().GetProperty(name, InstanceMembers).TryNonNull(out PropertyInfo r) && r.GetValue(@this, null).TryCast<TReturn>(out value))
			{
				return true;
			}
			value = default(TReturn);
			return false;
		}

		public static bool TryGetProperty<TReturn, TBase>(this object @this, string name, out TReturn value)
		{
			if (typeof(TBase).GetProperty(name, InstanceMembers).TryNonNull(out PropertyInfo r) && r.GetValue(@this, null).TryCast<TReturn>(out value))
			{
				return true;
			}
			value = default(TReturn);
			return false;
		}

		public static bool TrySetProperty<TValue>(this object @this, string name, TValue value)
		{
			if (@this.GetType().GetProperty(name, InstanceMembers).TryNonNull(out PropertyInfo r))
			{
				r.SetValue(@this, value, null);
				return true;
			}
			return false;
		}

		public static bool TrySetProperty<TValue, TBase>(this object @this, string name, TValue value)
		{
			if (typeof(TBase).GetProperty(name, InstanceMembers).TryNonNull(out PropertyInfo r))
			{
				r.SetValue(@this, value, null);
				return true;
			}
			return false;
		}

		public static TReturn InvokeMethod<TReturn>(this object @this, string name, params object[] parameters)
		{
			return (TReturn)@this.GetType().GetMethod(name, InstanceMembers).Invoke(@this, parameters);
		}

		public static TReturn InvokeMethod<TReturn, TBase>(this object @this, string name, params object[] parameters)
		{
			return (TReturn)typeof(TBase).GetMethod(name, InstanceMembers).Invoke(@this, parameters);
		}

		public static void InvokeMethodVoid(this object @this, string name, params object[] parameters)
		{
			@this.GetType().GetMethod(name, InstanceMembers).Invoke(@this, parameters);
		}

		public static void InvokeMethodVoid<TBase>(this object @this, string name, params object[] parameters)
		{
			typeof(TBase).GetMethod(name, InstanceMembers).Invoke(@this, parameters);
		}

		public static bool TryInvokeMethod<TReturn>(this object @this, string name, object[] parameters, out TReturn returnValue)
		{
			if (@this.GetType().GetMethod(name, InstanceMembers).TryNonNull(out MethodInfo r) && r.GetParameters().Length == parameters.Length)
			{
				returnValue = (TReturn)r.Invoke(@this, parameters);
				return true;
			}
			returnValue = default(TReturn);
			return false;
		}

		public static bool TryInvokeMethod<TReturn, TBase>(this object @this, string name, object[] parameters, out TReturn returnValue)
		{
			if (typeof(TBase).GetMethod(name, InstanceMembers).TryNonNull(out MethodInfo r) && r.GetParameters().Length == parameters.Length)
			{
				returnValue = (TReturn)r.Invoke(@this, parameters);
				return true;
			}
			returnValue = default(TReturn);
			return false;
		}

		public static bool TryInvokeMethodVoid(this object @this, string name, params object[] parameters)
		{
			if (@this.GetType().GetMethod(name, InstanceMembers).TryNonNull(out MethodInfo r) && r.GetParameters().Length == parameters.Length)
			{
				r.Invoke(@this, parameters);
				return true;
			}
			return false;
		}

		public static bool TryInvokeMethodVoid<TBase>(this object @this, string name, params object[] parameters)
		{
			if (typeof(TBase).GetMethod(name, InstanceMembers).TryNonNull(out MethodInfo r) && r.GetParameters().Length == parameters.Length)
			{
				r.Invoke(@this, parameters);
				return true;
			}
			return false;
		}

		public static TReturn GetField<TReturn>(this Type type, string fieldName)
		{
			return (TReturn)type.GetField(fieldName, StaticMembers).GetValue(null);
		}

		public static void SetField<TValue>(this Type type, string fieldName, TValue value)
		{
			type.GetField(fieldName, StaticMembers).SetValue(null, value);
		}

		public static TReturn GetProperty<TReturn>(this Type type, string propName)
		{
			return (TReturn)type.GetProperty(propName, StaticMembers).GetValue(null, null);
		}

		public static void SetProperty<TValue>(this Type type, string propName, TValue value)
		{
			type.GetProperty(propName, StaticMembers).SetValue(null, value, null);
		}

		public static TReturn InvokeMethod<TReturn>(this Type type, string methodName, params object[] methodParams)
		{
			return (TReturn)type.GetMethod(methodName, StaticMembers).Invoke(null, methodParams);
		}

		public static void InvokeMethodVoid(this Type type, string methodName, params object[] methodParams)
		{
			type.GetMethod(methodName, StaticMembers).Invoke(null, methodParams);
		}
	}
}
namespace Vheos.Helpers.RNG
{
	public static class Random_Extensions
	{
		public static T Random<T>(this IList<T> t)
		{
			return t[RNG.Range(0, t.Count)];
		}

		public static void Shuffle<T>(this IList<T> t)
		{
			for (int i = 0; i < t.Count - 1; i++)
			{
				int num = RNG.Range(i, t.Count);
				int index = num;
				int index2 = i;
				T val = t[i];
				T val2 = t[num];
				T val4 = (t[index] = val);
				val4 = (t[index2] = val2);
			}
		}

		public static bool Roll(this float @this)
		{
			if (!(RNG.Value01 < @this))
			{
				return @this == 1f;
			}
			return true;
		}

		public static bool RollPercent(this float @this)
		{
			if (!(RNG.Value01 < @this / 100f))
			{
				return @this == 100f;
			}
			return true;
		}

		public static bool RollPercent(this int @this)
		{
			if (!(RNG.Value01 < (float)@this / 100f))
			{
				return (float)@this == 100f;
			}
			return true;
		}
	}
	public static class RNG
	{
		private static Random _randomizer;

		public static int Seed { get; private set; }

		public static float Value01 => (float)_randomizer.NextDouble();

		public static float Degree => Value01 * 360f;

		public static float Radian => Value01 * 2f * (float)System.Math.PI;

		public static float Range(float toEx)
		{
			return Value01 * toEx;
		}

		public static float Range(float fromIn, float toEx)
		{
			return Value01.MapFrom01(fromIn, toEx);
		}

		public static int Range(int toEx)
		{
			return _randomizer.Next(toEx);
		}

		public static int Range(int fromIn, int toEx)
		{
			return _randomizer.Next(fromIn, toEx);
		}

		public static int RangeInclusive(int toIn)
		{
			return _randomizer.Next(toIn + 1);
		}

		public static int RangeInclusive(int fromIn, int toIn)
		{
			return _randomizer.Next(fromIn, toIn + 1);
		}

		public static Vector2 OnCircle(float radius = 1f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			float radian = Radian;
			float num = radian.Cos();
			float num2 = radian.Sin();
			return new Vector2(num, num2);
		}

		public static Vector2 InCircle(float radius = 1f)
		{
			//IL_0001: 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)
			return OnCircle(radius) * Value01;
		}

		public static Vector3 OnSphere(float radius = 1f)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			float radian = Radian;
			float radian2 = Radian;
			float num = radian.Sin() * radian2.Cos();
			float num2 = radian.Sin() * radian2.Cos();
			float num3 = radian.Cos();
			return new Vector3(num, num2, num3);
		}

		public static Vector3 InSphere(float radius = 1f)
		{
			//IL_0001: 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)
			return OnSphere(radius) * Value01;
		}

		static RNG()
		{
			Initialize((int)DateTime.Now.Ticks);
		}

		public static void Initialize(int seed)
		{
			Seed = seed;
			_randomizer = new Random(Seed);
		}
	}
}
namespace Vheos.Helpers.Math
{
	public static class Extensions_float
	{
		private const float DEG_TO_RAD = (float)System.Math.PI / 180f;

		public static float Add(this float @this, float a)
		{
			return @this + a;
		}

		public static float Sub(this float @this, float a)
		{
			return @this - a;
		}

		public static float Mul(this float @this, float a)
		{
			return @this * a;
		}

		public static float Div(this float @this, float a)
		{
			return @this / a;
		}

		public static float Pow(this float @this, float a)
		{
			return (float)System.Math.Pow(@this, a);
		}

		public static float Root(this float @this, float a)
		{
			return (float)System.Math.Pow(1f / @this, a);
		}

		public static float Mod(this float @this, float a)
		{
			return @this % a;
		}

		public static float PosMod(this float @this, float a)
		{
			return (@this % a + a) % a;
		}

		public static float Min(this float @this, float a)
		{
			if (!(@this < a))
			{
				return a;
			}
			return @this;
		}

		public static float Max(this float @this, float a)
		{
			if (!(@this > a))
			{
				return a;
			}
			return @this;
		}

		public static float Avg(this float @this, float a)
		{
			return (@this + a) / 2f;
		}

		public static float Add(this float @this, int a)
		{
			return @this + (float)a;
		}

		public static float Sub(this float @this, int a)
		{
			return @this - (float)a;
		}

		public static float Mul(this float @this, int a)
		{
			return @this * (float)a;
		}

		public static float Div(this float @this, int a)
		{
			return @this / (float)a;
		}

		public static float Pow(this float @this, int a)
		{
			return (float)System.Math.Pow(@this, a);
		}

		public static float Root(this float @this, int a)
		{
			return (float)System.Math.Pow(1f / @this, a);
		}

		public static float Mod(this float @this, int a)
		{
			return @this % (float)a;
		}

		public static float PosMod(this float @this, int a)
		{
			return (@this % (float)a + (float)a) % (float)a;
		}

		public static float Min(this float @this, int a)
		{
			if (!(@this < (float)a))
			{
				return a;
			}
			return @this;
		}

		public static float Max(this float @this, int a)
		{
			if (!(@this > (float)a))
			{
				return a;
			}
			return @this;
		}

		public static float Avg(this float @this, int a)
		{
			return (@this + (float)a) / 2f;
		}

		public static float Neg(this float @this)
		{
			return 0f - @this;
		}

		public static float Inv(this float @this)
		{
			return 1f / @this;
		}

		public static float Abs(this float @this)
		{
			if (!(@this > 0f))
			{
				return 0f - @this;
			}
			return @this;
		}

		public static int Sig(this float @this)
		{
			if (!(@this > 0f))
			{
				if (!(@this < 0f))
				{
					return 0;
				}
				return -1;
			}
			return 1;
		}

		public static float Sqrd(this float @this)
		{
			return @this * @this;
		}

		public static float Sqrt(this float @this)
		{
			return (float)System.Math.Sqrt(@this);
		}

		public static float Sin(this float @this, bool degrees = false)
		{
			return Mathf.Sin(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float Cos(this float @this, bool degrees = false)
		{
			return Mathf.Cos(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float Tan(this float @this, bool degrees = false)
		{
			return Mathf.Tan(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float Cot(this float @this, bool degrees = false)
		{
			return 1f / Mathf.Tan(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float Sec(this float @this, bool degrees = false)
		{
			return 1f / Mathf.Cos(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float Csc(this float @this, bool degrees = false)
		{
			return 1f / Mathf.Sin(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float ArcSin(this float @this, bool degrees = false)
		{
			return Mathf.Asin(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float ArcCos(this float @this, bool degrees = false)
		{
			return Mathf.Acos(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static float ArcTan(this float @this, bool degrees = false)
		{
			return Mathf.Atan(degrees ? (@this * ((float)System.Math.PI / 180f)) : @this);
		}

		public static int Round(this float @this)
		{
			return (int)System.Math.Round(@this, MidpointRounding.AwayFromZero);
		}

		public static int RoundDown(this float @this)
		{
			return (int)System.Math.Floor(@this);
		}

		public static int RoundUp(this float @this)
		{
			return (int)System.Math.Ceiling(@this);
		}

		public static int RoundTowardsZero(this float @this)
		{
			return (int)@this;
		}

		public static int RoundAwayFromZero(this float @this)
		{
			if (!(@this > 0f))
			{
				return (int)System.Math.Floor(@this);
			}
			return (int)System.Math.Ceiling(@this);
		}

		public static float RoundToDecimalDigits(this float @this, int a)
		{
			return (float)System.Math.Round(@this, a, MidpointRounding.AwayFromZero);
		}

		public static float RoundToMultiple(this float @this, float a)
		{
			return (float)System.Math.Round(@this / a, MidpointRounding.AwayFromZero) * a;
		}

		public static int RoundToMultiple(this float @this, int a)
		{
			return (int)System.Math.Round(@this / (float)a, MidpointRounding.AwayFromZero) * a;
		}

		public static float Clamp01(this float @this)
		{
			if (!(@this < 0f))
			{
				if (!(@this > 1f))
				{
					return @this;
				}
				return 1f;
			}
			return 0f;
		}

		public static float Clamp(this float @this, float a, float b)
		{
			if (!(@this < a))
			{
				if (!(@this > b))
				{
					return @this;
				}
				return b;
			}
			return a;
		}

		public static float ClampMin(this float @this, float a)
		{
			if (!(@this > a))
			{
				return a;
			}
			return @this;
		}

		public static float ClampMax(this float @this, float a)
		{
			if (!(@this < a))
			{
				return a;
			}
			return @this;
		}

		public static float Lerp(this float @this, float a, float b)
		{
			return @this + (a - @this) * b;
		}

		public static float LerpClamped(this float @this, float a, float b)
		{
			if (!(b <= 0f))
			{
				if (!(b >= 1f))
				{
					return @this.Lerp(a, b);
				}
				return a;
			}
			return @this;
		}

		public static float InverseLerp(this float @this, float a, float b)
		{
			return (@this - a) / (b - a);
		}

		public static float InverseLerpClamped(this float @this, float a, float b)
		{
			if (!(@this <= a))
			{
				if (!(@this >= b))
				{
					return @this.InverseLerp(a, b);
				}
				return 1f;
			}
			return 0f;
		}

		public static float Map(this float @this, float a, float b, float c, float d)
		{
			return (@this - a) * (d - c) / (b - a) + c;
		}

		public static float MapClamped(this float @this, float a, float b, float c, float d)
		{
			if (!(@this <= a))
			{
				if (!(@this >= b))
				{
					return @this.Map(a, b, c, d);
				}
				return d;
			}
			return c;
		}

		public static float MapFrom01(this float @this, float a, float b)
		{
			return @this.Map(0f, 1f, a, b);
		}

		public static float MapTo01(this float @this, float a, float b)
		{
			return @this.Map(a, b, 0f, 1f);
		}

		public static float Clamp(this float @this, int a, int b)
		{
			if (!(@this < (float)a))
			{
				if (!(@this > (float)b))
				{
					return @this;
				}
				return b;
			}
			return a;
		}

		public static float ClampMin(this float @this, int a)
		{
			if (!(@this > (float)a))
			{
				return a;
			}
			return @this;
		}

		public static float ClampMax(this float @this, int a)
		{
			if (!(@this < (float)a))
			{
				return a;
			}
			return @this;
		}

		public static float Lerp(this float @this, int a, float b)
		{
			return @this + ((float)a - @this) * b;
		}

		public static float LerpClamped(this float @this, int a, float b)
		{
			if (!(b <= 0f))
			{
				if (!(b >= 1f))
				{
					return @this.Lerp(a, b);
				}
				return a;
			}
			return @this;
		}

		public static float InverseLerp(this float @this, int a, int b)
		{
			return (@this - (float)a) / (float)(b - a);
		}

		public static float InverseLerpClamped(this float @this, int a, int b)
		{
			if (!(@this <= (float)a))
			{
				if (!(@this >= (float)b))
				{
					return @this.InverseLerp(a, b);
				}
				return 1f;
			}
			return 0f;
		}

		public static float Map(this float @this, int a, int b, int c, int d)
		{
			return (@this - (float)a) * (float)(d - c) / (float)(b - a) + (float)c;
		}

		public static float MapClamped(this float @this, int a, int b, int c, int d)
		{
			if (!(@this <= (float)a))
			{
				if (!(@this >= (float)b))
				{
					return @this.Map(a, b, c, d);
				}
				return d;
			}
			return c;
		}

		public static float MapFrom01(this float @this, int a, int b)
		{
			return @this.Map(0f, 1f, a, b);
		}

		public static float MapTo01(this float @this, int a, int b)
		{
			return @this.Map(a, b, 0f, 1f);
		}

		public static bool IsPos(this float @this)
		{
			return @this > 0f;
		}

		public static bool IsNeg(this float @this)
		{
			return @this < 0f;
		}

		public static bool IsPosInf(this float @this)
		{
			return float.IsPositiveInfinity(@this);
		}

		public static bool IsNegInf(this float @this)
		{
			return float.IsNegativeInfinity(@this);
		}

		public static bool IsInf(this float @this)
		{
			return float.IsInfinity(@this);
		}

		public static bool IsNaN(this float @this)
		{
			return float.IsNaN(@this);
		}

		public static bool IsBetween(this float @this, float a, float b)
		{
			if (@this >= a)
			{
				return @this <= b;
			}
			return false;
		}

		public static bool IsBetween(this float @this, int a, int b)
		{
			if (@this >= (float)a)
			{
				return @this <= (float)b;
			}
			return false;
		}

		public static float DistanceTo(this float @this, float a)
		{
			return (@this - a).Abs();
		}

		public static float DistanceTo(this float @this, int a)
		{
			return (@this - (float)a).Abs();
		}

		public static int ToInt(this float @this)
		{
			return (int)@this;
		}

		public static Vector2 ToVector2(this float @this)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(@this, @this);
		}

		public static Vector3 ToVector3(this float @this)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(@this, @this, @this);
		}

		public static Vector4 ToVector4(this float @this)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			return new Vector4(@this, @this, @this, @this);
		}

		public static Vector2 Append(this float @this)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(@this, 0f);
		}

		public static Vector2 Append(this float @this, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(@this, y);
		}

		public static Vector3 Append(this float @this, float y, float z)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(@this, y, z);
		}

		public static Vector3 Append(this float @this, Vector2 a)
		{
			//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(@this, a.x, a.y);
		}

		public static Vector4 Append(this float @this, float y, float z, float w)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			return new Vector4(@this, y, z, w);
		}

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

		public static void SetAdd(this ref float @this, int a)
		{
			@this = @this.Add(a);
		}

		public static void SetSub(this ref float @this, int a)
		{
			@this = @this.Sub(a);
		}

		public static void SetMul(this ref float @this, int a)
		{
			@this = @this.Mul(a);
		}

		public static void SetDiv(this ref float @this, int a)
		{
			@this = @this.Div(a);
		}

		public static void SetPow(this ref float @this, int a)
		{
			@this = @this.Pow(a);
		}

		public static void SetRoot(this ref float @this, int a)
		{
			@this = @this.Root(a);
		}

		public static void SetMod(this ref float @this, int a)
		{
			@this = @this.Mod(a);
		}

		public static void SetPosMod(this ref float @this, int a)
		{
			@this = @this.PosMod(a);
		}

		public static void SetMin(this ref float @this, int a)
		{
			@this = @this.Min(a);
		}

		public static void SetMax(this ref float @this, int a)
		{
			@this = @this.Max(a);
		}

		public static void SetAvg(this ref float @this, int a)
		{
			@this = @this.Avg(a);
		}

		public static void SetAdd(this ref float @this, float a)
		{
			@this = @this.Add(a);
		}

		public static void SetSub(this ref float @this, float a)
		{
			@this = @this.Sub(a);
		}

		public static void SetMul(this ref float @this, float a)
		{
			@this = @this.Mul(a);
		}

		public static void SetDiv(this ref float @this, float a)
		{
			@this = @this.Div(a);
		}

		public static void SetPow(this ref float @this, float a)
		{
			@this = @this.Pow(a);
		}

		public static void SetRoot(this ref float @this, float a)
		{
			@this = @this.Root(a);
		}

		public static void SetMod(this ref float @this, float a)
		{
			@this = @this.Mod(a);
		}

		public static void SetPosMod(this ref float @this, float a)
		{
			@this = @this.PosMod(a);
		}

		public static void SetMin(this ref float @this, float a)
		{
			@this = @this.Min(a);
		}

		public static void SetMax(this ref float @this, float a)
		{
			@this = @this.Max(a);
		}

		public static void SetAvg(this ref float @this, float a)
		{
			@this = @this.Avg(a);
		}

		public static void SetNeg(this ref float @this)
		{
			@this = @this.Neg();
		}

		public static void SetInv(this ref float @this)
		{
			@this = @this.Inv();
		}

		public static void SetAbs(this ref float @this)
		{
			@this = @this.Abs();
		}

		public static void SetSig(this ref float @this)
		{
			@this = @this.Sig();
		}

		public static void SetSqrt(this ref float @this)
		{
			@this = @this.Sqrt();
		}

		public static void SetSqrd(this ref float @this)
		{
			@this = @this.Sqrd();
		}

		public static void SetSin(this ref float @this, bool degrees = false)
		{
			@this = @this.Sin(degrees);
		}

		public static void SetCos(this ref float @this, bool degrees = false)
		{
			@this = @this.Cos(degrees);
		}

		public static void SetTan(this ref float @this, bool degrees = false)
		{
			@this = @this.Tan(degrees);
		}

		public static void SetCot(this ref float @this, bool degrees = false)
		{
			@this = @this.Cot(degrees);
		}

		public static void SetSec(this ref float @this, bool degrees = false)
		{
			@this = @this.Sec(degrees);
		}

		public static void SetCsc(this ref float @this, bool degrees = false)
		{
			@this = @this.Csc(degrees);
		}

		public static void SetArcSin(this ref float @this, bool degrees = false)
		{
			@this = @this.ArcSin(degrees);
		}

		public static void SetArcCos(this ref float @this, bool degrees = false)
		{
			@this = @this.ArcCos(degrees);
		}

		public static void SetArcTan(this ref float @this, bool degrees = false)
		{
			@this = @this.ArcTan(degrees);
		}

		public static void SetRound(this ref float @this)
		{
			@this = @this.Round();
		}

		public static void SetRoundDown(this ref float @this)
		{
			@this = @this.RoundDown();
		}

		public static void SetRoundUp(this ref float @this)
		{
			@this = @this.RoundUp();
		}

		public static void SetRoundTowardsZero(this ref float @this)
		{
			@this = @this.RoundTowardsZero();
		}

		public static void SetRoundAwayFromZero(this ref float @this)
		{
			@this = @this.RoundAwayFromZero();
		}

		public static void SetRoundToDecimalDigits(this ref float @this, int a)
		{
			@this = @this.RoundToDecimalDigits(a);
		}

		public static void SetRoundToMultiple(this ref float @this, int a)
		{
			@this = @this.RoundToMultiple(a);
		}

		public static void SetRoundToMultiple(this ref float @this, float a)
		{
			@this = @this.RoundToMultiple(a);
		}

		public static void SetClamp(this ref float @this, int a, int b)
		{
			@this = @this.Clamp(a, b);
		}

		public static void SetClampMin(this ref float @this, int a)
		{
			@this = @this.ClampMin(a);
		}

		public static void SetClampMax(this ref float @this, int a)
		{
			@this = @this.ClampMax(a);
		}

		public static void SetLerp(this ref float @this, int a, float b)
		{
			@this = @this.Lerp(a, b);
		}

		public static void SetLerpClamped(this ref float @this, int a, float b)
		{
			@this = @this.LerpClamped(a, b);
		}

		public static float SetInverseLerp(this ref float @this, int a, int b)
		{
			return @this = @this.InverseLerp(a, b);
		}

		public static float SetInverseLerpClamped(this ref float @this, int a, int b)
		{
			return @this = @this.SetInverseLerpClamped(a, b);
		}

	

BepInEx/Plugins/Vheos/Vheos.Mods.Core.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurationManager;
using HarmonyLib;
using UnityEngine;
using Vheos.Helpers.Collections;
using Vheos.Helpers.Common;
using Vheos.Helpers.KeyCodeCache;
using Vheos.Helpers.Math;
using Vheos.Helpers.RNG;
using Vheos.Helpers.Reflection;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
internal sealed class ConfigurationManagerAttributes
{
	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace Vheos.Mods.Core;

public abstract class AMod
{
	[Flags]
	private enum Toggles
	{
		None = 0,
		Apply = 2,
		Collapse = 4,
		Hide = 8
	}

	private const int MAX_SETTINGS_PER_MOD = 1000;

	private static readonly CustomDisposable _indentDisposable = new CustomDisposable((Action)delegate
	{
		IndentLevel--;
	});

	private static Type[] _modsOrderingList;

	private static int _nextPosition;

	private readonly Harmony _patcher;

	private readonly List<AModSetting> _settings;

	private readonly List<Action> _onConfigClosedEvents;

	private readonly List<Action> _onEnabledEvents;

	private readonly List<Action> _onDisabledEvents;

	private bool _isInitialized;

	private ModSetting<Toggles> _mainToggle;

	private Toggles _previousMainToggle;

	protected virtual string SectionOverride => "";

	protected virtual string Description => "";

	protected virtual string ModName => null;

	protected virtual bool IsAdvanced => false;

	protected static IDisposable Indent
	{
		get
		{
			IndentLevel++;
			return (IDisposable)_indentDisposable;
		}
	}

	internal static int IndentLevel { get; private set; }

	internal static int NextPosition => _nextPosition++;

	private string SectionName => GetType().Name;

	private int ModOrderingOffset
	{
		get
		{
			if (_modsOrderingList == null || !Extensions.IsContainedIn<Type>(GetType(), (ICollection<Type>)_modsOrderingList))
			{
				return 0;
			}
			return Extensions_int.Mul(Extensions_int.Add(Array.IndexOf(_modsOrderingList, GetType()), 1), 1000);
		}
	}

	public bool IsEnabled
	{
		get
		{
			return _mainToggle.Value.HasFlag(Toggles.Apply);
		}
		private set
		{
			if (value)
			{
				_mainToggle.Value |= Toggles.Apply;
			}
			else
			{
				_mainToggle.Value &= ~Toggles.Apply;
			}
		}
	}

	protected bool IsCollapsed
	{
		get
		{
			return _mainToggle.Value.HasFlag(Toggles.Collapse);
		}
		set
		{
			if (value)
			{
				_mainToggle.Value |= Toggles.Collapse;
			}
			else
			{
				_mainToggle.Value &= ~Toggles.Collapse;
			}
		}
	}

	protected bool IsHidden
	{
		get
		{
			return _mainToggle.Value.HasFlag(Toggles.Hide);
		}
		set
		{
			if (value)
			{
				_mainToggle.Value |= Toggles.Hide;
			}
			else
			{
				_mainToggle.Value &= ~Toggles.Hide;
			}
		}
	}

	protected abstract void Initialize();

	protected abstract void SetFormatting();

	protected internal virtual void LoadPreset(string presetName)
	{
	}

	internal static void SetOrderingList(params Type[] modTypes)
	{
		_modsOrderingList = modTypes;
	}

	private void CreateMainToggle()
	{
		ResetSettingPosition(-1);
		_mainToggle = new ModSetting<Toggles>(SectionName, "_mainToggle", Toggles.None)
		{
			FormattedSection = SectionOverride,
			DisplayResetButton = false,
			Description = Description
		};
		_mainToggle.Format(ModName ?? Extensions.SplitCamelCase(SectionName));
		_mainToggle.IsAdvanced = IsAdvanced;
		_mainToggle.AddEvent(OnTogglesChanged);
		_previousMainToggle = _mainToggle;
	}

	private void OnTogglesChanged()
	{
		Toggles toggles = (Toggles)_mainToggle ^ _previousMainToggle;
		bool flag = _mainToggle.Value.HasFlag(toggles);
		switch (toggles)
		{
		case Toggles.Apply:
			if (IsHidden)
			{
				ResetApplySilently();
			}
			else if (flag)
			{
				OnEnable();
			}
			else
			{
				OnDisable();
			}
			break;
		case Toggles.Collapse:
			if (!IsEnabled || IsHidden)
			{
				ResetCollapseSilently();
			}
			else if (flag)
			{
				OnCollapse();
			}
			else
			{
				OnExpand();
			}
			break;
		case Toggles.Hide:
			if (flag)
			{
				OnHide();
			}
			else
			{
				OnUnhide();
			}
			break;
		}
		_previousMainToggle = _mainToggle;
		ConfigHelper.SetDirtyConfigWindow();
	}

	private void OnEnable()
	{
		if (!_isInitialized)
		{
			_isInitialized = true;
			ResetSettingPosition();
			Log.Debug("\t[" + GetType().Name + "] Initializing...");
			Initialize();
			using (Indent)
			{
				Log.Debug("\t[" + GetType().Name + "] Formatting...");
				SetFormatting();
			}
		}
		Log.Debug("\t[" + GetType().Name + "] Patching...");
		_patcher.PatchAll(GetType());
		Log.Debug("\t[" + GetType().Name + "] Calling events...");
		foreach (Action onEnabledEvent in _onEnabledEvents)
		{
			onEnabledEvent();
		}
		foreach (AModSetting setting in _settings)
		{
			setting.CallAllEvents();
		}
		foreach (Action onConfigClosedEvent in _onConfigClosedEvents)
		{
			onConfigClosedEvent();
		}
		OnExpand();
	}

	private void OnDisable()
	{
		foreach (Action onDisabledEvent in _onDisabledEvents)
		{
			onDisabledEvent();
		}
		Log.Debug("\t[" + GetType().Name + "] Unpatching...");
		_patcher.UnpatchSelf();
		if (!IsCollapsed)
		{
			OnCollapse();
		}
		else
		{
			ResetCollapseSilently();
		}
	}

	private void OnCollapse()
	{
		foreach (AModSetting setting in _settings)
		{
			setting.IsVisible = false;
		}
	}

	private void OnExpand()
	{
		foreach (AModSetting setting in _settings)
		{
			setting.UpdateVisibility();
		}
	}

	private void OnHide()
	{
		_mainToggle.IsAdvanced = true;
		if (IsEnabled)
		{
			OnDisable();
			ResetApplySilently();
		}
	}

	private void OnUnhide()
	{
		_mainToggle.IsAdvanced = false;
	}

	private void ResetApplySilently()
	{
		_mainToggle.SetSilently((Toggles)_mainToggle & ~Toggles.Apply);
	}

	private void ResetCollapseSilently()
	{
		_mainToggle.SetSilently((Toggles)_mainToggle & ~Toggles.Collapse);
	}

	protected AMod()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		_patcher = new Harmony(GetType().Name);
		_settings = new List<AModSetting>();
		_onConfigClosedEvents = new List<Action>();
		_onEnabledEvents = new List<Action>();
		_onDisabledEvents = new List<Action>();
		CreateMainToggle();
		Log.Debug($"\t[{GetType().Name}] Main toggle: {_mainToggle.Value}");
		if (IsEnabled)
		{
			OnEnable();
		}
		if (IsCollapsed)
		{
			OnCollapse();
		}
		if (IsHidden)
		{
			OnHide();
		}
	}

	public void ResetSettings(bool resetMainToggle = false)
	{
		foreach (AModSetting setting in _settings)
		{
			if (setting.DisplayResetButton)
			{
				setting.Reset();
			}
		}
		if (resetMainToggle)
		{
			IsEnabled = false;
			IsCollapsed = false;
			IsHidden = false;
		}
	}

	protected void ForceApply()
	{
		IsHidden = false;
		IsEnabled = true;
		IsCollapsed = true;
	}

	protected void ResetSettingPosition(int offset = 0)
	{
		_nextPosition = ModOrderingOffset + offset;
	}

	protected void AddEventOnConfigOpened(Action action)
	{
		_onConfigClosedEvents.Add(action);
		ConfigHelper.AddEventOnConfigOpened(delegate
		{
			if (IsEnabled)
			{
				action();
			}
		});
	}

	protected void AddEventOnConfigClosed(Action action)
	{
		_onConfigClosedEvents.Add(action);
		ConfigHelper.AddEventOnConfigClosed(delegate
		{
			if (IsEnabled)
			{
				action();
			}
		});
	}

	protected void AddEventOnEnabled(Action action)
	{
		_onEnabledEvents.Add(action);
	}

	protected void AddEventOnDisabled(Action action)
	{
		_onDisabledEvents.Add(action);
	}

	protected internal ModSetting<T> CreateSetting<T>(string name, T defaultValue = default(T), AcceptableValueBase acceptableValues = null)
	{
		ModSetting<T> modSetting = new ModSetting<T>(SectionName, name, defaultValue, acceptableValues)
		{
			FormattedSection = SectionOverride,
			FormatAsPercent01 = false
		};
		_settings.Add(modSetting);
		return modSetting;
	}

	protected internal ModSetting<bool> CreateHeader(string displayName = null, ModSetting<bool> toggle = null)
	{
		ModSetting<bool> modSetting = CreateSetting("_header" + _nextPosition, defaultValue: false);
		modSetting.DisplayResetButton = false;
		modSetting.CustomDrawer = delegate
		{
		};
		if (displayName != null)
		{
			if (toggle != null)
			{
				modSetting.Format(displayName, toggle);
			}
			else
			{
				modSetting.Format(displayName);
			}
		}
		return modSetting;
	}

	protected AcceptableValueRange<int> IntRange(int from, int to)
	{
		return new AcceptableValueRange<int>(from, to);
	}

	protected AcceptableValueRange<float> FloatRange(float from, float to)
	{
		return new AcceptableValueRange<float>(from, to);
	}
}
public static class Extensions
{
	public static bool IsValidKeyCode(this ModSetting<string> t)
	{
		if (t != null)
		{
			return Extensions.IsValidKeyCode(t.Value);
		}
		return false;
	}

	public static KeyCode ToKeyCode(this ModSetting<string> t)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (t == null)
		{
			return (KeyCode)0;
		}
		return Extensions.ToKeyCode(t.Value);
	}

	public static bool Roll(this ModSetting<float> t)
	{
		return Random_Extensions.Roll(t.Value);
	}

	public static bool RollPercent(this ModSetting<float> t)
	{
		return Random_Extensions.RollPercent(t.Value);
	}

	public static bool RollPercent(this ModSetting<int> t)
	{
		return Random_Extensions.RollPercent(t.Value);
	}
}
public abstract class AModSetting
{
	protected ConfigEntryBase _configEntryBase;

	protected List<Action> _events;

	private Func<bool> _visibilityCheck;

	private readonly List<AModSetting> _visibilityControllers;

	public string Name { get; private set; }

	public string Key => _configEntryBase.Definition.Key;

	public string Section => _configEntryBase.Definition.Section;

	public string FormattedSection
	{
		get
		{
			return Attributes.Category;
		}
		set
		{
			Attributes.Category = value;
		}
	}

	public string FormattedName
	{
		get
		{
			return Attributes.DispName;
		}
		set
		{
			Attributes.DispName = value;
		}
	}

	public string Description
	{
		get
		{
			return Attributes.Description;
		}
		set
		{
			Attributes.Description = value;
		}
	}

	public int Ordering
	{
		get
		{
			return -Attributes.Order.Value;
		}
		set
		{
			Attributes.Order = -value;
		}
	}

	public bool IsVisible
	{
		get
		{
			if (Attributes.Browsable.HasValue)
			{
				return Attributes.Browsable.Value;
			}
			return false;
		}
		set
		{
			Attributes.Browsable = value;
		}
	}

	public bool IsAdvanced
	{
		get
		{
			return Attributes.IsAdvanced.Value;
		}
		set
		{
			Attributes.IsAdvanced = value;
		}
	}

	public bool DisplayResetButton
	{
		get
		{
			if (Attributes.HideDefaultButton.HasValue)
			{
				return !Attributes.HideDefaultButton.Value;
			}
			return true;
		}
		set
		{
			Attributes.HideDefaultButton = !value;
		}
	}

	public bool DrawInPlaceOfName
	{
		get
		{
			if (Attributes.HideSettingName.HasValue)
			{
				return Attributes.HideSettingName.Value;
			}
			return false;
		}
		set
		{
			Attributes.HideSettingName = value;
		}
	}

	public bool FormatAsPercent01
	{
		get
		{
			if (Attributes.ShowRangeAsPercent.HasValue)
			{
				return Attributes.ShowRangeAsPercent.Value;
			}
			return false;
		}
		set
		{
			Attributes.ShowRangeAsPercent = value;
		}
	}

	public bool ReadOnly
	{
		get
		{
			if (Attributes.ReadOnly.HasValue)
			{
				return Attributes.ReadOnly.Value;
			}
			return false;
		}
		set
		{
			Attributes.ReadOnly = value;
		}
	}

	public Action<ConfigEntryBase> CustomDrawer
	{
		get
		{
			return Attributes.CustomDrawer;
		}
		set
		{
			Attributes.CustomDrawer = value;
		}
	}

	private ConfigurationManagerAttributes Attributes => _configEntryBase.Description.Tags[0] as ConfigurationManagerAttributes;

	public void Format(string displayName)
	{
		Name = displayName;
		FormattedName = "";
		if (Extensions.IsNotEmpty(displayName))
		{
			FormattedName = FormattedName.PadLeft(5 * AMod.IndentLevel, ' ');
			if (AMod.IndentLevel > 0)
			{
				FormattedName += "• ";
			}
			FormattedName += Name;
		}
		Ordering = AMod.NextPosition;
		_visibilityCheck = () => true;
	}

	public void Format<T>(string displayName, ModSetting<T> controller, Func<T, bool> check = null)
	{
		Format(displayName);
		AddVisibilityControl(controller, check);
	}

	public void Format<T>(string displayName, ModSetting<T> controller, T value, bool positiveTest = true) where T : struct
	{
		Format(displayName);
		AddVisibilityControl(controller, value, positiveTest);
	}

	public void Format(string displayName, ModSetting<bool> toggle)
	{
		Format(displayName, toggle, value: true);
	}

	public void AddEvent(Action action)
	{
		AddEventSilently(action);
		_events.Add(action);
	}

	public void AddEventSilently(Action action)
	{
		_configEntryBase.ConfigFile.SettingChanged += delegate(object sender, SettingChangedEventArgs eventArgs)
		{
			if (eventArgs.ChangedSetting == _configEntryBase)
			{
				action();
			}
		};
	}

	public void Reset()
	{
		_configEntryBase.BoxedValue = _configEntryBase.DefaultValue;
	}

	public T CastValue<T>()
	{
		return (T)_configEntryBase.BoxedValue;
	}

	internal void CallAllEvents()
	{
		foreach (Action @event in _events)
		{
			@event();
		}
	}

	internal void UpdateVisibility()
	{
		ConfigHelper.SetDirtyConfigWindow();
		foreach (AModSetting visibilityController in _visibilityControllers)
		{
			if (!visibilityController.IsVisible)
			{
				IsVisible = false;
				return;
			}
		}
		IsVisible = _visibilityCheck();
	}

	private void AddVisibilityControl<T>(ModSetting<T> controller, Func<T, bool> check = null)
	{
		AddParentVisibilityControllers(controller);
		if (check != null)
		{
			_visibilityCheck = () => check(controller.Value);
		}
		foreach (AModSetting visibilityController in _visibilityControllers)
		{
			_configEntryBase.ConfigFile.SettingChanged += delegate(object sender, SettingChangedEventArgs eventArgs)
			{
				if (eventArgs.ChangedSetting == visibilityController._configEntryBase)
				{
					UpdateVisibility();
				}
			};
		}
	}

	private void AddVisibilityControl<T>(ModSetting<T> controller, T value, bool positiveTest = true) where T : struct
	{
		Enum valueAsEnum = value as Enum;
		Func<T, bool> check = ((valueAsEnum == null || !Extensions.HasFlagsAttribute(valueAsEnum)) ? (positiveTest ? ((Func<T, bool>)((T v) => v.Equals(value))) : ((Func<T, bool>)((T v) => !v.Equals(value)))) : (positiveTest ? ((Func<T, bool>)((T v) => (v as Enum).HasFlag(valueAsEnum))) : ((Func<T, bool>)((T v) => !(v as Enum).HasFlag(valueAsEnum)))));
		AddVisibilityControl(controller, check);
	}

	private void AddParentVisibilityControllers(AModSetting controller)
	{
		_visibilityControllers.Add(controller);
		foreach (AModSetting visibilityController in controller._visibilityControllers)
		{
			_visibilityControllers.Add(visibilityController);
		}
	}

	protected AModSetting()
	{
		_events = new List<Action>();
		_visibilityControllers = new List<AModSetting>();
		_visibilityCheck = () => false;
	}
}
public abstract class BepInExEntryPoint : BaseUnityPlugin
{
	private List<Type> _awakeModTypes;

	private List<Type> _delayedModTypes;

	private List<IUpdatable> _updatableMods;

	protected HashSet<AMod> _mods;

	private bool _instantiatedDelayedMods;

	protected abstract Assembly CurrentAssembly { get; }

	protected virtual bool DelayedInitializeCondition => true;

	protected virtual Type[] Whitelist => null;

	protected virtual Type[] Blacklist => null;

	protected virtual Type[] ModsOrderingList => null;

	protected virtual string[] PresetNames => null;

	protected virtual void Initialize()
	{
	}

	protected virtual void DelayedInitialize()
	{
	}

	private void CategorizeModsByInstantiationTime()
	{
		foreach (Type derivedType in Utility.GetDerivedTypes<AMod>(CurrentAssembly))
		{
			if (Extensions_ICollections.IsNullOrEmpty<Type>((ICollection<Type>)Blacklist) || (Extensions.IsNotContainedIn<Type>(derivedType, (ICollection<Type>)Blacklist) && (Extensions_ICollections.IsNullOrEmpty<Type>((ICollection<Type>)Whitelist) || Extensions.IsContainedIn<Type>(derivedType, (ICollection<Type>)Whitelist))))
			{
				if (Extensions.IsAssignableTo<IDelayedInit>(derivedType))
				{
					_delayedModTypes.Add(derivedType);
				}
				else
				{
					_awakeModTypes.Add(derivedType);
				}
			}
		}
	}

	private void InstantiateMods(ICollection<Type> modTypes)
	{
		foreach (Type modType in modTypes)
		{
			AMod aMod = (AMod)Activator.CreateInstance(modType);
			_mods.Add(aMod);
			if (Extensions.IsAssignableTo<IUpdatable>(modType))
			{
				_updatableMods.Add(aMod as IUpdatable);
			}
		}
	}

	private void TryInstantiateDelayedMods()
	{
		if (!_instantiatedDelayedMods && DelayedInitializeCondition)
		{
			Log.Debug("Finished waiting");
			DelayedInitialize();
			Log.Debug("Instantiating delayed mods...");
			InstantiateMods(_delayedModTypes);
			Log.Debug("Initializing Presets...");
			Presets.TryInitialize(PresetNames, _mods);
			Log.Debug("Finished DelayedInit");
			_instantiatedDelayedMods = true;
		}
	}

	private void UpdateMods(ICollection<IUpdatable> updatableMods)
	{
		foreach (IUpdatable updatableMod in updatableMods)
		{
			if (updatableMod.IsEnabled)
			{
				updatableMod.OnUpdate();
			}
		}
	}

	private void Awake()
	{
		_awakeModTypes = new List<Type>();
		_delayedModTypes = new List<Type>();
		_updatableMods = new List<IUpdatable>();
		_mods = new HashSet<AMod>();
		AMod.SetOrderingList(ModsOrderingList);
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Initializing Log...");
		Log.Initialize(((BaseUnityPlugin)this).Logger);
		Log.Debug("Initializing ConfigHelper...");
		ConfigHelper.Initialize((BaseUnityPlugin)(object)this);
		Initialize();
		Log.Debug("Categorizing mods by instantiation time...");
		CategorizeModsByInstantiationTime();
		Log.Debug("Awake:");
		foreach (Type awakeModType in _awakeModTypes)
		{
			Log.Debug("\t" + awakeModType.Name);
		}
		Log.Debug("Delayed:");
		foreach (Type delayedModType in _delayedModTypes)
		{
			Log.Debug("\t" + delayedModType.Name);
		}
		Log.Debug("Instantiating awake mods...");
		InstantiateMods(_awakeModTypes);
		Log.Debug("Finished AwakeInit");
		Log.Debug("Waiting for game initialization...");
	}

	private void Update()
	{
		TryInstantiateDelayedMods();
		UpdateMods(_updatableMods);
		ConfigHelper.TryRedrawConfigWindow();
	}
}
public class ColorSettings
{
	public readonly ModSetting<Color> Sliders;

	public readonly ModSetting<Vector4> Numbers;

	public string Description
	{
		get
		{
			return Sliders.Description;
		}
		set
		{
			Sliders.Description = value;
		}
	}

	private int ColorRange => ConfigHelper.NumericalColorRange;

	public ColorSettings(AMod mod, string settingKey, Color defaultColor)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		Sliders = mod.CreateSetting<Color>(settingKey + "Sliders", defaultColor);
		Numbers = mod.CreateSetting<Vector4>(settingKey + "Numbers", Color.op_Implicit(defaultColor));
		Sliders.AddEventSilently(OnChangeSliders);
		Numbers.AddEventSilently(OnChangeNumbers);
		ConfigHelper.NumericalColorRange.AddEvent(OnChangeSliders);
	}

	public void Format(string displayName)
	{
		Sliders.Format(displayName);
		Numbers.DisplayResetButton = false;
		Numbers.Format("", Sliders, (Func<Color, bool>)((Color t) => ColorRange != 0));
	}

	public void Format(string displayName, ModSetting<bool> toggle)
	{
		Sliders.Format(displayName, toggle);
		Numbers.DisplayResetButton = false;
		Numbers.Format("", toggle, (bool t) => t && ColorRange != 0);
	}

	private void OnChangeSliders()
	{
		//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_001d: Unknown result type (might be due to invalid IL or missing references)
		Numbers.SetSilently(Color.op_Implicit(Sliders.Value * (float)ColorRange));
	}

	private void OnChangeNumbers()
	{
		//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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		Numbers.SetSilently(Extensions_Vector4.Clamp(Numbers.Value, 0, ColorRange));
		Sliders.SetSilently(Color.op_Implicit(Numbers.Value / (float)ColorRange));
	}

	public static implicit operator ModSetting<Color>(ColorSettings colorSettings)
	{
		return colorSettings.Sliders;
	}

	public static implicit operator Color(ColorSettings colorSettings)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return colorSettings.Sliders.Value;
	}
}
public static class ConfigHelper
{
	private static ConfigurationManager _configManager;

	private static bool _isConfigWindowDirty;

	public static bool IsConfigOpen
	{
		get
		{
			return _configManager.DisplayingWindow;
		}
		set
		{
			_configManager.DisplayingWindow = value;
		}
	}

	public static bool AdvancedSettings
	{
		get
		{
			return _configManager._showAdvanced.Value;
		}
		set
		{
			_configManager._showAdvanced.Value = value;
		}
	}

	internal static ConfigFile ConfigFile { get; private set; }

	public static ModSetting<bool> UnlockSettingLimits { get; private set; }

	public static ModSetting<int> NumericalColorRange { get; private set; }

	public static void AddEventOnConfigOpened(Action action)
	{
		_configManager.DisplayingWindowChanged += delegate(object sender, ValueChangedEventArgs<bool> eventArgs)
		{
			if (eventArgs.NewValue)
			{
				action();
			}
		};
	}

	public static void AddEventOnConfigClosed(Action action)
	{
		_configManager.DisplayingWindowChanged += delegate(object sender, ValueChangedEventArgs<bool> eventArgs)
		{
			if (!eventArgs.NewValue)
			{
				action();
			}
		};
	}

	internal static void SetDirtyConfigWindow()
	{
		_isConfigWindowDirty = true;
	}

	internal static void TryRedrawConfigWindow()
	{
		if (IsConfigOpen && _isConfigWindowDirty)
		{
			_configManager.BuildSettingList();
			_isConfigWindowDirty = false;
		}
	}

	private static void CreateUnlockLimitsSetting()
	{
		UnlockSettingLimits = new ModSetting<bool>("", "UnlockSettingLimits", defaultValue: false);
		UnlockSettingLimits.Format("Unlock settings' limits");
		UnlockSettingLimits.Description = "Each setting that uses a value slider will use an input box instead\nThis allows you to enter ANY value, unlimited by the slider limits\nHowever, some extreme values on some settings might produce unexpected results or even crash the game\n(requires game restart to take effect)";
		UnlockSettingLimits.Ordering = 0;
		UnlockSettingLimits.IsAdvanced = true;
		UnlockSettingLimits.DisplayResetButton = false;
	}

	private static void CreateNumericalColorEditingSetting()
	{
		NumericalColorRange = new ModSetting<int>("", "NumericalColorRange", 0, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255));
		NumericalColorRange.Format("Numerical color range");
		NumericalColorRange.Description = "";
		NumericalColorRange.Ordering = 1;
		NumericalColorRange.IsAdvanced = true;
		NumericalColorRange.DisplayResetButton = false;
	}

	public static void Initialize(BaseUnityPlugin pluginComponent)
	{
		ConfigFile = pluginComponent.Config;
		_configManager = ((Component)pluginComponent).GetComponent<ConfigurationManager>();
		CreateUnlockLimitsSetting();
		CreateNumericalColorEditingSetting();
	}
}
public interface IDelayedInit
{
}
public interface IUpdatable
{
	bool IsEnabled { get; }

	void OnUpdate();
}
public static class Log
{
	private static ManualLogSource _logger;

	public static void Debug(object text)
	{
		_logger.Log((LogLevel)32, text);
	}

	public static void Message(object text)
	{
		_logger.Log((LogLevel)8, text);
	}

	public static void Level(LogLevel level, object text)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		_logger.Log(level, text);
	}

	public static void Initialize(ManualLogSource logger)
	{
		_logger = logger;
	}
}
public class ModSetting<T> : AModSetting
{
	private readonly ConfigEntry<T> _configEntry;

	public T Value
	{
		get
		{
			return _configEntry.Value;
		}
		set
		{
			_configEntry.Value = value;
		}
	}

	public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue;

	public void SetSilently(T value)
	{
		Extensions.SetField<T>((object)_configEntry, "_typedValue", value);
		((ConfigEntryBase)_configEntry).ConfigFile.Save();
	}

	public ModSetting(string section, string name, T defaultValue = default(T), AcceptableValueBase acceptableValues = null)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		if (ConfigHelper.UnlockSettingLimits != null && (bool)ConfigHelper.UnlockSettingLimits)
		{
			acceptableValues = null;
		}
		ConfigDescription val = new ConfigDescription("", acceptableValues, new object[1]
		{
			new ConfigurationManagerAttributes()
		});
		_configEntryBase = (ConfigEntryBase)(object)(_configEntry = ConfigHelper.ConfigFile.Bind<T>(section, name, defaultValue, val));
		base.IsVisible = true;
	}

	public static implicit operator T(ModSetting<T> setting)
	{
		return setting.Value;
	}
}
public abstract class PerValueSettings<TMod, TValue> where TMod : AMod
{
	public ModSetting<bool> Header;

	protected TMod _mod;

	protected bool _isToggle;

	public string Description
	{
		get
		{
			return Header.Description;
		}
		set
		{
			Header.Description = value;
		}
	}

	public TValue Value { get; private set; }

	protected string Prefix => $"{GetType().Name}_{Value}_";

	public PerValueSettings(TMod mod, TValue value, bool isToggle = false)
	{
		_mod = mod;
		Value = value;
		_isToggle = isToggle;
		if (_isToggle)
		{
			Header = _mod.CreateSetting(Prefix + "Header", defaultValue: false);
		}
	}

	public ModSetting<T> CreateSetting<T>(string name, T defaultValue = default(T), AcceptableValueBase acceptableValues = null)
	{
		return _mod.CreateSetting(Prefix + name, defaultValue, acceptableValues);
	}

	public void FormatHeader()
	{
		if (_isToggle)
		{
			Header.Format(Value.ToString());
		}
		else
		{
			Header = _mod.CreateHeader(Value.ToString());
		}
	}
}
public abstract class PerPlayerSettings<T> where T : AMod
{
	public readonly ModSetting<bool> Toggle;

	protected T _mod;

	protected int _playerID;

	public string Description
	{
		get
		{
			return Toggle.Description;
		}
		set
		{
			Toggle.Description = value;
		}
	}

	protected string PlayerPrefix => $"{GetType().Name}_Player{_playerID + 1}_";

	public PerPlayerSettings(T mod, int playerID)
	{
		_mod = mod;
		_playerID = playerID;
		Toggle = mod.CreateSetting(PlayerPrefix + "Toggle", defaultValue: false);
	}

	public virtual void Format()
	{
		Toggle.DisplayResetButton = false;
		Toggle.Format($"Player {_playerID + 1}");
	}
}
public static class Presets
{
	private const string DEFAULT_PRESET_NAME = "-";

	private const string RESET_TO_DEFAULTS_PRESET_NAME = "Reset to defaults";

	private static string[] _presetNames;

	private static ICollection<AMod> _mods;

	public static ModSetting<string> Preset { get; private set; }

	private static void CreateLoadPresetSetting()
	{
		Preset = new ModSetting<string>("", "Preset", "-", (AcceptableValueBase)(object)new AcceptableValueList<string>(_presetNames));
		Preset.Format("Load preset");
		Preset.Ordering = 2;
		Preset.IsAdvanced = true;
		Preset.DisplayResetButton = false;
		Preset.AddEvent(LoadPreset);
	}

	private static void LoadPreset()
	{
		Action<AMod> action = delegate(AMod t)
		{
			t.LoadPreset(Preset);
		};
		if (Preset == "Reset to defaults")
		{
			action = delegate(AMod t)
			{
				t.ResetSettings(resetMainToggle: true);
			};
		}
		foreach (AMod mod in _mods)
		{
			action(mod);
		}
		Preset.SetSilently("-");
	}

	public static void TryInitialize(string[] presetNames, ICollection<AMod> mods)
	{
		if (!Extensions_ICollections.IsNullOrEmpty<string>((ICollection<string>)presetNames) && !Extensions_ICollections.IsNullOrEmpty<AMod>(mods))
		{
			List<string> obj = new List<string> { "-", "Reset to defaults" };
			Extensions_ICollections.Add<string>((ICollection<string>)obj, presetNames);
			_presetNames = obj.ToArray();
			_mods = mods;
			CreateLoadPresetSetting();
		}
	}
}

BepInEx/Plugins/Vheos/Vheos.Mods.Outward.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using NodeCanvas.Tasks.Conditions;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Vheos.Helpers.Collections;
using Vheos.Helpers.Common;
using Vheos.Helpers.Dump;
using Vheos.Helpers.Math;
using Vheos.Helpers.RNG;
using Vheos.Helpers.UnityObjects;
using Vheos.Mods.Core;
using Vheos.Tools.TraitEqualizer;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Vheos.Mods.Outward;

internal class ModSections
{
	public const string Development = "    \nDEVELOPMENT";

	public const string SurvivalAndImmersion = "   \nSURVIVAL & IMMERSION";

	public const string Combat = "  \nCOMBAT";

	public const string Skills = " \nSKILLS";

	public const string UI = "\nUSER INTERFACE";
}
public static class Players
{
	public class Data
	{
		public SplitPlayer Split;

		public Character Character;

		public PlayerCharacterStats Stats;

		public CharacterCamera Camera;

		public CharacterUI UI;

		public PlayerSystem System;

		public int ID;

		public string UID;

		public bool IsUsingGamepad => GameInput.IsUsingGamepad(ID);

		public Vector2 CameraMovementInput => new Vector2(GameInput.AxisValue(ID, (GameplayActions)2), GameInput.AxisValue(ID, (GameplayActions)3));

		public Vector2 PlayerMovementInput => new Vector2(GameInput.AxisValue(ID, (GameplayActions)0), GameInput.AxisValue(ID, (GameplayActions)1));

		public bool Pressed(string actionName)
		{
			return GameInput.Pressed(ID, actionName);
		}

		public bool Released(string actionName)
		{
			return GameInput.Released(ID, actionName);
		}

		public bool Held(string actionName)
		{
			return GameInput.Held(ID, actionName);
		}

		public float AxisValue(string axisName)
		{
			return GameInput.AxisValue(ID, axisName);
		}

		public bool Pressed(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Pressed(ID, gameplayAction);
		}

		public bool Released(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Released(ID, gameplayAction);
		}

		public bool Held(GameplayActions gameplayAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Held(ID, gameplayAction);
		}

		public float AxisValue(GameplayActions gameplayAxis)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.AxisValue(ID, gameplayAxis);
		}

		public bool Pressed(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Pressed(ID, menuAction);
		}

		public bool Released(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Released(ID, menuAction);
		}

		public bool Held(MenuActions menuAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.Held(ID, menuAction);
		}

		public float AxisValue(MenuActions menuAxis)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GameInput.AxisValue(ID, menuAxis);
		}
	}

	public static List<Data> Local { get; private set; }

	public static Data GetFirst()
	{
		return UnityEngineExtensions.FirstOrDefault<Data>((IList<Data>)Local);
	}

	public static Data GetLocal(int playerID)
	{
		return Extensions_IList.DefaultOnInvalid<Data>((IList<Data>)Local, playerID);
	}

	public static Data GetLocal(LocalCharacterControl localCharacterControl)
	{
		return GetLocal(GetPlayerID(localCharacterControl));
	}

	public static Data GetLocal(UIElement uiElement)
	{
		return GetLocal(GetPlayerID(uiElement));
	}

	public static Data GetLocal(Character character)
	{
		return GetLocal(GetPlayerID(character));
	}

	public static Data GetLocal(CharacterUI characterUI)
	{
		return GetLocal(GetPlayerID(characterUI));
	}

	public static Data GetLocal(CharacterCamera characterCamera)
	{
		return GetLocal(GetPlayerID(characterCamera));
	}

	public static bool TryGetFirst(out Data player)
	{
		return Extensions.TryNonNull<Data>(GetFirst(), ref player);
	}

	public static bool TryGetLocal(int playerID, out Data player)
	{
		player = GetLocal(playerID);
		return player != null;
	}

	public static bool TryGetLocal(LocalCharacterControl localCharacterControl, out Data player)
	{
		return TryGetLocal(GetPlayerID(localCharacterControl), out player);
	}

	public static bool TryGetLocal(UIElement uiElement, out Data player)
	{
		return TryGetLocal(GetPlayerID(uiElement), out player);
	}

	public static bool TryGetLocal(Character character, out Data player)
	{
		return TryGetLocal(GetPlayerID(character), out player);
	}

	public static bool TryGetLocal(CharacterUI characterUI, out Data player)
	{
		return TryGetLocal(GetPlayerID(characterUI), out player);
	}

	public static bool TryGetLocal(CharacterCamera characterCamera, out Data player)
	{
		return TryGetLocal(GetPlayerID(characterCamera), out player);
	}

	private static void Recache()
	{
		Local.Clear();
		foreach (SplitPlayer localPlayer in SplitScreenManager.Instance.LocalPlayers)
		{
			Character assignedCharacter = localPlayer.AssignedCharacter;
			PlayerSystem ownerPlayerSys = assignedCharacter.OwnerPlayerSys;
			Local.Add(new Data
			{
				Split = localPlayer,
				Character = assignedCharacter,
				Stats = assignedCharacter.PlayerStats,
				Camera = assignedCharacter.CharacterCamera,
				UI = assignedCharacter.CharacterUI,
				System = ownerPlayerSys,
				ID = ownerPlayerSys.PlayerID,
				UID = ownerPlayerSys.UID
			});
		}
	}

	private static int GetPlayerID(LocalCharacterControl localCharacterControl)
	{
		return ((CharacterControl)localCharacterControl).Character.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(UIElement uiElement)
	{
		return uiElement.LocalCharacter.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(Character character)
	{
		return character.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(CharacterUI characterUI)
	{
		return characterUI.TargetCharacter.OwnerPlayerSys.PlayerID;
	}

	private static int GetPlayerID(CharacterCamera characterCamera)
	{
		return characterCamera.TargetCharacter.OwnerPlayerSys.PlayerID;
	}

	public static void Initialize()
	{
		Local = new List<Data>();
		Harmony.CreateAndPatchAll(typeof(Players), (string)null);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LocalCharacterControl), "RetrieveComponents")]
	private static void LocalCharacterControl_RetrieveComponents_Post()
	{
		Recache();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(RPCManager), "SendPlayerHasLeft")]
	private static void RPCManager_SendPlayerHasLeft_Post()
	{
		Recache();
	}
}
public static class Prefabs
{
	private static Dictionary<int, Item> _itemsByID;

	private static Dictionary<int, Item> _ingestiblesByID;

	private static Dictionary<int, Skill> _skillsByID;

	private static List<StatusEffect> _sleepBuffs;

	public static readonly Dictionary<string, int> ItemIDsByName = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
	{
		["Torcrab Egg"] = 4000480,
		["Boreo Blubber"] = 4000500,
		["Pungent Paste"] = 4100190,
		["Gaberry Jam"] = 4100030,
		["Crawlberry Jam"] = 4100710,
		["Golden Jam"] = 4100800,
		["Raw Torcrab Meat"] = 4000470,
		["Miner’s Omelet"] = 4100280,
		["Turmmip Potage"] = 4100270,
		["Meat Stew"] = 4100220,
		["Marshmelon Jelly"] = 4100420,
		["Blood Mushroom"] = 4000150,
		["Food Waste"] = 4100000,
		["Warm Boozu’s Milk"] = 4100680,
		["Panacea"] = 4300370,
		["Antidote"] = 4300110,
		["Hex Cleaner"] = 4300190,
		["Invigorating Potion"] = 4300280,
		["Able Tea"] = 4200090,
		["Bitter Spicy Tea"] = 4200050,
		["Greasy Tea"] = 4200110,
		["Iced Tea"] = 4200100,
		["Mineral Tea"] = 4200080,
		["Needle Tea"] = 4200070,
		["Soothing Tea"] = 4200060,
		["Boozu’s Milk"] = 4000380,
		["Gaberry Wine"] = 4100590,
		["Gep's Drink"] = 4300040,
		["Waterskin"] = 4200040,
		["Ambraine"] = 4000430,
		["Bandages"] = 4400010,
		["Life Potion"] = 4300010,
		["MistakenIngestible"] = 4500020,
		["Old Legion Shield"] = 2300070,
		["Boiled Azure Shrimp"] = 4100540,
		["Coralhorn Antler"] = 6600060,
		["Great Astral Potion"] = 4300250,
		["Alpha Tuanosaur Tail"] = 6600190,
		["Crystal Powder"] = 6600040,
		["Manticore Tail"] = 6600150,
		["Gold Ingot"] = 6300030,
		["Tsar Stone"] = 6200010,
		["Explorer Lantern"] = 5100000,
		["Old Lantern"] = 5100010,
		["Glowstone Lantern"] = 5100020,
		["Firefly Lantern"] = 5100030,
		["Lantern of Souls"] = 5100080,
		["Coil Lantern"] = 5100090,
		["Virgin Lantern"] = 5100100,
		["Djinn’s Lamp"] = 5100110,
		["Calixa’s Relic"] = 6600225,
		["Elatt’s Relic"] = 6600222,
		["Gep’s Generosity"] = 6600220,
		["Haunted Memory"] = 6600224,
		["Leyline Figment"] = 6600226,
		["Pearlbird’s Courage"] = 6600221,
		["Scourge’s Tears"] = 6600223,
		["Vendavel's Hospitality"] = 6600227,
		["Flowering Corruption"] = 6600228,
		["Metalized Bones"] = 6600230,
		["Enchanted Mask"] = 6600229,
		["Noble’s Greed"] = 6600232,
		["Scarlet Whisper"] = 6600231,
		["Calygrey’s Wisdom"] = 6600233,
		["Hailfrost Claymore"] = 2100270,
		["Hailfrost Mace"] = 2020290,
		["Hailfrost Hammer"] = 2120240,
		["Hailfrost Axe"] = 2010250,
		["Hailfrost Greataxe"] = 2110230,
		["Hailfrost Spear"] = 2130280,
		["Hailfrost Halberd"] = 2150110,
		["Hailfrost Pistol"] = 5110270,
		["Hailfrost Knuckles"] = 2160200,
		["Hailfrost Sword"] = 2000280,
		["Hailfrost Dagger"] = 5110015,
		["Mysterious Blade"] = 2000320,
		["Mysterious Long Blade"] = 2100300,
		["Ceremonial Bow"] = 2200190,
		["Cracked Red Moon"] = 2150180,
		["Compasswood Staff"] = 2150030,
		["Scarred Dagger"] = 5110340,
		["De-powered Bludgeon"] = 2120270,
		["Unusual Knuckles"] = 2160230,
		["Strange Rusted Sword"] = 2000151,
		["Flint and Steel"] = 5600010,
		["Fishing Harpoon"] = 2130130,
		["Mining Pick"] = 2120050,
		["Makeshift Torch"] = 5100060,
		["Ice-Flame Torch"] = 5100070,
		["Bullet"] = 4400080,
		["Arrow"] = 5200001,
		["Flaming Arrow"] = 5200002,
		["Poison Arrow"] = 5200003,
		["Venom Arrow"] = 5200004,
		["Palladium Arrow"] = 5200005,
		["Explosive Arrow"] = 5200007,
		["Forged Arrow"] = 5200008,
		["Holy Rage Arrow"] = 5200009,
		["Soul Rupture Arrow"] = 5200010,
		["Mana Arrow"] = 5200019,
		["Adventurer Backpack"] = 5300000
	};

	public static readonly Dictionary<string, int> SkillIDsByName = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
	{
		["Puncture"] = 8100290,
		["Pommel Counter"] = 8100362,
		["Talus Cleaver"] = 8100380,
		["Execution"] = 8100300,
		["Mace Infusion"] = 8100270,
		["Juggernaut"] = 8100310,
		["Simeon's Gambit"] = 8100340,
		["Moon Swipe"] = 8100320,
		["Prismatic Flurry"] = 8201040,
		["The Technique"] = 8100530,
		["Moment of Truth"] = 8100520,
		["Scalp Collector"] = 8100540,
		["Warrior's Vein"] = 8100500,
		["Dispersion"] = 8100510,
		["Crescendo"] = 8100550,
		["Vicious Cycle"] = 8100560,
		["Splitter"] = 8100561,
		["Vital Crash"] = 8100570,
		["Strafing Run"] = 8100580,
		["Mist"] = 8200170,
		["Warm"] = 8200130,
		["Cool"] = 8200140,
		["Blessed"] = 8200180,
		["Possessed"] = 8200190,
		["Haunt Hex"] = 8201024,
		["Scorch Hex"] = 8201020,
		["Chill Hex"] = 8201021,
		["Doom Hex"] = 8201022,
		["Curse Hex"] = 8201023,
		["Backstab"] = 8100070,
		["Opportunist Stab"] = 8100071,
		["Serpent's Parry"] = 8100261,
		["Shatter Bullet"] = 8200603,
		["Frost Bullet"] = 8200601,
		["Blood Bullet"] = 8200602,
		["Chakram Pierce"] = 8100250,
		["Chakram Arc"] = 8100252,
		["Chakram Dance"] = 8100251,
		["Shield Charge"] = 8100190,
		["Gong Strike"] = 8100200,
		["Shield Infusion"] = 8100330,
		["Evasion Shot"] = 8100100,
		["Sniper Shot"] = 8100101,
		["Piercing Shot"] = 8100102,
		["Dez"] = 8100210,
		["Shim"] = 8100220,
		["Egoth"] = 8100230,
		["Fal"] = 8100240,
		["Spark"] = 8200040,
		["Flamethrower"] = 8100090,
		["Push Kick"] = 8100120,
		["Throw Lantern"] = 8100010,
		["Dagger Slash"] = 8100072,
		["Fire/Reload"] = 8200600,
		["Armor Training"] = 8205220,
		["Acrobatics"] = 8205450,
		["Hunter's Eye"] = 8205160
	};

	public static IReadOnlyDictionary<int, Item> ItemsByID => _itemsByID;

	public static IReadOnlyDictionary<int, Skill> SkillsByID => _skillsByID;

	public static IReadOnlyDictionary<int, Item> IngestiblesByID => _ingestiblesByID;

	public static IReadOnlyList<StatusEffect> SleepBuffs => _sleepBuffs;

	public static IReadOnlyDictionary<string, StatusEffect> StatusEffectsByNameID => ResourcesPrefabManager.STATUSEFFECT_PREFABS;

	public static IReadOnlyDictionary<string, Recipe> RecipesByUID => RecipeManager.Instance.m_recipes;

	public static IReadOnlyDictionary<string, QuestEventSignature> QuestsByID => QuestEventDictionary.m_questEvents;

	public static bool IsInitialized { get; private set; }

	public static void Initialize()
	{
		_itemsByID = new Dictionary<int, Item>();
		_skillsByID = new Dictionary<int, Skill>();
		_ingestiblesByID = new Dictionary<int, Item>();
		int other = "MistakenIngestible".ToItemID();
		Skill val = default(Skill);
		foreach (KeyValuePair<string, Item> iTEM_PREFAB in ResourcesPrefabManager.ITEM_PREFABS)
		{
			int key = Extensions.ToInt(iTEM_PREFAB.Key);
			Item value = iTEM_PREFAB.Value;
			_itemsByID.Add(key, value);
			if ((value.IsEatable() || value.IsDrinkable()) && !value.SharesPrefabWith(other))
			{
				_ingestiblesByID.Add(value.ItemID, value);
			}
			if (Extensions.TryAs<Skill>((object)value, ref val))
			{
				_skillsByID.Add(((Item)val).ItemID, val);
			}
		}
		_sleepBuffs = new List<StatusEffect>();
		StatusEffect[] array = Resources.FindObjectsOfTypeAll<StatusEffect>();
		foreach (StatusEffect val2 in array)
		{
			if (((Component)(object)val2).NameContains("SleepBuff"))
			{
				_sleepBuffs.Add(val2);
			}
		}
		IsInitialized = true;
	}
}
public static class GameInput
{
	public static float HOLD_DURATION = 1.25f;

	public static float HOLD_THRESHOLD = 0.4f;

	public static bool ForceCursorNavigation;

	private static Dictionary<string, KeyCode> _keyCodesByName;

	public static bool Pressed(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButtonDown(actionName);
	}

	public static bool Released(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButtonUp(actionName);
	}

	public static bool Held(int playerID, string actionName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetButton(actionName);
	}

	public static float AxisValue(int playerID, string axisnName)
	{
		return ControlsInput.m_playerInputManager[playerID].GetAxis(axisnName);
	}

	public static bool IsUsingGamepad(int playerID)
	{
		return ControlsInput.IsLastActionGamepad(playerID);
	}

	public static KeyCode ToKeyCode(string text)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!Extensions.IsNotEmpty(text) || !_keyCodesByName.ContainsKey(text))
		{
			return (KeyCode)0;
		}
		return _keyCodesByName[text];
	}

	public static bool Pressed(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Pressed(playerID, gameplayAction.ToName());
	}

	public static bool Released(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Released(playerID, gameplayAction.ToName());
	}

	public static bool Held(int playerID, GameplayActions gameplayAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Held(playerID, gameplayAction.ToName());
	}

	public static float AxisValue(int playerID, GameplayActions gameplayAxis)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return AxisValue(playerID, gameplayAxis.ToName());
	}

	public static bool Pressed(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Pressed(playerID, menuAction.ToName());
	}

	public static bool Released(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Released(playerID, menuAction.ToName());
	}

	public static bool Held(int playerID, MenuActions menuAction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Held(playerID, menuAction.ToName());
	}

	public static float AxisValue(int playerID, MenuActions menuAxis)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return AxisValue(playerID, menuAxis.ToName());
	}

	public static void Initialize()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		_keyCodesByName = new Dictionary<string, KeyCode>();
		foreach (KeyCode value2 in Enum.GetValues(typeof(KeyCode)))
		{
			KeyCode value = value2;
			string text = ((object)(KeyCode)(ref value)).ToString();
			if (!text.Contains("Joystick") && !_keyCodesByName.ContainsKey(text))
			{
				_keyCodesByName.Add(text, value);
			}
		}
		Harmony.CreateAndPatchAll(typeof(GameInput), (string)null);
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static bool CharacterUI_IsMenuFocused_Getter_Pre(ref bool __result)
	{
		if (!ForceCursorNavigation)
		{
			return true;
		}
		__result = true;
		return false;
	}
}
public enum Preset
{
	Vheos_CoopSurvival,
	Vheos_PreferredUI
}
public class Dodge : AMod
{
	private static ModSetting<int> _staminaCost;

	private static ModSetting<int> _staminaCostWithAcrobatics;

	private static ModSetting<bool> _allowMidAttack;

	private static ModSetting<bool> _allowMidAttackUntilDamageDealt;

	private static ModSetting<bool> _allowMidAttackUntilDamageTaken;

	private static ModSetting<bool> _invincibility;

	protected override string SectionOverride => "  \nCOMBAT";

	protected override string Description => "• Adjust stamina cost\n• Allow dodging during attack animation\n• Remove dodge invincibility";

	protected override void Initialize()
	{
		_staminaCost = ((AMod)this).CreateSetting<int>("_staminaCost", 6, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 50));
		_staminaCostWithAcrobatics = ((AMod)this).CreateSetting<int>("_staminaCostWithAcrobatics", 9, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 50));
		_allowMidAttack = ((AMod)this).CreateSetting<bool>("_allowMidAttack", false, (AcceptableValueBase)null);
		_allowMidAttackUntilDamageDealt = ((AMod)this).CreateSetting<bool>("_allowMidAttackUntilDamageTaken", false, (AcceptableValueBase)null);
		_allowMidAttackUntilDamageTaken = ((AMod)this).CreateSetting<bool>("_allowMidAttackUntilDamageDealt", false, (AcceptableValueBase)null);
		_invincibility = ((AMod)this).CreateSetting<bool>("_invincibility", true, (AcceptableValueBase)null);
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_staminaCost.Value = 6;
			_staminaCostWithAcrobatics.Value = 9;
			_allowMidAttack.Value = true;
			_allowMidAttackUntilDamageDealt.Value = true;
			_allowMidAttackUntilDamageTaken.Value = true;
			_invincibility.Value = false;
		}
	}

	protected override void SetFormatting()
	{
		((AModSetting)_staminaCost).Format("Stamina cost");
		((AModSetting)_staminaCost).Description = "How much stamina dodging costs\n\nUnit: stamina points";
		using (AMod.Indent)
		{
			((AModSetting)_staminaCostWithAcrobatics).Format("with Acrobatics");
			((AModSetting)_staminaCostWithAcrobatics).Description = "If you have the Acrobatics passive skill, this value will be used in place of \"" + ((AModSetting)_staminaCost).Name + "\"";
		}
		((AModSetting)_allowMidAttack).Format("Allow mid-attack");
		((AModSetting)_allowMidAttack).Description = "Allows you to dodge even if you're in the middle of an attack animation";
		using (AMod.Indent)
		{
			((AModSetting)_allowMidAttackUntilDamageDealt).Format("until you deal damage", _allowMidAttack);
			((AModSetting)_allowMidAttackUntilDamageDealt).Description = "Prevents using mid-attack dodge after you deal damage\nLasts only until you start a new attack";
			((AModSetting)_allowMidAttackUntilDamageTaken).Format("until you take damage", _allowMidAttack);
			((AModSetting)_allowMidAttackUntilDamageTaken).Description = "Prevents using mid-attack dodge after you take damage\nLasts only until you start a new attack";
		}
		((AModSetting)_invincibility).Format("Invincibility");
		((AModSetting)_invincibility).Description = "Makes you invincible for roughly 500ms while performing a normal dodge (not slowed down by backpack)";
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Character), "StartAttack")]
	private static void Character_StartAttack_Post(Character __instance, int _type, int _id)
	{
		if (ModSetting<bool>.op_Implicit(_allowMidAttack) && __instance.IsPlayer())
		{
			__instance.m_dodgeAllowedInAction = Extensions.To01(_type == 0 || _type == 1);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Character), "OnReceiveHit")]
	private static void Character_OnReceiveHit_Post(Character __instance, Character _dealerChar)
	{
		if (ModSetting<bool>.op_Implicit(_allowMidAttack))
		{
			if (ModSetting<bool>.op_Implicit(_allowMidAttackUntilDamageTaken) && (Object)(object)__instance != (Object)null && __instance.IsPlayer())
			{
				__instance.m_dodgeAllowedInAction = 0;
			}
			if (ModSetting<bool>.op_Implicit(_allowMidAttackUntilDamageDealt) && (Object)(object)_dealerChar != (Object)null && _dealerChar.IsPlayer())
			{
				_dealerChar.m_dodgeAllowedInAction = 0;
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Interactions.InteractionTakeAnimated), "OnActivate")]
	private static void InteractionTakeAnimated_OnActivate_Pre(Interactions.InteractionTakeAnimated __instance)
	{
		((InteractionBase)__instance).LastCharacter.m_dodgeAllowedInAction = 0;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Character), "DodgeStep")]
	private static void Character_DodgeStep_Post(ref Hitbox[] ___m_hitboxes, ref int _step)
	{
		if (!ModSetting<bool>.op_Implicit(_invincibility) && _step > 0 && ___m_hitboxes != null)
		{
			Hitbox[] array = ___m_hitboxes;
			for (int i = 0; i < array.Length; i++)
			{
				((Component)array[i]).gameObject.SetActive(true);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void Character_DodgeStamCost_Getter_Post(Character __instance, ref int __result)
	{
		__result = ModSetting<int>.op_Implicit(((CharacterKnowledge)__instance.Inventory.SkillKnowledge).IsItemLearned("Acrobatics".ToSkillID()) ? _staminaCostWithAcrobatics : _staminaCost);
	}
}
public class Crafting : AMod
{
	[Flags]
	private enum CraftingExceptions
	{
		None = 0,
		Lanterns = 2,
		Relics = 4,
		HailfrostWeapons = 8,
		UniqueWeapons = 0x10
	}

	private const string CRYSTAL_POWDER_RECIPE_UID = "-SEtMHRqWUmvrmyvryV8Ng";

	private static readonly int[] LANTERN_IDS = new int[8]
	{
		"Explorer Lantern".ToItemID(),
		"Old Lantern".ToItemID(),
		"Glowstone Lantern".ToItemID(),
		"Firefly Lantern".ToItemID(),
		"Lantern of Souls".ToItemID(),
		"Coil Lantern".ToItemID(),
		"Virgin Lantern".ToItemID(),
		"Djinn’s Lamp".ToItemID()
	};

	private static readonly int[] RELIC_IDS = new int[14]
	{
		"Calixa’s Relic".ToItemID(),
		"Elatt’s Relic".ToItemID(),
		"Gep’s Generosity".ToItemID(),
		"Haunted Memory".ToItemID(),
		"Leyline Figment".ToItemID(),
		"Pearlbird’s Courage".ToItemID(),
		"Scourge’s Tears".ToItemID(),
		"Vendavel's Hospitality".ToItemID(),
		"Flowering Corruption".ToItemID(),
		"Metalized Bones".ToItemID(),
		"Enchanted Mask".ToItemID(),
		"Noble’s Greed".ToItemID(),
		"Scarlet Whisper".ToItemID(),
		"Calygrey’s Wisdom".ToItemID()
	};

	private static readonly int[] HAILFROST_WEAPONS_IDS = new int[11]
	{
		"Hailfrost Claymore".ToItemID(),
		"Hailfrost Mace".ToItemID(),
		"Hailfrost Hammer".ToItemID(),
		"Hailfrost Axe".ToItemID(),
		"Hailfrost Greataxe".ToItemID(),
		"Hailfrost Spear".ToItemID(),
		"Hailfrost Halberd".ToItemID(),
		"Hailfrost Pistol".ToItemID(),
		"Hailfrost Knuckles".ToItemID(),
		"Hailfrost Sword".ToItemID(),
		"Hailfrost Dagger".ToItemID()
	};

	private static readonly int[] UNIQUE_WEAPONS_IDS = new int[9]
	{
		"Mysterious Blade".ToItemID(),
		"Mysterious Long Blade".ToItemID(),
		"Ceremonial Bow".ToItemID(),
		"Cracked Red Moon".ToItemID(),
		"Compasswood Staff".ToItemID(),
		"Scarred Dagger".ToItemID(),
		"De-powered Bludgeon".ToItemID(),
		"Unusual Knuckles".ToItemID(),
		"Strange Rusted Sword".ToItemID()
	};

	private static ModSetting<bool> _preserveDurability;

	private static ModSetting<int> _restoreMissingDurability;

	private static ModSetting<bool> _autoLearnCrystalPowderRecipe;

	private static ModSetting<bool> _limitedManualCrafting;

	private static ModSetting<CraftingExceptions> _limitedManulCraftingExceptions;

	private static ModSetting<int> _extraResultsMultiplier;

	protected override string Description => "• Make crafted items' durability relative to ingredients\n• Require recipes for advanced crafting\n• Multiply amount of crafted items\n• Randomize starting durability of spawned items";

	protected override string SectionOverride => "   \nSURVIVAL & IMMERSION";

	protected override void Initialize()
	{
		_preserveDurability = ((AMod)this).CreateSetting<bool>("_preserveDurability", false, (AcceptableValueBase)null);
		_autoLearnCrystalPowderRecipe = ((AMod)this).CreateSetting<bool>("_autoLearnCrystalPowderRecipe", true, (AcceptableValueBase)null);
		_restoreMissingDurability = ((AMod)this).CreateSetting<int>("_restoreMissingDurability", 50, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_limitedManualCrafting = ((AMod)this).CreateSetting<bool>("_limitedManualCrafting", false, (AcceptableValueBase)null);
		_limitedManulCraftingExceptions = ((AMod)this).CreateSetting<CraftingExceptions>("CraftingExceptions", (CraftingExceptions)(-1), (AcceptableValueBase)null);
		_extraResultsMultiplier = ((AMod)this).CreateSetting<int>("_extraResultsMultiplier", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 200));
	}

	protected override void SetFormatting()
	{
		((AModSetting)_preserveDurability).Format("Preserve durability ratios");
		((AModSetting)_preserveDurability).Description = "Crafted items' durability will be based on the average of all ingredients (instead of 100%)";
		using (AMod.Indent)
		{
			((AModSetting)_restoreMissingDurability).Format("Restore % of missing durability", _preserveDurability);
			((AModSetting)_restoreMissingDurability).Description = "Increase to make broken/rotten ingredients still useful (instead of just lowering the durability ratio)";
		}
		((AModSetting)_limitedManualCrafting).Format("Limited manual crafting");
		((AModSetting)_limitedManualCrafting).Description = "Manual crafting will be limited to 1 ingredient\nAdvanced crafting will require learning recipes first";
		using (AMod.Indent)
		{
			((AModSetting)_limitedManulCraftingExceptions).Format("Exceptions", _limitedManualCrafting);
			((AModSetting)_limitedManulCraftingExceptions).Description = "If you use any of these items in manual crafting, you will be able to use all 4 ingredient slots\nThis allows you craft items whose recipes can't be learned in advance";
			((AModSetting)_autoLearnCrystalPowderRecipe).Format("Auto-learn \"Crystal Powder\" recipe", _limitedManualCrafting);
			((AModSetting)_autoLearnCrystalPowderRecipe).Description = "Normally, \"Crystal Powder\" recipe can only be learned via crafting\nThis will give you the recipe when you interact with the alchemy kit";
		}
		((AModSetting)_extraResultsMultiplier).Format("Extra results multiplier");
		((AModSetting)_extraResultsMultiplier).Description = "Multiplies the extra (over one) amount of crafting results\nFor example, Gaberry Tartine gives 3 (1+2) items, so the extra amount is 2\nat 0% extra amount, it will give 1 (1+0) item, and at 200% - 5 (1+4) items";
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_preserveDurability.Value = true;
			_restoreMissingDurability.Value = 50;
			_limitedManualCrafting.Value = true;
			_limitedManulCraftingExceptions.Value = (CraftingExceptions)(-1);
			_autoLearnCrystalPowderRecipe.Value = true;
			_extraResultsMultiplier.Value = 50;
		}
	}

	private static List<Item> GetDestructibleIngredients(CraftingMenu craftingMenu)
	{
		List<Item> list = new List<Item>();
		IngredientSelector[] ingredientSelectors = craftingMenu.m_ingredientSelectors;
		CompatibleIngredient val = default(CompatibleIngredient);
		int num = default(int);
		Item val2 = default(Item);
		for (int i = 0; i < ingredientSelectors.Length; i++)
		{
			if (!Extensions.TryNonNull<CompatibleIngredient>(ingredientSelectors[i].AssignedIngredient, ref val))
			{
				continue;
			}
			foreach (KeyValuePair<string, int> consumedItem in val.GetConsumedItems(false, ref num))
			{
				if (Extensions.TryNonNull<Item>(ItemManager.Instance.GetItem(consumedItem.Key), ref val2) && val2.MaxDurability > 0)
				{
					Extensions_ICollections.TryAddUnique<Item>((ICollection<Item>)list, val2);
				}
			}
		}
		return list;
	}

	private static List<Item> GetDestructibleResults(CraftingMenu craftingMenu)
	{
		int lastRecipeIndex = craftingMenu.m_lastRecipeIndex;
		int num = ((lastRecipeIndex >= 0) ? craftingMenu.m_complexeRecipes[lastRecipeIndex].Key : craftingMenu.m_lastFreeRecipeIndex);
		List<Item> list = new List<Item>();
		if (num >= 0)
		{
			ItemReferenceQuantity[] results = craftingMenu.m_allRecipes[num].Results;
			Item val = default(Item);
			for (int i = 0; i < results.Length; i++)
			{
				if (Extensions.TryNonNull<Item>(results[i].RefItem, ref val) && val.MaxDurability > 0)
				{
					Extensions_ICollections.TryAddUnique<Item>((ICollection<Item>)list, val);
				}
			}
		}
		return list;
	}

	private static void SetSingleIngredientCrafting(CraftingMenu __instance, bool enabled)
	{
		UnityEngineExtensions.SetAlpha((Graphic)(object)__instance.m_multipleIngrenentsBrackground, enabled ? 0f : 1f);
		UnityEngineExtensions.SetAlpha((Graphic)(object)__instance.m_singleIngredientBackground, enabled ? 1f : 0f);
		for (int i = 1; i < __instance.m_ingredientSelectors.Length; i++)
		{
			Extensions_Component.SetActive((Component)(object)__instance.m_ingredientSelectors[i], !enabled);
		}
	}

	private static int GetModifiedResultsAmount(ItemReferenceQuantity result)
	{
		return 1 + Extensions_float.Round(Extensions_float.Mul((float)result.Quantity - 1f, (float)ModSetting<int>.op_Implicit(_extraResultsMultiplier) / 100f));
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(CraftingMenu), "CraftingDone")]
	private static void CraftingMenu_CraftingDone_Pre(CraftingMenu __instance, ref List<Item> __state)
	{
		List<Item> destructibleIngredients = GetDestructibleIngredients(__instance);
		List<Item> destructibleResults = GetDestructibleResults(__instance);
		if (!ModSetting<bool>.op_Implicit(_preserveDurability) || Extensions_ICollections.IsNullOrEmpty<Item>((ICollection<Item>)destructibleIngredients) || Extensions_ICollections.IsNullOrEmpty<Item>((ICollection<Item>)destructibleIngredients))
		{
			return;
		}
		float num = 0f;
		foreach (Item item in destructibleIngredients)
		{
			num += item.DurabilityRatio;
		}
		num /= (float)destructibleIngredients.Count;
		ItemStats val = default(ItemStats);
		foreach (Item item2 in destructibleResults)
		{
			if (Extensions.TryNonNull<ItemStats>(item2.Stats, ref val))
			{
				val.StartingDurability = Extensions_float.Round((float)val.MaxDurability * Extensions_float.Lerp(num, 1f, (float)ModSetting<int>.op_Implicit(_restoreMissingDurability) / 100f));
			}
		}
		__state = destructibleResults;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CraftingMenu), "CraftingDone")]
	private static void CraftingMenu_CraftingDone_Post(CraftingMenu __instance, ref List<Item> __state)
	{
		if (__state == null)
		{
			return;
		}
		ItemStats val = default(ItemStats);
		foreach (Item item in __state)
		{
			if (Extensions.TryNonNull<ItemStats>(item.Stats, ref val))
			{
				val.StartingDurability = -1;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CraftingMenu), "OnRecipeSelected")]
	private static void CraftingMenu_OnRecipeSelected_Post(CraftingMenu __instance)
	{
		if (ModSetting<bool>.op_Implicit(_limitedManualCrafting))
		{
			SetSingleIngredientCrafting(__instance, __instance.m_lastRecipeIndex == -1);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CraftingMenu), "IngredientSelectorHasChanged")]
	private static void CraftingMenu_IngredientSelectorHasChanged_Post(CraftingMenu __instance, int _selectorIndex, int _itemID)
	{
		if (ModSetting<bool>.op_Implicit(_limitedManualCrafting) && __instance.m_lastRecipeIndex < 0)
		{
			bool flag = (_limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.Lanterns) && Extensions.IsContainedIn<int>(_itemID, (ICollection<int>)LANTERN_IDS)) || (_limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.Relics) && Extensions.IsContainedIn<int>(_itemID, (ICollection<int>)RELIC_IDS)) || (_limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.HailfrostWeapons) && Extensions.IsContainedIn<int>(_itemID, (ICollection<int>)HAILFROST_WEAPONS_IDS)) || (_limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.UniqueWeapons) && Extensions.IsContainedIn<int>(_itemID, (ICollection<int>)UNIQUE_WEAPONS_IDS));
			SetSingleIngredientCrafting(__instance, !flag);
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(CraftingMenu), "Show", new Type[] { typeof(CraftingStation) })]
	private static void CraftingMenu_Show_Pre(CraftingMenu __instance, CraftingStation _ustensil)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		if (ModSetting<bool>.op_Implicit(_limitedManualCrafting) && (int)_ustensil.StationType == 0 && RecipeManager.Instance.m_recipes.TryGetValue("-SEtMHRqWUmvrmyvryV8Ng", out var value) && !((UIElement)__instance).LocalCharacter.HasLearnedRecipe(value))
		{
			((UIElement)__instance).LocalCharacter.LearnRecipe(value);
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(CraftingMenu), "GenerateResult")]
	private static void CraftingMenu_GenerateResult_Pre(CraftingMenu __instance, ref int __state, ItemReferenceQuantity _result)
	{
		if (ModSetting<int>.op_Implicit(_extraResultsMultiplier) != 100)
		{
			__state = _result.Quantity;
			_result.Quantity = GetModifiedResultsAmount(_result);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CraftingMenu), "GenerateResult")]
	private static void CraftingMenu_GenerateResult_Post(CraftingMenu __instance, ref int __state, ItemReferenceQuantity _result)
	{
		if (ModSetting<int>.op_Implicit(_extraResultsMultiplier) != 100)
		{
			_result.Quantity = __state;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(RecipeResultDisplay), "UpdateQuantityDisplay")]
	private static bool RecipeResultDisplay_UpdateQuantityDisplay_Pre(RecipeResultDisplay __instance)
	{
		if (ModSetting<int>.op_Implicit(_extraResultsMultiplier) == 100 || ((ItemDisplay)__instance).StackCount <= 1)
		{
			return true;
		}
		int modifiedResultsAmount = GetModifiedResultsAmount(__instance.m_result);
		((ItemDisplay)__instance).m_lblQuantity.text = ((modifiedResultsAmount > 0) ? modifiedResultsAmount.ToString() : "");
		return false;
	}
}
public class AI : AMod
{
	[Flags]
	private enum FactionGroup
	{
		HumansAndNonHostileMonsters = 2,
		HostileMonsters = 4
	}

	private static ModSetting<int> _enemyDetectionModifier;

	private static ModSetting<FactionGroup> _preventInfighting;

	private static ModSetting<int> _walkTowardsPlayerOnSpawn;

	private static ModSetting<int> _retargetOnHit;

	private static ModSetting<bool> _retargetWhenTooFar;

	private static ModSetting<Vector2> _retargetCheckInterval;

	private static ModSetting<float> _retargetCurrentToNearestRatio;

	private static ModSetting<bool> _retargetDetectAllPlayers;

	private static readonly Dictionary<FactionGroup, Factions[]> FACTION_GROUPS_BY_ENUM;

	protected override string SectionOverride => "  \nCOMBAT";

	protected override string Description => "• Adjust enemy detection\n• Stop infighting between enemies\n• Adjust enemies' retargeting behaviour";

	protected override void Initialize()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		_enemyDetectionModifier = ((AMod)this).CreateSetting<int>("_enemyDetectionModifier", 0, (AcceptableValueBase)(object)((AMod)this).IntRange(-100, 100));
		_preventInfighting = ((AMod)this).CreateSetting<FactionGroup>("_preventInfighting", (FactionGroup)0, (AcceptableValueBase)null);
		_retargetOnHit = ((AMod)this).CreateSetting<int>("_retargetOnHit", 50, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_walkTowardsPlayerOnSpawn = ((AMod)this).CreateSetting<int>("_walkTowardsPlayerOnSpawn", 50, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_retargetWhenTooFar = ((AMod)this).CreateSetting<bool>("_retargetWhenTooFar", false, (AcceptableValueBase)null);
		_retargetCheckInterval = ((AMod)this).CreateSetting<Vector2>("_retargetCheckInterval", new Vector2(0f, 2f), (AcceptableValueBase)null);
		_retargetCurrentToNearestRatio = ((AMod)this).CreateSetting<float>("_retargetCurrentToNearestRatio", 1.5f, (AcceptableValueBase)(object)((AMod)this).FloatRange(1f, 2f));
		_retargetDetectAllPlayers = ((AMod)this).CreateSetting<bool>("_retargetDetectAllPlayers", true, (AcceptableValueBase)null);
	}

	protected override void LoadPreset(string presetName)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_enemyDetectionModifier.Value = 33;
			_preventInfighting.Value = (FactionGroup)(-1);
			_retargetOnHit.Value = 0;
			_walkTowardsPlayerOnSpawn.Value = 0;
			_retargetWhenTooFar.Value = true;
			_retargetCheckInterval.Value = new Vector2(0f, 2f);
			_retargetCurrentToNearestRatio.Value = 1.2f;
			_retargetDetectAllPlayers.Value = true;
		}
	}

	protected override void SetFormatting()
	{
		((AModSetting)_enemyDetectionModifier).Format("Enemy detection modifier");
		((AModSetting)_enemyDetectionModifier).Description = "How good the enemies are at detecting you\nat +100% enemies will detect you from twice the original distance, and in a 90 degrees cone\nat -50% all enemies' detectionranges and angles will be halved\nat -100% enemies will be effectively blind and deaf\n\nUnit: arbitrary linear scale";
		((AModSetting)_preventInfighting).Format("Prevent infighting between...");
		((AModSetting)_preventInfighting).Description = $"{FactionGroup.HumansAndNonHostileMonsters}:" + "\nmost humans (eg. bandits) and non-hostile monsters (eg. pearlbirds, deers) will ignore each other" + $"\n\n{FactionGroup.HostileMonsters}:" + "\nmost hostile monsters (eg. mantises, hive lords, assassin bugs) will ignore each other";
		((AModSetting)_walkTowardsPlayerOnSpawn).Format("Chance to approach player on spawn");
		((AModSetting)_walkTowardsPlayerOnSpawn).Description = "How likely enemies are to walk towards the nearest player when they spawn\n\nUnit: percent chance";
		((AModSetting)_retargetOnHit).Format("Chance to retarget on hit");
		((AModSetting)_retargetOnHit).Description = "How likely enemies are to start targeting the attacker when attacked\n\nUnit: percent chance";
		((AModSetting)_retargetWhenTooFar).Format("Retarget when too far");
		((AModSetting)_retargetWhenTooFar).Description = "Allows enemies to change their current target when it's too far away\nOnly detected characters and actual attackers are taken into account";
		using (AMod.Indent)
		{
			((AModSetting)_retargetCurrentToNearestRatio).Format("Current-to-nearest ratio", _retargetWhenTooFar);
			((AModSetting)_retargetCurrentToNearestRatio).Description = "How far away enemies have to be from their current target to switch to a closer one\nEnemies will switch only if their current target is this many times further away then the closest one\n\nUnit: ratio between distance to the current target and to the closest valid target";
			((AModSetting)_retargetCheckInterval).Format("Check interval", _retargetWhenTooFar);
			((AModSetting)_retargetCheckInterval).Description = "How often enemies will attempt to switch to a closer target\nEach interval is a random value between x and y\n\nUnit: seconds";
			((AModSetting)_retargetDetectAllPlayers).Format("Detect all players", _retargetWhenTooFar);
			((AModSetting)_retargetDetectAllPlayers).Description = "Allows enemies to detect all players when they detect any";
		}
	}

	public static void TryRetarget(CharacterAI ai)
	{
		//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_004b: 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)
		Character character = ((CharacterControl)ai).Character;
		List<Pair<UID, float>> lastDealers = character.m_lastDealers;
		if (lastDealers.Count <= 1)
		{
			return;
		}
		float num = Extensions_Component.DistanceTo((Component)(object)character, (Component)(object)character.TargetingSystem.LockedCharacter);
		float num2 = float.MaxValue;
		Character val = null;
		Character val2 = default(Character);
		foreach (Pair<UID, float> item in lastDealers)
		{
			if (Extensions.TryNonNull<Character>(CharacterManager.Instance.GetCharacter(UID.op_Implicit(item.Key)), ref val2))
			{
				float num3 = Extensions_Component.DistanceTo((Component)(object)character, (Component)(object)val2);
				if (num3 < num2)
				{
					num2 = num3;
					val = val2;
				}
			}
		}
		if (num / num2 >= ModSetting<float>.op_Implicit(_retargetCurrentToNearestRatio))
		{
			character.TargetingSystem.SwitchTarget(val.LockingPoint);
		}
	}

	public static IEnumerator TryRetargetCoroutine(CharacterAI ai)
	{
		while (!((CharacterControl)ai).Character.IsDead && !((CharacterControl)ai).Character.IsPetrified && !ai.CurrentAiState.IsNotAny<AISCombatMelee, AISCombatRanged>())
		{
			TryRetarget(ai);
			yield return (object)new WaitForSeconds(_retargetCheckInterval.Value.RandomRange());
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TargetingSystem), "InitTargetableFaction")]
	private static bool TargetingSystem_InitTargetableFaction_Pre(TargetingSystem __instance)
	{
		//IL_0014: 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_003d: 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_005a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		if (_preventInfighting.Value == (FactionGroup)0)
		{
			return true;
		}
		Factions faction = __instance.m_character.Faction;
		List<Factions> list = new List<Factions>();
		foreach (KeyValuePair<FactionGroup, Factions[]> item in FACTION_GROUPS_BY_ENUM)
		{
			if (!UnityEngineExtensions.Contains<Factions>(item.Value, faction))
			{
				continue;
			}
			Factions[] value = item.Value;
			foreach (Factions val in value)
			{
				if (val != faction)
				{
					Extensions_ICollections.TryAddUnique<Factions>((ICollection<Factions>)list, val);
				}
			}
		}
		List<Factions> list2 = new List<Factions>();
		foreach (Factions faction2 in Utils.Factions)
		{
			if (!Extensions.IsContainedIn<Factions>(faction2, (ICollection<Factions>)list) && !Extensions.IsContainedIn<Factions>(faction2, (ICollection<Factions>)__instance.StartAlliedFactions) && (!__instance.AlliedToSameFaction || faction2 != faction))
			{
				list2.Add(faction2);
			}
		}
		__instance.TargetableFactions = list2.ToArray();
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(AIPreset), "ApplyToCharAI")]
	private static void AIPreset_ApplyToCharAI_Post(AIPreset __instance, CharacterAI _charAI)
	{
		if (ModSetting<int>.op_Implicit(_enemyDetectionModifier) != 0)
		{
			float num = 1f + (float)ModSetting<int>.op_Implicit(_enemyDetectionModifier) / 100f;
			AICEnemyDetection[] componentsInChildren = ((Component)_charAI).GetComponentsInChildren<AICEnemyDetection>(true);
			foreach (AICEnemyDetection val in componentsInChildren)
			{
				val.GoodViewAngle = Utils.Lerp3(0f, val.GoodViewAngle, 90f, num / 2f);
				val.ViewAngle = Utils.Lerp3(0f, val.ViewAngle, 180f, num / 2f);
				val.ViewRange *= num;
				val.LowViewRange *= num;
				val.HearingDetectRange *= num;
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(AISquadSpawnPoint), "SpawnSquad")]
	private static void AISquadSpawnPoint_SpawnSquad_Pre(AISquadSpawnPoint __instance)
	{
		__instance.ChanceToWanderTowardsPlayers = ModSetting<int>.op_Implicit(_walkTowardsPlayerOnSpawn);
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(AICEnemyDetection), "Init")]
	private static void AICEnemyDetection_Init_Pre(AICEnemyDetection __instance)
	{
		__instance.ChanceToSwitchTargetOnHurt = ModSetting<int>.op_Implicit(_retargetOnHit);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CharacterAI), "SwitchAiState")]
	private static void CharacterAI_SwitchAiState_Post(CharacterAI __instance)
	{
		if (ModSetting<bool>.op_Implicit(_retargetWhenTooFar))
		{
			AIState t = __instance.AiStates[__instance.m_previousStateID];
			AIState t2 = __instance.AiStates[__instance.m_currentStateID];
			if (t.IsNotAny<AISCombatMelee, AISCombatRanged>() && t2.IsAny<AISCombatMelee, AISCombatRanged>())
			{
				((MonoBehaviour)__instance).StartCoroutine(TryRetargetCoroutine(__instance));
			}
			else if (t.IsAny<AISCombatMelee, AISCombatRanged>() && t2.IsNotAny<AISCombatMelee, AISCombatRanged>())
			{
				((CharacterControl)__instance).Character.m_lastDealers.Clear();
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(AICEnemyDetection), "Detected")]
	private static void AICEnemyDetection_Detected_Post(AICEnemyDetection __instance, LockingPoint _point)
	{
		//IL_002a: 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)
		Character val = default(Character);
		if (!ModSetting<bool>.op_Implicit(_retargetWhenTooFar) || !Extensions.TryNonNull<Character>(_point.OwnerChar, ref val))
		{
			return;
		}
		Character character = ((CharacterControl)((AICondition)__instance).m_characterAI).Character;
		character.AddLastDealer(val.UID);
		if (!ModSetting<bool>.op_Implicit(_retargetDetectAllPlayers) || !val.IsPlayer())
		{
			return;
		}
		foreach (Players.Data item in Players.Local)
		{
			character.AddLastDealer(item.Character.UID);
		}
	}

	static AI()
	{
		Dictionary<FactionGroup, Factions[]> dictionary = new Dictionary<FactionGroup, Factions[]> { [FactionGroup.HumansAndNonHostileMonsters] = (Factions[])(object)new Factions[2]
		{
			(Factions)2,
			(Factions)5
		} };
		Factions[] array = new Factions[6];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary[FactionGroup.HostileMonsters] = (Factions[])(object)array;
		FACTION_GROUPS_BY_ENUM = dictionary;
	}
}
public class Stashes : AMod, IUpdatable
{
	private enum StashType
	{
		PlayerBound,
		CityBound
	}

	private static readonly Dictionary<AreaEnum, (string UID, Vector3[] Positions)> STASH_DATA_BY_CITY = new Dictionary<AreaEnum, (string, Vector3[])>
	{
		[(AreaEnum)100] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-367.85f, -1488.25f, 596.277f),
			new Vector3(-373.539f, -1488.25f, 583.187f)
		}),
		[(AreaEnum)500] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-386.62f, -1493.132f, 773.86f),
			new Vector3(-372.41f, -1493.132f, 773.86f)
		}),
		[(AreaEnum)200] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[1]
		{
			new Vector3(-371.628f, -1493.41f, 569.91f)
		}),
		[(AreaEnum)300] = ("ZbPXNsPvlUeQVJRks3zBzg", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(-369.28f, -1502.535f, 592.85f),
			new Vector3(-380.53f, -1502.535f, 593.08f)
		}),
		[(AreaEnum)400] = ("ImqRiGAT80aE2WtUHfdcMw", (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-178.672f, -1515.915f, 597.934f),
			new Vector3(-182.373f, -1515.915f, 606.291f),
			new Vector3(-383.484f, -1504.82f, 583.343f),
			new Vector3(-392.681f, -1504.82f, 586.551f)
		}),
		[(AreaEnum)601] = ("IqUugGqBBkaOcQdRmhnMng", (Vector3[])(object)new Vector3[0])
	};

	private static ModSetting<bool> _innStashes;

	private static ModSetting<StashType> _stashType;

	private static ModSetting<string> _openStashKey;

	private static ModSetting<bool> _playerSharedStash;

	private static ModSetting<bool> _craftFromStash;

	private static ModSetting<bool> _craftFromStashOutside;

	private static ModSetting<bool> _stashesStartEmpty;

	private static ItemContainer _cachedStash;

	protected override string SectionOverride => "   \nSURVIVAL & IMMERSION";

	protected override string Description => "";

	protected override void Initialize()
	{
		_innStashes = ((AMod)this).CreateSetting<bool>("_innStashes", false, (AcceptableValueBase)null);
		_stashType = ((AMod)this).CreateSetting<StashType>("_stashType", StashType.PlayerBound, (AcceptableValueBase)null);
		_openStashKey = ((AMod)this).CreateSetting<string>("_openStashKey", "", (AcceptableValueBase)null);
		_playerSharedStash = ((AMod)this).CreateSetting<bool>("_playerSharedStash", false, (AcceptableValueBase)null);
		_craftFromStash = ((AMod)this).CreateSetting<bool>("_craftFromStash", false, (AcceptableValueBase)null);
		_craftFromStashOutside = ((AMod)this).CreateSetting<bool>("_craftFromStashOutside", false, (AcceptableValueBase)null);
		_stashesStartEmpty = ((AMod)this).CreateSetting<bool>("_stashesStartEmpty", false, (AcceptableValueBase)null);
	}

	protected override void SetFormatting()
	{
		((AModSetting)_innStashes).Format("Inn stashes");
		((AModSetting)_innStashes).Description = "Each inn room will have a player stash, linked with the one in player's house\n(exceptions: the first rooms in Monsoon's inn and Harmattan's Victorious Light inn)";
		((AModSetting)_stashType).Format("Stash type");
		((AModSetting)_stashType).Description = "What is actually displayed in the text pop-up\n" + $"\n• {StashType.PlayerBound} - one global stash, no matter which city you're in" + $"\n• {StashType.CityBound} - pre-DE behaviour: each city has its own stash";
		using (AMod.Indent)
		{
			((AModSetting)_openStashKey).Format<StashType>("open hotkey", _stashType, StashType.PlayerBound, true);
			((AModSetting)_openStashKey).Description = "Allows you to open your stash anywhere - even outside cities\nUse UnityEngine.KeyCode enum values\n(https://docs.unity3d.com/ScriptReference/KeyCode.html)";
			((AModSetting)_playerSharedStash).Format<StashType>("player-shared", _stashType, StashType.PlayerBound, true);
			((AModSetting)_playerSharedStash).Description = "pre-DE behaviour: all players will access the first player's stash";
		}
		((AModSetting)_craftFromStash).Format("Craft with stashed items");
		((AModSetting)_craftFromStash).Description = "When you're crafting in a city, you can use items from you stash";
		using (AMod.Indent)
		{
			((AModSetting)_craftFromStashOutside).Format<StashType>("outside of cities", _stashType, StashType.PlayerBound, true);
			((AModSetting)_craftFromStashOutside).Description = "Allows you to craft from stash anywhere - even outside cities";
		}
		((AModSetting)_stashesStartEmpty).Format("Stashes start empty");
		((AModSetting)_stashesStartEmpty).Description = "Stashes won't have any items inside the first time you open them";
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_innStashes.Value = true;
			_stashType.Value = StashType.CityBound;
			_craftFromStash.Value = true;
			_stashesStartEmpty.Value = true;
		}
	}

	public void OnUpdate()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		if (Extensions.Pressed(_openStashKey.Value.ToKeyCode()) && Players.TryGetFirst(out var player) && TryGetStash(player.Character, out var stash))
		{
			player.Character.CharacterUI.StashPanel.SetStash(stash);
			stash.ShowContent(player.Character);
		}
	}

	private static bool IsInCity()
	{
		Area val = default(Area);
		if (Extensions.TryNonNull<Area>(AreaManager.Instance.CurrentArea, ref val))
		{
			return STASH_DATA_BY_CITY.ContainsKey((AreaEnum)val.ID);
		}
		return false;
	}

	public static bool TryGetStash(Character character, out ItemContainer stash)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		if (ModSetting<StashType>.op_Implicit(_stashType) == StashType.CityBound)
		{
			Area val = default(Area);
			if ((Object)(object)_cachedStash == (Object)null && Extensions.TryNonNull<Area>(AreaManager.Instance.CurrentArea, ref val) && STASH_DATA_BY_CITY.TryGetValue((AreaEnum)val.ID, out (string, Vector3[]) value))
			{
				_cachedStash = (ItemContainer)(TreasureChest)ItemManager.Instance.GetItem(value.Item1);
			}
			stash = _cachedStash;
		}
		else
		{
			if (ModSetting<bool>.op_Implicit(_playerSharedStash))
			{
				character = Players.GetFirst().Character;
			}
			stash = (((Object)(object)character != (Object)null) ? character.Inventory.Stash : null);
		}
		return (Object)(object)stash != (Object)null;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(NetworkLevelLoader), "UnPauseGameplay")]
	private static void NetworkLevelLoader_UnPauseGameplay_Post(NetworkLevelLoader __instance)
	{
		_cachedStash = null;
	}

	[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(typeof(ItemContainer), "ShowContent")]
	public static void ItemContainer_ShowContent(ItemContainer instance, Character _character)
	{
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TreasureChest), "ShowContent")]
	private static bool TreasureChest_ShowContent_Pre(TreasureChest __instance, Character _character)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		if ((int)((ItemContainer)__instance).SpecialType == 4 && TryGetStash(_character, out var stash))
		{
			if (!ModSetting<bool>.op_Implicit(_stashesStartEmpty) && Extensions_ICollections.TryAddUnique<string>((ICollection<string>)__instance.m_playerReceivedUIDs, UID.op_Implicit(_character.UID)))
			{
				for (int i = 0; i < ((SelfFilledItemContainer)__instance).m_drops.Count; i++)
				{
					if (Object.op_Implicit((Object)(object)((SelfFilledItemContainer)__instance).m_drops[i]))
					{
						((SelfFilledItemContainer)__instance).m_drops[i].GenerateContents(stash);
					}
				}
			}
			_character.CharacterUI.StashPanel.SetStash(stash);
		}
		ItemContainer_ShowContent((ItemContainer)(object)__instance, _character);
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(TreasureChest), "InitDrops")]
	private static void TreasureChest_InitDrops_Post(TreasureChest __instance)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Invalid comparison between Unknown and I4
		if (ModSetting<bool>.op_Implicit(_stashesStartEmpty) && (int)((ItemContainer)__instance).SpecialType == 4)
		{
			__instance.m_hasGeneratedContent = true;
			__instance.m_ignoreHasGeneratedContent = false;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(NetworkLevelLoader), "UnPauseGameplay")]
	private static void NetworkLevelLoader_UnPauseGameplay_Post(NetworkLevelLoader __instance, string _identifier)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_007c: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		Area val = default(Area);
		if (ModSetting<bool>.op_Implicit(_innStashes) && !(_identifier != "Loading") && Extensions.TryNonNull<Area>(AreaManager.Instance.CurrentArea, ref val) && STASH_DATA_BY_CITY.TryGetValue((AreaEnum)val.ID, out (string, Vector3[]) value) && value.Item2.Length != 0)
		{
			TreasureChest val2 = (TreasureChest)ItemManager.Instance.GetItem(value.Item1);
			Extensions_Component.Activate((Component)(object)val2);
			int num = 0;
			Vector3[] item = value.Item2;
			foreach (Vector3 position in item)
			{
				Transform val3 = Object.Instantiate<Transform>(((Item)val2).InteractionHolder.transform);
				((Object)val3).name = $"InnStash{num} - Interaction";
				Extensions_Component.ResetLocalTransform((Component)(object)val3);
				val3.position = position;
				InteractionActivator firstComponentsInHierarchy = val3.GetFirstComponentsInHierarchy<InteractionActivator>();
				((EventActivator)firstComponentsInHierarchy).UID = UID.op_Implicit(UID.op_Implicit(((EventActivator)firstComponentsInHierarchy).UID) + $"_InnStash{num}");
				InteractionOpenChest firstComponentsInHierarchy2 = val3.GetFirstComponentsInHierarchy<InteractionOpenChest>();
				((InteractionOpenContainer)firstComponentsInHierarchy2).m_container = (ItemContainer)(object)val2;
				((ItemInteraction)firstComponentsInHierarchy2).m_item = (Item)(object)val2;
				((InteractionBase)firstComponentsInHierarchy2).StartInit();
				Transform obj = Object.Instantiate<Transform>(((Item)val2).CurrentVisual.ItemHighlightTrans);
				((Object)obj).name = $"InnStash{num} - Highlight";
				Extensions_Component.ResetLocalTransform((Component)(object)obj);
				Extensions_Component.BecomeChildOf((Component)(object)obj, (Component)(object)val3, false);
				((Behaviour)obj.GetFirstComponentsInHierarchy<InteractionHighlight>()).enabled = true;
				num++;
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(InteractionOpenChest), "OnActivate")]
	private static void InteractionOpenChest_OnActivate_Pre(InteractionOpenChest __instance)
	{
		TreasureChest val = default(TreasureChest);
		if (ModSetting<bool>.op_Implicit(_innStashes) && Extensions.TryNonNull<TreasureChest>(__instance.m_chest, ref val))
		{
			Extensions_Component.Activate((Component)(object)val);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void CharacterInventory_InventoryIngredients_Post(CharacterInventory __instance, Tag _craftingStationTag, ref DictionaryExt<int, CompatibleIngredient> _sortedIngredient)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (ModSetting<bool>.op_Implicit(_craftFromStash) && TryGetStash(__instance.m_character, out var stash) && (ModSetting<bool>.op_Implicit(_craftFromStashOutside) || IsInCity()))
		{
			__instance.InventoryIngredients(_craftingStationTag, ref _sortedIngredient, (IList<Item>)stash.GetContainedItems());
		}
	}

	bool IUpdatable.get_IsEnabled()
	{
		return ((AMod)this).IsEnabled;
	}
}
public class WIP : AMod
{
	private static ModSetting<Vector2> _temperatureMultiplier;

	private static ModSetting<bool> _allowPushKickRemoval;

	private static ModSetting<bool> _allowTargetingPlayers;

	protected override string SectionOverride => "    \nDEVELOPMENT";

	protected override void Initialize()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		_temperatureMultiplier = ((AMod)this).CreateSetting<Vector2>("_temperatureMultiplier", Extensions_float.ToVector2(1f), (AcceptableValueBase)null);
		_allowPushKickRemoval = ((AMod)this).CreateSetting<bool>("_allowPushKickRemoval", false, (AcceptableValueBase)null);
		_allowTargetingPlayers = ((AMod)this).CreateSetting<bool>("_allowTargetingPlayers", false, (AcceptableValueBase)null);
	}

	protected override void SetFormatting()
	{
		((AModSetting)_temperatureMultiplier).Format("Temperature multiplier");
		((AModSetting)_temperatureMultiplier).Description = "How strongly the environment temperature affects you when your temperature is:\nX   -   neutral\nY   -   approaching either extreme\n(set X and Y to the same value for a flat, linear multiplier)";
		((AModSetting)_allowPushKickRemoval).Format("Allow \"Push Kick\" removal");
		((AModSetting)_allowPushKickRemoval).Description = "For future skill trees mod\nNormally, player data won't be saved if they don't have the \"Push Kick\" skill";
		((AModSetting)_allowTargetingPlayers).Format("Allow targeting players");
		((AModSetting)_allowTargetingPlayers).Description = "For future co-op skills mod";
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void CharacterStats_TemperatureModifier_Getter_Post(PlayerCharacterStats __instance, ref float __result)
	{
		//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)
		float num = Extensions_float.Div(Extensions_float.DistanceTo(__instance.Temperature, 50f), 50f);
		__result *= Extensions_float.Lerp(_temperatureMultiplier.Value.x, _temperatureMultiplier.Value.y, num);
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static bool CharacterSave_IsValid_Getter_Pre(ref bool __result)
	{
		if (!_allowPushKickRemoval.Value)
		{
			return true;
		}
		__result = true;
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TargetingSystem), "IsTargetable", new Type[] { typeof(Character) })]
	private static bool TargetingSystem_IsTargetable_Pre(TargetingSystem __instance, ref bool __result, ref Character _char)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Invalid comparison between Unknown and I4
		if (!ModSetting<bool>.op_Implicit(_allowTargetingPlayers))
		{
			return true;
		}
		if ((int)_char.Faction == 1 && (Object)(object)_char != (Object)(object)__instance.m_character)
		{
			__result = true;
			return false;
		}
		return true;
	}
}
public class Durability : AMod
{
	private enum MultiRepairBehaviour
	{
		UseFixedValueForAllItems = 1,
		DivideValueAmongItems,
		TryToEqualizeValues,
		TryToEqualizeRatios
	}

	private enum RepairPercentReference
	{
		OfMaxDurability = 1,
		OfMissingDurability
	}

	private enum EffectivnessStats
	{
		None = 0,
		AttackSpeed = 2,
		ImpactDamage = 4,
		Barrier = 8,
		ImpactResistance = 0x10
	}

	private const int FAST_MAINTENANCE_ID = 8205140;

	private static ModSetting<bool> _lossMultipliers;

	private static ModSetting<int> _lossWeapons;

	private static ModSetting<int> _lossArmors;

	private static ModSetting<int> _lossLights;

	private static ModSetting<int> _lossIngestibles;

	private static ModSetting<bool> _campingRepairToggle;

	private static ModSetting<int> _repairDurabilityPerHour;

	private static ModSetting<int> _repairDurabilityPercentPerHour;

	private static ModSetting<RepairPercentReference> _repairPercentReference;

	private static ModSetting<MultiRepairBehaviour> _multiRepairBehaviour;

	private static ModSetting<int> _fastMaintenanceMultiplier;

	private static ModSetting<bool> _effectivenessAffectsAllStats;

	private static ModSetting<bool> _effectivenessAffectsPenalties;

	private static ModSetting<bool> _linearEffectiveness;

	private static ModSetting<int> _minNonBrokenEffectiveness;

	private static ModSetting<int> _brokenEffectiveness;

	private static ModSetting<bool> _smithRepairsOnlyEquipped;

	private static ModSetting<int> _minStartingDurability;

	protected override string Description => "• Change how quickly durability decreases per item type\n• Tweak camping repair mechanics\n• Change how durability affects equipment stats\n• Randomize starting durability of spawned items";

	protected override string SectionOverride => "   \nSURVIVAL & IMMERSION";

	protected override void Initialize()
	{
		_lossMultipliers = ((AMod)this).CreateSetting<bool>("_lossMultipliers", false, (AcceptableValueBase)null);
		_lossWeapons = ((AMod)this).CreateSetting<int>("_lossWeapons", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 200));
		_lossArmors = ((AMod)this).CreateSetting<int>("_lossArmors", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 200));
		_lossLights = ((AMod)this).CreateSetting<int>("_lossLights", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 200));
		_lossIngestibles = ((AMod)this).CreateSetting<int>("_lossIngestibles", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 200));
		_campingRepairToggle = ((AMod)this).CreateSetting<bool>("_campingRepairToggle", false, (AcceptableValueBase)null);
		_repairDurabilityPerHour = ((AMod)this).CreateSetting<int>("_repairDurabilityPerHour", 0, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_repairDurabilityPercentPerHour = ((AMod)this).CreateSetting<int>("_repairDurabilityPercentPerHour", 10, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_repairPercentReference = ((AMod)this).CreateSetting<RepairPercentReference>("_repairPercentReference", RepairPercentReference.OfMaxDurability, (AcceptableValueBase)null);
		_multiRepairBehaviour = ((AMod)this).CreateSetting<MultiRepairBehaviour>("_multiRepairBehaviour", MultiRepairBehaviour.UseFixedValueForAllItems, (AcceptableValueBase)null);
		_fastMaintenanceMultiplier = ((AMod)this).CreateSetting<int>("_fastMaintenanceMultiplier", 150, (AcceptableValueBase)(object)((AMod)this).IntRange(100, 200));
		_effectivenessAffectsAllStats = ((AMod)this).CreateSetting<bool>("_effectivenessAffectsAllStats", false, (AcceptableValueBase)null);
		_effectivenessAffectsPenalties = ((AMod)this).CreateSetting<bool>("_effectivenessAffectsPenalties", false, (AcceptableValueBase)null);
		_linearEffectiveness = ((AMod)this).CreateSetting<bool>("_linearEffectiveness", false, (AcceptableValueBase)null);
		_minNonBrokenEffectiveness = ((AMod)this).CreateSetting<int>("_minNonBrokenEffectiveness", 50, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_brokenEffectiveness = ((AMod)this).CreateSetting<int>("_brokenEffectiveness", 15, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_smithRepairsOnlyEquipped = ((AMod)this).CreateSetting<bool>("_smithRepairsOnlyEquipped", false, (AcceptableValueBase)null);
		_minStartingDurability = ((AMod)this).CreateSetting<int>("_minStartingDurability", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
	}

	protected override void SetFormatting()
	{
		((AModSetting)_lossMultipliers).Format("Durability loss multipliers");
		using (AMod.Indent)
		{
			((AModSetting)_lossWeapons).Format("Weapons", _lossMultipliers);
			((AModSetting)_lossWeapons).Description = "Includes shields";
			((AModSetting)_lossArmors).Format("Armors", _lossMultipliers);
			((AModSetting)_lossLights).Format("Lights", _lossMultipliers);
			((AModSetting)_lossLights).Description = "Torches and lanterns";
			((AModSetting)_lossIngestibles).Format("Food", _lossMultipliers);
		}
		((AModSetting)_campingRepairToggle).Format("Camping repair");
		using (AMod.Indent)
		{
			((AModSetting)_repairDurabilityPerHour).Format("Durability per hour", _campingRepairToggle);
			((AModSetting)_repairDurabilityPercentPerHour).Format("Durability % per hour", _campingRepairToggle);
			((AModSetting)_repairDurabilityPercentPerHour).Description = "By default, % of max durability (can be changed below)";
			((AModSetting)_repairPercentReference).Format<int>("", _repairDurabilityPercentPerHour, (Func<int, bool>)((int t) => t > 0));
			((AModSetting)_fastMaintenanceMultiplier).Format("\"Fast Maintenance\" repair multiplier", _campingRepairToggle);
			((AModSetting)_multiRepairBehaviour).Format("When repairing multiple items", _campingRepairToggle);
			((AModSetting)_multiRepairBehaviour).Description = "Use fixed value for all items   -   the same repair value will be used for all items\nDivide value among items   -   the repair value will be divided by the number of equipped items\nTry to equalize values   -   repair item with the lowest durabilty value\nTry to equalize ratios   -   repair item with the lowest durabilty ratio";
		}
		((AModSetting)_effectivenessAffectsAllStats).Format("Durability affects all stats");
		((AModSetting)_effectivenessAffectsAllStats).Description = "Normally, durability affects only damages, resistances (impact only for shields) and protection\nThis will make all* equipment stats decrease with durability\n( * currently all except damage bonuses)";
		using (AMod.Indent)
		{
			((AModSetting)_effectivenessAffectsPenalties).Format("affect penalties", _effectivenessAffectsAllStats);
			((AModSetting)_effectivenessAffectsPenalties).Description = "Stat penalties (like negative movement speed on heavy armors) will also decrease with durability";
		}
		((AModSetting)_linearEffectiveness).Format("Smooth durability effects");
		((AModSetting)_linearEffectiveness).Description = "Normally, equipment stats change only when durability reaches certain thresholds (50%, 25% and 0%)\nThis will update the stats smoothly, without any thersholds";
		using (AMod.Indent)
		{
			((AModSetting)_minNonBrokenEffectiveness).Format("when nearing zero durability", _linearEffectiveness);
			((AModSetting)_brokenEffectiveness).Format("when broken", _linearEffectiveness);
		}
		((AModSetting)_smithRepairsOnlyEquipped).Format("Smith repairs only equipped items");
		((AModSetting)_smithRepairsOnlyEquipped).Description = "Blacksmith will not repair items in your pouch and bag";
		((AModSetting)_minStartingDurability).Format("Minimum starting durability");
		((AModSetting)_minStartingDurability).Description = "When items are spawned, their durability is randomized between this value and 100%\nOnly affects dynamically spawned item (containers, enemy corpses, merchant stock)\nScene-static and serialized items are unaffected";
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_lossMultipliers.Value = true;
			_lossWeapons.Value = 50;
			_lossArmors.Value = 50;
			_lossLights.Value = 150;
			_lossIngestibles.Value = 100;
			_campingRepairToggle.Value = true;
			_repairDurabilityPerHour.Value = 0;
			_repairDurabilityPercentPerHour.Value = 0;
			_repairPercentReference.Value = RepairPercentReference.OfMaxDurability;
			_multiRepairBehaviour.Value = MultiRepairBehaviour.UseFixedValueForAllItems;
			_effectivenessAffectsAllStats.Value = true;
			_effectivenessAffectsPenalties.Value = true;
			_linearEffectiveness.Value = true;
			_minNonBrokenEffectiveness.Value = 50;
			_brokenEffectiveness.Value = 25;
			_smithRepairsOnlyEquipped.Value = true;
			_minStartingDurability.Value = 67;
		}
	}

	private static float CalculateDurabilityGain(Item item, float flat, float percent)
	{
		float num = ((ModSetting<RepairPercentReference>.op_Implicit(_repairPercentReference) == RepairPercentReference.OfMissingDurability) ? ((float)item.MaxDurability - item.m_currentDurability) : ((float)item.MaxDurability));
		return flat + percent * num;
	}

	private static bool HasLearnedFastMaintenance(Character character)
	{
		return ((CharacterKnowledge)character.Inventory.SkillKnowledge).IsItemLearned(8205140);
	}

	private static void TryApplyEffectiveness(ref float stat, EquipmentStats equipmentStats, bool invertedPositivity = false)
	{
		if (ModSetting<bool>.op_Implicit(_effectivenessAffectsAllStats) && (((!(stat < 0f) || invertedPositivity) && !(stat > 0f && invertedPositivity)) || ModSetting<bool>.op_Implicit(_effectivenessAffectsPenalties)))
		{
			stat *= ((ItemStats)equipmentStats).Effectiveness;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Item), "ReduceDurability")]
	private static void Item_ReduceDurability_Pre(Item __instance, ref float _durabilityLost)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (ModSetting<bool>.op_Implicit(_lossMultipliers))
		{
			int num = 100;
			if (__instance is Weapon)
			{
				num = ModSetting<int>.op_Implicit(_lossWeapons);
			}
			else if (__instance is Armor)
			{
				num = ModSetting<int>.op_Implicit(_lossArmors);
			}
			else if ((int)__instance.LitStatus != 0)
			{
				num = ModSetting<int>.op_Implicit(_lossLights);
			}
			else if (__instance.IsIngestible())
			{
				num = ModSetting<int>.op_Implicit(_lossIngestibles);
			}
			_durabilityLost *= (float)num / 100f;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(CharacterEquipment), "RepairEquipmentAfterRest")]
	private static bool CharacterEquipment_RepairEquipmentAfterRest_Pre(CharacterEquipment __instance)
	{
		if (!ModSetting<bool>.op_Implicit(_campingRepairToggle))
		{
			return false;
		}
		List<Equipment> list = new List<Equipment>();
		EquipmentSlot[] equipmentSlots = __instance.m_equipmentSlots;
		foreach (EquipmentSlot val in equipmentSlots)
		{
			if (val.IsAnythingEquipped() && !val.IsLeftHandUsedBy2H() && ((Item)val.EquippedItem).RepairedInRest && !((Item)val.EquippedItem).IsIndestructible && ((Item)val.EquippedItem).DurabilityRatio < 1f)
			{
				list.Add(val.EquippedItem);
			}
		}
		if (Extensions_ICollections.IsNullOrEmpty<Equipment>((ICollection<Equipment>)list))
		{
			return false;
		}
		float num = ModSetting<int>.op_Implicit(_repairDurabilityPerHour);
		float num2 = (float)ModSetting<int>.op_Implicit(_repairDurabilityPercentPerHour) / 100f;
		if (HasLearnedFastMaintenance(__instance.m_character))
		{
			num *= (float)ModSetting<int>.op_Implicit(_fastMaintenanceMultiplier) / 100f;
			num2 *= (float)ModSetting<int>.op_Implicit(_fastMaintenanceMultiplier) / 100f;
		}
		if (ModSetting<MultiRepairBehaviour>.op_Implicit(_multiRepairBehaviour) == MultiRepairBehaviour.DivideValueAmongItems)
		{
			num /= (float)list.Count;
			num2 /= (float)list.Count;
		}
		for (int j = 0; (float)j < __instance.m_character.CharacterResting.GetRepairLength(); j++)
		{
			if (ModSetting<MultiRepairBehaviour>.op_Implicit(_multiRepairBehaviour) == MultiRepairBehaviour.TryToEqualizeValues || ModSetting<MultiRepairBehaviour>.op_Implicit(_multiRepairBehaviour) == MultiRepairBehaviour.TryToEqualizeRatios)
			{
				bool equalizeValues = ModSetting<MultiRepairBehaviour>.op_Implicit(_multiRepairBehaviour) == MultiRepairBehaviour.TryToEqualizeValues;
				float minTest = list.Min((Equipment item) => (!equalizeValues) ? ((Item)item).DurabilityRatio : ((Item)item).m_currentDurability);
				Item val2 = (Item)(object)list.Find((Equipment item) => (equalizeValues ? ((Item)item).m_currentDurability : ((Item)item).DurabilityRatio) == minTest);
				val2.m_currentDurability += CalculateDurabilityGain(val2, num, num2);
				continue;
			}
			foreach (Equipment item in list)
			{
				((Item)item).m_currentDurability = ((Item)item).m_currentDurability + CalculateDurabilityGain((Item)(object)item, num, num2);
			}
		}
		foreach (Equipment item2 in list)
		{
			if (((Item)item2).DurabilityRatio > 1f)
			{
				((Item)item2).SetDurabilityRatio(1f);
			}
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ItemContainer), "RepairContainedEquipment")]
	private static bool ItemContainer_RepairContainedEquipment_Pre(ItemContainer __instance)
	{
		return !ModSetting<bool>.op_Implicit(_smithRepairsOnlyEquipped);
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static bool ItemStats_Effectiveness_Pre(ItemStats __instance, ref float __result)
	{
		if (!ModSetting<bool>.op_Implicit(_linearEffectiveness) || __instance.m_item.IsNot<Equipment>())
		{
			return true;
		}
		float durabilityRatio = __instance.m_item.DurabilityRatio;
		__result = ((durabilityRatio > 0f) ? Extensions_float.MapFrom01(__instance.m_item.DurabilityRatio, (float)ModSetting<int>.op_Implicit(_minNonBrokenEffectiveness) / 100f, 1f) : ((float)ModSetting<int>.op_Implicit(_brokenEffectiveness) / 100f));
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ItemDropper), "GenerateItem")]
	private static void ItemDropper_GenerateItem_Pre(ItemDropper __instance, ref Item __state, ItemContainer _container, BasicItemDrop _itemDrop, int _spawnAmount)
	{
		Item item = default(Item);
		Item val = default(Item);
		ItemStats val2 = default(ItemStats);
		if (ModSetting<int>.op_Implicit(_minStartingDurability) < 100 && Extensions.TryNonNull<Item>(_itemDrop.DroppedItem, ref item) && Extensions.TryNonNull<Item>(item.Prefab<Item>(), ref val) && Extensions.TryNonNull<ItemStats>(val.Stats, ref val2) && val2.MaxDurability > 0)
		{
			val2.StartingDurability = Extensions_float.Round((float)val.MaxDurability * RNG.Range((float)ModSetting<int>.op_Implicit(_minStartingDurability) / 100f, 1f));
			__state = val;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ItemDropper), "GenerateItem")]
	private static void ItemDropper_GenerateItem_Post(ItemDropper __instance, ref Item __state)
	{
		if (!((Object)(object)__state == (Object)null))
		{
			__state.Stats.StartingDurability = -1;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ItemDetailsDisplay), "GetPenaltyDisplay")]
	private static bool ItemDetailsDisplay_GetPenaltyDisplay_Pre(ItemDetailsDisplay __instance, ref string __result, float _value, bool _negativeIsPositive, bool _showPercent)
	{
		//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_0066: 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)
		if (!ModSetting<bool>.op_Implicit(_effectivenessAffectsAllStats))
		{
			return true;
		}
		string text = Extensions_float.Round(_value).ToString();
		if (_value > 0f)
		{
			text = "+" + text;
		}
		if (_showPercent)
		{
			text += "%";
		}
		Color val = Global.LIGHT_GREEN;
		if ((_value < 0f && !_negativeIsPositive) || (_value > 0f && _negativeIsPositive))
		{
			val = Global.LIGHT_RED;
		}
		__result = Global.SetTextColor(text, val);
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ItemDetailRowDisplay), "SetInfo", new Type[]
	{
		typeof(string),
		typeof(float)
	})]
	private static bool ItemDetailRowDisplay_SetInfo_Pre(ItemDetailRowDisplay __instance, string _dataName, float _dataValue)
	{
		if (!ModSetting<bool>.op_Implicit(_effectivenessAffectsAllStats))
		{
			return true;
		}
		__instance.SetInfo(_dataName, (float)Extensions_float.Round(_dataValue), false, (Sprite)null);
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void Weapon_BaseImpact_Post(Weapon __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, (EquipmentStats)(object)__instance.Stats);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void Weapon_BaseAttackSpeed_Post(Weapon __instance, ref float __result)
	{
		float stat = __result - 1f;
		TryApplyEffectiveness(ref stat, (EquipmentStats)(object)__instance.Stats);
		__result = stat + 1f;
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_BarrierProtection_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_ImpactResistance_Pre(EquipmentStats __instance)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Invalid comparison between Unknown and I4
		Weapon val = default(Weapon);
		__instance.m_impactResistEfficiencyAffected = ModSetting<bool>.op_Implicit(_effectivenessAffectsAllStats) || (Extensions.TryAs<Weapon>((object)((ItemStats)__instance).m_item, ref val) && (int)val.Type == 100);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_MovementPenalty_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance, invertedPositivity: true);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_StaminaUsePenalty_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance, invertedPositivity: true);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_ManaUseModifier_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance, invertedPositivity: true);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_HeatProtection_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_ColdProtection_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_CorruptionResistance_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_CooldownReduction_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance, invertedPositivity: true);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_HealthRegenBonus_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_ManaRegenBonus_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_StaminaCostReduction_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static void EquipmentStats_StaminaRegenModifier_Post(EquipmentStats __instance, ref float __result)
	{
		TryApplyEffectiveness(ref __result, __instance);
	}
}
public class Camping : AMod
{
	[Flags]
	private enum CampingSpots
	{
		None = 0,
		Cities = 2,
		OpenRegions = 4,
		Butterflies = 8,
		Dungeons = 0x10
	}

	[Flags]
	private enum CampingActivities
	{
		None = 0,
		Sleep = 2,
		Guard = 4,
		Repair = 8
	}

	private const string CANT_CAMP_NOTIFICATION = "You can't camp here!";

	private static ModSetting<CampingSpots> _campingSpots;

	private static ModSetting<int> _butterfliesSpawnChance;

	private static ModSetting<int> _butterfliesRadius;

	private static ModSetting<CampingActivities> _campingActivities;

	private static List<SphereCollider> _safeZoneColliders;

	protected override string Description => "• Restrict camping spots to chosen places\n• Change butterfly zones spawn chance and radius\n• Customize repairing mechanic";

	protected override string SectionOverride => "   \nSURVIVAL & IMMERSION";

	protected override void Initialize()
	{
		_campingSpots = ((AMod)this).CreateSetting<CampingSpots>("_campingSpots", (CampingSpots)(-1), (AcceptableValueBase)null);
		_butterfliesSpawnChance = ((AMod)this).CreateSetting<int>("_butterfliesSpawnChance", 100, (AcceptableValueBase)(object)((AMod)this).IntRange(0, 100));
		_butterfliesRadius = ((AMod)this).CreateSetting<int>("_butterfliesRadius", 25, (AcceptableValueBase)(object)((AMod)this).IntRange(5, 50));
		_campingActivities = ((AMod)this).CreateSetting<CampingActivities>("_campingActivities", (CampingActivities)(-1), (AcceptableValueBase)null);
		((AModSetting)_campingSpots).AddEvent((Action)delegate
		{
			if (_campingSpots.Value.HasFlag(CampingSpots.OpenRegions))
			{
				_campingSpots.SetSilently(_campingSpots.Value | CampingSpots.Butterflies);
			}
		});
		((AMod)this).AddEventOnConfigClosed((Action)SetButterfliesRadius);
		_safeZoneColliders = new List<SphereCollider>();
	}

	protected override void SetFormatting()
	{
		((AModSetting)_campingSpots).Format("Camping spots");
		((AModSetting)_campingSpots).Description = "Restrict where you can camp";
		((AModSetting)_butterfliesSpawnChance).Format("Butterflies spawn chance");
		((AModSetting)_butterfliesSpawnChance).Description = "Each butterfly zone in the area you're entering has X% to spawn\nAllows you to randomize safe zones for more unpredictability";
		((AModSetting)_butterfliesRadius).Format("Butterflies radius");
		((AModSetting)_butterfliesRadius).Description = "Vanilla radius is so big that it's possible to accidently set up a camp in a safe zone\n(minimum settings is still twice as big as the visuals)";
		((AModSetting)_campingActivities).Format("Available camping activities");
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_campingSpots.Value = CampingSpots.Dungeons;
			_butterfliesSpawnChance.Value = 100;
			_butterfliesRadius.Value = 10;
			_campingActivities.Value = CampingActivities.Sleep | CampingActivities.Repair;
		}
	}

	private static bool IsCampingAllowed(Character character, Vector3 position)
	{
		//IL_000f: 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_001d: 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)
		AreaEnum val = (AreaEnum)AreaManager.Instance.CurrentArea.ID;
		int num;
		if (!Extensions.IsContainedIn<AreaEnum>(val, (ICollection<AreaEnum>)Defaults.Cities))
		{
			if (!Extensions.IsContainedIn<AreaEnum>(val, (ICollection<AreaEnum>)Defaults.Regions))
			{
				num = (_campingSpots.Value.HasFlag(CampingSpots.Dungeons) ? 1 : 0);
			}
			else
			{
				if (_campingSpots.Value.HasFlag(CampingSpots.OpenRegions))
				{
					num = 1;
					goto IL_00ba;
				}
				if (!_campingSpots.Value.HasFlag(CampingSpots.Butterflies))
				{
					num = 0;
					goto IL_00aa;
				}
				num = (IsNearButterflies(position) ? 1 : 0);
			}
		}
		else
		{
			num = (_campingSpots.Value.HasFlag(CampingSpots.Cities) ? 1 : 0);
		}
		if (num == 0)
		{
			goto IL_00aa;
		}
		goto IL_00ba;
		IL_00aa:
		character.CharacterUI.ShowInfoNotification("You can't camp here!");
		goto IL_00ba;
		IL_00ba:
		return (byte)num != 0;
	}

	private static bool IsNearButterflies(Vector3 position)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		foreach (SphereCollider safeZoneCollider in _safeZoneColliders)
		{
			if (Extensions_Vector3.DistanceTo(position, ((Component)safeZoneCollider).transform.position) <= safeZoneCollider.radius)
			{
				return true;
			}
		}
		return false;
	}

	private static void SetButterfliesRadius()
	{
		foreach (SphereCollider safeZoneCollider in _safeZoneColliders)
		{
			if ((Object)(object)safeZoneCollider != (Object)null)
			{
				safeZoneCollider.radius = ModSetting<int>.op_Implicit(_butterfliesRadius);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(EnvironmentSave), "ApplyData")]
	private static void EnvironmentSave_ApplyData_Post(EnvironmentSave __instance)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		_safeZoneColliders.Clear();
		GameObject val = GameObject.Find("Environment/Assets/FX");
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		foreach (Transform item in val.transform)
		{
			Transform val2 = item;
			if (((Component)(object)val2).NameContains("butterfly"))
			{
				AmbienceSound componentInChildren = ((Component)val2).GetComponentInChildren<AmbienceSound>();
				if (Extensions.RollPercent(_butterfliesSpawnChance))
				{
					Extensions_Component.Activate((Component)(object)val2);
					((SoundPlayer)componentInChildren).MinVolume = (((SoundPlayer)componentInChildren).MaxVolume = 1f);
					_safeZoneColliders.Add(((Component)val2).GetComponent<SphereCollider>());
				}
				else
				{
					Extensions_Component.Deactivate((Component)(object)val2);
					((SoundPlayer)componentInChildren).MinVolume = (((SoundPlayer)componentInChildren).MaxVolume = 0f);
				}
			}
		}
		SetButterfliesRadius();
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(BasicDeployable), "TryDeploying", new Type[] { typeof(Character) })]
	private static bool BasicDeployable_TryDeploying_Pre(BasicDeployable __instance, Character _usingCharacter)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (((ItemExtension)__instance).Item.IsSleepKit)
		{
			return IsCampingAllowed(_usingCharacter, ((Component)__instance).transform.position);
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Sleepable), "OnReceiveSleepRequestResult")]
	private static bool Sleepable_OnReceiveSleepRequestResult_Pre(Sleepable __instance, Character _character)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (!__instance.IsInnsBed)
		{
			return IsCampingAllowed(_character, ((Component)__instance).transform.position);
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static bool OrientOnTerrain_IsValid_Pre(OrientOnTerrain __instance)
	{
		//IL_000f: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		AreaEnum val = (AreaEnum)AreaManager.Instance.CurrentArea.ID;
		if (!__instance.m_detectionScript.DeployedItem.IsSleepKit || Extensions.IsNotContainedIn<AreaEnum>(val, (ICollection<AreaEnum>)Defaults.Regions) || _campingSpots.Value.HasFlag(CampingSpots.OpenRegions) || !_campingSpots.Value.HasFlag(CampingSpots.Butterflies))
		{
			return true;
		}
		return IsNearButterflies(((Component)__instance).transform.position);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(RestingMenu), "Show")]
	private static void RestingMenu_Show_Post(RestingMenu __instance)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		foreach (Transform item in ((Component)__instance.m_restingActivitiesHolder).transform)
		{
			Transform val = item;
			CampingActivities[] array = new CampingActivities[3]
			{
				CampingActivities.Sleep,
				CampingActivities.Guard,
				CampingActivities.Repair
			};
			for (int i = 0; i < array.Length; i++)
			{
				CampingActivities campingActivities = array[i];
				if (((Component)(object)val).NameContains(campingActivities.ToString()))
				{
					Extensions_Component.SetActive((Component)(object)val, _campingActivities.Value.HasFlag(campingActivities));
				}
			}
		}
	}
}
public class Quickslots : AMod
{
	private enum WeaponTypeExtended
	{
		Empty = -1,
		Light = -2
	}

	private enum SkillContext
	{
		Innate = 1,
		BasicA,
		BasicB,
		Advanced,
		Weapon,
		WeaponMaster
	}

	private static ModSetting<bool> _weaponTypeBoundQuickslots;

	private static ModSetting<bool> _replaceQuickslotsOnEquip;

	private static ModSetting<bool> _assignByUsingEmptyQuickslot;

	private static ModSetting<bool> _extraGamepadQuickslots;

	private static Dictionary<int, SkillContext> _skillContextsByID = new Dictionary<int, SkillContext>();

	private static readonly Dictionary<SkillContext, Dictionary<WeaponType, int>> SKILL_CONTEXT_GROUPS = new Dictionary<SkillContext, Dictionary<WeaponType, int>>
	{
		[SkillContext.Innate] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)30] = "Dagger Slash".ToSkillID(),
			[(WeaponType)45] = "Fire/Reload".ToSkillID(),
			[(WeaponType)(-2)] = "Throw Lantern".ToSkillID()
		},
		[SkillContext.BasicA] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)200] = "Evasion Shot".ToSkillID(),
			[(WeaponType)30] = "Backstab".ToSkillID(),
			[(WeaponType)45] = "Shatter Bullet".ToSkillID(),
			[(WeaponType)40] = "Chakram Pierce".ToSkillID(),
			[(WeaponType)100] = "Shield Charge".ToSkillID(),
			[(WeaponType)(-2)] = "Flamethrower".ToSkillID()
		},
		[SkillContext.BasicB] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)200] = "Sniper Shot".ToSkillID(),
			[(WeaponType)30] = "Opportunist Stab".ToSkillID(),
			[(WeaponType)45] = "Frost Bullet".ToSkillID(),
			[(WeaponType)40] = "Chakram Arc".ToSkillID(),
			[(WeaponType)100] = "Gong Strike".ToSkillID()
		},
		[SkillContext.Advanced] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)200] = "Piercing Shot".ToSkillID(),
			[(WeaponType)30] = "Serpent's Parry".ToSkillID(),
			[(WeaponType)45] = "Blood Bullet".ToSkillID(),
			[(WeaponType)40] = "Chakram Dance".ToSkillID(),
			[(WeaponType)100] = "Shield Infusion".ToSkillID()
		},
		[SkillContext.Weapon] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)0] = "Puncture".ToSkillID(),
			[(WeaponType)51] = "Pommel Counter".ToSkillID(),
			[(WeaponType)1] = "Talus Cleaver".ToSkillID(),
			[(WeaponType)52] = "Execution".ToSkillID(),
			[(WeaponType)2] = "Mace Infusion".ToSkillID(),
			[(WeaponType)53] = "Juggernaut".ToSkillID(),
			[(WeaponType)54] = "Simeon's Gambit".ToSkillID(),
			[(WeaponType)50] = "Moon Swipe".ToSkillID(),
			[(WeaponType)55] = "Prismatic Flurry".ToSkillID()
		},
		[SkillContext.WeaponMaster] = new Dictionary<WeaponType, int>
		{
			[(WeaponType)0] = "The Technique".ToSkillID(),
			[(WeaponType)51] = "Moment of Truth".ToSkillID(),
			[(WeaponType)1] = "Scalp Collector".ToSkillID(),
			[(WeaponType)52] = "Warrior's Vein".ToSkillID(),
			[(WeaponType)2] = "Dispersion".ToSkillID(),
			[(WeaponType)53] = "Crescendo".ToSkillID(),
			[(WeaponType)54] = "Vicious Cycle".ToSkillID(),
			[(WeaponType)50] = "Splitter".ToSkillID(),
			[(WeaponType)55] = "Vital Crash".ToSkillID(),
			[(WeaponType)200] = "Strafing Run".ToSkillID()
		}
	};

	protected override string SectionOverride => "  \nCOMBAT";

	protected override string Description => "• Change skills when changing weapon\n• Switch between 2 weapons with 1 quickslot\n• Enable 16 gamepad quickslots";

	protected override void Initialize()
	{
		_weaponTypeBoundQuickslots = ((AMod)this).CreateSetting<bool>("_weaponTypeBoundQuickslots", false, (AcceptableValueBase)null);
		_replaceQuickslotsOnEquip = ((AMod)this).CreateSetting<bool>("_replaceQuickslotsOnEquip", false, (AcceptableValueBase)null);
		_assignByUsingEmptyQuickslot = ((AMod)this).CreateSetting<bool>("_assignByUsingEmptyQuickslot", false, (AcceptableValueBase)null);
		_extraGamepadQuickslots = ((AMod)this).CreateSetting<bool>("_extraGamepadQuickslots", false, (AcceptableValueBase)null);
		foreach (KeyValuePair<SkillContext, Dictionary<WeaponType, int>> sKILL_CONTEXT_GROUP in SKILL_CONTEXT_GROUPS)
		{
			foreach (KeyValuePair<WeaponType, int> item in sKILL_CONTEXT_GROUP.Value)
			{
				_skillContextsByID.Add(item.Value, sKILL_CONTEXT_GROUP.Key);
			}
		}
	}

	protected override void LoadPreset(string presetName)
	{
		if (presetName == "Vheos_CoopSurvival")
		{
			((AMod)this).ForceApply();
			_weaponTypeBoundQuickslots.Value = true;
			_replaceQuickslotsOnEquip.Value = true;
			_assignByUsingEmptyQuickslot.Value = false;
			_extraGamepadQuickslots.Value = true;
		}
	}

	protected override void SetFormatting()
	{
		((AModSetting)_weaponTypeBoundQuickslots).Format("Weapon-bound skills");
		((AModSetting)_weaponTypeBoundQuickslots).Description = "Makes your weapon-specific skills change whenever you change your weapon\nLet's assume you have the \"Dagger Slash\" skill assigned to a quickslot and you have a dagger equipped in your offhand. If you switch your dagger to:\n• a pistol, this quickslot will become \"Fire/Reload\"\n• a lantern, this quickslot will become a \"Throw Lantern\"\nAnd when you switch back to a dagger, this quickslot will become \"Dagger Slash\" again\n\nWorks for all weapon types - 1-handed, 2-handed and offhand";
		((AModSetting)_replaceQuickslotsOnEquip).Format("2 weapons, 1 quickslot");
		((AModSetting)_replaceQuickslotsOnEquip).Description = "Allows you to switch between 2 weapons using 1 quickslot\n\nHow to set it up:\nAssign weapon A to a quickslot, then equip weapon B manually\nNow whenver you switch to A, your quickslot will become B - and vice versa";
		((AModSetting)_assignByUsingEmptyQuickslot).Format("Assign by using empty quickslot");
		((AModSetting)_assignByUsingEmptyQuickslot).Description = "Allows you to assign your current weapon to an empty quickslot when you activate it\nIf your mainhand is already quickslotted, your offhand will be assigned\nIf both your mainhand and offhand are quickslotted, nothing will happen";
		((AModSetting)_extraGamepadQuickslots).Format("16 gamepad quickslots");
		((AModSetting)_extraGamepadQuickslots).Description = "Allows you to combine the LT/RT with d-pad buttons (in addition to face buttons) for 8 extra quickslots\n(requires default d-pad keybinds and game restart)";
	}

	private static WeaponType GetExtendedWeaponType(Item item)
	{
		//IL_001b: 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)
		if ((Object)(object)item != (Object)null)
		{
			Weapon val = default(Weapon);
			if (Extensions.TryAs<Weapon>((object)item, ref val))
			{
				return val.Type;
			}
			if ((int)item.LitStatus != 0)
			{
				return (WeaponType)(-2);
			}
		}
		return (WeaponType)(-1);
	}

	private static bool HasItemAssignedToAnyQuickslot(Character character, Item item)
	{
		QuickSlot[] quickSlots = character.QuickSlotMngr.m_quickSlots;
		for (int i = 0; i < quickSlots.Length; i++)
		{
			if ((Object)(object)quickSlots[i].ActiveItem == (Object)(object)item)
			{
				return true;
			}
		}
		return false;
	}

	private static Item GetLearnedSkillByID(Character character, int id)
	{
		return ((IEnumerable<Item>)((CharacterKnowledge)character.Inventory.SkillKnowledge).GetLearnedItems()).FirstOrDefault((Func<Item, bool>)((Item skill) => skill.SharesPrefabWith(id)));
	}

	private static void TryOverrideVanillaQuickslotInput(ref bool input, int playerID)
	{
		if (ModSetting<bool>.op_Implicit(_extraGamepadQuickslots))
		{
			input &= !ControlsInput.QuickSlotToggle1(playerID) && !ControlsInput.QuickSlotToggle2(playerID);
		}
	}

	private static void TryHandleCustomQuickslotInput(Character character)
	{
		if (!ModSetting<bool>.op_Implicit(_extraGamepadQuickslots) || (Object)(object)character == (Object)null || (Object)(object)character.QuickSlotMngr == (Object)null || character.CharacterUI.IsMenuFocused)
		{
			return;
		}
		int playerID = character.OwnerPlayerSys.PlayerID;
		if (!ControlsInput.QuickSlotToggle1(playerID) && !ControlsInput.QuickSlotToggle2(playerID))
		{
			return;
		}
		int num = -1;
		if (GameInput.Pressed(playerID, (GameplayActions)9))
		{
			num = 8;
		}
		else if (GameInput.Pressed(playerID, (MenuActions)16))
		{
			num = 9;
		}
		else if (GameInput.Pressed(playerID, (GameplayActions)23))
		{
			num = 10;
		}
		else if (GameInput.Pressed(playerID, (GameplayActions)24))
		{
			num = 11;
		}
		if (num >= 0)
		{
			if (ControlsInput.QuickSlotToggle1(playerID))
			{
				num += 4;
			}
			character.QuickSlotMngr.QuickSlotInput(num);
		}
	}

	private static void SetupQuickslots(Transform quickslotsHolder)
	{
		Transform val = quickslotsHolder.Find("1");
		for (int i = quickslotsHolder.childCount; i < 16; i++)
		{
			Object.Instantiate<Transform>(val, quickslotsHolder);
		}
		QuickSlot[] componentsInChildren = ((Component)quickslots

BepInEx/Plugins/Vheos/Vheos.Tools.TraitEqualizer.dll

Decompiled 8 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 System.Text;
using Vheos.Helpers.Common;
using Vheos.Helpers.RNG;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Vheos.Tools.TraitEqualizer;

public class Trait<T>
{
	private readonly Func<T, bool> _test;

	public string Name { get; private set; }

	public bool Test(T element)
	{
		return _test(element);
	}

	public Trait(string name, Func<T, bool> test)
	{
		Name = name;
		_test = test;
	}
}
public class TraitElement<T>
{
	public T Value { get; private set; }

	public IEnumerable<Trait<T>> Traits { get; private set; }

	public TraitElement(T value, IEnumerable<Trait<T>> traits)
	{
		Value = value;
		Traits = traits;
	}
}
public class TraitEqualizer<T>
{
	private readonly TraitList<T>[] _lists;

	private readonly Trait<T>[] _traits;

	private readonly Dictionary<Trait<T>, List<TraitList<T>>> _minListsByTrait;

	public IEnumerable<IEnumerable<T>> Results
	{
		get
		{
			TraitList<T>[] lists = _lists;
			foreach (TraitList<T> traitList in lists)
			{
				yield return traitList.Elements.Select((TraitElement<T> element) => element.Value);
			}
		}
	}

	public void Add(T value)
	{
		IEnumerable<Trait<T>> traits = GetTraits(value);
		List<TraitList<T>> list = Utility.Intersect<TraitList<T>>((IEnumerable<IEnumerable<TraitList<T>>>)GetMinListsByTrait(traits));
		if (list.Count == 0)
		{
			list = GetListsWithMostMinTraits(traits);
		}
		TraitList<T> traitList = Random_Extensions.Random<TraitList<T>>((IList<TraitList<T>>)list);
		traitList.Add(new TraitElement<T>(value, traits));
		foreach (Trait<T> item in traits)
		{
			if (_minListsByTrait[item].Remove(traitList) && _minListsByTrait[item].Count == 0)
			{
				_minListsByTrait[item] = GetMinLists(item, traitList.TraitCount(item));
			}
		}
	}

	public string GetResultsAsString()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append("List".PadRight(20));
		int num = 0;
		TraitList<T>[] lists = _lists;
		for (int i = 0; i < lists.Length; i++)
		{
			_ = lists[i];
			stringBuilder.Append($"{(char)(65 + num++),-3} ");
		}
		stringBuilder.AppendLine();
		stringBuilder.AppendLine(new string('-', 20 + 4 * _lists.Length));
		Trait<T>[] traits = _traits;
		foreach (Trait<T> trait in traits)
		{
			stringBuilder.Append($"{trait.Name,-20}");
			lists = _lists;
			for (int j = 0; j < lists.Length; j++)
			{
				int num2 = lists[j].TraitCount(trait);
				string arg = ((num2 == 0) ? "" : num2.ToString());
				stringBuilder.Append($"{arg,-3} ");
			}
			stringBuilder.AppendLine();
		}
		return stringBuilder.ToString();
	}

	private IEnumerable<Trait<T>> GetTraits(T element)
	{
		Trait<T>[] traits = _traits;
		foreach (Trait<T> trait in traits)
		{
			if (trait.Test(element))
			{
				yield return trait;
			}
		}
	}

	private List<TraitList<T>> GetMinLists(Trait<T> trait, int minThrehsold)
	{
		return _lists.Where((TraitList<T> list) => list.TraitCount(trait) <= minThrehsold).ToList();
	}

	private IEnumerable<List<TraitList<T>>> GetMinListsByTrait(IEnumerable<Trait<T>> traits)
	{
		foreach (Trait<T> trait in traits)
		{
			yield return _minListsByTrait[trait];
		}
	}

	private List<TraitList<T>> GetListsWithMostMinTraits(IEnumerable<Trait<T>> traits)
	{
		List<TraitList<T>> list = new List<TraitList<T>>();
		int num = 0;
		TraitList<T>[] lists = _lists;
		foreach (TraitList<T> item in lists)
		{
			int num2 = 0;
			foreach (Trait<T> trait in traits)
			{
				if (_minListsByTrait[trait].Contains(item))
				{
					num2++;
				}
			}
			if (num2 > num)
			{
				list.Clear();
				num = num2;
			}
			if (num2 == num)
			{
				list.Add(item);
			}
		}
		return list;
	}

	public TraitEqualizer(int listsCount, Trait<T>[] traits)
	{
		_traits = traits;
		_lists = new TraitList<T>[listsCount];
		for (int i = 0; i < _lists.Length; i++)
		{
			_lists[i] = new TraitList<T>(_traits);
		}
		_minListsByTrait = new Dictionary<Trait<T>, List<TraitList<T>>>();
		Trait<T>[] traits2 = _traits;
		foreach (Trait<T> key in traits2)
		{
			_minListsByTrait[key] = _lists.ToList();
		}
	}
}
public class TraitList<T>
{
	public List<TraitElement<T>> _elements;

	private readonly Dictionary<Trait<T>, int> _countsByTrait;

	public IEnumerable<TraitElement<T>> Elements
	{
		get
		{
			foreach (TraitElement<T> element in _elements)
			{
				yield return element;
			}
		}
	}

	public void Add(TraitElement<T> element)
	{
		_elements.Add(element);
		foreach (Trait<T> trait in element.Traits)
		{
			_countsByTrait[trait]++;
		}
	}

	public int TraitCount(Trait<T> trait)
	{
		return _countsByTrait[trait];
	}

	public TraitList(Trait<T>[] traits)
	{
		_elements = new List<TraitElement<T>>();
		_countsByTrait = new Dictionary<Trait<T>, int>();
		foreach (Trait<T> key in traits)
		{
			_countsByTrait.Add(key, 0);
		}
	}
}