Decompiled source of VanillaInventoryPlus v1.3.3

BepInEx/plugins/VanillaInventoryPlus/VanillaInventoryPlus.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Sprites;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VanillaInventoryPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: AssemblyInformationalVersion("1.3.3+e6ad2e5d21e201b02079d6ddfd4e617c70c7bf50")]
[assembly: AssemblyProduct("VanillaInventoryPlus")]
[assembly: AssemblyTitle("VanillaInventoryPlus")]
[assembly: AssemblyVersion("1.3.3.0")]
internal sealed class ConfigurationManagerAttributes
{
	public int? Order;

	public bool? Browsable;
}
namespace VanillaInventoryPlus;

internal static class PlayerSortNameButton
{
	private static Sprite _icon;

	internal static Sprite GetIconSprite()
	{
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_name.png");
		}
		return _icon;
	}

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_PlayerSortName", GetIconSprite(), buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_name", "$vit_sort_name_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = PlayerSortState.GetNextDirection(ContainerSortMode.Name, defaultAscending: true);
			PlayerInventorySorter.Sort(instance, ContainerSortMode.Name, nextDirection);
			PlayerSortState.Set(ContainerSortMode.Name, nextDirection);
		}
	}
}
internal static class PlayerSortTypeButton
{
	private static Sprite _icon;

	internal static Sprite GetIconSprite()
	{
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_type_thin.png");
		}
		return _icon;
	}

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_PlayerSortType", GetIconSprite(), buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_type", "$vit_sort_type_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = PlayerSortState.GetNextDirection(ContainerSortMode.Type, defaultAscending: true);
			PlayerInventorySorter.Sort(instance, ContainerSortMode.Type, nextDirection);
			PlayerSortState.Set(ContainerSortMode.Type, nextDirection);
		}
	}
}
internal static class PlayerSortWeightButton
{
	private static Sprite _icon;

	internal static Sprite GetIconSprite()
	{
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_weight.png");
		}
		return _icon;
	}

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_PlayerSortWeight", GetIconSprite(), buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_weight", "$vit_sort_weight_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = PlayerSortState.GetNextDirection(ContainerSortMode.Weight, defaultAscending: false);
			PlayerInventorySorter.Sort(instance, ContainerSortMode.Weight, nextDirection);
			PlayerSortState.Set(ContainerSortMode.Weight, nextDirection);
		}
	}
}
internal static class NearbyStashButton
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__2_0;

		internal void <Create>b__2_0()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				NearbyStashManager.Run(localPlayer);
			}
		}
	}

	private static Sprite _icon;

	internal static Sprite GetIconSprite()
	{
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("stash_nearby.png");
		}
		return _icon;
	}

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//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_0052: Expected O, but got Unknown
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_StashNearby", GetIconSprite(), buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		ButtonClickedEvent onClick = toolbarButtonView.Button.onClick;
		object obj = <>c.<>9__2_0;
		if (obj == null)
		{
			UnityAction val = delegate
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					NearbyStashManager.Run(localPlayer);
				}
			};
			<>c.<>9__2_0 = val;
			obj = (object)val;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
		TooltipUtility.AddDynamic(toolbarButtonView.GameObject, "$vit_stash_nearby", NearbyContainersTooltip.ForStash, null, GetHotkeyText);
	}

	internal unsafe static string GetHotkeyText()
	{
		//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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		if (ModConfig.NearbyStashEnableHotkey == null || !ModConfig.NearbyStashEnableHotkey.Value || ModConfig.NearbyStashHotkey == null)
		{
			return null;
		}
		KeyboardShortcut value = ModConfig.NearbyStashHotkey.Value;
		if ((int)((KeyboardShortcut)(ref value)).MainKey == 0)
		{
			return null;
		}
		return ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString();
	}
}
internal static class SortNameButton
{
	private static Sprite _icon;

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_name.png");
		}
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_SortName", _icon, buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_name", "$vit_sort_name_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = SortState.GetNextDirection(ContainerSortMode.Name, defaultAscending: true);
			InventorySorter.SortOpenContainer(instance, ContainerSortMode.Name, nextDirection);
			SortState.Set(ContainerSortMode.Name, nextDirection);
		}
	}
}
internal static class SortTypeButton
{
	private static Sprite _icon;

	private static Sprite _thinIcon;

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize, bool useThinIcon)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_type.png");
		}
		if (useThinIcon && (Object)(object)_thinIcon == (Object)null)
		{
			_thinIcon = SpriteLoader.Load("sort_type_thin.png");
		}
		Sprite icon = ((useThinIcon && (Object)(object)_thinIcon != (Object)null) ? _thinIcon : _icon);
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_SortType", icon, buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_type", "$vit_sort_type_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = SortState.GetNextDirection(ContainerSortMode.Type, defaultAscending: true);
			InventorySorter.SortOpenContainer(instance, ContainerSortMode.Type, nextDirection);
			SortState.Set(ContainerSortMode.Type, nextDirection);
		}
	}
}
internal static class SortWeightButton
{
	private static Sprite _icon;

	internal static void Create(GameObject template, Transform parent, float buttonWidth, float buttonHeight, float iconSize)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("sort_weight.png");
		}
		ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(template, parent, "VIT_SortWeight", _icon, buttonWidth, buttonHeight, iconSize);
		((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
		((UnityEvent)toolbarButtonView.Button.onClick).AddListener(new UnityAction(OnClick));
		TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_sort_weight", "$vit_sort_weight_desc");
	}

	private static void OnClick()
	{
		InventoryGui instance = InventoryGui.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			bool nextDirection = SortState.GetNextDirection(ContainerSortMode.Weight, defaultAscending: false);
			InventorySorter.SortOpenContainer(instance, ContainerSortMode.Weight, nextDirection);
			SortState.Set(ContainerSortMode.Weight, nextDirection);
		}
	}
}
internal static class StackAllButton
{
	private static Sprite _icon;

	internal static void Create(Transform source, Transform parent, float buttonWidth, float buttonHeight, float iconSize, bool useThinIcon)
	{
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		if ((Object)(object)source == (Object)null || (Object)(object)parent == (Object)null)
		{
			return;
		}
		Button vanillaButton = ((Component)source).GetComponent<Button>();
		if (!((Object)(object)vanillaButton == (Object)null))
		{
			if ((Object)(object)_icon == (Object)null)
			{
				_icon = SpriteLoader.Load("stack.png");
			}
			Sprite icon = _icon;
			ToolbarButtonView toolbarButtonView = ToolbarButtonFactory.Create(((Component)source).gameObject, parent, "VIT_StackAll", icon, buttonWidth, buttonHeight, iconSize);
			((UnityEventBase)toolbarButtonView.Button.onClick).RemoveAllListeners();
			((UnityEvent)toolbarButtonView.Button.onClick).AddListener((UnityAction)delegate
			{
				((UnityEvent)vanillaButton.onClick).Invoke();
				CompactCurrentContainer();
				SortState.Clear();
			});
			TooltipUtility.Add(toolbarButtonView.GameObject, "$vit_stack_all", "$vit_stack_all_desc");
			((Component)source).gameObject.SetActive(false);
		}
	}

	private static void CompactCurrentContainer()
	{
		InventoryGui instance = InventoryGui.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		Container value = Traverse.Create((object)instance).Field<Container>("m_currentContainer").Value;
		if ((Object)(object)value == (Object)null)
		{
			return;
		}
		Inventory inventory = value.GetInventory();
		if (inventory == null)
		{
			return;
		}
		List<ItemData> list = new List<ItemData>(inventory.GetAllItems());
		bool flag = false;
		for (int i = 0; i < list.Count; i++)
		{
			ItemData val = list[i];
			if (val == null || val.m_shared == null)
			{
				continue;
			}
			int maxStackSize = val.m_shared.m_maxStackSize;
			if (maxStackSize <= 1 || val.m_stack >= maxStackSize)
			{
				continue;
			}
			for (int j = i + 1; j < list.Count; j++)
			{
				ItemData val2 = list[j];
				if (val2 == null || val2.m_shared == null || !CanStackTogether(val, val2))
				{
					continue;
				}
				int num = maxStackSize - val.m_stack;
				if (num <= 0)
				{
					break;
				}
				int num2 = Mathf.Min(num, val2.m_stack);
				if (num2 > 0)
				{
					val.m_stack += num2;
					val2.m_stack -= num2;
					flag = true;
					if (val2.m_stack <= 0)
					{
						inventory.RemoveItem(val2);
						list[j] = null;
					}
				}
			}
		}
		if (flag)
		{
			Traverse.Create((object)inventory).Method("Changed", new object[2] { true, false }).GetValue();
			Traverse.Create((object)value).Method("Save", Array.Empty<object>()).GetValue();
			Traverse.Create((object)instance).Method("UpdateContainer", Array.Empty<object>()).GetValue();
		}
	}

	private static bool CanStackTogether(ItemData first, ItemData second)
	{
		if (first == null || second == null || first.m_shared == null || second.m_shared == null)
		{
			return false;
		}
		if (first.m_shared.m_maxStackSize <= 1 || second.m_shared.m_maxStackSize <= 1)
		{
			return false;
		}
		return first.m_shared.m_name == second.m_shared.m_name && first.m_quality == second.m_quality && first.m_variant == second.m_variant;
	}
}
internal static class TakeAllButton
{
	private static Sprite _icon;

	internal const float BottomMargin = 12f;

	private const float IconPadding = 4f;

