Decompiled source of Vandi v1.1.1

plugins/Vandi/Vandi.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Ezomic.Core;
using Ezomic.Shared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Thijssen Software")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 Robbin Thijssen")]
[assembly: AssemblyDescription("Creatures wear more stars in a biome whose boss you keep killing, and that boss comes back harder.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+f21fb7122757850d90dee8d665444800f3e7c3db")]
[assembly: AssemblyProduct("Vandi")]
[assembly: AssemblyTitle("Vandi")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 Ezomic.Shared
{
	public static class BiomeIndex
	{
		private struct Placement
		{
			public int Index;

			public int Confidence;
		}

		private static ManualLogSource _log;

		public static Func<string, string> BiomeForKey;

		public static Func<string> Overrides;

		public static string OverrideSetting = "BiomeOverrides";

		public const string None = "none";

		public const string Everything = "all";

		private static readonly KeyValuePair<string, Biome>[] Ordered = new KeyValuePair<string, Biome>[9]
		{
			new KeyValuePair<string, Biome>("meadows", (Biome)1),
			new KeyValuePair<string, Biome>("blackforest", (Biome)8),
			new KeyValuePair<string, Biome>("ocean", (Biome)256),
			new KeyValuePair<string, Biome>("swamp", (Biome)2),
			new KeyValuePair<string, Biome>("mountain", (Biome)4),
			new KeyValuePair<string, Biome>("plains", (Biome)16),
			new KeyValuePair<string, Biome>("mistlands", (Biome)512),
			new KeyValuePair<string, Biome>("ashlands", (Biome)32),
			new KeyValuePair<string, Biome>("deepnorth", (Biome)64)
		};

		public static readonly string[] All = BuildNames();

		private const int Guessed = 0;

		private const int Derived = 1;

		private const int Pinned = 2;

		private static Dictionary<string, Placement> _biomeOf;

		private static bool _complete;

		private const int MaxClosurePasses = 12;

		private const int MaxFallbackRounds = 4;

		public static ManualLogSource Log
		{
			get
			{
				return _log ?? (_log = Logger.CreateLogSource("BiomeIndex"));
			}
			set
			{
				_log = value;
			}
		}

		public static bool Complete => _complete;

		public static int Count
		{
			get
			{
				if (_biomeOf != null)
				{
					return _biomeOf.Count;
				}
				return 0;
			}
		}

		private static string BossBiome(string globalKey)
		{
			return BiomeForKey?.Invoke(globalKey);
		}

		private static string[] BuildNames()
		{
			string[] array = new string[Ordered.Length + 1];
			for (int i = 0; i < Ordered.Length; i++)
			{
				array[i] = Ordered[i].Key;
			}
			array[Ordered.Length] = "none";
			return array;
		}

		public static void Invalidate()
		{
			_biomeOf = null;
			_complete = false;
		}

		public static string BiomeOf(string prefabName)
		{
			if (_biomeOf != null && _biomeOf.TryGetValue(prefabName, out var value))
			{
				return Ordered[value.Index].Key;
			}
			return "none";
		}

		public static void Prepare()
		{
			Build();
		}

		private static void Build()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (_complete && _biomeOf != null)
			{
				return;
			}
			ZoneSystem instance = ZoneSystem.instance;
			SpawnSystem val = Object.FindObjectOfType<SpawnSystem>();
			ZNetScene instance2 = ZNetScene.instance;
			Dictionary<string, Placement> dictionary = new Dictionary<string, Placement>();
			if ((Object)(object)instance != (Object)null && instance.m_vegetation != null)
			{
				foreach (ZoneVegetation item in instance.m_vegetation)
				{
					if (item != null && item.m_enable)
					{
						Harvest(dictionary, item.m_prefab, Earliest(item.m_biome));
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				HarvestSpawnLists(dictionary, val);
			}
			if ((Object)(object)instance2 != (Object)null && instance2.m_prefabs != null)
			{
				Bosses(dictionary, instance2);
			}
			ApplyOverrides(dictionary);
			List<string> guesses = new List<string>();
			for (int i = 0; i < 4; i++)
			{
				int deferred = 0;
				for (int j = 0; j < 12; j++)
				{
					bool flag = Craft(dictionary, permissive: false, out deferred, null);
					if ((Object)(object)instance2 != (Object)null && instance2.m_prefabs != null)
					{
						flag |= Convert(dictionary, instance2);
					}
					if (!flag)
					{
						break;
					}
				}
				if (deferred == 0 || !Craft(dictionary, permissive: true, out var _, guesses))
				{
					break;
				}
			}
			ApplyOverrides(dictionary);
			_biomeOf = dictionary;
			_complete = (Object)(object)instance != (Object)null && (Object)(object)val != (Object)null && (Object)(object)instance2 != (Object)null;
			if (_complete)
			{
				Log.LogInfo((object)("Biome index built: " + dictionary.Count + " item(s) placed."));
				ReportGuesses(dictionary, guesses);
				return;
			}
			List<string> list = new List<string>();
			if ((Object)(object)instance == (Object)null)
			{
				list.Add("ZoneSystem");
			}
			if ((Object)(object)val == (Object)null)
			{
				list.Add("SpawnSystem");
			}
			if ((Object)(object)instance2 == (Object)null)
			{
				list.Add("ZNetScene");
			}
			Log.LogInfo((object)("Biome index partial: " + dictionary.Count + " item(s) placed, still waiting on " + string.Join(" and ", list.ToArray()) + "."));
		}

		private static void ReportGuesses(Dictionary<string, Placement> found, List<string> guesses)
		{
			if (guesses == null || guesses.Count == 0)
			{
				return;
			}
			List<string> list = new List<string>(guesses.Count);
			foreach (string guess in guesses)
			{
				if (found.TryGetValue(guess, out var value) && value.Confidence == 0)
				{
					list.Add(guess);
				}
			}
			if (list.Count != 0)
			{
				list.Sort(StringComparer.Ordinal);
				Log.LogWarning((object)("Biome index: " + list.Count + " item(s) classified from an INCOMPLETE ingredient list, because the closure could not place everything their recipe asks for. Their biome is a best guess and " + OverrideSetting + " is the cure: " + string.Join(", ", list.ToArray()) + "."));
			}
		}

		private static void HarvestSpawnLists(Dictionary<string, Placement> found, SpawnSystem spawn)
		{
			if (spawn.m_spawnLists == null)
			{
				return;
			}
			HashSet<string> hashSet = new HashSet<string>();
			foreach (SpawnSystemList spawnList in spawn.m_spawnLists)
			{
				if ((Object)(object)spawnList == (Object)null || spawnList.m_spawners == null)
				{
					continue;
				}
				foreach (SpawnData spawner in spawnList.m_spawners)
				{
					if (Runs(spawner) && !Conditional(spawner))
					{
						hashSet.Add(((Object)spawner.m_prefab).name);
					}
				}
			}
			foreach (SpawnSystemList spawnList2 in spawn.m_spawnLists)
			{
				if ((Object)(object)spawnList2 == (Object)null || spawnList2.m_spawners == null)
				{
					continue;
				}
				foreach (SpawnData spawner2 in spawnList2.m_spawners)
				{
					if (Runs(spawner2))
					{
						Harvest(found, spawner2.m_prefab, SpawnIndex(spawner2, hashSet));
					}
				}
			}
		}

		private static bool Runs(SpawnData row)
		{
			if (row != null && row.m_enabled && !row.m_devDisabled)
			{
				return (Object)(object)row.m_prefab != (Object)null;
			}
			return false;
		}

		private static bool Conditional(SpawnData row)
		{
			if (string.IsNullOrEmpty(row.m_requiredGlobalKey) && string.IsNullOrEmpty(row.m_requiredPersistentEvent))
			{
				if (row.m_requiredEnvironments != null)
				{
					return row.m_requiredEnvironments.Count > 0;
				}
				return false;
			}
			return true;
		}

		private static int SpawnIndex(SpawnData row, HashSet<string> unconditional)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			int num = Earliest(row.m_biome);
			if (num < 0)
			{
				return -1;
			}
			if (!string.IsNullOrEmpty(row.m_requiredPersistentEvent))
			{
				return -1;
			}
			if (!Conditional(row))
			{
				return num;
			}
			if (unconditional.Contains(((Object)row.m_prefab).name))
			{
				return -1;
			}
			string requiredGlobalKey = row.m_requiredGlobalKey;
			if (string.IsNullOrEmpty(requiredGlobalKey))
			{
				return num;
			}
			string text = BossBiome(requiredGlobalKey);
			if (text == null)
			{
				return num;
			}
			int num2 = IndexOf(text);
			if (num2 < 0)
			{
				return num;
			}
			if (num <= num2)
			{
				return num2;
			}
			return num;
		}

		private static void Harvest(Dictionary<string, Placement> found, GameObject prefab, int index)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null || index < 0)
			{
				return;
			}
			Pickable[] componentsInChildren = prefab.GetComponentsInChildren<Pickable>(true);
			foreach (Pickable val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null)
				{
					Record(found, val.m_itemPrefab, index, 1);
				}
			}
			PickableItem[] componentsInChildren2 = prefab.GetComponentsInChildren<PickableItem>(true);
			foreach (PickableItem val2 in componentsInChildren2)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				if ((Object)(object)val2.m_itemPrefab != (Object)null)
				{
					Record(found, ((Component)val2.m_itemPrefab).gameObject, index, 1);
				}
				if (val2.m_randomItemPrefabs == null)
				{
					continue;
				}
				RandomItem[] randomItemPrefabs = val2.m_randomItemPrefabs;
				foreach (RandomItem val3 in randomItemPrefabs)
				{
					if ((Object)(object)val3.m_itemPrefab != (Object)null)
					{
						Record(found, ((Component)val3.m_itemPrefab).gameObject, index, 1);
					}
				}
			}
			MineRock5[] componentsInChildren3 = prefab.GetComponentsInChildren<MineRock5>(true);
			foreach (MineRock5 val4 in componentsInChildren3)
			{
				if ((Object)(object)val4 != (Object)null)
				{
					Record(found, val4.m_dropItems, index, 1);
				}
			}
			MineRock[] componentsInChildren4 = prefab.GetComponentsInChildren<MineRock>(true);
			foreach (MineRock val5 in componentsInChildren4)
			{
				if ((Object)(object)val5 != (Object)null)
				{
					Record(found, val5.m_dropItems, index, 1);
				}
			}
			DropOnDestroyed[] componentsInChildren5 = prefab.GetComponentsInChildren<DropOnDestroyed>(true);
			foreach (DropOnDestroyed val6 in componentsInChildren5)
			{
				if ((Object)(object)val6 != (Object)null)
				{
					Record(found, val6.m_dropWhenDestroyed, index, 1);
				}
			}
			LootSpawner[] componentsInChildren6 = prefab.GetComponentsInChildren<LootSpawner>(true);
			foreach (LootSpawner val7 in componentsInChildren6)
			{
				if ((Object)(object)val7 != (Object)null)
				{
					Record(found, val7.m_items, index, 1);
				}
			}
			Container[] componentsInChildren7 = prefab.GetComponentsInChildren<Container>(true);
			foreach (Container val8 in componentsInChildren7)
			{
				if ((Object)(object)val8 != (Object)null)
				{
					Record(found, val8.m_defaultItems, index, 1);
				}
			}
			CharacterDrop[] componentsInChildren8 = prefab.GetComponentsInChildren<CharacterDrop>(true);
			foreach (CharacterDrop drop in componentsInChildren8)
			{
				RecordDrops(found, drop, index);
			}
			SpawnArea[] componentsInChildren9 = prefab.GetComponentsInChildren<SpawnArea>(true);
			foreach (SpawnArea val9 in componentsInChildren9)
			{
				if ((Object)(object)val9 == (Object)null || val9.m_prefabs == null)
				{
					continue;
				}
				foreach (SpawnData prefab2 in val9.m_prefabs)
				{
					if (prefab2 != null && !((Object)(object)prefab2.m_prefab == (Object)null))
					{
						componentsInChildren8 = prefab2.m_prefab.GetComponentsInChildren<CharacterDrop>(true);
						foreach (CharacterDrop drop2 in componentsInChildren8)
						{
							RecordDrops(found, drop2, index);
						}
					}
				}
			}
			Plant[] componentsInChildren10 = prefab.GetComponentsInChildren<Plant>(true);
			foreach (Plant val10 in componentsInChildren10)
			{
				if ((Object)(object)val10 == (Object)null || val10.m_grownPrefabs == null)
				{
					continue;
				}
				GameObject[] grownPrefabs = val10.m_grownPrefabs;
				foreach (GameObject val11 in grownPrefabs)
				{
					if ((Object)(object)val11 == (Object)null)
					{
						continue;
					}
					componentsInChildren = val11.GetComponentsInChildren<Pickable>(true);
					foreach (Pickable val12 in componentsInChildren)
					{
						if ((Object)(object)val12 != (Object)null)
						{
							Record(found, val12.m_itemPrefab, index, 1);
						}
					}
					componentsInChildren8 = val11.GetComponentsInChildren<CharacterDrop>(true);
					foreach (CharacterDrop drop3 in componentsInChildren8)
					{
						RecordDrops(found, drop3, index);
					}
				}
			}
			TreeBase[] componentsInChildren11 = prefab.GetComponentsInChildren<TreeBase>(true);
			foreach (TreeBase val13 in componentsInChildren11)
			{
				if ((Object)(object)val13 == (Object)null)
				{
					continue;
				}
				Record(found, val13.m_dropWhenDestroyed, index, 1);
				if ((Object)(object)val13.m_stubPrefab != (Object)null)
				{
					componentsInChildren5 = val13.m_stubPrefab.GetComponentsInChildren<DropOnDestroyed>(true);
					foreach (DropOnDestroyed val14 in componentsInChildren5)
					{
						if ((Object)(object)val14 != (Object)null)
						{
							Record(found, val14.m_dropWhenDestroyed, index, 1);
						}
					}
				}
				HarvestLogChain(found, val13.m_logPrefab, index);
			}
		}

		private static void HarvestLogChain(Dictionary<string, Placement> found, GameObject log, int index)
		{
			if ((Object)(object)log == (Object)null)
			{
				return;
			}
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			Queue<GameObject> queue = new Queue<GameObject>();
			queue.Enqueue(log);
			while (queue.Count > 0)
			{
				GameObject val = queue.Dequeue();
				if ((Object)(object)val == (Object)null || !hashSet.Add(val))
				{
					continue;
				}
				TreeLog[] componentsInChildren = val.GetComponentsInChildren<TreeLog>(true);
				foreach (TreeLog val2 in componentsInChildren)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						Record(found, val2.m_dropWhenDestroyed, index, 1);
						if ((Object)(object)val2.m_subLogPrefab != (Object)null)
						{
							queue.Enqueue(val2.m_subLogPrefab);
						}
					}
				}
			}
		}

		private static void RecordDrops(Dictionary<string, Placement> found, CharacterDrop drop, int index)
		{
			if ((Object)(object)drop == (Object)null || drop.m_drops == null)
			{
				return;
			}
			foreach (Drop drop2 in drop.m_drops)
			{
				if (drop2 != null)
				{
					Record(found, drop2.m_prefab, index, 1);
				}
			}
		}

		private static bool Convert(Dictionary<string, Placement> found, ZNetScene scene)
		{
			bool flag = false;
			foreach (GameObject prefab in scene.m_prefabs)
			{
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				Smelter component = prefab.GetComponent<Smelter>();
				if ((Object)(object)component != (Object)null && component.m_conversion != null)
				{
					foreach (ItemConversion item in component.m_conversion)
					{
						flag |= Inherit(found, item.m_from, item.m_to);
					}
				}
				CookingStation component2 = prefab.GetComponent<CookingStation>();
				if ((Object)(object)component2 != (Object)null && component2.m_conversion != null)
				{
					foreach (ItemConversion item2 in component2.m_conversion)
					{
						flag |= Inherit(found, item2.m_from, item2.m_to);
					}
				}
				Fermenter component3 = prefab.GetComponent<Fermenter>();
				if (!((Object)(object)component3 != (Object)null) || component3.m_conversion == null)
				{
					continue;
				}
				foreach (ItemConversion item3 in component3.m_conversion)
				{
					flag |= Inherit(found, item3.m_from, item3.m_to);
				}
			}
			return flag;
		}

		private static void Bosses(Dictionary<string, Placement> found, ZNetScene scene)
		{
			foreach (GameObject prefab in scene.m_prefabs)
			{
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				Character component = prefab.GetComponent<Character>();
				if ((Object)(object)component == (Object)null || string.IsNullOrEmpty(component.m_defeatSetGlobalKey))
				{
					continue;
				}
				string text = BossBiome(component.m_defeatSetGlobalKey);
				if (text == null)
				{
					continue;
				}
				int num = IndexOf(text);
				if (num >= 0)
				{
					CharacterDrop[] componentsInChildren = prefab.GetComponentsInChildren<CharacterDrop>(true);
					foreach (CharacterDrop drop in componentsInChildren)
					{
						RecordDrops(found, drop, num);
					}
				}
			}
		}

		private static int IndexOf(string biome)
		{
			for (int i = 0; i < Ordered.Length; i++)
			{
				if (Ordered[i].Key == biome)
				{
					return i;
				}
			}
			return -1;
		}

		private static bool Craft(Dictionary<string, Placement> found, bool permissive, out int deferred, List<string> guesses)
		{
			deferred = 0;
			ObjectDB instance = ObjectDB.instance;
			if ((Object)(object)instance == (Object)null || instance.m_recipes == null)
			{
				return false;
			}
			bool result = false;
			foreach (Recipe recipe in instance.m_recipes)
			{
				if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null || recipe.m_resources == null || (Object)(object)((Component)recipe.m_item).gameObject == (Object)null)
				{
					continue;
				}
				int num = 0;
				int num2 = 0;
				int num3 = -1;
				int num4 = int.MaxValue;
				int num5 = 1;
				Requirement[] resources = recipe.m_resources;
				foreach (Requirement val in resources)
				{
					if (val == null || (Object)(object)val.m_resItem == (Object)null || (Object)(object)((Component)val.m_resItem).gameObject == (Object)null)
					{
						continue;
					}
					num++;
					if (found.TryGetValue(((Object)((Component)val.m_resItem).gameObject).name, out var value))
					{
						num2++;
						if (value.Index > num3)
						{
							num3 = value.Index;
						}
						if (value.Index < num4)
						{
							num4 = value.Index;
						}
						if (value.Confidence < num5)
						{
							num5 = value.Confidence;
						}
					}
				}
				if (num2 == 0)
				{
					continue;
				}
				bool requireOnlyOneIngredient = recipe.m_requireOnlyOneIngredient;
				int index = (requireOnlyOneIngredient ? num4 : num3);
				bool flag = false;
				if (!requireOnlyOneIngredient && num2 < num)
				{
					deferred++;
					if (!permissive)
					{
						continue;
					}
					num5 = 0;
					flag = true;
				}
				if (Record(found, ((Object)((Component)recipe.m_item).gameObject).name, index, num5))
				{
					result = true;
					if (flag && guesses != null && !guesses.Contains(((Object)((Component)recipe.m_item).gameObject).name))
					{
						guesses.Add(((Object)((Component)recipe.m_item).gameObject).name);
					}
				}
			}
			return result;
		}

		private static bool Inherit(Dictionary<string, Placement> found, ItemDrop from, ItemDrop to)
		{
			if ((Object)(object)from == (Object)null || (Object)(object)to == (Object)null || (Object)(object)((Component)from).gameObject == (Object)null || (Object)(object)((Component)to).gameObject == (Object)null)
			{
				return false;
			}
			if (!found.TryGetValue(((Object)((Component)from).gameObject).name, out var value))
			{
				return false;
			}
			int confidence = ((value.Confidence >= 1) ? 1 : value.Confidence);
			return Record(found, ((Object)((Component)to).gameObject).name, value.Index, confidence);
		}

		private static void ApplyOverrides(Dictionary<string, Placement> found)
		{
			string[] array = (Overrides?.Invoke() ?? "").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0)
				{
					continue;
				}
				string[] array2 = text.Split(new char[1] { ':' });
				if (array2.Length != 2)
				{
					Log.LogWarning((object)("Ignoring biome override '" + text + "': expected prefab:biome."));
					continue;
				}
				string text2 = array2[1].Trim().ToLowerInvariant();
				int num = IndexOf(text2);
				if (num < 0)
				{
					Log.LogWarning((object)("Ignoring biome override '" + text + "': '" + text2 + "' is not a biome."));
				}
				else
				{
					found[array2[0].Trim()] = new Placement
					{
						Index = num,
						Confidence = 2
					};
				}
			}
		}

		private static void Record(Dictionary<string, Placement> found, DropTable table, int index, int confidence)
		{
			//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_0022: 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)
			if (table == null || table.m_drops == null)
			{
				return;
			}
			foreach (DropData drop in table.m_drops)
			{
				if ((Object)(object)drop.m_item != (Object)null)
				{
					Record(found, ((Object)drop.m_item).name, index, confidence);
				}
			}
		}

		private static void Record(Dictionary<string, Placement> found, GameObject prefab, int index, int confidence)
		{
			if ((Object)(object)prefab != (Object)null)
			{
				Record(found, ((Object)prefab).name, index, confidence);
			}
		}

		private static bool Record(Dictionary<string, Placement> found, string prefabName, int index, int confidence)
		{
			if (string.IsNullOrEmpty(prefabName) || index < 0 || index >= Ordered.Length)
			{
				return false;
			}
			if (found.TryGetValue(prefabName, out var value))
			{
				if (confidence < value.Confidence)
				{
					return false;
				}
				if (confidence == value.Confidence && index >= value.Index)
				{
					return false;
				}
			}
			found[prefabName] = new Placement
			{
				Index = index,
				Confidence = confidence
			};
			return true;
		}

		private static int Earliest(Biome mask)
		{
			//IL_0004: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Ordered.Length; i++)
			{
				if ((mask & Ordered[i].Value) != 0)
				{
					return i;
				}
			}
			return -1;
		}
	}
}
namespace Vandi
{
	internal static class Bosses
	{
		internal sealed class Boss
		{
			internal string Key;

