Decompiled source of CSGC Ashy v0.4.2

plugins/IconSign.dll

Decompiled 10 hours 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.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using IconSign.Assets;
using IconSign.Config;
using IconSign.Data;
using IconSign.Extensions;
using IconSign.Helper;
using IconSign.Selection;
using IconSign.Selection.IconScrollContent;
using IconSign.Selection.IconScrollContent.CategorizedIcons;
using IconSign.Selection.Interaction;
using IconSign.Selection.Scrollpane;
using IconSign.Selection.TabBar;
using IconSign.Sign;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.U2D;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("IconSign")]
[assembly: AssemblyDescription("Adds a sign with an icon on it to Valheim.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IconSign")]
[assembly: AssemblyCopyright("Copyright © Oppodelldog 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee7b99ba-8e24-4496-9e0c-e788d84c200d")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.0.0")]
namespace IconSign
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("oppodelldog.mod.iconsign", "IconSign", "0.4.0")]
	internal class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "oppodelldog.mod.iconsign";

		public const string PluginName = "IconSign";

		public const string PluginVersion = "0.4.0";

		private void Awake()
		{
			RecentIcons.ConfigEntry = ((BaseUnityPlugin)this).Config.Bind<string>("config", "recent_icons", "", "your recently used icons");
			ModConfig.SelectionPanel.SelectedTab = ((BaseUnityPlugin)this).Config.Bind<string>("config", "selection_panel_selected_tab", "", "selected tab in selection panel");
			DevConfig.SelectionPanel.DebugView = ((BaseUnityPlugin)this).Config.Bind<bool>("dev", "selection_panel_debug_view", false, "show debug info in selection panel");
			DevConfig.IconSign.ShowInternalName = ((BaseUnityPlugin)this).Config.Bind<bool>("dev", "icon_sign_show_internal_name", false, "show internal name of IconSign when hovering the sign");
			DevConfig.SeachIndex.DumpIndexToFile = ((BaseUnityPlugin)this).Config.Bind<bool>("dev", "search_index_dump_index_to_file", false, "dump search index to file");
			DevConfig.SeachIndex.LogSearchStatsEvery = ((BaseUnityPlugin)this).Config.Bind<int>("dev", "search_index_log_search_stats", 10, "log search stats every nth search");
			DevConfig.Layout.LogLayoutStatsEvery = ((BaseUnityPlugin)this).Config.Bind<int>("dev", "layout_log_layout_stats", 10, "log layout stats every nth layout");
			IconSignFactory.Register();
			IconTranslation.Register();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TestCommand());
		}
	}
	public class TestCommand : ConsoleCommand
	{
		public override string Name => "search";

		public override string Help => "for debug purpose";

		public override void Run(string[] args)
		{
			CreateCategorizedIcons.SearchInputChanged(args[0]);
		}
	}
}
namespace IconSign.Sign
{
	internal class IconSign : MonoBehaviour, Hoverable, Interactable, TextReceiver
	{
		[FormerlySerializedAs("m_name")]
		public string mName;

		[FormerlySerializedAs("m_defaultText")]
		public string mDefaultText = "rested";

		private ZNetView _mNview;

		private string _mCurrentText = "rested";

		private void Awake()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			mName = LocalizationManager.Instance.TryTranslate("name");
			Canvas componentInChildren = ((Component)this).gameObject.GetComponentInChildren<Canvas>();
			Transform obj = ExposedGameObjectExtension.FindDeepChild(((Component)this).gameObject, "wood_pole (1)", (IterativeSearchType)1);
			Sign component = ((Component)this).gameObject.GetComponent<Sign>();
			Collider componentInChildren2 = ((Component)this).gameObject.GetComponentInChildren<Collider>();
			LOGIfNull(componentInChildren, "Canvas");
			LOGIfNull(obj, "WoodPole");
			LOGIfNull(component, "Sign");
			LOGIfNull(componentInChildren2, "Collider");
			Transform child = ((Component)componentInChildren).transform.GetChild(0);
			LOGIfNull(child, "Text");
			Object.Destroy((Object)(object)((Component)child).gameObject);
			Object.Destroy((Object)(object)component);
			((Component)componentInChildren).gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(0.5f, 0.5f);
			((Component)obj).transform.localScale = new Vector3(0.5f, 0.5f, 0.1f);
			((Component)componentInChildren2).transform.localScale = new Vector3(0.5f, 1f, 1f);
			RectTransform component2 = GUIManager.Instance.CreateImage(GetText(), ((Component)componentInChildren).transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), new Vector2(0.35f, 0.35f)).GetComponent<RectTransform>();
			((Transform)component2).localPosition = ((Transform)component2).localPosition + new Vector3(0f, 0f, -0.007f);
			_mNview = ((Component)this).GetComponent<ZNetView>();
			if (_mNview.GetZDO() != null)
			{
				UpdateText();
				((MonoBehaviour)this).InvokeRepeating("UpdateText", 2f, 2f);
			}
		}

		public string GetHoverText()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			if (DevConfig.IconSign.ShowInternalName.Value)
			{
				text = text + "\"" + StringExtensionMethods.RemoveRichTextTags(GetText()) + "\"\n";
			}
			if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
			{
				return text;
			}
			text = text + "\n" + mName + Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] ") + LocalizationManager.Instance.TryTranslate("use");
			return text + "\n[<color=yellow><b>1-8</b></color>] " + LocalizationManager.Instance.TryTranslate("paint_item");
		}

		public string GetHoverName()
		{
			return mName;
		}

		public bool Interact(Humanoid character, bool hold, bool alt)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (hold || !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
			{
				return false;
			}
			IconSelectionPanel.Instance.RequestSelection();
			IconSelectionPanel.Instance.OnIconSelected += OnIconSelected;
			return true;
		}

		private void OnIconSelected(string icon)
		{
			IconSelectionPanel.Instance.OnIconSelected -= OnIconSelected;
			if (!(icon == ""))
			{
				RecentIcons.Add(icon);
				SetText(icon);
			}
		}

		private void UpdateText()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			string text = _mNview.GetZDO().GetString(ZDOVars.s_text, mDefaultText);
			string @string = _mNview.GetZDO().GetString(ZDOVars.s_author, "");
			text = CensorShittyWords.FilterUGC(text, (UGCType)4, @string, 0L);
			if (_mCurrentText == text)
			{
				return;
			}
			PrivilegeManager.CanViewUserGeneratedContent(@string, (CanAccessResult)delegate(Result access)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected I4, but got Unknown
				switch ((int)access)
				{
				case 0:
					_mCurrentText = text;
					UpdateSprite();
					break;
				case 1:
					_mCurrentText = "";
					UpdateSprite();
					break;
				default:
					_mCurrentText = "";
					UpdateSprite();
					ZLog.LogError((object)"Failed to check UGC privilege");
					break;
				}
			});
		}

		private void UpdateSprite()
		{
			((Component)this).gameObject.GetComponentInChildren<Image>().sprite = GUIManager.Instance.GetSprite(_mCurrentText);
		}

		public string GetText()
		{
			return _mCurrentText;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			string name = ((Object)item.GetIcon()).name;
			RecentIcons.Add(name);
			SetText(name);
			return true;
		}

		public void SetText(string text)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
			{
				_mNview.ClaimOwnership();
				_mNview.GetZDO().Set(ZDOVars.s_text, text);
				_mNview.GetZDO().Set(ZDOVars.s_author, PrivilegeManager.GetNetworkUserId());
				UpdateText();
			}
		}

		private static void LOGIfNull(object obj, string descriptiveName)
		{
			if (obj == null)
			{
				Logger.LogError((object)(descriptiveName + " is null"));
			}
		}
	}
	public static class IconSignFactory
	{
		private const string BuildPieceName = "iconsign";

		internal static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += CreateIconSign;
		}

		private static void CreateIconSign()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= CreateIconSign;
			Logger.LogInfo((object)"creating icon sign");
			Translations.AddToLocalizationManager();
			PieceConfig val = new PieceConfig
			{
				Name = LocalizationManager.Instance.TryTranslate("name"),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Furniture
			};
			val.AddRequirement(new RequirementConfig("Wood", 1, 0, true));
			val.AddRequirement(new RequirementConfig("Coal", 1, 0, false));
			val.AddRequirement(new RequirementConfig("Raspberry", 1, 0, false));
			val.AddRequirement(new RequirementConfig("Blueberries", 1, 0, false));
			val.AddRequirement(new RequirementConfig("Dandelion", 1, 0, false));
			val.Icon = SpriteLoader.LoadBuildPieceIcon();
			CustomPiece val2 = new CustomPiece("iconsign", "sign", val);
			PieceManager.Instance.AddPiece(val2);
			val2.PiecePrefab.gameObject.AddComponent<IconSign>();
			Logger.LogInfo((object)"icon sign created");
		}
	}
}
namespace IconSign.Selection
{
	public class IconSelectionPanel
	{
		private static IconSelectionPanel _instance;

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

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

		private GameObject _iconSelectionPanel;

		public static IconSelectionPanel Instance => _instance ?? (_instance = new IconSelectionPanel());

		public event Action<string> OnIconSelected;

		internal void RequestSelection()
		{
			EnsurePanel();
			_iconSelectionPanel.SetActive(true);
			GUIManager.BlockInput(true);
		}

		internal void ClosePanel()
		{
			foreach (KeyValuePair<string, GameObject> tabButton in _tabButtons)
			{
				tabButton.Value.GetComponent<TabButton>().UpdateTextColor();
			}
			_iconSelectionPanel.SetActive(false);
			GUIManager.BlockInput(false);
		}

		private void EnsurePanel()
		{
			if (!Object.op_Implicit((Object)(object)_iconSelectionPanel))
			{
				if (GUIManager.Instance == null)
				{
					Logger.LogError((object)"GUIManager instance is null");
					return;
				}
				if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
				{
					Logger.LogError((object)"GUIManager CustomGUI is null");
					return;
				}
				CreateWoodPanel();
				CreateHeadline();
				CreateSearchInput();
				_tabButtons = CreateTabButtons.Create(_iconSelectionPanel.transform);
				CreateTabButtons.OnCategoryButtonClicked += SwitchTab;
				TabContainers.Add("tab_categories", CreateCategoriesScrollPane.Create(_iconSelectionPanel.transform));
				CreateCategoriesScrollPane.OnIconClicked += TriggerSelectionEvent;
				TabContainers.Add("tab_inventory", CreateInventoryScrollPane.Create(_iconSelectionPanel.transform));
				CreateInventoryScrollPane.OnIconClicked += TriggerSelectionEvent;
				TabContainers.Add("tab_recent", CreateRecentScrollPane.Create(_iconSelectionPanel.transform));
				CreateRecentScrollPane.OnIconClicked += TriggerSelectionEvent;
				SwitchTab(ModConfig.SelectionPanel.SelectedTab.Value);
			}
		}

		private void CreateSearchInput()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			GameObject input = GUIManager.Instance.CreateInputField(_iconSelectionPanel.transform, Vector2.zero, Vector2.zero, new Vector2(40f, -92f), (ContentType)0, "[Filter]", 22, 160f, 36f);
			((UnityEvent<string>)(object)input.GetComponent<InputField>().onValueChanged).AddListener((UnityAction<string>)CreateCategorizedIcons.SearchInputChanged);
			Anchors.SetTopLeft(input);
			GameObject obj = GUIManager.Instance.CreateImage("trash_icon", _iconSelectionPanel.transform);
			Anchors.SetTopLeft(obj);
			Anchors.SetPosition(obj, new Vector2(210f, -88f));
			Anchors.SetSize(obj, new Vector2(44f, 44f));
			obj.AddComponent<HoverEffect>().OnClicked += delegate
			{
				input.GetComponent<InputField>().text = string.Empty;
			};
			((Object)obj).name = "ResetSearchFilterIcon";
		}

		private void CreateWoodPanel()
		{
			//IL_001a: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			_iconSelectionPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 1200f, 800f, false);
			_iconSelectionPanel.SetActive(false);
			_iconSelectionPanel.AddComponent<EscClosePanelListener>();
		}

		private void CreateHeadline()
		{
			//IL_0029: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			GUIManager.Instance.CreateText(LocalizationManager.Instance.TryTranslate("name"), _iconSelectionPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -45f), GUIManager.Instance.AveriaSerifBold, 38, GUIManager.Instance.ValheimOrange, true, Color.black, 650f, 48f, false).GetComponent<Text>().alignment = (TextAnchor)4;
		}