	internal static void Create(Transform originalTakeAll)
	{
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Expected O, but got Unknown
		if ((Object)(object)originalTakeAll == (Object)null)
		{
			return;
		}
		RectTransform component = ((Component)originalTakeAll).GetComponent<RectTransform>();
		Button vanillaButton = ((Component)originalTakeAll).GetComponent<Button>();
		if ((Object)(object)component == (Object)null || (Object)(object)vanillaButton == (Object)null)
		{
			return;
		}
		if ((Object)(object)_icon == (Object)null)
		{
			_icon = SpriteLoader.Load("take_all.png");
		}
		float width = GetWidth(component, 100f);
		float height = GetHeight(component, 30f);
		GameObject clone = Object.Instantiate<GameObject>(((Component)originalTakeAll).gameObject, originalTakeAll.parent);
		((Object)clone).name = "VIT_TakeAll";
		RectTransform component2 = clone.GetComponent<RectTransform>();
		Button component3 = clone.GetComponent<Button>();
		if ((Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null)
		{
			Object.Destroy((Object)(object)clone);
			return;
		}
		component2.sizeDelta = new Vector2(width, height);
		LayoutElement component4 = clone.GetComponent<LayoutElement>();
		if ((Object)(object)component4 != (Object)null)
		{
			component4.minWidth = width;
			component4.preferredWidth = width;
			component4.minHeight = height;
			component4.preferredHeight = height;
			component4.flexibleWidth = 0f;
			component4.flexibleHeight = 0f;
		}
		component2.anchorMin = new Vector2(0.5f, 0f);
		component2.anchorMax = new Vector2(0.5f, 0f);
		component2.pivot = new Vector2(0.5f, 1f);
		component2.anchoredPosition = new Vector2(0f, -12f);
		ApplyDisplayMode(clone, width, height);
		((UnityEventBase)component3.onClick).RemoveAllListeners();
		((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
		{
			if (!TakeAllButtonDock.ModifierHeld && !TakeAllButtonDock.IsDragging)
			{
				TakeAllButtonDock component5 = clone.GetComponent<TakeAllButtonDock>();
				if (component5 == null || !component5.SuppressClick)
				{
					if ((Object)(object)vanillaButton != (Object)null)
					{
						((UnityEvent)vanillaButton.onClick).Invoke();
					}
					SortState.Clear();
				}
			}
		});
		TooltipUtility.Add(clone, "$vit_take_all", "$vit_take_all_desc");
		clone.transform.SetAsLastSibling();
		clone.SetActive(true);
		((Component)originalTakeAll).gameObject.SetActive(false);
	}

	private static void ApplyDisplayMode(GameObject buttonObject, float buttonWidth, float buttonHeight)
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		TakeAllDisplayMode value = ModConfig.TakeAllMode.Value;
		TMP_Text[] componentsInChildren = buttonObject.GetComponentsInChildren<TMP_Text>(true);
		if (value == TakeAllDisplayMode.Text)
		{
			TMP_Text[] array = componentsInChildren;
			foreach (TMP_Text val in array)
			{
				((Component)val).gameObject.SetActive(true);
			}
			return;
		}
		TMP_Text[] array2 = componentsInChildren;
		foreach (TMP_Text val2 in array2)
		{
			((Component)val2).gameObject.SetActive(false);
		}
		GameObject val3 = new GameObject("Icon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val3.transform.SetParent(buttonObject.transform, false);
		RectTransform component = val3.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = Vector2.zero;
		float num = Mathf.Max(8f, buttonHeight - 4f);
		component.sizeDelta = new Vector2(num, num);
		Image component2 = val3.GetComponent<Image>();
		component2.sprite = _icon;
		component2.preserveAspect = true;
		((Graphic)component2).raycastTarget = false;
		((Graphic)component2).color = ((ModConfig.IconColor != null) ? ModConfig.IconColor.Value : Color.white);
	}

	private static float GetWidth(RectTransform rect, float fallback)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0042: 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)
		if ((Object)(object)rect != (Object)null)
		{
			Rect rect2 = rect.rect;
			if (((Rect)(ref rect2)).width > 1f)
			{
				rect2 = rect.rect;
				return ((Rect)(ref rect2)).width;
			}
		}
		if ((Object)(object)rect != (Object)null && rect.sizeDelta.x > 1f)
		{
			return rect.sizeDelta.x;
		}
		return fallback;
	}

	private static float GetHeight(RectTransform rect, float fallback)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0042: 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)
		if ((Object)(object)rect != (Object)null)
		{
			Rect rect2 = rect.rect;
			if (((Rect)(ref rect2)).height > 1f)
			{
				rect2 = rect.rect;
				return ((Rect)(ref rect2)).height;
			}
		}
		if ((Object)(object)rect != (Object)null && rect.sizeDelta.y > 1f)
		{
			return rect.sizeDelta.y;
		}
		return fallback;
	}
}
[DefaultExecutionOrder(1100)]
internal sealed class TakeAllButtonDock : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
{
	private RectTransform _rect;

	private RectTransform _window;

	private Vector2 _anchorMin;

	private Vector2 _anchorMax;

	private Vector2 _pivot;

	private Vector2 _outsidePosition;

	private Vector2 _size;

	private Vector3 _dragStart;

	private float _grabOffsetY;

	private int _containerId;

	private MirrorDropMarker _marker;

	private bool _compact;

	private bool _suppressClick;

	private static TakeAllButtonDock _active;

	private static readonly FieldInfo ContainerField = AccessTools.Field(typeof(InventoryGui), "m_currentContainer");

	private static readonly FieldInfo DraggedItemField = AccessTools.Field(typeof(InventoryGui), "m_dragItem");

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

	internal static bool ModifierHeld => ModConfig.ModuleDragModifier != null && (int)ModConfig.ModuleDragModifier.Value != 0 && Input.GetKey(ModConfig.ModuleDragModifier.Value);

	internal bool WantsInside => ModConfig.TakeAllInside?.Value ?? false;

	internal bool IsCompact => _compact;

	internal bool SuppressClick => _suppressClick;

