Decompiled source of Loot Manager v2.0.1

Erenshor.LootManager.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LootManager;

public class LootManagerController : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <WaitForInventoryAndInit>d__2 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public LootManagerController <>4__this;

		private GameObject <go>5__1;

		private GameObject <mover>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WaitForInventoryAndInit>d__2(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<go>5__1 = null;
			<mover>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)GameObject.Find("TrashSlot") == (Object)null)
			{
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<go>5__1 = new GameObject("BlacklistSlotObject");
			<go>5__1.AddComponent<BlacklistSlot>().InitSlotAsync();
			<mover>5__2 = new GameObject("TrashSlotMover");
			<mover>5__2.AddComponent<TrashSlotPatch>();
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static LootManagerController _instance;

	public static void Initialize()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		if ((Object)(object)_instance == (Object)null)
		{
			GameObject val = new GameObject("LootManager_Controller");
			_instance = val.AddComponent<LootManagerController>();
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<LootManagerUI>();
			((MonoBehaviour)_instance).StartCoroutine(_instance.WaitForInventoryAndInit());
		}
	}

	[IteratorStateMachine(typeof(<WaitForInventoryAndInit>d__2))]
	private IEnumerator WaitForInventoryAndInit()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitForInventoryAndInit>d__2(0)
		{
			<>4__this = this
		};
	}
}
public static class LootUIController
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__51_0;

		public static UnityAction <>9__51_1;

		public static UnityAction <>9__51_2;

		public static UnityAction <>9__51_3;

		public static UnityAction<float> <>9__66_0;

		public static UnityAction<float> <>9__66_1;

		public static Func<Item, bool> <>9__68_0;

		public static Func<Item, string> <>9__68_1;

		public static Func<string, string> <>9__68_2;

		public static UnityAction<string> <>9__68_3;

		public static Func<string, string> <>9__69_2;

		public static Func<Item, bool> <>9__74_0;

		public static Func<Item, string> <>9__74_1;

		public static Func<string, string> <>9__74_2;

		public static UnityAction<string> <>9__74_3;

		public static Func<string, string> <>9__75_2;

		public static UnityAction<BaseEventData> <>9__79_0;

		public static UnityAction<BaseEventData> <>9__79_1;

		public static UnityAction<BaseEventData> <>9__79_2;

		internal void <SetupMenuBarButtons>b__51_0()
		{
			ShowPanel(_settingsPanel);
		}

		internal void <SetupMenuBarButtons>b__51_1()
		{
			ShowPanel(_blacklistPanel);
		}

		internal void <SetupMenuBarButtons>b__51_2()
		{
			ShowPanel(_banklistPanel);
		}

		internal void <SetupMenuBarButtons>b__51_3()
		{
			if ((Object)(object)LootManagerUI.Instance != (Object)null)
			{
				LootManagerUI.Instance.ToggleUI();
			}
		}

		internal void <SetupBankPageRangeSliders>b__66_0(float val)
		{
			int value = (int)val;
			Plugin.BankPageFirst.Value = value;
			((TMP_Text)_pageFirstText).text = value.ToString();
		}

		internal void <SetupBankPageRangeSliders>b__66_1(float val)
		{
			int value = (int)val;
			Plugin.BankPageLast.Value = value;
			((TMP_Text)_pageLastText).text = value.ToString();
		}

		internal bool <SetupBlacklistPanel>b__68_0(Item item)
		{
			return !string.IsNullOrWhiteSpace(item.ItemName);
		}

		internal string <SetupBlacklistPanel>b__68_1(Item item)
		{
			return item.ItemName;
		}

		internal string <SetupBlacklistPanel>b__68_2(string x)
		{
			return x;
		}

		internal void <SetupBlacklistPanel>b__68_3(string <p0>)
		{
			RefreshBlacklistUI();
		}

		internal string <RefreshBlacklistUI>b__69_2(string item)
		{
			return item;
		}

		internal bool <SetupBanklistPanel>b__74_0(Item item)
		{
			return !string.IsNullOrWhiteSpace(item.ItemName);
		}

		internal string <SetupBanklistPanel>b__74_1(Item item)
		{
			return item.ItemName;
		}

		internal string <SetupBanklistPanel>b__74_2(string x)
		{
			return x;
		}

		internal void <SetupBanklistPanel>b__74_3(string <p0>)
		{
			RefreshBanklistUI();
		}

		internal string <RefreshBanklistUI>b__75_2(string item)
		{
			return item;
		}

		internal void <AddDragEvents>b__79_0(BaseEventData data)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			PointerEventData val = (PointerEventData)data;
			if ((int)val.button == 0)
			{
				dragging = true;
				GameData.DraggingUIElement = true;
				RectTransformUtility.ScreenPointToLocalPointInRectangle(panelRect, val.position, (Camera)null, ref dragOffset);
			}
		}

		internal void <AddDragEvents>b__79_1(BaseEventData data)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (dragging)
			{
				Transform parent = ((Transform)panelRect).parent;
				Vector2 val = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), ((PointerEventData)data).position, (Camera)null, ref val);
				panelRect.anchoredPosition = val - dragOffset;
			}
		}

		internal void <AddDragEvents>b__79_2(BaseEventData data)
		{
			dragging = false;
			GameData.DraggingUIElement = false;
		}
	}

	private static GameObject _uiRoot;

	private static GameObject _panelBG;

	private static GameObject _settingsPanel;

	private static GameObject _blacklistPanel;

	private static GameObject _banklistPanel;

	private static GameObject _menuBar;

	private static GameObject _titleImage;

	private static GameObject _dragHangle;

	private static TMP_Dropdown _autoLootDropdown;

	private static readonly List<string> _autoLootOptions = new List<string> { "On", "Off" };

	private static string _selectedAutoLootMode;

	private static Slider _autoDistanceSlider;

	private static TextMeshProUGUI _autoDistanceText;

	private static TMP_Dropdown _lootMethodDropdown;

	private static readonly List<string> _lootMethodOptions = new List<string> { "Blacklist", "Standard" };

	private static string _selectedLootMethod;

	private static Toggle _bankLootToggle;

	private static TMP_Dropdown _bankMethodDropdown;

	private static readonly List<string> _bankMethodOptions = new List<string> { "All", "Filtered" };

	private static string _selectedBankMethod;

	private static TMP_Dropdown _bankPageDropdown;

	private static readonly List<string> _bankPageOptions = new List<string> { "First Empty", "Page Range" };

	private static string _selectedBankPageMode;

	private static Slider _bankPageFirstSlider;

	private static TextMeshProUGUI _pageFirstText;

	private static Slider _bankPageLastSlider;

	private static TextMeshProUGUI _pageLastText;

	private static Transform _blackitemContent;

	private static Transform _blacklistContent;

	private static TMP_InputField _blackfilterInput;

	private static Button _blackaddBtn;

	private static Button _blackremoveBtn;

	private static Transform _bankitemContent;

	private static Transform _banklistContent;

	private static TMP_InputField _bankfilterInput;

	private static Button _bankaddBtn;

	private static Button _bankremoveBtn;

	private static bool dragging = false;

	private static Vector2 dragOffset;

	private static RectTransform panelRect;

	private static List<string> _allItems = new List<string>();

	private static List<(Text text, bool isBlacklist)> _selectedBlackEntries = new List<(Text, bool)>();

	private static List<(Text text, bool isBanklist)> _selectedBankEntries = new List<(Text, bool)>();

	private static Dictionary<string, float> _lastClickTime = new Dictionary<string, float>();

	private const float DoubleClickThreshold = 0.25f;

	private static HashSet<string> _blacklist => Plugin.Blacklist;

	private static HashSet<string> _banklist => Plugin.Banklist;

	public static void Initialize(GameObject uiRoot)
	{
		_uiRoot = uiRoot;
		Transform obj = Find("panelBG");
		_panelBG = ((obj != null) ? ((Component)obj).gameObject : null);
		Transform obj2 = Find("panelBG/settingsPanel");
		_settingsPanel = ((obj2 != null) ? ((Component)obj2).gameObject : null);
		Transform obj3 = Find("panelBG/blacklistPanel");
		_blacklistPanel = ((obj3 != null) ? ((Component)obj3).gameObject : null);
		Transform obj4 = Find("panelBG/banklistPanel");
		_banklistPanel = ((obj4 != null) ? ((Component)obj4).gameObject : null);
		Transform obj5 = Find("panelBG/menuBar");
		_menuBar = ((obj5 != null) ? ((Component)obj5).gameObject : null);
		Transform obj6 = Find("panelBG/titleImage");
		_titleImage = ((obj6 != null) ? ((Component)obj6).gameObject : null);
		Transform obj7 = Find("panelBG/lootUIDragHandle");
		_dragHangle = ((obj7 != null) ? ((Component)obj7).gameObject : null);
		AddDragEvents(_dragHangle, _panelBG.GetComponent<RectTransform>());
		ShowPanel(_settingsPanel);
		SetupMenuBarButtons();
		SetupSettingsPanel();
	}

	private static void ShowPanel(GameObject activePanel)
	{
		GameObject menuBar = _menuBar;
		if (menuBar != null)
		{
			menuBar.SetActive(true);
		}
		GameObject titleImage = _titleImage;
		if (titleImage != null)
		{
			titleImage.SetActive(true);
		}
		GameObject settingsPanel = _settingsPanel;
		if (settingsPanel != null)
		{
			settingsPanel.SetActive((Object)(object)activePanel == (Object)(object)_settingsPanel);
		}
		GameObject blacklistPanel = _blacklistPanel;
		if (blacklistPanel != null)
		{
			blacklistPanel.SetActive((Object)(object)activePanel == (Object)(object)_blacklistPanel);
		}
		GameObject banklistPanel = _banklistPanel;
		if (banklistPanel != null)
		{
			banklistPanel.SetActive((Object)(object)activePanel == (Object)(object)_banklistPanel);
		}
		Transform obj = Find("panelBG/menuBar/settingBtn");
		Outline val = ((obj != null) ? ((Component)obj).GetComponent<Outline>() : null);
		if ((Object)(object)val != (Object)null)
		{
			((Behaviour)val).enabled = (Object)(object)activePanel == (Object)(object)_settingsPanel;
		}
		Transform obj2 = Find("panelBG/menuBar/blacklistBtn");
		Outline val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Outline>() : null);
		if ((Object)(object)val2 != (Object)null)
		{
			((Behaviour)val2).enabled = (Object)(object)activePanel == (Object)(object)_blacklistPanel;
		}
		Transform obj3 = Find("panelBG/menuBar/banklistBtn");
		Outline val3 = ((obj3 != null) ? ((Component)obj3).GetComponent<Outline>() : null);
		if ((Object)(object)val3 != (Object)null)
		{
			((Behaviour)val3).enabled = (Object)(object)activePanel == (Object)(object)_banklistPanel;
		}
		if ((Object)(object)activePanel == (Object)(object)_blacklistPanel)
		{
			SetupBlacklistPanel();
		}
		if ((Object)(object)activePanel == (Object)(object)_banklistPanel)
		{
			SetupBanklistPanel();
		}
	}

	private static void SetupMenuBarButtons()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_00ac: 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_00b7: Expected O, but got Unknown
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Expected O, but got Unknown
		Transform obj = Find("panelBG/menuBar/settingBtn");
		Button val = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
		Transform obj2 = Find("panelBG/menuBar/blacklistBtn");
		Button val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
		Transform obj3 = Find("panelBG/menuBar/banklistBtn");
		Button val3 = ((obj3 != null) ? ((Component)obj3).GetComponent<Button>() : null);
		Transform obj4 = Find("panelBG/menuBar/closeBtn");
		Button val4 = ((obj4 != null) ? ((Component)obj4).GetComponent<Button>() : null);
		if (val != null)
		{
			ButtonClickedEvent onClick = val.onClick;
			object obj5 = <>c.<>9__51_0;
			if (obj5 == null)
			{
				UnityAction val5 = delegate
				{
					ShowPanel(_settingsPanel);
				};
				<>c.<>9__51_0 = val5;
				obj5 = (object)val5;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj5);
		}
		if (val2 != null)
		{
			ButtonClickedEvent onClick2 = val2.onClick;
			object obj6 = <>c.<>9__51_1;
			if (obj6 == null)
			{
				UnityAction val6 = delegate
				{
					ShowPanel(_blacklistPanel);
				};
				<>c.<>9__51_1 = val6;
				obj6 = (object)val6;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj6);
		}
		if (val3 != null)
		{
			ButtonClickedEvent onClick3 = val3.onClick;
			object obj7 = <>c.<>9__51_2;
			if (obj7 == null)
			{
				UnityAction val7 = delegate
				{
					ShowPanel(_banklistPanel);
				};
				<>c.<>9__51_2 = val7;
				obj7 = (object)val7;
			}
			((UnityEvent)onClick3).AddListener((UnityAction)obj7);
		}
		if (val4 == null)
		{
			return;
		}
		ButtonClickedEvent onClick4 = val4.onClick;
		object obj8 = <>c.<>9__51_3;
		if (obj8 == null)
		{
			UnityAction val8 = delegate
			{
				if ((Object)(object)LootManagerUI.Instance != (Object)null)
				{
					LootManagerUI.Instance.ToggleUI();
				}
			};
			<>c.<>9__51_3 = val8;
			obj8 = (object)val8;
		}
		((UnityEvent)onClick4).AddListener((UnityAction)obj8);
	}

	private static void SetupSettingsPanel()
	{
		Transform obj = Find("panelBG/settingsPanel/autoLootDrop");
		_autoLootDropdown = ((obj != null) ? ((Component)obj).GetComponent<TMP_Dropdown>() : null);
		Transform obj2 = Find("panelBG/settingsPanel/autoDistance");
		_autoDistanceSlider = ((obj2 != null) ? ((Component)obj2).GetComponent<Slider>() : null);
		Transform obj3 = Find("panelBG/settingsPanel/autoText");
		_autoDistanceText = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null);
		Transform obj4 = Find("panelBG/settingsPanel/lootMethod");
		_lootMethodDropdown = ((obj4 != null) ? ((Component)obj4).GetComponent<TMP_Dropdown>() : null);
		Transform obj5 = Find("panelBG/settingsPanel/bankLootToggle");
		_bankLootToggle = ((obj5 != null) ? ((Component)obj5).GetComponent<Toggle>() : null);
		Transform obj6 = Find("panelBG/settingsPanel/bankMethodDrop");
		_bankMethodDropdown = ((obj6 != null) ? ((Component)obj6).GetComponent<TMP_Dropdown>() : null);
		Transform obj7 = Find("panelBG/settingsPanel/bankPageDrop");
		_bankPageDropdown = ((obj7 != null) ? ((Component)obj7).GetComponent<TMP_Dropdown>() : null);
		Transform obj8 = Find("panelBG/settingsPanel/bankPageFirst");
		_bankPageFirstSlider = ((obj8 != null) ? ((Component)obj8).GetComponent<Slider>() : null);
		Transform obj9 = Find("panelBG/settingsPanel/pageFirstText");
		_pageFirstText = ((obj9 != null) ? ((Component)obj9).GetComponent<TextMeshProUGUI>() : null);
		Transform obj10 = Find("panelBG/settingsPanel/bankPageLast");
		_bankPageLastSlider = ((obj10 != null) ? ((Component)obj10).GetComponent<Slider>() : null);
		Transform obj11 = Find("panelBG/settingsPanel/pageLastText");
		_pageLastText = ((obj11 != null) ? ((Component)obj11).GetComponent<TextMeshProUGUI>() : null);
		SetupAutoLootDropdown();
		SetupAutoLootDistanceSlider();
		SetupLootMethodDropdown();
		SetupBankLootToggle();
		SetupBankMethodDropdown();
		SetupBankPageDropdown();
		SetupBankPageRangeSliders();
	}

	private static void SetupAutoLootDropdown()
	{
		if ((Object)(object)_autoLootDropdown == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] autoLootDrop dropdown not found.");
			return;
		}
		_autoLootDropdown.ClearOptions();
		_autoLootDropdown.AddOptions(_autoLootOptions);
		int num = ((!Plugin.AutoLootEnabled.Value) ? 1 : 0);
		_autoLootDropdown.SetValueWithoutNotify(num);
		_selectedAutoLootMode = _autoLootOptions[num];
		UpdateAutoDistanceInteractable();
		((UnityEvent<int>)(object)_autoLootDropdown.onValueChanged).AddListener((UnityAction<int>)OnAutoLootDropdownChanged);
	}

	private static void OnAutoLootDropdownChanged(int index)
	{
		if (index >= 0 && index < _autoLootOptions.Count)
		{
			_selectedAutoLootMode = _autoLootOptions[index];
			Plugin.AutoLootEnabled.Value = _selectedAutoLootMode == "On";
			UpdateAutoDistanceInteractable();
		}
	}

	private static void SetupAutoLootDistanceSlider()
	{
		if ((Object)(object)_autoDistanceSlider == (Object)null || (Object)(object)_autoDistanceText == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] autoDistance slider or autoText not found.");
			return;
		}
		_autoDistanceSlider.minValue = 0f;
		_autoDistanceSlider.maxValue = 200f;
		_autoDistanceSlider.wholeNumbers = true;
		float value = Plugin.AutoLootDistance.Value;
		_autoDistanceSlider.SetValueWithoutNotify(value);
		((TMP_Text)_autoDistanceText).text = $"{(int)value:F0}";
		((UnityEvent<float>)(object)_autoDistanceSlider.onValueChanged).AddListener((UnityAction<float>)OnAutoDistanceChanged);
	}

	private static void OnAutoDistanceChanged(float newValue)
	{
		Plugin.AutoLootDistance.Value = newValue;
		if ((Object)(object)_autoDistanceText != (Object)null)
		{
			((TMP_Text)_autoDistanceText).text = $"{(int)newValue:F0}";
		}
	}

	private static void UpdateAutoDistanceInteractable()
	{
		bool interactable = _selectedAutoLootMode == "On";
		if ((Object)(object)_autoDistanceSlider != (Object)null)
		{
			((Selectable)_autoDistanceSlider).interactable = interactable;
		}
	}

	private static void SetupLootMethodDropdown()
	{
		if ((Object)(object)_lootMethodDropdown == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] lootMethod dropdown not found.");
			return;
		}
		_lootMethodDropdown.ClearOptions();
		_lootMethodDropdown.AddOptions(_lootMethodOptions);
		int num = _lootMethodOptions.IndexOf(Plugin.LootMethod.Value);
		_lootMethodDropdown.SetValueWithoutNotify(num);
		_selectedLootMethod = _lootMethodOptions[num];
		((UnityEvent<int>)(object)_lootMethodDropdown.onValueChanged).AddListener((UnityAction<int>)OnLootMethodDropdownChanged);
	}

	private static void OnLootMethodDropdownChanged(int index)
	{
		if (index >= 0 && index < _lootMethodOptions.Count)
		{
			_selectedLootMethod = _lootMethodOptions[index];
			Plugin.LootMethod.Value = _selectedLootMethod;
		}
	}

	private static void SetupBankLootToggle()
	{
		if ((Object)(object)_bankLootToggle == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] bankLootToggle not found.");
			return;
		}
		_bankLootToggle.SetIsOnWithoutNotify(Plugin.BankLootEnabled.Value);
		((UnityEvent<bool>)(object)_bankLootToggle.onValueChanged).AddListener((UnityAction<bool>)OnBankLootToggleChanged);
	}

	private static void OnBankLootToggleChanged(bool isOn)
	{
		Plugin.BankLootEnabled.Value = isOn;
		if ((Object)(object)_bankMethodDropdown != (Object)null)
		{
			((Selectable)_bankMethodDropdown).interactable = isOn;
		}
		if ((Object)(object)_bankPageDropdown != (Object)null)
		{
			((Selectable)_bankPageDropdown).interactable = isOn;
		}
		UpdateBankPageSliderInteractable();
	}

	private static void SetupBankMethodDropdown()
	{
		if ((Object)(object)_bankMethodDropdown == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] bankMethodDrop dropdown not found.");
			return;
		}
		_bankMethodDropdown.ClearOptions();
		_bankMethodDropdown.AddOptions(_bankMethodOptions);
		int num = _bankMethodOptions.IndexOf(Plugin.BankLootMethod.Value);
		if (num < 0)
		{
			num = 0;
		}
		_bankMethodDropdown.SetValueWithoutNotify(num);
		_selectedBankMethod = _bankMethodOptions[num];
		((UnityEvent<int>)(object)_bankMethodDropdown.onValueChanged).AddListener((UnityAction<int>)OnBankMethodDropdownChanged);
		((Selectable)_bankMethodDropdown).interactable = Plugin.BankLootEnabled.Value;
	}

	private static void OnBankMethodDropdownChanged(int index)
	{
		if (index >= 0 && index < _bankMethodOptions.Count)
		{
			_selectedBankMethod = _bankMethodOptions[index];
			Plugin.BankLootMethod.Value = _selectedBankMethod;
		}
	}

	private static void SetupBankPageDropdown()
	{
		if ((Object)(object)_bankPageDropdown == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] bankPageDrop dropdown not found.");
			return;
		}
		_bankPageDropdown.ClearOptions();
		_bankPageDropdown.AddOptions(_bankPageOptions);
		int num = _bankPageOptions.IndexOf(Plugin.BankLootPageMode.Value);
		if (num < 0)
		{
			num = 0;
		}
		_bankPageDropdown.SetValueWithoutNotify(num);
		_selectedBankPageMode = _bankPageOptions[num];
		((UnityEvent<int>)(object)_bankPageDropdown.onValueChanged).AddListener((UnityAction<int>)OnBankPageDropdownChanged);
		((Selectable)_bankPageDropdown).interactable = Plugin.BankLootEnabled.Value;
		UpdateBankPageSliderInteractable();
	}

	private static void OnBankPageDropdownChanged(int index)
	{
		if (index >= 0 && index < _bankPageOptions.Count)
		{
			_selectedBankPageMode = _bankPageOptions[index];
			Plugin.BankLootPageMode.Value = _selectedBankPageMode;
			UpdateBankPageSliderInteractable();
		}
	}

	private static void SetupBankPageRangeSliders()
	{
		if ((Object)(object)_bankPageFirstSlider == (Object)null || (Object)(object)_pageFirstText == (Object)null || (Object)(object)_bankPageLastSlider == (Object)null || (Object)(object)_pageLastText == (Object)null)
		{
			Debug.LogWarning((object)"[LootUI] Bank page range sliders or text missing.");
			return;
		}
		_bankPageFirstSlider.minValue = 1f;
		_bankPageFirstSlider.maxValue = 98f;
		_bankPageFirstSlider.wholeNumbers = true;
		_bankPageLastSlider.minValue = 1f;
		_bankPageLastSlider.maxValue = 98f;
		_bankPageLastSlider.wholeNumbers = true;
		_bankPageFirstSlider.SetValueWithoutNotify((float)Plugin.BankPageFirst.Value);
		_bankPageLastSlider.SetValueWithoutNotify((float)Plugin.BankPageLast.Value);
		((TMP_Text)_pageFirstText).text = Plugin.BankPageFirst.Value.ToString();
		((TMP_Text)_pageLastText).text = Plugin.BankPageLast.Value.ToString();
		((UnityEvent<float>)(object)_bankPageFirstSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
		{
			int value2 = (int)val;
			Plugin.BankPageFirst.Value = value2;
			((TMP_Text)_pageFirstText).text = value2.ToString();
		});
		((UnityEvent<float>)(object)_bankPageLastSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
		{
			int value = (int)val;
			Plugin.BankPageLast.Value = value;
			((TMP_Text)_pageLastText).text = value.ToString();
		});
		UpdateBankPageSliderInteractable();
	}

	private static void UpdateBankPageSliderInteractable()
	{
		bool interactable = Plugin.BankLootEnabled.Value && Plugin.BankLootPageMode.Value == "Page Range";
		if ((Object)(object)_bankPageFirstSlider != (Object)null)
		{
			((Selectable)_bankPageFirstSlider).interactable = interactable;
		}
		if ((Object)(object)_bankPageLastSlider != (Object)null)
		{
			((Selectable)_bankPageLastSlider).interactable = interactable;
		}
	}

	private static void SetupBlacklistPanel()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		_blackitemContent = Find("panelBG/blacklistPanel/blackitemView/Viewport/blackitemContent");
		_blacklistContent = Find("panelBG/blacklistPanel/blacklistView/Viewport/blacklistContent");
		Transform obj = Find("panelBG/blacklistPanel/blacklistFilter");
		_blackfilterInput = ((obj != null) ? ((Component)obj).GetComponent<TMP_InputField>() : null);
		Transform obj2 = Find("panelBG/blacklistPanel/blackaddBtn");
		_blackaddBtn = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
		Transform obj3 = Find("panelBG/blacklistPanel/blackremoveBtn");
		_blackremoveBtn = ((obj3 != null) ? ((Component)obj3).GetComponent<Button>() : null);
		Button blackaddBtn = _blackaddBtn;
		if (blackaddBtn != null)
		{
			((UnityEventBase)blackaddBtn.onClick).RemoveAllListeners();
		}
		Button blackaddBtn2 = _blackaddBtn;
		if (blackaddBtn2 != null)
		{
			((UnityEvent)blackaddBtn2.onClick).AddListener(new UnityAction(AddSelectedToBlacklist));
		}
		Button blackremoveBtn = _blackremoveBtn;
		if (blackremoveBtn != null)
		{
			((UnityEventBase)blackremoveBtn.onClick).RemoveAllListeners();
		}
		Button blackremoveBtn2 = _blackremoveBtn;
		if (blackremoveBtn2 != null)
		{
			((UnityEvent)blackremoveBtn2.onClick).AddListener(new UnityAction(RemoveSelectedFromBlacklist));
		}
		if ((Object)(object)_blackitemContent == (Object)null || (Object)(object)_blacklistContent == (Object)null)
		{
			Debug.LogError((object)"[LootUI] One or more content panels not found. Check prefab paths.");
			return;
		}
		_allItems = (from x in (from item in GameData.ItemDB.ItemDB
				where !string.IsNullOrWhiteSpace(item.ItemName)
				select item.ItemName).Distinct()
			orderby x
			select x).ToList();
		if ((Object)(object)_blackfilterInput != (Object)null)
		{
			((UnityEventBase)_blackfilterInput.onValueChanged).RemoveAllListeners();
			((UnityEvent<string>)(object)_blackfilterInput.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				RefreshBlacklistUI();
			});
		}
		RefreshBlacklistUI();
	}

	private static void RefreshBlacklistUI()
	{
		ClearList(_blackitemContent);
		ClearList(_blacklistContent);
		_selectedBlackEntries.Clear();
		TMP_InputField blackfilterInput = _blackfilterInput;
		string filter = ((blackfilterInput == null) ? null : blackfilterInput.text?.ToLowerInvariant()) ?? string.Empty;
		List<string> list = (string.IsNullOrEmpty(filter) ? _allItems : _allItems.Where((string item) => item.ToLowerInvariant().Contains(filter)).ToList());
		List<string> list2 = (from item in _blacklist
			where string.IsNullOrEmpty(filter) || item.ToLowerInvariant().Contains(filter)
			orderby item
			select item).ToList();
		foreach (string item in list)
		{
			if (!list2.Contains(item))
			{
				CreateItemEntryBlacklist(_blackitemContent, item, isBlacklist: false);
			}
		}
		foreach (string item2 in list2)
		{
			CreateItemEntryBlacklist(_blacklistContent, item2, isBlacklist: true);
		}
	}

	private static void ClearList(Transform content)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in content)
		{
			Transform val = item;
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
	}

	private static void CreateItemEntryBlacklist(Transform parent, string itemName, bool isBlacklist)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0078: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		GameObject val = new GameObject(itemName);
		val.transform.SetParent(parent, false);
		Text text = val.AddComponent<Text>();
		text.text = itemName;
		text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)text).color = (isBlacklist ? Color.red : Color.white);
		text.fontSize = 14;
		Button val2 = val.AddComponent<Button>();
		((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			float value;
			bool flag = _lastClickTime.TryGetValue(itemName, out value) && time - value < 0.25f;
			_lastClickTime[itemName] = time;
			if (flag)
			{
				if (isBlacklist)
				{
					Plugin.Blacklist.Remove(itemName);
					LootBlacklist.SaveBlacklist();
					UpdateSocialLog.LogAdd("[LootUI] Removed from blacklist: " + itemName, "yellow");
				}
				else
				{
					Plugin.Blacklist.Add(itemName);
					LootBlacklist.SaveBlacklist();
					UpdateSocialLog.LogAdd("[LootUI] Added to blacklist: " + itemName, "yellow");
				}
				RefreshBlacklistUI();
			}
			else
			{
				bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
				bool flag3 = _selectedBlackEntries.Any(((Text text, bool isBlacklist) entry) => (Object)(object)entry.text == (Object)(object)text);
				if (flag2)
				{
					if (flag3)
					{
						((Graphic)text).color = (isBlacklist ? Color.red : Color.white);
						_selectedBlackEntries.RemoveAll(((Text text, bool isBlacklist) entry) => (Object)(object)entry.text == (Object)(object)text);
					}
					else
					{
						((Graphic)text).color = Color.green;
						_selectedBlackEntries.Add((text, isBlacklist));
					}
				}
				else
				{
					foreach (var (val3, flag4) in _selectedBlackEntries)
					{
						((Graphic)val3).color = (flag4 ? Color.red : Color.white);
					}
					_selectedBlackEntries.Clear();
					((Graphic)text).color = Color.green;
					_selectedBlackEntries.Add((text, isBlacklist));
				}
			}
		});
	}

	private static void AddSelectedToBlacklist()
	{
		bool flag = false;
		foreach (var item2 in _selectedBlackEntries.ToList())
		{
			Text item = item2.text;
			if (!Plugin.Blacklist.Contains(item.text))
			{
				Plugin.Blacklist.Add(item.text);
				flag = true;
			}
		}
		if (flag)
		{
			LootBlacklist.SaveBlacklist();
			RefreshBlacklistUI();
			UpdateSocialLog.LogAdd("[LootUI] Added selected items to blacklist.", "yellow");
		}
		else
		{
			UpdateSocialLog.LogAdd("[LootUI] No valid items selected to add.", "red");
		}
	}

	private static void RemoveSelectedFromBlacklist()
	{
		bool flag = false;
		foreach (var item2 in _selectedBlackEntries.ToList())
		{
			Text item = item2.text;
			if (Plugin.Blacklist.Contains(item.text))
			{
				Plugin.Blacklist.Remove(item.text);
				flag = true;
			}
		}
		if (flag)
		{
			LootBlacklist.SaveBlacklist();
			RefreshBlacklistUI();
			UpdateSocialLog.LogAdd("[LootUI] Removed selected items from blacklist.", "yellow");
		}
		else
		{
			UpdateSocialLog.LogAdd("[LootUI] No valid items selected to remove.", "red");
		}
	}

	private static void SetupBanklistPanel()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		_bankitemContent = Find("panelBG/banklistPanel/bankitemView/Viewport/bankitemContent");
		_banklistContent = Find("panelBG/banklistPanel/banklistView/Viewport/banklistContent");
		Transform obj = Find("panelBG/banklistPanel/banklistFilter");
		_bankfilterInput = ((obj != null) ? ((Component)obj).GetComponent<TMP_InputField>() : null);
		Transform obj2 = Find("panelBG/banklistPanel/bankaddBtn");
		_bankaddBtn = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
		Transform obj3 = Find("panelBG/banklistPanel/bankremoveBtn");
		_bankremoveBtn = ((obj3 != null) ? ((Component)obj3).GetComponent<Button>() : null);
		Button bankaddBtn = _bankaddBtn;
		if (bankaddBtn != null)
		{
			((UnityEventBase)bankaddBtn.onClick).RemoveAllListeners();
		}
		Button bankaddBtn2 = _bankaddBtn;
		if (bankaddBtn2 != null)
		{
			((UnityEvent)bankaddBtn2.onClick).AddListener(new UnityAction(AddSelectedToBanklist));
		}
		Button bankremoveBtn = _bankremoveBtn;
		if (bankremoveBtn != null)
		{
			((UnityEventBase)bankremoveBtn.onClick).RemoveAllListeners();
		}
		Button bankremoveBtn2 = _bankremoveBtn;
		if (bankremoveBtn2 != null)
		{
			((UnityEvent)bankremoveBtn2.onClick).AddListener(new UnityAction(RemoveSelectedFromBanklist));
		}
		if ((Object)(object)_bankitemContent == (Object)null || (Object)(object)_banklistContent == (Object)null)
		{
			Debug.LogError((object)"[LootUI] One or more content panels not found. Check prefab paths.");
			return;
		}
		_allItems = (from x in (from item in GameData.ItemDB.ItemDB
				where !string.IsNullOrWhiteSpace(item.ItemName)
				select item.ItemName).Distinct()
			orderby x
			select x).ToList();
		if ((Object)(object)_bankfilterInput != (Object)null)
		{
			((UnityEventBase)_bankfilterInput.onValueChanged).RemoveAllListeners();
			((UnityEvent<string>)(object)_bankfilterInput.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				RefreshBanklistUI();
			});
		}
		RefreshBanklistUI();
	}

	private static void RefreshBanklistUI()
	{
		ClearList(_bankitemContent);
		ClearList(_banklistContent);
		_selectedBankEntries.Clear();
		TMP_InputField bankfilterInput = _bankfilterInput;
		string filter = ((bankfilterInput == null) ? null : bankfilterInput.text?.ToLowerInvariant()) ?? string.Empty;
		List<string> list = (string.IsNullOrEmpty(filter) ? _allItems : _allItems.Where((string item) => item.ToLowerInvariant().Contains(filter)).ToList());
		List<string> list2 = (from item in _banklist
			where string.IsNullOrEmpty(filter) || item.ToLowerInvariant().Contains(filter)
			orderby item
			select item).ToList();
		foreach (string item in list)
		{
			if (!list2.Contains(item))
			{
				CreateItemEntryBanklist(_bankitemContent, item, isBanklist: false);
			}
		}
		foreach (string item2 in list2)
		{
			CreateItemEntryBanklist(_banklistContent, item2, isBanklist: true);
		}
	}

	private static void CreateItemEntryBanklist(Transform parent, string itemName, bool isBanklist)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0078: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		GameObject val = new GameObject(itemName);
		val.transform.SetParent(parent, false);
		Text text = val.AddComponent<Text>();
		text.text = itemName;
		text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)text).color = (isBanklist ? Color.blue : Color.white);
		text.fontSize = 14;
		Button val2 = val.AddComponent<Button>();
		((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			float value;
			bool flag = _lastClickTime.TryGetValue(itemName, out value) && time - value < 0.25f;
			_lastClickTime[itemName] = time;
			if (flag)
			{
				if (isBanklist)
				{
					Plugin.Banklist.Remove(itemName);
					LootBanklist.SaveBanklist();
					UpdateSocialLog.LogAdd("[LootUI] Removed from banklist: " + itemName, "yellow");
				}
				else
				{
					Plugin.Banklist.Add(itemName);
					LootBanklist.SaveBanklist();
					UpdateSocialLog.LogAdd("[LootUI] Added to banklist: " + itemName, "yellow");
				}
				RefreshBanklistUI();
			}
			else
			{
				bool flag2 = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
				bool flag3 = _selectedBankEntries.Any(((Text text, bool isBanklist) entry) => (Object)(object)entry.text == (Object)(object)text);
				if (flag2)
				{
					if (flag3)
					{
						((Graphic)text).color = (isBanklist ? Color.blue : Color.white);
						_selectedBankEntries.RemoveAll(((Text text, bool isBanklist) entry) => (Object)(object)entry.text == (Object)(object)text);
					}
					else
					{
						((Graphic)text).color = Color.green;
						_selectedBankEntries.Add((text, isBanklist));
					}
				}
				else
				{
					foreach (var (val3, flag4) in _selectedBankEntries)
					{
						((Graphic)val3).color = (flag4 ? Color.blue : Color.white);
					}
					_selectedBankEntries.Clear();
					((Graphic)text).color = Color.green;
					_selectedBankEntries.Add((text, isBanklist));
				}
			}
		});
	}

	private static void AddSelectedToBanklist()
	{
		bool flag = false;
		foreach (var item2 in _selectedBankEntries.ToList())
		{
			Text item = item2.text;
			if (!Plugin.Banklist.Contains(item.text))
			{
				Plugin.Banklist.Add(item.text);
				flag = true;
			}
		}
		if (flag)
		{
			LootBanklist.SaveBanklist();
			RefreshBanklistUI();
			UpdateSocialLog.LogAdd("[LootUI] Added selected items to banklist.", "yellow");
		}
		else
		{
			UpdateSocialLog.LogAdd("[LootUI] No valid items selected to add.", "red");
		}
	}

	private static void RemoveSelectedFromBanklist()
	{
		bool flag = false;
		foreach (var item2 in _selectedBankEntries.ToList())
		{
			Text item = item2.text;
			if (Plugin.Banklist.Contains(item.text))
			{
				Plugin.Banklist.Remove(item.text);
				flag = true;
			}
		}
		if (flag)
		{
			LootBanklist.SaveBanklist();
			RefreshBanklistUI();
			UpdateSocialLog.LogAdd("[LootUI] Removed selected items from banklist.", "yellow");
		}
		else
		{
			UpdateSocialLog.LogAdd("[LootUI] No valid items selected to remove.", "red");
		}
	}

	private static void AddDragEvents(GameObject dragHandle, RectTransform panelToMove)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_00ac: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		panelRect = panelToMove;
		EventTrigger val = dragHandle.GetComponent<EventTrigger>();
		if ((Object)(object)val == (Object)null)
		{
			val = dragHandle.AddComponent<EventTrigger>();
		}
		Entry val2 = new Entry
		{
			eventID = (EventTriggerType)2
		};
		((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			PointerEventData val6 = (PointerEventData)data;
			if ((int)val6.button == 0)
			{
				dragging = true;
				GameData.DraggingUIElement = true;
				RectTransformUtility.ScreenPointToLocalPointInRectangle(panelRect, val6.position, (Camera)null, ref dragOffset);
			}
		});
		val.triggers.Add(val2);
		Entry val3 = new Entry
		{
			eventID = (EventTriggerType)5
		};
		((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (dragging)
			{
				Transform parent = ((Transform)panelRect).parent;
				Vector2 val5 = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), ((PointerEventData)data).position, (Camera)null, ref val5);
				panelRect.anchoredPosition = val5 - dragOffset;
			}
		});
		val.triggers.Add(val3);
		Entry val4 = new Entry
		{
			eventID = (EventTriggerType)3
		};
		((UnityEvent<BaseEventData>)(object)val4.callback).AddListener((UnityAction<BaseEventData>)delegate
		{
			dragging = false;
			GameData.DraggingUIElement = false;
		});
		val.triggers.Add(val4);
	}

	private static Transform Find(string path)
	{
		GameObject uiRoot = _uiRoot;
		return (uiRoot != null) ? uiRoot.transform.Find(path) : null;
	}
}
[HarmonyPatch(typeof(TypeText), "CheckCommands")]
public static class LootCommands
{
	public static bool Prefix()
	{
		string text = GameData.TextInput.typed.text;
		if (string.IsNullOrWhiteSpace(text))
		{
			return true;
		}
		if (text.Equals("/lootui", StringComparison.OrdinalIgnoreCase))
		{
			LootManagerUI.Instance?.ToggleUI();
			ClearInput();
			return false;
		}
		return true;
	}

