Decompiled source of LethalMuseum v1.1.0

LethalMuseum.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using LethalMuseum.Dependencies.InputUtils;
using LethalMuseum.Dependencies.LethalConfig;
using LethalMuseum.Dependencies.LethalLib;
using LethalMuseum.Dependencies.RuntimeIcons;
using LethalMuseum.Helpers;
using LethalMuseum.Objects;
using LethalMuseum.Objects.Models;
using LethalMuseum.Patches;
using LethalMuseum.UI.Elements;
using Microsoft.CodeAnalysis;
using RuntimeIcons;
using RuntimeIcons.Components;
using RuntimeIcons.Utils;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
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: IgnoresAccessChecksTo("RuntimeIcons")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalMuseum")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+c6e43361ed4e1b04d1d67f336ee6bd3b662442f5")]
[assembly: AssemblyProduct("LethalMuseum")]
[assembly: AssemblyTitle("LethalMuseum")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalMuseum
{
	public class Configuration
	{
		public readonly ConfigEntry<string> Blacklist;

		public readonly ConfigEntry<bool> AllowBaby;

		public readonly ConfigEntry<bool> AllowBody;

		public readonly ConfigEntry<bool> AutomaticIconGeneration;

		public Configuration(ConfigFile cfg)
		{
			Blacklist = cfg.Bind<string>("General", "itemBlacklist", "", "List of every item to disable by default");
			AllowBaby = cfg.Bind<bool>("Items", "allowBabyItem", false, "Defines if the Maneater should count as an item to collect.\n\nThis can lead to problem from the tracker, but it is a fun challenge.");
			AllowBody = cfg.Bind<bool>("Items", "allowBodyItem", false, "Defines if the body of a dead player should count as an item to collect.");
			AutomaticIconGeneration = cfg.Bind<bool>("Dependency", "automaticIconGeneration", true, "Defines if this mod will force RuntimeIcons to automatically generate all the icons upon loading a game.");
		}
	}
	internal static class Constants
	{
		public const string MAIN_MENU_PARENT_PATH = "Canvas/MenuContainer";

		public const string MAIN_MENU_SIBLING_BEFORE = "LobbyHostSettings";

		public const string MAIN_MENU_CENTRAL_MENU_NAME = "MainButtons";

		public const string IN_GAME_PARENT_PATH = "Systems/UI/Canvas";

		public const string IN_GAME_SIBLING_BEFORE = "LoadingText";

		public const int ITEMS_PER_PAGE = 16;

		public static Color BLACKED_COLOR = new Color(0.3f, 0.3f, 0.3f);
	}
	[BepInPlugin("LethalMuseum", "LethalMuseum", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LethalMuseum : BaseUnityPlugin
	{
		internal static GameObject? ITEMS_BOARD;

		internal static GameObject? MUSEUM_FORM;

		internal static Texture2D? MOD_ICON;

		private Harmony? Harmony;

		internal static Configuration? Configuration;

		private void Awake()
		{
			Logger.SetLogger(((BaseUnityPlugin)this).Logger);
			if (LoadAssets("lm-bundle"))
			{
				LoadConfiguration(((BaseUnityPlugin)this).Config);
				LoadDependencies();
				Patch();
				Logger.Info("LethalMuseum v1.1.0 has loaded!");
			}
		}

		private static bool LoadAssets(string bundleName)
		{
			if (!Bundle.LoadBundle(bundleName))
			{
				return false;
			}
			ITEMS_BOARD = Bundle.LoadAsset<GameObject>("ItemsBoard");
			MUSEUM_FORM = Bundle.LoadAsset<GameObject>("MuseumForm");
			MOD_ICON = Bundle.LoadAsset<Texture2D>("lm-icon");
			return true;
		}

		private void Patch()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Harmony = new Harmony("LethalMuseum");
			Harmony.PatchAll(typeof(MenuManager_Patches));
			Harmony.PatchAll(typeof(global::LethalMuseum.Patches.PlayerControllerB_Patches));
			Harmony.PatchAll(typeof(StartOfRound_Patches));
			if (global::LethalMuseum.Dependencies.RuntimeIcons.Dependency.Enabled)
			{
				Harmony.PatchAll(typeof(CameraQueueComponent_Patches));
				Harmony.PatchAll(typeof(global::LethalMuseum.Dependencies.RuntimeIcons.PlayerControllerB_Patches));
				Harmony.PatchAll(typeof(RenderingRequest_Patches));
			}
		}

		private static void LoadDependencies()
		{
			CustomInputActions.Actions = new CustomInputActions();
			ModdedItemIdentifier.LoadModdedItems();
			if (ConfigToUI.Enabled)
			{
				ConfigToUI.AddConfigs(Configuration);
			}
		}

		private static void LoadConfiguration(ConfigFile file)
		{
			Configuration = new Configuration(file);
			Configuration.Blacklist.SettingChanged += delegate
			{
				Register.ApplyBlacklist(Configuration.Blacklist.Value);
			};
			Register.ApplyBlacklist(Configuration.Blacklist.Value);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalMuseum";

		public const string PLUGIN_NAME = "LethalMuseum";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace LethalMuseum.UI.Forms
{
	public class ToggleForm : MonoBehaviour
	{
		[Header("Fields")]
		[SerializeField]
		private Transform? itemListContainer;

		[SerializeField]
		private GameObject? itemPrefab;

		[SerializeField]
		private GameObject? noItemText;

		[Header("Controls")]
		[SerializeField]
		private Toggle? allToggle;

		[SerializeField]
		private Toggle? scrapsToggle;

		[SerializeField]
		private Toggle? toolsToggle;

		[SerializeField]
		private Toggle? basesToggle;

		[SerializeField]
		private Toggle? variantsToggle;

		[SerializeField]
		private Toggle? oneHandedToggle;

		[SerializeField]
		private Toggle? twoHandedToggle;

		[SerializeField]
		private Toggle? conductiveToggle;

		[SerializeField]
		private Toggle? batteryToggle;

		[SerializeField]
		private Toggle? vanillaToggle;

		[SerializeField]
		private Toggle? moddedToggle;

		[Header("View")]
		[SerializeField]
		private Toggle? enabledToggle;

		[SerializeField]
		private Toggle? disabledToggle;

		[Header("Buttons")]
		[SerializeField]
		private Button? openBtn;

		[SerializeField]
		private Button? closeBtn;

		[Header("Animations")]
		[SerializeField]
		private Animator? animator;

		private static readonly int OpenMenu = Animator.StringToHash("openMenu");

		private static readonly int CloseMenu = Animator.StringToHash("closeMenu");

		private void Start()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			MenuManager val = Object.FindObjectOfType<MenuManager>();
			Button? obj = openBtn;
			if (obj != null)
			{
				((UnityEvent)obj.onClick).AddListener(new UnityAction(OpenForm));
			}
			Button? obj2 = openBtn;
			if (obj2 != null)
			{
				((UnityEvent)obj2.onClick).AddListener(new UnityAction(val.PlayConfirmSFX));
			}
			Button? obj3 = closeBtn;
			if (obj3 != null)
			{
				((UnityEvent)obj3.onClick).AddListener(new UnityAction(CloseForm));
			}
			Button? obj4 = closeBtn;
			if (obj4 != null)
			{
				((UnityEvent)obj4.onClick).AddListener(new UnityAction(val.PlayCancelSFX));
			}
			((UnityEvent<bool>)(object)allToggle?.onValueChanged).AddListener((UnityAction<bool>)onAllToggled);
			AddToggle(scrapsToggle, (ItemEntry item) => item.Item.isScrap);
			AddToggle(toolsToggle, (ItemEntry item) => !item.Item.isScrap);
			AddToggle(basesToggle, (ItemEntry item) => item.IsBase);
			AddToggle(variantsToggle, (ItemEntry item) => item.IsVariant);
			AddToggle(oneHandedToggle, (ItemEntry item) => !item.Item.twoHanded);
			AddToggle(twoHandedToggle, (ItemEntry item) => item.Item.twoHanded);
			AddToggle(conductiveToggle, (ItemEntry item) => item.Item.isConductiveMetal);
			AddToggle(batteryToggle, (ItemEntry item) => item.Item.requiresBattery);
			AddToggle(vanillaToggle, (ItemEntry item) => !item.IsModded);
			AddToggle(moddedToggle, (ItemEntry item) => item.IsModded);
			((UnityEvent<bool>)(object)enabledToggle?.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				UpdateAllItems();
			});
			((UnityEvent<bool>)(object)disabledToggle?.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				UpdateAllItems();
			});
		}

		private void OpenForm()
		{
			UpdateAllItems();
			Animator? obj = animator;
			if (obj != null)
			{
				obj.SetTrigger(OpenMenu);
			}
		}

		private void CloseForm()
		{
			if (LethalMuseum.Configuration != null)
			{
				LethalMuseum.Configuration.Blacklist.Value = Register.GenerateBlacklist();
			}
			Animator? obj = animator;
			if (obj != null)
			{
				obj.SetTrigger(CloseMenu);
			}
		}

		private void UpdateAllItems()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)(object)itemListContainer == (Object)null)
			{
				return;
			}
			ItemEntry[] all = Register.GetAll();
			foreach (Transform item2 in itemListContainer)
			{
				Transform val = item2;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			GameObject? obj = noItemText;
			if (obj != null)
			{
				obj.SetActive(all.Length == 0);
			}
			ItemEntry[] array = all;
			foreach (ItemEntry item in array)
			{
				if (ShowItem(item))
				{
					AddItem(item);
				}
			}
		}

		private void AddItem(ItemEntry item)
		{
			if ((Object)(object)itemListContainer == (Object)null || (Object)(object)itemPrefab == (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(itemPrefab, itemListContainer, false);
			((Object)val).name = item.Name;
			ItemList itemList = default(ItemList);
			if (val.TryGetComponent<ItemList>(ref itemList))
			{
				itemList.SetItem(item);
				ItemList itemList2 = itemList;
				itemList2.OnActiveChanged = (Action<bool>)Delegate.Combine(itemList2.OnActiveChanged, (Action<bool>)delegate(bool isActive)
				{
					Register.SetItemEnable(item.ID, isActive);
					UpdateAllItems();
				});
			}
		}

		private bool ShowItem(ItemEntry item)
		{
			bool flag = Register.IsEnabled(item.ID);
			if ((Object)(object)enabledToggle != (Object)null && flag)
			{
				return enabledToggle.isOn;
			}
			if ((Object)(object)disabledToggle != (Object)null && !flag)
			{
				return disabledToggle.isOn;
			}
			return true;
		}

		private void AddToggle(Toggle? toggle, Func<ItemEntry, bool> condition)
		{
			Func<ItemEntry, bool> condition2 = condition;
			((UnityEvent<bool>)(object)toggle?.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isActive)
			{
				Register.ApplyFilter(condition2, isActive);
				UpdateAllItems();
			});
		}

		private void onAllToggled(bool isActive)
		{
			Register.ApplyFilter((ItemEntry _) => true, isActive);
			UpdateAllItems();
			Toggle[] array = (Toggle[])(object)new Toggle[10] { scrapsToggle, toolsToggle, basesToggle, variantsToggle, oneHandedToggle, twoHandedToggle, conductiveToggle, batteryToggle, vanillaToggle, moddedToggle };
			Toggle[] array2 = array;
			foreach (Toggle val in array2)
			{
				if (val != null)
				{
					val.SetIsOnWithoutNotify(isActive);
				}
			}
		}
	}
}
namespace LethalMuseum.UI.Elements
{
	public class ItemBoard : MonoBehaviour
	{
		[SerializeField]
		private Image? icon;

		[SerializeField]
		private TMP_Text? text;

		[SerializeField]
		private Image? collectedBackground;

		private ItemEntry? shownItem;

		internal void SetItem(ItemEntry item)
		{
			shownItem = item;
			((Object)((Component)this).gameObject).name = item.ID;
			UpdateSelf();
		}

		internal void OnItemUpdate(string id)
		{
			if (shownItem.HasValue && !(shownItem.Value.ID != id))
			{
				UpdateSelf();
			}
		}

		private void UpdateSelf()
		{
			//IL_0086: 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)
			if (shownItem.HasValue)
			{
				if ((Object)(object)icon != (Object)null)
				{
					((Behaviour)icon).enabled = IsIconEnabled(shownItem.Value);
					icon.sprite = shownItem.Value.Icon;
					((Graphic)icon).color = (shownItem.Value.IsBase ? Constants.BLACKED_COLOR : Color.white);
				}
				if ((Object)(object)text != (Object)null)
				{
					((Behaviour)text).enabled = IsTextEnabled(shownItem.Value);
					text.text = shownItem.Value.Name;
				}
				if ((Object)(object)collectedBackground != (Object)null)
				{
					((Behaviour)collectedBackground).enabled = Tracker.Instance?.IsCollected(shownItem.Value.ID) ?? false;
				}
			}
		}

		private static bool IsIconEnabled(ItemEntry item)
		{
			return item.IsBase || item.HasCustomIcon;
		}

		private static bool IsTextEnabled(ItemEntry item)
		{
			return item.IsBase || !item.HasCustomIcon;
		}
	}
	public class ItemList : MonoBehaviour
	{
		[SerializeField]
		private Image? icon;

		[SerializeField]
		private TMP_Text? text;

		[SerializeField]
		private Toggle? toggle;

		internal Action<bool>? OnActiveChanged;

		private void Start()
		{
			((UnityEvent<bool>)(object)toggle?.onValueChanged).AddListener((UnityAction<bool>)ToggleItem);
		}

		internal void SetItem(ItemEntry item)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			((Object)((Component)this).gameObject).name = item.ID;
			if ((Object)(object)icon != (Object)null)
			{
				((Behaviour)icon).enabled = item.HasCustomIcon;
				icon.sprite = item.Icon;
				((Graphic)icon).color = (item.IsBase ? Constants.BLACKED_COLOR : Color.white);
			}
			if ((Object)(object)text != (Object)null)
			{
				text.text = item.Name;
				((Behaviour)text).enabled = !item.HasCustomIcon || item.IsBase;
			}
			if ((Object)(object)toggle != (Object)null)
			{
				toggle.isOn = Register.IsEnabled(item.ID);
			}
		}

		private void ToggleItem(bool isActive)
		{
			OnActiveChanged?.Invoke(isActive);
		}
	}
	public class ItemsBoard : MonoBehaviour
	{
		[Header("Items")]
		[SerializeField]
		private Transform? itemsContainer;

		[SerializeField]
		private GameObject? itemPrefab;

		[Header("Amounts")]
		[SerializeField]
		private TMP_Text? collectedAmountText;

		[SerializeField]
		private TMP_Text? totalAmountText;

		[SerializeField]
		private TMP_Text? percentAmountText;

		[Header("Pages")]
		[SerializeField]
		private TMP_Text? pageText;

		[SerializeField]
		private Graphic? leftPageIcon;

		[SerializeField]
		private Graphic? rightPageIcon;

		internal static ItemsBoard? Instance;

		private int pageIndex = 1;

		private event Action<string>? OnItemUpdated;

		private void Start()
		{
			Subscribe();
			UpdatePage();
			UpdateInformation();
			Instance = this;
		}

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

		private void UpdateInformation()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			int num = Tracker.Instance?.GetCollectedCount() ?? 0;
			int registeredCount = Register.GetRegisteredCount();
			if ((Object)(object)collectedAmountText != (Object)null)
			{
				collectedAmountText.text = num.ToString();
				((Graphic)collectedAmountText).color = ((num >= registeredCount) ? Color.green : Color.white);
			}
			if ((Object)(object)totalAmountText != (Object)null)
			{
				totalAmountText.text = registeredCount.ToString();
				((Graphic)totalAmountText).color = ((num >= registeredCount) ? Color.green : Color.white);
			}
			if ((Object)(object)percentAmountText != (Object)null)
			{
				if (num < registeredCount)
				{
					float num2 = ((registeredCount != 0) ? ((float)num / (float)registeredCount * 100f) : 0f);
					percentAmountText.text = $"{num2:N1}%";
					((Graphic)percentAmountText).color = Color.white;
				}
				else
				{
					percentAmountText.text = "100%";
					((Graphic)percentAmountText).color = Color.green;
				}
			}
		}

		private void OnPageMove(bool scrollLeft)
		{
			if (((Component)this).gameObject.activeSelf)
			{
				if (scrollLeft)
				{
					pageIndex--;
				}
				else
				{
					pageIndex++;
				}
				int pageCount = Register.GetPageCount(16);
				if (pageIndex < 1)
				{
					pageIndex = 1;
					Audio.PlayUI(GameNetworkManager.Instance?.buttonCancelSFX);
				}
				else if (pageIndex > pageCount)
				{
					pageIndex = pageCount;
					Audio.PlayUI(GameNetworkManager.Instance?.buttonCancelSFX);
				}
				else
				{
					Audio.PlayUI(GameNetworkManager.Instance?.buttonTuneSFX);
					UpdatePage();
				}
			}
		}

		private void UpdatePage()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			TMP_Text? obj = pageText;
			if (obj != null)
			{
				obj.SetText(pageIndex.ToString(), true);
			}
			if ((Object)(object)leftPageIcon != (Object)null)
			{
				((Behaviour)leftPageIcon).enabled = pageIndex > 1;
			}
			if ((Object)(object)rightPageIcon != (Object)null)
			{
				((Behaviour)rightPageIcon).enabled = pageIndex < Register.GetPageCount(16);
			}
			if (!((Object)(object)itemsContainer != (Object)null) || !((Object)(object)itemPrefab != (Object)null))
			{
				return;
			}
			ItemBoard @object = default(ItemBoard);
			foreach (Transform item2 in itemsContainer)
			{
				Transform val = item2;
				if (((Component)val).gameObject.TryGetComponent<ItemBoard>(ref @object))
				{
					OnItemUpdated -= @object.OnItemUpdate;
				}
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			ItemEntry[] page = Register.GetPage(pageIndex - 1, 16);
			ItemEntry[] array = page;
			ItemBoard itemBoard = default(ItemBoard);
			for (int i = 0; i < array.Length; i++)
			{
				ItemEntry item = array[i];
				GameObject val2 = Object.Instantiate<GameObject>(itemPrefab, itemsContainer, false);
				((Object)val2).name = item.Name;
				if (val2.TryGetComponent<ItemBoard>(ref itemBoard))
				{
					itemBoard.SetItem(item);
					OnItemUpdated += itemBoard.OnItemUpdate;
				}
			}
		}

		public void UpdateItem(string id)
		{
			this.OnItemUpdated?.Invoke(id);
		}

		private void Subscribe()
		{
			if (CustomInputActions.Actions != null)
			{
				if (CustomInputActions.Actions.ToggleVisibilityKey != null)
				{
					CustomInputActions.Actions.ToggleVisibilityKey.performed += OnToggle;
				}
				if (CustomInputActions.Actions.PageLeftKey != null)
				{
					CustomInputActions.Actions.PageLeftKey.performed += MovePageLeft;
				}
				if (CustomInputActions.Actions.PageRightKey != null)
				{
					CustomInputActions.Actions.PageRightKey.performed += MovePageRight;
				}
			}
			if ((Object)(object)Tracker.Instance != (Object)null)
			{
				Tracker.Instance.OnCollected += OnCollected;
				Tracker.Instance.OnDiscarded += OnDiscarded;
			}
		}

		private void UnSubscribe()
		{
			if (CustomInputActions.Actions != null)
			{
				if (CustomInputActions.Actions.ToggleVisibilityKey != null)
				{
					CustomInputActions.Actions.ToggleVisibilityKey.performed -= OnToggle;
				}
				if (CustomInputActions.Actions.PageLeftKey != null)
				{
					CustomInputActions.Actions.PageLeftKey.performed -= MovePageLeft;
				}
				if (CustomInputActions.Actions.PageRightKey != null)
				{
					CustomInputActions.Actions.PageRightKey.performed -= MovePageRight;
				}
			}
			if ((Object)(object)Tracker.Instance != (Object)null)
			{
				Tracker.Instance.OnCollected -= OnCollected;
				Tracker.Instance.OnDiscarded -= OnDiscarded;
			}
		}

		private void OnToggle(CallbackContext ctx)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!global::LethalMuseum.Dependencies.InputUtils.Dependency.Enabled || global::LethalMuseum.Dependencies.InputUtils.Dependency.AllowKeybind(ctx))
			{
				bool flag = !((Component)this).gameObject.activeSelf;
				((Component)this).gameObject.SetActive(flag);
				Audio.PlayUI((!flag) ? GameNetworkManager.Instance?.buttonCancelSFX : GameNetworkManager.Instance?.buttonPressSFX);
			}
		}

		private void OnCollected(string id)
		{
			UpdateItem(id);
			UpdateInformation();
		}

		private void OnDiscarded(string id)
		{
			UpdateItem(id);
			UpdateInformation();
		}

		private void MovePageRight(CallbackContext ctx)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!global::LethalMuseum.Dependencies.InputUtils.Dependency.Enabled || global::LethalMuseum.Dependencies.InputUtils.Dependency.AllowKeybind(ctx))
			{
				OnPageMove(scrollLeft: false);
			}
		}

		private void MovePageLeft(CallbackContext ctx)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!global::LethalMuseum.Dependencies.InputUtils.Dependency.Enabled || global::LethalMuseum.Dependencies.InputUtils.Dependency.AllowKeybind(ctx))
			{
				OnPageMove(scrollLeft: true);
			}
		}
	}
}
namespace LethalMuseum.Patches
{
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManager_Patches
	{
		private static GameObject? customUI;

		private static bool hasInitializedItems;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start_Postfix(MenuManager __instance)
		{
			if (!__instance.isInitScene)
			{
				CreateButton();
				InitializeItems();
			}
		}

		[HarmonyPatch("SetLoadingScreen")]
		[HarmonyPrefix]
		private static void SetLoadingScreen_Prefix(bool isLoading)
		{
			GameObject? obj = customUI;
			if (obj != null)
			{
				obj.SetActive(!isLoading);
			}
		}

		[HarmonyPatch("EnableUIPanel")]
		[HarmonyPrefix]
		private static void EnableUIPanel_Prefix(GameObject enablePanel)
		{
			GameObject? obj = customUI;
			if (obj != null)
			{
				obj.SetActive(((Object)enablePanel).name == "MainButtons");
			}
		}

		[HarmonyPatch("DisableUIPanel")]
		[HarmonyPrefix]
		private static void DisableUIPanel_Prefix(GameObject enablePanel)
		{
			GameObject? obj = customUI;
			if (obj != null)
			{
				obj.SetActive(((Object)enablePanel).name != "MainButtons");
			}
		}

		private static void CreateButton()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Canvas/MenuContainer");
			if ((Object)(object)val == (Object)null)
			{
				Logger.Error("Could not find the container at 'Canvas/MenuContainer'.");
				return;
			}
			GameObject val2 = new GameObject("LethalMuseum_UI");
			val2.transform.SetParent(val.transform, false);
			RectTransform val3 = val2.AddComponent<RectTransform>();
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.anchoredPosition = Vector2.zero;
			Vector2 offsetMin = (val3.offsetMax = Vector2.zero);
			val3.offsetMin = offsetMin;
			Transform obj = val.transform.Find("LobbyHostSettings");
			int num = ((obj != null) ? obj.GetSiblingIndex() : (-1));
			if (num != -1)
			{
				val2.transform.SetSiblingIndex(num);
			}
			if ((Object)(object)LethalMuseum.MUSEUM_FORM != (Object)null)
			{
				customUI = Object.Instantiate<GameObject>(LethalMuseum.MUSEUM_FORM, val2.transform, false);
			}
			else
			{
				Logger.Error("Could not spawn the main form.");
			}
		}

