Decompiled source of AchievementHelper v1.0.0

plugins\AchievementHelper\AchievementHelper.dll

Decompiled 5 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using AchievementHelper.Patches;
using AchievementHelper.Services;
using AchievementHelper.UI;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AchievementHelper")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+22510bad584f34ae6da39be2ee21be1aeb2228e1")]
[assembly: AssemblyProduct("AchievementHelper")]
[assembly: AssemblyTitle("AchievementHelper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AchievementHelper
{
	[BepInPlugin("com.bokeher.achievementhelper", "AchievementHelper", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private sealed class ConfigurationManagerAttributes
		{
			public bool? Browsable;

			public int? Order;
		}

		public const string ModGuid = "com.bokeher.achievementhelper";

		public const string ModName = "AchievementHelper";

		public const string ModVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static ConfigEntry<bool> ModEnabled;

		internal static ConfigEntry<ProgressScope> ProgressScopeConfig;

		internal static ConfigEntry<bool> CountCheatedCharacters;

		internal static ConfigEntry<bool> SyncSteamUnlocks;

		internal static ConfigEntry<bool> OnlyHideSpoilerAchievements;

		internal static ConfigEntry<bool> ShowCompletionPercentages;

		internal static ConfigEntry<bool> GroupDetailsByBiome;

		internal static ConfigEntry<bool> ShowHideCompletedFilter;

		internal static ConfigEntry<bool> ShowNotCraftedTooltip;

		internal static ConfigEntry<bool> ShowNotCookedTooltip;

		internal static ConfigEntry<bool> ShowNotEatenTooltip;

		internal static ConfigEntry<bool> ShowRawRoastedCookedTooltip;

		internal static ConfigEntry<bool> ShowRawRoastedEatenTooltip;

		internal static ConfigEntry<bool> ShowMissingTrophyTooltip;

		internal static ConfigEntry<bool> ShowUncaughtFishTooltip;

		internal static ConfigEntry<bool> ShowInventoryItemBadges;

		internal static ConfigEntry<BadgeCorner> InventoryBadgeCorner;

		internal static ConfigEntry<bool> ShowNotCraftedBadges;

		internal static ConfigEntry<bool> ShowNotCookedBadges;

		internal static ConfigEntry<bool> ShowUnbuiltPieceBadges;

		internal static ConfigEntry<bool> EnableNotCraftedFilter;

		internal static ConfigEntry<bool> EnableNotCookedFilter;

		internal static ConfigEntry<bool> ResetCraftingFilterOnClose;

		internal static ConfigEntry<bool> ShowUnbuiltPieceDescription;

		internal static ConfigEntry<bool> EnableNotBuiltFilter;

		internal static ConfigEntry<bool> ResetBuildFilterOnClose;

		internal static ConfigEntry<bool> ShowUndefeatedEnemyIcon;

		internal static ConfigEntry<bool> ShowMissingTrophyIcon;

		internal static ConfigEntry<bool> MasterRevealAll;

		internal static ConfigEntry<string> RevealedAchievementIds;

		private Harmony? _harmony;

		private void Awake()
		{
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "Enable or disable the entire mod.");
			ProgressScopeConfig = ((BaseUnityPlugin)this).Config.Bind<ProgressScope>("2 - Progression", "Progress Mode", ProgressScope.Character, "Character: track progress for the current character only. Global: aggregate progress across all characters in memory (read-only; never modifies save files).");
			CountCheatedCharacters = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Progression", "Include Cheated Characters In Global Mode", false, "Include characters that have used cheats when calculating Global progress.");
			SyncSteamUnlocks = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Progression", "Import Steam Unlocks", false, "Also show achievements already unlocked on your Steam account as completed, even if the current character has not earned them yet. When off, only in-game progress is used.");
			OnlyHideSpoilerAchievements = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Achievements Tab", "Reveal Non-Spoiler Achievements", true, "Show non-spoiler concealed achievements while keeping bosses and story secrets hidden. When off, uses default game hiding for all concealed achievements.");
			ShowCompletionPercentages = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Achievements Tab", "Show Progress Percentage", true, "Show completion percentage (%) centered on locked achievement tiles.");
			GroupDetailsByBiome = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Achievements Tab", "Group Details By Biome", true, "Group supported achievement detail lists (such as enemies and craftable items) by biome progression.");
			ShowHideCompletedFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Achievements Tab", "Show Hide Completed Button", true, "Show the 'Hide Completed' toggle button in multi-entry achievement detail windows.");
			ShowNotCraftedTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Not Crafted", true, "Show 'Not crafted for achievement' on craftable items.");
			ShowNotCookedTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Not Cooked", true, "Show 'Not cooked for achievement' on cookable dishes.");
			ShowNotEatenTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Not Eaten", true, "Show 'Not eaten for achievement' on edible food.");
			ShowRawRoastedCookedTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Raw Item Not Cooked", true, "Show 'Not cooked for achievement' on raw cookable items.");
			ShowRawRoastedEatenTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Raw Item Not Eaten", true, "Show 'Cooked variant not eaten for achievement' on raw cookable items.");
			ShowMissingTrophyTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Missing Trophy", true, "Show 'Not collected for achievement' on uncollected trophies. Achievement is counted when a trophy is added to your inventory.");
			ShowUncaughtFishTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Item Tooltips", "Show Uncaught Fish", true, "Show 'Not caught for achievement' on uncaught fish. Achievement is counted only when caught with a fishing rod (not from chests or ground pickups).");
			ShowInventoryItemBadges = ((BaseUnityPlugin)this).Config.Bind<bool>("5 - Badges", "Show Inventory Badge", true, new ConfigDescription("Show the corner '!' badge on items in your inventory and chests that are missing for achievements (crafting, cooking, eating, trophies, or fish).", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 50
				}
			}));
			InventoryBadgeCorner = ((BaseUnityPlugin)this).Config.Bind<BadgeCorner>("5 - Badges", "Inventory Badge Position", BadgeCorner.TopLeft, new ConfigDescription("Corner of the inventory slot where the '!' badge is displayed.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 40
				}
			}));
			ShowNotCraftedBadges = ((BaseUnityPlugin)this).Config.Bind<bool>("5 - Badges", "Show Crafting Recipe Badge", true, new ConfigDescription("Show the '!' badge on uncrafted achievement recipes at crafting stations.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 30
				}
			}));
			ShowNotCookedBadges = ((BaseUnityPlugin)this).Config.Bind<bool>("5 - Badges", "Show Cooking Recipe Badge", true, new ConfigDescription("Show the '!' badge on uncooked achievement recipes at cooking stations.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 20
				}
			}));
			ShowUnbuiltPieceBadges = ((BaseUnityPlugin)this).Config.Bind<bool>("5 - Badges", "Show Building Piece Badge", true, new ConfigDescription("Show the corner '!' badge on unbuilt achievement pieces in the build menu.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10
				}
			}));
			EnableNotCraftedFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("6 - Crafting & Cooking", "Show Not Crafted Filter", true, "Show the 'Not Crafted (N)' toggle button at crafting stations.");
			EnableNotCookedFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("6 - Crafting & Cooking", "Show Not Cooked Filter", true, "Show the 'Not Cooked (N)' toggle button at cooking stations.");
			ResetCraftingFilterOnClose = ((BaseUnityPlugin)this).Config.Bind<bool>("6 - Crafting & Cooking", "Reset Filter On Inventory Close", true, "Turn off the crafting/cooking filter automatically when closing the inventory.");
			ShowUnbuiltPieceDescription = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Building", "Show Unbuilt Description", true, "Show 'Not built for achievement' under the selected piece description.");
			EnableNotBuiltFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Building", "Show Not Built Filter", true, "Show the 'Not Built (N)' toggle button in the build menu.");
			ResetBuildFilterOnClose = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Building", "Reset Filter On Menu Close", false, "Turn off the Not Built filter every time the build menu closes. When off, it stays active until you unequip the tool.");
			ShowUndefeatedEnemyIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("8 - Enemies", "Show Undefeated Icon", true, "Show crossed-swords icon next to the health bar of undefeated achievement enemies.");
			ShowMissingTrophyIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("8 - Enemies", "Show Missing Trophy Icon", true, "Show trophy cup icon next to the health bar of enemies whose trophy has not been collected.");
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				Browsable = false
			};
			MasterRevealAll = ((BaseUnityPlugin)this).Config.Bind<bool>("9 - Saved State", "Reveal All Active", false, new ConfigDescription("Managed automatically by the in-game 'Reveal All / Hide All' button.", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
			RevealedAchievementIds = ((BaseUnityPlugin)this).Config.Bind<string>("9 - Saved State", "Revealed Achievement IDs", "", new ConfigDescription("Managed automatically by in-game 'Reveal / Hide' buttons and clicking '???' rows.", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
			ModEnabled.SettingChanged += delegate
			{
				if (!ModEnabled.Value)
				{
					InventoryGuiCraftingFilterPatches.ResetFilter();
					BuildingFilterState.ResetFilterPreservingSelection();
				}
				RefreshOpenAchievementsPanel();
				AchievementsGuiPatches.RefreshOpenDetailsIfVisible();
				InventoryGuiCraftingFilterPatches.RefreshCraftingPanelIfOpen();
				InventoryGridBadgePatches.RefreshOpenInventoryGrids();
				BuildUiFilterPatches.RefreshOpenBuildUi();
			};
			ProgressScopeConfig.SettingChanged += delegate
			{
				AchievementService.RefreshProgressScope(recheckUnlocks: true);
			};
			CountCheatedCharacters.SettingChanged += delegate
			{
				AchievementService.RefreshProgressScope(recheckUnlocks: true);
			};
			SyncSteamUnlocks.SettingChanged += delegate
			{
				AchievementService.RefreshProgressScope(recheckUnlocks: true);
			};
			OnlyHideSpoilerAchievements.SettingChanged += delegate
			{
				RefreshOpenAchievementsPanel();
			};
			ShowCompletionPercentages.SettingChanged += delegate
			{
				RefreshOpenAchievementsPanel();
			};
			GroupDetailsByBiome.SettingChanged += delegate
			{
				AchievementsGuiPatches.RefreshOpenDetailsIfVisible();
			};
			ShowHideCompletedFilter.SettingChanged += delegate
			{
				AchievementsGuiPatches.RefreshOpenDetailsIfVisible();
			};
			ShowInventoryItemBadges.SettingChanged += delegate
			{
				InventoryGridBadgePatches.RefreshOpenInventoryGrids();
			};
			InventoryBadgeCorner.SettingChanged += delegate
			{
				InventoryGridBadgePatches.RefreshOpenInventoryGrids();
			};
			ShowNotCraftedBadges.SettingChanged += delegate
			{
				InventoryGuiCraftingFilterPatches.RefreshCraftingPanelIfOpen();
			};
			ShowNotCookedBadges.SettingChanged += delegate
			{
				InventoryGuiCraftingFilterPatches.RefreshCraftingPanelIfOpen();
			};
			ShowUnbuiltPieceBadges.SettingChanged += delegate
			{
				BuildUiFilterPatches.RefreshOpenBuildUi();
			};
			EnableNotCraftedFilter.SettingChanged += delegate
			{
				if (!EnableNotCraftedFilter.Value)
				{
					InventoryGuiCraftingFilterPatches.ResetFilter();
				}
				InventoryGuiCraftingFilterPatches.RefreshCraftingPanelIfOpen();
			};
			EnableNotCookedFilter.SettingChanged += delegate
			{
				if (!EnableNotCookedFilter.Value)
				{
					InventoryGuiCraftingFilterPatches.ResetFilter();
				}
				InventoryGuiCraftingFilterPatches.RefreshCraftingPanelIfOpen();
			};
			ShowUnbuiltPieceDescription.SettingChanged += delegate
			{
				BuildUiFilterPatches.RefreshOpenBuildUi();
			};
			EnableNotBuiltFilter.SettingChanged += delegate
			{
				if (!EnableNotBuiltFilter.Value)
				{
					BuildingFilterState.ResetFilterPreservingSelection();
				}
				BuildUiFilterPatches.RefreshOpenBuildUi();
			};
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.bokeher.achievementhelper");
			Log.LogInfo((object)"AchievementHelper v1.0.0 loaded.");
		}

		private static void RefreshOpenAchievementsPanel()
		{
			if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_achievementsPanel != (Object)null && ((Component)InventoryGui.instance.m_achievementsPanel).gameObject.activeInHierarchy)
			{
				InventoryGui.instance.UpdateAchievementsList();
			}
		}

		private void OnDestroy()
		{
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace AchievementHelper.UI
{
	internal sealed class FilterToggleButton
	{
		private static readonly Color ActiveTextColor = new Color(1f, 0.88f, 0.42f, 1f);

		private static readonly Color InactiveTextColor = new Color(0.9f, 0.9f, 0.9f, 1f);

		private static readonly Color ActiveButtonColor = new Color(1f, 0.78f, 0.32f, 1f);

		private static readonly Color ActiveButtonHoverColor = new Color(1f, 0.86f, 0.46f, 1f);

		private readonly Button _button;

		private readonly TMP_Text? _label;

		private readonly ColorBlock _defaultColors;

		private readonly Color _defaultGraphicColor;

		private string? _lastText;

		private bool? _lastActive;

		public bool IsAlive => (Object)(object)_button != (Object)null;

		private FilterToggleButton(Button button)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			_button = button;
			_label = ((Component)button).GetComponentInChildren<TMP_Text>(true);
			_defaultColors = ((Selectable)button).colors;
			_defaultGraphicColor = (((Object)(object)((Selectable)button).targetGraphic != (Object)null) ? ((Selectable)button).targetGraphic.color : Color.white);
		}

		public static FilterToggleButton? CreateOrAttach(Transform parent, string name, Button? template, Vector2 anchor, Vector2 pivot, Vector2 anchoredPosition, Vector2 size, Action onClick)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				Button component = ((Component)val).GetComponent<Button>();
				if ((Object)(object)component != (Object)null)
				{
					WireClick(component, onClick);
					return new FilterToggleButton(component);
				}
			}
			if ((Object)(object)template == (Object)null)
			{
				return null;
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)template).gameObject, parent);
			((Object)val2).name = name;
			val2.SetActive(true);
			val2.transform.SetAsLastSibling();
			for (int num = val2.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = val2.transform.GetChild(num);
				if ((Object)(object)((Component)child).GetComponent<TMP_Text>() == (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
				}
			}
			(val2.GetComponent<LayoutElement>() ?? val2.AddComponent<LayoutElement>()).ignoreLayout = true;
			Transform transform = val2.transform;
			RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if (val3 != null)
			{
				val3.anchorMin = anchor;
				val3.anchorMax = anchor;
				val3.pivot = pivot;
				val3.sizeDelta = size;
				val3.anchoredPosition = anchoredPosition;
			}
			Button component2 = val2.GetComponent<Button>();
			((Selectable)component2).interactable = true;
			WireClick(component2, onClick);
			TMP_Text componentInChildren = val2.GetComponentInChildren<TMP_Text>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Transform transform2 = componentInChildren.transform;
				RectTransform val4 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
				if (val4 != null)
				{
					val4.anchorMin = Vector2.zero;
					val4.anchorMax = Vector2.one;
					val4.offsetMin = new Vector2(6f, 2f);
					val4.offsetMax = new Vector2(-6f, -2f);
				}
				componentInChildren.enableAutoSizing = false;
				componentInChildren.fontSize = 15f;
				componentInChildren.alignment = (TextAlignmentOptions)514;
				componentInChildren.textWrappingMode = (TextWrappingModes)0;
				componentInChildren.overflowMode = (TextOverflowModes)0;
			}
			return new FilterToggleButton(component2);
		}

		public void SetVisible(bool visible)
		{
			if (!((Object)(object)_button == (Object)null))
			{
				if (((Component)_button).gameObject.activeSelf != visible)
				{
					((Component)_button).gameObject.SetActive(visible);
				}
				if (visible)
				{
					((Component)_button).transform.SetAsLastSibling();
				}
			}
		}

		public void SetState(string text, bool active)
		{
			if ((Object)(object)_button == (Object)null)
			{
				return;
			}
			if (_lastText != text)
			{
				_lastText = text;
				if ((Object)(object)_label != (Object)null)
				{
					_label.text = text;
				}
			}
			if (_lastActive != active)
			{
				_lastActive = active;
				ApplyVisualState(active);
			}
		}

		private void ApplyVisualState(bool active)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_label != (Object)null)
			{
				((Graphic)_label).color = (active ? ActiveTextColor : InactiveTextColor);
			}
			if (active)
			{
				ColorBlock defaultColors = _defaultColors;
				((ColorBlock)(ref defaultColors)).normalColor = ActiveButtonColor;
				((ColorBlock)(ref defaultColors)).highlightedColor = ActiveButtonHoverColor;
				((ColorBlock)(ref defaultColors)).selectedColor = ActiveButtonColor;
				((Selectable)_button).colors = defaultColors;
				if ((Object)(object)((Selectable)_button).targetGraphic != (Object)null && (int)((Selectable)_button).transition != 1)
				{
					((Selectable)_button).targetGraphic.color = ActiveButtonColor;
				}
			}
			else
			{
				((Selectable)_button).colors = _defaultColors;
				if ((Object)(object)((Selectable)_button).targetGraphic != (Object)null && (int)((Selectable)_button).transition != 1)
				{
					((Selectable)_button).targetGraphic.color = _defaultGraphicColor;
				}
			}
		}

		private static void WireClick(Button button, Action onClick)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			button.onClick = new ButtonClickedEvent();
			((UnityEvent)button.onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
		}
	}
	internal static class IconLoader
	{
		private static readonly Dictionary<string, Sprite?> Cache = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		private static readonly MethodInfo? LoadImageMethod = AccessTools.Method("UnityEngine.ImageConversion:LoadImage", new Type[2]
		{
			typeof(Texture2D),
			typeof(byte[])
		}, (Type[])null);

		public static Sprite? UndefeatedSprite => GetSprite("crossed-swords.png");

		public static Sprite? TrophySprite => GetSprite("trophy-cup.png");

		private static Sprite? GetSprite(string fileName)
		{
			if (Cache.TryGetValue(fileName, out Sprite value))
			{
				return value;
			}
			Sprite val = LoadEmbeddedSprite(fileName);
			Cache[fileName] = val;
			return val;
		}

		private static Sprite? LoadEmbeddedSprite(string fileName)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string text = null;
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				foreach (string text2 in manifestResourceNames)
				{
					if (text2.EndsWith(fileName, StringComparison.OrdinalIgnoreCase))
					{
						text = text2;
						break;
					}
				}
				if (text == null)
				{
					Plugin.Log.LogWarning((object)("Embedded icon resource not found: " + fileName));
					return null;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				int num;
				for (int j = 0; j < array.Length; j += num)
				{
					num = stream.Read(array, j, array.Length - j);
					if (num <= 0)
					{
						break;
					}
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
				if (!(LoadImageMethod != null) || !(LoadImageMethod.Invoke(null, new object[2] { val, array }) is int num2) || num2 == 0)
				{
					Object.Destroy((Object)(object)val);
					Plugin.Log.LogWarning((object)("Failed to decode PNG icon: " + fileName));
					return null;
				}
				((Texture)val).filterMode = (FilterMode)2;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).mipMapBias = -0.35f;
				((Texture)val).anisoLevel = 4;
				val.Apply(true, true);
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Error loading embedded icon " + fileName + ": " + ex.Message));
				return null;
			}
		}
	}
}
namespace AchievementHelper.Services
{
	public enum AchievementDisplayMode
	{
		All,
		Revealable,
		Simple,
		Hidden
	}
	public static class AchievementService
	{
		private static readonly Dictionary<string, AchievementDisplayMode> ModeById = new Dictionary<string, AchievementDisplayMode>(StringComparer.OrdinalIgnoreCase)
		{
			["Boss1Eikthyr"] = AchievementDisplayMode.Hidden,
			["Boss2Elder"] = AchievementDisplayMode.Hidden,
			["Boss3Bonemass"] = AchievementDisplayMode.Hidden,
			["Boss4Moder"] = AchievementDisplayMode.Hidden,
			["Boss5Yagluth"] = AchievementDisplayMode.Hidden,
			["Boss6Queen"] = AchievementDisplayMode.Hidden,
			["Boss7Fader"] = AchievementDisplayMode.Hidden,
			["Boss8FrozenKing"] = AchievementDisplayMode.Hidden,
			["AllMiniBosses"] = AchievementDisplayMode.Revealable,
			["AllBosses"] = AchievementDisplayMode.Revealable,
			["AllBossesNormal"] = AchievementDisplayMode.Revealable,
			["AllBossesHard"] = AchievementDisplayMode.Revealable,
			["SoloBoss"] = AchievementDisplayMode.Simple,
			["MultiplayerBoss"] = AchievementDisplayMode.Simple,
			["KillAllCreatures"] = AchievementDisplayMode.Revealable,
			["KillAllCreaturesHard"] = AchievementDisplayMode.Revealable,
			["AllWeaponCraft"] = AchievementDisplayMode.Revealable,
			["AllItemCraft"] = AchievementDisplayMode.Revealable,
			["AllFoodCooked"] = AchievementDisplayMode.Revealable,
			["AllFoodEaten"] = AchievementDisplayMode.Revealable,
			["AllBuildPieces"] = AchievementDisplayMode.Revealable,
			["FindAllTrophies"] = AchievementDisplayMode.Revealable,
			["BuildDyrnwyn"] = AchievementDisplayMode.Hidden,
			["GrindCook"] = AchievementDisplayMode.All,
			["GrindEat"] = AchievementDisplayMode.All,
			["GrindBuild"] = AchievementDisplayMode.All,
			["BuildHouse"] = AchievementDisplayMode.All,
			["BuildVillage"] = AchievementDisplayMode.All,
			["BuildHigh"] = AchievementDisplayMode.All,
			["BuildHighWorld"] = AchievementDisplayMode.All,
			["GrindComfort"] = AchievementDisplayMode.All,
			["GrindTrees"] = AchievementDisplayMode.All,
			["GrindHarvest"] = AchievementDisplayMode.All,
			["GrindForager"] = AchievementDisplayMode.All,
			["GrindHoney"] = AchievementDisplayMode.All,
			["GrindFish"] = AchievementDisplayMode.Revealable,
			["BigFish"] = AchievementDisplayMode.Simple,
			["Arrived"] = AchievementDisplayMode.Simple,
			["GrindDays"] = AchievementDisplayMode.All,
			["ExploreNSEW"] = AchievementDisplayMode.All,
			["ExploreNSEWNoMap"] = AchievementDisplayMode.All,
			["GrindSail"] = AchievementDisplayMode.All,
			["GrindSailHelm"] = AchievementDisplayMode.All,
			["GrindTreasure"] = AchievementDisplayMode.All,
			["GrindLeviathan"] = AchievementDisplayMode.Hidden,
			["SailEdge"] = AchievementDisplayMode.Hidden,
			["FirstDeath"] = AchievementDisplayMode.Hidden,
			["DeathByAllTypes"] = AchievementDisplayMode.Revealable,
			["DeathByTree"] = AchievementDisplayMode.Simple,
			["DeathByTreeAll"] = AchievementDisplayMode.Revealable,
			["DeathByObliterator"] = AchievementDisplayMode.Hidden,
			["ChildOfOdin"] = AchievementDisplayMode.All,
			["KingsQueens"] = AchievementDisplayMode.All
		};