	private static void ClearInput()
	{
		GameData.TextInput.typed.text = "";
		GameData.TextInput.CDFrames = 10f;
		GameData.TextInput.InputBox.SetActive(false);
		GameData.PlayerTyping = false;
	}
}
[Serializable]
public class LootBanklistData
{
	public List<string> items = new List<string>();
}
public static class LootBanklist
{
	private const string BanklistFileName = "LootBanklist.json";

	public static void Load()
	{
		string path = Path.Combine(Paths.ConfigPath, "LootBanklist.json");
		if (!File.Exists(path))
		{
			File.WriteAllText(path, JsonUtility.ToJson((object)new LootBanklistData(), true));
			Plugin.Log.LogInfo((object)"Created empty loot banklist file.");
			return;
		}
		try
		{
			string text = File.ReadAllText(path);
			LootBanklistData lootBanklistData = JsonUtility.FromJson<LootBanklistData>(text);
			if (lootBanklistData?.items != null)
			{
				Plugin.Banklist = new HashSet<string>(lootBanklistData.items, StringComparer.OrdinalIgnoreCase);
				Plugin.Log.LogInfo((object)$"Loaded {Plugin.Banklist.Count} banklisted items.");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("Failed to load banklist: " + ex));
		}
	}

	public static void SaveBanklist()
	{
		LootBanklistData lootBanklistData = new LootBanklistData
		{
			items = new List<string>(Plugin.Banklist)
		};
		string contents = JsonUtility.ToJson((object)lootBanklistData, true);
		string path = Path.Combine(Paths.ConfigPath, "LootBanklist.json");
		File.WriteAllText(path, contents);
	}
}
[Serializable]
public class LootBlacklistData
{
	public List<string> items = new List<string>();
}
public static class LootBlacklist
{
	private const string BlacklistFileName = "LootBlacklist.json";