	private float OutsideCenterX
	{
		get
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = _window.rect;
			float xMin = ((Rect)(ref rect)).xMin;
			rect = _window.rect;
			return xMin + ((Rect)(ref rect)).width * Mathf.Lerp(_anchorMin.x, _anchorMax.x, _pivot.x) + _outsidePosition.x + (0.5f - _pivot.x) * _size.x;
		}
	}

	private UniversalSideModuleFollower Follower
	{
		get
		{
			object result;
			if (!((Object)(object)_window != (Object)null))
			{
				result = null;
			}
			else
			{
				Transform obj = ((Transform)_window).Find("VIT_UniversalSideBar");
				result = ((obj != null) ? ((Component)obj).GetComponent<UniversalSideModuleFollower>() : null);
			}
			return (UniversalSideModuleFollower)result;
		}
	}

	private Camera EventCamera
	{
		get
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Canvas val = (((Object)(object)_window != (Object)null) ? ((Component)_window).GetComponentInParent<Canvas>() : null);
			return ((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? val.worldCamera : null;
		}
	}

	private bool WindowOpen => (Object)(object)_rect != (Object)null && (Object)(object)_window != (Object)null && ((Behaviour)this).isActiveAndEnabled && UniversalSideModuleMirror.IsInventoryOpen && UniversalSideModuleMirror.IsStorageWindowOpen() && !InventoryUiBuilder.IsRefreshing;

	internal static void Install(Transform window)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)window != (Object)null) ? window.Find("VIT_TakeAll") : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<TakeAllButtonDock>() != (Object)null))
		{
			TakeAllButtonDock takeAllButtonDock = ((Component)val).gameObject.AddComponent<TakeAllButtonDock>();
			takeAllButtonDock._rect = (RectTransform)(object)((val is RectTransform) ? val : null);
			takeAllButtonDock._window = (RectTransform)(object)((window is RectTransform) ? window : null);
			takeAllButtonDock._anchorMin = takeAllButtonDock._rect.anchorMin;
			takeAllButtonDock._anchorMax = takeAllButtonDock._rect.anchorMax;
			takeAllButtonDock._pivot = takeAllButtonDock._rect.pivot;
			takeAllButtonDock._outsidePosition = takeAllButtonDock._rect.anchoredPosition;
			Rect rect = takeAllButtonDock._rect.rect;
			takeAllButtonDock._size = ((Rect)(ref rect)).size;
		}
	}

	private static int ContainerId()
	{
		InventoryGui instance = InventoryGui.instance;
		Container val = (Container)(((Object)(object)instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
		return ((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0;
	}

	internal void ApplyCompact(Rect bounds)
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_active == (Object)(object)this) && !((Object)(object)_rect == (Object)null))
		{
			_compact = WantsInside && UniversalSideModuleMirror.IsExtended(storage: true) && ((Rect)(ref bounds)).width > 0f && ((Rect)(ref bounds)).height > 0f;
			if (_compact)
			{
				RectTransform rect = _rect;
				RectTransform rect2 = _rect;
				RectTransform rect3 = _rect;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 0.5f);
				rect3.pivot = val;
				Vector2 anchorMin = (rect2.anchorMax = val);
				rect.anchorMin = anchorMin;
				_rect.sizeDelta = ((Rect)(ref bounds)).size;
				((Transform)_rect).localPosition = new Vector3(((Rect)(ref bounds)).center.x, ((Rect)(ref bounds)).center.y, 0f);
			}
			else
			{
				RestoreOutside();
			}
		}
	}

	private void RestoreOutside()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_rect == (Object)null))
		{
			_rect.anchorMin = _anchorMin;
			_rect.anchorMax = _anchorMax;
			_rect.pivot = _pivot;
			_rect.anchoredPosition = _outsidePosition;
			_rect.sizeDelta = _size;
			_compact = false;
		}
	}

	internal bool TryGetInsideBounds(out Rect bounds)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Rect);
		RectTransform val = InventoryUiBuilder.FindStorageBackground((Transform)(object)_window);
		if (!UniversalSideModuleMirror.IsExtended(storage: true) || (Object)(object)val == (Object)null || !StatModuleDockLayout.TryBounds(val, _window, out var bounds2))
		{
			return false;
		}
		float padding = 6f + ToolbarLayout.ScreenPixelsToLocalUnits(_window, 7f, vertical: true);
		return TryGetFixedInsideBounds(bounds2, _size, OutsideCenterX, padding, out bounds);
	}

	internal static bool TryGetFixedInsideBounds(Rect background, Vector2 size, float outsideCenterX, float padding, out Rect bounds)
	{
		//IL_0003: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Rect);
		if (float.IsNaN(outsideCenterX) || float.IsInfinity(outsideCenterX) || float.IsNaN(size.x) || float.IsInfinity(size.x) || size.x <= 0f || !ToolbarLayout.TryGetStorageFooterCenterY(((Rect)(ref background)).yMin, ((Rect)(ref background)).yMax, size.y, padding, out var centerY))
		{
			return false;
		}
		bounds = new Rect(outsideCenterX - size.x * 0.5f, centerY - size.y * 0.5f + 1f, size.x, size.y);
		return ((Rect)(ref bounds)).xMin >= ((Rect)(ref background)).xMin && ((Rect)(ref bounds)).xMax <= ((Rect)(ref background)).xMax && ((Rect)(ref bounds)).yMax <= ((Rect)(ref background)).yMax;
	}

	public void OnPointerDown(PointerEventData data)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		if ((int)data.button == 0)
		{
			_suppressClick = ModifierHeld;
		}
	}

	public void OnBeginDrag(PointerEventData data)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if ((int)data.button == 0 && WindowOpen && ModifierHeld && !IsDragging && !StatModuleDisplayController.IsDragging && !ToolbarDragController.IsDragging)
		{
			InventoryGui instance = InventoryGui.instance;
			Vector2 val = default(Vector2);
			if (!((Object)(object)instance == (Object)null) && !(DraggedItemField == null) && DraggedItemField.GetValue(instance) == null && RectTransformUtility.ScreenPointToLocalPointInRectangle(_window, data.position, EventCamera, ref val) && StatModuleDockLayout.TryBounds(_rect, _window, out var bounds))
			{
				_dragStart = ((Transform)_rect).localPosition;
				_grabOffsetY = ((Rect)(ref bounds)).center.y - val.y;
				_containerId = ContainerId();
				_suppressClick = true;
				_active = this;
				UpdateDrag(data.position);
			}
		}
	}

	public void OnDrag(PointerEventData data)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_active == (Object)(object)this)
		{
			UpdateDrag(data.position);
		}
	}

	public void OnEndDrag(PointerEventData data)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_0047: 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_0097: 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)
		if ((Object)(object)_active != (Object)(object)this || (int)data.button > 0)
		{
			return;
		}
		Vector2 val = default(Vector2);
		if (!WindowOpen || ContainerId() != _containerId || !RectTransformUtility.ScreenPointToLocalPointInRectangle(_window, data.position, EventCamera, ref val))
		{
			CancelDrag();
			return;
		}
		UniversalSideModuleFollower follower = Follower;
		Rect bounds;
		bool inside = (Object)(object)follower != (Object)null && follower.TryGetTakeAllInsertion(new Vector2(OutsideCenterX, val.y + _grabOffsetY), out bounds);
		RectTransform val2 = InventoryUiBuilder.FindStorageBackground((Transform)(object)_window);
		Rect bounds2;
		bool flag = (Object)(object)val2 != (Object)null && StatModuleDockLayout.TryBounds(val2, _window, out bounds2) && val.y < ((Rect)(ref bounds2)).yMin;
		CancelDrag();
		if (!inside && !flag)
		{
			return;
		}
		ModConfig.BatchModuleSettings(delegate
		{
			if (ModConfig.TakeAllInside != null)
			{
				ModConfig.TakeAllInside.Value = inside;
			}
		});
		follower?.ForceModuleRefresh();
	}

	private void UpdateDrag(Vector2 screen)
	{
		//IL_0007: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(_window, screen, EventCamera, ref val) || !StatModuleDockLayout.TryBounds(_rect, _window, out var bounds))
		{
			return;
		}
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(OutsideCenterX - ((Rect)(ref bounds)).center.x, val.y + _grabOffsetY - ((Rect)(ref bounds)).center.y);
		RectTransform rect = _rect;
		((Transform)rect).localPosition = ((Transform)rect).localPosition + new Vector3(val2.x, val2.y, 0f);
		UniversalSideModuleFollower follower = Follower;
		if ((Object)(object)follower != (Object)null && follower.TryGetTakeAllInsertion(new Vector2(OutsideCenterX, val.y + _grabOffsetY), out var bounds2))
		{
			if (_marker == null)
			{
				_marker = new MirrorDropMarker(_window);
			}
			_marker.Show(bounds2);
		}
		else
		{
			_marker?.Hide();
		}
	}

	private void LateUpdate()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_active == (Object)(object)this)
		{
			if (!WindowOpen || ContainerId() != _containerId || Input.GetKeyDown((KeyCode)27) || !Input.GetMouseButton(0))
			{
				CancelDrag();
			}
			else
			{
				UpdateDrag(Vector2.op_Implicit(Input.mousePosition));
			}
		}
		else if (!WantsInside || !UniversalSideModuleMirror.IsExtended(storage: true) || (Object)(object)Follower == (Object)null)
		{
			ApplyCompact(default(Rect));
		}
	}

	private void CancelDrag()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_active == (Object)(object)this)
		{
			((Transform)_rect).localPosition = _dragStart;
			_active = null;
		}
		_marker?.Hide();
	}

	private void OnDisable()
	{
		CancelDrag();
		RestoreOutside();
	}

	private void OnDestroy()
	{
		CancelDrag();
		_marker?.Destroy();
	}
}
internal static class ExtraSlotsCompatibility
{
	private const string ExtraSlotsGuid = "shudnal.ExtraSlots";

	private const string ExtraSlotsApiTypeName = "ExtraSlots.API";

	internal static bool TryGetRegularInventoryHeight(Inventory inventory, out int height, bool logFailure = true)
	{
		height = 0;
		if (inventory == null)
		{
			return false;
		}
		int height2 = inventory.GetHeight();
		if (height2 <= 0)
		{
			return false;
		}
		if (!Chainloader.PluginInfos.TryGetValue("shudnal.ExtraSlots", out var value))
		{
			height = height2;
			return true;
		}
		if (value == null || (Object)(object)value.Instance == (Object)null)
		{
			if (logFailure)
			{
				LogCompatibilityFailure("plugin instance is unavailable");
			}
			return false;
		}
		try
		{
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			Type type = assembly.GetType("ExtraSlots.API", throwOnError: false);
			if (type == null)
			{
				if (logFailure)
				{
					LogCompatibilityFailure("ExtraSlots.API was not found");
				}
				return false;
			}
			MethodInfo method = type.GetMethod("GetInventoryHeightPlayer", BindingFlags.Static | BindingFlags.Public);
			if (method == null)
			{
				if (logFailure)
				{
					LogCompatibilityFailure("GetInventoryHeightPlayer() was not found");
				}
				return false;
			}
			if (!(method.Invoke(null, null) is int num) || 1 == 0)
			{
				if (logFailure)
				{
					LogCompatibilityFailure("GetInventoryHeightPlayer() returned an unexpected value");
				}
				return false;
			}
			if (num <= 0 || num > height2)
			{
				if (logFailure)
				{
					LogCompatibilityFailure("invalid player inventory height: " + num + " / full height: " + height2);
				}
				return false;
			}
			height = num;
			return true;
		}
		catch (Exception ex)
		{
			if (logFailure)
			{
				LogCompatibilityFailure(ex.GetType().Name + ": " + ex.Message);
			}
			return false;
		}
	}

	private static void LogCompatibilityFailure(string reason)
	{
		Plugin.Log.LogWarning((object)("Extra Slots compatibility: " + reason + ". Player inventory operation was skipped to protect extra-slot items."));
	}
}
[DefaultExecutionOrder(950)]
internal sealed class ExtraSlotsWindowDock : MonoBehaviour
{
	private static ExtraSlotsWindowDock _current;

	private static MethodInfo _predict;

	private static MethodInfo _preview;

	private static MethodInfo _commit;

	private static ConfigEntry<Vector2> _offset;

	private static ConfigEntry<bool> _sticky;

	private RectTransform _window;

	private RectTransform _inventory;

	private RectTransform _equipment;

	private RectTransform _equipmentImageRect;

	private Image _shared;

	private Image _shadow;

	private Image _separate;

	private Image _separateShadow;

	private ExtraSlotsDockDragProxy _dragProxy;

	private readonly List<StatModuleBackgroundMask> _masks = new List<StatModuleBackgroundMask>();

	private readonly List<InventoryElement> _cells = new List<InventoryElement>();