			internal List<Biome> Biomes = new List<Biome>();
		}

		private static Dictionary<Biome, List<string>> _byBiome;

		private static string _parsedFrom;

		private static Dictionary<string, string> _firstBiome;

		internal static readonly Biome[] Order;

		private static ZNetScene _namesFor;

		private static readonly Dictionary<string, string> Names;

		private static readonly Dictionary<string, string> Tokens;

		internal static List<string> For(Biome biome)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Parse();
			if (!_byBiome.TryGetValue(biome, out var value))
			{
				return null;
			}
			return value;
		}

		internal static string BiomeNameFor(string key)
		{
			if (string.IsNullOrEmpty(key))
			{
				return null;
			}
			Parse();
			if (!_firstBiome.TryGetValue(key.ToLowerInvariant(), out var value))
			{
				return null;
			}
			return value;
		}

		internal static bool IsBossKey(string key)
		{
			if (string.IsNullOrEmpty(key))
			{
				return false;
			}
			Parse();
			foreach (KeyValuePair<Biome, List<string>> item in _byBiome)
			{
				if (item.Value.Contains(key))
				{
					return true;
				}
			}
			return false;
		}

		internal static string KeyOf(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return null;
			}
			string defeatSetGlobalKey = character.m_defeatSetGlobalKey;
			if (!string.IsNullOrEmpty(defeatSetGlobalKey))
			{
				return defeatSetGlobalKey.ToLowerInvariant();
			}
			return null;
		}

		internal static string KeyOf(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			Character component = prefab.GetComponent<Character>();
			if (!((Object)(object)component == (Object)null))
			{
				return KeyOf(component);
			}
			return null;
		}

		internal static List<Boss> Roster()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Parse();
			List<Boss> list = new List<Boss>();
			Dictionary<string, Boss> dictionary = new Dictionary<string, Boss>();
			List<Biome> list2 = new List<Biome>(Order);
			foreach (Biome key in _byBiome.Keys)
			{
				if (!list2.Contains(key))
				{
					list2.Add(key);
				}
			}
			foreach (Biome item in list2)
			{
				if (!_byBiome.TryGetValue(item, out var value))
				{
					continue;
				}
				foreach (string item2 in value)
				{
					if (!dictionary.TryGetValue(item2, out var value2))
					{
						value2 = (dictionary[item2] = new Boss
						{
							Key = item2
						});
						list.Add(value2);
					}
					value2.Biomes.Add(item);
				}
			}
			return list;
		}

		internal static string TokenOf(string key)
		{
			NameOf(key);
			if (!Tokens.TryGetValue(key ?? "", out var value))
			{
				return null;
			}
			return value;
		}

		internal static string NameOf(string key)
		{
			if (string.IsNullOrEmpty(key))
			{
				return "";
			}
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return key;
			}
			if (instance != _namesFor)
			{
				_namesFor = instance;
				Names.Clear();
				Tokens.Clear();
				Dictionary<string, Character> dictionary = new Dictionary<string, Character>();
				Character val = default(Character);
				foreach (GameObject prefab in instance.m_prefabs)
				{
					if (!((Object)(object)prefab == (Object)null) && prefab.TryGetComponent<Character>(ref val))
					{
						string text = KeyOf(val);
						if (text != null && (!dictionary.TryGetValue(text, out var value) || (val.m_boss && !value.m_boss)))
						{
							dictionary[text] = val;
						}
					}
				}
				foreach (KeyValuePair<string, Character> item in dictionary)
				{
					string name = item.Value.m_name;
					if (!string.IsNullOrEmpty(name))
					{
						Tokens[item.Key] = name;
					}
					string value2 = ((string.IsNullOrEmpty(name) || Localization.instance == null) ? null : Localization.instance.Localize(name));
					if (!string.IsNullOrEmpty(value2))
					{
						Names[item.Key] = value2;
					}
				}
			}
			if (!Names.TryGetValue(key, out var value3))
			{
				return key;
			}
			return value3;
		}

		private unsafe static void Parse()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			string text = VandiConfig.BossBiomes.Value ?? "";
			if (_byBiome != null && text == _parsedFrom)
			{
				return;
			}
			_parsedFrom = text;
			_byBiome = new Dictionary<Biome, List<string>>();
			_firstBiome = new Dictionary<string, string>();
			string[] array = text.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				if (array2.Length != 2)
				{
					continue;
				}
				string text2 = array2[0].Trim().ToLowerInvariant();
				string text3 = array2[1].Trim();
				if (text2.Length != 0 && text3.Length != 0)
				{
					Biome key;
					try
					{
						key = (Biome)Enum.Parse(typeof(Biome), text3, ignoreCase: true);
					}
					catch (Exception)
					{
						VandiPlugin.LogOnce("BossBiomes names a biome this game does not have: '" + text3 + "'. That pair is skipped; the rest of the line still counts.");
						continue;
					}
					if (!_byBiome.TryGetValue(key, out var value))
					{
						value = new List<string>();
						_byBiome[key] = value;
					}
					if (!value.Contains(text2))
					{
						value.Add(text2);
					}
					if (!_firstBiome.ContainsKey(text2))
					{
						_firstBiome[text2] = ((object)(*(Biome*)(&key))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
					}
				}
			}
		}

		static Bosses()
		{
			Biome[] array = new Biome[9];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Order = (Biome[])(object)array;
			Names = new Dictionary<string, string>();
			Tokens = new Dictionary<string, string>();
		}
	}
	internal static class CompendiumPage
	{
		private sealed class BossRow
		{
			public string Key;

			public GameObject Go;

			public Image Edge;

			public Image Face;

			public TMP_Text Biome;

			public TMP_Text Boss;

			public TMP_Text Count;
		}

		private sealed class Rung
		{
			public GameObject Go;

			public Image Edge;

			public Image Face;

			public TMP_Text Kill;

			public TMP_Text Value;

			public TMP_Text Stars;
		}

		private sealed class Pane
		{
			public TMP_Text Head;

			public TMP_Text Value;

			public TMP_Text Sub;
		}

		[HarmonyPatch(typeof(TextsDialog), "UpdateTextsList")]
		internal static class ListPatch
		{
			private static FieldRef<TextsDialog, List<TextInfo>> _texts;

			private static bool _bound;

			[HarmonyPostfix]
			private static void Postfix(TextsDialog __instance)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				_page = null;
				if (!VandiConfig.ShowCompendiumPage.Value)
				{
					return;
				}
				try
				{
					List<TextInfo> list = TextsOf(__instance);
					if (list != null)
					{
						_page = new TextInfo("Vandi", Summary());
						list.Insert(Math.Min(2, list.Count), _page);
					}
				}
				catch (Exception ex)
				{
					_page = null;
					VandiPlugin.Log.LogError((object)("Compendium page failed to build: " + ex));
				}
			}

			private static List<TextInfo> TextsOf(TextsDialog dialog)
			{
				if (!_bound)
				{
					_bound = true;
					try
					{
						_texts = AccessTools.FieldRefAccess<TextsDialog, List<TextInfo>>("m_texts");
					}
					catch (Exception ex)
					{
						VandiPlugin.Log.LogWarning((object)("The compendium has no m_texts list to add the Vandi page to, so there is no page this session: " + ex.Message));
					}
				}
				if (_texts != null)
				{
					return _texts.Invoke(dialog);
				}
				return null;
			}
		}

		[HarmonyPatch]
		internal static class ShowPatch
		{
			[HarmonyTargetMethod]
			private static MethodBase Target()
			{
				foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(TextsDialog)))
				{
					if (!(declaredMethod.Name != "ShowText"))
					{
						ParameterInfo[] parameters = declaredMethod.GetParameters();
						if (parameters.Length == 1 && parameters[0].ParameterType == typeof(TextInfo))
						{
							return declaredMethod;
						}
					}
				}
				VandiPlugin.Log.LogError((object)"TextsDialog has no ShowText(TextInfo) any more, so the Vandi page in the compendium stays the plain text version.");
				return null;
			}

			[HarmonyPostfix]
			private static void Postfix(TextsDialog __instance, TextInfo __0)
			{
				Shown(__instance, __0);
			}
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		internal static class HudPatch
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				Forget();
				_failedFor = null;
			}
		}

		private static readonly Color PanelFace = Rgb(2038292);

		private static readonly Color RaisedFace = Rgb(2827032);

		private static readonly Color PanelEdge = Rgb(5917238);

		private static readonly Color BodyText = Rgb(15129282);

		private static readonly Color Muted = Rgb(10720906);

		private static readonly Color Orange = Rgb(16753920);

		private static readonly Color OpenText = Rgb(8831614);

		private static readonly Color LockedText = Rgb(13794926);

		private static readonly Color BoxEdge = Rgb(4865326);

		private const string OrangeTag = "#ffa500";

		private const string MutedTag = "#a3968a";

		private const string OpenTag = "#86c27e";

		private const float ListHeadSize = 13f;

		private const float RowBiomeSize = 14f;

		private const float RowBossSize = 13f;

		private const float RowCountSize = 18f;

		private const float TitleSize = 20f;

		private const float SubSize = 13f;

		private const float CellSize = 13f;

		private const float CellValueSize = 17f;

		private const float BoxSize = 13f;

		private const float BoxValueSize = 20f;

		private const float MalmrTitleSize = 15f;

		private const float RoadSize = 14f;

		private const float LineHeight = 1.4f;

		private const float ListWidth = 190f;

		private const float ColumnGap = 14f;

		private const float EdgeMargin = 14f;

		private const int MostSteps = 8;

		private const float RefreshSeconds = 1f;

		private const int AfterVanilla = 2;

		private const float ColumnsPadding = 26f;

		private const float LeastColumns = 200f;

		private static TextInfo _page;

		private static TextsDialog _dialog;

		private static GameObject _root;

		private static RectTransform _host;

		private static LayoutElement _floor;

		private static LayoutElement _columns;

		private static ScrollRect _listScroll;

		private static ScrollRect _detailScroll;

		private static float _fitScale = -1f;

		private static Vector2 _fitSize;

		private static float _fitPixels = -1f;

		private static float _pixelsPerUnit = 1f;

		private static readonly List<RectTransform> Rims = new List<RectTransform>();

		private static TextsDialog _failedFor;

		private static string _selected;

		private static float _nextRefresh;

		private static string _built;

		private static TMP_Text _proto;

		private static float _naturalPerEm;

		private static readonly List<BossRow> Rows = new List<BossRow>();

		private static readonly List<Rung> Rungs = new List<Rung>();

		private static TMP_Text _title;

		private static TMP_Text _sub;

		private static TMP_Text _off;

		private static GameObject _ladder;

		private static GameObject _ladderGap;

		private static GameObject _pair;

		private static GameObject _pairGap;

		private static Pane _now;

		private static Pane _next;

		private static GameObject _malmrBox;

		private static GameObject _malmrGap;

		private static TMP_Text _malmrBody;

		private static GameObject _roadBox;

		private static GameObject _roadGap;

		private static TMP_Text _roadBody;

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		private static void Shown(TextsDialog dialog, TextInfo text)
		{
			if (_page == null || text != _page || !VandiConfig.ShowCompendiumPage.Value)
			{
				if ((Object)(object)_root != (Object)null)
				{
					_root.SetActive(false);
				}
			}
			else
			{
				if ((Object)(object)dialog == (Object)null || dialog == _failedFor)
				{
					return;
				}
				try
				{
					if ((Object)(object)_root == (Object)null || _dialog != dialog || _built != Signature())
					{
						Build(dialog);
					}
					_selected = Default();
					MalmrLink.Opened();
					_root.transform.SetAsLastSibling();
					_root.SetActive(true);
					Fit();
					Draw();
					Settle(layout: true);
					dialog.m_textArea.text = "";
					_nextRefresh = Time.unscaledTime + 1f;
				}
				catch (Exception e)
				{
					Abandon(dialog, e);
				}
			}
		}

		internal static void Tick()
		{
			if ((Object)(object)_root == (Object)null || !_root.activeInHierarchy)
			{
				return;
			}
			try
			{
				int num = 0;
				if (ZInput.IsExclusiveGamepadActive())
				{
					if (ZInput.GetButtonDown("JoyDPadLeft"))
					{
						num = -1;
					}
					else if (ZInput.GetButtonDown("JoyDPadRight"))
					{
						num = 1;
					}
				}
				if (ZInput.IsExclusiveGamepadActive() && (Object)(object)_detailScroll != (Object)null)
				{
					float joyRightStickY = ZInput.GetJoyRightStickY();
					if (Mathf.Abs(joyRightStickY) > 0.1f)
					{
						_detailScroll.verticalNormalizedPosition = Mathf.Clamp01(_detailScroll.verticalNormalizedPosition + joyRightStickY * 2f * Time.unscaledDeltaTime);
					}
				}
				if (num != 0)
				{
					Walk(num);
				}
				else if (Time.unscaledTime < _nextRefresh)
				{
					return;
				}
				_nextRefresh = Time.unscaledTime + 1f;
				if (_built != Signature())
				{
					Build(_dialog);
					_root.SetActive(true);
				}
				Fit();
				Draw();
				if (num != 0)
				{
					Settle(layout: true);
				}
			}
			catch (Exception e)
			{
				Abandon(_dialog, e);
			}
		}

		private static void Select(string key)
		{
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			try
			{
				_selected = key;
				Draw();
				Settle(layout: false);
			}
			catch (Exception e)
			{
				Abandon(_dialog, e);
			}
		}

		private static void Settle(bool layout)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			if ((Object)(object)_detailScroll != (Object)null)
			{
				_detailScroll.verticalNormalizedPosition = 1f;
			}
			if ((Object)(object)_listScroll == (Object)null)
			{
				return;
			}
			if (layout)
			{
				Canvas.ForceUpdateCanvases();
			}
			foreach (BossRow row in Rows)
			{
				if (row.Key == _selected)
				{
					Reveal(_listScroll, (RectTransform)row.Go.transform);
					break;
				}
			}
		}

		private static void Reveal(ScrollRect scroll, RectTransform item)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			RectTransform content = scroll.content;
			Rect rect = scroll.viewport.rect;
			float height = ((Rect)(ref rect)).height;
			rect = content.rect;
			float num = ((Rect)(ref rect)).height - height;
			if (!(num <= 0f))
			{
				Vector3[] array = (Vector3[])(object)new Vector3[4];
				item.GetWorldCorners(array);
				float y = ((Transform)content).InverseTransformPoint(array[1]).y;
				float y2 = ((Transform)content).InverseTransformPoint(array[0]).y;
				float num2 = content.anchoredPosition.y;
				if (y > 0f - num2)
				{
					num2 = 0f - y;
				}
				else if (y2 < 0f - (num2 + height))
				{
					num2 = 0f - y2 - height;
				}
				content.anchoredPosition = new Vector2(content.anchoredPosition.x, Mathf.Clamp(num2, 0f, num));
			}
		}

		private static void Walk(int step)
		{
			int num = -1;
			for (int i = 0; i < Rows.Count; i++)
			{
				if (Rows[i].Key == _selected)
				{
					num = i;
				}
			}
			num += step;
			if (num >= 0 && num < Rows.Count)
			{
				_selected = Rows[num].Key;
			}
		}

		private static string Default()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			List<Bosses.Boss> list = Bosses.Roster();
			if (list.Count == 0)
			{
				return null;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				Biome currentBiome = localPlayer.GetCurrentBiome();
				foreach (Bosses.Boss item in list)
				{
					if (item.Biomes.Contains(currentBiome))
					{
						return item.Key;
					}
				}
			}
			return list[0].Key;
		}

		private static string Signature()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected I4, but got Unknown
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Bosses.Boss item in Bosses.Roster())
			{
				stringBuilder.Append(item.Key);
				foreach (Biome biome in item.Biomes)
				{
					stringBuilder.Append('/').Append((int)biome);
				}
				stringBuilder.Append(';');
			}
			return stringBuilder.ToString();
		}

		private static void Abandon(TextsDialog dialog, Exception e)
		{
			_failedFor = dialog;
			VandiPlugin.Log.LogError((object)("The Vandi compendium page failed, so it is back to plain text for this world. Nothing else is affected. " + e));
			try
			{
				if ((Object)(object)_root != (Object)null)
				{
					Object.Destroy((Object)(object)_root);
				}
				_root = null;
				if ((Object)(object)dialog != (Object)null && (Object)(object)dialog.m_textArea != (Object)null && _page != null)
				{
					dialog.m_textArea.text = ((Localization.instance != null) ? Localization.instance.Localize(_page.m_text) : _page.m_text);
				}
			}
			catch (Exception ex)
			{
				VandiPlugin.Log.LogError((object)("Could not put the Vandi text page back either: " + ex));
			}
		}

		private static string Num(float value)
		{
			return value.ToString("0.##", Inv);
		}

		private static string Points(float value)
		{
			return "+" + Num(value) + "%";
		}

		private static string StarsText(int stars)
		{
			if (stars > 0)
			{
				if (stars != 1)
				{
					return stars + " stars";
				}
				return "1 star";
			}
			return "no stars";
		}

		private static string TimesText(int kills)
		{
			if (kills != 1)
			{
				return kills + " times";
			}
			return "1 time";
		}

		private static string Ordinal(int n)
		{
			return n switch
			{
				1 => "first", 
				2 => "second", 
				3 => "third", 
				_ => n + "th", 
			};
		}

		private static string KillPhrase(int needed)
		{
			int num = needed - 1;
			if (num > 0)
			{
				if (num != 1)
				{
					return "a " + num + "-star kill";
				}
				return "a one-star kill";
			}
			return "a kill";
		}

		private unsafe static string BiomeName(Biome biome)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			string text = "$biome_" + ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
			Localization instance = Localization.instance;
			if (instance != null)
			{
				string text2 = instance.Localize(text);
				if (!string.IsNullOrEmpty(text2) && !(text2 == text) && (!text2.StartsWith("[", StringComparison.Ordinal) || !text2.EndsWith("]", StringComparison.Ordinal)))
				{
					return text2;
				}
			}
			if ((int)biome != 8)
			{
				if ((int)biome != 32)
				{
					if ((int)biome == 64)
					{
						return "Deep North";
					}
					return ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString();
				}
				return "Ashlands";
			}
			return "Black Forest";
		}

		private static string Where(Bosses.Boss boss)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (boss.Biomes.Count <= 1)
			{
				return "here";
			}
			List<string> list = new List<string>();
			foreach (Biome biome in boss.Biomes)
			{
				list.Add("the " + BiomeName(biome));
			}
			return "in " + Joined(list);
		}

		private static string Joined(List<string> items)
		{
			if (items.Count <= 1)
			{
				if (items.Count != 0)
				{
					return items[0];
				}
				return "";
			}
			return string.Join(", ", items.GetRange(0, items.Count - 1).ToArray()) + " and " + items[items.Count - 1];
		}

		private static string Intro(Bosses.Boss boss, int kills)
		{
			string text = Bosses.NameOf(boss.Key);
			float value = VandiConfig.StarChancePerKill.Value;
			float value2 = VandiConfig.StarChanceCap.Value;
			string text2 = ((kills <= 0) ? ("You have not killed " + text + " yet.") : ("You have killed " + text + " " + TimesText(kills) + "."));
			if (value <= 0f)
			{
				return text2 + " Kills add nothing to the star chance (StarChancePerKill is 0).";
			}
			return text2 + " Each kill adds " + Num(value) + "% starred creatures " + Where(boss) + ((value2 > 0f) ? (", up to " + Num(value2) + "%.") : ", with no cap.");
		}

		private static string NextKillLine(int kills)
		{
			float num = Stars.Earned(kills);
			float num2 = Stars.Earned(kills + 1);
			if (VandiConfig.StarChancePerKill.Value <= 0f)
			{
				return "Kills add nothing here";
			}
			if (num2 <= num)
			{
				return "Already the most it gives";
			}
			if (Stars.Earned(kills + 2) <= num2)
			{
				return "Next kill: " + Points(num2) + ", the most it gives";
			}
			return "Next kill: " + Points(num2);
		}

		private static string NextSummonLine(int kills)
		{
			if (!VandiConfig.HarderBosses.Value)
			{
				return "Bosses come back plain, HarderBosses is off";
			}
			if (VandiConfig.BossStarCap.Value <= 0)
			{
				return "Bosses come back plain, the star cap is 0";
			}
			int num = Summon.StarsFor(kills);
			int num2 = Summon.StarsFor(kills + 1);
			if (num2 > num)
			{
				return "The next kill makes it " + StarsText(num2);
			}
			return "The cap, so it stays " + num;
		}

		internal static string Summary()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("Your boss kills, as this world has recorded them. A kill counts when you made ").Append("the offering at the altar.\n");
			foreach (Bosses.Boss item in Bosses.Roster())
			{
				int kills = Kills.LocalCount(item.Key);
				List<string> list = new List<string>();
				foreach (Biome biome in item.Biomes)
				{
					list.Add(BiomeName(biome));
				}
				stringBuilder.Append('\n').Append(Bosses.NameOf(item.Key)).Append(" (")
					.Append(string.Join(", ", list.ToArray()))
					.Append("): killed ")
					.Append(TimesText(kills))
					.Append(", starred creatures ")
					.Append(Points(Stars.Earned(kills)))
					.Append(", next summon at ")
					.Append(StarsText(Summon.StarsFor(kills)))
					.Append('.');
			}
			return stringBuilder.ToString();
		}

		private static void Draw()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			List<Bosses.Boss> list = Bosses.Roster();
			bool flag = list.Count > 0;
			Bosses.Boss boss = null;
			foreach (Bosses.Boss item in list)
			{
				if (item.Key == _selected)
				{
					boss = item;
				}
			}
			if (boss == null && flag)
			{
				boss = list[0];
			}
			if (boss != null)
			{
				_selected = boss.Key;
			}
			foreach (BossRow row in Rows)
			{
				int num = Kills.LocalCount(row.Key);
				bool flag2 = row.Key == _selected;
				Bosses.Boss boss2 = Find(list, row.Key);
				SetText(row.Biome, "<b>" + ((boss2 == null) ? "" : BiomeName(boss2.Biomes[0])) + "</b>");
				SetColor((Graphic)(object)row.Biome, flag2 ? Orange : ((num > 0) ? OpenText : LockedText));
				SetText(row.Boss, Bosses.NameOf(row.Key));
				SetText(row.Count, "<b>" + num + "</b>");
				SetColor((Graphic)(object)row.Count, (num > 0) ? BodyText : Muted);
				SetColor((Graphic)(object)row.Edge, flag2 ? Orange : BoxEdge);
				SetColor((Graphic)(object)row.Face, flag2 ? RaisedFace : PanelFace);
			}
			bool flag3 = !VandiConfig.Enabled.Value;
			SetActive(((Component)_off).gameObject, flag3 && flag);
			if (flag3)
			{
				SetText(_off, Wrapped("Vandi is switched off in this game, so none of this is being applied."));
			}
			if (!flag)
			{
				SetText(_title, "<b>Vandi counts no bosses</b>");
				SetText(_sub, Wrapped("BossBiomes in the config is empty, so no kill is recorded and no biome is raised."));
				SetActive(_ladderGap, active: false);
				SetActive(_ladder, active: false);
				SetActive(_pairGap, active: false);
				SetActive(_pair, active: false);
				SetActive(_malmrGap, active: false);
				SetActive(_malmrBox, active: false);
				SetActive(_roadGap, active: false);
				SetActive(_roadBox, active: false);
				return;
			}
			string text = Bosses.NameOf(boss.Key);
			int num2 = Kills.LocalCount(boss.Key);
			SetText(_title, "<b>The " + BiomeName(boss.Biomes[0]) + ", " + text + "</b>");
			SetText(_sub, Wrapped(Intro(boss, num2)));
			DrawLadder(num2);
			SetActive(_pairGap, active: true);
			SetActive(_pair, active: true);
			SetText(_now.Head, "Starred creatures now");
			SetText(_now.Value, "<b>" + Points(Stars.Earned(num2)) + "</b>");
			SetText(_now.Sub, Wrapped(NextKillLine(num2)));
			SetText(_next.Head, "Next summon comes back at");
			SetText(_next.Value, "<b>" + StarsText(Summon.StarsFor(num2)) + "</b>");
			SetText(_next.Sub, Wrapped(NextSummonLine(num2)));
			List<MalmrLink.Unlock> unlocks = MalmrLink.Unlocks();
			DrawMalmr(boss, text, num2, unlocks);
			DrawRoad(list, boss, unlocks);
		}

		private static Bosses.Boss Find(List<Bosses.Boss> roster, string key)
		{
			foreach (Bosses.Boss item in roster)
			{
				if (item.Key == key)
				{
					return item;
				}
			}
			return null;
		}

		private static void DrawLadder(int have)
		{
			//IL_0145: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			float value = VandiConfig.StarChancePerKill.Value;
			float value2 = VandiConfig.StarChanceCap.Value;
			int num = ((!(value > 0f)) ? (VandiConfig.HarderBosses.Value ? VandiConfig.BossStarCap.Value : 0) : ((value2 > 0f) ? Mathf.CeilToInt(value2 / value) : 5));
			num = Mathf.Clamp(num, 0, 8);
			SetActive(_ladderGap, num > 0);
			SetActive(_ladder, num > 0);
			int num2 = Mathf.Min(have, num);
			for (int i = 0; i < Rungs.Count; i++)
			{
				Rung rung = Rungs[i];
				bool flag = i < num;
				SetActive(rung.Go, flag);
				if (flag)
				{
					int num3 = i + 1;
					bool flag2 = num3 <= have;
					int num4 = Summon.StarsFor(num3);
					SetText(rung.Kill, "Kill " + num3);
					SetText(rung.Value, "<b>" + Points(Stars.Earned(num3)) + "</b>");
					SetText(rung.Stars, (num4 <= 0) ? "boss plain" : ("boss " + StarsText(num4)));
					SetColor((Graphic)(object)rung.Kill, flag2 ? BodyText : Muted);
					SetColor((Graphic)(object)rung.Value, flag2 ? Orange : Muted);
					SetColor((Graphic)(object)rung.Stars, Muted);
					SetColor((Graphic)(object)rung.Edge, (num3 == num2) ? Orange : BoxEdge);
					SetColor((Graphic)(object)rung.Face, flag2 ? RaisedFace : PanelFace);
				}
			}
		}

		private static void DrawMalmr(Bosses.Boss chosen, string name, int have, List<MalmrLink.Unlock> unlocks)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (MalmrLink.Unlock unlock in unlocks)
			{
				if (!(unlock.Boss != chosen.Key))
				{
					bool flag = have >= unlock.KillsNeeded;
					bool flag2 = unlock.PickaxesNow >= unlock.Pickaxes;
					string text = KillPhrase(unlock.KillsNeeded) + " of " + name + ", your " + Ordinal(unlock.KillsNeeded);
					string value;
					string value2;
					string value3;
					if (flag && flag2)
					{
						value = "#86c27e";
						value2 = unlock.Noun + " mining is open";
						value3 = "Needed Pickaxes " + unlock.Pickaxes + " and " + text;
					}
					else if (flag)
					{
						value = "#ffa500";
						value2 = unlock.Noun + " mining waits for Pickaxes " + unlock.Pickaxes;
						value3 = "You are at Pickaxes " + unlock.PickaxesNow + ", and " + text + " is done";
					}
					else
					{
						int num = unlock.KillsNeeded - have;
						value = "#ffa500";
						value2 = ((num == 1) ? ("The next kill opens " + unlock.Noun + " mining") : (num + " more kills open " + unlock.Noun + " mining"));
						value3 = "Needs " + text + (flag2 ? (", and Pickaxes " + unlock.Pickaxes) : (" and Pickaxes " + unlock.Pickaxes + ", you are at " + unlock.PickaxesNow));
					}
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append('\n');
					}
					stringBuilder.Append("<size=").Append(Num(15f)).Append("><b><color=")
						.Append(value)
						.Append('>')
						.Append(value2)
						.Append("</color></b></size>\n<color=")
						.Append("#a3968a")
						.Append('>')
						.Append(value3)
						.Append("</color>");
				}
			}
			bool flag3 = stringBuilder.Length > 0;
			SetActive(_malmrGap, flag3);
			SetActive(_malmrBox, flag3);
			if (flag3)
			{
				SetText(_malmrBody, Wrapped(stringBuilder.ToString()));
			}
		}

		private static void DrawRoad(List<Bosses.Boss> roster, Bosses.Boss chosen, List<MalmrLink.Unlock> unlocks)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Bosses.Boss item in roster)
			{
				if (item.Key == chosen.Key)
				{
					continue;
				}
				int num = Kills.LocalCount(item.Key);
				List<MalmrLink.Unlock> list = new List<MalmrLink.Unlock>();
				foreach (MalmrLink.Unlock unlock in unlocks)
				{
					if (unlock.Boss == item.Key && num < unlock.KillsNeeded)
					{
						list.Add(unlock);
					}
				}
				if (list.Count == 0)
				{
					continue;
				}
				int killsNeeded = list[0].KillsNeeded;
				string text = Bosses.NameOf(item.Key);
				List<string> list2 = new List<string>();
				foreach (MalmrLink.Unlock item2 in list)
				{
					list2.Add((num > 0) ? (item2.Plain + " (Pickaxes " + item2.Pickaxes + ")") : item2.Plain);
				}
				string text2 = "<color=#ffa500>" + Joined(list2) + "</color>";
				string value;
				if (num <= 0)
				{
					value = ((killsNeeded <= 1) ? (text + ": never killed, the first kill opens " + text2) : ((killsNeeded != 2) ? (text + ": never killed, the first " + (killsNeeded - 1) + " kills open nothing yet, the " + Ordinal(killsNeeded) + " opens " + text2) : (text + ": never killed, first kill opens nothing yet, the second opens " + text2)));
				}
				else
				{
					int num2 = killsNeeded - num;
					value = text + ": " + ((num2 == 1) ? "one more kill opens " : (num2 + " more kills open ")) + text2;
				}
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append('\n');
				}
				stringBuilder.Append(value);
			}
			bool flag = stringBuilder.Length > 0;
			SetActive(_roadGap, flag);
			SetActive(_roadBox, flag);
			if (flag)
			{
				SetText(_roadBody, Wrapped(stringBuilder.ToString()));
			}
		}

		private static string Wrapped(string text)
		{
			return "<line-height=" + 1.4f.ToString(Inv) + "em>" + text;
		}

		private static void SetText(TMP_Text label, string text)
		{
			if (label.text != text)
			{
				label.text = text;
			}
		}

		private static void SetColor(Graphic graphic, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (graphic.color != color)
			{
				graphic.color = color;
			}
		}

		private static void SetActive(GameObject go, bool active)
		{
			if (go.activeSelf != active)
			{
				go.SetActive(active);
			}
		}

		private static float Edge()
		{
			return Mathf.Max(1f, Mathf.Round(_pixelsPerUnit)) / _pixelsPerUnit;
		}

		private static void Rim(RectTransform face)
		{
			Rims.Add(face);
			Inset(face, Edge());
		}

		private static void Build(TextsDialog dialog)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			Forget();
			TMP_Text textArea = dialog.m_textArea;
			if ((Object)(object)textArea == (Object)null)
			{
				throw new InvalidOperationException("TextsDialog.m_textArea is not set.");
			}
			string passed;
			RectTransform val = Host(dialog, textArea, out passed);
			GameObject val2 = new GameObject("Vandi_Page", new Type[1] { typeof(RectTransform) });
			val2.SetActive(false);
			RectTransform val3 = (RectTransform)val2.transform;
			((Transform)val3).SetParent((Transform)(object)val, false);
			_floor = val2.AddComponent<LayoutElement>();
			_floor.ignoreLayout = true;
			_root = val2;
			_dialog = dialog;
			_host = val;
			Paint(val3, PanelEdge, raycast: true);
			RectTransform obj = Child("Face", (Transform)(object)val3);
			((Component)obj).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Rim(obj);
			Paint(obj, PanelFace, raycast: false);
			VerticalLayoutGroup obj2 = val2.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(1, 1, 1, 1);
			Stack(obj2, fillHeight: false);
			val2.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			GameObject obj3 = Object.Instantiate<GameObject>(((Component)textArea).gameObject, (Transform)(object)val3);
			((Object)obj3).name = "Vandi_Label";
			Strip(obj3);
			obj3.SetActive(false);
			_proto = obj3.GetComponent<TMP_Text>();
			if ((Object)(object)_proto == (Object)null)
			{
				throw new InvalidOperationException("The compendium's text carried no TextMeshPro component.");
			}
			Prime(_proto);
			val2.SetActive(true);
			_naturalPerEm = Measure(val3);
			val2.AddComponent<CompendiumPageTicker>();
			RectTransform val4 = Child("Body", (Transform)(object)val3);
			((Component)val4).gameObject.AddComponent<LayoutElement>().flexibleHeight = 0f;
			VerticalLayoutGroup obj4 = ((Component)val4).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(14, 14, 10, 14);
			Stack(obj4, fillHeight: false);
			_fitScale = -1f;
			Fit();
			RectTransform val5 = Child("Split", (Transform)(object)val4);
			HorizontalLayoutGroup obj5 = ((Component)val5).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj5).spacing = 14f;
			Across(obj5, even: false);
			_columns = ((Component)val5).gameObject.AddComponent<LayoutElement>();
			_columns.flexibleHeight = 0f;
			List<Bosses.Boss> list = Bosses.Roster();
			int num = 0;
			RectTransform val6 = Scroller("List", val5, dialog, out _listScroll);
			LayoutElement component = ((Component)_listScroll).GetComponent<LayoutElement>();
			component.minWidth = 190f;
			component.preferredWidth = 190f;
			component.flexibleWidth = 0f;
			VerticalLayoutGroup obj6 = ((Component)val6).gameObject.AddComponent<VerticalLayoutGroup>();
			Stack(obj6, fillHeight: false);
			((HorizontalOrVerticalLayoutGroup)obj6).spacing = 5f;
			Label((Transform)(object)val6, 13f, Muted, (TextAlignmentOptions)257).text = "Boss, by biome (your kills)";
			foreach (Bosses.Boss item in list)
			{
				BossRow bossRow = MakeRow(val6, item.Key);
				if (Sound(bossRow.Go, dialog))
				{
					num++;
				}
				Rows.Add(bossRow);
			}
			RectTransform val7 = Scroller("Detail", val5, dialog, out _detailScroll);
			LayoutElement component2 = ((Component)_detailScroll).GetComponent<LayoutElement>();
			component2.minWidth = 0f;
			component2.preferredWidth = 0f;
			component2.flexibleWidth = 1f;
			Stack(((Component)val7).gameObject.AddComponent<VerticalLayoutGroup>(), fillHeight: false);
			_title = Label((Transform)(object)val7, 20f, Orange, (TextAlignmentOptions)257);
			_sub = Label((Transform)(object)val7, 13f, Muted, (TextAlignmentOptions)257);
			_off = Label((Transform)(object)val7, 13f, LockedText, (TextAlignmentOptions)257);
			_ladderGap = Gap((Transform)(object)val7, 10f);
			RectTransform val8 = Child("Ladder", (Transform)(object)val7);
			HorizontalLayoutGroup obj7 = ((Component)val8).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj7).spacing = 6f;
			Across(obj7, even: true);
			_ladder = ((Component)val8).gameObject;
			for (int i = 0; i < 8; i++)
			{
				Rungs.Add(MakeRung(val8));
			}
			_pairGap = Gap((Transform)(object)val7, 10f);
			RectTransform obj8 = Child("Pair", (Transform)(object)val7);
			HorizontalLayoutGroup obj9 = ((Component)obj8).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj9).spacing = 8f;
			Across(obj9, even: true);
			_pair = ((Component)obj8).gameObject;
			_now = MakePane(obj8, "Now");
			_next = MakePane(obj8, "Next");
			_malmrGap = Gap((Transform)(object)val7, 8f);
			_malmrBox = MakeNote(val7, "Malmr", "Malmr, tied to this boss", Muted, 13f, out _malmrBody);
			_roadGap = Gap((Transform)(object)val7, 8f);
			_roadBox = MakeNote(val7, "Road", "The road ahead", BodyText, 14f, out _roadBody);
			_built = Signature();
			_fitScale = -1f;
			Fit();
			Rect rect = val.rect;
			VandiPlugin.Log.LogInfo((object)("Compendium page built over '" + ((Object)val).name + "'" + ((passed.Length > 0) ? (" (past " + passed + ", sized by what is in it)") : "") + ", " + Mathf.RoundToInt(((Rect)(ref rect)).width) + " x " + Mathf.RoundToInt(((Rect)(ref rect)).height) + " at scale " + _fitScale.ToString("0.###", Inv) + ", " + _pixelsPerUnit.ToString("0.###", Inv) + " screen pixels to a unit, the compendium's own text at size " + textArea.fontSize.ToString("0.#", Inv) + ", one line of text at " + _naturalPerEm.ToString("0.00", Inv) + " em, " + num + " of " + Rows.Count + " boss rows with vanilla's click sound."));
		}

		private static RectTransform Scroller(string name, RectTransform parent, TextsDialog dialog, out ScrollRect scroll)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Child(name + "_Scroll", (Transform)(object)parent);
			LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.minHeight = 0f;
			obj.flexibleHeight = 1f;
			RectTransform val2 = Child("Viewport", (Transform)(object)val);
			Inset(val2, 0f);
			((Component)val2).gameObject.AddComponent<RectMask2D>();
			Paint(val2, Color.clear, raycast: true);
			RectTransform val3 = Child(name, (Transform)(object)val2);
			val3.anchorMin = new Vector2(0f, 1f);
			val3.anchorMax = new Vector2(1f, 1f);
			val3.pivot = new Vector2(0f, 1f);
			val3.offsetMin = Vector2.zero;
			val3.offsetMax = Vector2.zero;
			((Component)val3).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect val4 = ((Component)val).gameObject.AddComponent<ScrollRect>();
			val4.horizontal = false;
			val4.vertical = true;
			val4.movementType = (MovementType)2;
			val4.scrollSensitivity = (((Object)(object)dialog.m_leftScrollRect != (Object)null) ? dialog.m_leftScrollRect.scrollSensitivity : 30f);
			val4.viewport = val2;
			val4.content = val3;
			Bar(val4, val, dialog);
			scroll = val4;
			return val3;
		}

		private static void Bar(ScrollRect scroll, RectTransform outer, TextsDialog dialog)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			Scrollbar rightScrollbar = dialog.m_rightScrollbar;
			if ((Object)(object)rightScrollbar == (Object)null)
			{
				return;
			}
			try
			{
				Rect rect = ((RectTransform)((Component)rightScrollbar).transform).rect;
				float num = Mathf.Clamp(((Rect)(ref rect)).width, 8f, 24f);
				GameObject val = Object.Instantiate<GameObject>(((Component)rightScrollbar).gameObject, (Transform)(object)outer);
				((Object)val).name = "Scrollbar";
				MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true);
				foreach (MonoBehaviour val2 in componentsInChildren)
				{
					if (!((Object)(object)val2 == (Object)null) && !(val2 is Scrollbar) && !(val2 is Graphic) && !(val2 is Mask) && !(val2 is RectMask2D))
					{
						Object.DestroyImmediate((Object)(object)val2);
					}
				}
				RectTransform val3 = (RectTransform)val.transform;
				val3.anchorMin = new Vector2(1f, 0f);
				val3.anchorMax = new Vector2(1f, 1f);
				val3.pivot = new Vector2(1f, 0.5f);
				val3.sizeDelta = new Vector2(num, 0f);
				val3.anchoredPosition = Vector2.zero;
				((Transform)val3).localScale = Vector3.one;
				Scrollbar component = val.GetComponent<Scrollbar>();
				component.onValueChanged = new ScrollEvent();
				component.direction = (Direction)2;
				val.SetActive(true);
				scroll.verticalScrollbar = component;
				scroll.verticalScrollbarVisibility = (ScrollbarVisibility)2;
				scroll.verticalScrollbarSpacing = 4f;
			}
			catch (Exception ex)
			{
				VandiPlugin.Log.LogWarning((object)("Compendium page: could not copy the scrollbar, so the columns scroll without one. " + ex.Message));
			}
		}

		private static BossRow MakeRow(RectTransform list, string key)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			RectTransform val = Child("Boss_" + key, (Transform)(object)list);
			Image val2 = Paint(val, BoxEdge, raycast: true);
			HorizontalLayoutGroup obj = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(11, 12, 5, 5);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			RectTransform obj2 = Child("Face", (Transform)(object)val);
			((Component)obj2).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Rim(obj2);
			Image face = Paint(obj2, PanelFace, raycast: false);
			RectTransform val3 = Child("Names", (Transform)(object)val);
			LayoutElement obj3 = ((Component)val3).gameObject.AddComponent<LayoutElement>();
			obj3.minWidth = 0f;
			obj3.flexibleWidth = 1f;
			Stack(((Component)val3).gameObject.AddComponent<VerticalLayoutGroup>(), fillHeight: false);
			BossRow obj4 = new BossRow
			{
				Key = key,
				Go = ((Component)val).gameObject,
				Edge = val2,
				Face = face,
				Biome = Label((Transform)(object)val3, 14f, OpenText, (TextAlignmentOptions)257),
				Boss = Label((Transform)(object)val3, 13f, Muted, (TextAlignmentOptions)257),
				Count = Label((Transform)(object)val, 18f, BodyText, (TextAlignmentOptions)4100)
			};
			obj4.Count.textWrappingMode = (TextWrappingModes)0;
			Button obj5 = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)obj5).transition = (Transition)0;
			((Selectable)obj5).targetGraphic = (Graphic)(object)val2;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj5).navigation = navigation;
			string chosen = key;
			((UnityEvent)obj5.onClick).AddListener((UnityAction)delegate
			{
				Select(chosen);
			});
			return obj4;
		}

		private static Rung MakeRung(RectTransform ladder)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Child("Step", (Transform)(object)ladder);
			Image edge = Paint(val, BoxEdge, raycast: false);
			LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 0f;
			obj.preferredWidth = 0f;
			obj.flexibleWidth = 1f;
			VerticalLayoutGroup obj2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(3, 3, 4, 4);
			Stack(obj2, fillHeight: false);
			RectTransform obj3 = Child("Face", (Transform)(object)val);
			((Component)obj3).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Rim(obj3);
			Image face = Paint(obj3, PanelFace, raycast: false);
			Rung obj4 = new Rung
			{
				Go = ((Component)val).gameObject,
				Edge = edge,
				Face = face,
				Kill = Label((Transform)(object)val, 13f, BodyText, (TextAlignmentOptions)258),
				Value = Label((Transform)(object)val, 17f, Orange, (TextAlignmentOptions)258),
				Stars = Label((Transform)(object)val, 13f, Muted, (TextAlignmentOptions)258)
			};
			obj4.Go.SetActive(false);
			return obj4;
		}

		private static Pane MakePane(RectTransform pair, string name)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Child(name, (Transform)(object)pair);
			Paint(val, BoxEdge, raycast: false);
			LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 0f;
			obj.preferredWidth = 0f;
			obj.flexibleWidth = 1f;
			VerticalLayoutGroup obj2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(12, 12, 4, 4);
			Stack(obj2, fillHeight: false);
			RectTransform obj3 = Child("Face", (Transform)(object)val);
			((Component)obj3).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Rim(obj3);
			Paint(obj3, PanelFace, raycast: false);
			return new Pane
			{
				Head = Label((Transform)(object)val, 13f, Muted, (TextAlignmentOptions)257),
				Value = Label((Transform)(object)val, 20f, Orange, (TextAlignmentOptions)257),
				Sub = Label((Transform)(object)val, 13f, Muted, (TextAlignmentOptions)257)
			};
		}

		private static GameObject MakeNote(RectTransform detail, string name, string heading, Color bodyColor, float bodySize, out TMP_Text body)
		{
			//IL_0009: 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_0031: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Child(name, (Transform)(object)detail);
			Paint(val, BoxEdge, raycast: false);
			VerticalLayoutGroup obj = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(12, 12, 4, 4);
			Stack(obj, fillHeight: false);
			RectTransform obj2 = Child("Face", (Transform)(object)val);
			((Component)obj2).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Rim(obj2);
			Paint(obj2, PanelFace, raycast: false);
			Label((Transform)(object)val, 13f, Muted, (TextAlignmentOptions)257).text = heading;
			body = Label((Transform)(object)val, bodySize, bodyColor, (TextAlignmentOptions)257);
			((Component)val).gameObject.SetActive(false);
			return ((Component)val).gameObject;
		}

		private static void Fit()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0108: 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_0123: 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)
			if ((Object)(object)_root == (Object)null || (Object)(object)_host == (Object)null || (Object)(object)_floor == (Object)null)
			{
				return;
			}
			float num = HostScale(_host);
			Rect rect = _host.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			float num2 = PixelsPerUnit(_host);
			if (Mathf.Approximately(num, _fitScale) && size == _fitSize && Mathf.Approximately(num2, _fitPixels))
			{
				return;
			}
			_fitScale = num;
			_fitSize = size;
			_fitPixels = num2;
			float num3 = ((num >= 0.99f) ? 1f : num);
			float num4 = 1f / num3;
			RectTransform val = (RectTransform)_root.transform;
			val.anchorMin = new Vector2(0f, 1f);
			val.anchorMax = new Vector2(0f, 1f);
			val.pivot = new Vector2(0f, 1f);
			((Transform)val).localScale = new Vector3(num4, num4, 1f);
			val.anchoredPosition = new Vector2(14f, 0f);
			val.SetSizeWithCurrentAnchors((Axis)0, Mathf.Max(0f, size.x - 28f) * num3);
			_floor.minHeight = Mathf.Max(0f, size.y - 14f) * num3;
			if ((Object)(object)_columns != (Object)null)
			{
				float num5 = Mathf.Max(200f, _floor.minHeight - 26f);
				_columns.minHeight = num5;
				_columns.preferredHeight = num5;
			}
			_pixelsPerUnit = num2 * num4;
			foreach (RectTransform rim in Rims)
			{
				Inset(rim, Edge());
			}
		}

		private static float PixelsPerUnit(RectTransform rect)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Canvas componentInParent = ((Component)rect).GetComponentInParent<Canvas>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return 1f;
			}
			Canvas rootCanvas = componentInParent.rootCanvas;
			float x = ((Component)rootCanvas).transform.lossyScale.x;
			if (x <= 0f || rootCanvas.scaleFactor <= 0f)
			{
				return 1f;
			}
			float num = rootCanvas.scaleFactor * ((Transform)rect).lossyScale.x / x;
			if (!(num > 0.1f) || !(num < 20f))
			{
				return 1f;
			}
			return num;
		}

		private static float HostScale(RectTransform host)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Canvas componentInParent = ((Component)host).GetComponentInParent<Canvas>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return 1f;
			}
			float x = ((Component)componentInParent.rootCanvas).transform.lossyScale.x;
			if (x <= 0f)
			{
				return 1f;
			}
			float num = ((Transform)host).lossyScale.x / x;
			if (!(num > 0.2f) || !(num < 5f))
			{
				return 1f;
			}
			return num;
		}

		private static bool Sound(GameObject button, TextsDialog dialog)
		{
			try
			{
				return CopySound(button, dialog);
			}
			catch (Exception ex)
			{
				VandiPlugin.Log.LogWarning((object)("Compendium page: the boss rows stay silent. " + ex.Message));
				return false;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static bool CopySound(GameObject button, TextsDialog dialog)
		{
			if ((Object)(object)dialog.m_elementPrefab == (Object)null)
			{
				return false;
			}
			ButtonSfx componentInChildren = dialog.m_elementPrefab.GetComponentInChildren<ButtonSfx>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			ButtonSfx obj = button.AddComponent<ButtonSfx>();
			obj.m_sfxPrefab = componentInChildren.m_sfxPrefab;
			obj.m_sfxPrefabVibrationOnly = componentInChildren.m_sfxPrefabVibrationOnly;
			obj.m_selectSfxPrefab = componentInChildren.m_selectSfxPrefab;
			obj.m_selectSfxPrefabVibrationOnly = componentInChildren.m_selectSfxPrefabVibrationOnly;
			obj.m_enterSfxPrefab = componentInChildren.m_enterSfxPrefab;
			obj.m_enterSfxPrefabVibrationOnly = componentInChildren.m_enterSfxPrefabVibrationOnly;
			return true;
		}

		private static RectTransform Host(TextsDialog dialog, TMP_Text donor, out string passed)
		{
			Transform parent = donor.transform.parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("The compendium's text has no parent to draw over.");
			}
			passed = "";
			while (!Clips(val) && FollowsContent(val))
			{
				Transform parent2 = ((Transform)val).parent;
				RectTransform val2 = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null);
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)((Component)dialog).transform || !((Transform)val2).IsChildOf(((Component)dialog).transform) || Brings((Transform)(object)val, (Transform)(object)val2, (Component)(object)dialog.m_textAreaTopic) || Brings((Transform)(object)val, (Transform)(object)val2, (Component)(object)dialog.m_rightScrollbar) || Brings((Transform)(object)val, (Transform)(object)val2, (Component)(object)dialog.m_listRoot))
				{
					break;
				}
				passed = passed + ((passed.Length > 0) ? ", '" : "'") + ((Object)val).name + "'";
				val = val2;
			}
			if (((Object)val).name != "ScrollArea")
			{
				RectTransform val3 = val;
				Transform parent3 = donor.transform.parent;
				while ((Object)(object)parent3 != (Object)null && (Object)(object)parent3 != (Object)(object)((Component)dialog).transform)
				{
					RectTransform val4 = (RectTransform)(object)((parent3 is RectTransform) ? parent3 : null);
					if (!((Object)(object)val4 == (Object)null) && !(((Object)val4).name != "ScrollArea"))
					{
						if (!Brings((Transform)(object)val3, (Transform)(object)val4, (Component)(object)dialog.m_textAreaTopic) && !Brings((Transform)(object)val3, (Transform)(object)val4, (Component)(object)dialog.m_rightScrollbar) && !Brings((Transform)(object)val3, (Transform)(object)val4, (Component)(object)dialog.m_listRoot))
						{
							passed = passed + ((passed.Length > 0) ? ", '" : "'") + ((Object)val).name + "'";
							val = val4;
						}
						break;
					}
					parent3 = parent3.parent;
				}
			}
			return val;
		}

		private static bool FollowsContent(RectTransform rect)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ContentSizeFitter[] components = ((Component)rect).GetComponents<ContentSizeFitter>();
			foreach (ContentSizeFitter val in components)
			{
				if (((Behaviour)val).enabled && (int)val.verticalFit != 0)
				{
					return true;
				}
			}
			ScrollRect[] componentsInParent = ((Component)rect).GetComponentsInParent<ScrollRect>(true);
			for (int i = 0; i < componentsInParent.Length; i++)
			{
				if ((Object)(object)componentsInParent[i].content == (Object)(object)rect)
				{
					return true;
				}
			}
			Transform parent = ((Transform)rect).parent;
			if ((Object)(object)parent == (Object)null)
			{
				return false;
			}
			HorizontalOrVerticalLayoutGroup[] components2 = ((Component)parent).GetComponents<HorizontalOrVerticalLayoutGroup>();
			foreach (HorizontalOrVerticalLayoutGroup val2 in components2)
			{
				if (((Behaviour)val2).enabled && val2.childControlHeight)
				{
					return true;
				}
			}
			return false;
		}

		private static bool Clips(RectTransform rect)
		{
			RectMask2D component = ((Component)rect).GetComponent<RectMask2D>();
			if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
			{
				return true;
			}
			Mask component2 = ((Component)rect).GetComponent<Mask>();
			if ((Object)(object)component2 != (Object)null)
			{
				return ((Behaviour)component2).enabled;
			}
			return false;
		}

		private static bool Brings(Transform from, Transform to, Component part)
		{
			if ((Object)(object)part != (Object)null && part.transform.IsChildOf(to))
			{
				return !part.transform.IsChildOf(from);
			}
			return false;
		}

		private static void Strip(GameObject go)
		{
			for (int i = 0; i < 2; i++)
			{
				Component[] components = go.GetComponents<Component>();
				foreach (Component val in components)
				{
					if (!((Object)(object)val == (Object)null) && !(val is RectTransform) && !(val is CanvasRenderer) && !(val is TMP_Text))
					{
						Object.DestroyImmediate((Object)(object)val);
					}
				}
			}
			for (int num = go.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)go.transform.GetChild(num)).gameObject);
			}
		}

		private static void Prime(TMP_Text label)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			label.text = "";
			label.enableAutoSizing = false;
			label.richText = true;
			((Graphic)label).raycastTarget = false;
			label.overrideColorTags = false;
			label.enableVertexGradient = false;
			label.textWrappingMode = (TextWrappingModes)1;
			label.overflowMode = (TextOverflowModes)0;
			label.margin = Vector4.zero;
			label.lineSpacing = 0f;
			label.paragraphSpacing = 0f;
			label.alignment = (TextAlignmentOptions)257;
			((Graphic)label).color = BodyText;
		}

		private static float Measure(RectTransform parent)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)_proto).gameObject, (Transform)(object)parent);
			try
			{
				val.SetActive(true);
				TMP_Text component = val.GetComponent<TMP_Text>();
				component.fontSize = 100f;
				component.textWrappingMode = (TextWrappingModes)0;
				float num = component.GetPreferredValues("Hg").y / 100f;
				if (num > 0.6f && num < 2.5f)
				{
					return num;
				}
				VandiPlugin.Log.LogWarning((object)("Compendium page: measured a line of " + num + " em, which cannot be right; spacing the text as if it were 1.2."));
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
			}
			return 1.2f;
		}

		private static float Lead(float size)
		{
			return Mathf.Max(0f, (1.4f - _naturalPerEm) * size * 0.5f);
		}

		private static TMP_Text Label(Transform parent, float size, Color color, TextAlignmentOptions align)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(((Component)_proto).gameObject, parent);
			((Object)obj).name = "Text";
			obj.SetActive(true);
			TMP_Text component = obj.GetComponent<TMP_Text>();
			component.fontSize = size;
			((Graphic)component).color = color;
			component.alignment = align;
			float num = Lead(size);
			component.margin = new Vector4(0f, num, 0f, num);
			return component;
		}

		private static RectTransform Child(string name, Transform parent)
		{
			//IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent(parent, false);
			return val;
		}

		private static Image Paint(RectTransform rect, Color color, bool raycast)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)rect).gameObject.AddComponent<Image>();
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = raycast;
			return obj;
		}

		private static void Inset(RectTransform rect, float by)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.offsetMin = new Vector2(by, by);
			rect.offsetMax = new Vector2(0f - by, 0f - by);
		}

		private static GameObject Gap(Transform parent, float height)
		{
			RectTransform obj = Child("Gap", parent);
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			obj2.minHeight = height;
			obj2.preferredHeight = height;
			return ((Component)obj).gameObject;
		}

		private static void Stack(VerticalLayoutGroup group, bool fillHeight)
		{
			((HorizontalOrVerticalLayoutGroup)group).spacing = 0f;
			((LayoutGroup)group).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)group).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)group).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)group).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)group).childForceExpandHeight = fillHeight;
		}

		private static void Across(HorizontalLayoutGroup group, bool even)
		{
			((LayoutGroup)group).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)group).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)group).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)group).childForceExpandWidth = even;
			((HorizontalOrVerticalLayoutGroup)group).childForceExpandHeight = even;
		}

		private static void Forget()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
			_root = null;
			_dialog = null;
			_host = null;
			_floor = null;
			_columns = null;
			_listScroll = null;
			_detailScroll = null;
			_fitScale = -1f;
			_fitPixels = -1f;
			_built = null;
			Rims.Clear();
			_proto = null;
			Rows.Clear();
			Rungs.Clear();
			_title = null;
			_sub = null;
			_off = null;
			_ladder = null;
			_ladderGap = null;
			_pair = null;
			_pairGap = null;
			_now = null;
			_next = null;
			_malmrBox = null;
			_malmrGap = null;
			_malmrBody = null;
			_roadBox = null;
			_roadGap = null;
			_roadBody = null;
		}

		private static Color Rgb(int hex)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((hex >> 16) & 0xFF) / 255f, (float)((hex >> 8) & 0xFF) / 255f, (float)(hex & 0xFF) / 255f, 1f);
		}
	}
	internal sealed class CompendiumPageTicker : MonoBehaviour
	{
		private void Update()
		{
			CompendiumPage.Tick();
		}
	}
	internal static class Kills
	{
		[HarmonyPatch]
		internal static class Readout
		{
			private static bool _registered;

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Terminal), "InitTerminal")]
			private static void Register()
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				if (!_registered)
				{
					_registered = true;
					new ConsoleCommand("vandi", "the boss kills this world has credited to you, per boss Vandi counts, and the star roll where you stand", new ConsoleEvent(OnCommand), false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				}
			}

			private static void OnCommand(ConsoleEventArgs args)
			{
				Terminal context = args.Context;
				if ((Object)(object)context == (Object)null)
				{
					return;
				}
				if (args.Length > 1 && args[1] == "metal")
				{
					Metal.Print(context, args.Args);
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null)
				{
					context.AddString("vandi: no character in a world yet");
					return;
				}
				long playerID = localPlayer.GetPlayerID();
				context.AddString("vandi: " + localPlayer.GetPlayerName() + ", id " + playerID.ToString(CultureInfo.InvariantCulture) + ", enabled=" + (VandiConfig.Enabled.Value ? "yes" : "no") + (VandiConfig.CountGameKills.Value ? "   (kills as the game counts them for this character, CountGameKills is on)" : "   (kills of a boss you summoned at an altar, as this world has recorded them)"));
				HashSet<string> hashSet = new HashSet<string>();
				Biome[] order = Bosses.Order;
				for (int i = 0; i < order.Length; i++)
				{
					List<string> list = Bosses.For(order[i]);
					if (list == null)
					{
						continue;
					}
					foreach (string item in list)
					{
						if (hashSet.Add(item))
						{
							context.AddString("vandi " + item + "=" + Count(playerID, item).ToString(CultureInfo.InvariantCulture));
						}
					}
				}
				context.AddString(StarLine(localPlayer));
			}

			private static string StarLine(Player player)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: 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)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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)
				WorldGenerator instance = WorldGenerator.instance;
				if (instance == null)
				{
					return "vandi starchance: no world generator yet";
				}
				Vector3 position = ((Component)player).transform.position;
				float levelUpChance = SpawnSystem.GetLevelUpChance(position, 0f);
				float num = Stars.Share(position);
				float levelUpChanceMultiplier = instance.GetBiomeSector(position, false).GetLevelUpChanceMultiplier();
				return "vandi starchance=" + Number(levelUpChance) + " here (" + ((object)instance.GetBiome(position)/*cast due to .constrained prefix*/).ToString() + ", sector x" + Number(levelUpChanceMultiplier) + "): the game's " + Number(levelUpChance - num) + ", Vandi's +" + Number(num);
			}

			private static string Number(float value)
			{
				return value.ToString("0.##", CultureInfo.InvariantCulture);
			}
		}

		private const string Prefix = "vandi_p_";

		internal static int Count(long playerId, string bossKey)
		{
			ZoneSystem instance = ZoneSystem.instance;
			if ((Object)(object)instance == (Object)null || string.IsNullOrEmpty(bossKey))
			{
				return 0;
			}
			Player localPlayer = Player.m_localPlayer;
			if (VandiConfig.CountGameKills.Value && (Object)(object)localPlayer != (Object)null && localPlayer.GetPlayerID() == playerId)
			{
				return GameCount(bossKey);
			}
			string s = default(string);
			if (!instance.GetGlobalKey(Key(playerId, bossKey), ref s))
			{
				return 0;
			}
			if (!int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return 0;
			}
			if (result >= 0)
			{
				return result;
			}
			return 0;
		}

		internal static int GameCount(string bossKey)
		{
			string text = Bosses.TokenOf(bossKey);
			if (text == null || (Object)(object)Game.instance == (Object)null)
			{
				return 0;
			}
			PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
			if (playerProfile == null)
			{
				return 0;
			}
			if (!playerProfile.m_playerStats[0].m_enemyStats[0].TryGetValue(text, out var value))
			{
				return 0;
			}
			if (!(value < 0f))
			{
				return (int)value;
			}
			return 0;
		}

		internal static int LocalCount(string bossKey)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				return Count(localPlayer.GetPlayerID(), bossKey);
			}
			return 0;
		}

		internal static int Add(long playerId, string bossKey)
		{
			ZoneSystem instance = ZoneSystem.instance;
			if ((Object)(object)instance == (Object)null || string.IsNullOrEmpty(bossKey))
			{
				return 0;
			}
			if (VandiConfig.CountGameKills.Value)
			{
				return Count(playerId, bossKey);
			}
			int result = Count(playerId, bossKey) + 1;
			instance.SetGlobalKey(Key(playerId, bossKey) + " " + result.ToString(CultureInfo.InvariantCulture));
			return result;
		}

		private static string Key(long playerId, string bossKey)
		{
			return ("vandi_p_" + playerId + "_" + bossKey).ToLowerInvariant();
		}
	}
	internal static class MalmrLink
	{
		internal sealed class Unlock
		{
			internal string Entry;

			internal string Noun;

			internal string Plain;

			internal int Pickaxes;

			internal int PickaxesNow;

			internal int KillsNeeded;

			internal string Boss;
		}

		private const string MalmrGuid = "ezomic.valheim.malmr";

		private const string AnyMetal = "*";

		private static bool _bound;

		private static bool _usable;

		private static bool _warned;

		private static List<Unlock> _cache;

		private stat