		private static void InitializeItems()
		{
			if (hasInitializedItems)
			{
				return;
			}
			Item[] array = Resources.FindObjectsOfTypeAll<Item>();
			Item[] array2 = array;
			foreach (Item val in array2)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Register.RegisterItem(val);
				}
			}
			hasInitializedItems = true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerB_Patches
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void ConnectClientToPlayerObject_Postfix(PlayerControllerB __instance)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Systems/UI/Canvas");
			if ((Object)(object)val == (Object)null)
			{
				Logger.Error("Could not find the canvas.");
				return;
			}
			if ((Object)(object)LethalMuseum.ITEMS_BOARD == (Object)null)
			{
				Logger.Error("The asset for 'ITEMS_BOARD' was not loaded.");
				return;
			}
			GameObject val2 = new GameObject("LethalMuseum-InGameUI");
			val2.transform.SetParent(val.transform, false);
			Transform obj = val.transform.Find("LoadingText");
			int num = ((obj != null) ? obj.GetSiblingIndex() : (-1));
			if (num >= 0)
			{
				val2.transform.SetSiblingIndex(num);
			}
			RectTransform val3 = val2.AddComponent<RectTransform>();
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.anchoredPosition = Vector2.zero;
			val3.offsetMin = Vector2.zero;
			val3.offsetMax = Vector2.zero;
			Object.Instantiate<GameObject>(LethalMuseum.ITEMS_BOARD, val2.transform, false);
		}

		[HarmonyPatch("SetItemInElevator")]
		[HarmonyPrefix]
		private static void SetItemInElevator_Prefix(bool droppedInShipRoom, bool droppedInElevator, GrabbableObject gObject)
		{
			if (!((Object)(object)gObject == (Object)null) && gObject.isInShipRoom != droppedInShipRoom)
			{
				if (droppedInShipRoom)
				{
					Tracker.Instance?.Collect(gObject);
				}
				else
				{
					Tracker.Instance?.Discard(gObject);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRound_Patches
	{
		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		private static void ResetShip_Postfix()
		{
			Logger.Info("RESET SHIP");
			Tracker.Instance?.ResetCollected();
		}

		[HarmonyPatch("AllPlayersHaveRevivedClientRpc")]
		[HarmonyPostfix]
		private static void AllPlayersHaveRevivedClientRpc_Postfix(StartOfRound __instance)
		{
			Tracker.Instance?.ResetCollected();
		}
	}
}
namespace LethalMuseum.Objects
{
	internal static class Identifier
	{
		public static string GetID(Item item)
		{
			if (ModdedItemIdentifier.GetModdedID(item, out string moddedID) && moddedID != null)
			{
				return moddedID;
			}
			return "Vanilla/" + item.itemName;
		}

		public static bool IsItemModded(Item item)
		{
			return ModdedItemIdentifier.IsItemModded(item);
		}

		public static bool IsItemAllowed(Item item)
		{
			if (item.lockedInDemo)
			{
				return false;
			}
			if ((Object)(object)item.spawnPrefab == (Object)null)
			{
				return false;
			}
			if (item.itemName == "Maneater")
			{
				return LethalMuseum.Configuration?.AllowBaby.Value ?? false;
			}
			if (item.itemName == "Body")
			{
				return LethalMuseum.Configuration?.AllowBody.Value ?? false;
			}
			return true;
		}

		public static ItemEntry[] GetEntries(Item item)
		{
			ItemEntry item2 = new ItemEntry(item);
			List<ItemEntry> list = new List<ItemEntry> { item2 };
			for (int i = 0; i < item.materialVariants.Length; i++)
			{
				list.Add(item2.Material(i));
			}
			for (int j = 0; j < item.meshVariants.Length; j++)
			{
				list.Add(item2.Mesh(j));
			}
			return list.ToArray();
		}

		public static ItemEntry[] GetEntries(GrabbableObject item)
		{
			ItemEntry item2 = new ItemEntry(item.itemProperties);
			List<ItemEntry> list = new List<ItemEntry> { item2 };
			MeshRenderer val = default(MeshRenderer);
			if (((Component)item).TryGetComponent<MeshRenderer>(ref val))
			{
				int num = Array.IndexOf(item.itemProperties.materialVariants, ((Renderer)val).sharedMaterial);
				if (num != -1)
				{
					list.Add(item2.Material(num));
				}
			}
			MeshFilter val2 = default(MeshFilter);
			if (((Component)item).TryGetComponent<MeshFilter>(ref val2))
			{
				int num2 = Array.IndexOf(item.itemProperties.meshVariants, (val2 != null) ? val2.mesh : null);
				if (num2 != -1)
				{
					list.Add(item2.Mesh(num2));
				}
			}
			return list.ToArray();
		}
	}
	internal static class Register
	{
		private static readonly SortedDictionary<string, ItemEntry> itemsData = new SortedDictionary<string, ItemEntry>();

		private static readonly HashSet<string> disabledItems = new HashSet<string>();

		private const char SEPARATION_CHARACTER = '|';

		public static void RegisterItem(Item item, bool registerAsEnabled = true)
		{
			if (!Identifier.IsItemAllowed(item))
			{
				return;
			}
			ItemEntry[] entries = Identifier.GetEntries(item);
			ItemEntry[] array = entries;
			for (int i = 0; i < array.Length; i++)
			{
				ItemEntry value = array[i];
				if (!itemsData.TryAdd(value.ID, value))
				{
					Logger.Debug("An item has already been registered under the value '" + value.ID + "'.");
				}
				else if (!disabledItems.Contains(value.ID))
				{
					SetItemEnable(value.ID, registerAsEnabled);
				}
			}
		}

		public static void SetItemEnable(string id, bool isEnabled)
		{
			if (isEnabled)
			{
				disabledItems.Remove(id);
			}
			else
			{
				disabledItems.Add(id);
			}
		}

		public static void ApplyFilter(Func<ItemEntry, bool> condition, bool isEnabled)
		{
			foreach (var (id, arg) in itemsData)
			{
				if (condition(arg))
				{
					SetItemEnable(id, isEnabled);
				}
			}
		}

		public static bool IsEnabled(string id)
		{
			return itemsData.ContainsKey(id) && !disabledItems.Contains(id);
		}

		public static string GenerateBlacklist()
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			foreach (string disabledItem in disabledItems)
			{
				stringBuilder.Append(disabledItem);
				if (num != disabledItems.Count - 1)
				{
					stringBuilder.Append('|');
				}
				num++;
			}
			return stringBuilder.ToString();
		}

		public static void ApplyBlacklist(string blacklist)
		{
			string[] array = blacklist.Split('|', StringSplitOptions.RemoveEmptyEntries);
			string[] array2 = array;
			foreach (string id in array2)
			{
				SetItemEnable(id, isEnabled: false);
			}
		}

		public static int GetRegisteredCount()
		{
			return itemsData.Count - disabledItems.Count;
		}

		public static ItemEntry[] GetAll()
		{
			ItemEntry[] array = new ItemEntry[itemsData.Count];
			int num = 0;
			foreach (var (_, itemEntry2) in itemsData)
			{
				array[num] = itemEntry2;
				num++;
			}
			return array;
		}

		public static ItemEntry[] GetPage(int index, int pageSize)
		{
			int num = pageSize * index;
			List<ItemEntry> list = new List<ItemEntry>();
			foreach (var (id, item) in itemsData)
			{
				if (!IsEnabled(id))
				{
					continue;
				}
				if (num > 0)
				{
					num--;
					continue;
				}
				list.Add(item);
				if (list.Count < pageSize)
				{
					continue;
				}
				break;
			}
			return list.ToArray();
		}

		public static int GetPageCount(int pageSize)
		{
			int registeredCount = GetRegisteredCount();
			float num = (float)registeredCount / (float)pageSize;
			return Mathf.CeilToInt(num);
		}
	}
	public class Tracker : MonoBehaviour
	{
		internal static Tracker? Instance;

		private readonly Dictionary<string, uint> itemsCollected = new Dictionary<string, uint>();

		public event Action<string>? OnCollected;

		public event Action<string>? OnDiscarded;

		private void Awake()
		{
			Instance = this;
			ResetCollected();
		}

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

		public void Collect(GrabbableObject? item)
		{
			if (item == null)
			{
				return;
			}
			ItemEntry[] entries = Identifier.GetEntries(item);
			ItemEntry[] array = entries;
			for (int i = 0; i < array.Length; i++)
			{
				ItemEntry itemEntry = array[i];
				if (Register.IsEnabled(itemEntry.ID))
				{
					if (!itemsCollected.TryAdd(itemEntry.ID, 1u))
					{
						itemsCollected[itemEntry.ID]++;
					}
					else
					{
						this.OnCollected?.Invoke(itemEntry.ID);
					}
				}
			}
		}

		public void Discard(GrabbableObject? item)
		{
			if (item == null)
			{
				return;
			}
			ItemEntry[] entries = Identifier.GetEntries(item);
			ItemEntry[] array = entries;
			for (int i = 0; i < array.Length; i++)
			{
				ItemEntry itemEntry = array[i];
				if (Register.IsEnabled(itemEntry.ID) && itemsCollected.TryGetValue(itemEntry.ID, out var value))
				{
					value--;
					if (value != 0)
					{
						itemsCollected[itemEntry.ID] = value;
						break;
					}
					itemsCollected.Remove(itemEntry.ID);
					this.OnDiscarded?.Invoke(itemEntry.ID);
				}
			}
		}

		public void ResetCollected()
		{
			if (itemsCollected.Count > 0)
			{
				string[] array = new string[itemsCollected.Count];
				int num = 0;
				foreach (var (text2, _) in itemsCollected)
				{
					array[num] = text2;
					num++;
				}
				itemsCollected.Clear();
				string[] array2 = array;
				foreach (string obj in array2)
				{
					this.OnDiscarded?.Invoke(obj);
				}
			}
			GrabbableObject[] array3 = Object.FindObjectsOfType<GrabbableObject>();
			GrabbableObject[] array4 = array3;
			foreach (GrabbableObject val in array4)
			{
				if (val.isInShipRoom)
				{
					Collect(val);
				}
			}
		}

		public int GetCollectedCount()
		{
			return itemsCollected.Count;
		}

		public bool IsCollected(string id)
		{
			return itemsCollected.ContainsKey(id);
		}
	}
}
namespace LethalMuseum.Objects.Models
{
	public readonly struct ItemEntry
	{
		public readonly Item Item;

		public readonly string ID;

		public readonly int MaterialIndex;

		public readonly int MeshIndex;

		public bool IsVariant => MaterialIndex != -1 || MeshIndex != -1;

		public bool HasVariants => Item.materialVariants.Length != 0 || Item.meshVariants.Length != 0;

		public bool IsBase => HasVariants && !IsVariant;

		public Sprite Icon => GetIcon();

		public bool HasCustomIcon => GetHasCustomIcon();

		public string Name => GetName();

		public bool IsModded => Identifier.IsItemModded(Item);

		public ItemEntry(Item original)
		{
			Item = original;
			ID = Identifier.GetID(original);
			MaterialIndex = -1;
			MeshIndex = -1;
		}

		private ItemEntry(ItemEntry baseEntry, int materialIndex, int meshIndex)
		{
			Item = baseEntry.Item;
			string iD = Identifier.GetID(baseEntry.Item);
			if (materialIndex != -1)
			{
				ID = $"{iD}/base/{materialIndex}";
			}
			else if (meshIndex != -1)
			{
				ID = $"{iD}/{meshIndex}/base";
			}
			else
			{
				ID = iD;
			}
			MaterialIndex = materialIndex;
			MeshIndex = meshIndex;
		}

		public ItemEntry Mesh(int index)
		{
			return new ItemEntry(this, -1, index);
		}

		public ItemEntry Material(int index)
		{
			return new ItemEntry(this, index, -1);
		}

		private Sprite GetIcon()
		{
			if (!IsVariant)
			{
				return Item.itemIcon;
			}
			if (global::LethalMuseum.Dependencies.RuntimeIcons.Dependency.Enabled && global::LethalMuseum.Dependencies.RuntimeIcons.Dependency.HasCustomIcon(this, out Sprite sprite) && (Object)(object)sprite != (Object)null)
			{
				return sprite;
			}
			return Item.itemIcon;
		}

		private string GetName()
		{
			if (HasCustomIcon && IsBase)
			{
				return "Any";
			}
			string text = Item.itemName ?? "Scrap";
			if (IsVariant)
			{
				return text + " (Variant)";
			}
			return text;
		}

		private bool GetHasCustomIcon()
		{
			Sprite icon = Icon;
			if ((Object)(object)icon == (Object)null)
			{
				return false;
			}
			if (((Object)icon).name == "ScrapItemIcon2")
			{
				return false;
			}
			if (global::LethalMuseum.Dependencies.RuntimeIcons.Dependency.Enabled && global::LethalMuseum.Dependencies.RuntimeIcons.Dependency.IsLoadingIcon(icon))
			{
				return false;
			}
			return true;
		}
	}
}
namespace LethalMuseum.Helpers
{
	internal static class Audio
	{
		public static void PlayUI(AudioClip? clip)
		{
			if (!((Object)(object)clip == (Object)null))
			{
				AudioSource uIAudio = HUDManager.Instance.UIAudio;
				if (uIAudio != null)
				{
					uIAudio.PlayOneShot(clip);
				}
			}
		}
	}
	internal static class Bundle
	{
		private static AssetBundle? loadedBundle;

		public static bool LoadBundle(string name)
		{
			string location = Assembly.GetExecutingAssembly().Location;
			location = Path.GetDirectoryName(location) ?? throw new NullReferenceException();
			location = Path.Combine(location, name);
			loadedBundle = AssetBundle.LoadFromFile(location);
			if ((Object)(object)loadedBundle == (Object)null)
			{
				Logger.Error("Failed to load custom assets.");
				return false;
			}
			return true;
		}

		public static T? LoadAsset<T>(string name) where T : Object
		{
			if ((Object)(object)loadedBundle == (Object)null)
			{
				Logger.Error("Tried to load asset from unloaded bundle.");
				return default(T);
			}
			T val = loadedBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Logger.Error("No asset named '" + name + "' was found.");
			}
			return val;
		}
	}
	internal static class Logger
	{
		private static ManualLogSource? log;

		public static void SetLogger(ManualLogSource logSource)
		{
			log = logSource;
		}

		private static void Log(LogLevel level, object? content)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource? obj = log;
			if (obj != null)
			{
				obj.Log(level, content ?? "null");
			}
		}

		public static void Info(object? content)
		{
			Log((LogLevel)16, content);
		}

		public static void Debug(object? content)
		{
			Log((LogLevel)32, content);
		}

		public static void Error(object? content)
		{
			Log((LogLevel)2, content);
		}
	}
}
namespace LethalMuseum.Dependencies.RuntimeIcons
{
	[HarmonyPatch(typeof(CameraQueueComponent))]
	internal class CameraQueueComponent_Patches
	{
		[HarmonyPatch("PullLastRender")]
		[HarmonyPostfix]
		private static void PullLastRender_Postfix(RenderingResult render, ref bool __result)
		{
			if (__result)
			{
				Dependency.OnRender(render.Request.GrabbableObject, render.Texture);
			}
		}
	}
	internal static class Dependency
	{
		private static readonly Dictionary<string, Sprite?> generatedIcons = new Dictionary<string, Sprite>();