	public static void Load()
	{
		string path = Path.Combine(Paths.ConfigPath, "LootBlacklist.json");
		if (!File.Exists(path))
		{
			File.WriteAllText(path, JsonUtility.ToJson((object)new LootBlacklistData(), true));
			Plugin.Log.LogInfo((object)"Created empty loot blacklist file.");
			return;
		}
		try
		{
			string text = File.ReadAllText(path);
			LootBlacklistData lootBlacklistData = JsonUtility.FromJson<LootBlacklistData>(text);
			if (lootBlacklistData?.items != null)
			{
				Plugin.Blacklist = new HashSet<string>(lootBlacklistData.items, StringComparer.OrdinalIgnoreCase);
				Plugin.Log.LogInfo((object)$"Loaded {Plugin.Blacklist.Count} blacklisted items.");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("Failed to load blacklist: " + ex));
		}
	}

	public static void SaveBlacklist()
	{
		LootBlacklistData lootBlacklistData = new LootBlacklistData
		{
			items = new List<string>(Plugin.Blacklist)
		};
		string contents = JsonUtility.ToJson((object)lootBlacklistData, true);
		string path = Path.Combine(Paths.ConfigPath, "LootBlacklist.json");
		File.WriteAllText(path, contents);
	}
}
public static class BankLoot
{
	public class LootEntry
	{
		public string Id { get; }