	private readonly List<Selectable> _flagControls = new List<Selectable>();

	private Rect _previousInventory;

	private Rect _previousEquipment;

	private Rect _combined;

	private Rect _bridge;

	private int _sampleFrame = -1;

	private bool _joined;

	internal static bool Available => _predict != null;

	private static float GapWidth => ModConfig.ExtraSlotsJoinedGap?.Value ?? 30f;

	internal static bool IsAttached => (Object)(object)_current != (Object)null && _current._joined && ((Behaviour)_current).isActiveAndEnabled && UniversalSideModuleMirror.IsInventoryPresentationVisible;

	internal static void InstallHooks(Harmony harmony)
	{
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Expected O, but got Unknown
		if (Chainloader.PluginInfos.TryGetValue("shudnal.ExtraSlots", out var value) && !((Object)(object)value.Instance == (Object)null))
		{
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			Type type = assembly.GetType("ExtraSlots.EquipmentPanel");
			MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "SnapPanelOffset", new Type[1] { typeof(Vector2) }, (Type[])null) : null);
			_predict = ((type != null) ? AccessTools.Method(type, "GetPredictedPanelRect", new Type[1] { typeof(Vector2) }, (Type[])null) : null);
			_preview = ((type != null) ? AccessTools.Method(type, "PreviewPanelOffset", new Type[1] { typeof(Vector2) }, (Type[])null) : null);
			_commit = ((type != null) ? AccessTools.Method(type, "CommitPanelOffset", new Type[1] { typeof(Vector2) }, (Type[])null) : null);
			_offset = AccessTools.Field(((object)value.Instance).GetType(), "equipmentPanelOffset")?.GetValue(null) as ConfigEntry<Vector2>;
			_sticky = AccessTools.Field(((object)value.Instance).GetType(), "equipmentPanelSticky")?.GetValue(null) as ConfigEntry<bool>;
			if (methodInfo == null || _predict == null || _sticky == null || _preview == null || _commit == null || _offset == null)
			{
				_predict = null;
				Plugin.Log.LogWarning((object)"Extra Slots joined background is unavailable: native panel snapping API was not found.");
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ExtraSlotsWindowDock), "SnapOffset", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}
	}

	internal static void Install(Transform player)
	{
		if (Available && !((Object)(object)player == (Object)null))
		{
			ExtraSlotsWindowDock extraSlotsWindowDock = ((Component)player).GetComponent<ExtraSlotsWindowDock>();
			if ((Object)(object)extraSlotsWindowDock == (Object)null)
			{
				extraSlotsWindowDock = ((Component)player).gameObject.AddComponent<ExtraSlotsWindowDock>();
			}
			extraSlotsWindowDock._window = (RectTransform)(object)((player is RectTransform) ? player : null);
			_current = extraSlotsWindowDock;
		}
	}

	private static void SnapOffset(Vector2 offset, ref Vector2 __result)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: 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_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_current == (Object)null)
		{
			return;
		}
		ConfigEntry<bool> sticky = _sticky;
		if (sticky == null || !sticky.Value || !UniversalSideModuleMirror.IsInventoryOpen || !_current.Resolve() || !_current.ReadBounds(out var inventory, out var equipment))
		{
			return;
		}
		Rect val = (Rect)_predict.Invoke(null, new object[1] { offset });
		Vector2 position = ((Rect)(ref val)).position;
		Rect rect = _current._window.rect;
		float xMin = ((Rect)(ref rect)).xMin;
		rect = _current._window.rect;
		((Rect)(ref val)).position = position + new Vector2(xMin, ((Rect)(ref rect)).yMax);
		if (StatModuleDockLayout.TryBounds(_current._equipment, _current._window, out var bounds))
		{
			Rect equipment2 = equipment;
			((Rect)(ref equipment2)).position = ((Rect)(ref equipment2)).position + (((Rect)(ref val)).position - ((Rect)(ref bounds)).position);
			if ((_current._joined ? ExtraSlotsDockGeometry.TryKeepJoined(inventory, equipment2, out var delta, GapWidth) : ExtraSlotsDockGeometry.TrySnap(inventory, equipment2, out delta, GapWidth)) && _current.ContentFits(inventory, ((Rect)(ref equipment2)).position - ((Rect)(ref equipment)).position + delta, equipment))
			{
				__result = offset + new Vector2(delta.x, 0f - delta.y);
			}
		}
	}

	internal static bool TryGetCombined(RectTransform window, out Rect bounds)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Rect);
		if (!IsAttached || (Object)(object)_current._window != (Object)(object)window)
		{
			return false;
		}
		bounds = _current._combined;
		return true;
	}

	internal static bool CanDockSideFlag(RectTransform window, Rect flag, float overlap)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		if (!TryGetCombined(window, out var bounds) || !ExtraSlotsDockGeometry.AllowsSideFlag(bounds, flag, overlap))
		{
			return false;
		}
		InventoryGui instance = InventoryGui.instance;
		InventoryGrid val = (((Object)(object)instance != (Object)null) ? Traverse.Create((object)instance).Field<InventoryGrid>("m_playerGrid").Value : null);
		if ((Object)(object)val == (Object)null || (Object)(object)_current._equipment == (Object)null)
		{
			return false;
		}
		((Component)val).GetComponentsInChildren<InventoryElement>(false, _current._cells);
		foreach (InventoryElement cell in _current._cells)
		{
			Transform transform = ((Component)cell).transform;
			if (StatModuleDockLayout.TryBounds((RectTransform)(object)((transform is RectTransform) ? transform : null), window, out var bounds2) && StatModuleDockLayout.Intersects(flag, bounds2))
			{
				return false;
			}
		}
		((Component)_current._equipment).GetComponentsInChildren<Selectable>(false, _current._flagControls);
		foreach (Selectable flagControl in _current._flagControls)
		{
			if (((Behaviour)flagControl).isActiveAndEnabled && (Object)(object)flagControl.targetGraphic != (Object)null && StatModuleDockLayout.TryBounds(flagControl.targetGraphic.rectTransform, window, out var bounds3) && StatModuleDockLayout.Intersects(flag, bounds3))
			{
				return false;
			}
		}
		return true;
	}

	internal static void EnsureMirrorWidth(RectTransform window, float textWidth)
	{
		//IL_0069: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: 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)
		if (!IsAttached || (Object)(object)_current._window != (Object)(object)window || ModConfig.ExtraSlotsJoinedGap == null)
		{
			return;
		}
		float num = ExtraSlotsDockGeometry.RequiredGap(textWidth);
		if (!(num <= GapWidth + 0.5f) && _current.ReadBounds(out var inventory, out var equipment))
		{
			Vector2 val = _offset.Value + new Vector2(num - (((Rect)(ref equipment)).xMin - ((Rect)(ref inventory)).xMax), 0f);
			ModConfig.ExtraSlotsJoinedGap.Value = num;
			_preview.Invoke(null, new object[1] { val });
			_commit.Invoke(null, new object[1] { val });
			if (_current.ReadBounds(out inventory, out equipment))
			{
				_current._combined = ExtraSlotsDockGeometry.Combined(inventory, equipment);
				_current._bridge = ExtraSlotsDockGeometry.Bridge(inventory, equipment);
				_current.RenderBackground(inventory);
			}
		}
	}

	internal static RectTransform BackgroundSurface(RectTransform window)
	{
		return (IsAttached && (Object)(object)_current._window == (Object)(object)window && (Object)(object)_current._shared != (Object)null) ? ((Graphic)_current._shared).rectTransform : null;
	}

	internal static bool TryGetBridge(RectTransform window, out Rect bounds)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Rect);
		if (!IsAttached || (Object)(object)_current._window != (Object)(object)window)
		{
			return false;
		}
		bounds = _current._bridge;
		return true;
	}

	private bool Resolve()
	{
		if ((Object)(object)_window == (Object)null)
		{
			return false;
		}
		_inventory = InventoryUiBuilder.FindPlayerBackground((Transform)(object)_window);
		if ((Object)(object)_equipment == (Object)null || (Object)(object)((Transform)_equipment).parent != (Object)(object)_window)
		{
			ref RectTransform equipment = ref _equipment;
			Transform obj = ((Transform)_window).Find("ExtraSlotsEquipmentPanel");
			equipment = (RectTransform)(object)((obj is RectTransform) ? obj : null);
		}
		_equipmentImageRect = (RectTransform)(((Object)(object)_equipment != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
		return (Object)(object)_inventory != (Object)null && (Object)(object)_equipment != (Object)null && (Object)(object)_equipmentImageRect != (Object)null && ((Component)_equipment).gameObject.activeInHierarchy && (Object)(object)((Component)_equipmentImageRect).GetComponent<Image>() != (Object)null;
	}

	private bool ReadBounds(out Rect inventory, out Rect equipment)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		equipment = default(Rect);
		return StatModuleDockLayout.TryBounds(_inventory, _window, out inventory) && StatModuleDockLayout.TryBounds(_equipmentImageRect, _window, out equipment);
	}

	private bool ContentFits(Rect inventory, Vector2 shift, Rect equipment)
	{
		//IL_0083: 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_00bd: 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)
		InventoryGui instance = InventoryGui.instance;
		InventoryGrid val = (((Object)(object)instance != (Object)null) ? Traverse.Create((object)instance).Field<InventoryGrid>("m_playerGrid").Value : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		((Component)val).GetComponentsInChildren<InventoryElement>(false, _cells);
		foreach (InventoryElement cell in _cells)
		{
			Transform transform = ((Component)cell).transform;
			if (!StatModuleDockLayout.TryBounds((RectTransform)(object)((transform is RectTransform) ? transform : null), _window, out var bounds) || ((Rect)(ref bounds)).center.x < ((Rect)(ref equipment)).xMin || ((Rect)(ref bounds)).center.x > ((Rect)(ref equipment)).xMax || (!(((Rect)(ref bounds)).yMin + shift.y < ((Rect)(ref inventory)).yMin - 2f) && !(((Rect)(ref bounds)).yMax + shift.y > ((Rect)(ref inventory)).yMax + 2f)))
			{
				continue;
			}
			return false;
		}
		return true;
	}

	private void LateUpdate()
	{
		using (InventoryUiPreparation.Measure("ExtraSlotsDockFrame"))
		{
			UpdateDockFrame();
		}
	}

	private void UpdateDockFrame()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		if (UniversalSideModuleMirror.IsInventoryClosing || InventoryUiBuilder.IsRefreshing)
		{
			return;
		}
		if (!UniversalSideModuleMirror.IsInventoryOpen || !Resolve() || !ReadBounds(out var inventory, out var equipment))
		{
			Detach();
			return;
		}
		bool flag = _sampleFrame == Time.frameCount - 1 && StatModuleDockLayout.Stable(inventory, _previousInventory) && StatModuleDockLayout.Stable(equipment, _previousEquipment);
		_sampleFrame = Time.frameCount;
		_previousInventory = inventory;
		_previousEquipment = equipment;
		ConfigEntry<bool> sticky = _sticky;
		if (sticky == null || !sticky.Value || !ExtraSlotsDockGeometry.IsJoined(inventory, equipment, GapWidth) || !ContentFits(inventory, Vector2.zero, equipment))
		{
			Detach(keepProxy: true);
			using (InventoryUiPreparation.Measure("ExtraSlotsSeparateBackground"))
			{
				RenderSeparate(inventory, equipment);
				return;
			}
		}
		if (flag || _joined)
		{
			_combined = ExtraSlotsDockGeometry.Combined(inventory, equipment);
			_bridge = ExtraSlotsDockGeometry.Bridge(inventory, equipment);
			bool joined = _joined;
			_joined = true;
			if ((Object)(object)_separate != (Object)null)
			{
				((Component)_separate).gameObject.SetActive(false);
			}
			if ((Object)(object)_separateShadow != (Object)null)
			{
				((Component)_separateShadow).gameObject.SetActive(false);
			}
			using (InventoryUiPreparation.Measure("ExtraSlotsJoinedBackground"))
			{
				RenderBackground(inventory);
			}
			if (!joined)
			{
				UniversalSideModuleMirror.RefreshDisplayModes();
			}
		}
	}

	private void RenderBackground(Rect inventory)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		Image component = ((Component)_inventory).GetComponent<Image>();
		if ((Object)(object)component == (Object)null)
		{
			Detach();
			return;
		}
		if ((Object)(object)_shared == (Object)null)
		{
			_shared = CreateImage("VIT_JoinedInventoryBackground");
		}
		CopyImage(component, _shared);
		Place(((Graphic)_shared).rectTransform, _combined);
		if (((Component)_shared).transform.GetSiblingIndex() >= ((Transform)_inventory).GetSiblingIndex())
		{
			((Component)_shared).transform.SetSiblingIndex(((Transform)_inventory).GetSiblingIndex());
		}
		Mask(component);
		Mask(((Component)_equipmentImageRect).GetComponent<Image>());
		if ((Object)(object)_dragProxy == (Object)null)
		{
			Image val = CreateImage("VIT_JoinedExtraSlotsDragSurface");
			((Graphic)val).color = Color.clear;
			((Graphic)val).raycastTarget = true;
			_dragProxy = ((Component)val).gameObject.AddComponent<ExtraSlotsDockDragProxy>();
		}
		_dragProxy.Setup(((Component)_equipmentImageRect).gameObject);
		_dragProxy.SetDocked(value: true);
		if (StatModuleDockLayout.TryBounds(_equipmentImageRect, _window, out var bounds))
		{
			Transform transform = ((Component)_dragProxy).transform;
			Place((RectTransform)(object)((transform is RectTransform) ? transform : null), Rect.MinMaxRect(((Rect)(ref bounds)).xMin, ((Rect)(ref _combined)).yMin, ((Rect)(ref bounds)).xMax, ((Rect)(ref _combined)).yMax));
		}
		OrderAfter(((Component)_dragProxy).transform, (Transform)(object)_equipment);
		Transform val2 = ((Transform)_equipment).Find("Darken");
		if ((Object)(object)val2 != (Object)null)
		{
			Mask(((Component)val2).GetComponent<Image>());
		}
		Transform val3 = ((Transform)_window).Find("Darken");
		Image val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<Image>() : null);
		if ((Object)(object)val4 != (Object)null && StatModuleDockLayout.TryBounds(((Graphic)val4).rectTransform, _window, out var bounds2))
		{
			if ((Object)(object)_shadow == (Object)null)
			{
				_shadow = CreateImage("VIT_JoinedInventoryShadow");
			}
			CopyImage(val4, _shadow);
			((Rect)(ref bounds2)).xMax = ((Rect)(ref bounds2)).xMax + (((Rect)(ref _combined)).width - ((Rect)(ref inventory)).width);
			Place(((Graphic)_shadow).rectTransform, bounds2);
			if (((Component)_shadow).transform.GetSiblingIndex() >= val3.GetSiblingIndex())
			{
				((Component)_shadow).transform.SetSiblingIndex(val3.GetSiblingIndex());
			}
			Mask(val4);
		}
	}

	private void RenderSeparate(Rect inventory, Rect equipment)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: 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_014b: Unknown result type (might be due to invalid IL or missing references)
		Rect val = ExtraSlotsDockGeometry.Separate(inventory, equipment, UniversalSideModuleMirror.IsExtended(storage: false));
		if (!ContentFits(val, Vector2.zero, equipment))
		{
			Detach();
			return;
		}
		Image component = ((Component)_equipmentImageRect).GetComponent<Image>();
		if ((Object)(object)_separate == (Object)null)
		{
			_separate = CreateImage("VIT_SeparateExtraSlotsBackground");
		}
		CopyImage(component, _separate);
		Place(((Graphic)_separate).rectTransform, val);
		OrderBefore(((Component)_separate).transform, (Transform)(object)_equipment);
		Mask(component);
		Transform val2 = ((Transform)_equipment).Find("Darken");
		Image val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Image>() : null);
		if ((Object)(object)val3 != (Object)null && StatModuleDockLayout.TryBounds(((Graphic)val3).rectTransform, _window, out var bounds))
		{
			if ((Object)(object)_separateShadow == (Object)null)
			{
				_separateShadow = CreateImage("VIT_SeparateExtraSlotsShadow");
			}
			CopyImage(val3, _separateShadow);
			float num = ((Rect)(ref equipment)).yMin - ((Rect)(ref bounds)).yMin;
			((Rect)(ref bounds)).yMin = ((Rect)(ref val)).yMin - num;
			Place(((Graphic)_separateShadow).rectTransform, bounds);
			OrderBefore(((Component)_separateShadow).transform, ((Component)_separate).transform);
			Mask(val3);
		}
		if ((Object)(object)_dragProxy == (Object)null)
		{
			Image val4 = CreateImage("VIT_JoinedExtraSlotsDragSurface");
			((Graphic)val4).color = Color.clear;
			((Graphic)val4).raycastTarget = true;
			_dragProxy = ((Component)val4).gameObject.AddComponent<ExtraSlotsDockDragProxy>();
		}
		_dragProxy.Setup(((Component)_equipmentImageRect).gameObject);
		_dragProxy.SetDocked(value: true);
		Transform transform = ((Component)_dragProxy).transform;
		Place((RectTransform)(object)((transform is RectTransform) ? transform : null), val);
		OrderAfter(((Component)_dragProxy).transform, (Transform)(object)_equipment);
	}

	internal static int IndexBefore(int moving, int anchor)
	{
		return (moving < anchor) ? moving : anchor;
	}

	internal static int IndexAfter(int moving, int anchor)
	{
		return (moving < anchor) ? anchor : (anchor + 1);
	}

	private static void OrderBefore(Transform layer, Transform anchor)
	{
		if (!((Object)(object)layer == (Object)(object)anchor) && !((Object)(object)layer.parent != (Object)(object)anchor.parent))
		{
			int siblingIndex = layer.GetSiblingIndex();
			int num = IndexBefore(siblingIndex, anchor.GetSiblingIndex());
			if (siblingIndex != num)
			{
				layer.SetSiblingIndex(num);
			}
		}
	}

	private static void OrderAfter(Transform layer, Transform anchor)
	{
		if (!((Object)(object)layer == (Object)(object)anchor) && !((Object)(object)layer.parent != (Object)(object)anchor.parent))
		{
			int siblingIndex = layer.GetSiblingIndex();
			int num = IndexAfter(siblingIndex, anchor.GetSiblingIndex());
			if (siblingIndex != num)
			{
				layer.SetSiblingIndex(num);
			}
		}
	}

	private Image CreateImage(string name)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		GameObject val = new GameObject(name, new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent((Transform)(object)_window, false);
		val.layer = ((Component)_inventory).gameObject.layer;
		Image component = val.GetComponent<Image>();
		((Graphic)component).raycastTarget = false;
		return component;
	}

	private static void CopyImage(Image source, Image destination)
	{
		//IL_0037: 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)
		((Component)destination).gameObject.SetActive(true);
		destination.sprite = source.sprite;
		destination.overrideSprite = source.overrideSprite;
		((Graphic)destination).material = ((Graphic)source).material;
		((Graphic)destination).color = ((Graphic)source).color;
		destination.type = source.type;
		destination.preserveAspect = false;
		destination.fillCenter = source.fillCenter;
		destination.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier;
	}

	private static void Place(RectTransform rect, Rect bounds)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		rect.pivot = val;
		Vector2 anchorMin = (rect.anchorMax = val);
		rect.anchorMin = anchorMin;
		rect.sizeDelta = ((Rect)(ref bounds)).size;
		((Transform)rect).localPosition = new Vector3(((Rect)(ref bounds)).center.x, ((Rect)(ref bounds)).center.y, 0f);
	}

	private void Mask(Image image)
	{
		if (!((Object)(object)image == (Object)null))
		{
			StatModuleBackgroundMask statModuleBackgroundMask = ((Component)image).GetComponent<StatModuleBackgroundMask>();
			if ((Object)(object)statModuleBackgroundMask == (Object)null)
			{
				statModuleBackgroundMask = ((Component)image).gameObject.AddComponent<StatModuleBackgroundMask>();
			}
			if (!_masks.Contains(statModuleBackgroundMask))
			{
				_masks.Add(statModuleBackgroundMask);
			}
			statModuleBackgroundMask.Suppress(value: true);
		}
	}

	private void Detach(bool keepProxy = false)
	{
		bool joined = _joined;
		_joined = false;
		if (keepProxy && !joined)
		{
			return;
		}
		foreach (StatModuleBackgroundMask mask in _masks)
		{
			if ((Object)(object)mask != (Object)null)
			{
				mask.Suppress(value: false);
			}
		}
		_masks.Clear();
		if ((Object)(object)_shared != (Object)null)
		{
			((Component)_shared).gameObject.SetActive(false);
		}
		if ((Object)(object)_shadow != (Object)null)
		{
			((Component)_shadow).gameObject.SetActive(false);
		}
		if ((Object)(object)_separate != (Object)null)
		{
			((Component)_separate).gameObject.SetActive(false);
		}
		if ((Object)(object)_separateShadow != (Object)null)
		{
			((Component)_separateShadow).gameObject.SetActive(false);
		}
		if ((Object)(object)_dragProxy != (Object)null && !keepProxy)
		{
			_dragProxy.SetDocked(value: false);
		}
		if (joined)
		{
			UniversalSideModuleMirror.RefreshDisplayModes();
		}
	}

	private void OnDisable()
	{
		Detach();
		_sampleFrame = -1;
	}

	private void OnDestroy()
	{
		Detach();
		if ((Object)(object)_shared != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_shared).gameObject);
		}
		if ((Object)(object)_shadow != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_shadow).gameObject);
		}
		if ((Object)(object)_separate != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_separate).gameObject);
		}
		if ((Object)(object)_separateShadow != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_separateShadow).gameObject);
		}
		if ((Object)(object)_dragProxy != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_dragProxy).gameObject);
		}
		if ((Object)(object)_current == (Object)(object)this)
		{
			_current = null;
		}
	}
}
internal sealed class ExtraSlotsDockDragProxy : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
{
	private GameObject _target;