		private void TriggerSelectionEvent(string spriteName)
		{
			this.OnIconSelected?.Invoke(spriteName);
			ClosePanel();
		}

		private static void SwitchTab(string tabName)
		{
			if (!ModConfig.SelectionPanel.Tabs.Contains(tabName))
			{
				tabName = "tab_categories";
			}
			ModConfig.SelectionPanel.SelectedTab.Value = tabName;
			foreach (KeyValuePair<string, GameObject> tabContainer in TabContainers)
			{
				tabContainer.Value.SetActive(tabContainer.Key == tabName);
			}
			foreach (KeyValuePair<string, GameObject> tabButton in _tabButtons)
			{
				tabButton.Value.GetComponent<TabButton>().IsSelected = tabButton.Key == tabName;
			}
		}
	}
}
namespace IconSign.Selection.TabBar
{
	public static class CreateTabButtons
	{
		public delegate void OnCategoryButtonClickedDelegate(string name);

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

		public static event OnCategoryButtonClickedDelegate OnCategoryButtonClicked;

		private static GameObject CreateTabButton(Transform parent, string name, string label, Vector2 pos, Vector2 size)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_007a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			Sprite sprite = GUIManager.Instance.GetSprite("button_tab");
			Sprite sprite2 = GUIManager.Instance.GetSprite("button_tab_disabled");
			Sprite sprite3 = GUIManager.Instance.GetSprite("button_tab_hover");
			Sprite sprite4 = GUIManager.Instance.GetSprite("button_tab_selected");
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.5f, 1f);
			obj.anchorMax = new Vector2(0.5f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = pos;
			obj.sizeDelta = size;
			((Transform)obj).localScale = new Vector3(1f, 1f, 1f);
			val.AddComponent<Image>().sprite = sprite;
			Button obj2 = val.AddComponent<Button>();
			((Selectable)obj2).transition = (Transition)2;
			SpriteState val2 = default(SpriteState);
			((SpriteState)(ref val2)).disabledSprite = sprite2;
			((SpriteState)(ref val2)).highlightedSprite = sprite3;
			((SpriteState)(ref val2)).pressedSprite = sprite4;
			SpriteState spriteState = val2;
			((Selectable)obj2).spriteState = spriteState;
			GameObject val3 = GUIManager.Instance.CreateText(label, val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerifBold, 20, Color.white, true, Color.black, size.x, size.y, true);
			val3.GetComponent<Text>().alignment = (TextAnchor)4;
			val3.GetComponent<RectTransform>().Expand();
			val.AddComponent<TabButton>().textComponent = val3.GetComponent<Text>();
			((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
			{
				TriggerButtonClicked(name);
			});
			return val;
		}

		internal static Dictionary<string, GameObject> Create(Transform parent)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			int num = -140;
			string[] tabs = ModConfig.SelectionPanel.Tabs;
			foreach (string text in tabs)
			{
				string label = LocalizationManager.Instance.TryTranslate(text);
				GameObject value = CreateTabButton(parent, text, label, new Vector2((float)num, -92f), new Vector2(140f, 38f));
				TabButtons.Add(text, value);
				num += 140;
			}
			TabButtons["tab_categories"].GetComponent<TabButton>().IsSelected = true;
			GUIManager.Instance.CreateImage("panel_separator", parent, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0.5f, 0.5f), new Vector2(0f, -130f), new Vector2(440f, 4f));
			return TabButtons;
		}

		private static void TriggerButtonClicked(string category)
		{
			foreach (KeyValuePair<string, GameObject> tabButton in TabButtons)
			{
				tabButton.Value.GetComponent<TabButton>().IsSelected = tabButton.Key == category;
			}
			CreateTabButtons.OnCategoryButtonClicked?.Invoke(category);
		}
	}
	public class TabButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerUpHandler
	{
		public Text textComponent;

		private bool _isSelected;

		private readonly Color _normalTextColor = Color.white;

		private readonly Color _highlightedTextColor = GUIManager.Instance.ValheimOrange;

		public bool IsSelected
		{
			set
			{
				_isSelected = value;
				UpdateTextColor();
			}
		}

		private void Start()
		{
			UpdateTextColor();
		}

		public void UpdateTextColor()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)textComponent).color = (_isSelected ? _highlightedTextColor : _normalTextColor);
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)textComponent).color = _highlightedTextColor;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			UpdateTextColor();
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)textComponent).color = _highlightedTextColor;
		}
	}
}
namespace IconSign.Selection.Scrollpane
{
	public static class CreateCategoriesScrollPane
	{
		internal delegate void IconClickedDelegate(string iconName);

		internal static event IconClickedDelegate OnIconClicked;

		internal static GameObject Create(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			GameObject val = new GameObject("scroll-container-categories");
			RectTransform rectTransform = val.AddComponent<RectTransform>();
			val.AddComponent<ScrollableContainer>();
			val.AddComponent<IconLoadingInitializer>();
			val.transform.SetParent(parent);
			rectTransform.Expand();
			CreateCategorizedIcons.OnIconClicked = (CreateCategorizedIcons.IconClickedAction)Delegate.Combine(CreateCategorizedIcons.OnIconClicked, new CreateCategorizedIcons.IconClickedAction(TriggerClickEvent));
			return val;
		}

		private static void TriggerClickEvent(string iconName)
		{
			CreateCategoriesScrollPane.OnIconClicked?.Invoke(iconName);
		}
	}
	internal class IconLoadingInitializer : MonoBehaviour
	{
		private void Start()
		{
			ScrollableContainer component = ((Component)this).GetComponent<ScrollableContainer>();
			CreateCategorizedIcons.StartFillingContent(component.Content, component);
		}
	}
	internal static class CreateInventoryScrollPane
	{
		internal delegate void IconClicked(string iconName);

		internal static event IconClicked OnIconClicked;

		public static GameObject Create(Transform transform)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			GameObject val = new GameObject("scroll-container-inventory");
			RectTransform rectTransform = val.AddComponent<RectTransform>();
			val.AddComponent<ScrollableContainer>();
			val.AddComponent<InventoryScrollPaneRefresher>();
			val.transform.SetParent(transform);
			rectTransform.Expand();
			CreateInventoryIcons.OnIconClicked += TriggerClickEvent;
			return val;
		}

		private static void TriggerClickEvent(string iconName)
		{
			CreateInventoryScrollPane.OnIconClicked?.Invoke(iconName);
		}
	}
	internal class InventoryScrollPaneRefresher : MonoBehaviour
	{
		private void OnEnable()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ScrollableContainer component = ((Component)this).GetComponent<ScrollableContainer>();
			Transform content = component.Content;
			for (int i = 0; i < content.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)content.GetChild(i)).gameObject);
			}
			Vector2 size = CreateInventoryIcons.FillContent(content);
			component.SetSize(size);
		}

		private void OnDisable()
		{
			Transform content = ((Component)this).GetComponent<ScrollableContainer>().Content;
			for (int i = 0; i < content.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)content.GetChild(i)).gameObject);
			}
		}
	}
	internal static class CreateRecentScrollPane
	{
		internal delegate void IconClicked(string iconName);

		internal static event IconClicked OnIconClicked;

		public static GameObject Create(Transform transform)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			GameObject val = new GameObject("scroll-container-recent");
			RectTransform rectTransform = val.AddComponent<RectTransform>();
			val.AddComponent<ScrollableContainer>();
			val.AddComponent<RecentScrollPaneRefresher>();
			val.transform.SetParent(transform);
			rectTransform.Expand();
			CreateRecentIcons.OnIconClicked += TriggerClickEvent;
			return val;
		}

		private static void TriggerClickEvent(string iconName)
		{
			CreateRecentScrollPane.OnIconClicked?.Invoke(iconName);
		}
	}
	internal class RecentScrollPaneRefresher : MonoBehaviour
	{
		private void OnEnable()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			ScrollableContainer component = ((Component)this).GetComponent<ScrollableContainer>();
			Transform content = ((Component)this).GetComponent<ScrollableContainer>().Content;
			for (int i = 0; i < content.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)content.GetChild(i)).gameObject);
			}
			Vector2 size = CreateRecentIcons.FillContent(content);
			component.SetSize(size);
		}

		private void OnDisable()
		{
			Transform content = ((Component)this).GetComponent<ScrollableContainer>().Content;
			for (int i = 0; i < content.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)content.GetChild(i)).gameObject);
			}
		}
	}
	public class ScrollableContainer : MonoBehaviour
	{
		private GameObject _content;

		public Transform Content
		{
			get
			{
				if ((Object)(object)_content == (Object)null)
				{
					InitContent();
				}
				return _content.transform;
			}
		}

		public void SetSize(Vector2 size)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			_content.GetComponent<RectTransform>().sizeDelta = size;
		}

		private void InitContent()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)_content == (Object)null)
			{
				_content = new GameObject("Content");
			}
			RectTransform obj = _content.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
		}

		private void Start()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ScrollablePanel");
			val.transform.SetParent(((Component)this).transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.sizeDelta = new Vector2(1200f, 660f);
			obj.anchorMin = new Vector2(0.5f, 0.5f);
			obj.anchorMax = new Vector2(0.5f, 0.5f);
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchoredPosition = new Vector2(0f, -60f);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
			ScrollRect obj2 = val.AddComponent<ScrollRect>();
			GameObject val3 = new GameObject("Viewport");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.sizeDelta = new Vector2(1120f, 660f);
			val4.anchorMin = new Vector2(0.5f, 0.5f);
			val4.anchorMax = new Vector2(0.5f, 0.5f);
			val4.pivot = new Vector2(0.5f, 0.5f);
			val4.anchoredPosition = new Vector2(0f, 0f);
			Image val5 = val3.AddComponent<Image>();
			((Graphic)val5).color = new Color(0f, 0f, 0f, 0.1f);
			val3.AddComponent<Mask>().showMaskGraphic = false;
			obj2.viewport = val4;
			Content.SetParent(val3.transform, false);
			Image val6 = _content.AddComponent<Image>();
			((Graphic)val6).color = new Color(0f, 0f, 0f, 0f);
			obj2.content = ((Component)Content).GetComponent<RectTransform>();
			obj2.horizontal = false;
			obj2.vertical = true;
			obj2.scrollSensitivity = 10f;
			GameObject val7 = new GameObject("Scrollbar");
			val7.transform.SetParent(val.transform, false);
			Scrollbar val8 = val7.AddComponent<Scrollbar>();
			RectTransform component = val7.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(20f, 660f);
			component.anchorMin = new Vector2(1f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			val8.direction = (Direction)3;
			val8.value = 1f;
			obj2.verticalScrollbar = val8;
			obj2.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			if (DevConfig.SelectionPanel.DebugView.Value)
			{
				((Graphic)val2).color = new Color(0f, 1f, 0f, 0.4f);
				((Graphic)val2).color = new Color(0f, 1f, 0f, 0.4f);
				((Graphic)val5).color = new Color(0f, 1f, 1f, 0.4f);
				((Graphic)val6).color = new Color(1f, 0f, 0.4f, 0.4f);
			}
		}
	}
}
namespace IconSign.Selection.Interaction
{
	internal class EscClosePanelListener : MonoBehaviour
	{
		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)27))
			{
				IconSelectionPanel.Instance.ClosePanel();
			}
		}
	}
	internal class HoverEffect : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler
	{
		public delegate void ClickAction();

		private Image _image;

		public Color normalColor = Color.gray;

		public Color hoverColor = Color.white;

		public event ClickAction OnClicked;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_image = ((Component)this).GetComponent<Image>();
			((Graphic)_image).color = normalColor;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)_image).color = hoverColor;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)_image).color = normalColor;
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			this.OnClicked?.Invoke();
			((Graphic)_image).color = normalColor;
		}
	}
}
namespace IconSign.Selection.IconScrollContent
{
	internal static class CreateInventoryIcons
	{
		internal delegate void IconClicked(string iconName);

		private const float IconLineWidth = 1120f;

		private const float IconSize = 44f;

		private const float Spacing = 10f;

		internal static event IconClicked OnIconClicked;

		public static Vector2 FillContent(Transform content)
		{
			//IL_0059: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = -20f;
			foreach (ItemData item in ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems())
			{
				GUIManager.Instance.CreateImage(IconName.GetName(item.GetIcon()), content, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num, num2), new Vector2(44f, 44f)).AddComponent<HoverEffect>().OnClicked += delegate
				{
					TriggerClickEvent(IconName.GetName(item.GetIcon()));
				};
				num += 54f;
				if (!(num <= 1120f))
				{
					num = 0f;
					num2 -= 54f;
				}
			}
			return new Vector2(1f, Mathf.Abs(num2) + 108f);
		}