		public int Quantity { get; }

		public string Name { get; }

		public LootEntry(string id, int quantity, string name)
		{
			Id = id;
			Quantity = quantity;
			Name = name;
		}
	}

	public static void DepositLoot(IEnumerable<LootEntry> entries)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		string text = Path.Combine(Application.persistentDataPath, "ESSaveData");
		string path = Path.Combine(text, "GBDATA");
		string path2 = Application.persistentDataPath + "GBDATA";
		BankSaveData val = (BankSaveData)(File.Exists(path) ? JsonUtility.FromJson<BankSaveData>(File.ReadAllText(path)) : ((!File.Exists(path2)) ? ((object)new BankSaveData
		{
			BankData = Enumerable.Repeat(string.Empty, 3168).ToList(),
			BankCount = Enumerable.Repeat(1, 3168).ToList()
		}) : ((object)JsonUtility.FromJson<BankSaveData>(File.ReadAllText(path2)))));
		int count = val.BankData.Count;
		int num = 32;
		int num2 = Mathf.CeilToInt((float)count / (float)num);
		string value = Plugin.BankLootPageMode.Value;
		int num3 = Mathf.Clamp(Plugin.BankPageFirst.Value, 1, num2);
		int num4 = Mathf.Clamp(Plugin.BankPageLast.Value, 1, num2);
		int num5 = (num3 - 1) * num;
		int num6 = num4 * num;
		bool flag = false;
		foreach (LootEntry entry in entries)
		{
			bool flag2 = false;
			Item itemByID = GameData.ItemDB.GetItemByID(entry.Id);
			if (itemByID != null && itemByID.Stackable)
			{
				for (int i = 0; i < count; i++)
				{
					if (val.BankData[i] == entry.Id)
					{
						val.BankCount[i] += entry.Quantity;
						flag2 = true;
						break;
					}
				}
			}
			if (!flag2)
			{
				int num7 = 0;
				int num8 = count;
				if (value == "Page Range")
				{
					num7 = num5;
					num8 = Mathf.Min(num6, count);
				}
				for (int j = num7; j < num8; j++)
				{
					if (string.IsNullOrEmpty(val.BankData[j]))
					{
						val.BankData[j] = entry.Id;
						val.BankCount[j] = entry.Quantity;
						flag2 = true;
						break;
					}
				}
			}
			if (flag2)
			{
				flag = true;
				UpdateSocialLog.LogAdd("[Loot Manager] Deposited \"" + entry.Name + "\" into bank.", "lightblue");
			}
			else
			{
				UpdateSocialLog.LogAdd("[Loot Manager] No bank space. Adding \"" + entry.Name + "\" to inventory instead.", "orange");
				Item itemByID2 = GameData.ItemDB.GetItemByID(entry.Id);
				StandardLoot.LootToInv(itemByID2, entry.Quantity, entry.Name);
			}
		}
		if (flag)
		{
			Directory.CreateDirectory(text);
			File.WriteAllText(path, JsonUtility.ToJson((object)val));
		}
	}
}
public static class StandardLoot
{
	public static void LootToInv(Item item, int qty, string name = null)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)item == (Object)null))
		{
			if (((int)item.RequiredSlot == 0) ? GameData.PlayerInv.AddItemToInv(item) : GameData.PlayerInv.AddItemToInv(item, qty))
			{
				UpdateSocialLog.LogAdd("[Loot Manager] Looted \"" + (name ?? item.ItemName) + "\" to inventory", "yellow");
			}
			else
			{
				UpdateSocialLog.LogAdd("[Loot Manager] No room for \"" + (name ?? item.ItemName) + "\"", "yellow");
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "DoDeath")]
[HarmonyPriority(50000)]
[HarmonyAfter(new string[] { "Brumdail.ErenshorREL" })]
public class Autoloot
{
	private static void Postfix(Character __instance)
	{
		//IL_0080: 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)
		if (!Plugin.AutoLootEnabled.Value || (Object)(object)__instance == (Object)null || !__instance.isNPC || (Object)(object)__instance.MyNPC == (Object)null)
		{
			return;
		}
		Character myself = GameData.PlayerControl.Myself;
		if ((Object)(object)myself == (Object)null || !myself.Alive)
		{
			return;
		}
		float value = Plugin.AutoLootDistance.Value;
		float num = Vector3.Distance(((Component)myself).transform.position, ((Component)__instance.MyNPC).transform.position);
		if (!(num >= value))
		{
			LootTable component = ((Component)__instance.MyNPC).GetComponent<LootTable>();
			if ((Object)(object)component != (Object)null)
			{
				UpdateSocialLog.LogAdd("[Loot Manager] Looting NPC: " + ((Object)__instance.MyNPC).name, "yellow");
				component.LoadLootTable();
				GameData.LootWindow.LootAll();
			}
		}
	}
}
[HarmonyPatch(typeof(LootWindow), "LootAll")]
[HarmonyPriority(800)]
public static class LootWindowPatch
{
	public static bool Prefix(LootWindow __instance)
	{
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		string value = Plugin.LootMethod.Value;
		bool value2 = Plugin.BankLootEnabled.Value;
		string value3 = Plugin.BankLootMethod.Value;
		List<BankLoot.LootEntry> list = new List<BankLoot.LootEntry>();
		foreach (ItemIcon lootSlot in __instance.LootSlots)
		{
			Item myItem = lootSlot.MyItem;
			int quantity = lootSlot.Quantity;
			if ((Object)(object)myItem == (Object)(object)GameData.PlayerInv.Empty)
			{
				continue;
			}
			string itemName = myItem.ItemName;
			if (value == "Blacklist" && Plugin.Blacklist.Contains(itemName))
			{
				UpdateSocialLog.LogAdd("[Loot Manager] Destroyed \"" + itemName + "\"", "grey");
				lootSlot.MyItem = GameData.PlayerInv.Empty;
				lootSlot.Quantity = 1;
				lootSlot.UpdateSlotImage();
				continue;
			}
			bool flag = false;
			if (value2)
			{
				if (value3 == "All")
				{
					flag = true;
				}
				else if (value3 == "Filtered" && Plugin.Banklist.Contains(itemName))
				{
					flag = true;
				}
			}
			if (flag)
			{
				list.Add(new BankLoot.LootEntry(((BaseScriptableObject)myItem).Id, quantity, itemName));
			}
			else
			{
				if (!(((int)myItem.RequiredSlot == 0) ? GameData.PlayerInv.AddItemToInv(myItem) : GameData.PlayerInv.AddItemToInv(myItem, quantity)))
				{
					UpdateSocialLog.LogAdd("[Loot Manager] No room for \"" + itemName + "\"", "yellow");
					continue;
				}
				UpdateSocialLog.LogAdd("[Loot Manager] Looted \"" + itemName + "\" to inventory", "yellow");
				lootSlot.InformGroupOfLoot(myItem);
			}
			lootSlot.MyItem = GameData.PlayerInv.Empty;
			lootSlot.Quantity = 1;
			lootSlot.UpdateSlotImage();
		}
		if (list.Count > 0)
		{
			BankLoot.DepositLoot(list);
		}
		GameData.PlayerAud.PlayOneShot(((Component)GameData.GM).GetComponent<Misc>().DropItem, GameData.PlayerAud.volume / 2f * GameData.SFXVol);
		__instance.CloseWindow();
		return false;
	}
}
public class TrashSlotPatch : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <MoveTrashSlot>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public TrashSlotPatch <>4__this;

		private GameObject <playerInv>5__1;

		private GameObject <trashSlot>5__2;

		private RectTransform <rtTrash>5__3;

		private GameObject <text1>5__4;

		private RectTransform <rtText1>5__5;

		private int <count>5__6;

		private IEnumerator <>s__7;

		private Transform <child>5__8;

		private RectTransform <rtText>5__9;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveTrashSlot>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<playerInv>5__1 = null;
			<trashSlot>5__2 = null;
			<rtTrash>5__3 = null;
			<text1>5__4 = null;
			<rtText1>5__5 = null;
			<>s__7 = null;
			<child>5__8 = null;
			<rtText>5__9 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)GameObject.Find("PlayerInv") == (Object)null || (Object)(object)GameObject.Find("TrashSlot") == (Object)null || (Object)(object)GameObject.Find("Text (TMP) (1)") == (Object)null)
			{
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<playerInv>5__1 = GameObject.Find("PlayerInv");
			Transform obj = <playerInv>5__1.transform.Find("TrashSlot");
			<trashSlot>5__2 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)<trashSlot>5__2 != (Object)null && <trashSlot>5__2.TryGetComponent<RectTransform>(ref <rtTrash>5__3))
			{
				RectTransform obj2 = <rtTrash>5__3;
				obj2.anchoredPosition += new Vector2(-74f, 0f);
			}
			Transform obj3 = <playerInv>5__1.transform.Find("Text (TMP) (1)");
			<text1>5__4 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
			if ((Object)(object)<text1>5__4 != (Object)null && <text1>5__4.TryGetComponent<RectTransform>(ref <rtText1>5__5))
			{
				RectTransform obj4 = <rtText1>5__5;
				obj4.anchoredPosition += new Vector2(-71f, 0f);
			}
			<count>5__6 = 0;
			<>s__7 = <playerInv>5__1.transform.GetEnumerator();
			try
			{
				while (<>s__7.MoveNext())
				{
					<child>5__8 = (Transform)<>s__7.Current;
					if (((Object)<child>5__8).name == "Text (TMP)")
					{
						<count>5__6++;
						if (<count>5__6 == 2)
						{
							if (((Component)<child>5__8).TryGetComponent<RectTransform>(ref <rtText>5__9))
							{
								RectTransform obj5 = <rtText>5__9;
								obj5.anchoredPosition += new Vector2(-74f, 0f);
							}
							break;
						}
					}
					<child>5__8 = null;
				}
			}
			finally
			{
				if (<>s__7 is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
			<>s__7 = null;
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(MoveTrashSlot());
	}

	[IteratorStateMachine(typeof(<MoveTrashSlot>d__1))]
	private IEnumerator MoveTrashSlot()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveTrashSlot>d__1(0)
		{
			<>4__this = this
		};
	}
}
[BepInPlugin("et508.erenshor.lootmanager", "Loot Manager", "2.0.0")]
[BepInProcess("Erenshor.exe")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static HashSet<string> Blacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

	internal static HashSet<string> Banklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

	public static ConfigEntry<bool> AutoLootEnabled;

	public static ConfigEntry<float> AutoLootDistance;

	public static ConfigEntry<string> LootMethod;

	public static ConfigEntry<bool> BankLootEnabled;

	public static ConfigEntry<string> BankLootMethod;

	public static ConfigEntry<string> BankLootPageMode;

	public static ConfigEntry<int> BankPageFirst;

	public static ConfigEntry<int> BankPageLast;

	private void Awake()
	{
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		AutoLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Autoloot Settings", "Enable Autoloot", true, "Enable or disable auto looting.");
		AutoLootDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Autoloot Settings", "Autoloot Distance", 20f, "Maximum distance for auto looting.");
		LootMethod = ((BaseUnityPlugin)this).Config.Bind<string>("Loot Method Settings", "Loot Method", "Blacklist", "Loot method to use: Blacklist, Whitelist, or Standard.");
		BankLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Bankloot Settings", "Bankloot Enabled", false, "If enabled, looted items will be deposited to bank instead of inventory.");
		BankLootMethod = ((BaseUnityPlugin)this).Config.Bind<string>("Bankloot Settings", "Bankloot Method", "All", "Method for bank looting: All or Filtered");
		BankLootPageMode = ((BaseUnityPlugin)this).Config.Bind<string>("Bankloot Settings", "Bankloot Page Mode", "First Empty", "Mode for depositing items to bank: First Empty or Page Range");
		BankPageFirst = ((BaseUnityPlugin)this).Config.Bind<int>("Bankloot Settings", "Bank Page First", 20, new ConfigDescription("First bank page to use when in Page Range mode.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 98), Array.Empty<object>()));
		BankPageLast = ((BaseUnityPlugin)this).Config.Bind<int>("Bankloot Settings", "Bank Page Last", 20, new ConfigDescription("Last bank page to use when in Page Range mode.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 98), Array.Empty<object>()));
		LootBlacklist.Load();
		LootBanklist.Load();
		Log.LogInfo((object)"Loot Manager loaded.");
		Harmony val = new Harmony("et508.erenshor.lootmanager");
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			if (assembly.GetName().Name == "ErenshorQoL")
			{
				string text = "Brumdail.ErenshorQoLMod";
				MethodInfo methodInfo = AccessTools.Method(typeof(LootWindow), "LootAll", (Type[])null, (Type[])null);
				val.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)1, text);
				Log.LogWarning((object)"[LootManager] Unpatched ErenshorQoL LootAll prefix.");
				MethodInfo methodInfo2 = AccessTools.Method(typeof(Character), "DoDeath", new Type[0], (Type[])null);
				if (methodInfo2 != null)
				{
					val.Unpatch((MethodBase)methodInfo2, (HarmonyPatchType)2, text);
					Log.LogWarning((object)"[LootManager] Unpatched ErenshorQoL DoDeath postfix.");
				}
				else
				{
					Log.LogError((object)"[LootManager] Failed to find Character.DoDeath for unpatching.");
				}
				break;
			}
		}
		val.PatchAll();
		LootManagerController.Initialize();
	}
}
public class BlacklistSlot : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <WaitAndCreateSlot>d__5 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlacklistSlot <>4__this;

		private GameObject <templateSlot>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WaitAndCreateSlot>d__5(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<templateSlot>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<templateSlot>5__1 = null;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)<templateSlot>5__1 == (Object)null)
			{
				<templateSlot>5__1 = GameObject.Find("TrashSlot");
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<>4__this.CreateSlot(<templateSlot>5__1);
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static BlacklistSlot Instance;

	public ItemIcon Slot;

	private GameObject slotContainer;

	private void Awake()
	{
		if ((Object)(object)Instance != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Instance = this;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
	}

	public void InitSlotAsync()
	{
		((MonoBehaviour)this).StartCoroutine(WaitAndCreateSlot());
	}

	[IteratorStateMachine(typeof(<WaitAndCreateSlot>d__5))]
	private IEnumerator WaitAndCreateSlot()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitAndCreateSlot>d__5(0)
		{
			<>4__this = this
		};
	}

	public void CreateSlot(GameObject templateSlot)
	{
		//IL_0058: 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)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)slotContainer != (Object)null) && !((Object)(object)templateSlot == (Object)null))
		{
			slotContainer = Object.Instantiate<GameObject>(templateSlot, templateSlot.transform.parent);
			((Object)slotContainer).name = "BlacklistSlot";
			RectTransform component = slotContainer.GetComponent<RectTransform>();
			component.anchoredPosition += new Vector2(73f, 0f);
			Text componentInChildren = slotContainer.GetComponentInChildren<Text>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.text = "Blacklist";
			}
			Slot = slotContainer.GetComponentInChildren<ItemIcon>();
			if ((Object)(object)Slot == (Object)null)
			{
				Debug.LogError((object)"[LootManager] BlacklistSlot: Failed to get ItemIcon component on cloned slot.");
				return;
			}
			Slot.TrashSlot = false;
			Slot.MouseSlot = false;
		}
	}

	private void Update()
	{
		if (!((Object)(object)Slot == (Object)null) && !((Object)(object)Slot.MyItem == (Object)null) && !((Object)(object)Slot.MyItem == (Object)(object)GameData.PlayerInv.Empty))
		{
			string itemName = Slot.MyItem.ItemName;
			if (!Plugin.Blacklist.Contains(itemName))
			{
				Plugin.Blacklist.Add(itemName);
				LootBlacklist.SaveBlacklist();
				UpdateSocialLog.LogAdd("[Loot Manager] Added to blacklist: " + itemName, "yellow");
			}
			Slot.MyItem = GameData.PlayerInv.Empty;
			Slot.UpdateSlotImage();
		}
	}
}
public class LootManagerUI : MonoBehaviour
{
	private const string BundleFileName = "lootui";