		private static readonly Dictionary<string, AchievementDisplayMode> ModeByLocalizedName = new Dictionary<string, AchievementDisplayMode>(StringComparer.OrdinalIgnoreCase)
		{
			["Eikthyr"] = AchievementDisplayMode.Hidden,
			["The Elder"] = AchievementDisplayMode.Hidden,
			["Bonemass"] = AchievementDisplayMode.Hidden,
			["Moder"] = AchievementDisplayMode.Hidden,
			["Yagluth"] = AchievementDisplayMode.Hidden,
			["The Seeker Queen"] = AchievementDisplayMode.Hidden,
			["Fader"] = AchievementDisplayMode.Hidden,
			["Kall Fimbulbringer"] = AchievementDisplayMode.Hidden,
			["Odin is Pleased"] = AchievementDisplayMode.Revealable,
			["The Viking"] = AchievementDisplayMode.Revealable,
			["The Tough Viking"] = AchievementDisplayMode.Revealable,
			["The Toughest Viking"] = AchievementDisplayMode.Revealable,
			["Lone Wolf"] = AchievementDisplayMode.Simple,
			["Stronger Together"] = AchievementDisplayMode.Simple,
			["The Hunter"] = AchievementDisplayMode.Revealable,
			["The Master Hunter"] = AchievementDisplayMode.Revealable,
			["The Blacksmith"] = AchievementDisplayMode.Revealable,
			["The Artisan"] = AchievementDisplayMode.Revealable,
			["The Master Chef"] = AchievementDisplayMode.Revealable,
			["The Gourmet"] = AchievementDisplayMode.Revealable,
			["The Carpenter"] = AchievementDisplayMode.Revealable,
			["The Trophy Collector"] = AchievementDisplayMode.Revealable,
			["The Chosen One"] = AchievementDisplayMode.Hidden,
			["The Cook"] = AchievementDisplayMode.All,
			["No Adventuring On an Empty Stomach"] = AchievementDisplayMode.All,
			["The Builder"] = AchievementDisplayMode.All,
			["The Homesteader"] = AchievementDisplayMode.All,
			["The Architect"] = AchievementDisplayMode.All,
			["Mighty Halls"] = AchievementDisplayMode.All,
			["Top of the World"] = AchievementDisplayMode.All,
			["Comfort is King"] = AchievementDisplayMode.All,
			["The Lumberjack"] = AchievementDisplayMode.All,
			["The Farmer"] = AchievementDisplayMode.All,
			["The Forager"] = AchievementDisplayMode.All,
			["The Beekeeper"] = AchievementDisplayMode.All,
			["The Fisherman"] = AchievementDisplayMode.Revealable,
			["A Catch Worthy of Njord"] = AchievementDisplayMode.Simple,
			["I Have Arrived!"] = AchievementDisplayMode.Simple,
			["The Survivor"] = AchievementDisplayMode.All,
			["The Explorer"] = AchievementDisplayMode.All,
			["The Pathfinder"] = AchievementDisplayMode.All,
			["The Sailor"] = AchievementDisplayMode.All,
			["The Captain"] = AchievementDisplayMode.All,
			["The Treasure Hunter"] = AchievementDisplayMode.All,
			["No Time For Snoozing"] = AchievementDisplayMode.Hidden,
			["The Legends Are True"] = AchievementDisplayMode.Hidden,
			["The First of Many"] = AchievementDisplayMode.Hidden,
			["Are You Alright?"] = AchievementDisplayMode.Revealable,
			["Accidents Happen"] = AchievementDisplayMode.Simple,
			["That Can't Be an Accident"] = AchievementDisplayMode.Revealable,
			["Obliterated"] = AchievementDisplayMode.Hidden,
			["Child of Odin"] = AchievementDisplayMode.All,
			["Kings and Queens of Valheim"] = AchievementDisplayMode.All
		};