		private static void TriggerClickEvent(string iconName)
		{
			CreateInventoryIcons.OnIconClicked?.Invoke(iconName);
		}
	}
	public static class CreateRecentIcons
	{
		public delegate void IconClickedAction(string iconName);

		private const float IconLineWidth = 1120f;

		private const float IconSize = 44f;

		private const float Spacing = 10f;

		public static event IconClickedAction OnIconClicked;

		public static Vector2 FillContent(Transform content)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = -20f;
			foreach (string icon in RecentIcons.Get())
			{
				if (!string.IsNullOrEmpty(icon))
				{
					GUIManager.Instance.CreateImage(icon, content, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num, num2), new Vector2(44f, 44f)).AddComponent<HoverEffect>().OnClicked += delegate
					{
						TriggerClickEvent(icon);
					};
					num += 54f;
					if (!(num <= 1120f))
					{
						num = 0f;
						num2 -= 54f;
					}
				}
			}
			return new Vector2(1f, Mathf.Abs(num2) + 108f);
		}

		private static void TriggerClickEvent(string iconName)
		{
			CreateRecentIcons.OnIconClicked?.Invoke(iconName);
		}
	}
}
namespace IconSign.Selection.IconScrollContent.CategorizedIcons
{
	public static class CreateCategorizedIcons
	{
		public delegate void IconClickedAction(string iconName);

		private const int BatchSize = 100;

		public static IconClickedAction OnIconClicked;

		private static readonly List<Category> IconCategories = new List<Category>();

		private static ScrollableContainer _scrollableContainer;

		private static GameObject NoResultsLabel { get; set; }

		public static void StartFillingContent(Transform content, ScrollableContainer container)
		{
			_scrollableContainer = container;
			((MonoBehaviour)_scrollableContainer).StartCoroutine(FillContentCoroutine(content, _scrollableContainer));
		}

		public static void SearchInputChanged(string searchInput)
		{
			if (searchInput.Length == 0)
			{
				ShowAll();
			}
			else
			{
				ApplyFilter(SearchIndex.Search(searchInput));
			}
		}

		private static void ShowAll()
		{
			foreach (Category iconCategory in IconCategories)
			{
				iconCategory.ShowAll();
			}
			Layout.Apply(IconCategories, _scrollableContainer);
		}

		private static void ApplyFilter(string[] iconNames)
		{
			foreach (Category iconCategory in IconCategories)
			{
				iconCategory.HideAll();
			}
			foreach (Category iconCategory2 in IconCategories)
			{
				iconCategory2.ShowIcons(iconNames);
			}
			foreach (Category iconCategory3 in IconCategories)
			{
				iconCategory3.Label.SetActive(!iconCategory3.IsHidden());
			}
			NoResultsLabel.SetActive(iconNames.Length == 0);
			Layout.Apply(IconCategories, _scrollableContainer);
		}

		private static IEnumerator FillContentCoroutine(Transform content, ScrollableContainer scrollableContainer)
		{
			IconCategories.Clear();
			string[] categories = new string[9] { "consumables", "farming", "armor", "weapons", "building", "furniture", "misc", "plunder", "abstract" };
			Dictionary<string, List<Sprite>> catSpriteDict = IconSign.Data.CategorizedIcons.PrepareData(categories);
			yield return null;
			int createdCount = 0;
			DateTime startTime = DateTime.Now;
			scrollableContainer.SetSize(new Vector2(0f, 0f));
			NoResultsLabel = CreateLabel(content, "search_no_results");
			NoResultsLabel.SetActive(false);
			RectTransform component = NoResultsLabel.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(200f, 30f);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = new Vector2(0f, 0f);
			string[] array = categories;
			foreach (string text in array)
			{
				List<Sprite> categorySprites = catSpriteDict[text];
				Category iconCategory = new Category();
				IconCategories.Add(iconCategory);
				GameObject label = CreateLabel(content, text);
				iconCategory.Label = label;
				yield return null;
				foreach (Sprite sprite in categorySprites)
				{
					string name = IconName.GetName(sprite);
					GameObject val = GUIManager.Instance.CreateImage(name, content, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(1f, 1f));
					val.AddComponent<HoverEffect>().OnClicked += delegate
					{
						TriggerClickEvent(sprite);
					};
					iconCategory.Icons.Add(name, val);
					createdCount++;
					if (createdCount % 100 == 0)
					{
						yield return null;
					}
				}
			}
			Logger.LogInfo((object)$"Created {createdCount} icons in {(DateTime.Now - startTime).TotalMilliseconds}ms");
			Layout.Apply(IconCategories, scrollableContainer);
		}

		private static GameObject CreateLabel(Transform content, string category)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			GameObject val = new GameObject("CategoryLabel");
			val.transform.SetParent(content, false);
			Text obj = val.AddComponent<Text>();
			obj.text = LocalizationManager.Instance.TryTranslate(category);
			obj.font = GUIManager.Instance.AveriaSerifBold;
			obj.fontSize = 20;
			((Graphic)obj).color = GUIManager.Instance.ValheimBeige;
			obj.alignment = (TextAnchor)3;
			return val;
		}

		private static void TriggerClickEvent(Sprite sprite)
		{
			OnIconClicked?.Invoke(IconName.GetName(sprite));
		}
	}
	public abstract class Layout
	{
		private const float IconLineWidth = 1120f;

		private const float IconSize = 44f;

		private const float Spacing = 10f;

		private static StatsLogger _layoutStats;

		public static void Apply(List<Category> iconCategories, ScrollableContainer scrollableContainer)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (_layoutStats == null)
			{
				_layoutStats = new StatsLogger("Layout", DevConfig.Layout.LogLayoutStatsEvery.Value);
			}
			_layoutStats.Start();
			float num = -0f;
			foreach (Category iconCategory in iconCategories)
			{
				if (!iconCategory.Label.activeSelf)
				{
					continue;
				}
				float num2 = 0f;
				num -= 54f;
				RectTransform component = iconCategory.Label.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(1120f, 30f);
				component.anchoredPosition = new Vector2(num2, num);
				Anchors.SetTopLeft(iconCategory.Label);
				num2 = 0f;
				num -= 54f;
				foreach (GameObject activeIcon in iconCategory.GetActiveIcons())
				{
					if (IsAtEndOfLine(num2, 1120f))
					{
						num2 = 0f;
						num -= 54f;
					}
					RectTransform component2 = activeIcon.GetComponent<RectTransform>();
					component2.sizeDelta = new Vector2(44f, 44f);
					component2.anchoredPosition = new Vector2(num2, num);
					Anchors.SetTopLeft(activeIcon);
					num2 += 54f;
				}
			}
			Vector2 size = default(Vector2);
			((Vector2)(ref size))..ctor(1f, Mathf.Abs(num) + 108f);
			scrollableContainer.SetSize(size);
			_layoutStats.Done();
		}

		private static bool IsAtEndOfLine(float x, float right)
		{
			return x + 44f > right;
		}
	}
	public class Category
	{
		public GameObject Label { get; set; }

		public Dictionary<string, GameObject> Icons { get; } = new Dictionary<string, GameObject>();


		public List<GameObject> GetActiveIcons()
		{
			return (from icon in Icons
				where icon.Value.activeSelf
				select icon.Value).ToList();
		}

		public bool IsHidden()
		{
			return Icons.All((KeyValuePair<string, GameObject> icon) => !icon.Value.activeSelf);
		}

		public void HideAll()
		{
			Label.SetActive(false);
			foreach (KeyValuePair<string, GameObject> icon in Icons)
			{
				icon.Value.SetActive(false);
			}
		}

		public void ShowIcons(string[] iconNames)
		{
			Label.SetActive(true);
			foreach (string key in iconNames)
			{
				if (Icons.ContainsKey(key))
				{
					Icons[key].SetActive(true);
				}
			}
		}

		public void ShowAll()
		{
			Label.SetActive(true);
			foreach (KeyValuePair<string, GameObject> icon in Icons)
			{
				icon.Value.SetActive(true);
			}
		}
	}
}
namespace IconSign.Helper
{
	public abstract class Anchors
	{
		private static void SetTopLeft(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0f, 1f);
			rt.anchorMax = new Vector2(0f, 1f);
			rt.pivot = new Vector2(0f, 1f);
		}

		public static void SetTopMiddle(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0.5f, 1f);
			rt.anchorMax = new Vector2(0.5f, 1f);
			rt.pivot = new Vector2(0.5f, 1f);
		}

		public static void SetTopRight(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(1f, 1f);
			rt.anchorMax = new Vector2(1f, 1f);
			rt.pivot = new Vector2(1f, 1f);
		}

		public static void SetMiddleLeft(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0f, 0.5f);
			rt.anchorMax = new Vector2(0f, 0.5f);
			rt.pivot = new Vector2(0f, 0.5f);
		}

		public static void SetMiddle(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0.5f, 0.5f);
			rt.anchorMax = new Vector2(0.5f, 0.5f);
			rt.pivot = new Vector2(0.5f, 0.5f);
		}

		public static void SetMiddleRight(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(1f, 0.5f);
			rt.anchorMax = new Vector2(1f, 0.5f);
			rt.pivot = new Vector2(1f, 0.5f);
		}

		public static void SetBottomLeft(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0f, 0f);
			rt.anchorMax = new Vector2(0f, 0f);
			rt.pivot = new Vector2(0f, 0f);
		}

		public static void SetBottomMiddle(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(0.5f, 0f);
			rt.anchorMax = new Vector2(0.5f, 0f);
			rt.pivot = new Vector2(0.5f, 0f);
		}

		public static void SetBottomRight(RectTransform rt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(1f, 0f);
			rt.anchorMax = new Vector2(1f, 0f);
			rt.pivot = new Vector2(1f, 0f);
		}

		public static void SetPosition(RectTransform rt, Vector2 vector2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rt.anchoredPosition = vector2;
		}

		public static void SetSize(RectTransform rt, Vector2 vector2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rt.sizeDelta = vector2;
		}

		public static void SetTopLeft(GameObject rt)
		{
			SetTopLeft(rt.GetComponent<RectTransform>());
		}

		public static void SetPosition(GameObject searchIcon, Vector2 vector2)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			SetPosition(searchIcon.GetComponent<RectTransform>(), vector2);
		}

		public static void SetSize(GameObject searchIcon, Vector2 vector2)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			SetSize(searchIcon.GetComponent<RectTransform>(), vector2);
		}
	}
	public static class IconName
	{
		internal static string GetName(Sprite sprite)
		{
			string text = ((Object)sprite).name;
			if (text.EndsWith("(Clone)"))
			{
				text = text.Substring(0, text.Length - "(Clone)".Length);
			}
			return text;
		}
	}
	public class StatsLogger
	{
		private DateTime _start;

		private string Name { get; set; }

		private int LogEvery { get; set; }

		private int Total { get; set; }

		private float AvgDuration { get; set; }

		private float MinDuration { get; set; } = float.MaxValue;


		private float MaxDuration { get; set; }

		public StatsLogger(string name, int logEvery)
		{
			Name = name;
			LogEvery = logEvery;
		}

		public void Start()
		{
			_start = DateTime.Now;
		}

		public void Done()
		{
			float num = (float)(DateTime.Now - _start).TotalMilliseconds;
			Total++;
			AvgDuration = (AvgDuration * (float)(Total - 1) + num) / (float)Total;
			MinDuration = Mathf.Min(MinDuration, num);
			MaxDuration = Mathf.Max(MaxDuration, num);
			if (Total % LogEvery == 0)
			{
				Logger.LogInfo((object)ToString());
			}
		}

		public override string ToString()
		{
			return $"Stats for {Name} - Total: {Total}, Avg: {AvgDuration}ms, Min: {MinDuration}ms, Max: {MaxDuration}ms";
		}
	}
}
namespace IconSign.Extensions
{
	public static class ImageCreationExtensions
	{
		public static GameObject CreateImage(this GUIManager guiManager, string spriteName, Transform parent)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return guiManager.CreateImage(spriteName, parent, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one);
		}