	private bool _docked;

	private bool _forwarding;

	private PointerEventData _event;

	internal void Setup(GameObject target)
	{
		_target = target;
	}

	internal void SetDocked(bool value)
	{
		_docked = value;
		((Component)this).gameObject.SetActive(value || _forwarding);
	}

	public void OnBeginDrag(PointerEventData data)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		if ((int)data.button == 0 && !((Object)(object)_target == (Object)null))
		{
			_event = data;
			_forwarding = true;
			ExecuteEvents.Execute<IBeginDragHandler>(_target, (BaseEventData)(object)data, ExecuteEvents.beginDragHandler);
		}
	}

	public void OnDrag(PointerEventData data)
	{
		if (_forwarding && (Object)(object)_target != (Object)null)
		{
			ExecuteEvents.Execute<IDragHandler>(_target, (BaseEventData)(object)data, ExecuteEvents.dragHandler);
		}
	}

	public void OnEndDrag(PointerEventData data)
	{
		Finish(data);
	}

	private void Finish(PointerEventData data)
	{
		if (_forwarding)
		{
			_forwarding = false;
			if ((Object)(object)_target != (Object)null)
			{
				ExecuteEvents.Execute<IEndDragHandler>(_target, (BaseEventData)(object)data, ExecuteEvents.endDragHandler);
			}
			_event = null;
			((Component)this).gameObject.SetActive(_docked);
		}
	}

	private void OnDisable()
	{
		if (_event != null)
		{
			Finish(_event);
		}
	}
}
internal static class RecyclePlusCompatibility
{
	private static FieldInfo _trash;