	private const string PrefabAssetName = "lootui";

	private AssetBundle _uiBundle;

	private GameObject _uiRoot;

	public static LootManagerUI Instance { get; private set; }

	private void Awake()
	{
		if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Instance = this;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		LoadUIFromBundle();
	}

	private void LoadUIFromBundle()
	{
		Plugin.Log.LogInfo((object)"[Loot Manager] Creating Loot UI...");
		string location = Assembly.GetExecutingAssembly().Location;
		string directoryName = Path.GetDirectoryName(location);
		string text = Path.Combine(directoryName, "lootui");
		if (!File.Exists(text))
		{
			Debug.LogError((object)("[LootManagerUI] AssetBundle not found at: " + text));
			return;
		}
		_uiBundle = AssetBundle.LoadFromFile(text);
		if ((Object)(object)_uiBundle == (Object)null)
		{
			Debug.LogError((object)"[LootManagerUI] Failed to load AssetBundle!");
			return;
		}
		GameObject val = _uiBundle.LoadAsset<GameObject>("lootui");
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"[Loot Manager] Prefab 'lootui' not found in bundle.");
			return;
		}
		_uiRoot = Object.Instantiate<GameObject>(val);
		LootUIController.Initialize(_uiRoot);
		Object.DontDestroyOnLoad((Object)(object)_uiRoot);
		_uiRoot.SetActive(false);
		Plugin.Log.LogInfo((object)"[Loot Manager] Loot UI initialized successfully.");
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)287) && (Object)(object)Instance == (Object)(object)this)
		{
			ToggleUI();
		}
	}

	public void ToggleUI()
	{
		if (!((Object)(object)_uiRoot == (Object)null))
		{
			bool flag = !_uiRoot.activeSelf;
			_uiRoot.SetActive(flag);
			GameData.PlayerTyping = flag;
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)_uiBundle != (Object)null)
		{
			_uiBundle.Unload(false);
			_uiBundle = null;
		}
		if ((Object)(object)_uiRoot != (Object)null)
		{
			Object.Destroy((Object)(object)_uiRoot);
			_uiRoot = null;
		}
		Instance = null;
	}
}