		public static GameObject CreateImage(this GUIManager guiManager, string spriteName, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 position, Vector2 size)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			GameObject val = new GameObject("Image", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			Image component = val.GetComponent<Image>();
			RectTransform component2 = val.GetComponent<RectTransform>();
			val.transform.SetParent(parent, false);
			component.sprite = guiManager.GetSprite(spriteName);
			component2.anchorMin = anchorMin;
			component2.anchorMax = anchorMax;
			component2.pivot = pivot;
			component2.anchoredPosition = position;
			component2.sizeDelta = size;
			return val;
		}
	}
	public static class RectTransformExtension
	{
		public static void Expand(this RectTransform rectTransform)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
			((Transform)rectTransform).localScale = new Vector3(1f, 1f, 1f);
		}
	}
}
namespace IconSign.Data
{
	public static class CategorizedIcons
	{
		internal static Dictionary<string, List<Sprite>> PrepareData(string[] categories)
		{
			DateTime now = DateTime.Now;
			Logger.LogInfo((object)"Loading icon categories...");
			Sprite[] sprites = GetSprites();
			Dictionary<string, List<Sprite>> result = BuildCategorizedIcons(categories, sprites);
			Logger.LogInfo((object)$"Loaded icon categories in {(DateTime.Now - now).TotalMilliseconds}ms");
			return result;
		}

		private static Dictionary<string, List<Sprite>> BuildCategorizedIcons(string[] categories, Sprite[] sprites)
		{
			DateTime now = DateTime.Now;
			Logger.LogInfo((object)"Building categorized icons...");
			Dictionary<string, List<Sprite>> result = InitResult(categories);
			BuildDataIndices(IconCategories.Data, out var categoryByIcon, out var nameOrderByIcon);
			BuildSpritesByCategoryIndex(sprites, categoryByIcon, result);
			SortSprites(result, nameOrderByIcon);
			Logger.LogInfo((object)$"Built categorized icons in {(DateTime.Now - now).TotalMilliseconds}ms");
			return result;
		}

		private static Sprite[] GetSprites()
		{
			DateTime now = DateTime.Now;
			Logger.LogInfo((object)"Loading icons...");
			SpriteAtlas prefab = Cache.GetPrefab<SpriteAtlas>("IconAtlas");
			Sprite[] array = (Sprite[])(object)new Sprite[prefab.spriteCount];
			prefab.GetSprites(array);
			Logger.LogInfo((object)$"Loaded {array.Length} sprites in {(DateTime.Now - now).TotalMilliseconds}ms");
			return array;
		}

		private static void SortSprites(Dictionary<string, List<Sprite>> result, Dictionary<string, int> nameOrderByIcon)
		{
			foreach (KeyValuePair<string, List<Sprite>> item in result)
			{
				item.Value.Sort(delegate(Sprite a, Sprite b)
				{
					string name = IconName.GetName(a);
					string name2 = IconName.GetName(b);
					return nameOrderByIcon[name].CompareTo(nameOrderByIcon[name2]);
				});
			}
		}

		private static void BuildSpritesByCategoryIndex(Sprite[] sprites, Dictionary<string, string> categoryByIcon, Dictionary<string, List<Sprite>> result)
		{
			foreach (Sprite val in sprites)
			{
				string name = IconName.GetName(val);
				if (categoryByIcon.TryGetValue(name, out var value))
				{
					result[value].Add(val);
				}
				else
				{
					Logger.LogWarning((object)("Icon " + name + " has no category"));
				}
			}
		}

		private static Dictionary<string, List<Sprite>> InitResult(string[] categories)
		{
			Dictionary<string, List<Sprite>> dictionary = new Dictionary<string, List<Sprite>>();
			foreach (string key in categories)
			{
				dictionary[key] = new List<Sprite>();
			}
			return dictionary;
		}