		private static readonly Dictionary<Item, Queue<ItemEntry>> spawnQueue = new Dictionary<Item, Queue<ItemEntry>>();

		private static readonly Dictionary<string, GameObject> objectToClear = new Dictionary<string, GameObject>();

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.github.lethalcompanymodding.runtimeicons");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool HasCustomIcon(ItemEntry entry, out Sprite? sprite)
		{
			return generatedIcons.TryGetValue(entry.ID, out sprite);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsLoadingIcon(Sprite sprite)
		{
			if ((Object)(object)sprite == (Object)(object)RuntimeIcons.LoadingSprite)
			{
				return true;
			}
			if ((Object)(object)sprite == (Object)(object)RuntimeIcons.LoadingSprite2)
			{
				return true;
			}
			return false;
		}

		internal static void OnRender(GrabbableObject item, Texture2D texture)
		{
			ItemEntry[] entries = Identifier.GetEntries(item);
			HashSet<Item> hashSet = new HashSet<Item>();
			ItemEntry[] array = entries;
			for (int i = 0; i < array.Length; i++)
			{
				ItemEntry itemEntry = array[i];
				if (!itemEntry.IsBase)
				{
					Sprite val = SpriteUtils.CreateSprite(texture);
					string name = (((Object)val.texture).name = "LethalMuseum+RuntimeIcons." + itemEntry.ID);
					((Object)val).name = name;
					generatedIcons.Add(itemEntry.ID, val);
					if (objectToClear.Remove(itemEntry.ID, out GameObject value) && (Object)(object)value != (Object)null)
					{
						Object.Destroy((Object)(object)value);
					}
					if (hashSet.Add(itemEntry.Item))
					{
						EnqueueNext(itemEntry.Item);
					}
				}
			}
			ItemEntry[] array2 = entries;
			for (int j = 0; j < array2.Length; j++)
			{
				ItemEntry itemEntry2 = array2[j];
				if (hashSet.Contains(itemEntry2.Item))
				{
					ItemsBoard.Instance?.UpdateItem(itemEntry2.ID);
				}
			}
		}

		internal static void TryEnqueueAll(ItemEntry[] entries)
		{
			Dictionary<Item, ItemEntry> dictionary = new Dictionary<Item, ItemEntry>();
			for (int i = 0; i < entries.Length; i++)
			{
				ItemEntry itemEntry = entries[i];
				if (itemEntry.IsBase || itemEntry.HasCustomIcon)
				{
					continue;
				}
				GameObject spawnPrefab = itemEntry.Item.spawnPrefab;
				if (!((Object)(object)((spawnPrefab != null) ? spawnPrefab.GetComponent<GrabbableObject>() : null) == (Object)null))
				{
					if (dictionary.TryAdd(itemEntry.Item, itemEntry))
					{
						spawnQueue.Add(itemEntry.Item, new Queue<ItemEntry>());
					}
					else
					{
						spawnQueue[itemEntry.Item].Enqueue(itemEntry);
					}
				}
			}
			foreach (var (_, entry) in dictionary)
			{
				EnqueueEntry(entry);
			}
		}

		private static void EnqueueEntry(ItemEntry entry)
		{
			GrabbableObject component = Object.Instantiate<GameObject>(entry.Item.spawnPrefab).GetComponent<GrabbableObject>();
			((Behaviour)component).enabled = false;
			((Object)((Component)component).gameObject).name = "LethalMuseum.processing-icon." + entry.ID;
			if (entry.IsVariant)
			{
				MeshRenderer val = default(MeshRenderer);
				if (entry.MaterialIndex != -1 && ((Component)component).TryGetComponent<MeshRenderer>(ref val))
				{
					((Renderer)val).sharedMaterial = entry.Item.materialVariants[entry.MaterialIndex];
				}
				MeshFilter val2 = default(MeshFilter);
				if (entry.MeshIndex != -1 && ((Component)component).TryGetComponent<MeshFilter>(ref val2))
				{
					val2.mesh = entry.Item.meshVariants[entry.MeshIndex];
				}
			}
			objectToClear.Add(entry.ID, ((Component)component).gameObject);
			RuntimeIcons.RenderingStage.CameraQueue.EnqueueObject(component, RuntimeIcons.WarningSprite, 2L);
		}

		private static void EnqueueNext(Item item)
		{
			if (spawnQueue.TryGetValue(item, out Queue<ItemEntry> value))
			{
				if (value.TryDequeue(out var result))
				{
					EnqueueEntry(result);
				}
				if (value.Count == 0)
				{
					spawnQueue.Remove(item);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerB_Patches
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void ConnectClientToPlayerObject_Postfix(PlayerControllerB __instance)
		{
			if (LethalMuseum.Configuration != null && LethalMuseum.Configuration.AutomaticIconGeneration.Value)
			{
				ItemEntry[] all = Register.GetAll();
				Dependency.TryEnqueueAll(all);
			}
		}
	}
	[HarmonyPatch(typeof(RenderingRequest))]
	internal class RenderingRequest_Patches
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void Test(ref RenderingRequest __instance)
		{
			ItemEntry[] entries = Identifier.GetEntries(__instance.GrabbableObject);
			if (entries.Length != 0)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(RenderingRequest), "ItemKey");
				if (!(fieldInfo == null))
				{
					fieldInfo.SetValueDirect(__makeref(__instance), entries[^1].ID);
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool HasIcon_Prefix(ref RenderingRequest __instance, ref bool __result)
		{
			ItemEntry[] entries = Identifier.GetEntries(__instance.GrabbableObject);
			if (entries.Length == 0)
			{
				return false;
			}
			if (Dependency.HasCustomIcon(entries[^1], out Sprite _))
			{
				__result = true;
				return true;
			}
			return false;
		}
	}
}
namespace LethalMuseum.Dependencies.LethalLib
{
	internal static class ModdedItemIdentifier
	{
		private static Dictionary<Item, string>? _cachedModdedItems;

		public static void LoadModdedItems()
		{
			_cachedModdedItems = new Dictionary<Item, string>();
			foreach (ScrapItem scrapItem in Items.scrapItems)
			{
				_cachedModdedItems.TryAdd(scrapItem.item, scrapItem.modName + "/" + scrapItem.item.itemName);
			}
			foreach (ShopItem shopItem in Items.shopItems)
			{
				_cachedModdedItems.TryAdd(shopItem.item, shopItem.modName + "/" + shopItem.item.itemName);
			}
			foreach (PlainItem plainItem in Items.plainItems)
			{
				_cachedModdedItems.TryAdd(plainItem.item, plainItem.modName + "/" + plainItem.item.itemName);
			}
		}

		public static bool GetModdedID(Item item, out string? moddedID)
		{
			moddedID = _cachedModdedItems?.GetValueOrDefault(item);
			return string.IsNullOrEmpty(moddedID);
		}

		public static bool IsItemModded(Item item)
		{
			return _cachedModdedItems?.ContainsKey(item) ?? false;
		}
	}
}
namespace LethalMuseum.Dependencies.LethalConfig
{
	internal static class ConfigToUI
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfigs(Configuration? config)
		{
			//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_0094: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (config != null)
			{
				if ((Object)(object)LethalMuseum.MOD_ICON != (Object)null)
				{
					Sprite modIcon = Sprite.Create(LethalMuseum.MOD_ICON, new Rect(0f, 0f, (float)((Texture)LethalMuseum.MOD_ICON).width, (float)((Texture)LethalMuseum.MOD_ICON).height), new Vector2(0.5f, 0.5f));
					LethalConfigManager.SetModIcon(modIcon);
				}
				LethalConfigManager.SetModDescription("Adds a built-in tracker for Museum%.");
				LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.AllowBaby, new BoolCheckBoxOptions
				{
					Name = "Allow Baby",
					RequiresRestart = true
				}));
				LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.AllowBody, new BoolCheckBoxOptions
				{
					Name = "Allow Body",
					RequiresRestart = true
				}));
				LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config.AutomaticIconGeneration, new BoolCheckBoxOptions
				{
					Name = "Automatic Icon Generation",
					RequiresRestart = false
				}));
				LethalConfigManager.SkipAutoGenFor((ConfigEntryBase)(object)config.Blacklist);
			}
		}
	}
}
namespace LethalMuseum.Dependencies.InputUtils
{
	internal class CustomInputActions : LcInputActions
	{
		internal static CustomInputActions? Actions;

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? ToggleVisibilityKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? PageLeftKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? PageRightKey { get; set; }
	}
	internal static class Dependency
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool AllowKeybind(CallbackContext ctx)
		{
			PlayerControllerB val = StartOfRound.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			if (val.inTerminalMenu)
			{
				return false;
			}
			if (val.isTypingChat)
			{
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}