	private static FieldInfo _clicked;

	private static bool _installed;

	private static bool _loggedSource;

	internal static bool MirrorSupported => _installed;

	private static RectTransform Source
	{
		get
		{
			object obj = _trash?.GetValue(null);
			Component val = (Component)((obj is Component) ? obj : null);
			GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
			return (RectTransform)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: (((Object)(object)val2 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null));
		}
	}

	private static bool LayoutGesture => StatModuleDisplayController.IsDragging || ToolbarDragController.IsDragging || (ModConfig.ModuleDragModifier != null && (int)ModConfig.ModuleDragModifier.Value != 0 && Input.GetKey(ModConfig.ModuleDragModifier.Value));

	internal static void InstallHooks(Harmony harmony)
	{
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Expected O, but got Unknown
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Expected O, but got Unknown
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Expected O, but got Unknown
		if (!Chainloader.PluginInfos.TryGetValue("TastyChickenLegs.RecyclePlus", out var value) || (Object)(object)value.Instance == (Object)null)
		{
			return;
		}
		Type type = ((object)value.Instance).GetType();
		_trash = AccessTools.Field(type, "trash");
		_clicked = AccessTools.Field(type, "_clickedTrash");
		MethodInfo methodInfo = AccessTools.Method(type, "IsPointerOverTrash", Type.EmptyTypes, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateItemDrag_Postfix", (Type[])null, (Type[])null);
		MethodInfo methodInfo3 = AccessTools.Method(type, "TrashItem", Type.EmptyTypes, (Type[])null);
		if (_trash == null || !_trash.IsStatic || _clicked == null || !_clicked.IsStatic || _clicked.FieldType != typeof(bool) || methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(bool) || methodInfo2 == null || !methodInfo2.IsStatic || methodInfo3 == null || !methodInfo3.IsStatic)
		{
			Plugin.Log.LogWarning((object)"RecyclePlus integration is unavailable: the native Trash API was not found.");
			return;
		}
		try
		{
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(RecyclePlusCompatibility), "PointerOverTrash", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(RecyclePlusCompatibility), "AllowNativeAction", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(RecyclePlusCompatibility), "AllowNativeAction", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_installed = true;
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("RecyclePlus integration could not be installed: " + ex.Message));
		}
	}

	internal static bool IsSource(Transform source)
	{
		return (Object)(object)source != (Object)null && (Object)(object)source == (Object)(object)Source;
	}

	internal static RectTransform GetSource(RectTransform window)
	{
		RectTransform source = Source;
		return ((Object)(object)source != (Object)null && (Object)(object)source != (Object)(object)window && ((Transform)source).IsChildOf((Transform)(object)window) && ((Component)source).gameObject.activeInHierarchy) ? source : null;
	}

	private static bool AllowNativeAction()
	{
		if (!LayoutGesture)
		{
			return true;
		}
		_clicked.SetValue(null, false);
		return false;
	}

	private static void PointerOverTrash(ref bool __result)
	{
		//IL_004e: 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)
		if (LayoutGesture)
		{
			__result = false;
			return;
		}
		RectTransform source = Source;
		if ((Object)(object)source == (Object)null)
		{
			return;
		}
		if (UniversalSideModuleMirror.TryGetMirrorSurface((Transform)(object)source, out var surface))
		{
			Canvas componentInParent = ((Component)surface).GetComponentInParent<Canvas>();
			Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			__result = RectTransformUtility.RectangleContainsScreenPoint(surface, Vector2.op_Implicit(Input.mousePosition), val);
			return;
		}
		StatModuleRegistry.Entry entry = StatModuleRegistry.Find((Transform)(object)source);
		if (!((Component)source).gameObject.activeInHierarchy || (entry != null && entry.Mode.Value == StatDisplayMode.Hidden) || !UniversalSideModuleMirror.IsInventoryOpen)
		{
			__result = false;
		}
		CanvasGroup[] componentsInParent = ((Component)source).GetComponentsInParent<CanvasGroup>();
		foreach (CanvasGroup val2 in componentsInParent)
		{
			if (((Behaviour)val2).enabled && (val2.alpha <= 0.001f || !val2.blocksRaycasts))
			{
				__result = false;
				break;
			}
		}
	}