		private static void BuildDataIndices(Dictionary<string, string[]> data, out Dictionary<string, string> categoryByIcon, out Dictionary<string, int> nameOrderByIcon)
		{
			categoryByIcon = new Dictionary<string, string>();
			nameOrderByIcon = new Dictionary<string, int>();
			foreach (KeyValuePair<string, string[]> datum in data)
			{
				string key = datum.Key;
				string[] value = datum.Value;
				for (int i = 0; i < value.Length; i++)
				{
					string key2 = value[i];
					categoryByIcon[key2] = key;
					nameOrderByIcon[key2] = i;
				}
			}
		}
	}
	public abstract class IconCategories
	{
		internal static readonly Dictionary<string, string[]> Data = new Dictionary<string, string[]>
		{
			{
				"abstract",
				new string[68]
				{
					"plank", "Slimed", "bronzehead_01", "bronzehead_02", "fireworks_rocket", "placeholder", "clear_ground", "wood_box", "skill_block", "skill_jump",
					"skill_run", "skill_sneak", "skill_swim", "skill_woodcutting", "Frost", "Lightning", "replant", "Poison", "immobilized", "rested",
					"resting", "raise", "Burning", "Cold", "Cold_lvl2", "ColdProtection", "CorpseRun", "cozy", "Encumbered", "Exhausted",
					"Full", "Healthy", "Hungry", "Shelter", "Smoked", "SoftDeath", "Sun", "SunProtection", "Tared", "Wet",
					"Warm", "Warm_old", "Campfire", "Sandstorm", "ShipMaterializer", "T_emote_blowkiss", "T_emote_bow", "T_emote_challenge", "T_emote_cheer", "T_emote_comehere",
					"T_emote_cower", "T_emote_cry", "T_emote_dance", "T_emote_despair", "T_emote_flex", "T_emote_headbang", "T_emote_kneel", "T_emote_laugh", "T_emote_nonono", "T_emote_point",
					"T_emote_roar", "T_emote_shrug", "T_emote_sit", "T_emote_thumbsup", "T_emote_wave", "paved_road", "cultivate_ground", "path"
				}
			},
			{
				"armor",
				new string[154]
				{
					"HelmetAshlandsMage", "HelmetAshlandsMedium", "HelmetBronze", "HelmetBronzeHorned", "HelmetCarapace", "HelmetDrake", "HelmetDverger", "HelmetFenris", "HelmetFishingHat", "HelmetFlametal",
					"HelmetIron", "HelmetLeather", "HelmetMage", "HelmetMidsummerCrown", "HelmetOdin", "HelmetPadded", "HelmetPointyHat", "HelmetRoot", "HelmetStrawHat", "HelmetTrollLeather",
					"HelmetYule", "hat1", "hat2", "hat3", "hat4", "hat5", "hat6", "hat7", "hat8", "hat9",
					"hat10", "ArmorBronzeChest", "ArmorCarapaceChest", "ArmorFenringChest", "ArmorFlametalChest", "ArmorIronChest", "ArmorLeatherChest", "ArmorMageAshlandsChest", "ArmorMageChest", "ArmorMediumAshlandsChest",
					"ArmorPaddedCuirass", "ArmorRootChest", "ArmorTrollLeatherChest", "ArmorWolfChest", "RagPants", "ArmorBronzeLegs", "ArmorCarapaceLegs", "ArmorFenringLegs", "ArmorFlametalLegs", "ArmorIronLegs",
					"ArmorLeatherLegs", "ArmorMageAshlandsLegs", "ArmorMageLegs", "ArmorMediumAshlandsLegs", "ArmorPaddedGreaves", "ArmorRootLegs", "ArmorTrollLeatherLegs", "ArmorwolfLegs", "capeash", "capeasksvin",
					"CapeDeerHide", "CapeFeather", "CapeFenris", "CapeLinen0", "CapeLinen1", "CapeLinen2", "CapeLinen3", "CapeLinen4", "CapeLinen5", "CapeLox",
					"CapeOdin", "CapeTrollHide", "CapeWolf", "dress1", "dress2", "dress3", "dress4", "dress5", "dress6", "dress7",
					"dress8", "dress9", "dress10", "RagTunic", "tunic1", "tunic2", "tunic3", "tunic4", "tunic5", "tunic6",
					"tunic7", "tunic8", "tunic9", "tunic10", "shield_wood0", "shield_wood1", "shield_wood2", "shield_wood3", "shield_bronzebuckler", "shield_ironbuckler",
					"shield_banded0", "shield_banded1", "shield_banded2", "shield_banded3", "shield_silver00", "shield_silver01", "shield_silver02", "shield_silver03", "shield_silver04", "shield_silver05",
					"shield_silver06", "StaffShield", "shield_blackmetal00", "shield_blackmetal01", "shield_blackmetal02", "shield_blackmetal03", "shield_blackmetal04", "shield_blackmetal05", "shield_blackmetal06", "shield_blackmetaltower00",
					"shield_blackmetaltower01", "shield_blackmetaltower02", "shield_blackmetaltower03", "shield_blackmetaltower04", "shield_blackmetaltower05", "shield_blackmetaltower06", "shield_carapacebuckler", "shield_woodtower0", "shield_woodtower1", "shield_woodtower2",
					"shield_woodtower3", "shield_woodtower4", "shield_woodtower5", "shield_woodtower6", "shield_irontower0", "shield_irontower1", "shield_irontower2", "shield_irontower3", "shield_irontower4", "shield_irontower5",
					"shield_irontower6", "shield_serpentscale", "shield_flametal00", "shield_flametal01", "shield_flametal02", "shield_flametal03", "shield_flametal04", "shield_flametaltower00", "shield_flametaltower01", "shield_flametaltower02",
					"shield_flametaltower03", "shield_flametaltower04", "shield_bonetower", "shield_carapace"
				}
			},
			{
				"building",
				new string[167]
				{
					"stake_wall", "wood_beam1", "wood_beam2", "wood_beam_26", "wood_beam_45", "wood_door", "wood_dragon1", "wood_fence", "wood_floor", "wood_floor_1x1",
					"wood_gate", "wood_ladder", "wood_log_26", "wood_log_45", "wood_logpole2", "wood_logpole4", "wood_logwall", "wood_logwall_4x05", "wood_pole", "wood_pole2",
					"wood_roof", "wood_roof_45", "wood_roof_icorner", "wood_roof_icorner_45", "wood_roof_ocorner", "wood_roof_ocorner_45", "wood_roof_top", "wood_roof_top_45", "wood_stair", "wood_wall",
					"wood_wall_half", "wood_wall_quarter", "wood_wall_roof", "wood_wall_roof_45", "wood_wall_roof_45_upsidedown", "wood_wall_roof_cross", "wood_wall_roof_cross_45", "wood_wall_roof_upsidedown", "wood_window", "stone_arch",
					"stone_floor", "stone_floor_2x2", "stone_pillar", "stone_stair", "stone_wall_1x1", "stone_wall_2x1", "stone_wall_4x2", "darkwood_arch", "darkwood_beam", "darkwood_beam4",
					"darkwood_beam_26", "darkwood_beam_45", "darkwood_decowall", "darkwood_gate", "darkwood_pole", "darkwood_pole4", "darkwood_raven", "darkwood_roof_26", "darkwood_roof_45", "darkwood_roof_icorner_26",
					"darkwood_roof_icorner_45", "darkwood_roof_ocorner_26", "darkwood_roof_ocorner_45", "darkwood_roof_top_26", "darkwood_roof_top_45", "darkwood_wolf", "iron_floor_1x1", "iron_floor_2x2", "iron_grate", "iron_wall_1x1",
					"iron_wall_2x2", "woodiron_beam", "woodiron_beam_26", "woodiron_beam_45", "woodiron_pole", "blackmarble_1x1", "blackmarble_2x1x1", "blackmarble_2x2", "blackmarble_arch", "blackmarble_column_small",
					"blackmarble_column_wide", "blackmarble_cornice", "blackmarble_cornice_corner", "blackmarble_floor", "blackmarble_floor_tile_large", "blackmarble_floor_tile_small", "blackmarble_plinth", "blackmarble_plinth_corner", "blackmarble_stair", "blackmarble_tip",
					"blackmarble_triangle_floor", "blackmarble_wall_tile_large", "blackmarble_wall_tile_small", "blackmarble_wall_tile_tall", "blackwood_stakewall", "blackmarble_2x2x1", "hexagonal_gate", "sharpstakes", "piece_dvergr_metall_wall_2x2", "piece_dvergr_pole",
					"piece_dvergr_sharpstakes", "piece_dvergr_spiralstair", "piece_dvergr_spiralstair_right", "piece_dvergr_stake_wall", "piece_dvergr_wood_wall", "ashwood_arch", "ashwood_arch_bottom", "ashwood_arch_top", "ashwood_beam_1m", "ashwood_beam_2m",
					"ashwood_beam_26", "ashwood_beam_45", "ashwood_cross_26", "ashwood_cross_45", "ashwood_deco_floor", "ashwood_decowall_2x2", "ashwood_decowall_divider", "ashwood_decowall_tree", "ashwood_door", "ashwood_floor",
					"ashwood_floor_1x1", "ashwood_halfwall_1x2", "ashwood_pole_1m", "ashwood_pole_2m", "ashwood_quarterwall_1x1", "ashwood_stair", "ashwood_wall_2x2", "ashwood_wall_arch", "ashwood_wall_roof_26", "ashwood_wall_roof_26_upsidedown",
					"ashwood_wall_roof_45", "ashwood_wall_roof_45_upsidedown", "grausten_arch_medium", "grausten_arch_small", "grausten_beam_medium", "grausten_beam_small", "grausten_floor_1x1", "grausten_floor_2x2", "grausten_floor_4x4", "grausten_ladder",
					"grausten_pillar_medium", "grausten_pillar_small", "grausten_pillar_tapered", "grausten_pillar_tapered_inv", "grausten_roof45", "grausten_roof45_arch", "grausten_roof45_arch_corner", "grausten_roof45_arch_corner2", "grausten_roof45_corner", "grausten_roof45_corner2",
					"grausten_stair", "grausten_wall_1x2", "grausten_wall_2x2", "grausten_wall_4x2", "grausten_wall_arch", "grausten_wall_arch_inv", "grausten_window_2x2", "grausten_window_4x2", "piece_ashland_arch_twisted", "piece_ashland_floor_1x1",
					"piece_ashland_pillar_twisted", "piece_ashland_stone_ladder", "piece_ashland_wall_3x2", "piece_ashland_window_3x2", "flametal_gate", "flametal_pillar", "flametal_beam"
				}
			},
			{
				"consumables",
				new string[169]
				{
					"BlackSoup", "BloodPudding", "BonemawMeat", "BonemawMeatCooked", "Bread", "BreadDough", "CarrotSoup", "CuredSquirrelHamstring", "FeastAshlands", "FeastBlackforest",
					"FeastMeadows", "FeastMistlands", "FeastMountains", "FeastOcean", "FeastPlains", "FeastSwamps", "FiddleberrySoup", "FierySvinstew", "FishAndBread", "FishAndBreadUncooked",
					"FishWraps", "LoxPie", "LoxPieUncooked", "MarinatedGreens", "MashedMeat", "MeadBase", "MeadBaseBarleyWine", "MeadBaseBugRepellent", "MeadBaseBzerker", "MeadBaseEitrLingering",
					"MeadBaseEitrMinor", "MeadBaseFrostResist", "MeadBaseHasty", "MeadBaseHealthLingering", "MeadBaseHealthMajor", "MeadBaseHealthMedium", "MeadBaseHealthMinor", "MeadBaseLightFoot", "MeadBasePoisonResist", "MeadBaseStaminaLingering",
					"MeadBaseStaminaMedium", "MeadBaseStaminaMinor", "MeadBaseStrength", "MeadBaseSwimmer", "MeadBaseTamer", "MeadBaseTasty", "Meat", "MeatPlatter", "MeatPlatterUncooked", "MisthareSupreme",
					"MisthareSupremeUncooked", "MushroomOmelette", "OnionSoup", "PiquantPie", "PiquantPieUncooked", "PowderedDragonEgg", "PungentPebbles", "QueensJam", "RoastedCrustPie", "RoastedCrustPieUncooked",
					"Salad", "Sausages", "ScorchingMedley", "SeekerAspic", "SerpentStew", "SizzlingBerryBroth", "SparklingShroomshake", "TurnipStew", "WolfSkewer", "YggdrasilPorridge",
					"asksvin_meat", "asksvin_meat_cooked", "barleyflour", "barleywine", "bloodbag", "blueberries", "boarjerky", "bugmeat", "bugmeat_cooked", "carrot",
					"chicken_meat", "chicken_meat_cooked", "cloudberry", "dandelion", "deer_meat", "deer_meat_cooked", "deerstew", "dragonegg", "egg", "egg_cooked",
					"entrails", "eyescream", "faderdrop", "fiddlehead", "fish1", "fish10", "fish11", "fish12", "fish2", "fish3",
					"fish4", "fish5", "fish6", "fish7", "fish8", "fish9", "fish_cooked", "fish_raw", "giantbloodsack", "hare_meat",
					"hare_meat_cooked", "harvester1", "harvester2", "honey", "honeyglazedchicken", "honeyglazedchickenuncooked", "loxmeat", "loxmeat_cooked", "mandible", "meat_cooked",
					"meat_rotten", "mincemeatsauce", "mushroom", "mushroomblue", "mushroombzerker", "mushroomjotunpuffs", "mushroommagecap", "mushroomsmokepuff", "mushroomyellow", "neckgill",
					"necktail", "necktailgrilled", "onion", "potion_bugrepellent", "potion_bzerker", "potion_eitr_lingering", "potion_eitr_minor", "potion_frostresist", "potion_hasty", "potion_health_lingering",
					"potion_health_major", "potion_health_medium", "potion_health_minor", "potion_lightfoot", "potion_pheromones", "potion_poisonresist", "potion_stamina_lingering", "potion_stamina_medium", "potion_stamina_minor", "potion_strength",
					"potion_swimmer", "potion_tamer", "potion_tasty", "pukeberries", "raspberry", "raw_meat", "royaljelly", "serpentmeat", "serpentmeat_cooked", "shocklatesmoothie",
					"softtissue_cooked", "stuffedmagicshroom", "stuffedmagicshroomuncooked", "volture_meat", "volture_meat_cooked", "wolf_meat_cooked", "wolf_skewer", "wolfjerky", "wolfmeat"
				}
			},
			{
				"farming",
				new string[137]
				{
					"BlackWood", "Catapult", "CelestialFeather", "Fireworks_Rocket", "FishingBait", "FishingBait_ashlands", "FishingBait_cave", "FishingBait_deepnorth", "FishingBait_forest", "FishingBait_mistlands",
					"FishingBait_ocean", "FishingBait_plains", "FishingBait_swamp", "FragrantBundle", "FreshSeaweed", "Kvastur", "MechanicalSpring", "MoltenCore", "Silver", "Sulfur",
					"Tin", "TinOre", "WolfFang", "acorn", "ancientseed", "ashvine_sapling", "barley", "batteringram", "beechseeds", "beehive",
					"birchseeds", "blackmarble", "blackmetal", "blackmetalscrap", "blackwood_stack", "bone_stack", "bonefragments", "bronze", "bronzenails", "bronzescrap",
					"carrotseeds", "cart", "cartography_table", "chain", "chisel", "chitin", "coal", "coal_pile", "copper", "copperore",
					"copperscrap", "crystal", "cultivator_bronze", "cultivator_iron", "demister", "eitr", "elderbark", "feather", "finewood", "fircone",
					"fishingrod", "flametal", "flametal_old", "flametalore", "flametalore_old", "flax", "flint", "freezegland", "gdkingheart", "giantbloodsack",
					"grausten_pile", "greydwarf_eye", "guck", "hammer", "hoe", "iron", "ironlump", "ironnails", "ironore", "ironscrap",
					"leatherscraps", "linenthread", "mandible", "marble_pile", "mistletoe", "needle", "obsidian", "onion_sapling", "onion_seedling", "onionseeds",
					"ooze", "pinecone", "queenbee", "resin", "rotten_entrails", "roundlog", "sap", "sapling_beech", "sapling_birch", "sapling_fir",
					"sapling_oak", "sapling_pine", "seedcarrot", "seedturnip", "serpentscale", "sharpeningstone", "sharpstakes", "silverore", "skullpile", "softtissue",
					"spiceashlands", "spiceforests", "spicemistlands", "spicemountains", "spiceoceans", "spiceplains", "stone", "stone_grausten", "stone_pile", "surtling_core",
					"tar", "thistle", "treasure_stack", "turnip", "turnipseeds", "vineberryseeds", "vinegreen_sapling", "vinegreenseeds", "wishbone", "wood",
					"wood_core_stack", "wood_fine_stack", "wood_stack", "wood_yggdrasil_stack", "yggdrasilbranch", "yggdrasilwood", "ymirremains"
				}
			},
			{
				"furniture",
				new string[166]
				{
					"ArmorStand", "artisanextension", "artisanstation", "ashwood_bed", "banner01", "banner02", "banner03", "banner04", "banner05", "banner06",
					"banner07", "banner08", "banner09", "banner10", "banner11", "barberstation", "Barrel", "BarrelRings", "bath", "bed",
					"bed02", "bench01", "bench_blackmarble", "bench_log", "benchashwood", "blackforge", "blackforge_ext1", "blackforge_ext2", "blackforge_ext3", "blackforge_ext4",
					"blackwood_bench", "blastfurnace", "bonfire", "bonfire", "brazierceiling01", "brazierfloor01", "brazierfloor02", "butchertable", "cauldron", "meadcauldron",
					"chair", "candle_resin", "candlewick", "chair02", "chair03", "chest_blackmetal", "chest_hildir1", "chest_hildir2", "chest_hildir3", "chest_iron",
					"chest_private", "chest_treasure", "chest_wood", "clothdoor", "coal_kiln", "cooking_station", "cooking_station_iron", "crystal_wall", "deerhide", "fermenter",
					"feaster", "preptable", "firepit", "firepitiron", "forge", "forge_ext1", "forge_ext1", "forge_ext2", "forge_ext2", "forge_ext3",
					"forge_ext3", "forge_ext4", "forge_ext4", "forge_ext5", "forge_ext5", "forge_ext6", "forge_ext6", "groundtorch", "groundtorch_blue", "groundtorch_green",
					"groundtorch_mist", "groundtorch_wood", "guardstone", "hanging_cloth_blue1", "hanging_cloth_blue2", "hearth", "hide", "incinerator", "ironpit", "itemstand",
					"itemstandh", "jackoturnip", "jute_carpet", "juteblue_carpet", "lantern", "lavalantern", "loxpelt", "magetable", "magetable_ext1", "magetable_ext2",
					"magetable_ext3", "maypole", "mortarandpestle", "oven", "piece_dvergr_lantern", "piece_dvergr_lantern_pole", "piece_pot1", "piece_pot1_cracked", "piece_pot1_red", "piece_pot2",
					"piece_pot2_cracked", "piece_pot2_red", "piece_pot3", "piece_pot3_cracked", "piece_pot3_red", "pirate_ironchest", "pirate_privatechest", "pirate_woodwood", "portal", "portal_stone",
					"portal_wood", "potsnpans", "refinery", "rollingpins", "rug_asksvin", "rug_deer", "rug_hare", "rug_lox", "rug_straw", "rug_wolf",
					"sapcollector", "scalehide", "sign", "smelter", "spicerack", "spinningwheel", "stonecutter", "table", "table_blackmarble", "table_oak",
					"table_round", "tankard", "tankard_anniversary", "tankard_odin", "throne01", "throne02", "throne_blackmarble", "throne_bone", "torch", "torch_mist",
					"troll_hide", "walltorch", "walltorch", "windmill", "wisp", "wisplure", "wolfpelt", "woodwood", "workbench", "workbench_ext1",
					"workbench_ext2", "workbench_ext3", "workbench_ext4", "xmastree", "yulecrown", "yulegarland"
				}
			},
			{
				"misc",
				new string[87]
				{
					"AskBladder", "AskHide", "AsksvinEgg", "BarberKit", "Bell", "BellFragment", "BeltStrength", "BlackCore", "BonemawScale", "BonemawTooth",
					"Catapult", "CatapultAmmo", "CeramicPlate", "CharcoalResin", "CharredBone", "CharredCogwheel", "DvergrKey", "DvergrKeyFragment", "DvergrNeedle", "DyrnwynBlade",
					"DyrnwynHilt", "DyrnwynTip", "HardAntler", "JuteBlue", "JuteRed", "MechanicalSpring", "MorgenHeart", "MorgenSinew", "ProustitePowder", "RocketBlue",
					"RocketCyan", "RocketGreen", "RocketPurple", "RocketRed", "RocketWhite", "RocketYellow", "Root", "SadleAsksvin", "SadleLox", "ShieldCore",
					"SlowFall", "Sparkler", "Staff_Shield", "Trap", "Trap_Unstablemine", "Turret", "Vineberry", "VoltureEgg", "WolfHairBundle", "asksvinNeck",
					"asksvinPelvic", "asksvinRibcage", "asksvinSkull", "asksvinskeleton", "bilebag", "branch", "carapace", "charredskull", "cryptkey", "dragonegg",
					"dragontear", "dvergrtankard", "gift1", "gift2", "gift3", "goblintotem", "hildir_key1", "hildir_key2", "hildir_key3", "instrumentboneflute",
					"instrumentdrum", "instrumentharp", "instrumentlur", "instrumentmouthharp", "instrumenttagelharp", "karve", "larva", "longship", "longship_ashlands", "pot_shard_green",
					"pot_shard_red", "queendrop", "raft", "staminaupgrade", "thunderstone", "witheredbone", "yagluthdrop"
				}
			},
			{
				"plunder",
				new string[69]
				{
					"AmberPearl", "GemstoneBlue", "GemstoneGreen", "GemstoneRed", "TrophyAbomination", "TrophyAsksvin", "TrophyBlob", "TrophyBoar", "TrophyBonemass", "TrophyBonemawSerpent",
					"TrophyCharredArcher", "TrophyCharredMage", "TrophyCharredMelee", "TrophyCultist", "TrophyCultistHildir", "TrophyDeathSquito", "TrophyDeer", "TrophyDragonQueen", "TrophyDraugr", "TrophyDraugrElite",
					"TrophyDraugrFem", "TrophyDvergr", "TrophyEikthyr", "TrophyFader", "TrophyFallenValkyrie", "TrophyFenring", "TrophyForestTroll", "TrophyFrostTroll", "TrophyGjall", "TrophyGoblin",
					"TrophyGoblinBrute", "TrophyGoblinBruteBro", "TrophyGoblinKing", "TrophyGoblinShaman", "TrophyGoblinShamanBro", "TrophyGreydwarf", "TrophyGreydwarfBrute", "TrophyGreydwarfShaman", "TrophyGrowth", "TrophyHare",
					"TrophyHatchling", "TrophyLeech", "TrophyLox", "TrophyMorgen", "TrophyNeck", "TrophySGolem", "TrophySeeker", "TrophySeekerBrute", "TrophySeekerQueen", "TrophySerpent",
					"TrophySkeleton", "TrophySkeletonHildir", "TrophySkeletonPoison", "TrophySurtling", "TrophyTheElder", "TrophyTick", "TrophyUlv", "TrophyVolture", "TrophyWolf", "TrophyWraith",
					"amber", "coin", "coin_16", "coin_32", "coins", "ruby", "silvernecklace", "treasure_pile", "treasure_stack"
				}
			},
			{
				"weapons",
				new string[118]
				{
					"FistFenringClaw", "AtgeirBlackmetal", "AtgeirBronze", "AtgeirHimminAfl", "AtgeirIron", "AxeBerzerker", "AxeBerzerker_Blood", "AxeBerzerker_Lightning", "AxeBerzerker_Nature", "axe_blackmetal",
					"axe_bronze", "axe_flint", "axe_iron", "axe_JotunBane", "axe_stone", "BattleAxe", "BattleAxe_crystal", "MaceBronze", "MaceEldner", "MaceEldner_Blood",
					"MaceEldner_Lightning", "MaceEldner_Nature", "MaceIron", "MaceNeedle", "MaceSilver", "SpearAncientbark", "SpearBronze", "SpearCarapace", "SpearChitin", "SpearFlint",
					"SpearSplitner", "SpearSplitner_Blood", "SpearSplitner_Lightning", "SpearSplitner_Nature", "SpearWolffang", "SwordBlackmetal", "SwordBronze", "SwordCheat", "SwordDyrnwyn", "SwordFire",
					"SwordIron", "SwordKrom", "SwordMistwalker", "SwordNiedhogg", "SwordNiedhogg_Blood", "SwordNiedhogg_Lightning", "SwordNiedhogg_Nature", "SwordSilver", "bow", "bow_ashlands",
					"bow_ashlandsblood", "bow_ashlandsroot", "bow_ashlandsstorm", "bow_draugrfang", "bow_finewood", "bow_huntsman", "bow_spinesnap", "crossbow_arbalest", "crossbow_ripper", "crossbow_ripper_blood",
					"crossbow_ripper_root", "crossbow_ripper_storm", "arrow_bronze", "arrow_carapace", "arrow_charred", "arrow_fire", "arrow_flint", "arrow_frost", "arrow_iron", "arrow_needle",
					"arrow_obsidian", "arrow_poison", "arrow_silver", "arrow_wood", "bolt_blackmetal", "bolt_bone", "bolt_carapace", "bolt_charred", "bolt_iron", "StaffClusterbomb",
					"StaffFireball", "StaffGreenRoots", "StaffIceShards", "StaffLightning", "StaffRedTroll", "StaffSkeleton", "BombBile", "BombLava", "BombOoze", "BombSiege",
					"BombSmoke", "knife_blackmetal", "knife_butcher", "knife_chitin", "knife_copper", "knife_flint", "knife_silver", "knife_skollandhati", "THSwordSlayer", "THSWordSlayer_Blood",
					"THSwordSlayer_Lightning", "THSwordSlayer_Nature", "club", "pickaxe_antler", "pickaxe_blackmetal", "pickaxe_bronze", "pickaxe_iron", "pickaxe_stone", "Scythe", "ScytheHandle",
					"shieldgenerator", "SledgeDemolisher", "SledgeIron", "SledgeStagbreaker", "TurretBolt", "TurretBoltFlamteal", "TurretBoltWood", "WolfClaw"
				}
			}
		};
	}
	public abstract class IconTranslation
	{
		private static readonly Dictionary<string, string> Translations = new Dictionary<string, string>();

