Decompiled source of WiresSmoothUI v0.6.8

WiresSmoothUI.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("WiresSmoothUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ec78e024f70f5f79047d68625f76bff83abac453")]
[assembly: AssemblyProduct("WiresSmoothUI")]
[assembly: AssemblyTitle("WiresSmoothUI")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WiresSmoothUI
{
	internal static class ArmorPop
	{
		private const float SpawnQuiet = 2f;

		internal static float SpawnTime = -100f;

		internal static void EquipChanged(ItemData item)
		{
			if (item != null && !(item.m_shared.m_armor <= 0f) && WiresSmoothUIPlugin.Enabled.Value && WiresSmoothUIPlugin.ItemAnimations.Value && !(Time.unscaledTime - SpawnTime < 2f))
			{
				InventoryGui instance = InventoryGui.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_armor != (Object)null)
				{
					UiMotion.Pop(instance.m_armor.transform, 1f, 1.15f, 0.2f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "OnSpawned")]
	internal static class SmoothUISpawnPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				ArmorPop.SpawnTime = Time.unscaledTime;
			}
		}
	}
	internal static class BuildMenuAnimationSystem
	{
		private sealed class State
		{
			internal Transform Root;

			internal Transform Parent;

			internal Button Button;

			internal Vector3 BasePosition;

			internal Vector3 BaseScale;

			internal Quaternion BaseRotation;

			internal Vector3 AppliedPosition;

			internal float AppliedScale = 1f;

			internal float AppliedRotation;

			internal bool Applied;

			internal bool Hovered;

			internal bool Pressed;

			internal bool Selected;

			internal float Scale = 1f;

			internal Vector2 Sway;

			internal float Rotation;

			internal int ActiveIndex = -1;
		}

		private static readonly Dictionary<Transform, State> States = new Dictionary<Transform, State>();

		private static readonly List<State> Active = new List<State>();

		internal static bool Busy => Active.Count > 0;

		internal static bool OwnsButton(Button button)
		{
			if ((Object)(object)button == (Object)null)
			{
				return false;
			}
			if (!((Object)(object)((Component)button).GetComponentInParent<BuildUiPieceButton>() != (Object)null) && !((Object)(object)((Component)button).GetComponentInParent<BuildUiTagButton>() != (Object)null))
			{
				return (Object)(object)((Component)button).GetComponentInParent<BuildUiFavoriteCategoryCheckButton>() != (Object)null;
			}
			return true;
		}

		internal static void Register(Component owner)
		{
			if ((Object)(object)owner == (Object)null)
			{
				return;
			}
			Transform transform = owner.transform;
			if ((Object)(object)transform == (Object)null || States.ContainsKey(transform))
			{
				return;
			}
			Button component = owner.GetComponent<Button>();
			if (!((Object)(object)component == (Object)null))
			{
				ButtonAnimationSystem.Unregister(component);
				State state = new State
				{
					Root = transform,
					Button = component
				};
				CaptureBase(state);
				States.Add(transform, state);
				BuildMenuMotionHook buildMenuMotionHook = owner.GetComponent<BuildMenuMotionHook>();
				if ((Object)(object)buildMenuMotionHook == (Object)null)
				{
					buildMenuMotionHook = owner.gameObject.AddComponent<BuildMenuMotionHook>();
				}
				buildMenuMotionHook.Bind(transform);
			}
		}

		internal static void Unregister(Transform root)
		{
			if (!((Object)(object)root == (Object)null) && States.TryGetValue(root, out var value))
			{
				RestoreState(value);
				Deactivate(value);
				States.Remove(root);
			}
		}

		internal static void SetHovered(Transform root, bool value)
		{
			if (!((Object)(object)root == (Object)null) && States.TryGetValue(root, out var value2))
			{
				value2.Hovered = value && ZInput.instance != null && ZInput.IsMouseActive();
				if (!value2.Hovered)
				{
					value2.Pressed = false;
				}
				ActivateFresh(value2);
			}
		}

		internal static void SetPressed(Transform root, bool value)
		{
			if (!((Object)(object)root == (Object)null) && States.TryGetValue(root, out var value2))
			{
				value2.Pressed = value && value2.Hovered;
				ActivateFresh(value2);
			}
		}

		internal static void SetSelected(Transform root, bool value)
		{
			if (!((Object)(object)root == (Object)null) && States.TryGetValue(root, out var value2))
			{
				value2.Selected = value;
				ActivateFresh(value2);
			}
		}

		private static void ActivateFresh(State state)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (state.ActiveIndex < 0 && !((Object)(object)state.Root == (Object)null) && ((Component)state.Root).gameObject.activeInHierarchy)
			{
				CaptureBase(state);
				state.Scale = 1f;
				state.Sway = Vector2.zero;
				state.Rotation = 0f;
				state.ActiveIndex = Active.Count;
				Active.Add(state);
				SmoothUIDriver.Wake();
			}
		}

		internal static void Tick()
		{
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			if (!WiresSmoothUIPlugin.BuildMenuAnimations.Value)
			{
				RestoreAll();
			}
			else
			{
				if (Active.Count == 0)
				{
					return;
				}
				float num = Mathf.Max(1f, WiresSmoothUIPlugin.BuildMenuResponse.Value);
				float num2 = Mathf.Clamp(WiresSmoothUIPlugin.BuildMenuHoverScale.Value, 1f, 1.2f);
				float num3 = 1f + (num2 - 1f) * 0.75f;
				for (int num4 = Active.Count - 1; num4 >= 0; num4--)
				{
					State state = Active[num4];
					Transform root = state.Root;
					Button button = state.Button;
					if ((Object)(object)root == (Object)null || (Object)(object)button == (Object)null || !((Component)root).gameObject.activeInHierarchy)
					{
						RestoreState(state);
						DeactivateAt(num4);
					}
					else
					{
						RestoreState(state);
						if ((Object)(object)root.parent != (Object)(object)state.Parent)
						{
							CaptureBase(state);
						}
						bool flag = state.Hovered && ZInput.instance != null && ZInput.IsMouseActive();
						bool flag2 = state.Selected && ZInput.instance != null && ZInput.IsExclusiveGamepadActive();
						float target = 1f;
						if (state.Pressed && flag)
						{
							target = 0.965f;
						}
						else if (flag)
						{
							target = num2;
						}
						else if (flag2)
						{
							target = num3;
						}
						state.Scale = WiresSmoothUIPlugin.Damp(state.Scale, target, num);
						Vector2 target2 = Vector2.zero;
						float target3 = 0f;
						if (flag && WiresSmoothUIPlugin.BuildMenuInertia.Value)
						{
							Vector2 val = Vector2.ClampMagnitude(PointerMotion.Delta, 18f) / 18f;
							target2 = new Vector2(0f - val.x, 0f - val.y) * 1.65f;
							target3 = (0f - val.x) * 1.15f;
						}
						state.Sway = WiresSmoothUIPlugin.Damp(state.Sway, target2, num * 0.75f);
						state.Rotation = WiresSmoothUIPlugin.Damp(state.Rotation, target3, num * 0.7f);
						ApplyState(state);
						bool num5 = flag || flag2 || (state.Pressed && flag);
						bool flag3 = Mathf.Abs(state.Scale - 1f) < 0.001f && ((Vector2)(ref state.Sway)).sqrMagnitude < 0.0005f && Mathf.Abs(state.Rotation) < 0.01f;
						if (!num5 && flag3)
						{
							RestoreState(state);
							DeactivateAt(num4);
						}
					}
				}
			}
		}

		private static void ApplyState(State state)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Transform root = state.Root;
			if (!((Object)(object)root == (Object)null))
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(state.Sway.x, state.Sway.y, 0f);
				root.localPosition = state.BasePosition + val;
				root.localScale = state.BaseScale * state.Scale;
				root.localRotation = state.BaseRotation * Quaternion.Euler(0f, 0f, state.Rotation);
				state.AppliedPosition = val;
				state.AppliedScale = state.Scale;
				state.AppliedRotation = state.Rotation;
				state.Applied = true;
			}
		}

		private static void CaptureBase(State state)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)state?.Root == (Object)null))
			{
				state.Parent = state.Root.parent;
				state.BasePosition = state.Root.localPosition;
				state.BaseScale = state.Root.localScale;
				state.BaseRotation = state.Root.localRotation;
				state.Applied = false;
				state.AppliedPosition = Vector3.zero;
				state.AppliedScale = 1f;
				state.AppliedRotation = 0f;
			}
		}

		private static void RestoreState(State state)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)state?.Root == (Object)null || !state.Applied)
			{
				return;
			}
			Transform root = state.Root;
			if ((Object)(object)root.parent != (Object)(object)state.Parent)
			{
				CaptureBase(state);
				return;
			}
			Vector3 val = state.BasePosition + state.AppliedPosition;
			Vector3 val2 = state.BaseScale * state.AppliedScale;
			Quaternion val3 = state.BaseRotation * Quaternion.Euler(0f, 0f, state.AppliedRotation);
			Vector3 val4 = root.localPosition - val;
			if (((Vector3)(ref val4)).sqrMagnitude < 0.0009f)
			{
				root.localPosition = state.BasePosition;
			}
			else
			{
				state.BasePosition = root.localPosition;
			}
			val4 = root.localScale - val2;
			if (((Vector3)(ref val4)).sqrMagnitude < 0.0009f)
			{
				root.localScale = state.BaseScale;
			}
			else
			{
				state.BaseScale = root.localScale;
			}
			if (Quaternion.Angle(root.localRotation, val3) < 0.05f)
			{
				root.localRotation = state.BaseRotation;
			}
			else
			{
				state.BaseRotation = root.localRotation;
			}
			state.Applied = false;
			state.AppliedPosition = Vector3.zero;
			state.AppliedScale = 1f;
			state.AppliedRotation = 0f;
		}

		private static void Deactivate(State state)
		{
			if (state.ActiveIndex >= 0)
			{
				DeactivateAt(state.ActiveIndex);
			}
		}

		private static void DeactivateAt(int index)
		{
			int num = Active.Count - 1;
			State state = Active[index];
			if (index != num)
			{
				State state2 = Active[num];
				Active[index] = state2;
				state2.ActiveIndex = index;
			}
			Active.RemoveAt(num);
			state.ActiveIndex = -1;
		}

		internal static void RestoreAll()
		{
			//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)
			for (int num = Active.Count - 1; num >= 0; num--)
			{
				State state = Active[num];
				RestoreState(state);
				state.Hovered = false;
				state.Pressed = false;
				state.Selected = false;
				state.Scale = 1f;
				state.Sway = Vector2.zero;
				state.Rotation = 0f;
				DeactivateAt(num);
			}
		}

		internal static void Shutdown()
		{
			RestoreAll();
			States.Clear();
		}
	}
	internal sealed class BuildMenuMotionHook : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, ISelectHandler, IDeselectHandler
	{
		private Transform _root;

		internal void Bind(Transform root)
		{
			_root = root;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			BuildMenuAnimationSystem.SetHovered(_root, value: true);
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			BuildMenuAnimationSystem.SetHovered(_root, value: false);
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 0)
			{
				BuildMenuAnimationSystem.SetPressed(_root, value: true);
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 0)
			{
				BuildMenuAnimationSystem.SetPressed(_root, value: false);
			}
		}

		public void OnSelect(BaseEventData eventData)
		{
			BuildMenuAnimationSystem.SetSelected(_root, value: true);
		}

		public void OnDeselect(BaseEventData eventData)
		{
			BuildMenuAnimationSystem.SetSelected(_root, value: false);
		}

		private void OnDisable()
		{
			BuildMenuAnimationSystem.SetHovered(_root, value: false);
			BuildMenuAnimationSystem.SetPressed(_root, value: false);
			BuildMenuAnimationSystem.SetSelected(_root, value: false);
		}

		private void OnDestroy()
		{
			BuildMenuAnimationSystem.Unregister(_root);
		}
	}
	[HarmonyPatch(typeof(BuildUiPieceButton), "Awake")]
	internal static class SmoothUIBuildPieceButtonPatch
	{
		[HarmonyPostfix]
		private static void Postfix(BuildUiPieceButton __instance)
		{
			BuildMenuAnimationSystem.Register((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(BuildUiTagButton), "Awake")]
	internal static class SmoothUIBuildTagButtonPatch
	{
		[HarmonyPostfix]
		private static void Postfix(BuildUiTagButton __instance)
		{
			BuildMenuAnimationSystem.Register((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(BuildUiFavoriteCategoryCheckButton), "Awake")]
	internal static class SmoothUIBuildFavoriteCheckPatch
	{
		[HarmonyPostfix]
		private static void Postfix(BuildUiFavoriteCategoryCheckButton __instance)
		{
			BuildMenuAnimationSystem.Register((Component)(object)__instance);
		}
	}
	internal static class ButtonAnimationSystem
	{
		internal sealed class State
		{
			internal Button Button;

			internal Vector3 BaseScale;

			internal float Scale = 1f;

			internal float AppliedScale = 1f;

			internal bool Applied;

			internal bool Hovered;

			internal bool Pressed;

			internal int ActiveIndex = -1;
		}

		private static readonly Dictionary<Button, State> States = new Dictionary<Button, State>();

		private static readonly List<State> Active = new List<State>();

		internal static bool Busy => Active.Count > 0;

		internal static void Register(Button button)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)button == (Object)null) && !States.ContainsKey(button) && !((Object)(object)((Component)button).GetComponentInParent<InventoryElement>() != (Object)null) && !((Object)(object)((Component)button).GetComponentInParent<InventoryGrid>() != (Object)null) && !((Object)(object)((Component)button).GetComponentInParent<HotkeyBar>() != (Object)null) && !BuildMenuAnimationSystem.OwnsButton(button))
			{
				State value = new State
				{
					Button = button,
					BaseScale = ((Component)button).transform.localScale
				};
				States.Add(button, value);
				ButtonMotionHook buttonMotionHook = ((Component)button).GetComponent<ButtonMotionHook>();
				if ((Object)(object)buttonMotionHook == (Object)null)
				{
					buttonMotionHook = ((Component)button).gameObject.AddComponent<ButtonMotionHook>();
				}
				buttonMotionHook.Bind(button);
			}
		}

		internal static void Unregister(Button button)
		{
			if (button != null && States.TryGetValue(button, out var value))
			{
				RestoreState(value);
				Deactivate(value);
				States.Remove(button);
			}
		}

		internal static void SetHovered(Button button, bool hovered)
		{
			if (!((Object)(object)button == (Object)null) && States.TryGetValue(button, out var value))
			{
				value.Hovered = hovered;
				if (!hovered)
				{
					value.Pressed = false;
				}
				if (WiresSmoothUIPlugin.ButtonAnimations.Value)
				{
					Activate(value);
				}
			}
		}

		internal static void SetPressed(Button button, bool pressed)
		{
			if (!((Object)(object)button == (Object)null) && States.TryGetValue(button, out var value))
			{
				value.Pressed = pressed;
				if (WiresSmoothUIPlugin.ButtonAnimations.Value)
				{
					Activate(value);
				}
			}
		}

		internal static void Tick()
		{
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			if (!WiresSmoothUIPlugin.ButtonAnimations.Value)
			{
				RestoreActive();
			}
			else
			{
				if (Active.Count == 0)
				{
					return;
				}
				for (int num = Active.Count - 1; num >= 0; num--)
				{
					State state = Active[num];
					Button button = state.Button;
					if ((Object)(object)button == (Object)null)
					{
						DeactivateAt(num);
					}
					else
					{
						RestoreState(state);
						if (!((Component)button).gameObject.activeInHierarchy || !((Selectable)button).interactable)
						{
							state.Hovered = false;
							state.Pressed = false;
						}
						float num2 = (state.Pressed ? 0.975f : (state.Hovered ? Mathf.Clamp(WiresSmoothUIPlugin.ButtonHoverScale.Value, 1f, 1.15f) : 1f));
						state.Scale = WiresSmoothUIPlugin.Damp(state.Scale, num2, WiresSmoothUIPlugin.ButtonResponse.Value);
						if (!state.Hovered && !state.Pressed && Mathf.Abs(state.Scale - 1f) < 0.001f)
						{
							state.Scale = 1f;
							((Component)button).transform.localScale = state.BaseScale;
							DeactivateAt(num);
						}
						else if (Mathf.Abs(state.Scale - num2) < 0.001f)
						{
							state.Scale = num2;
							state.AppliedScale = num2;
							((Component)button).transform.localScale = state.BaseScale * num2;
							state.Applied = true;
							DeactivateAt(num);
						}
						else
						{
							state.AppliedScale = state.Scale;
							((Component)button).transform.localScale = state.BaseScale * state.AppliedScale;
							state.Applied = true;
						}
					}
				}
			}
		}

		private static void RestoreState(State state)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (state != null && !((Object)(object)state.Button == (Object)null) && state.Applied)
			{
				Transform transform = ((Component)state.Button).transform;
				Vector3 val = state.BaseScale * state.AppliedScale;
				Vector3 val2 = transform.localScale - val;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.0009f)
				{
					transform.localScale = state.BaseScale;
				}
				else
				{
					state.BaseScale = transform.localScale;
				}
				state.Applied = false;
				state.AppliedScale = 1f;
			}
		}

		private static void Activate(State state)
		{
			if (state.ActiveIndex < 0)
			{
				state.ActiveIndex = Active.Count;
				Active.Add(state);
				SmoothUIDriver.Wake();
			}
		}

		private static void Deactivate(State state)
		{
			if (state.ActiveIndex >= 0)
			{
				DeactivateAt(state.ActiveIndex);
			}
		}

		private static void DeactivateAt(int index)
		{
			int num = Active.Count - 1;
			State state = Active[index];
			if (index != num)
			{
				State state2 = Active[num];
				Active[index] = state2;
				state2.ActiveIndex = index;
			}
			Active.RemoveAt(num);
			state.ActiveIndex = -1;
		}

		private static void RestoreActive()
		{
			for (int num = Active.Count - 1; num >= 0; num--)
			{
				State state = Active[num];
				RestoreState(state);
				state.Scale = 1f;
				state.Hovered = false;
				state.Pressed = false;
				DeactivateAt(num);
			}
		}

		internal static void RestoreAll()
		{
			RestoreActive();
			foreach (State value in States.Values)
			{
				RestoreState(value);
				value.Scale = 1f;
				value.Hovered = false;
				value.Pressed = false;
			}
		}

		internal static void Shutdown()
		{
			RestoreActive();
			States.Clear();
		}
	}
	internal sealed class ButtonMotionHook : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
	{
		private Button _button;

		internal void Bind(Button button)
		{
			_button = button;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			ButtonAnimationSystem.SetHovered(_button, hovered: true);
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			ButtonAnimationSystem.SetHovered(_button, hovered: false);
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 0)
			{
				ButtonAnimationSystem.SetPressed(_button, pressed: true);
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 0)
			{
				ButtonAnimationSystem.SetPressed(_button, pressed: false);
			}
		}

		private void OnDisable()
		{
			ButtonAnimationSystem.SetHovered(_button, hovered: false);
			ButtonAnimationSystem.SetPressed(_button, pressed: false);
		}

		private void OnDestroy()
		{
			ButtonAnimationSystem.Unregister(_button);
		}
	}
	[HarmonyPatch(typeof(Selectable), "OnEnable")]
	internal static class SmoothUIButtonEnablePatch
	{
		[HarmonyPostfix]
		private static void Postfix(Selectable __instance)
		{
			Button val = (Button)(object)((__instance is Button) ? __instance : null);
			if (val != null)
			{
				ButtonAnimationSystem.Register(val);
			}
		}
	}
	internal static class CraftingMotion
	{
		private static readonly FieldInfo SelectedField = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe");

		private static readonly FieldInfo RecipesField = AccessTools.Field(typeof(InventoryGui), "m_availableRecipes");

		private static readonly Vector3 DetailFrom = new Vector3(14f, 0f, 0f);

		private const float DetailStep = 0.025f;

		private const float DetailDuration = 0.2f;

		private static readonly Vector3 RowFrom = new Vector3(-16f, 0f, 0f);

		private const float RowStep = 0.025f;

		private const float RowDuration = 0.22f;

		private const float MaxRowDelay = 0.3f;

		internal static bool ListPending;

		private static readonly Type PairType = AccessTools.Inner(typeof(InventoryGui), "RecipeDataPair");

		private static readonly PropertyInfo RecipeProp = AccessTools.Property(PairType, "Recipe");

		private static readonly PropertyInfo ItemProp = AccessTools.Property(PairType, "ItemData");

		private static readonly PropertyInfo RowProp = AccessTools.Property(PairType, "InterfaceElement");

		private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4];

		private static string _lastLevel = "";

		private static readonly Dictionary<Transform, string> Shown = new Dictionary<Transform, string>();

		private static readonly List<TMP_Text> Texts = new List<TMP_Text>();

		private static readonly List<Image> Images = new List<Image>();

		private static readonly StringBuilder Sig = new StringBuilder();

		internal static bool On
		{
			get
			{
				if (WiresSmoothUIPlugin.Enabled.Value)
				{
					return WiresSmoothUIPlugin.CraftingAnimations.Value;
				}
				return false;
			}
		}

		internal static object Selected(InventoryGui gui)
		{
			return SelectedField?.GetValue(gui);
		}

		private static GameObject RowOf(object pair)
		{
			if (pair != null)
			{
				object? obj = RowProp?.GetValue(pair);
				return (GameObject)((obj is GameObject) ? obj : null);
			}
			return null;
		}

		internal static bool SameRecipe(object a, object b)
		{
			if (a == null || b == null)
			{
				return a == b;
			}
			if (RecipeProp?.GetValue(a) == RecipeProp?.GetValue(b))
			{
				return ItemProp?.GetValue(a) == ItemProp?.GetValue(b);
			}
			return false;
		}

		internal static void PlayList(InventoryGui gui)
		{
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			if (!On || (Object)(object)gui == (Object)null || (Object)(object)gui.m_recipeListRoot == (Object)null || !((Component)gui.m_recipeListRoot).gameObject.activeInHierarchy || !(RecipesField?.GetValue(gui) is IList list))
			{
				return;
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(gui.m_recipeListRoot);
			List<Component> list2 = new List<Component>(list.Count);
			foreach (object item in list)
			{
				GameObject val = RowOf(item);
				if ((Object)(object)val != (Object)null)
				{
					list2.Add((Component)(object)val.transform);
				}
			}
			ScrollRect componentInParent = ((Component)gui.m_recipeListRoot).GetComponentInParent<ScrollRect>();
			RectTransform val2 = (RectTransform)(((Object)(object)componentInParent == (Object)null) ? null : (((Object)(object)componentInParent.viewport != (Object)null) ? ((object)componentInParent.viewport) : ((object)/*isinst with value type is only supported in some contexts*/)));
			int num = 0;
			foreach (Component item2 in list2)
			{
				if (item2.gameObject.activeInHierarchy && (!((Object)(object)val2 != (Object)null) || Overlaps((RectTransform)/*isinst with value type is only supported in some contexts*/, val2)))
				{
					UiMotion.Enter(item2.transform, Mathf.Min(0.3f, (float)num * 0.025f), 0.22f, RowFrom, 1f, fade: true);
					num++;
				}
			}
		}

		private static bool Overlaps(RectTransform row, RectTransform viewport)
		{
			if ((Object)(object)row == (Object)null)
			{
				return false;
			}
			row.GetWorldCorners(Corners);
			float y = Corners[0].y;
			float y2 = Corners[1].y;
			viewport.GetWorldCorners(Corners);
			if (y2 > Corners[0].y)
			{
				return y < Corners[1].y;
			}
			return false;
		}

		internal static void ExtraTabPressed(Button button)
		{
			InventoryGui instance = InventoryGui.instance;
			if (On && !((Object)(object)instance == (Object)null) && !((Object)(object)button == (Object)null) && !((Object)(object)instance.m_tabCraft == (Object)null) && !((Object)(object)button == (Object)(object)instance.m_tabCraft) && !((Object)(object)button == (Object)(object)instance.m_tabUpgrade) && !((Object)(object)((Component)button).transform.parent != (Object)(object)((Component)instance.m_tabCraft).transform.parent))
			{
				TabPressed(button);
				PlayList(instance);
			}
		}

		internal static void TabPressed(Button tab)
		{
			if (On && !((Object)(object)tab == (Object)null))
			{
				TMP_Text componentInChildren = ((Component)tab).GetComponentInChildren<TMP_Text>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					UiMotion.Pop(componentInChildren.transform, 0.85f, 1.12f, 0.22f);
				}
			}
		}

		internal static void RecipeChanged(InventoryGui gui)
		{
			if (On)
			{
				UiMotion.NextFrame(delegate
				{
					PlayRecipe(gui, picked: true);
				});
			}
		}

		private static void PlayRecipe(InventoryGui gui, bool picked)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			object obj = (((Object)(object)gui != (Object)null) ? Selected(gui) : null);
			if (obj == null)
			{
				return;
			}
			GameObject val = (picked ? RowOf(obj) : null);
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = val.transform.Find("icon");
				if ((Object)(object)val2 != (Object)null)
				{
					UiMotion.Pop(val2, 1f, 1.14f, 0.2f);
				}
				Transform val3 = val.transform.Find("selected");
				if ((Object)(object)val3 != (Object)null)
				{
					UiMotion.Enter(val3, 0f, 0.2f, Vector3.zero, 1f, fade: true);
				}
			}
			int index = 0;
			Detail((Object)(object)gui.m_recipeIcon, ref index);
			Detail((Object)(object)gui.m_recipeName, ref index);
			Detail((Object)(object)gui.m_itemCraftType, ref index);
			Detail((Object)(object)gui.m_upgradeItemIcon, ref index);
			Detail((Object)(object)gui.m_upgradeItemName, ref index);
			Detail((Object)(object)gui.m_recipeDecription, ref index);
			Detail((Object)(object)gui.m_qualityPanel, ref index);
			Detail((Object)(object)gui.m_variantButton, ref index);
			Image minStationLevelIcon = gui.m_minStationLevelIcon;
			TMP_Text minStationLevelText = gui.m_minStationLevelText;
			if ((Object)(object)minStationLevelIcon != (Object)null && (Object)(object)minStationLevelText != (Object)null)
			{
				string text = (((Component)minStationLevelIcon).gameObject.activeInHierarchy ? minStationLevelText.text : "");
				if (text != _lastLevel && text.Length > 0)
				{
					UiMotion.Pop(minStationLevelText.transform, 0.6f, 1.25f, 0.28f);
				}
				_lastLevel = text;
			}
			GameObject[] recipeRequirementList = gui.m_recipeRequirementList;
			foreach (GameObject val4 in recipeRequirementList)
			{
				MaterialSlotWatcher materialSlotWatcher = (((Object)(object)val4 != (Object)null) ? val4.GetComponent<MaterialSlotWatcher>() : null);
				if ((Object)(object)materialSlotWatcher != (Object)null && materialSlotWatcher.Empty)
				{
					Shown.Remove(val4.transform);
				}
				else
				{
					Detail((Object)(object)val4, ref index);
				}
			}
		}

		internal static void ResetShown()
		{
			Shown.Clear();
			_lastLevel = "";
		}

		private static string Signature(Transform t)
		{
			Sig.Length = 0;
			((Component)t).GetComponentsInChildren<TMP_Text>(false, Texts);
			foreach (TMP_Text text in Texts)
			{
				Sig.Append(text.text).Append('|');
			}
			((Component)t).GetComponentsInChildren<Image>(false, Images);
			foreach (Image image in Images)
			{
				Sig.Append(((Object)(object)image.sprite != (Object)null) ? ((Object)image.sprite).GetInstanceID() : 0).Append('|');
			}
			return Sig.ToString();
		}

		private static void Detail(Object part, ref int index)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (GameObject)(object)((part is GameObject) ? part : null);
			object obj2;
			if (val == null)
			{
				Object obj = ((part is Component) ? part : null);
				obj2 = ((obj != null) ? ((Component)obj).transform : null);
			}
			else
			{
				obj2 = val.transform;
			}
			Transform val2 = (Transform)obj2;
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			if (!((Component)val2).gameObject.activeInHierarchy)
			{
				Shown.Remove(val2);
				return;
			}
			string text = Signature(val2);
			if (!Shown.TryGetValue(val2, out var value) || !(value == text))
			{
				Shown[val2] = text;
				UiMotion.Enter(val2, Mathf.Min(0.25f, (float)index * 0.025f), 0.2f, DetailFrom, 1f, fade: true);
				index++;
			}
		}

		internal static void Crafted(InventoryGui gui)
		{
			if (On && !((Object)(object)gui == (Object)null) && gui.InUpradeTab())
			{
				UiMotion.NextFrame(delegate
				{
					PlayRecipe(gui, picked: false);
				});
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "SetRecipe")]
	internal static class SmoothUICraftSelectPatch
	{
		[HarmonyPrefix]
		private static void Prefix(InventoryGui __instance, out object __state)
		{
			__state = CraftingMotion.Selected(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(InventoryGui __instance, object __state)
		{
			if (!CraftingMotion.SameRecipe(__state, CraftingMotion.Selected(__instance)))
			{
				CraftingMotion.RecipeChanged(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Show")]
	internal static class SmoothUICraftListShowPatch
	{
		[HarmonyPostfix]
		private static void Postfix(InventoryGui __instance)
		{
			if (CraftingMotion.On)
			{
				UiMotion.NextFrame(delegate
				{
					CraftingMotion.PlayList(__instance);
				});
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnTabCraftPressed")]
	internal static class SmoothUICraftListCraftTabPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			CraftingMotion.ListPending = true;
		}

		[HarmonyPostfix]
		private static void Postfix(InventoryGui __instance)
		{
			CraftingMotion.TabPressed(__instance.m_tabCraft);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnTabUpgradePressed")]
	internal static class SmoothUICraftListUpgradeTabPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			CraftingMotion.ListPending = true;
		}

		[HarmonyPostfix]
		private static void Postfix(InventoryGui __instance)
		{
			CraftingMotion.TabPressed(__instance.m_tabUpgrade);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")]
	internal static class SmoothUICraftListRebuildPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(InventoryGui __instance)
		{
			if (CraftingMotion.ListPending)
			{
				CraftingMotion.ListPending = false;
				CraftingMotion.PlayList(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	internal static class SmoothUICraftPatch
	{
		internal static bool InCraft;

		internal static bool Consumed;

		[HarmonyPrefix]
		private static void Prefix()
		{
			InCraft = true;
			Consumed = false;
		}

		[HarmonyPostfix]
		private static void Postfix(InventoryGui __instance)
		{
			if (Consumed)
			{
				CraftingMotion.Crafted(__instance);
			}
		}

		[HarmonyFinalizer]
		private static void Finalizer()
		{
			InCraft = false;
			Consumed = false;
		}
	}
	[HarmonyPatch(typeof(Player), "ConsumeResources")]
	internal static class SmoothUICraftConsumePatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			if (SmoothUICraftPatch.InCraft)
			{
				SmoothUICraftPatch.Consumed = true;
			}
		}
	}
	[HarmonyPatch(typeof(Button), "OnPointerClick")]
	internal static class SmoothUICraftExtraTabClickPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Button __instance)
		{
			CraftingMotion.ExtraTabPressed(__instance);
		}
	}
	[HarmonyPatch(typeof(Button), "OnSubmit")]
	internal static class SmoothUICraftExtraTabSubmitPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Button __instance)
		{
			CraftingMotion.ExtraTabPressed(__instance);
		}
	}
	internal static class DragAnimationSystem
	{
		private static readonly FieldRef<InventoryGui, GameObject> DragGo = AccessTools.FieldRefAccess<InventoryGui, GameObject>("m_dragGo");

		private static GameObject _current;

		private static ItemData _currentItem;

		private static readonly FieldRef<InventoryGui, ItemData> DragItem = AccessTools.FieldRefAccess<InventoryGui, ItemData>("m_dragItem");

		private static Vector3 _smoothPosition;

		private static Vector3 _baseScale = Vector3.one;

		private static Quaternion _baseRotation = Quaternion.identity;

		private static Vector2 _physicsOffset;

		private static Vector2 _physicsVelocity;

		private static float _rotation;

		private static float _rotationVelocity;

		private static float _spawnTimer;

		private static bool _applied;

		internal static bool IsDragging => (Object)(object)_current != (Object)null;

		internal static void NotifySetup(InventoryGui gui)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gui == (Object)null)
			{
				return;
			}
			GameObject val;
			try
			{
				val = DragGo.Invoke(gui);
			}
			catch
			{
				return;
			}
			if ((Object)(object)val == (Object)null)
			{
				if ((Object)(object)_current != (Object)null && _currentItem != null)
				{
					Transform val2 = _current.transform.Find("icon");
					ItemAnimationSystem.NotifyDropped(_currentItem, (((Object)(object)val2 != (Object)null) ? val2 : _current.transform).position);
				}
				Restore();
				_current = null;
				_currentItem = null;
			}
			else if (!((Object)(object)_current == (Object)(object)val))
			{
				Restore();
				_current = val;
				_currentItem = DragItem.Invoke(gui);
				SmoothUIDriver.Wake();
				_smoothPosition = ((ZInput.instance != null && ZInput.IsMouseActive()) ? ZInput.pointerPosition : val.transform.position);
				if (ZInput.instance != null && ZInput.IsMouseActive())
				{
					val.transform.position = _smoothPosition;
				}
				_baseScale = val.transform.localScale;
				_baseRotation = val.transform.localRotation;
				_physicsOffset = Vector2.zero;
				_physicsVelocity = Vector2.zero;
				_rotation = 0f;
				_rotationVelocity = 0f;
				_spawnTimer = 0f;
			}
		}

		internal static void Tick()
		{
			//IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			GameObject current = _current;
			if ((Object)(object)current == (Object)null)
			{
				return;
			}
			if (_applied)
			{
				Vector3 val = _baseScale * CurrentScale();
				Quaternion val2 = _baseRotation * Quaternion.Euler(0f, 0f, _rotation);
				Vector3 val3 = current.transform.localScale - val;
				if (((Vector3)(ref val3)).sqrMagnitude > 0.0009f)
				{
					_baseScale = current.transform.localScale;
				}
				if (Quaternion.Angle(current.transform.localRotation, val2) > 0.05f)
				{
					_baseRotation = current.transform.localRotation;
				}
			}
			if (!WiresSmoothUIPlugin.ItemAnimations.Value)
			{
				Restore();
				return;
			}
			float dt = WiresSmoothUIPlugin.Dt;
			_spawnTimer += dt;
			if (ZInput.IsMouseActive())
			{
				Vector3 val4 = Vector2.op_Implicit(PointerMotion.Position);
				float num = Mathf.Max(1f, WiresSmoothUIPlugin.DragFollow.Value);
				float num2 = 1f - Mathf.Exp((0f - num) * dt);
				_smoothPosition = Vector3.Lerp(_smoothPosition, val4, num2);
				Vector2 val5 = Vector2.ClampMagnitude(PointerMotion.Delta, 24f);
				Vector2 val6 = (WiresSmoothUIPlugin.DragPhysics.Value ? (-val5 * 0.17f) : Vector2.zero);
				val6 = Vector2.ClampMagnitude(val6, 4.25f);
				float target = (WiresSmoothUIPlugin.DragPhysics.Value ? ((0f - Mathf.Clamp(val5.x / 18f, -1f, 1f)) * Mathf.Max(0f, WiresSmoothUIPlugin.DragRotation.Value)) : 0f);
				float num3 = Mathf.Clamp(num * 0.6f, 7f, 22f);
				_physicsOffset.x = Spring(_physicsOffset.x, ref _physicsVelocity.x, val6.x, num3, 0.68f, dt);
				_physicsOffset.y = Spring(_physicsOffset.y, ref _physicsVelocity.y, val6.y, num3, 0.68f, dt);
				_rotation = Spring(_rotation, ref _rotationVelocity, target, num3 * 0.8f, 0.62f, dt);
				current.transform.position = _smoothPosition + new Vector3(_physicsOffset.x, _physicsOffset.y, 0f);
			}
			else
			{
				_smoothPosition = current.transform.position;
				_physicsOffset = Vector2.zero;
				_physicsVelocity = Vector2.zero;
				_rotation = 0f;
				_rotationVelocity = 0f;
			}
			current.transform.localScale = _baseScale * CurrentScale();
			current.transform.localRotation = _baseRotation * Quaternion.Euler(0f, 0f, _rotation);
			_applied = true;
		}

		private static float Spring(float current, ref float velocity, float target, float frequency, float damping, float dt)
		{
			float num = Mathf.Max(1f, frequency);
			float num2 = (target - current) * num * num - 2f * damping * num * velocity;
			velocity += num2 * dt;
			return current + velocity * dt;
		}

		private static float CurrentScale()
		{
			float num = Mathf.Max(0.01f, WiresSmoothUIPlugin.ItemAppearDuration.Value);
			if (_spawnTimer >= num)
			{
				return 1f;
			}
			float num2 = Mathf.Clamp01(_spawnTimer / num);
			float num3 = WiresSmoothUIPlugin.PopScale(num2, 0.88f);
			float num4 = Mathf.Sin(num2 * (float)Math.PI) * 0.025f;
			return num3 + num4;
		}

		internal static void Restore()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			if ((Object)(object)_current != (Object)null && _applied)
			{
				_current.transform.localScale = _baseScale;
				_current.transform.localRotation = _baseRotation;
			}
			_applied = false;
			_physicsOffset = Vector2.zero;
			_physicsVelocity = Vector2.zero;
			_rotation = 0f;
			_rotationVelocity = 0f;
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "SetupDragItem")]
	internal static class SmoothUIDragSetupPatch
	{
		[HarmonyPostfix]
		private static void Postfix(InventoryGui __instance)
		{
			DragAnimationSystem.NotifySetup(__instance);
		}
	}
	internal sealed class DynamicReticleSystem : MonoBehaviour
	{
		private enum AttackGroup
		{
			None,
			Spear,
			Magic,
			Other
		}

		public enum EasingMode
		{
			Linear,
			SineInOut,
			ExpoInOut
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		private static class HudAwakePatch
		{
			[HarmonyPostfix]
			private static void Postfix(Hud __instance)
			{
				if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<DynamicReticleSystem>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<DynamicReticleSystem>();
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
		private static class HudUpdateCrosshairPatch
		{
			private static void Postfix(Hud __instance, Player player, float bowDrawPercentage)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.UpdateHud(__instance, player, bowDrawPercentage);
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateStealth")]
		private static class HudUpdateStealthPatch
		{
			private static void Postfix(Hud __instance)
			{
				DisableStealthHud(__instance);
			}
		}

		[HarmonyPatch(typeof(Attack), "Start")]
		private static class AttackStartPatch
		{
			private static void Postfix(Attack __instance, Humanoid character, ItemData weapon, ref bool __result)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.OnAttackStarted(__instance, character, weapon, __result);
				}
			}
		}

		[HarmonyPatch(typeof(Attack), "OnAttackTrigger")]
		private static class AttackTriggerPatch
		{
			private static void Postfix(Attack __instance)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.OnAttackTriggered(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(Attack), "Stop")]
		private static class AttackStopPatch
		{
			private static void Postfix(Attack __instance)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.OnAttackStopped(__instance);
				}
			}
		}

		private const float VanillaStartScale = 1f;

		private const float VanillaEndScale = 0.15f;

		private const float VanillaCrosshairIdleAlpha = 0.5f;

		internal static DynamicReticleSystem Instance;

		private Image _customRing;

		private float _ringShownAt;

		private Hud _customRingHud;

		private float _crosshairVisibility;

		private bool _bowReleaseWaitingForZero;

		private float _lastBowDraw;

		private float _bowDrawAtRelease;

		private GameObject _lastHoverObject;

		private bool _lastHoverInteractable;

		private Attack _activeAttack;

		private ItemData _activeWeapon;

		private AttackGroup _activeGroup;

		private bool _activeReleased;

		private readonly Dictionary<string, float> _learnedReleaseTimes = new Dictionary<string, float>(StringComparer.Ordinal);

		private static readonly FieldRef<Player, List<MinorActionData>> ActionQueueRef = AccessTools.FieldRefAccess<Player, List<MinorActionData>>("m_actionQueue");

		private static readonly FieldRef<Attack, Humanoid> AttackCharacterRef = AccessTools.FieldRefAccess<Attack, Humanoid>("m_character");

		private static readonly FieldRef<Attack, float> AttackTimeRef = AccessTools.FieldRefAccess<Attack, float>("m_time");

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		internal static void Shutdown()
		{
			DynamicReticleSystem instance = Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				if ((Object)(object)instance._customRing != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)instance._customRing).gameObject);
				}
				instance._customRing = null;
				instance._customRingHud = null;
				instance._activeAttack = null;
				instance._activeWeapon = null;
				instance._activeGroup = AttackGroup.None;
				instance._activeReleased = false;
				instance._bowReleaseWaitingForZero = false;
				instance._crosshairVisibility = 0f;
				instance._lastHoverObject = null;
				instance._lastHoverInteractable = false;
			}
		}

		internal void UpdateHud(Hud hud, Player player, float bowDrawPercentage)
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Invalid comparison between Unknown and I4
			if ((Object)(object)hud == (Object)null || (Object)(object)player == (Object)null)
			{
				return;
			}
			bool flag = WiresSmoothUIPlugin.HudEnabled.Value && WiresSmoothUIPlugin.CrosshairAnimations.Value;
			bool flag2 = WiresSmoothUIPlugin.Enabled.Value && WiresSmoothUIPlugin.ProjectileReticle.Value;
			if (!flag && !flag2)
			{
				HideRing(hud);
				_crosshairVisibility = 0f;
				return;
			}
			if (flag2)
			{
				EnsureCustomRing(hud);
				if ((Object)(object)hud.m_crosshairBow != (Object)null)
				{
					((Component)hud.m_crosshairBow).gameObject.SetActive(false);
				}
			}
			else
			{
				HideRing(hud);
			}
			ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
			ItemData rightItem = ((Humanoid)player).RightItem;
			ItemData leftItem = ((Humanoid)player).LeftItem;
			if (flag)
			{
				UpdateNormalCrosshair(hud, player, rightItem, leftItem);
			}
			else
			{
				_crosshairVisibility = 0f;
			}
			if (!flag2)
			{
				return;
			}
			if (WiresSmoothUIPlugin.ProjectileReticle.Value && bowDrawPercentage > 0f)
			{
				if (_bowReleaseWaitingForZero && bowDrawPercentage < _bowDrawAtRelease - 0.01f)
				{
					_bowReleaseWaitingForZero = false;
				}
				_lastBowDraw = bowDrawPercentage;
				if (_bowReleaseWaitingForZero)
				{
					HideRing(hud);
				}
				else
				{
					RenderProgress(hud, bowDrawPercentage, useConfiguredEasing: true);
				}
				return;
			}
			if (bowDrawPercentage <= 0f && _bowReleaseWaitingForZero)
			{
				_bowReleaseWaitingForZero = false;
			}
			_lastBowDraw = 0f;
			if (!WiresSmoothUIPlugin.ProjectileReticle.Value)
			{
				HideRing(hud);
			}
			else if (currentWeapon == null || currentWeapon.m_shared == null)
			{
				HideRing(hud);
			}
			else if ((int)currentWeapon.m_shared.m_skillType == 14)
			{
				RenderCrossbow(hud, player, currentWeapon);
			}
			else if (IsDundr(currentWeapon))
			{
				RenderDundr(hud, player, currentWeapon);
			}
			else if (_activeAttack != null && _activeWeapon == currentWeapon)
			{
				RenderActiveAttack(hud);
			}
			else
			{
				HideRing(hud);
			}
		}

		private void UpdateNormalCrosshair(Hud hud, Player player, ItemData rightItem, ItemData leftItem)
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			Image crosshair = hud.m_crosshair;
			if ((Object)(object)crosshair == (Object)null)
			{
				return;
			}
			if (((Character)player).IsAttached() && (Object)(object)player.GetAttachCameraPoint() != (Object)null)
			{
				_crosshairVisibility = 0f;
				return;
			}
			bool flag = false;
			if (WiresSmoothUIPlugin.ShowHoverCrosshair.Value)
			{
				flag = (Object)(object)hud.m_hoverName != (Object)null && !string.IsNullOrEmpty(((TMP_Text)hud.m_hoverName).text);
				if (!flag)
				{
					GameObject hoverObject = ((Humanoid)player).GetHoverObject();
					if ((Object)(object)hoverObject != (Object)(object)_lastHoverObject)
					{
						_lastHoverObject = hoverObject;
						_lastHoverInteractable = false;
						if ((Object)(object)hoverObject != (Object)null)
						{
							try
							{
								_lastHoverInteractable = hoverObject.GetComponentInParent<Interactable>() != null;
							}
							catch
							{
								_lastHoverInteractable = false;
							}
						}
					}
					flag = _lastHoverInteractable;
				}
			}
			bool flag2 = ShouldShowForHeldItem(rightItem) || ShouldShowForHeldItem(leftItem);
			bool flag3 = (WiresSmoothUIPlugin.CrosshairActivator.Value && MapStatusVisibilitySystem.ActivatorHeld) || flag2 || flag;
			float value = WiresSmoothUIPlugin.CrosshairFade.Value;
			_crosshairVisibility = ((!(value <= 0f)) ? Mathf.MoveTowards(_crosshairVisibility, flag3 ? 1f : 0f, Time.unscaledDeltaTime / value) : (flag3 ? 1f : 0f));
			Color color;
			if (flag && WiresSmoothUIPlugin.CrosshairYellowHover.Value)
			{
				color = Color.yellow;
				color.a = _crosshairVisibility;
			}
			else
			{
				color = Color.white;
				color.a = 0.5f * _crosshairVisibility;
			}
			((Graphic)crosshair).color = color;
		}

		private bool ShouldShowForHeldItem(ItemData item)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			if (item == null || item.m_shared == null)
			{
				return false;
			}
			if (WiresSmoothUIPlugin.CrosshairWithRanged.Value && IsRangedWeaponForCrosshair(item))
			{
				return true;
			}
			ItemType itemType = item.m_shared.m_itemType;
			if (IsHammer(item) || (int)itemType == 19 || (int)itemType == 15)
			{
				return WiresSmoothUIPlugin.CrosshairWithTools.Value;
			}
			if (item.IsWeapon() && !IsRangedWeaponForCrosshair(item))
			{
				return WiresSmoothUIPlugin.CrosshairWithMelee.Value;
			}
			return false;
		}

		private static bool IsActualHeldWeaponOrTool(ItemData item)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			if (item == null || item.m_shared == null)
			{
				return false;
			}
			if (item.IsWeapon())
			{
				return true;
			}
			ItemType itemType = item.m_shared.m_itemType;
			if ((int)itemType != 19)
			{
				return (int)itemType == 15;
			}
			return true;
		}

		private static bool IsHammer(ItemData item)
		{
			if (item != null && item.m_shared != null)
			{
				return string.Equals(item.m_shared.m_name, "$item_hammer", StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private void RenderCrossbow(Hud hud, Player player, ItemData weapon)
		{
			if (TryGetReloadProgress(player, weapon, out var progress))
			{
				RenderProgress(hud, progress);
			}
			else if (((Humanoid)player).IsWeaponLoaded())
			{
				RenderProgress(hud, 1f);
			}
			else
			{
				HideRing(hud);
			}
		}

		private void RenderDundr(Hud hud, Player player, ItemData weapon)
		{
			if (TryGetReloadProgress(player, weapon, out var progress))
			{
				RenderProgress(hud, progress);
			}
			else if (((Humanoid)player).IsWeaponLoaded())
			{
				RenderProgress(hud, 1f);
			}
			else if (_activeAttack != null && _activeWeapon == weapon && !_activeReleased)
			{
				RenderActiveAttack(hud);
			}
			else
			{
				HideRing(hud);
			}
		}

		private bool TryGetReloadProgress(Player player, ItemData weapon, out float progress)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			progress = 0f;
			List<MinorActionData> list = ActionQueueRef.Invoke(player);
			if (list == null)
			{
				return false;
			}
			for (int i = 0; i < list.Count; i++)
			{
				MinorActionData val = list[i];
				if (val != null && (int)val.m_type == 2 && (val.m_item == null || val.m_item == weapon))
				{
					progress = ((val.m_duration <= 0f) ? 1f : Mathf.Clamp01(val.m_time / val.m_duration));
					return true;
				}
			}
			return false;
		}

		private void RenderActiveAttack(Hud hud)
		{
			if (_activeAttack == null)
			{
				HideRing(hud);
			}
			else if (_activeReleased)
			{
				if (IsSustainedBurstAttack(_activeAttack))
				{
					RenderProgress(hud, 1f);
				}
				else
				{
					HideRing(hud);
				}
			}
			else
			{
				float attackElapsed = GetAttackElapsed(_activeAttack);
				float expectedReleaseSeconds = GetExpectedReleaseSeconds(_activeAttack, _activeWeapon, _activeGroup);
				float rawProgress = ((expectedReleaseSeconds <= 0.001f) ? 0f : Mathf.Clamp01(attackElapsed / expectedReleaseSeconds));
				RenderProgress(hud, rawProgress);
			}
		}

		private void RenderProgress(Hud hud, float rawProgress)
		{
			RenderProgress(hud, rawProgress, useConfiguredEasing: true);
		}

		private void RenderProgress(Hud hud, float rawProgress, bool useConfiguredEasing)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			EnsureCustomRing(hud);
			if ((Object)(object)_customRing == (Object)null)
			{
				return;
			}
			rawProgress = Mathf.Clamp01(rawProgress);
			if (rawProgress <= 0f)
			{
				((Component)_customRing).gameObject.SetActive(false);
				return;
			}
			float num = (useConfiguredEasing ? Ease(rawProgress) : rawProgress);
			float num2 = Mathf.Lerp(GetStartScale(), GetEndScale(), num);
			if (!((Component)_customRing).gameObject.activeSelf)
			{
				_ringShownAt = Time.unscaledTime;
			}
			((Component)_customRing).gameObject.SetActive(true);
			((Component)_customRing).transform.localScale = new Vector3(num2, num2, num2);
			Color color = Color.Lerp(new Color(1f, 1f, 1f, 0f), Color.yellow, num);
			float value = WiresSmoothUIPlugin.ReticleFadeIn.Value;
			if (value > 0f)
			{
				color.a *= Mathf.Clamp01((Time.unscaledTime - _ringShownAt) / value);
			}
			((Graphic)_customRing).color = color;
		}

		internal void OnAttackStarted(Attack attack, Humanoid character, ItemData weapon, bool started)
		{
			if (started && WiresSmoothUIPlugin.Enabled.Value && WiresSmoothUIPlugin.ProjectileReticle.Value && attack != null && !((Object)(object)character != (Object)(object)Player.m_localPlayer) && weapon != null && weapon.m_shared != null)
			{
				AttackGroup attackGroup = ClassifyAttack(weapon, attack);
				if (attackGroup != AttackGroup.None)
				{
					_activeAttack = attack;
					_activeWeapon = weapon;
					_activeGroup = attackGroup;
					_activeReleased = false;
				}
			}
		}

		internal void OnAttackTriggered(Attack attack)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			if (!WiresSmoothUIPlugin.Enabled.Value || !WiresSmoothUIPlugin.ProjectileReticle.Value || attack == null)
			{
				return;
			}
			Humanoid attackCharacter = GetAttackCharacter(attack);
			if ((Object)(object)attackCharacter != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			ItemData currentWeapon = attackCharacter.GetCurrentWeapon();
			if (currentWeapon == null || currentWeapon.m_shared == null)
			{
				return;
			}
			SkillType skillType = currentWeapon.m_shared.m_skillType;
			if ((int)skillType == 8)
			{
				HideRing(Hud.instance);
				_bowReleaseWaitingForZero = _lastBowDraw > 0f;
				_bowDrawAtRelease = _lastBowDraw;
			}
			else if ((int)skillType == 14)
			{
				HideRing(Hud.instance);
			}
			else if (attack == _activeAttack)
			{
				float attackElapsed = GetAttackElapsed(attack);
				if (attackElapsed > 0.03f && attackElapsed < 10f)
				{
					_learnedReleaseTimes[GetAttackKey(attack, _activeWeapon)] = attackElapsed;
				}
				_activeReleased = true;
				if (!IsSustainedBurstAttack(attack))
				{
					HideRing(Hud.instance);
				}
			}
		}

		internal void OnAttackStopped(Attack attack)
		{
			if (attack != null && attack == _activeAttack)
			{
				if (_activeReleased && IsSustainedBurstAttack(attack))
				{
					HideRing(Hud.instance);
				}
				_activeAttack = null;
				_activeWeapon = null;
				_activeGroup = AttackGroup.None;
				_activeReleased = false;
			}
		}

		private AttackGroup ClassifyAttack(ItemData weapon, Attack attack)
		{
			//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_0023: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (weapon == null || weapon.m_shared == null || !IsProjectileAttack(attack))
			{
				return AttackGroup.None;
			}
			SkillType skillType = weapon.m_shared.m_skillType;
			if ((int)skillType == 8 || (int)skillType == 14)
			{
				return AttackGroup.None;
			}
			if ((int)skillType == 5)
			{
				return AttackGroup.Spear;
			}
			if (IsMagicSkill(skillType))
			{
				if (IsUtilityMagicStaff(weapon))
				{
					return AttackGroup.None;
				}
				return AttackGroup.Magic;
			}
			return AttackGroup.Other;
		}

		private bool IsRangedWeaponForCrosshair(ItemData weapon)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (weapon == null || weapon.m_shared == null)
			{
				return false;
			}
			SkillType skillType = weapon.m_shared.m_skillType;
			if ((int)skillType == 8 || (int)skillType == 14 || (int)skillType == 5)
			{
				return true;
			}
			if (IsMagicSkill(skillType) && IsUtilityMagicStaff(weapon))
			{
				return false;
			}
			if (!IsProjectileAttack(weapon.m_shared.m_attack))
			{
				return IsProjectileAttack(weapon.m_shared.m_secondaryAttack);
			}
			return true;
		}

		private float GetExpectedReleaseSeconds(Attack attack, ItemData weapon, AttackGroup group)
		{
			string attackKey = GetAttackKey(attack, weapon);
			if (_learnedReleaseTimes.TryGetValue(attackKey, out var value) && value > 0.03f)
			{
				return value;
			}
			return group switch
			{
				AttackGroup.Spear => 0.55f, 
				AttackGroup.Magic => 0.42f, 
				_ => 0.4f, 
			};
		}

		private float GetScaleForRawProgress(float rawProgress)
		{
			float num = Ease(Mathf.Clamp01(rawProgress));
			return Mathf.Lerp(GetStartScale(), GetEndScale(), num);
		}

		private float GetStartScale()
		{
			return 1f;
		}

		private float GetEndScale()
		{
			return 0.15f;
		}

		private float Ease(float t)
		{
			t = Mathf.Clamp01(t);
			switch (WiresSmoothUIPlugin.ReticleEasing.Value)
			{
			case EasingMode.Linear:
				return t;
			case EasingMode.ExpoInOut:
				if (t <= 0f)
				{
					return 0f;
				}
				if (t >= 1f)
				{
					return 1f;
				}
				if (!(t < 0.5f))
				{
					return (2f - Mathf.Pow(2f, -20f * t + 10f)) / 2f;
				}
				return Mathf.Pow(2f, 20f * t - 10f) / 2f;
			default:
				return (0f - (Mathf.Cos((float)Math.PI * t) - 1f)) / 2f;
			}
		}

		private static bool IsSustainedBurstAttack(Attack attack)
		{
			if (attack != null)
			{
				return attack.m_projectileBursts > 1;
			}
			return false;
		}

		private static string GetAttackKey(Attack attack, ItemData weapon)
		{
			string text = ((weapon != null && weapon.m_shared != null) ? (weapon.m_shared.m_name ?? string.Empty) : string.Empty);
			string text2 = ((attack != null) ? (attack.m_attackAnimation ?? string.Empty) : string.Empty);
			return text + "|" + text2 + "|" + ((attack != null) ? ((object)Unsafe.As<AttackType, AttackType>(ref attack.m_attackType)/*cast due to .constrained prefix*/).ToString() : string.Empty);
		}

		private static float GetAttackElapsed(Attack attack)
		{
			if (attack != null)
			{
				return AttackTimeRef.Invoke(attack);
			}
			return 0f;
		}

		private static Humanoid GetAttackCharacter(Attack attack)
		{
			if (attack != null)
			{
				return AttackCharacterRef.Invoke(attack);
			}
			return null;
		}

		private static bool IsProjectileAttack(Attack attack)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			if (attack != null)
			{
				if ((int)attack.m_attackType != 2)
				{
					return (int)attack.m_attackType == 5;
				}
				return true;
			}
			return false;
		}

		private static bool IsMagicSkill(SkillType skill)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)skill != 9)
			{
				return (int)skill == 10;
			}
			return true;
		}

		private static bool IsDundr(ItemData weapon)
		{
			if (weapon != null && weapon.m_shared != null)
			{
				return string.Equals(weapon.m_shared.m_name, "$item_staff_lightning", StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private static bool IsUtilityMagicStaff(ItemData weapon)
		{
			if (weapon == null || weapon.m_shared == null)
			{
				return false;
			}
			switch ((weapon.m_shared.m_name ?? string.Empty).ToLowerInvariant())
			{
			case "$item_staffshield":
			case "$item_staffskeleton":
			case "$item_staffredtroll":
			case "$item_staff_frostorbs":
			case "$item_staff_spiritcaller":
				return true;
			default:
				return false;
			}
		}

		internal static void DisableStealthHud(Hud hud)
		{
			if (!((Object)(object)Instance == (Object)null) && WiresSmoothUIPlugin.HudEnabled.Value && WiresSmoothUIPlugin.CrosshairAnimations.Value && WiresSmoothUIPlugin.DisableStealthIndicator.Value && !((Object)(object)hud == (Object)null))
			{
				if ((Object)(object)hud.m_targetedAlert != (Object)null)
				{
					hud.m_targetedAlert.SetActive(false);
				}
				if ((Object)(object)hud.m_targeted != (Object)null)
				{
					hud.m_targeted.SetActive(false);
				}
				if ((Object)(object)hud.m_hidden != (Object)null)
				{
					hud.m_hidden.SetActive(false);
				}
				if ((Object)(object)hud.m_stealthBar != (Object)null)
				{
					((Component)hud.m_stealthBar).gameObject.SetActive(false);
				}
			}
		}

		private void EnsureCustomRing(Hud hud)
		{
			if (!((Object)(object)hud == (Object)null) && !((Object)(object)hud.m_crosshairBow == (Object)null) && (!((Object)(object)_customRing != (Object)null) || !((Object)(object)_customRingHud == (Object)(object)hud)))
			{
				if ((Object)(object)_customRing != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_customRing).gameObject);
				}
				_customRingHud = hud;
				_customRing = Object.Instantiate<Image>(hud.m_crosshairBow, ((Component)hud.m_crosshairBow).transform.parent, false);
				((Object)_customRing).name = "DynamicReticleRing";
				((Graphic)_customRing).raycastTarget = false;
				((Component)_customRing).transform.SetSiblingIndex(((Component)hud.m_crosshairBow).transform.GetSiblingIndex() + 1);
				((Component)_customRing).gameObject.SetActive(false);
			}
		}

		private void HideRing(Hud hud)
		{
			if ((Object)(object)_customRing != (Object)null)
			{
				((Component)_customRing).gameObject.SetActive(false);
			}
		}
	}
	internal static class EmptyMaterialSlots
	{
		[HarmonyPatch(typeof(InventoryGui), "Awake")]
		private static class InventoryGuiAwake
		{
			private static void Postfix(InventoryGui __instance)
			{
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				CraftingMotion.ResetShown();
				if (__instance.m_recipeRequirementList != null)
				{
					GameObject[] recipeRequirementList = __instance.m_recipeRequirementList;
					foreach (GameObject val in recipeRequirementList)
					{
						Image val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Image>() : null);
						if ((Object)(object)val2 == (Object)null || (Object)(object)val.GetComponent<MaterialSlotWatcher>() != (Object)null)
						{
							continue;
						}
						MaterialSlotWatcher materialSlotWatcher = val.AddComponent<MaterialSlotWatcher>();
						materialSlotWatcher.Frame = val2;
						foreach (Transform item in val.transform)
						{
							((Component)item).gameObject.AddComponent<MaterialPartWatcher>().Slot = materialSlotWatcher;
						}
						materialSlotWatcher.Apply();
					}
				}
				Image minStationLevelIcon = __instance.m_minStationLevelIcon;
				Transform val3 = (((Object)(object)minStationLevelIcon != (Object)null) ? ((Component)minStationLevelIcon).transform.parent : null);
				if ((Object)(object)val3 != (Object)null && ((Object)val3).name == "level" && (Object)(object)((Component)minStationLevelIcon).GetComponent<LevelIconWatcher>() == (Object)null)
				{
					CanvasGroup val4 = ((Component)val3).GetComponent<CanvasGroup>();
					if ((Object)(object)val4 == (Object)null)
					{
						val4 = ((Component)val3).gameObject.AddComponent<CanvasGroup>();
					}
					LevelIconWatcher levelIconWatcher = ((Component)minStationLevelIcon).gameObject.AddComponent<LevelIconWatcher>();
					levelIconWatcher.Box = val4;
					levelIconWatcher.Apply();
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Show")]
		private static class InventoryGuiShow
		{
			private static void Postfix()
			{
				Refresh();
			}
		}

		internal static bool On
		{
			get
			{
				if (WiresSmoothUIPlugin.Enabled.Value)
				{
					return WiresSmoothUIPlugin.HideEmptyMaterialSlots.Value;
				}
				return false;
			}
		}

		internal static void Refresh()
		{
			InventoryGui instance = InventoryGui.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				MaterialSlotWatcher[] componentsInChildren = ((Component)instance).GetComponentsInChildren<MaterialSlotWatcher>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].Apply();
				}
				LevelIconWatcher[] componentsInChildren2 = ((Component)instance).GetComponentsInChildren<LevelIconWatcher>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					componentsInChildren2[i].Apply();
				}
			}
		}
	}
	internal sealed class MaterialSlotWatcher : MonoBehaviour
	{
		internal Image Frame;

		private bool _hidFrame;

		internal bool Empty
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				foreach (Transform item in ((Component)this).transform)
				{
					if (((Component)item).gameObject.activeSelf)
					{
						return false;
					}
				}
				return true;
			}
		}

		internal void Apply()
		{
			if (!((Object)(object)Frame == (Object)null))
			{
				bool flag = !EmptyMaterialSlots.On || !Empty;
				if (!flag && ((Behaviour)Frame).enabled)
				{
					((Behaviour)Frame).enabled = false;
					_hidFrame = true;
				}
				else if (flag && _hidFrame)
				{
					((Behaviour)Frame).enabled = true;
					_hidFrame = false;
				}
			}
		}

		private void OnTransformChildrenChanged()
		{
			Apply();
		}
	}
	internal sealed class MaterialPartWatcher : MonoBehaviour
	{
		internal MaterialSlotWatcher Slot;

		private void OnEnable()
		{
			if ((Object)(object)Slot != (Object)null)
			{
				Slot.Apply();
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)Slot != (Object)null)
			{
				Slot.Apply();
			}
		}
	}
	internal sealed class LevelIconWatcher : MonoBehaviour
	{
		internal CanvasGroup Box;

		internal void Apply()
		{
			if (!((Object)(object)Box == (Object)null))
			{
				bool flag = ((Component)this).gameObject.activeSelf || !EmptyMaterialSlots.On;
				if (!flag)
				{
					UiMotion.Cancel(((Component)Box).transform);
				}
				Box.alpha = (flag ? 1f : 0f);
				Box.blocksRaycasts = flag;
			}
		}

		private void OnEnable()
		{
			Apply();
		}

		private void OnDisable()
		{
			Apply();
		}
	}
	internal static class HotbarAccess
	{
		private static readonly FieldInfo ElementsField = AccessTools.Field(typeof(HotkeyBar), "m_elements");

		private static FieldInfo _queued;

		private static FieldInfo _equiped;

		internal static HotkeyBar[] Bars()
		{
			return Object.FindObjectsByType<HotkeyBar>((FindObjectsSortMode)0);
		}

		internal static IList Elements(HotkeyBar bar)
		{
			if (!((Object)(object)bar != (Object)null))
			{
				return null;
			}
			return ElementsField?.GetValue(bar) as IList;
		}

		internal static GameObject Queued(object element)
		{
			return Get(ref _queued, element, "m_queued");
		}

		internal static GameObject Equiped(object element)
		{
			return Get(ref _equiped, element, "m_equiped");
		}

		private static GameObject Get(ref FieldInfo field, object element, string name)
		{
			if (element == null)
			{
				return null;
			}
			if (field == null)
			{
				field = AccessTools.Field(element.GetType(), name);
			}
			object? obj = field?.GetValue(element);
			return (GameObject)((obj is GameObject) ? obj : null);
		}
	}
	internal static class EquipFillSystem
	{
		private sealed class Original
		{
			internal Type Type;

			internal FillMethod Method;

			internal int Origin;

			internal float Amount;
		}

		private static readonly FieldInfo GridElementsField = AccessTools.Field(typeof(InventoryGrid), "m_elements");

		private static readonly Dictionary<Image, Original> Filled = new Dictionary<Image, Original>();

		private static readonly Dictionary<Image, bool> HiddenEquip = new Dictionary<Image, bool>();

		private static readonly HashSet<Image> Touched = new HashSet<Image>();

		private static readonly List<Image> Release = new List<Image>();

		private static HotkeyBar[] _bars = (HotkeyBar[])(object)new HotkeyBar[0];

		private static bool _active;

		internal static bool Busy => _active;

		private static bool On
		{
			get
			{
				if (WiresSmoothUIPlugin.Enabled.Value)
				{
					return WiresSmoothUIPlugin.EquipProgressFill.Value;
				}
				return false;
			}
		}

		internal static void Begin()
		{
			if (On)
			{
				_bars = HotbarAccess.Bars();
				_active = true;
				SmoothUIDriver.Wake();
			}
		}

		internal static void Tick()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if (!_active)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!On || (Object)(object)localPlayer == (Object)null)
			{
				RestoreAll();
				return;
			}
			string text = default(string);
			float progress = default(float);
			MinorActionData val = default(MinorActionData);
			localPlayer.GetActionProgress(ref text, ref progress, ref val);
			if (val == null || (int)val.m_type == 2)
			{
				RestoreAll();
				return;
			}
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			Touched.Clear();
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_playerGrid != (Object)null && ((Component)instance.m_playerGrid).gameObject.activeInHierarchy && GridElementsField?.GetValue(instance.m_playerGrid) is List<InventoryElement> list)
			{
				foreach (InventoryElement item in list)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item.m_queued == (Object)null) && ((Behaviour)item.m_queued).enabled)
					{
						ItemData itemAt = inventory.GetItemAt(item.Position.x, item.Position.y);
						Apply(item.m_queued, item.m_equiped, hotbar: false, itemAt, val, progress);
					}
				}
			}
			HotkeyBar[] bars = _bars;
			foreach (HotkeyBar val2 in bars)
			{
				if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).isActiveAndEnabled)
				{
					continue;
				}
				IList list2 = HotbarAccess.Elements(val2);
				if (list2 == null)
				{
					continue;
				}
				for (int j = 0; j < list2.Count; j++)
				{
					GameObject val3 = HotbarAccess.Queued(list2[j]);
					if (!((Object)(object)val3 == (Object)null) && val3.activeInHierarchy)
					{
						GameObject val4 = HotbarAccess.Equiped(list2[j]);
						Apply(val3.GetComponent<Image>(), ((Object)(object)val4 != (Object)null) ? val4.GetComponent<Image>() : null, hotbar: true, inventory.GetItemAt(j, 0), val, progress);
					}
				}
			}
			Release.Clear();
			foreach (Image key in Filled.Keys)
			{
				if (!Touched.Contains(key))
				{
					Release.Add(key);
				}
			}
			foreach (Image key2 in HiddenEquip.Keys)
			{
				if (!Touched.Contains(key2))
				{
					Release.Add(key2);
				}
			}
			foreach (Image item2 in Release)
			{
				RestoreImage(item2);
			}
		}

		private static void Apply(Image queued, Image equiped, bool hotbar, ItemData item, MinorActionData data, float progress)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)queued == (Object)null || item == null)
			{
				return;
			}
			bool equipped = item.m_equipped;
			float num = Mathf.SmoothStep(0f, 1f, progress);
			float fillAmount = ((data.m_item != item) ? (equipped ? 1f : 0f) : (((int)data.m_type == 1) ? (1f - num) : num));
			if (!Filled.ContainsKey(queued))
			{
				Filled.Add(queued, new Original
				{
					Type = queued.type,
					Method = queued.fillMethod,
					Origin = queued.fillOrigin,
					Amount = queued.fillAmount
				});
			}
			queued.type = (Type)3;
			queued.fillMethod = (FillMethod)1;
			queued.fillOrigin = 0;
			queued.fillAmount = fillAmount;
			Touched.Add(queued);
			if (equipped && (Object)(object)equiped != (Object)null)
			{
				if (!HiddenEquip.ContainsKey(equiped))
				{
					HiddenEquip.Add(equiped, hotbar);
				}
				((Behaviour)equiped).enabled = false;
				Touched.Add(equiped);
			}
		}

		private static void RestoreImage(Image image)
		{
			//IL_001a: 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)
			if (Filled.TryGetValue(image, out var value))
			{
				if ((Object)(object)image != (Object)null)
				{
					image.type = value.Type;
					image.fillMethod = value.Method;
					image.fillOrigin = value.Origin;
					image.fillAmount = value.Amount;
				}
				Filled.Remove(image);
			}
			if (HiddenEquip.TryGetValue(image, out var value2))
			{
				if (value2 && (Object)(object)image != (Object)null)
				{
					((Behaviour)image).enabled = true;
				}
				HiddenEquip.Remove(image);
			}
		}

		internal static void RestoreAll()
		{
			Release.Clear();
			Release.AddRange(Filled.Keys);
			Release.AddRange(HiddenEquip.Keys);
			foreach (Image item in Release)
			{
				RestoreImage(item);
			}
			Release.Clear();
			Touched.Clear();
			_active = false;
		}
	}
	[HarmonyPatch(typeof(Hud), "Awake")]
	internal static class SmoothUIHudAwakePatch
	{
		[HarmonyPostfix]
		private static void Postfix(Hud __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				if ((Object)(object)((Component)__instance).GetComponent<DynamicReticleSystem>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<DynamicReticleSystem>();
				}
				if ((Object)(object)((Component)__instance).GetComponent<SmoothUIHudVisibilityReworkDriver>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<SmoothUIHudVisibilityReworkDriver>().Initialize(__instance);
				}
			}
		}
	}
	internal static class HudVisibilityReworkSystem
	{
		internal sealed class CanvasFadeGate
		{
			private readonly GameObject _root;

			private readonly CanvasGroup _group;

			private readonly float _baseAlpha;

			private readonly bool _baseInteractable;

			private readonly bool _baseBlocksRaycasts;

			private readonly bool _touchOnlyRaycasts;

			private readonly bool _preserveInteractable;

			private float _alpha;

			private float _hideTimer;

			internal GameObject Root => _root;

			internal bool IsAlive
			{
				get
				{
					if ((Object)(object)_root != (Object)null)
					{
						return (Object)(object)_group != (Object)null;
					}
					return false;
				}
			}

			internal CanvasFadeGate(GameObject root, bool startHidden, bool touchOnlyRaycasts = false, bool preserveInteractable = false)
			{
				_root = root;
				_touchOnlyRaycasts = touchOnlyRaycasts;
				_preserveInteractable = preserveInteractable;
				if (!((Object)(object)_root == (Object)null))
				{
					_group = _root.GetComponent<CanvasGroup>();
					if ((Object)(object)_group == (Object)null)
					{
						_group = _root.AddComponent<CanvasGroup>();
					}
					_baseAlpha = _group.alpha;
					_baseInteractable = _group.interactable;
					_baseBlocksRaycasts = _group.blocksRaycasts;
					_alpha = (startHidden ? 0f : _baseAlpha);
					_hideTimer = (startHidden ? 999f : 0f);
					Apply();
				}
			}

			internal void Update(bool wanted, float dt, float hideDelay = 0f, float showSeconds = 0.2f, float hideSeconds = 0.2f)
			{
				if (!IsAlive)
				{
					return;
				}
				if (wanted)
				{
					_hideTimer = 0f;
				}
				else
				{
					_hideTimer += dt;
				}
				int num;
				float num2;
				if (!wanted)
				{
					num = ((_hideTimer < Mathf.Max(0f, hideDelay)) ? 1 : 0);
					if (num == 0)
					{
						num2 = 0f;
						goto IL_0050;
					}
				}
				else
				{
					num = 1;
				}
				num2 = _baseAlpha;
				goto IL_0050;
				IL_0050:
				float num3 = num2;
				float num4 = ((num != 0) ? Mathf.Max(0.01f, showSeconds) : Mathf.Max(0.01f, hideSeconds));
				float num5 = Mathf.Max(0.01f, _baseAlpha) / num4;
				_alpha = ((num4 <= 0.01f) ? num3 : Mathf.MoveTowards(_alpha, num3, num5 * dt));
				Apply();
			}

			internal void Restore()
			{
				if (IsAlive)
				{
					_hideTimer = 0f;
					_alpha = _baseAlpha;
					Apply();
				}
			}

			private void Apply()
			{
				if (IsAlive)
				{
					if (Mathf.Abs(_group.alpha - _alpha) > 0.0005f)
					{
						_group.alpha = _alpha;
					}
					bool flag = _alpha > 0.02f;
					bool flag2 = (_preserveInteractable ? _baseInteractable : (flag && _baseInteractable));
					if (_group.interactable != flag2)
					{
						_group.interactable = flag2;
					}
					bool flag3 = flag && ((!_touchOnlyRaycasts) ? _baseBlocksRaycasts : (_baseBlocksRaycasts && ZInput.IsTouchActive()));
					if (_group.blocksRaycasts != flag3)
					{
						_group.blocksRaycasts = flag3;
					}
				}
			}
		}

		internal sealed class GraphicFadeSet
		{
			private sealed class Target
			{
				internal Graphic Graphic;

				internal float BaseRendererAlpha;

				internal bool BaseRaycastTarget;
			}

			private readonly List<Target> _targets = new List<Target>();

			private float _factor;

			private float _hideTimer;

			internal bool IsEmpty => _targets.Count == 0;

			internal bool IsFullyVisible => _factor >= 0.999f;

			internal bool IsFullyHidden => _factor <= 0.001f;

			internal GraphicFadeSet(IEnumerable<Graphic> graphics, bool startHidden)
			{
				HashSet<Graphic> hashSet = new HashSet<Graphic>();
				if (graphics != null)
				{
					foreach (Graphic graphic in graphics)
					{
						if (!((Object)(object)graphic == (Object)null) && hashSet.Add(graphic))
						{
							_targets.Add(new Target
							{
								Graphic = graphic,
								BaseRendererAlpha = (((Object)(object)graphic.canvasRenderer != (Object)null) ? graphic.canvasRenderer.GetAlpha() : 1f),
								BaseRaycastTarget = graphic.raycastTarget
							});
						}
					}
				}
				_factor = (startHidden ? 0f : 1f);
				_hideTimer = (startHidden ? 999f : 0f);
				Apply();
			}

			internal void Update(bool wanted, float dt, float hideDelay = 0f, float fadeSeconds = 0.2f)
			{
				if (_targets.Count != 0)
				{
					if (wanted)
					{
						_hideTimer = 0f;
					}
					else
					{
						_hideTimer += dt;
					}
					float num = ((wanted || _hideTimer < Mathf.Max(0f, hideDelay)) ? 1f : 0f);
					_factor = Mathf.MoveTowards(_factor, num, (fadeSeconds <= 0f) ? 1f : (dt / fadeSeconds));
					Apply();
				}
			}

			internal void Restore()
			{
				if (_targets.Count != 0)
				{
					_hideTimer = 0f;
					_factor = 1f;
					Apply();
				}
			}

			private void Apply()
			{
				bool flag = _factor > 0.02f;
				for (int i = 0; i < _targets.Count; i++)
				{
					Target target = _targets[i];
					Graphic graphic = target.Graphic;
					if ((Object)(object)graphic == (Object)null)
					{
						continue;
					}
					if ((Object)(object)graphic.canvasRenderer != (Object)null)
					{
						float num = target.BaseRendererAlpha * _factor;
						if (Mathf.Abs(graphic.canvasRenderer.GetAlpha() - num) > 0.0005f)
						{
							graphic.canvasRenderer.SetAlpha(num);
						}
					}
					bool flag2 = flag && target.BaseRaycastTarget;
					if (graphic.raycastTarget != flag2)
					{
						graphic.raycastTarget = flag2;
					}
				}
			}
		}

		internal const float FadeSeconds = 0.2f;

		internal const float HotbarHideDelay = 1f;

		internal const float ResourceHideDelay = 1f;

		internal const float ForsakenPreviewSeconds = 5f;

		internal const float FoodRecentRevealSeconds = 1f;

		internal const float FoodReplaceableRevealSeconds = 1f;

		internal const float FoodExpiryFlashSeconds = 60f;

		internal const float HotbarInstantEquipRevealSeconds = 0.75f;

		internal const float HotbarPostActionHoldSeconds = 0.25f;

		private static readonly FieldRef<HotkeyBar, List<ItemData>> HotkeyItems = AccessTools.FieldRefAccess<HotkeyBar, List<ItemData>>("m_items");

		private static readonly FieldRef<Humanoid, HashSet<StatusEffect>> EquipmentStatusEffects = AccessTools.FieldRefAccess<Humanoid, HashSet<StatusEffect>>("m_equipmentStatusEffects");

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

		private static readonly Dictionary<int, Sprite> ForsakenUnavailableSprites = new Dictionary<int, Sprite>();

		private static readonly List<Texture2D> ForsakenUnavailableTextures = new List<Texture2D>();

		private static SmoothUIHudVisibilityReworkDriver _driver;

		private static float _foodRevealUntil = -999f;

		internal static bool FoodRecentlyEaten => Time.unscaledTime < _foodRevealUntil;

		internal static void Register(SmoothUIHudVisibilityReworkDriver driver)
		{
			_driver = driver;
		}

		internal static void Unregister(SmoothUIHudVisibilityReworkDriver driver)
		{
			if ((Object)(object)_driver == (Object)(object)driver)
			{
				_driver = null;
			}
		}

		internal static void Shutdown()
		{
			_driver?.RestoreEverything();
			_driver = null;
			EquipmentEffectHashes.Clear();
			ClearForsakenUnavailableSprites();
			_foodRevealUntil = -999f;
		}

		internal static void NotifyFoodEaten(Player player)
		{
			if (!((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer))
			{
				_foodRevealUntil = Time.unscaledTime + 1f;
			}
		}

		internal static bool IsCombatRelevant(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			if (!player.IsTargeted())
			{
				return player.IsSensed();
			}
			return true;
		}

		internal static ItemData ActiveEquipActionItem(Player player)
		{
			//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)
			//IL_0033: Invalid comparison between Unknown and I4
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			string text = default(string);
			float num = default(float);
			MinorActionData val = default(MinorActionData);
			player.GetActionProgress(ref text, ref num, ref val);
			if (val == null || val.m_item == null)
			{
				return null;
			}
			if ((int)val.m_type != 0 && (int)val.m_type != 1)
			{
				return null;
			}
			return val.m_item;
		}

		internal static void NotifyHotbarEquipmentChanged()
		{
			_driver?.NotifyHotbarEquipmentChanged();
		}

		internal static void FilterPermanentEquipmentEffects(List<StatusEffect> effects)
		{
			if (effects == null || !WiresSmoothUIPlugin.Enabled.Value || !WiresSmoothUIPlugin.HidePermanentStatusEffects.Value)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			EquipmentEffectHashes.Clear();
			HashSet<StatusEffect> hashSet;
			try
			{
				hashSet = EquipmentStatusEffects.Invoke((Humanoid)(object)localPlayer);
			}
			catch
			{
				return;
			}
			if (hashSet == null || hashSet.Count == 0)
			{
				return;
			}
			foreach (StatusEffect item in hashSet)
			{
				if ((Object)(object)item != (Object)null)
				{
					EquipmentEffectHashes.Add(item.NameHash());
				}
			}
			if (EquipmentEffectHashes.Count == 0)
			{
				return;
			}
			for (int num = effects.Count - 1; num >= 0; num--)
			{
				StatusEffect val = effects[num];
				if ((Object)(object)val != (Object)null && EquipmentEffectHashes.Contains(val.NameHash()))
				{
					effects.RemoveAt(num);
				}
			}
		}

		internal static Sprite GetForsakenUnavailableSprite(Sprite source)
		{
			if ((Object)(object)source == (Object)null)
			{
				return null;
			}
			int instanceID = ((Object)source).GetInstanceID();
			if (ForsakenUnavailableSprites.TryGetValue(instanceID, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Sprite val = CreateForsakenUnavailableSprite(source);
			if ((Object)(object)val != (Object)null)
			{
				ForsakenUnavailableSprites[instanceID] = val;
			}
			return val ?? source;
		}

		private static Sprite CreateForsakenUnavailableSprite(Sprite source)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = (((Object)(object)source != (Object)null) ? source.texture : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			RenderTexture val2 = null;
			RenderTexture active = null;
			Texture2D val3 = null;
			try
			{
				Rect textureRect = source.te