		private static readonly HashSet<PlayerStatType> RecordStatTypes = new HashSet<PlayerStatType>
		{
			(PlayerStatType)129,
			(PlayerStatType)132,
			(PlayerStatType)130,
			(PlayerStatType)131
		};

		private static readonly HashSet<string> RevealedIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static bool _revealedLoaded;

		private static readonly FieldInfo? PlayerKnownBiomeField = AccessTools.Field(typeof(Player), "m_knownBiome");

		private static readonly Dictionary<Biome, BiomeSector> BiomeSectorCache = new Dictionary<Biome, BiomeSector>();

		private static PlayerStats[]? _otherCharactersStats;

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

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

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

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

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

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

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

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

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

		public static void OnAchievementsInitialized()
		{
			EnsureRevealedLoaded();
			BiomeClassifier.ResetCache();
			RebuildTriggerCaches();
			RefreshProgressScope(recheckUnlocks: true);
			DumpAllAchievements();
		}

		public static void RefreshProgressScope(bool recheckUnlocks)
		{
			if (Plugin.ProgressScopeConfig.Value == ProgressScope.Global)
			{
				RebuildOtherCharactersCache();
			}
			else
			{
				_otherCharactersStats = null;
			}
			if (recheckUnlocks && !((Object)(object)Achievements.m_instance == (Object)null) && !((Object)(object)Game.instance == (Object)null))
			{
				ReevaluateAllAchievements();
				if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_achievementsPanel != (Object)null && ((Component)InventoryGui.instance.m_achievementsPanel).gameObject.activeInHierarchy)
				{
					InventoryGui.instance.UpdateAchievementsList();
				}
			}
		}

		public static AchievementDisplayMode GetDisplayMode(Achievement achievement)
		{
			if ((Object)(object)achievement == (Object)null)
			{
				return AchievementDisplayMode.Hidden;
			}
			if (ModeById.TryGetValue(achievement.m_id, out var value))
			{
				return value;
			}
			string key = ((Localization.instance != null) ? Localization.instance.Localize(achievement.m_name) : achievement.m_name);
			if (ModeByLocalizedName.TryGetValue(key, out var value2))
			{
				return value2;
			}
			if (!achievement.m_isSecret)
			{
				return AchievementDisplayMode.Revealable;
			}
			return AchievementDisplayMode.Hidden;
		}

		public static bool IsRevealed(Achievement achievement)
		{
			if ((Object)(object)achievement == (Object)null)
			{
				return false;
			}
			if (achievement.m_unlocked || Plugin.MasterRevealAll.Value)
			{
				return true;
			}
			EnsureRevealedLoaded();
			return RevealedIds.Contains(achievement.m_id);
		}

		public static bool IsStatRevealed(Achievement achievement, string statKey)
		{
			if (IsRevealed(achievement))
			{
				return true;
			}
			if ((Object)(object)achievement == (Object)null || string.IsNullOrEmpty(statKey))
			{
				return false;
			}
			EnsureRevealedLoaded();
			return RevealedIds.Contains(achievement.m_id + ":" + statKey);
		}

		public static void RevealAchievement(Achievement achievement)
		{
			if (!((Object)(object)achievement == (Object)null) && !string.IsNullOrEmpty(achievement.m_id))
			{
				EnsureRevealedLoaded();
				if (RevealedIds.Add(achievement.m_id))
				{
					SaveRevealedIds();
				}
			}
		}

		public static void RevealStat(Achievement achievement, string statKey)
		{
			if (!((Object)(object)achievement == (Object)null) && !string.IsNullOrEmpty(achievement.m_id) && !string.IsNullOrEmpty(statKey))
			{
				EnsureRevealedLoaded();
				if (RevealedIds.Add(achievement.m_id + ":" + statKey))
				{
					SaveRevealedIds();
				}
			}
		}