		public static void Register()
		{
			PieceManager.OnPiecesRegistered += Init;
		}

		private static void Init()
		{
			Logger.LogInfo((object)"init translations");
			InitFromPrefabs();
			InitFromPieces();
			Logger.LogInfo((object)$"{Translations.Count} translation load");
			SearchIndex.Init();
		}

		public static string Translate(string iconName)
		{
			if (Translations.Count == 0)
			{
				Init();
			}
			Translations.TryGetValue(iconName, out var value);
			return value;
		}

		private static void InitFromPrefabs()
		{
			List<GameObject> list = new List<GameObject>();
			list.AddRange(ZNetScene.instance.m_nonNetViewPrefabs);
			list.AddRange(ZNetScene.instance.m_prefabs);
			list.RemoveAll((GameObject x) => CustomPrefab.IsCustomPrefab(((Object)x).name));
			foreach (GameObject item in list.OrderBy((GameObject x) => ((Object)x).name).ToList())
			{
				ItemDrop component = item.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared.m_icons.Length != 0)
				{
					string name = ((Object)component.m_itemData.m_shared.m_icons[0]).name;
					if (!Translations.ContainsKey(name) && component.m_itemData.m_shared.m_name.StartsWith("$"))
					{
						Translations.Add(name, LocalizationManager.Instance.TryTranslate(component.m_itemData.m_shared.m_name));
					}
				}
			}
		}

		private static void InitFromPieces()
		{
			foreach (PieceTable pieceTable in PieceManager.Instance.GetPieceTables())
			{
				foreach (GameObject piece in pieceTable.m_pieces)
				{
					Piece component = piece.GetComponent<Piece>();
					if (!Translations.ContainsKey(((Object)component.m_icon).name) && component.m_name.StartsWith("$"))
					{
						Translations.Add(((Object)component.m_icon).name, LocalizationManager.Instance.TryTranslate(component.m_name));
					}
				}
			}
		}

		public static Dictionary<string, string> GetTranslations()
		{
			return Translations;
		}
	}
	public static class RecentIcons
	{
		private const char Delim = '|';

		public static ConfigEntry<string> ConfigEntry;

		private static List<string> Parse()
		{
			return new List<string>(ConfigEntry.Value.Split(new char[1] { '|' }));
		}

		internal static IEnumerable<string> Get()
		{
			return Parse();
		}

		internal static void Add(string iconName)
		{
			ConfigEntry.Value = string.Join('|'.ToString(), Parse().Prepend(iconName).Distinct().Take(100)
				.ToArray());
		}
	}
	public abstract class SearchIndex
	{
		private static StatsLogger _searchStats;

		private static readonly Dictionary<string, List<string>> Index = new Dictionary<string, List<string>>();

		public static void Init()
		{
			_searchStats = new StatsLogger("Search", DevConfig.SeachIndex.LogSearchStatsEvery.Value);
			DateTime now = DateTime.Now;
			Logger.LogInfo((object)"init search index");
			foreach (KeyValuePair<string, string> translation in IconTranslation.GetTranslations())
			{
				string[] array = translation.Value.Split(new char[1] { ' ' });
				for (int i = 0; i < array.Length; i++)
				{
					string key = array[i].ToLower();
					Index.TryGetValue(key, out var value);
					if (value == null)
					{
						value = new List<string>();
					}
					value.Add(translation.Key);
					Index[key] = value;
				}
			}
			Logger.LogInfo((object)("search index initialized in " + (DateTime.Now - now).TotalMilliseconds + "ms"));
			if (DevConfig.SeachIndex.DumpIndexToFile.Value)
			{
				DumpIndexToFile();
			}
		}

		private static void DumpIndexToFile()
		{
			string @string = PlayerPrefs.GetString("language", "en");
			string text = Paths.PluginPath + "/search_index_" + @string + ".txt";
			Logger.LogInfo((object)("dumping search index to " + text));
			File.WriteAllLines(text, Index.Select((KeyValuePair<string, List<string>> kv) => kv.Key + ": " + string.Join(", ", kv.Value)));
		}

		public static string[] Search(string query)
		{
			_searchStats.Start();
			List<string> list = new List<string>();
			query = query.ToLower();
			foreach (KeyValuePair<string, List<string>> item in Index)
			{
				if (item.Key.Contains(query))
				{
					list.AddRange(item.Value);
				}
			}
			List<string> list2 = list.Distinct().ToList();
			_searchStats.Done();
			return list2.ToArray();
		}
	}
	internal static class Translations
	{
		private const string en = "English";

		private const string de = "German";

		private const string fr = "French";

		private const string es = "Spanish";

		private const string no = "Norwegian";

		private const string sv = "Swedish";

		private const string da = "Danish";

		private const string fi = "Finnish";

		private const string it = "Italian";

		internal static void AddToLocalizationManager()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Icon Sign" },
				{ "use", "Paint" },
				{ "paint_item", "Paint item" },
				{ "tab_inventory", "Inventory" },
				{ "tab_recent", "Recent" },
				{ "tab_categories", "Categories" },
				{ "armor", "Armor" },
				{ "building", "Building" },
				{ "consumables", "Consumables" },
				{ "farming", "Farming" },
				{ "furniture", "Furniture" },
				{ "misc", "Misc" },
				{ "weapons", "Weapons" },
				{ "plunder", "Plunder" },
				{ "abstract", "Abstract" },
				{ "search_no_results", "No results found" }
			});
			CustomLocalization localization2 = LocalizationManager.Instance.GetLocalization();
			text = "German";
			localization2.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Icon Schild" },
				{ "use", "bemalen" },
				{ "paint_item", "Objekt anmalen" },
				{ "tab_inventory", "Inventar" },
				{ "tab_recent", "Kürzliche" },
				{ "tab_categories", "Kategorien" },
				{ "armor", "Rüstung & Kleidung" },
				{ "building", "Baustruktur" },
				{ "consumables", "Verbrauchsgüter" },
				{ "farming", "Anbau & Herstellung" },
				{ "furniture", "Einrichtung" },
				{ "misc", "Sonstiges" },
				{ "weapons", "Waffen & Werkzeuge" },
				{ "plunder", "Trophäen" },
				{ "abstract", "Abstrakt" },
				{ "search_no_results", "Keine Ergebnisse gefunden" }
			});
			CustomLocalization localization3 = LocalizationManager.Instance.GetLocalization();
			text = "French";
			localization3.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Icône de panneau" },
				{ "use", "Peindre" },
				{ "paint_item", "Peindre l'objet" },
				{ "tab_inventory", "Inventaire" },
				{ "tab_recent", "Récent" },
				{ "tab_categories", "Catégories" },
				{ "armor", "Armure" },
				{ "building", "Bâtiment" },
				{ "consumables", "Consommables" },
				{ "farming", "Agriculture" },
				{ "furniture", "Meubles" },
				{ "misc", "Divers" },
				{ "weapons", "Armes" },
				{ "plunder", "Butin" },
				{ "abstract", "Abstrait" },
				{ "search_no_results", "Aucun résultat trouvé" }
			});
			CustomLocalization localization4 = LocalizationManager.Instance.GetLocalization();
			text = "Spanish";
			localization4.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Icono de señal" },
				{ "use", "Pintar" },
				{ "paint_item", "Pintar objeto" },
				{ "tab_inventory", "Inventario" },
				{ "tab_recent", "Reciente" },
				{ "tab_categories", "Categorías" },
				{ "armor", "Armadura" },
				{ "building", "Edificio" },
				{ "consumables", "Consumibles" },
				{ "farming", "Agricultura" },
				{ "furniture", "Muebles" },
				{ "misc", "Diverso" },
				{ "weapons", "Armas" },
				{ "plunder", "Botín" },
				{ "abstract", "Abstracto" },
				{ "search_no_results", "No se encontraron resultados" }
			});
			CustomLocalization localization5 = LocalizationManager.Instance.GetLocalization();
			text = "Norwegian";
			localization5.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Ikon skilt" },
				{ "use", "Maling" },
				{ "paint_item", "Maling objekt" },
				{ "tab_inventory", "Inventar" },
				{ "tab_recent", "Siste" },
				{ "tab_categories", "Kategorier" },
				{ "armor", "Rustning" },
				{ "building", "Bygning" },
				{ "consumables", "Forbruksvarer" },
				{ "farming", "Jordbruk" },
				{ "furniture", "Møbler" },
				{ "misc", "Diverse" },
				{ "weapons", "Våpen" },
				{ "plunder", "Plyndring" },
				{ "abstract", "Abstrakt" },
				{ "search_no_results", "Ingen resultater funnet" }
			});
			CustomLocalization localization6 = LocalizationManager.Instance.GetLocalization();
			text = "Swedish";
			localization6.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Ikon skylt" },
				{ "use", "Måla" },
				{ "paint_item", "Måla objekt" },
				{ "tab_inventory", "Inventering" },
				{ "tab_recent", "Senaste" },
				{ "tab_categories", "Kategorier" },
				{ "armor", "Rustning" },
				{ "building", "Byggnad" },
				{ "consumables", "Förbrukningsvaror" },
				{ "farming", "Jordbruk" },
				{ "furniture", "Möbler" },
				{ "misc", "Diverse" },
				{ "weapons", "Vapen" },
				{ "plunder", "Plundra" },
				{ "abstract", "Abstrakt" },
				{ "search_no_results", "Inga resultat hittades" }
			});
			CustomLocalization localization7 = LocalizationManager.Instance.GetLocalization();
			text = "Danish";
			localization7.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Ikon skilt" },
				{ "use", "Maling" },
				{ "paint_item", "Maling objekt" },
				{ "tab_inventory", "Inventar" },
				{ "tab_recent", "Seneste" },
				{ "tab_categories", "Kategorier" },
				{ "armor", "Rustning" },
				{ "building", "Bygning" },
				{ "consumables", "Forbrugsvarer" },
				{ "farming", "Landbrug" },
				{ "furniture", "Møbler" },
				{ "misc", "Diverse" },
				{ "weapons", "Våben" },
				{ "plunder", "Plyndring" },
				{ "abstract", "Abstrakt" },
				{ "search_no_results", "Ingen resultater fundet" }
			});
			CustomLocalization localization8 = LocalizationManager.Instance.GetLocalization();
			text = "Finnish";
			localization8.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Kuvakekyltti" },
				{ "use", "Maali" },
				{ "paint_item", "Maalaa kohde" },
				{ "tab_inventory", "Inventaario" },
				{ "tab_recent", "Viimeisin" },
				{ "tab_categories", "Kategoriat" },
				{ "armor", "Panssari" },
				{ "building", "Rakennus" },
				{ "consumables", "Kulutustavarat" },
				{ "farming", "Maatalous" },
				{ "furniture", "Huonekalut" },
				{ "misc", "Sekalaiset" },
				{ "weapons", "Aseet" },
				{ "plunder", "Ryöstö" },
				{ "abstract", "Abstrakti" },
				{ "search_no_results", "Ei tuloksia" }
			});
			CustomLocalization localization9 = LocalizationManager.Instance.GetLocalization();
			text = "Italian";
			localization9.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "name", "Segnale icona" },
				{ "use", "Pittura" },
				{ "paint_item", "Pittura oggetto" },
				{ "tab_inventory", "Inventario" },
				{ "tab_recent", "Recente" },
				{ "tab_categories", "Categorie" },
				{ "armor", "Armatura" },
				{ "building", "Edificio" },
				{ "consumables", "Consumabili" },
				{ "farming", "Agricoltura" },
				{ "furniture", "Mobili" },
				{ "misc", "Varie" },
				{ "weapons", "Armi" },
				{ "plunder", "Bottino" },
				{ "abstract", "Astratto" },
				{ "search_no_results", "Nessun risultato trovato" }
			});
		}
	}
}
namespace IconSign.Config
{
	internal abstract class Constants
	{
		internal const string TranslationKeyName = "name";