	internal static void AttachDragRelay(RectTransform source, StatModuleDisplayController owner)
	{
		if (!IsSource((Transform)(object)source))
		{
			return;
		}
		BindRelay(((Component)source).gameObject, source, owner);
		Graphic[] componentsInChildren = ((Component)source).GetComponentsInChildren<Graphic>(true);
		foreach (Graphic val in componentsInChildren)
		{
			if (val.raycastTarget)
			{
				BindRelay(((Component)val).gameObject, source, owner);
			}
		}
		if (!_loggedSource)
		{
			_loggedSource = true;
			Plugin.Log.LogInfo((object)("RecyclePlus Trash registered for module dragging; native mirror input " + (_installed ? "enabled." : "unavailable.")));
		}
	}

	private static void BindRelay(GameObject target, RectTransform source, StatModuleDisplayController owner)
	{
		RecyclePlusDragRelay recyclePlusDragRelay = target.GetComponent<RecyclePlusDragRelay>();
		if ((Object)(object)recyclePlusDragRelay == (Object)null)
		{
			recyclePlusDragRelay = target.AddComponent<RecyclePlusDragRelay>();
		}
		recyclePlusDragRelay.Setup(source, owner);
	}

	internal static void StyleMirror(GameObject target, Image background, Transform source)
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		InventoryGui instance = InventoryGui.instance;
		Transform val = (((Object)(object)instance != (Object)null) ? ((Component)instance).transform.Find("root/Player/Container/StackAll") : null);
		if ((Object)(object)val != (Object)null)
		{
			PlayerToolbarPlacementQuickControl.CopyVanillaButtonStyle(background, ((Component)val).gameObject);
		}
		Button val2 = target.AddComponent<Button>();
		((Selectable)val2).targetGraphic = (Graphic)(object)background;
		((Selectable)val2).transition = (Transition)1;
		Button val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Button>() : null);
		if ((Object)(object)val3 != (Object)null)
		{
			((Selectable)val2).colors = ((Selectable)val3).colors;
		}
		Navigation navigation = default(Navigation);
		((Navigation)(ref navigation)).mode = (Mode)0;
		((Selectable)val2).navigation = navigation;
		TooltipUtility.AddDynamic(target, "", () => LocalizationManager.Translate("$vit_trash_tooltip"), null, null, delegate
		{
			TMP_Text obj = UniversalSideModuleFollower.FindText(source);
			return ((obj != null) ? obj.text : null) ?? "Trash";
		});
	}
}
internal sealed class RecyclePlusDragRelay : MonoBehaviour, IInitializePotentialDragHandler, IEventSystemHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
{
	private RectTransform _source;

	private StatModuleDisplayController _owner;

	private bool _dragging;

	internal void Setup(RectTransform source, StatModuleDisplayController owner)
	{
		_source = source;
		_owner = owner;
	}

	public void OnInitializePotentialDrag(PointerEventData data)
	{
		if ((Object)(object)_owner != (Object)null && _owner.ModifierHeld)
		{
			data.useDragThreshold = false;
		}
	}

	public void OnBeginDrag(PointerEventData data)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		_dragging = (int)data.button == 0 && (Object)(object)_owner != (Object)null && _owner.BeginSourceDrag((Transform)(object)_source, data.position);
		if (_dragging)
		{
			data.eligibleForClick = false;
		}
	}

	public void OnDrag(PointerEventData data)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (_dragging && (Object)(object)_owner != (Object)null)
		{
			_owner.UpdateDrag(data.position);
		}
	}

	public void OnEndDrag(PointerEventData data)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (_dragging && (Object)(object)_owner != (Object)null)
		{
			_owner.EndDrag(data.position);
		}
		_dragging = false;
	}
}
internal static class StorageFilterIntegration
{
	private static Func<Container, ItemData, bool> accepts;

	private static Func<Container, ItemData, bool> explicitDestination;

	private static Func<Container, ItemData, int> priority;

	private static bool resolved;

	internal static bool HasApi
	{
		get
		{
			Resolve();
			return priority != null;
		}
	}

	private static void Resolve()
	{
		if (resolved)
		{
			return;
		}
		resolved = true;
		Type type = Type.GetType("VanillaChestItemCategory.StorageFilterCore, VanillaChestItemCategory");
		Type type2 = Type.GetType("VanillaChestItemCategory.StorageFilterRouting, VanillaChestItemCategory");
		if (type == null || type2 == null)
		{
			return;
		}
		try
		{
			Func<Container, ItemData, bool> func = (Func<Container, ItemData, bool>)Delegate.CreateDelegate(typeof(Func<Container, ItemData, bool>), type.GetMethod("CanAcceptItem"));
			Func<Container, ItemData, bool> func2 = (Func<Container, ItemData, bool>)Delegate.CreateDelegate(typeof(Func<Container, ItemData, bool>), type2.GetMethod("IsExplicitDestination"));
			Func<Container, ItemData, int> func3 = (Func<Container, ItemData, int>)Delegate.CreateDelegate(typeof(Func<Container, ItemData, int>), type2.GetMethod("Priority"));
			accepts = func;
			explicitDestination = func2;
			priority = func3;
		}
		catch (ArgumentException ex)
		{
			Plugin.Log.LogError((object)("Storage filter API is incompatible: " + ex));
		}
	}

	internal static bool CanAccept(Container container, ItemData item)
	{
		Resolve();
		return accepts == null || accepts(container, item);
	}

	internal static bool IsExplicit(Container container, ItemData item)
	{
		Resolve();
		return explicitDestination != null && explicitDestination(container, item);
	}

	internal static bool IsDestination(Container container, ItemData item)
	{
		return CanAccept(container, item) && (IsExplicit(container, item) || container.GetInventory().ContainsItemByName(item.m_shared.m_name));
	}

	internal static List<Container> RoutingPasses(List<Container> containers)
	{
		Resolve();
		if (priority == null)
		{
			return containers;
		}
		List<Container> list = new List<Container>();
		for (int i = 0; i <= 2; i++)
		{
			list.AddRange(containers);
		}
		return list;
	}

	internal static bool InPass(Container container, ItemData item, int pass)
	{
		Resolve();
		return priority == null || priority(container, item) == pass;
	}

	internal static Dictionary<Inventory, Container> PreviewTargets(IEnumerable<Inventory> inventories)
	{
		Resolve();
		HashSet<Inventory> hashSet = new HashSet<Inventory>(inventories);
		Dictionary<Inventory, Container> dictionary = new Dictionary<Inventory, Container>();
		if (accepts != null)
		{
			Container[] array = Object.FindObjectsByType<Container>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (Container val in array)
			{
				if (val.GetInventory() != null && hashSet.Contains(val.GetInventory()))
				{
					dictionary[val.GetInventory()] = val;
				}
			}
		}
		return dictionary;
	}

	internal static bool PreviewDestination(Inventory inventory, ItemData item, Dictionary<Inventory, Container> containers)
	{
		Container value;
		return containers.TryGetValue(inventory, out value) ? IsDestination(value, item) : inventory.ContainsItemByName(item.m_shared.m_name);
	}

	internal static int PreviewPriority(Inventory inventory, ItemData item, Dictionary<Inventory, Container> containers)
	{
		Container value;
		return containers.TryGetValue(inventory, out value) ? priority(value, item) : 2;
	}
}
internal enum ToolbarSide
{
	RightTop,
	LeftTop,
	LeftDown,
	RightDown,
	DownLeft,
	DownRight
}
internal enum PlayerToolbarSide
{
	LeftTop,
	LeftDown,
	RightTop,
	RightDown,
	DownLeft,
	DownRight
}
internal enum TakeAllDisplayMode
{
	Icon,
	Text
}
internal enum ToolbarPlacement
{
	Inside,
	OnBorder,
	Outside
}
internal enum StatDisplayMode
{
	Original,
	MirrorInside,
	Hidden
}
internal readonly struct StatDockPosition : IEquatable<StatDockPosition>
{
	private readonly int _address;

	internal readonly Vector2 FreeOffset;

	internal readonly Vector2 FreeAnchor;

	internal readonly bool FreeBottom;

	internal static readonly StatDockPosition Default = new StatDockPosition(0);

	internal bool IsFree => _address == -1;

	private StatDockPosition(int address)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		_address = address;
		FreeOffset = (FreeAnchor = Vector2.zero);
		FreeBottom = false;
	}

	internal StatDockPosition(Vector2 offset, Vector2 anchor, bool bottom)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		_address = -1;
		FreeOffset = offset;
		FreeAnchor = anchor;
		FreeBottom = bottom;
	}

	public bool Equals(StatDockPosition other)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		int result;
		if (_address == other._address)
		{
			Vector2 val = FreeOffset;
			if (((Vector2)(ref val)).Equals(other.FreeOffset))
			{
				val = FreeAnchor;
				if (((Vector2)(ref val)).Equals(other.FreeAnchor))
				{
					result = ((FreeBottom == other.FreeBottom) ? 1 : 0);
					goto IL_004b;
				}
			}
		}
		result = 0;
		goto IL_004b;
		IL_004b:
		return (byte)result != 0;
	}

	public override bool Equals(object other)
	{
		return other is StatDockPosition other2 && Equals(other2);
	}

	public override int GetHashCode()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		return _address ^ ((object)FreeOffset/*cast due to .constrained prefix*/).GetHashCode() ^ ((object)FreeAnchor/*cast due to .constrained prefix*/).GetHashCode() ^ FreeBottom.GetHashCode();
	}

	public override string ToString()
	{
		return StatDockPositionCodec.Format(this);
	}

	public static bool operator ==(StatDockPosition a, StatDockPosition b)
	{
		return a.Equals(b);
	}

	public static bool operator !=(StatDockPosition a, StatDockPosition b)
	{
		return !a.Equals(b);
	}

	public static explicit operator int(StatDockPosition position)
	{
		return position._address;
	}

	public static explicit operator StatDockPosition(int address)
	{
		return new StatDockPosition(address);
	}
}
internal static class ModConfig
{
	private sealed class LegacyConfigSnapshot
	{
		private readonly Dictionary<string, string> _values = new Dictionary<string, string>();