		public static bool IsBiomeKnownByPlayer(BiomeTier tier)
		{
			//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)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			Biome val = tier.ToGameBiome();
			if ((int)val == 0)
			{
				return false;
			}
			if (!BiomeSectorCache.TryGetValue(val, out BiomeSector value))
			{
				value = new BiomeSector((AltBiomeWorldData)null, val);
				BiomeSectorCache[val] = value;
			}
			if (localPlayer.IsBiomeKnown(value))
			{
				return true;
			}
			if (PlayerKnownBiomeField?.GetValue(localPlayer) is HashSet<string> hashSet)
			{
				string biomeName = BiomeSector.GetBiomeName(val);
				if (hashSet.Contains(biomeName))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsBiomeHeaderRevealed(Achievement achievement, BiomeTier tier)
		{
			if (tier == BiomeTier.Uncategorized)
			{
				return true;
			}
			if (IsRevealed(achievement) || IsBiomeKnownByPlayer(tier))
			{
				return true;
			}
			return IsStatRevealed(achievement, $"biome:{tier}");
		}

		public static void RevealBiomeHeader(Achievement achievement, BiomeTier tier)
		{
			if (tier != BiomeTier.Uncategorized)
			{
				RevealStat(achievement, $"biome:{tier}");
			}
		}

		public unsafe static bool HasAnyUnrevealedCondition(Achievement achievement)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected I4, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)achievement == (Object)null || achievement.m_unlocked || IsRevealed(achievement))
			{
				return false;
			}
			if ((((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null) == null)
			{
				return false;
			}
			int diffIndex = (int)achievement.m_difficultyRequirement;
			foreach (PlayerStatRequirement item in achievement.m_statTrigger)
			{
				if (GetEffectivePlayerStat(diffIndex, item.m_stat) < item.m_amountAboveEquals)
				{
					PlayerStatType stat = item.m_stat;
					if (!IsStatRevealed(achievement, ((object)(*(PlayerStatType*)(&stat))/*cast due to .constrained prefix*/).ToString()))
					{
						return true;
					}
				}
			}
			foreach (Achievement otherAchievementTrigger in achievement.m_otherAchievementTriggers)
			{
				if ((Object)(object)otherAchievementTrigger != (Object)null && !otherAchievementTrigger.m_unlocked && !IsStatRevealed(achievement, otherAchievementTrigger.m_name))
				{
					return true;
				}
			}
			foreach (EnemyStatRequirement enemyStatsTrigger in achievement.m_enemyStatsTriggers)
			{
				if (GetEffectiveEnemyStat(diffIndex, enemyStatsTrigger.m_modifier, enemyStatsTrigger.m_stat) < enemyStatsTrigger.m_amount && !IsStatRevealed(achievement, enemyStatsTrigger.m_stat))
				{
					return true;
				}
			}
			if (!HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_foodEatenTriggers, (PlayerStats s) => s.m_foodEatenStats) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_itemCraftTriggers, (PlayerStats s) => s.m_itemCraftStats) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_itemPickupTriggers, (PlayerStats s) => s.m_itemPickupStats) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_knownCommandsTriggers, (PlayerStats s) => s.m_knownCommands) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_knownWorldKeysTriggers, (PlayerStats s) => s.m_knownWorldKeys) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_knownWorldTriggers, (PlayerStats s) => s.m_knownWorlds) && !HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_pickableTriggers, (PlayerStats s) => s.m_pickableStats))
			{
				return HasUnrevealedDictTrigger(achievement, diffIndex, achievement.m_piecePlacedTriggers, (PlayerStats s) => s.m_piecesPlacedStats);
			}
			return true;
		}

		private static bool HasUnrevealedDictTrigger(Achievement achievement, int diffIndex, List<DictStatRequirement> triggers, Func<PlayerStats, Dictionary<string, float>> selector)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			foreach (DictStatRequirement trigger in triggers)
			{
				if (GetEffectiveDictStat(diffIndex, selector, trigger.m_stat) < trigger.m_amount && !IsStatRevealed(achievement, trigger.m_stat))
				{
					return true;
				}
			}
			return false;
		}

		private static void SaveRevealedIds()
		{
			Plugin.RevealedAchievementIds.Value = string.Join(",", RevealedIds.OrderBy((string id) => id));
			((BaseUnityPlugin)Plugin.Instance).Config.Save();
		}

		public static void RevealAllSpoilers()
		{
			Plugin.MasterRevealAll.Value = true;
			((BaseUnityPlugin)Plugin.Instance).Config.Save();
		}

		public static bool HasAnyManuallyRevealedEntry(Achievement achievement)
		{
			if ((Object)(object)achievement == (Object)null || string.IsNullOrEmpty(achievement.m_id))
			{
				return false;
			}
			EnsureRevealedLoaded();
			string value = achievement.m_id + ":";
			foreach (string revealedId in RevealedIds)
			{
				if (revealedId.Equals(achievement.m_id, StringComparison.OrdinalIgnoreCase) || revealedId.StartsWith(value, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public static void HideAchievement(Achievement achievement)
		{
			if (!((Object)(object)achievement == (Object)null) && !string.IsNullOrEmpty(achievement.m_id))
			{
				EnsureRevealedLoaded();
				string prefix = achievement.m_id + ":";
				if (RevealedIds.RemoveWhere((string entry) => entry.Equals(achievement.m_id, StringComparison.OrdinalIgnoreCase) || entry.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) > 0)
				{
					SaveRevealedIds();
				}
			}
		}

		public static void HideAllSpoilers()
		{
			EnsureRevealedLoaded();
			Plugin.MasterRevealAll.Value = false;
			RevealedIds.Clear();
			Plugin.RevealedAchievementIds.Value = string.Empty;
			((BaseUnityPlugin)Plugin.Instance).Config.Save();
		}

		public static bool IsConcealed(Achievement achievement)
		{
			if ((Object)(object)achievement == (Object)null || achievement.m_unlocked || Plugin.MasterRevealAll.Value)
			{
				return false;
			}
			if (!achievement.m_isSecret)
			{
				return false;
			}
			AchievementDisplayMode displayMode = GetDisplayMode(achievement);
			if (Plugin.OnlyHideSpoilerAchievements.Value && displayMode != AchievementDisplayMode.Hidden)
			{
				return false;
			}
			return true;
		}

		public static bool HasAnyDetails(Achievement achievement)
		{
			if ((Object)(object)achievement == (Object)null)
			{
				return false;
			}
			if (achievement.m_statTrigger.Count <= 0 && achievement.m_enemyStatsTriggers.Count <= 0 && achievement.m_foodEatenTriggers.Count <= 0 && achievement.m_itemCraftTriggers.Count <= 0 && achievement.m_itemPickupTriggers.Count <= 0 && achievement.m_knownCommandsTriggers.Count <= 0 && achievement.m_knownWorldKeysTriggers.Count <= 0 && achievement.m_knownWorldTriggers.Count <= 0 && achievement.m_pickableTriggers.Count <= 0 && achievement.m_piecePlacedTriggers.Count <= 0)
			{
				return achievement.m_otherAchievementTriggers.Count > 0;
			}
			return true;
		}

		public static string FormatStatName(string statKey)
		{
			if (string.IsNullOrEmpty(statKey))
			{
				return string.Empty;
			}
			PlayerStatType result;
			string text = (Enum.TryParse<PlayerStatType>(statKey, out result) ? ("$stat_" + statKey) : statKey);
			string text2 = ((Localization.instance != null) ? Localization.instance.Localize(text) : text);
			if (!string.IsNullOrEmpty(text2) && (!text2.StartsWith("[") || !text2.EndsWith("]")))
			{
				return text2;
			}
			return SplitPascalCase(statKey.TrimStart(new char[1] { '$' }));
		}

		public static string FormatAmount(float value)
		{
			if (!Mathf.Approximately(value, Mathf.Round(value)))
			{
				return value.ToString("0.#");
			}
			return Mathf.RoundToInt(value).ToString();
		}

		private static string SplitPascalCase(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return string.Empty;
			}
			StringBuilder stringBuilder = new StringBuilder(input.Length + 8);
			for (int i = 0; i < input.Length; i++)
			{
				char c = input[i];
				if (i > 0 && char.IsUpper(c) && !char.IsUpper(input[i - 1]) && input[i - 1] != ' ' && input[i - 1] != '_')
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append((c == '_') ? ' ' : c);
			}
			return stringBuilder.ToString();
		}

		public static float GetCompletionPercentage(Achievement achievement)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected I4, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)achievement == (Object)null)
			{
				return 0f;
			}
			if (achievement.m_unlocked)
			{
				return 100f;
			}
			PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null);
			if (val == null)
			{
				return 0f;
			}
			int num = (int)achievement.m_difficultyRequirement;
			if (num < 0 || num >= val.m_playerStats.Length)
			{
				return 0f;
			}
			float totalRatio = 0f;
			int totalCount = 0;
			foreach (PlayerStatRequirement item in achievement.m_statTrigger)
			{
				float effectivePlayerStat = GetEffectivePlayerStat(num, item.m_stat);
				float num2 = Mathf.Max(1f, item.m_amountAboveEquals);
				totalRatio += Mathf.Clamp01(effectivePlayerStat / num2);
				totalCount++;
			}
			foreach (EnemyStatRequirement enemyStatsTrigger in achievement.m_enemyStatsTriggers)
			{
				float value;
				bool hasValue = TryGetEffectiveEnemyStat(num, enemyStatsTrigger.m_modifier, enemyStatsTrigger.m_stat, out value);
				totalRatio += (EvaluateOperator(hasValue, value, enemyStatsTrigger.m_amount, enemyStatsTrigger.m_operator) ? 1f : Mathf.Clamp01(value / Mathf.Max(1f, enemyStatsTrigger.m_amount)));
				totalCount++;
			}
			AccumulateDictTriggers(num, achievement.m_itemCraftTriggers, (PlayerStats s) => s.m_itemCraftStats, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_itemPickupTriggers, (PlayerStats s) => s.m_itemPickupStats, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_foodEatenTriggers, (PlayerStats s) => s.m_foodEatenStats, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_piecePlacedTriggers, (PlayerStats s) => s.m_piecesPlacedStats, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_pickableTriggers, (PlayerStats s) => s.m_pickableStats, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_knownCommandsTriggers, (PlayerStats s) => s.m_knownCommands, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_knownWorldKeysTriggers, (PlayerStats s) => s.m_knownWorldKeys, ref totalRatio, ref totalCount);
			AccumulateDictTriggers(num, achievement.m_knownWorldTriggers, (PlayerStats s) => s.m_knownWorlds, ref totalRatio, ref totalCount);
			foreach (Achievement otherAchievementTrigger in achievement.m_otherAchievementTriggers)
			{
				totalRatio += (((Object)(object)otherAchievementTrigger != (Object)null && otherAchievementTrigger.m_unlocked) ? 1f : 0f);
				totalCount++;
			}
			if (totalCount <= 0)
			{
				return 0f;
			}
			return totalRatio / (float)totalCount * 100f;
		}

		public static bool EvaluateAchievementUnlocked(Achievement achievement)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected I4, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)achievement == (Object)null)
			{
				return false;
			}
			if (achievement.m_unlocked)
			{
				return true;
			}
			PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null);
			if (val == null)
			{
				return false;
			}
			int num = (int)achievement.m_difficultyRequirement;
			if (num < 0 || num >= val.m_playerStats.Length)
			{
				return false;
			}
			foreach (PlayerStatRequirement item in achievement.m_statTrigger)
			{
				if (GetEffectivePlayerStat(num, item.m_stat) < item.m_amountAboveEquals)
				{
					return false;
				}
			}
			if (!AreDictTriggersMet(num, achievement.m_knownWorldTriggers, (PlayerStats s) => s.m_knownWorlds))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_knownWorldKeysTriggers, (PlayerStats s) => s.m_knownWorldKeys))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_knownCommandsTriggers, (PlayerStats s) => s.m_knownCommands))
			{
				return false;
			}
			foreach (EnemyStatRequirement enemyStatsTrigger in achievement.m_enemyStatsTriggers)
			{
				if (!EvaluateOperator(TryGetEffectiveEnemyStat(num, enemyStatsTrigger.m_modifier, enemyStatsTrigger.m_stat, out var value), value, enemyStatsTrigger.m_amount, enemyStatsTrigger.m_operator))
				{
					return false;
				}
			}
			if (!AreDictTriggersMet(num, achievement.m_itemPickupTriggers, (PlayerStats s) => s.m_itemPickupStats))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_itemCraftTriggers, (PlayerStats s) => s.m_itemCraftStats))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_pickableTriggers, (PlayerStats s) => s.m_pickableStats))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_foodEatenTriggers, (PlayerStats s) => s.m_foodEatenStats))
			{
				return false;
			}
			if (!AreDictTriggersMet(num, achievement.m_piecePlacedTriggers, (PlayerStats s) => s.m_piecesPlacedStats))
			{
				return false;
			}
			foreach (Achievement otherAchievementTrigger in achievement.m_otherAchievementTriggers)
			{
				if ((Object)(object)otherAchievementTrigger != (Object)null && !otherAchievementTrigger.m_unlocked)
				{
					return false;
				}
			}
			return true;
		}

		public static float GetEffectivePlayerStat(int diffIndex, PlayerStatType stat)
		{
			//IL_0048: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null);
			float value = 0f;
			if (val != null && diffIndex >= 0 && diffIndex < val.m_playerStats.Length && IncludeCurrentProfileInScope(val))
			{
				val.m_playerStats[diffIndex].m_stats.TryGetValue(stat, out value);
			}
			if (Plugin.ProgressScopeConfig.Value != ProgressScope.Global || _otherCharactersStats == null || diffIndex < 0 || diffIndex >= _otherCharactersStats.Length)
			{
				return value;
			}
			_otherCharactersStats[diffIndex].m_stats.TryGetValue(stat, out var value2);
			if (!RecordStatTypes.Contains(stat))
			{
				return value + value2;
			}
			return Mathf.Max(value, value2);
		}

		public static float GetEffectiveEnemyStat(int diffIndex, KillModifiers modifier, string statKey)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			TryGetEffectiveEnemyStat(diffIndex, modifier, statKey, out var value);
			return value;
		}

		public static bool TryGetEffectiveEnemyStat(int diffIndex, KillModifiers modifier, string statKey, out float value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected I4, but got Unknown
			int modIndex = (int)modifier;
			return TryGetEffectiveDictStat(diffIndex, (PlayerStats s) => s.m_enemyStats[modIndex], statKey, out value);
		}

		public static float GetEffectiveDictStat(int diffIndex, Func<PlayerStats, Dictionary<string, float>> selector, string statKey)
		{
			TryGetEffectiveDictStat(diffIndex, selector, statKey, out var value);
			return value;
		}

		public static bool TryGetEffectiveDictStat(int diffIndex, Func<PlayerStats, Dictionary<string, float>> selector, string statKey, out float value)
		{
			PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null);
			bool flag = false;
			float value2 = 0f;
			if (val != null && diffIndex >= 0 && diffIndex < val.m_playerStats.Length && IncludeCurrentProfileInScope(val))
			{
				flag = selector(val.m_playerStats[diffIndex]).TryGetValue(statKey, out value2);
			}
			if (Plugin.ProgressScopeConfig.Value != ProgressScope.Global || _otherCharactersStats == null || diffIndex < 0 || diffIndex >= _otherCharactersStats.Length)
			{
				value = value2;
				return flag;
			}
			float value3;
			bool flag2 = selector(_otherCharactersStats[diffIndex]).TryGetValue(statKey, out value3);
			value = value2 + value3;
			return flag || flag2;
		}

		public static bool IsItemCraftTarget(string sharedName)
		{
			return CraftTargets.Contains(sharedName);
		}

		public static bool IsFoodCookTarget(string sharedName)
		{
			return CookTargets.Contains(sharedName);
		}

		public static bool IsFoodEatenTarget(string sharedName)
		{
			return FoodEatenTargets.Contains(sharedName);
		}

		public static bool IsBuildPieceTarget(string pieceName)
		{
			return BuildPieceTargets.Contains(pieceName);
		}

		public static bool IsEnemyTarget(string enemyName)
		{
			return EnemyTargets.Contains(enemyName);
		}

		public static bool IsTrophyTarget(string trophySharedName)
		{
			return TrophyTargets.Contains(trophySharedName);
		}

		public static bool IsFishTarget(string fishSharedName)
		{
			return FishTargets.Contains(fishSharedName);
		}

		public static bool TryGetCookedVariant(string rawSharedName, out string cookedSharedName)
		{
			return RawToCookedMap.TryGetValue(rawSharedName, out cookedSharedName);
		}

		public static bool IsRecipeMissingForAchievement(Recipe recipe, out bool isFoodRecipe)
		{
			isFoodRecipe = false;
			string text = recipe?.m_item?.m_itemData?.m_shared?.m_name;
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			bool flag = IsFoodCookTarget(text);
			string cookedSharedName;
			bool flag2 = TryGetCookedVariant(text, out cookedSharedName) && IsFoodCookTarget(cookedSharedName);
			isFoodRecipe = flag || flag2;
			if (flag && !HasCraftedItem(text))
			{
				return true;
			}
			if (flag2 && !HasCraftedItem(cookedSharedName))
			{
				return true;
			}
			if (IsItemCraftTarget(text) && !HasCraftedItem(text))
			{
				return true;
			}
			return false;
		}

		public static bool HasCraftedItem(string sharedName)
		{
			return GetEffectiveDictStat(1, (PlayerStats s) => s.m_itemCraftStats, sharedName) >= 1f;
		}

		public static bool HasEatenFood(string sharedName)
		{
			return GetEffectiveDictStat(1, (PlayerStats s) => s.m_foodEatenStats, sharedName) >= 1f;
		}

		public static bool HasBuiltPiece(string pieceName)
		{
			return GetEffectiveDictStat(1, (PlayerStats s) => s.m_piecesPlacedStats, pieceName) >= 1f;
		}

		public static bool IsPieceMissingForAchievement(Piece? piece)
		{
			if ((Object)(object)piece != (Object)null && !string.IsNullOrEmpty(piece.m_name) && IsBuildPieceTarget(piece.m_name))
			{
				return !HasBuiltPiece(piece.m_name);
			}
			return false;
		}

		public static bool HasKilledEnemy(string enemyName)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			return GetEffectiveEnemyStat(((int)Achievements.GetCurrentAchievementDifficulty() < 7) ? 1 : 7, (KillModifiers)0, enemyName) >= 1f;
		}

		public static bool HasPickedUpTrophy(string trophySharedName)
		{
			return GetEffectiveDictStat(1, (PlayerStats s) => s.m_itemPickupStats, trophySharedName) >= 1f;
		}

		public static bool HasCaughtFish(string fishSharedName)
		{
			return GetEffectiveDictStat(1, (PlayerStats s) => s.m_pickableStats, fishSharedName) >= 1f;
		}

		public static bool IsEnemyMissingForAchievement(Character? character)
		{
			if ((Object)(object)character != (Object)null && !character.IsPlayer() && !character.IsBoss() && !character.IsTamed() && !string.IsNullOrEmpty(character.m_name) && IsEnemyTarget(character.m_name))
			{
				return !HasKilledEnemy(character.m_name);
			}
			return false;
		}

		public static bool IsEnemyMissingTrophyForAchievement(Character? character)
		{
			if ((Object)(object)character == (Object)null || character.IsPlayer() || character.IsBoss() || character.IsTamed())
			{
				return false;
			}
			if (TryGetCharacterTrophy(character, out string trophySharedName) && IsTrophyTarget(trophySharedName))
			{
				return !HasPickedUpTrophy(trophySharedName);
			}
			return false;
		}

		public static bool TryGetCharacterTrophy(Character character, out string trophySharedName)
		{
			trophySharedName = string.Empty;
			if ((Object)(object)character == (Object)null || string.IsNullOrEmpty(character.m_name))
			{
				return false;
			}
			if (CharacterTrophyMap.TryGetValue(character.m_name, out string value))
			{
				trophySharedName = value;
				return !string.IsNullOrEmpty(value);
			}
			string text = FindTrophyDropName(((Component)character).GetComponent<CharacterDrop>());
			CharacterTrophyMap[character.m_name] = text;
			trophySharedName = text;
			return !string.IsNullOrEmpty(text);
		}

		private static string FindTrophyDropName(CharacterDrop? dropComponent)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			if ((Object)(object)dropComponent == (Object)null || dropComponent.m_drops == null)
			{
				return string.Empty;
			}
			foreach (Drop drop in dropComponent.m_drops)
			{
				SharedData val = (((Object)(object)drop.m_prefab != (Object)null) ? drop.m_prefab.GetComponent<ItemDrop>() : null)?.m_itemData?.m_shared;
				if (val != null && (int)val.m_itemType == 13 && !string.IsNullOrEmpty(val.m_name))
				{
					return val.m_name;
				}
			}
			return string.Empty;
		}

		private static bool IncludeCurrentProfileInScope(PlayerProfile current)
		{
			if (Plugin.ProgressScopeConfig.Value != ProgressScope.Global)
			{
				return true;
			}
			if (current.m_usedCheats)
			{
				return Plugin.CountCheatedCharacters.Value;
			}
			return true;
		}

		private static bool AreDictTriggersMet(int diffIndex, List<DictStatRequirement> triggers, Func<PlayerStats, Dictionary<string, float>> selector)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			foreach (DictStatRequirement trigger in triggers)
			{
				if (!EvaluateOperator(TryGetEffectiveDictStat(diffIndex, selector, trigger.m_stat, out var value), value, trigger.m_amount, trigger.m_operator))
				{
					return false;
				}
			}
			return true;
		}

		private static bool EvaluateOperator(bool hasValue, float current, float target, RequirementOperator op)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected I4, but got Unknown
			if (!hasValue)
			{
				return false;
			}
			return (int)op switch
			{
				0 => current >= target, 
				1 => current <= target, 
				2 => current == target, 
				3 => current != target, 
				_ => false, 
			};
		}

		private static void AccumulateDictTriggers(int diffIndex, List<DictStatRequirement> triggers, Func<PlayerStats, Dictionary<string, float>> selector, ref float totalRatio, ref int totalCount)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			foreach (DictStatRequirement trigger in triggers)
			{
				float effectiveDictStat = GetEffectiveDictStat(diffIndex, selector, trigger.m_stat);
				float num = Mathf.Max(1f, trigger.m_amount);
				totalRatio += Mathf.Clamp01(effectiveDictStat / num);
				totalCount++;
			}
		}

		private static void RebuildOtherCharactersCache()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null);
			if (val == null)
			{
				_otherCharactersStats = null;
				return;
			}
			int num = val.m_playerStats.Length;
			PlayerStats[] array = (PlayerStats[])(object)new PlayerStats[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = new PlayerStats();
			}
			string value = val.GetFilename() ?? string.Empty;
			long playerID = val.GetPlayerID();
			int num2 = 0;
			try
			{
				foreach (PlayerProfile allPlayerProfile in SaveSystem.GetAllPlayerProfiles())
				{
					if (allPlayerProfile == null)
					{
						continue;
					}
					string text = allPlayerProfile.GetFilename() ?? string.Empty;
					if ((string.IsNullOrEmpty(value) || !text.Equals(value, StringComparison.OrdinalIgnoreCase)) && (playerID == 0L || allPlayerProfile.GetPlayerID() != playerID) && (!allPlayerProfile.m_usedCheats || Plugin.CountCheatedCharacters.Value))
					{
						int num3 = Mathf.Min(num, allPlayerProfile.m_playerStats.Length);
						for (int j = 0; j < num3; j++)
						{
							MergeStatsSlot(array[j], allPlayerProfile.m_playerStats[j]);
						}
						num2++;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Failed to aggregate other character profiles: " + ex.Message));
			}
			_otherCharactersStats = array;
			Plugin.Log.LogInfo((object)$"Global progress cache built from {num2} other character(s).");
		}

		private static void MergeStatsSlot(PlayerStats target, PlayerStats source)
		{
			//IL_0030: 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: Unknown result type (might be due to invalid IL or missing references)
			if (source == null)
			{
				return;
			}
			foreach (KeyValuePair<PlayerStatType, float> stat in source.m_stats)
			{
				if (stat.Value != 0f)
				{
					target.m_stats.TryGetValue(stat.Key, out var value);
					target.m_stats[stat.Key] = (RecordStatTypes.Contains(stat.Key) ? Mathf.Max(value, stat.Value) : (value + stat.Value));
				}
			}
			MergeStringDict(target.m_knownWorlds, source.m_knownWorlds);
			MergeStringDict(target.m_knownWorldKeys, source.m_knownWorldKeys);
			MergeStringDict(target.m_knownCommands, source.m_knownCommands);
			MergeStringDict(target.m_itemPickupStats, source.m_itemPickupStats);
			MergeStringDict(target.m_itemCraftStats, source.m_itemCraftStats);
			MergeStringDict(target.m_pickableStats, source.m_pickableStats);
			MergeStringDict(target.m_foodEatenStats, source.m_foodEatenStats);
			MergeStringDict(target.m_piecesPlacedStats, source.m_piecesPlacedStats);
			int num = Mathf.Min(target.m_enemyStats.Length, source.m_enemyStats.Length);
			for (int i = 0; i < num; i++)
			{
				MergeStringDict(target.m_enemyStats[i], source.m_enemyStats[i]);
			}
		}

		private static void MergeStringDict(Dictionary<string, float> target, Dictionary<string, float> source)
		{
			if (source == null)
			{
				return;
			}
			foreach (KeyValuePair<string, float> item in source)
			{
				if (item.Value != 0f)
				{
					target.TryGetValue(item.Key, out var value);
					target[item.Key] = value + item.Value;
				}
			}
		}

		private static void ReevaluateAllAchievements()
		{
			if ((Object)(object)Achievements.m_instance == (Object)null)
			{
				return;
			}
			List<Achievement> list = new List<Achievement>();
			foreach (AchievementList achievementList in Achievements.m_instance.m_achievementLists)
			{
				foreach (Achievement achievement in achievementList.m_achievements)
				{
					if ((Object)(object)achievement != (Object)null)
					{
						list.Add(achievement);
					}
				}
			}
			foreach (Achievement item in list)
			{
				item.m_unlocked = false;
			}
			if (Plugin.SyncSteamUnlocks.Value)
			{
				foreach (Achievement item2 in list)
				{
					if (IsUnlockedOnSteam(item2))
					{
						item2.m_unlocked = true;
					}
				}
			}
			bool flag = false;
			foreach (Achievement item3 in list)
			{
				if (item3.m_otherAchievementTriggers.Count <= 0 && !item3.m_unlocked)
				{
					if (item3.m_lenientBuildAchievement)
					{
						Piece.CheckLenientBuildAchUnlocked(item3, false, false);
					}
					if (item3.CheckUnlocked())
					{
						Achievements.AchievementEvent(item3, false, false);
						flag = true;
					}
				}
			}
			foreach (Achievement item4 in list)
			{
				if (item4.m_otherAchievementTriggers.Count != 0 && !item4.m_unlocked && item4.CheckUnlocked())
				{
					Achievements.AchievementEvent(item4, false, false);
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			IDistributionPlatform distributionPlatform = PlatformManager.DistributionPlatform;
			if (distributionPlatform != null)
			{
				IAchievementManager achievementManager = distributionPlatform.AchievementManager;
				if (achievementManager != null)
				{
					achievementManager.Synchronize();
				}
			}
		}

		private static bool IsUnlockedOnSteam(Achievement achievement)
		{
			try
			{
				string achievementInternalPlatformId = Achievements.GetAchievementInternalPlatformId(achievement);
				bool result = default(bool);
				if (!string.IsNullOrEmpty(achievementInternalPlatformId) && SteamUserStats.GetAchievement(achievementInternalPlatformId, ref result))
				{
					return result;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("Steam unlock check skipped for " + achievement.m_id + ": " + ex.Message));
			}
			return false;
		}

		private static void EnsureRevealedLoaded()
		{
			if (_revealedLoaded)
			{
				return;
			}
			_revealedLoaded = true;
			string value = Plugin.RevealedAchievementIds.Value;
			if (!string.IsNullOrWhiteSpace(value))
			{
				string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string text in array)
				{
					RevealedIds.Add(text.Trim());
				}
			}
		}

		private static void RebuildTriggerCaches()
		{
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Invalid comparison between Unknown and I4
			CraftTargets.Clear();
			CookTargets.Clear();
			FoodEatenTargets.Clear();
			BuildPieceTargets.Clear();
			EnemyTargets.Clear();
			TrophyTargets.Clear();
			FishTargets.Clear();
			RawToCookedMap.Clear();
			CharacterTrophyMap.Clear();
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
				{
					if ((Object)(object)prefab == (Object)null)
					{
						continue;
					}
					Character component = prefab.GetComponent<Character>();
					if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.m_name) && !CharacterTrophyMap.ContainsKey(component.m_name))
					{
						string value = FindTrophyDropName(prefab.GetComponent<CharacterDrop>());
						if (!string.IsNullOrEmpty(value))
						{
							CharacterTrophyMap[component.m_name] = value;
						}
					}
					CookingStation component2 = prefab.GetComponent<CookingStation>();
					if ((Object)(object)component2 == (Object)null)
					{
						continue;
					}
					foreach (ItemConversion item in component2.m_conversion)
					{
						string text = item.m_from?.m_itemData?.m_shared?.m_name;
						SharedData val = item.m_to?.m_itemData?.m_shared;
						if (!string.IsNullOrEmpty(text) && val != null && !string.IsNullOrEmpty(val.m_name) && val.m_food > 0f && (int)val.m_itemType == 2 && !RawToCookedMap.ContainsKey(text))
						{
							RawToCookedMap[text] = val.m_name;
						}
					}
				}
			}
			if ((Object)(object)Achievements.m_instance == (Object)null)
			{
				return;
			}
			foreach (AchievementList achievementList in Achievements.m_instance.m_achievementLists)
			{
				foreach (Achievement achievement in achievementList.m_achievements)
				{
					switch (achievement.m_id)
					{
					case "AllItemCraft":
					case "AllWeaponCraft":
						foreach (DictStatRequirement itemCraftTrigger in achievement.m_itemCraftTriggers)
						{
							if (!string.IsNullOrEmpty(itemCraftTrigger.m_stat))
							{
								CraftTargets.Add(itemCraftTrigger.m_stat);
							}
						}
						break;
					case "AllFoodCooked":
						foreach (DictStatRequirement itemCraftTrigger2 in achievement.m_itemCraftTriggers)
						{
							if (!string.IsNullOrEmpty(itemCraftTrigger2.m_stat))
							{
								CookTargets.Add(itemCraftTrigger2.m_stat);
							}
						}
						break;
					case "AllFoodEaten":
						foreach (DictStatRequirement foodEatenTrigger in achievement.m_foodEatenTriggers)
						{
							if (!string.IsNullOrEmpty(foodEatenTrigger.m_stat))
							{
								FoodEatenTargets.Add(foodEatenTrigger.m_stat);
							}
						}
						break;
					case "AllBuildPieces":
						foreach (DictStatRequirement piecePlacedTrigger in achievement.m_piecePlacedTriggers)
						{
							if (!string.IsNullOrEmpty(piecePlacedTrigger.m_stat))
							{
								BuildPieceTargets.Add(piecePlacedTrigger.m_stat);
							}
						}
						break;
					case "KillAllCreatures":
					case "KillAllCreaturesHard":
						foreach (EnemyStatRequirement enemyStatsTrigger in achievement.m_enemyStatsTriggers)
						{
							if (!string.IsNullOrEmpty(enemyStatsTrigger.m_stat))
							{
								EnemyTargets.Add(enemyStatsTrigger.m_stat);
							}
						}
						break;
					case "FindAllTrophies":
						foreach (DictStatRequirement itemPickupTrigger in achievement.m_itemPickupTriggers)
						{
							if (!string.IsNullOrEmpty(itemPickupTrigger.m_stat))
							{
								TrophyTargets.Add(itemPickupTrigger.m_stat);
							}
						}
						break;
					case "GrindFish":
						foreach (DictStatRequirement pickableTrigger in achievement.m_pickableTriggers)
						{
							if (!string.IsNullOrEmpty(pickableTrigger.m_stat))
							{
								FishTargets.Add(pickableTrigger.m_stat);
							}
						}
						break;
					}
				}
			}
		}

		private static void DumpAllAchievements()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Achievements.m_instance == (Object)null)
			{
				return;
			}
			int num = 0;
			foreach (AchievementList achievementList in Achievements.m_instance.m_achievementLists)
			{
				foreach (Achievement achievement in achievementList.m_achievements)
				{
					num++;
					string text = ((Localization.instance != null) ? Localization.instance.Localize(achievement.m_name) : achievement.m_name);
					AchievementDisplayMode displayMode = GetDisplayMode(achievement);
					Plugin.Log.LogDebug((object)$"[Ach #{num:00}] id={achievement.m_id} | name=\"{text}\" | secret={achievement.m_isSecret} | diff={achievement.m_difficultyRequirement} | mode={displayMode}");
				}
			}
		}
	}
	public enum BadgeCorner
	{
		TopLeft,
		TopRight,
		BottomLeft,
		BottomRight
	}
	public static class BiomeClassifier
	{
		private readonly struct CookingConversionSource
		{
			public readonly string FromSharedName;

			public readonly BiomeTier StationBiome;

			public CookingConversionSource(string fromSharedName, BiomeTier stationBiome)
			{
				FromSharedName = fromSharedName;
				StationBiome = stationBiome;
			}
		}

		private static readonly Dictionary<string, BiomeTier> EnemyBiomeByName = new Dictionary<string, BiomeTier>(StringComparer.Ordinal);

		private static readonly Dictionary<string, BiomeTier> DerivedMaterialBiomes = new Dictionary<string, BiomeTier>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, Recipe> RecipeBySharedName = new Dictionary<string, Recipe>(StringComparer.Ordinal);

		private static readonly Dictionary<string, List<CookingConversionSource>> CookingSourcesBySharedName = new Dictionary<string, List<CookingConversionSource>>(StringComparer.Ordinal);

		private static readonly Dictionary<string, Piece> PieceByName = new Dictionary<string, Piece>(StringComparer.Ordinal);

		private static readonly Dictionary<string, string> PrefabNameBySharedName = new Dictionary<string, string>(StringComparer.Ordinal);

		private static readonly Dictionary<string, BiomeTier> ItemBiomeCache = new Dictionary<string, BiomeTier>(StringComparer.Ordinal);

		private static readonly Dictionary<string, BiomeTier> PieceBiomeCache = new Dictionary<string, BiomeTier>(StringComparer.Ordinal);

		private static readonly Dictionary<PlayerStatType, BiomeTier> TreeBiomeByStat = new Dictionary<PlayerStatType, BiomeTier>();

		private static readonly HashSet<string> LoggedSummaryKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static bool _enemyIndexBuilt;

		private static bool _itemIndexBuilt;

		private static bool _cookingIndexBuilt;

		private static bool _pieceIndexBuilt;

		private static bool _treeIndexBuilt;

		private static readonly Dictionary<string, BiomeTier> EnemyBiomeOverrides = new Dictionary<string, BiomeTier>(StringComparer.Ordinal)
		{
			["$enemy_eikthyr"] = BiomeTier.Meadows,
			["$enemy_boarpiggy"] = BiomeTier.Meadows,
			["$piece_trainingdummy"] = BiomeTier.Meadows,
			["$enemy_gdking"] = BiomeTier.BlackForest,
			["$enemy_skeletonfire"] = BiomeTier.BlackForest,
			["$enemy_ghost"] = BiomeTier.BlackForest,
			["$enemy_skeleton_poison"] = BiomeTier.BlackForest,
			["$enemy_bonemass"] = BiomeTier.Swamp,
			["$enemy_draugr"] = BiomeTier.Swamp,
			["$enemy_draugrelite"] = BiomeTier.Swamp,
			["$enemy_surtling"] = BiomeTier.Swamp,
			["$enemy_kvastur"] = BiomeTier.Swamp,
			["$enemy_dragon"] = BiomeTier.Mountain,
			["$enemy_fenringcultist_hildir"] = BiomeTier.Mountain,
			["$enemy_bat"] = BiomeTier.Mountain,
			["$enemy_ulv"] = BiomeTier.Mountain,
			["$enemy_fenringcultist"] = BiomeTier.Mountain,
			["$enemy_wolfcub"] = BiomeTier.Mountain,
			["$enemy_goblinking"] = BiomeTier.Plains,
			["$enemy_goblinbrute_hildircombined"] = BiomeTier.Plains,
			["$enemy_goblin_hildir"] = BiomeTier.Plains,
			["$enemy_goblinshaman"] = BiomeTier.Plains,
			["$enemy_blobtar"] = BiomeTier.Plains,
			["$enemy_loxcalf"] = BiomeTier.Plains,
			["$enemy_chicken"] = BiomeTier.Plains,
			["$enemy_hen"] = BiomeTier.Plains,
			["$enemy_seekerqueen"] = BiomeTier.Mistlands,
			["$enemy_tick"] = BiomeTier.Mistlands,
			["$enemy_seeker_brood"] = BiomeTier.Mistlands,
			["$enemy_dverger"] = BiomeTier.Mistlands,
			["$enemy_dvergr_mage"] = BiomeTier.Mistlands,
			["$enemy_skeleton_summoned"] = BiomeTier.Mistlands,
			["$enemy_fader"] = BiomeTier.Ashlands,
			["$enemy_charred_melee_Dyrnwyn"] = BiomeTier.Ashlands,
			["$enemy_morgen"] = BiomeTier.Ashlands,
			["$enemy_charred_mage"] = BiomeTier.Ashlands,
			["$enemy_asksvin_hatchling"] = BiomeTier.Ashlands,
			["$enemy_charred_melee_Fader"] = BiomeTier.Ashlands,
			["$enemy_charred_twitcher_summoned"] = BiomeTier.Ashlands,
			["$enemy_summonedtroll"] = BiomeTier.Ashlands,
			["$enemy_frozenking"] = BiomeTier.DeepNorth,
			["$enemy_frozenking_p3"] = BiomeTier.DeepNorth,
			["$enemy_aspect_eikthyr"] = BiomeTier.DeepNorth,
			["$enemy_aspect_gdking"] = BiomeTier.DeepNorth,
			["$enemy_aspect_bonemass"] = BiomeTier.DeepNorth,
			["$enemy_aspect_dragon"] = BiomeTier.DeepNorth,
			["$enemy_aspect_goblinking"] = BiomeTier.DeepNorth,
			["$enemy_aspect_seekerqueen"] = BiomeTier.DeepNorth,
			["$enemy_aspect_fader"] = BiomeTier.DeepNorth,
			["$enemy_trollfrost"] = BiomeTier.DeepNorth,
			["$enemy_jotun_warrior"] = BiomeTier.DeepNorth,
			["$enemy_jotun_witch"] = BiomeTier.DeepNorth,
			["$enemy_elakingmole"] = BiomeTier.DeepNorth,
			["$enemy_fallenwarrior"] = BiomeTier.DeepNorth,
			["$enemy_blobfrost"] = BiomeTier.DeepNorth,
			["$enemy_blobmork"] = BiomeTier.DeepNorth,
			["$enemy_blobmorkmini"] = BiomeTier.DeepNorth,
			["$enemy_goblin_deepnorth"] = BiomeTier.DeepNorth,
			["$enemy_dvergr_deepnorth"] = BiomeTier.DeepNorth,
			["$enemy_moosecalf"] = BiomeTier.DeepNorth,
			["$spiritcaller_boar"] = BiomeTier.DeepNorth,
			["$spiritcaller_bjorn"] = BiomeTier.DeepNorth,
			["$spiritcaller_wolf"] = BiomeTier.DeepNorth,
			["$spiritcaller_moose"] = BiomeTier.DeepNorth
		};

		private static readonly Dictionary<PlayerStatType, BiomeTier> TreeStatBiomes = new Dictionary<PlayerStatType, BiomeTier>
		{
			[(PlayerStatType)199] = BiomeTier.Meadows,
			[(PlayerStatType)200] = BiomeTier.Meadows,
			[(PlayerStatType)194] = BiomeTier.Meadows,
			[(PlayerStatType)193] = BiomeTier.BlackForest,
			[(PlayerStatType)195] = BiomeTier.BlackForest,
			[(PlayerStatType)198] = BiomeTier.Swamp,
			[(PlayerStatType)197] = BiomeTier.Mistlands,
			[(PlayerStatType)196] = BiomeTier.Ashlands,
			[(PlayerStatType)201] = BiomeTier.DeepNorth,
			[(PlayerStatType)202] = BiomeTier.DeepNorth
		};

		private static readonly Dictionary<string, BiomeTier> BaseMaterialBiomes = new Dictionary<string, BiomeTier>(StringComparer.OrdinalIgnoreCase)
		{
			["Wood"] = BiomeTier.Meadows,
			["FineWood"] = BiomeTier.Meadows,
			["Stone"] = BiomeTier.Meadows,
			["Flint"] = BiomeTier.Meadows,
			["Resin"] = BiomeTier.Meadows,
			["Feathers"] = BiomeTier.Meadows,
			["HardAntler"] = BiomeTier.Meadows,
			["LeatherScraps"] = BiomeTier.Meadows,
			["DeerHide"] = BiomeTier.Meadows,
			["RawMeat"] = BiomeTier.Meadows,
			["NeckTail"] = BiomeTier.Meadows,
			["Raspberry"] = BiomeTier.Meadows,
			["Mushroom"] = BiomeTier.Meadows,
			["Dandelion"] = BiomeTier.Meadows,
			["Honey"] = BiomeTier.Meadows,
			["QueenBee"] = BiomeTier.Meadows,
			["BeechSeeds"] = BiomeTier.Meadows,
			["BirchSeeds"] = BiomeTier.Meadows,
			["Acorn"] = BiomeTier.Meadows,
			["AxeHead1"] = BiomeTier.Meadows,
			["AxeHead2"] = BiomeTier.Meadows,
			["BarberKit"] = BiomeTier.Meadows,
			["Ironpit"] = BiomeTier.Meadows,
			["StoneRock"] = BiomeTier.Meadows,
			["Fish1"] = BiomeTier.Meadows,
			["Fish2"] = BiomeTier.Meadows,
			["RoundLog"] = BiomeTier.BlackForest,
			["CopperOre"] = BiomeTier.BlackForest,
			["Copper"] = BiomeTier.BlackForest,
			["CopperScrap"] = BiomeTier.BlackForest,
			["TinOre"] = BiomeTier.BlackForest,
			["Tin"] = BiomeTier.BlackForest,
			["Bronze"] = BiomeTier.BlackForest,
			["BronzeNails"] = BiomeTier.BlackForest,
			["Coal"] = BiomeTier.BlackForest,
			["SurtlingCore"] = BiomeTier.BlackForest,
			["BoneFragments"] = BiomeTier.BlackForest,
			["GreydwarfEye"] = BiomeTier.BlackForest,
			["TrollHide"] = BiomeTier.BlackForest,
			["TrophyForestTroll"] = BiomeTier.BlackForest,
			["BjornHide"] = BiomeTier.BlackForest,
			["BearHide"] = BiomeTier.BlackForest,
			["Blueberries"] = BiomeTier.BlackForest,
			["Thistle"] = BiomeTier.BlackForest,
			["MushroomYellow"] = BiomeTier.BlackForest,
			["Carrot"] = BiomeTier.BlackForest,
			["CarrotSeeds"] = BiomeTier.BlackForest,
			["PineCone"] = BiomeTier.BlackForest,
			["FirCone"] = BiomeTier.BlackForest,
			["CryptKey"] = BiomeTier.BlackForest,
			["YmirRemains"] = BiomeTier.BlackForest,
			["Thunderstone"] = BiomeTier.BlackForest,
			["FishingBait"] = BiomeTier.BlackForest,
			["FireworksRocket_White"] = BiomeTier.BlackForest,
			["Coins"] = BiomeTier.BlackForest,
			["Amber"] = BiomeTier.BlackForest,
			["AmberPearl"] = BiomeTier.BlackForest,
			["Ruby"] = BiomeTier.BlackForest,
			["Fish5"] = BiomeTier.BlackForest,
			["Chitin"] = BiomeTier.Ocean,
			["SerpentScale"] = BiomeTier.Ocean,
			["SerpentMeat"] = BiomeTier.Ocean,
			["Fish3"] = BiomeTier.Ocean,
			["Fish8"] = BiomeTier.Ocean,
			["Fish12"] = BiomeTier.Ocean,
			["IronScrap"] = BiomeTier.Swamp,
			["Iron"] = BiomeTier.Swamp,
			["IronNails"] = BiomeTier.Swamp,
			["ElderBark"] = BiomeTier.Swamp,
			["WitheredBone"] = BiomeTier.Swamp,
			["Guck"] = BiomeTier.Swamp,
			["Chain"] = BiomeTier.Swamp,
			["Root"] = BiomeTier.Swamp,
			["Entrails"] = BiomeTier.Swamp,
			["Ooze"] = BiomeTier.Swamp,
			["Bloodbag"] = BiomeTier.Swamp,
			["Turnip"] = BiomeTier.Swamp,
			["TurnipSeeds"] = BiomeTier.Swamp,
			["Wishbone"] = BiomeTier.Swamp,
			["ScytheHandle"] = BiomeTier.Swamp,
			["BlobVial"] = BiomeTier.Swamp,
			["PungentPebbles"] = BiomeTier.Swamp,
			["FragrantBundle"] = BiomeTier.Swamp,
			["CuredSquirrelHamstring"] = BiomeTier.Swamp,
			["PowderedDragonEgg"] = BiomeTier.Swamp,
			["FreshSeaweed"] = BiomeTier.Swamp,
			["Toadstool"] = BiomeTier.Swamp,
			["MushroomBzerker"] = BiomeTier.Swamp,
			["SpiceForests"] = BiomeTier.Swamp,
			["SpiceOceans"] = BiomeTier.Swamp,
			["HelmetRootCrown"] = BiomeTier.Swamp,
			["BarrelRings"] = BiomeTier.Swamp,
			["CandleWick"] = BiomeTier.Swamp,
			["SilverNecklace"] = BiomeTier.Swamp,
			["Fish6"] = BiomeTier.Swamp,
			["SilverOre"] = BiomeTier.Mountain,
			["Silver"] = BiomeTier.Mountain,
			["Obsidian"] = BiomeTier.Mountain,
			["Crystal"] = BiomeTier.Mountain,
			["FreezeGland"] = BiomeTier.Mountain,
			["WolfPelt"] = BiomeTier.Mountain,
			["WolfFang"] = BiomeTier.Mountain,
			["WolfMeat"] = BiomeTier.Mountain,
			["WolfHairBundle"] = BiomeTier.Mountain,
			["WolfClaw"] = BiomeTier.Mountain,
			["FenrisHair"] = BiomeTier.Mountain,
			["FenrisClaw"] = BiomeTier.Mountain,
			["JuteRed"] = BiomeTier.Mountain,
			["Onion"] = BiomeTier.Mountain,
			["OnionSeeds"] = BiomeTier.Mountain,
			["DragonEgg"] = BiomeTier.Mountain,
			["DragonTear"] = BiomeTier.Mountain,
			["SpiceMountains"] = BiomeTier.Mountain,
			["Fish4_cave"] = BiomeTier.Mountain,
			["BlackMetalScrap"] = BiomeTier.Plains,
			["BlackMetal"] = BiomeTier.Plains,
			["Tar"] = BiomeTier.Plains,
			["Needle"] = BiomeTier.Plains,
			["LoxPelt"] = BiomeTier.Plains,
			["LoxMeat"] = BiomeTier.Plains,
			["Flax"] = BiomeTier.Plains,
			["LinenThread"] = BiomeTier.Plains,
			["Barley"] = BiomeTier.Plains,
			["BarleyFlour"] = BiomeTier.Plains,
			["SpicePlains"] = BiomeTier.Plains,
			["Cloudberry"] = BiomeTier.Plains,
			["GoblinTotem"] = BiomeTier.Plains,
			["YagluthDrop"] = BiomeTier.Plains,
			["ChickenEgg"] = BiomeTier.Plains,
			["ChickenMeat"] = BiomeTier.Plains,
			["Fish7"] = BiomeTier.Plains,
			["YggdrasilWood"] = BiomeTier.Mistlands,
			["BlackMarble"] = BiomeTier.Mistlands,
			["Softtissue"] = BiomeTier.Mistlands,
			["Sap"] = BiomeTier.Mistlands,
			["Eitr"] = BiomeTier.Mistlands,
			["Wisp"] = BiomeTier.Mistlands,
			["BlackCore"] = BiomeTier.Mistlands,
			["Carapace"] = BiomeTier.Mistlands,
			["Mandible"] = BiomeTier.Mistlands,
			["ScaleHide"] = BiomeTier.Mistlands,
			["BloodClot"] = BiomeTier.Mistlands,
			["Bilebag"] = BiomeTier.Mistlands,
			["RoyalJelly"] = BiomeTier.Mistlands,
			["JuteBlue"] = BiomeTier.Mistlands,
			["Hook"] = BiomeTier.Mistlands,
			["DvergrNeedle"] = BiomeTier.Mistlands,
			["DvergrKeyFragment"] = BiomeTier.Mistlands,
			["DvergrKey"] = BiomeTier.Mistlands,
			["MechanicalSpring"] = BiomeTier.Mistlands,
			["Lantern"] = BiomeTier.Mistlands,
			["QueenDrop"] = BiomeTier.Mistlands,
			["BugMeat"] = BiomeTier.Mistlands,
			["HareMeat"] = BiomeTier.Mistlands,
			["MushroomJotunPuffs"] = BiomeTier.Mistlands,
			["MushroomMagecap"] = BiomeTier.Mistlands,
			["SpiceMistlands"] = BiomeTier.Mistlands,
			["Fish9"] = BiomeTier.Mistlands,
			["Blackwood"] = BiomeTier.Ashlands,
			["Grausten"] = BiomeTier.Ashlands,
			["FlametalOreNew"] = BiomeTier.Ashlands,
			["FlametalNew"] = BiomeTier.Ashlands,
			["FlametalOre"] = BiomeTier.Ashlands,
			["Flametal"] = BiomeTier.Ashlands,
			["MoltenCore"] = BiomeTier.Ashlands,
			["BellFragment"] = BiomeTier.Ashlands,
			["Bell"] = BiomeTier.Ashlands,
			["ShieldCore"] = BiomeTier.Ashlands,
			["FaderDrop"] = BiomeTier.Ashlands,
			["FaderEmber"] = BiomeTier.Ashlands,
			["GemstoneRed"] = BiomeTier.Ashlands,
			["GemstoneBlue"] = BiomeTier.Ashlands,
			["GemstoneGreen"] = BiomeTier.Ashlands,
			["SulfurStone"] = BiomeTier.Ashlands,
			["Sulfur"] = BiomeTier.Ashlands,
			["CharcoalResin"] = BiomeTier.Ashlands,
			["ProustitePowder"] = BiomeTier.Ashlands,
			["CharredBone"] = BiomeTier.Ashlands,
			["Charredskull"] = BiomeTier.Ashlands,
			["CharredCogwheel"] = BiomeTier.Ashlands,
			["Pot_Shard_Green"] = BiomeTier.Ashlands,
			["AskHide"] = BiomeTier.Ashlands,
			["AskBladder"] = BiomeTier.Ashlands,
			["AsksvinNeck"] = BiomeTier.Ashlands,
			["AsksvinPelvis"] = BiomeTier.Ashlands,
			["AsksvinRibcage"] = BiomeTier.Ashlands,
			["AsksvinSkull"] = BiomeTier.Ashlands,
			["AsksvinCarrionNeck"] = BiomeTier.Ashlands,
			["AsksvinCarrionPelvic"] = BiomeTier.Ashlands,
			["AsksvinCarrionRibcage"] = BiomeTier.Ashlands,
			["AsksvinCarrionSkull"] = BiomeTier.Ashlands,
			["MorgenHeart"] = BiomeTier.Ashlands,
			["MorgenSinew"] = BiomeTier.Ashlands,
			["BonemawSerpentTooth"] = BiomeTier.Ashlands,
			["BonemawTooth"] = BiomeTier.Ashlands,
			["CelestialFeather"] = BiomeTier.Ashlands,
			["Fiddlehead"] = BiomeTier.Ashlands,
			["Fiddleheadfern"] = BiomeTier.Ashlands,
			["SmokePuff"] = BiomeTier.Ashlands,
			["MushroomSmokePuff"] = BiomeTier.Ashlands,
			["Vineberry"] = BiomeTier.Ashlands,
			["VineberryCluster"] = BiomeTier.Ashlands,
			["VineberrySeeds"] = BiomeTier.Ashlands,
			["VoltureMeat"] = BiomeTier.Ashlands,
			["AsksvinMeat"] = BiomeTier.Ashlands,
			["BonemawSerpentMeat"] = BiomeTier.Ashlands,
			["DyrnwynBladeFragment"] = BiomeTier.Ashlands,
			["DyrnwynHiltFragment"] = BiomeTier.Ashlands,
			["DyrnwynTipFragment"] = BiomeTier.Ashlands,
			["SpiceAshlands"] = BiomeTier.Ashlands,
			["Fish11"] = BiomeTier.Ashlands,
			["Frostwood"] = BiomeTier.DeepNorth,
			["Ice"] = BiomeTier.DeepNorth,
			["LiquidFrost"] = BiomeTier.DeepNorth,
			["FrostCore"] = BiomeTier.DeepNorth,
			["GoldOre"] = BiomeTier.DeepNorth,
			["Gold"] = BiomeTier.DeepNorth,
			["NornThread"] = BiomeTier.DeepNorth,
			["OrbFrostFire"] = BiomeTier.DeepNorth,
			["OrbThunderBlood"] = BiomeTier.DeepNorth,
			["AncientGemstoneOrange"] = BiomeTier.DeepNorth,
			["AncientGemstoneGreen"] = BiomeTier.DeepNorth,
			["AncientGemstonePurple"] = BiomeTier.DeepNorth,
			["AncientGemstoneBlack"] = BiomeTier.DeepNorth,
			["Lingonberry"] = BiomeTier.DeepNorth,
			["Kale"] = BiomeTier.DeepNorth,
			["KaleSeeds"] = BiomeTier.DeepNorth,
			["Poteitr"] = BiomeTier.DeepNorth,
			["Oat"] = BiomeTier.DeepNorth,
			["OatSeeds"] = BiomeTier.DeepNorth,
			["OatFlour"] = BiomeTier.DeepNorth,
			["Snowball"] = BiomeTier.DeepNorth,
			["SealBlubber"] = BiomeTier.DeepNorth,
			["MooseHide"] = BiomeTier.DeepNorth,
			["MooseMeat"] = BiomeTier.DeepNorth,
			["GlowWorm"] = BiomeTier.DeepNorth,
			["SpiceDeepNorth"] = BiomeTier.DeepNorth,
			["Fish10"] = BiomeTier.DeepNorth,
			["AtgeirGold"] = BiomeTier.DeepNorth,
			["AxeGold"] = BiomeTier.DeepNorth,
			["BattleaxeGold"] = BiomeTier.DeepNorth,
			["BowGold"] = BiomeTier.DeepNorth,
			["CrossbowGold"] = BiomeTier.DeepNorth,
			["FistGold"] = BiomeTier.DeepNorth,
			["KnifeGold"] = BiomeTier.DeepNorth,
			["MaceGold"] = BiomeTier.DeepNorth,
			["SledgeGold"] = BiomeTier.DeepNorth,
			["SpearGold"] = BiomeTier.DeepNorth,
			["SwordGold"] = BiomeTier.DeepNorth,
			["THSwordGold"] = BiomeTier.DeepNorth,
			["ShieldGold"] = BiomeTier.DeepNorth,
			["ShieldGoldBuckler"] = BiomeTier.DeepNorth,
			["ShieldGoldTower"] = BiomeTier.DeepNorth,
			["HelmetDNHeavy"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthHeavyChest"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthHeavylegs"] = BiomeTier.DeepNorth,
			["HelmetDNMediumHood"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthMediumChest"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthMediumlegs"] = BiomeTier.DeepNorth,
			["HelmetDNMage"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthMageChest"] = BiomeTier.DeepNorth,
			["ArmorDeepNorthMagelegs"] = BiomeTier.DeepNorth,
			["StaffFrostOrbs"] = BiomeTier.DeepNorth,
			["StaffThunderBlood"] = BiomeTier.DeepNorth,
			["StaffOrbofAhri"] = BiomeTier.DeepNorth,
			["StaffSpiritCaller"] = BiomeTier.DeepNorth
		};

		private static readonly Dictionary<string, BiomeTier[]> StationLevelBiomes = new Dictionary<string, BiomeTier[]>(StringComparer.OrdinalIgnoreCase)
		{
			["$piece_workbench"] = new BiomeTier[5]
			{
				BiomeTier.Meadows,
				BiomeTier.Meadows,
				BiomeTier.Meadows,
				BiomeTier.BlackForest,
				BiomeTier.Mountain
			},
			["$piece_forge"] = new BiomeTier[7]
			{
				BiomeTier.BlackForest,
				BiomeTier.BlackForest,
				BiomeTier.BlackForest,
				BiomeTier.Swamp,
				BiomeTier.Swamp,
				BiomeTier.Swamp,
				BiomeTier.Mountain
			},
			["$piece_cauldron"] = new BiomeTier[7]
			{
				BiomeTier.BlackForest,
				BiomeTier.Swamp,
				BiomeTier.Mountain,
				BiomeTier.Plains,
				BiomeTier.Mistlands,
				BiomeTier.Ashlands,
				BiomeTier.DeepNorth
			},
			["$piece_meadcauldron"] = new BiomeTier[1] { BiomeTier.BlackForest },
			["$piece_preptable"] = new BiomeTier[1] { BiomeTier.Swamp },
			["$piece_artisanstation"] = new BiomeTier[1] { BiomeTier.Mountain },
			["$piece_blackforge"] = new BiomeTier[5]
			{
				BiomeTier.Mistlands,
				BiomeTier.Mistlands,
				BiomeTier.Ashlands,
				BiomeTier.Ashlands,
				BiomeTier.DeepNorth
			},
			["$piece_magetable"] = new BiomeTier[4]
			{
				BiomeTier.Mistlands,
				BiomeTier.Mistlands,
				BiomeTier.Ashlands,
				BiomeTier.DeepNorth
			}
		};

		private static readonly Dictionary<string, BiomeTier> CookingStationBiomes = new Dictionary<string, BiomeTier>(StringComparer.OrdinalIgnoreCase)
		{
			["piece_cookingstation"] = BiomeTier.Meadows,
			["piece_cookingstation_iron"] = BiomeTier.Swamp,
			["piece_oven"] = BiomeTier.Mountain
		};

		public static void ResetCache()
		{
			EnemyBiomeByName.Clear();
			DerivedMaterialBiomes.Clear();
			RecipeBySharedName.Clear();
			CookingSourcesBySharedName.Clear();
			PieceByName.Clear();
			PrefabNameBySharedName.Clear();
			ItemBiomeCache.Clear();
			PieceBiomeCache.Clear();
			TreeBiomeByStat.Clear();
			LoggedSummaryKeys.Clear();
			_enemyIndexBuilt = false;
			_itemIndexBuilt = false;
			_cookingIndexBuilt = false;
			_pieceIndexBuilt = false;
			_treeIndexBuilt = false;
		}

		public static BiomeTier GetEnemyBiome(string enemySharedName)
		{
			if (string.IsNullOrEmpty(enemySharedName))
			{
				return BiomeTier.Uncategorized;
			}
			if (EnemyBiomeOverrides.TryGetValue(enemySharedName, out var value))
			{
				return value;
			}
			EnsureEnemyIndexBuilt();
			if (!EnemyBiomeByName.TryGetValue(enemySharedName, out var value2))
			{
				return BiomeTier.Uncategorized;
			}
			return value2;
		}

		public static BiomeTier GetItemBiome(string sharedName)
		{
			if (string.IsNullOrEmpty(sharedName))
			{
				return BiomeTier.Uncategorized;
			}
			EnsureEnemyIndexBuilt();
			EnsureItemIndexBuilt();
			EnsureCookingIndexBuilt();
			if (ItemBiomeCache.TryGetValue(sharedName, out var value))
			{
				return value;
			}
			HashSet<string> visiting = new HashSet<string>(StringComparer.Ordinal);
			BiomeTier biomeTier = ResolveItemBiome(sharedName, visiting);
			ItemBiomeCache[sharedName] = biomeTier;
			return biomeTier;
		}

		public static BiomeTier GetPieceBiome(string pieceName)
		{
			if (string.IsNullOrEmpty(pieceName))
			{
				return BiomeTier.Uncategorized;
			}
			EnsureEnemyIndexBuilt();
			EnsureItemIndexBuilt();
			EnsureCookingIndexBuilt();
			EnsurePieceIndexBuilt();
			if (PieceBiomeCache.TryGetValue(pieceName, out var value))
			{
				return value;
			}
			if (!PieceByName.TryGetValue(pieceName, out Piece value2) || (Object)(object)value2 == (Object)null)
			{
				PieceBiomeCache[pieceName] = BiomeTier.Uncategorized;
				return BiomeTier.Uncategorized;
			}
			HashSet<string> visiting = new HashSet<string>(StringComparer.Ordinal);
			BiomeTier biomeTier = ResolvePieceBiome(value2, visiting);
			PieceBiomeCache[pieceName] = biomeTier;
			return biomeTier;
		}

		public static BiomeTier GetTreeStatBiome(PlayerStatType stat)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			EnsureTreeIndexBuilt();
			if (TreeBiomeByStat.TryGetValue(stat, out var value))
			{
				return value;
			}
			if (!TreeStatBiomes.TryGetValue(stat, out var value2))
			{
				return BiomeTier.Uncategorized;
			}
			return value2;
		}

		private static BiomeTier ResolvePieceBiome(Piece piece, HashSet<string> visiting)
		{
			if ((Object)(object)piece == (Object)null)
			{
				return BiomeTier.Uncategorized;
			}
			string text = ((!string.IsNullOrEmpty(piece.m_name)) ? piece.m_name : ((Object)piece).name);
			if (PieceBiomeCache.TryGetValue(text, out var value))
			{
				return value;
			}
			string item = "piece:" + text;
			if (!visiting.Add(item))
			{
				return BiomeTier.Uncategorized;
			}
			try
			{
				BiomeTier biomeTier = BiomeTier.Meadows;
				bool flag = false;
				if (piece.m_resources != null)
				{
					Requirement[] resources = piece.m_resources;
					foreach (Requirem