		internal const string TranslationKeyUse = "use";

		internal const string TranslationKeyPaintItem = "paint_item";

		internal const string TabNameCategories = "tab_categories";

		internal const string TabNameRecent = "tab_recent";

		internal const string TabNameInventory = "tab_inventory";

		internal const string CategoryAbstract = "abstract";

		internal const string CategoryArmor = "armor";

		internal const string CategoryBuilding = "building";

		internal const string CategoryConsumables = "consumables";

		internal const string CategoryFarming = "farming";

		internal const string CategoryFurniture = "furniture";

		internal const string CategoryMiscellaneous = "misc";

		internal const string CategoryPlunder = "plunder";

		internal const string CategoryWeapons = "weapons";

		internal const string SearchNoResults = "search_no_results";

		internal const float BlitPreventionOffset = -0.007f;
	}
	internal static class DevConfig
	{
		internal static class SelectionPanel
		{
			internal static ConfigEntry<bool> DebugView;
		}

		internal static class IconSign
		{
			internal static ConfigEntry<bool> ShowInternalName;
		}

		internal static class SeachIndex
		{
			internal static ConfigEntry<bool> DumpIndexToFile;

			internal static ConfigEntry<int> LogSearchStatsEvery;
		}

		public class Layout
		{
			public static ConfigEntry<int> LogLayoutStatsEvery;
		}
	}
	internal static class ModConfig
	{
		internal static class SelectionPanel
		{
			internal static ConfigEntry<string> SelectedTab;

			internal static readonly string[] Tabs = new string[3] { "tab_categories", "tab_recent", "tab_inventory" };
		}
	}
}
namespace IconSign.Assets
{
	public static class SpriteLoader
	{
		public static Sprite LoadBuildPieceIcon()
		{
			return LoadSpriteFromEmbeddedResource("IconSign.Assets.prefab-icon.png");
		}

		private static Sprite LoadSpriteFromEmbeddedResource(string resourceName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0080: 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)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Debug.LogError((object)("Failed to find resource: " + resourceName));
				return null;
			}
			byte[] array = new byte[stream.Length];
			if (stream.Read(array, 0, array.Length) != array.Length)
			{
				Debug.LogError((object)("Failed to read resource: " + resourceName));
				return null;
			}
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
}

plugins/PetNameExtender.dll

Decompiled 10 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NameExtender")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NameExtender")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("716b3d76-bb99-4533-8c38-27a47302d670")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NameExtender;

[BepInPlugin("graphicsbard.PetNameExtender", "PetNameExtender", "1.0.0")]
[BepInProcess("valheim.exe")]
public class NameExtender : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("graphicsbard.PetNameExtender");

	private void Awake()
	{
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(Tameable), "SetName")]
public class TameableNamePatch
{
	public static bool Prefix(Tameable __instance)
	{
		TextInput.instance.RequestText((TextReceiver)(object)__instance, "$hud_rename", 255);
		return false;
	}
}

plugins/BBFarts.dll