		internal static LegacyConfigSnapshot Load(string path)
		{
			LegacyConfigSnapshot legacyConfigSnapshot = new LegacyConfigSnapshot();
			if (string.IsNullOrEmpty(path) || !File.Exists(path))
			{
				return legacyConfigSnapshot;
			}
			string section = string.Empty;
			try
			{
				string[] array = File.ReadAllLines(path);
				string[] array2 = array;
				foreach (string text in array2)
				{
					string text2 = text.Trim();
					if (text2.Length == 0 || text2.StartsWith("#"))
					{
						continue;
					}
					if (text2.StartsWith("[") && text2.EndsWith("]") && text2.Length > 2)
					{
						section = text2.Substring(1, text2.Length - 2);
						continue;
					}
					int num = text2.IndexOf('=');
					if (num > 0)
					{
						string key = text2.Substring(0, num).Trim();
						string value = text2.Substring(num + 1).Trim();
						legacyConfigSnapshot._values[MakeKey(section, key)] = value;
					}
				}
			}
			catch
			{
			}
			return legacyConfigSnapshot;
		}

		internal bool Contains(string section, string key)
		{
			return _values.ContainsKey(MakeKey(section, key));
		}

		internal bool TryGet(string section, string key, out string value)
		{
			return _values.TryGetValue(MakeKey(section, key), out value);
		}

		private static string MakeKey(string section, string key)
		{
			return (section ?? string.Empty) + "\n" + (key ?? string.Empty);
		}
	}

	internal const float ExtendedBackgroundHeight = 30f;

	private static ConfigFile _config;

	private static bool _applyingToolbarDock;

	internal static ConfigEntry<StatDisplayMode> PlayerArmorDisplay;

	internal static ConfigEntry<StatDisplayMode> PlayerWeightDisplay;

	internal static ConfigEntry<StatDisplayMode> StorageWeightDisplay;

	internal static ConfigEntry<StatDockPosition> PlayerArmorDock;

	internal static ConfigEntry<StatDockPosition> PlayerWeightDock;

	internal static ConfigEntry<StatDockPosition> StorageWeightDock;

	internal static ConfigEntry<KeyCode> ModuleDragModifier;

	internal static ConfigEntry<float> ExtraSlotsJoinedGap;

	internal static ConfigEntry<bool> TakeAllInside;

	internal static ConfigEntry<bool> LogInventoryOpenTiming;

	internal static ConfigEntry<Color> IconColor;

	internal static ConfigEntry<bool> ExtendPlayerBackground;

	internal static ConfigEntry<ToolbarPlacement> PlayerToolbarPlacement;

	internal static ConfigEntry<bool> ShowWeightStat;

	internal static ConfigEntry<bool> ShowArmorStat;

	internal static ConfigEntry<PlayerToolbarSide> PlayerInventoryToolbarSide;

	internal static ConfigEntry<int> PlayerToolbarButtonWidthScalePercent;

	internal static ConfigEntry<int> PlayerToolbarButtonHeightScalePercent;

	internal static ConfigEntry<int> StorageToolbarButtonWidthScalePercent;

	internal static ConfigEntry<int> StorageToolbarButtonHeightScalePercent;

	internal static ConfigEntry<float> PlayerToolbarOffsetX;

	internal static ConfigEntry<float> PlayerToolbarOffsetY;

	internal static ConfigEntry<float> PlayerToolbarSpacing;

	internal static ConfigEntry<bool> ShowPlayerSortNameButton;

	internal static ConfigEntry<bool> ShowPlayerSortWeightButton;

	internal static ConfigEntry<bool> ShowPlayerSortTypeButton;

	internal static ConfigEntry<bool> ShowNearbyStashButton;

	internal static ConfigEntry<bool> ExtendStorageBackground;

	internal static ConfigEntry<ToolbarPlacement> StorageToolbarPlacement;

	internal static ConfigEntry<bool> ShowStorageWeightStat;

	internal static ConfigEntry<ToolbarSide> ContainerToolbarSide;

	internal static ConfigEntry<float> ContainerToolbarSpacing;

	internal static ConfigEntry<float> ContainerToolbarOffsetX;

	internal static ConfigEntry<float> ContainerToolbarOffsetY;

	internal static ConfigEntry<bool> HideVanillaStackAllButton;

	internal static ConfigEntry<bool> HideVanillaTakeAllButton;

	internal static ConfigEntry<bool> ShowSortNameButton;

	internal static ConfigEntry<bool> ShowSortWeightButton;

	internal static ConfigEntry<bool> ShowSortTypeButton;

	internal static ConfigEntry<bool> ShowStackAllButton;

	internal static ConfigEntry<bool> ShowTakeAllButton;

	internal static ConfigEntry<TakeAllDisplayMode> TakeAllMode;

	internal static ConfigEntry<float> NearbyStashRadius;

	internal static ConfigEntry<bool> NearbyStashPlayerBuiltOnly;

	internal static ConfigEntry<bool> NearbyStashProtectHotbar;

	internal static ConfigEntry<bool> NearbyStashEnableHotkey;

	internal static ConfigEntry<KeyboardShortcut> NearbyStashHotkey;

	internal static void Bind(ConfigFile config)
	{
		//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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Expected O, but got Unknown
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Expected O, but got Unknown
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Expected O, but got Unknown
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Expected O, but got Unknown
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Expected O, but got Unknown
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Expected O, but got Unknown
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Expected O, but got Unknown
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Expected O, but got Unknown
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Expected O, but got Unknown
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Expected O, but got Unknown
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Expected O, but got Unknown
		//IL_0428: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Expected O, but got Unknown
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Expected O, but got Unknown
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Expected O, but got Unknown
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Expected O, but got Unknown
		//IL_0527: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Expected O, but got Unknown
		//IL_0575: Unknown result type (might be due to invalid IL or missing references)
		//IL_057f: Expected O, but got Unknown
		//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cd: Expected O, but got Unknown
		//IL_0611: Unknown result type (might be due to invalid IL or missing references)
		//IL_061b: Expected O, but got Unknown
		//IL_0659: Unknown result type (might be due to invalid IL or missing references)
		//IL_0663: Expected O, but got Unknown
		//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Expected O, but got Unknown
		//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e7: Expected O, but got Unknown
		//IL_0719: Unknown result type (might be due to invalid IL or missing references)
		//IL_0723: Expected O, but got Unknown
		//IL_0755: Unknown result type (might be due to invalid IL or missing references)
		//IL_075f: Expected O, but got Unknown
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_079b: Expected O, but got Unknown
		//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d7: Expected O, but got Unknown
		//IL_0809: Unknown result type (might be due to invalid IL or missing references)
		//IL_0813: Expected O, but got Unknown
		//IL_0845: Unknown result type (might be due to invalid IL or missing references)
		//IL_084f: Expected O, but got Unknown
		//IL_0881: Unknown result type (might be due to invalid IL or missing references)
		//IL_088b: Expected O, but got Unknown
		//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c7: Expected O, but got Unknown
		//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_090d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0917: Expected O, but got Unknown
		//IL_0949: Unknown result type (might be due to invalid IL or missing references)
		//IL_0953: Expected O, but got Unknown
		//IL_0985: Unknown result type (might be due to invalid IL or missing references)
		//IL_098f: Expected O, but got Unknown
		//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09dd: Expected O, but got Unknown
		_config = config;
		LegacyConfigSnapshot legacy = LegacyConfigSnapshot.Load(config.ConfigFilePath);
		LogInventoryOpenTiming = config.Bind<bool>("Diagnostics", "LogInventoryOpenTiming", false, HiddenModuleSetting("Log inventory opening work timings. Disabled by default; does not change UI behavior."));
		IconColor = config.Bind<Color>("Appearance", "IconColor", Color32.op_Implicit(new Color32(byte.MaxValue, (byte)161, (byte)61, byte.MaxValue)), new ConfigDescription("Color tint for all custom icons.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 10
			}
		}));
		ExtendPlayerBackground = config.Bind<bool>("Player Inventory Window Appearance", "ExtendBackground", false, new ConfigDescription("Extend the player inventory background downward by 30 UI pixels. Disable for vanilla background height.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 100
			}
		}));
		PlayerToolbarPlacement = config.Bind<ToolbarPlacement>("Player Inventory Window Appearance", "ToolbarPlacement", ToolbarPlacement.OnBorder, new ConfigDescription("For DownLeft and DownRight, place the inventory toolbar inside the added background area, centered on the window border, or outside the window. Vertical side positions stay outside the window.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 90
			}
		}));
		ShowWeightStat = config.Bind<bool>("Player Inventory Window Appearance", "ExtendedBackgroundShowWeight", true, new ConfigDescription("Show the weight/carry indicator in the extended area. Works only when ExtendBackground is enabled.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Browsable = false,
				Order = 20
			}
		}));
		ShowArmorStat = config.Bind<bool>("Player Inventory Window Appearance", "ExtendedBackgroundShowArmor", true, new ConfigDescription("Show the armor/defense indicator in the extended area. Works only when ExtendBackground is enabled.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{