Decompiled 10 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyDescription("")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyProduct("BBFarts")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2483fa13-8406-413c-8bad-a5bf7982d98d")]
[assembly: AssemblyFileVersion("0.1")]
[assembly: AssemblyTitle("BBFarts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
namespace BBFarts;

[HarmonyPatch]
public static class AssetHelper
{
	public static readonly List<GameObject> Prefabs = new List<GameObject>();

	private static readonly List<RecipeStub> RecipeStubs = new List<RecipeStub>();

	private static readonly List<KeyValuePair<int, StatusEffect>> StatusEffects = new List<KeyValuePair<int, StatusEffect>>();

	public static AssetBundle LoadAssetBundle(string name)
	{
		Assembly callingAssembly = Assembly.GetCallingAssembly();
		return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + name));
	}

	public static void RegisterPrefab(GameObject prefab)
	{
		Prefabs.Add(prefab);
		Object.DontDestroyOnLoad((Object)(object)prefab);
	}

	public static void RegisterRecipe(RecipeStub rs)
	{
		RecipeStubs.Add(rs);
	}

	public static void RegisterStatusEffect<T>(string name) where T : StatusEffect
	{
		StatusEffects.Add(new KeyValuePair<int, StatusEffect>(StringExtensionMethods.GetStableHashCode(name), (StatusEffect)(object)ScriptableObject.CreateInstance<T>()));
	}

	public static RecipeStub GetRecipeStub(string itemName)
	{
		return RecipeStubs.Find((RecipeStub r) => ((Object)r.Item).name == itemName);
	}

	public static Recipe BuildRecipe(RecipeStub rs, ObjectDB odb)
	{
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Expected O, but got Unknown
		Recipe val = ScriptableObject.CreateInstance<Recipe>();
		val.m_item = rs.Item;
		GameObject itemPrefab = odb.GetItemPrefab(rs.CraftingStation);
		val.m_craftingStation = ((itemPrefab != null) ? itemPrefab.GetComponentInChildren<CraftingStation>(true) : null);
		if ((Object)(object)val.m_craftingStation == (Object)null)
		{
			ZNetScene instance = ZNetScene.instance;
			object craftingStation;
			if (instance == null)
			{
				craftingStation = null;
			}
			else
			{
				GameObject prefab = instance.GetPrefab(rs.CraftingStation);
				craftingStation = ((prefab != null) ? prefab.GetComponentInChildren<CraftingStation>(true) : null);
			}
			val.m_craftingStation = (CraftingStation)craftingStation;
			if ((Object)(object)val.m_craftingStation == (Object)null)
			{
				Plugin.Log.LogInfo((object)("BuildRecipe couldn't find crafting station " + rs.CraftingStation + " for " + rs.Name));
				return null;
			}
		}
		if (!string.IsNullOrWhiteSpace(rs.RepairStation))
		{
			GameObject itemPrefab2 = odb.GetItemPrefab(rs.RepairStation);
			val.m_repairStation = ((itemPrefab2 != null) ? itemPrefab2.GetComponentInChildren<CraftingStation>(true) : null);
			if ((Object)(object)val.m_repairStation == (Object)null)
			{
				ZNetScene instance2 = ZNetScene.instance;
				object repairStation;
				if (instance2 == null)
				{
					repairStation = null;
				}
				else
				{
					GameObject prefab2 = instance2.GetPrefab(rs.RepairStation);
					repairStation = ((prefab2 != null) ? prefab2.GetComponentInChildren<CraftingStation>(true) : null);
				}
				val.m_repairStation = (CraftingStation)repairStation;
				if ((Object)(object)val.m_repairStation == (Object)null)
				{
					Plugin.Log.LogInfo((object)("BuildRecipe couldn't find declared repair station " + rs.RepairStation + " for " + rs.Name));
					return null;
				}
			}
			if ((Object)(object)val.m_repairStation == (Object)null)
			{
				return null;
			}
		}
		val.m_minStationLevel = Mathf.Max(1, rs.MinStationLevel);
		List<Requirement> list = new List<Requirement>();
		foreach (RecipeStub.RequirementStub requirement in rs.Requirements)
		{
			GameObject itemPrefab3 = odb.GetItemPrefab(requirement.Component);
			ItemDrop val2 = ((itemPrefab3 != null) ? itemPrefab3.GetComponentInChildren<ItemDrop>(true) : null);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Plugin.Log.LogInfo((object)("BuildRecipe couldn't get requirement component " + requirement.Component + " for " + rs.Name));
				return null;
			}
			list.Add(new Requirement
			{
				m_resItem = val2,
				m_amount = requirement.Amount,
				m_amountPerLevel = requirement.AmountPerLevel,
				m_recover = requirement.Recoverable
			});
		}
		val.m_resources = list.ToArray();
		return val;
	}

	private static void PopulateObjectDB(ObjectDB odb)
	{
		if (Prefabs.Count > 0 && !Object.op_Implicit((Object)(object)odb.m_items.Find((GameObject p) => ((Object)p).name == ((Object)Prefabs[0]).name)))
		{
			foreach (GameObject prefab in Prefabs)
			{
				if (Object.op_Implicit((Object)(object)prefab.GetComponentInChildren<ItemDrop>(true)))
				{
					odb.m_items.Add(prefab);
				}
			}
			odb.UpdateRegisters();
		}
		if (RecipeStubs.Count > 0 && !Object.op_Implicit((Object)(object)odb.GetRecipe(RecipeStubs[0].Item.m_itemData)))
		{
			foreach (RecipeStub recipeStub in RecipeStubs)
			{
				Recipe val = BuildRecipe(recipeStub, odb);
				if (Object.op_Implicit((Object)(object)val))
				{
					odb.m_recipes.Add(val);
					Plugin.Log.LogInfo((object)("Added recipe " + ((Object)val).name));
				}
			}
		}
		if (StatusEffects.Count <= 0 || Object.op_Implicit((Object)(object)odb.GetStatusEffect(StatusEffects[0].Key)))
		{
			return;
		}
		foreach (KeyValuePair<int, StatusEffect> statusEffect in StatusEffects)
		{
			odb.m_StatusEffects.Add(statusEffect.Value);
		}
	}

	public static void UpdateRecipes()
	{
		foreach (RecipeStub recipeStub in RecipeStubs)
		{
			Recipe r = BuildRecipe(recipeStub, ObjectDB.instance);
			if (Object.op_Implicit((Object)(object)r))
			{
				Recipe val = ObjectDB.instance.m_recipes.Find((Recipe rt) => ((Object)rt).name == ((Object)r).name);
				if (Object.op_Implicit((Object)(object)val))
				{
					ObjectDB.instance.m_recipes.Remove(val);
				}
				ObjectDB.instance.m_recipes.Add(r);
				Plugin.Log.LogInfo((object)("Updated recipe " + ((Object)r).name));
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static void AwakePostfix(ObjectDB __instance)
	{
		PopulateObjectDB(__instance);
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	[HarmonyPostfix]
	public static void CopyOtherDBPostfix(ObjectDB __instance, ObjectDB other)
	{
		PopulateObjectDB(__instance);
	}

	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	[HarmonyPostfix]
	public static void AwakePostfix(ZNetScene __instance)
	{
		if (Prefabs.Count == 0)
		{
			return;
		}
		foreach (GameObject prefab in Prefabs)
		{
			__instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = prefab;
		}
	}
}
[HarmonyPatch(typeof(Character))]
public class CharacterPatches
{
	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	public static void AwakePostfix(Character __instance)
	{
		if (!Plugin.OnlyPlayers.Value || __instance is Player)
		{
			((Component)__instance).gameObject.AddComponent<Farter>();
		}
	}
}
public class Farter : MonoBehaviour
{
	private static string[] BoneRoots = new string[3] { "Hip", "Hips", "l_hip" };

	private AudioSource AS;

	private Character Char;

	private bool Crouching;

	private float TimeSinceLastFart;

	private float FartTimerDelay;

	private float randomTimerMultiplier = 10f;

	private ParticleSystem PS;

	private float SizeScalar = 1f;

	public void Awake()
	{
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		Char = ((Component)this).GetComponentInChildren<Character>();
		AS = ((Component)this).gameObject.AddComponent<AudioSource>();
		AS.playOnAwake = false;
		AS.maxDistance = Plugin.FartNoiseRange.Value;
		AS.rolloffMode = (AudioRolloffMode)1;
		AS.spatialBlend = 1f;
		AS.outputAudioMixerGroup = AudioMan.m_instance.m_ambientMixer;
		Transform val = null;
		if (Object.op_Implicit((Object)(object)Char) && !((Object)((Component)this).gameObject).name.StartsWith("Skeleton") && !((Object)((Component)this).gameObject).name.StartsWith("Blob"))
		{
			string bone = null;
			SkinnedMeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				if (((Object)((Component)this).gameObject).name.StartsWith("Boar") || ((Object)((Component)this).gameObject).name.StartsWith("Wolf"))
				{
					bone = "Pelvis";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Deer"))
				{
					bone = "L Thigh";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Dragon"))
				{
					bone = "Hips.001";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Draugr"))
				{
					bone = "LeftHip";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Eikthyr"))
				{
					bone = "Bone.009";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Hatchling"))
				{
					bone = "Spine1";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Surtling"))
				{
					bone = "mixamorig:Hips";
				}
				else if (((Object)((Component)this).gameObject).name.StartsWith("Troll"))
				{
					bone = "Spine0";
				}
				if (bone != null)
				{
					val = ((IEnumerable<Transform>)componentInChildren.bones).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == bone));
					if (!Object.op_Implicit((Object)(object)val))
					{
						val = ((Component)this).transform;
					}
				}
				else
				{
					val = ((IEnumerable<Transform>)componentInChildren.bones).FirstOrDefault((Func<Transform, bool>)((Transform t) => BoneRoots.Contains(((Object)t).name)));
				}
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			val = ((Component)this).transform;
		}
		PS = Object.Instantiate<GameObject>(Plugin.FartSystemPrefab, val).GetComponent<ParticleSystem>();
		CapsuleCollider componentInChildren2 = ((Component)this).gameObject.GetComponentInChildren<CapsuleCollider>();
		if (Object.op_Implicit((Object)(object)componentInChildren2))
		{
			double num = componentInChildren2.radius;
			double num2 = componentInChildren2.height;
			double num3 = 4.1887902047863905 * Math.Pow(num, 3.0);
			double num4 = 2.0 * num;
			if (num2 - num4 > 0.0)
			{
				num3 += Math.PI * Math.Pow(num, 2.0);
			}
			SizeScalar = (float)Math.Sqrt(num3);
		}
		else
		{
			SphereCollider componentInChildren3 = ((Component)this).gameObject.GetComponentInChildren<SphereCollider>();
			if (Object.op_Implicit((Object)(object)componentInChildren3))
			{
				SizeScalar = (float)Math.Sqrt(4.1887902047863905 * Math.Pow(componentInChildren3.radius, 3.0));
			}
		}
		if ((double)SizeScalar != 1.0)
		{
			MainModule main = PS.main;
			((MainModule)(ref main)).startSpeedMultiplier = SizeScalar;
			((MainModule)(ref main)).startSizeMultiplier = SizeScalar;
			VelocityOverLifetimeModule velocityOverLifetime = PS.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).speedModifierMultiplier = SizeScalar;
		}
	}

	private void Fart()
	{
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		List<AudioClip> list = ((!Object.op_Implicit((Object)(object)Char) || !Char.InWater()) ? Plugin.DryFarts : Plugin.WetFarts);
		int index = ((!Object.op_Implicit((Object)(object)Char) || !Char.IsPlayer() || !Plugin.BunsOfSteel.Value) ? Mathf.Min(list.Count - 1, (int)((double)Random.value * (double)list.Count)) : Mathf.Min(list.Count - 1, (int)((double)TimeSinceLastFart / (double)Plugin.MaxFartTime.Value * (double)list.Count)));
		AudioClip val = list[index];
		AS.pitch = (float)(0.75 + (double)Random.value * 0.5) / SizeScalar;
		AS.PlayOneShot(val, Mathf.Clamp(TimeSinceLastFart / Plugin.MaxFartTime.Value, 0.25f, 1f));
		FartTimerDelay = val.length + 1f + Random.value;
		TimeSinceLastFart = 0f;
		((Component)PS).transform.rotation = Quaternion.LookRotation(-((Component)this).transform.forward, ((Component)this).transform.up);
		MainModule main = PS.main;
		((MainModule)(ref main)).duration = val.length;
		PS.Play();
	}

	public void Update()
	{
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
		{
			return;
		}
		if (!Object.op_Implicit((Object)(object)Char) || !Char.IsPlayer() || !Plugin.BunsOfSteel.Value)
		{
			if ((double)FartTimerDelay <= 0.0)
			{
				TimeSinceLastFart += Time.deltaTime;
				if ((double)TimeSinceLastFart >= (double)(Random.value * Plugin.MaxFartTime.Value * randomTimerMultiplier))
				{
					Fart();
				}
				else
				{
					FartTimerDelay += 0.5f + Random.value;
				}
			}
			else
			{
				FartTimerDelay -= Time.deltaTime;
				if ((double)TimeSinceLastFart > 0.0)
				{
					TimeSinceLastFart += Time.deltaTime;
				}
			}
		}
		else
		{
			TimeSinceLastFart += Time.deltaTime;
		}
		if (Object.op_Implicit((Object)(object)Char) && Char.IsCrouching())
		{
			if (!Crouching)
			{
				Crouching = true;
				Fart();
			}
		}
		else if (Crouching)
		{
			Crouching = false;
		}
		if (Object.op_Implicit((Object)(object)PS))
		{
			ForceOverLifetimeModule forceOverLifetime = PS.forceOverLifetime;
			if (Object.op_Implicit((Object)(object)Char) && (Char.InInterior() || (Char.IsPlayer() && ((Player)/*isinst with value type is only supported in some contexts*/).InShelter())))
			{
				((ForceOverLifetimeModule)(ref forceOverLifetime)).x = new MinMaxCurve(0f);
				((ForceOverLifetimeModule)(ref forceOverLifetime)).z = new MinMaxCurve(0f);
			}
			else
			{
				Vector3 windForce = EnvMan.instance.GetWindForce();
				((ForceOverLifetimeModule)(ref forceOverLifetime)).x = new MinMaxCurve(windForce.x * 3f);
				((ForceOverLifetimeModule)(ref forceOverLifetime)).z = new MinMaxCurve(windForce.z * 3f);
			}
		}
	}
}
[BepInPlugin("BBFarts", "BBFarts", "0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string Version = "0.1";

	public const string ModName = "BBFarts";

	private Harmony _Harmony;

	public static ManualLogSource Log;

	private AssetBundle AB;

	public static List<AudioClip> DryFarts = new List<AudioClip>();

	public static List<AudioClip> WetFarts = new List<AudioClip>();

	public static GameObject FartSystemPrefab;

	public static ConfigEntry<float> MaxFartTime;

	public static ConfigEntry<float> FartNoiseRange;

	public static ConfigEntry<bool> BunsOfSteel;

	public static ConfigEntry<bool> OnlyPlayers;

	private void Awake()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		Log = new ManualLogSource((string)null);
		AB = AssetHelper.LoadAssetBundle("fartheim");
		AudioClip[] array = AB.LoadAllAssets<AudioClip>();
		foreach (AudioClip val in array)
		{
			if (((Object)val).name.Contains("water"))
			{
				WetFarts.Add(val);
			}
			else
			{
				DryFarts.Add(val);
			}
		}
		if (DryFarts.Count > 0)
		{
			DryFarts = DryFarts.OrderBy((AudioClip f) => f.length).ToList();
		}
		if (WetFarts.Count > 0)
		{
			WetFarts = WetFarts.OrderBy((AudioClip f) => f.length).ToList();
		}
		FartSystemPrefab = AB.LoadAsset<GameObject>("Assets\\FartSystem.prefab");
		AssetHelper.RegisterPrefab(FartSystemPrefab);
		MaxFartTime = ((BaseUnityPlugin)this).Config.Bind<float>("Farts", "Maximum Fart Time", 30f, (ConfigDescription)null);
		FartNoiseRange = ((BaseUnityPlugin)this).Config.Bind<float>("Farts", "Fart Noise Range", 32f, (ConfigDescription)null);
		BunsOfSteel = ((BaseUnityPlugin)this).Config.Bind<bool>("Farts", "Players Only Fart When Crouching", true, (ConfigDescription)null);
		OnlyPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Farts", "Only Players Fart (unrealistic)", false, (ConfigDescription)null);
		_Harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
	}

	private void OnDestroy()
	{
		if (_Harmony != null)
		{
			_Harmony.UnpatchSelf();
		}
	}
}
public class RecipeStub
{
	public class RequirementStub
	{
		public string Component;

		public int Amount;

		public int AmountPerLevel;

		public bool Recoverable = true;

		private RequirementStub()
		{
		}

		public static RequirementStub Parse(string def)
		{
			string[] array = def.Split(new char[1] { ':' });
			if (array.Length < 2)
			{
				return null;
			}
			RequirementStub requirementStub = new RequirementStub();
			requirementStub.Component = array[0];
			int.TryParse(array[1], out requirementStub.Amount);
			if (array.Length > 2)
			{
				int.TryParse(array[2], out requirementStub.AmountPerLevel);
			}
			return requirementStub;
		}
	}

	public ItemDrop Item;

	public string CraftingStation;

	public string RepairStation;

	public int MinStationLevel = 1;

	public List<RequirementStub> Requirements = new List<RequirementStub>();

	public string Name => "Recipe" + ((Object)Item).name;
}