Decompiled source of HearthCodex v1.2.1

HearthCodex.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("BlackHearthx")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A progressive creature bestiary for Valheim, saved per character.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+dd0dd843730410ee1248a5528ea19adf7b525517")]
[assembly: AssemblyProduct("HearthCodex")]
[assembly: AssemblyTitle("HearthCodex")]
[assembly: AssemblyVersion("1.2.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 CreatureCodex
{
	internal sealed class DungeonBiomeRule
	{
		internal Theme Themes;

		internal Biome Biomes;
	}
	internal static class CodexBiomeRules
	{
		internal static Biome MatchRoomBiomes(Theme roomTheme, IEnumerable<DungeonBiomeRule> sources)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			Biome val = (Biome)0;
			if ((int)roomTheme == 0 || sources == null)
			{
				return val;
			}
			foreach (DungeonBiomeRule source in sources)
			{
				if (source != null && (roomTheme & source.Themes) != 0)
				{
					val |= source.Biomes;
				}
			}
			return val;
		}
	}
	internal static class CodexBook
	{
		private static CodexBookView _view;

		private static string _uiLanguage;

		private static bool _blocking;

		private static bool _listening;

		private static bool _typedLastFrame;

		internal static bool IsOpen
		{
			get
			{
				if (_view != null && (Object)(object)_view.Root != (Object)null)
				{
					return _view.Root.activeSelf;
				}
				return false;
			}
		}

		internal static bool IsTyping
		{
			get
			{
				if (IsOpen)
				{
					if (!_typedLastFrame)
					{
						return _view.IsTyping;
					}
					return true;
				}
				return false;
			}
		}

		internal static void Invalidate()
		{
			SetOpen(open: false);
			if (_view != null)
			{
				_view.Destroy();
				_view = null;
			}
		}

		internal static void Toggle()
		{
			SetOpen(!IsOpen);
		}

		internal static void Close()
		{
			SetOpen(open: false);
		}

		internal static void Tick()
		{
			if (!IsOpen)
			{
				_typedLastFrame = false;
				return;
			}
			bool isTyping = _view.IsTyping;
			bool typedLastFrame = _typedLastFrame;
			_typedLastFrame = isTyping;
			if (!(isTyping || typedLastFrame))
			{
				if (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("JoyButtonB"))
				{
					SetOpen(open: false);
				}
				else if (ZInput.GetKeyDown((KeyCode)273, true) || ZInput.GetKeyDown((KeyCode)276, true))
				{
					_view.Step(-1);
				}
				else if (ZInput.GetKeyDown((KeyCode)274, true) || ZInput.GetKeyDown((KeyCode)275, true))
				{
					_view.Step(1);
				}
			}
		}

		private static void SetOpen(bool open)
		{
			if (open)
			{
				if (!CreatureCatalog.IsBuilt)
				{
					Logger.LogWarning((object)"Creature Codex: the creature catalog is not ready yet.");
					return;
				}
				if (!CreatureDatabase.IsBuilt)
				{
					Logger.LogWarning((object)"Creature Codex: creature data is still being prepared.");
					return;
				}
				EnsureUi();
				if (_view != null && !((Object)(object)_view.Root == (Object)null))
				{
					_view.Refresh();
					_view.Root.SetActive(true);
					SetBlocking(block: true);
					Logger.LogInfo((object)"Creature Codex opened.");
				}
			}
			else
			{
				if (_view != null && (Object)(object)_view.Root != (Object)null)
				{
					_view.EndTyping();
					_view.SaveLayout();
					_view.Root.SetActive(false);
				}
				_typedLastFrame = false;
				if (_blocking)
				{
					SetBlocking(block: false);
					Logger.LogInfo((object)"Creature Codex closed.");
				}
			}
		}

		private static void SetBlocking(bool block)
		{
			if (block != _blocking)
			{
				GUIManager.BlockInput(block);
				_blocking = block;
			}
		}

		private static void EnsureUi()
		{
			string text = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : "English");
			if (_uiLanguage != text && _view != null)
			{
				_view.Destroy();
				_view = null;
			}
			_uiLanguage = text;
			if (!_listening)
			{
				CodexProgress.Changed += OnProgressChanged;
				_listening = true;
			}
			if (_view == null || (Object)(object)_view.Root == (Object)null)
			{
				_view = CodexBookView.TryBuild();
			}
		}

		private static void OnProgressChanged()
		{
			if (IsOpen)
			{
				_view.Refresh();
			}
		}
	}
	internal sealed class CodexBookView
	{
		private sealed class Row
		{
			public CreatureSpecies Species;

			public CreatureData Data;

			public GameObject Go;

			public GameObject Selected;

			public Image Icon;

			public Text IconPlaceholder;

			public Text Name;

			public GameObject StudiedMark;

			public GameObject DiscoveredMark;

			public Text UnknownMark;

			public string SortKey;
		}

		private sealed class CategoryRow
		{
			public Biome Biome;

			public GameObject Selected;

			public Text Label;
		}

		private struct GameManagerRefs
		{
			public GUIManager Gui;

			public Font Bold;

			public Font Regular;
		}

		private const float RowHeight = 34f;

		internal const float MouseWheelSensitivity = 120f;

		private const float RowSpacing = 2f;

		private const float ListPadding = 4f;

		private const float CategoryWidth = 150f;

		private const float CategoryRowHeight = 28f;

		private const float ListWidth = 262f;

		private const float ColumnGap = 10f;

		private const float DesignWidth = 1000f;

		private const float DesignHeight = 660f;

		private const float SearchHeight = 32f;

		private const float SearchGap = 6f;

		private const float StateFilterHeight = 30f;

		private CodexStateFilter _stateFilter;

		private Text _stateFilterLabel;

		private const int SearchMaxLength = 32;

		private const Biome BossCategory = (Biome)(-1);

		internal static readonly Color Cream = new Color(0.93f, 0.88f, 0.76f, 1f);

		internal static readonly Color Muted = new Color(0.62f, 0.58f, 0.5f, 1f);

		private static readonly Color PanelColor = new Color(0f, 0f, 0f, 0.38f);

		internal static readonly Color RowColor = new Color(0f, 0f, 0f, 0.22f);

		internal static readonly Color FrameColor = new Color(0.12f, 0.09f, 0.06f, 0.85f);

		private static readonly Regex RichTextTags = new Regex("<[^>]+>");

		internal static readonly Biome[] Categories;

		private static readonly Dictionary<Biome, string> BiomeLabels;

		private readonly List<Row> _rows = new List<Row>();

		private readonly List<Row> _visible = new List<Row>();

		private readonly List<CategoryRow> _categories = new List<CategoryRow>();

		private GameManagerRefs _gm;

		private Text _progress;

		private RectTransform _viewport;

		private RectTransform _content;

		private Scrollbar _scrollbar;

		private Text _emptyMessage;

		private CodexDetailPage _page;

		private InputField _search;

		private GameObject _searchClear;

		private Biome _filter;

		private string _query = string.Empty;

		private CreatureSpecies _selected;

		internal GameObject Root { get; private set; }

		internal bool IsTyping
		{
			get
			{
				if ((Object)(object)_search != (Object)null)
				{
					return _search.isFocused;
				}
				return false;
			}
		}

		internal static CodexBookView TryBuild()
		{
			if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
			{
				Logger.LogWarning((object)"Creature Codex: the game UI is not ready yet.");
				return null;
			}
			CodexBookView codexBookView = new CodexBookView();
			codexBookView.Build();
			return codexBookView;
		}

		internal void Destroy()
		{
			CodexPortraits.Clear();
			if ((Object)(object)Root != (Object)null)
			{
				Object.Destroy((Object)(object)Root);
				Root = null;
			}
		}

		internal void Refresh()
		{
			FitToScreen();
			foreach (Row row in _rows)
			{
				StyleRow(row);
			}
			SortRows();
			UpdateProgress();
			ApplyFilter();
		}

		internal void EndTyping()
		{
			if ((Object)(object)_search != (Object)null && _search.isFocused)
			{
				_search.DeactivateInputField();
			}
		}

		internal void SaveLayout()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			GameObject root = Root;
			Transform obj = ((root != null) ? root.transform : null);
			RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			if (val != null)
			{
				FitToScreen();
				if (!Mathf.Approximately(PluginConfig.WindowPositionX.Value, val.anchoredPosition.x))
				{
					PluginConfig.WindowPositionX.Value = val.anchoredPosition.x;
				}
				if (!Mathf.Approximately(PluginConfig.WindowPositionY.Value, val.anchoredPosition.y))
				{
					PluginConfig.WindowPositionY.Value = val.anchoredPosition.y;
				}
			}
		}

		internal void Step(int delta)
		{
			if (_visible.Count != 0)
			{
				int num = _visible.FindIndex((Row r) => r.Species == _selected);
				num = ((num >= 0) ? Mathf.Clamp(num + delta, 0, _visible.Count - 1) : 0);
				Select(_visible[num]);
			}
		}

		private void Build()
		{
			//IL_0067: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			_gm = new GameManagerRefs
			{
				Gui = GUIManager.Instance,
				Bold = GUIManager.Instance.AveriaSerifBold,
				Regular = GUIManager.Instance.AveriaSerif
			};
			BiomeLabels.Clear();
			Root = _gm.Gui.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(PluginConfig.WindowPositionX.Value, PluginConfig.WindowPositionY.Value), 1000f, 660f, true);
			((Object)Root).name = "CreatureCodex_Book";
			FitToScreen();
			BuildHeader();
			BuildFooter();
			RectTransform body = MakeRect("Body", Root.transform, Vector2.zero, Vector2.one, new Vector2(24f, 72f), new Vector2(-24f, -96f));
			BuildCategories(body);
			BuildList(body);
			BuildDetail(body);
			Root.SetActive(false);
			Logger.LogInfo((object)("Creature Codex: book ready with " + _rows.Count + " species."));
		}

		private void FitToScreen()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00bf: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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)
			RectTransform val = (RectTransform)(((Object)(object)Root != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Rect rect = val.rect;
			if (!(((Rect)(ref rect)).width <= 0f))
			{
				rect = val.rect;
				if (!(((Rect)(ref rect)).height <= 0f))
				{
					rect = val.rect;
					float width = ((Rect)(ref rect)).width;
					rect = val.rect;
					float num = CodexPresentation.EffectiveScale(width, ((Rect)(ref rect)).height, 1000f, 660f, PluginConfig.InterfaceScale.Value);
					Root.transform.localScale = Vector3.one * num;
					RectTransform val2 = (RectTransform)Root.transform;
					float x = val2.anchoredPosition.x;
					rect = val.rect;
					float num2 = CodexPresentation.ClampOffset(x, ((Rect)(ref rect)).width, 1000f, num);
					float y = val2.anchoredPosition.y;
					rect = val.rect;
					val2.anchoredPosition = new Vector2(num2, CodexPresentation.ClampOffset(y, ((Rect)(ref rect)).height, 660f, num));
				}
			}
		}

		private void BuildHeader()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakeRect("Header", Root.transform, new Vector2(0f, 1f), Vector2.one, new Vector2(24f, -90f), new Vector2(-24f, -18f));
			Stretch(((Graphic)MakeText("Title", (Transform)(object)parent, CodexText.Title.ToUpper(CultureInfo.CurrentCulture), _gm.Bold, 30, _gm.Gui.ValheimOrange, (TextAnchor)4)).rectTransform, new Vector2(0f, 0.4f), Vector2.one);
			_progress = MakeText("Progress", (Transform)(object)parent, string.Empty, _gm.Regular, 15, _gm.Gui.ValheimBeige, (TextAnchor)4);
			Stretch(((Graphic)_progress).rectTransform, new Vector2(0f, 0.08f), new Vector2(1f, 0.4f));
			((Graphic)AddImage(((Component)MakeRect("Rule", (Transform)(object)parent, new Vector2(0.3f, 0f), new Vector2(0.7f, 0f), new Vector2(0f, 0f), new Vector2(0f, 1f))).gameObject, new Color(_gm.Gui.ValheimOrange.r, _gm.Gui.ValheimOrange.g, _gm.Gui.ValheimOrange.b, 0.3f))).raycastTarget = false;
		}

		private void BuildFooter()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakeRect("Footer", Root.transform, Vector2.zero, new Vector2(1f, 0f), new Vector2(24f, 16f), new Vector2(-24f, 62f));
			MakeButton(CodexText.Previous, parent, new Vector2(0f, 0.5f), new Vector2(70f, 0f), 130f, delegate
			{
				Step(-1);
			});
			MakeButton(CodexText.Next, parent, new Vector2(0f, 0.5f), new Vector2(210f, 0f), 130f, delegate
			{
				Step(1);
			});
			MakeButton(CodexText.Close, parent, new Vector2(1f, 0.5f), new Vector2(-70f, 0f), 130f, CodexBook.Close);
		}

		private void MakeButton(string label, RectTransform parent, Vector2 anchor, Vector2 position, float width, Action onClick)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			((UnityEvent)_gm.Gui.CreateButton(label, (Transform)(object)parent, anchor, anchor, position, width, 38f).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				onClick();
			});
		}

		private unsafe void BuildCategories(RectTransform body)
		{
			//IL_0006: 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)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Invalid comparison between Unknown and I4
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = MakeRect("Categories", (Transform)(object)body, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(150f, 0f));
			AddImage(((Component)val).gameObject, PanelColor);
			VerticalLayoutGroup obj = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(6, 6, 6, 6);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 2f;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			Biome[] categories = Categories;
			for (int i = 0; i < categories.Length; i++)
			{
				Biome val2 = categories[i];
				CategoryRow categoryRow = new CategoryRow
				{
					Biome = val2
				};
				GameObject val3 = new GameObject("Category_" + ((object)(*(Biome*)(&val2))/*cast due to .constrained prefix*/).ToString(), new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent((Transform)(object)val, false);
				val3.AddComponent<LayoutElement>().preferredHeight = 28f;
				Image background = AddImage(val3, Color.white);
				categoryRow.Selected = MakeSelectedOverlay(val3.transform);
				string text = (((int)val2 == 0 || (int)val2 == -1) ? BiomeLabel(val2).ToUpper(CultureInfo.CurrentCulture) : BiomeLabel(val2));
				categoryRow.Label = MakeText("Label", val3.transform, text, _gm.Bold, 15, Cream, (TextAnchor)3);
				Stretch(((Graphic)categoryRow.Label).rectTransform, Vector2.zero, Vector2.one, new Vector2(12f, 0f), new Vector2(-6f, 0f));
				categoryRow.Label.resizeTextForBestFit = true;
				categoryRow.Label.resizeTextMinSize = 12;
				categoryRow.Label.resizeTextMaxSize = 15;
				Button obj2 = AddRowButton(val3, background);
				Biome captured = val2;
				((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					SetFilter(captured);
				});
				_categories.Add(categoryRow);
			}
		}

		private void BuildList(RectTransform body)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			float num = 160f;
			BuildSearch(body, num);
			BuildStateFilter(body, num);
			RectTransform val = MakeRect("CreatureList", (Transform)(object)body, Vector2.zero, new Vector2(0f, 1f), new Vector2(num, 0f), new Vector2(num + 262f, -74f));
			AddImage(((Component)val).gameObject, PanelColor);
			ScrollRect obj = ((Component)val).gameObject.AddComponent<ScrollRect>();
			obj.horizontal = false;
			obj.vertical = true;
			obj.movementType = (MovementType)2;
			obj.scrollSensitivity = 120f;
			_viewport = MakeRect("Viewport", (Transform)(object)val, Vector2.zero, Vector2.one, new Vector2(4f, 4f), new Vector2(-18f, -4f));
			((Component)_viewport).gameObject.AddComponent<RectMask2D>();
			_content = MakeRect("Content", (Transform)(object)_viewport, new Vector2(0f, 1f), Vector2.one, Vector2.zero, Vector2.zero);
			_content.pivot = new Vector2(0.5f, 1f);
			VerticalLayoutGroup obj2 = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(4, 4, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 2f;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((Component)_content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			obj.viewport = _viewport;
			obj.content = _content;
			_scrollbar = BuildScrollbar(val);
			obj.verticalScrollbar = _scrollbar;
			obj.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			_emptyMessage = MakeText("Empty", (Transform)(object)val, CodexText.EmptyCategory, _gm.Regular, 16, Muted, (TextAnchor)4);
			Stretch(((Graphic)_emptyMessage).rectTransform, Vector2.zero, Vector2.one, new Vector2(16f, 0f), new Vector2(-16f, 0f));
			_emptyMessage.fontStyle = (FontStyle)2;
			((Component)_emptyMessage).gameObject.SetActive(false);
			foreach (CreatureSpecies item in CreatureCatalog.Species)
			{
				_rows.Add(BuildRow(item));
			}
			SortRows();
		}

		private void BuildStateFilter(RectTransform body, float left)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			GameObject val = _gm.Gui.CreateButton(string.Empty, (Transform)(object)body, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(left + 131f, -53f), 262f, 30f);
			((Object)val).name = "StateFilter";
			_stateFilterLabel = val.GetComponentInChildren<Text>();
			_stateFilterLabel.fontSize = 14;
			_stateFilterLabel.resizeTextForBestFit = true;
			_stateFilterLabel.resizeTextMinSize = 12;
			_stateFilterLabel.resizeTextMaxSize = 14;
			Button component = val.GetComponent<Button>();
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)component).navigation = navigation;
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				_stateFilter = (CodexStateFilter)((int)(_stateFilter + 1) % 4);
				_selected = null;
				ApplyFilter();
			});
			UpdateStateFilterLabel();
		}

		private void UpdateStateFilterLabel()
		{
			string arg = ((_stateFilter == CodexStateFilter.Unknown) ? CodexText.FilterUnknown : ((_stateFilter == CodexStateFilter.Discovered) ? CodexText.FilterDiscovered : ((_stateFilter == CodexStateFilter.Studied) ? CodexText.FilterStudied : CodexText.CategoryAll)));
			_stateFilterLabel.text = string.Format(CodexText.StateFilterFormat, arg);
		}

		private void BuildSearch(RectTransform body, float left)
		{
			//IL_0016: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = _gm.Gui.CreateInputField((Transform)(object)body, new Vector2(0f, 1f), new Vector2(0f, 1f), Vector2.zero, (ContentType)0, CodexText.SearchPlaceholder, 16, 0f, 0f);
			((Object)val).name = "Search";
			RectTransform val2 = (RectTransform)val.transform;
			val2.pivot = new Vector2(0.5f, 0.5f);
			Stretch(val2, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(left, -32f), new Vector2(left + 262f, 0f));
			_search = val.GetComponent<InputField>();
			_search.characterLimit = 32;
			ColorBlock colors = ((Selectable)_search).colors;
			((ColorBlock)(ref colors)).normalColor = new Color(0.78f, 0.75f, 0.7f, 1f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.9f, 0.87f, 0.82f, 1f);
			((ColorBlock)(ref colors)).pressedColor = Color.white;
			((ColorBlock)(ref colors)).selectedColor = Color.white;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.08f;
			((Selectable)_search).colors = colors;
			InputField search = _search;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)search).navigation = navigation;
			_search.lineType = (LineType)0;
			Stretch(((Graphic)_search.textComponent).rectTransform, Vector2.zero, Vector2.one, new Vector2(10f, 4f), new Vector2(-30f, -4f));
			Stretch(_search.placeholder.rectTransform, Vector2.zero, Vector2.one, new Vector2(10f, 4f), new Vector2(-30f, -4f));
			_search.textComponent.alignment = (TextAnchor)3;
			Graphic placeholder = _search.placeholder;
			Text val3 = (Text)(object)((placeholder is Text) ? placeholder : null);
			if (val3 != null)
			{
				val3.alignment = (TextAnchor)3;
				val3.fontStyle = (FontStyle)2;
				((Graphic)val3).color = Muted;
			}
			RectTransform val4 = MakeRect("Clear", (Transform)(object)val2, new Vector2(1f, 0f), Vector2.one, new Vector2(-28f, 0f), Vector2.zero);
			Text val5 = MakeText("Label", (Transform)(object)val4, CodexText.SearchClear, _gm.Bold, 20, Cream, (TextAnchor)4);
			Stretch(((Graphic)val5).rectTransform, Vector2.zero, Vector2.one);
			((Graphic)val5).raycastTarget = true;
			Button obj = ((Component)val4).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val5;
			ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock;
			((ColorBlock)(ref defaultColorBlock)).normalColor = new Color(0.68f, 0.64f, 0.56f, 1f);
			((ColorBlock)(ref defaultColorBlock)).highlightedColor = _gm.Gui.ValheimOrange;
			((ColorBlock)(ref defaultColorBlock)).pressedColor = Color.white;
			((ColorBlock)(ref defaultColorBlock)).selectedColor = ((ColorBlock)(ref defaultColorBlock)).normalColor;
			((Selectable)obj).colors = defaultColorBlock;
			navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj).navigation = navigation;
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				_search.text = string.Empty;
			});
			_searchClear = ((Component)val4).gameObject;
			_searchClear.SetActive(false);
			((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)OnSearchChanged);
		}

		private void OnSearchChanged(string text)
		{
			string text2 = (text ?? string.Empty).Trim();
			_searchClear.SetActive(text != null && text.Length > 0);
			if (!(text2 == _query))
			{
				_query = text2;
				ApplyFilter();
			}
		}

		internal Scrollbar BuildScrollbar(RectTransform column)
		{
			//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)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0073: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = MakeRect("Scrollbar", (Transform)(object)column, new Vector2(1f, 0f), Vector2.one, new Vector2(-14f, 4f), new Vector2(-4f, -4f));
			AddImage(((Component)val).gameObject, new Color(0f, 0f, 0f, 0.4f));
			RectTransform parent = MakeRect("SlidingArea", (Transform)(object)val, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			RectTransform val2 = MakeRect("Handle", (Transform)(object)parent, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			Image targetGraphic = AddImage(((Component)val2).gameObject, new Color(0.55f, 0.42f, 0.25f, 1f));
			Scrollbar val3 = ((Component)val).gameObject.AddComponent<Scrollbar>();
			val3.direction = (Direction)2;
			val3.handleRect = val2;
			((Selectable)val3).targetGraphic = (Graphic)(object)targetGraphic;
			try
			{
				_gm.Gui.ApplyScrollbarStyle(val3);
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("Creature Codex: kept the plain scrollbar, Valheim style could not be applied. " + ex.Message));
			}
			return val3;
		}

		private Row BuildRow(CreatureSpecies species)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00c6: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: 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_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Expected O, but got Unknown
			CreatureDatabase.TryGet(species.DisplayToken, out var data);
			Row row = new Row
			{
				Species = species,
				Data = data,
				SortKey = RichTextTags.Replace(species.DisplayName ?? string.Empty, string.Empty).Trim()
			};
			row.Go = new GameObject("Creature", new Type[1] { typeof(RectTransform) });
			row.Go.transform.SetParent((Transform)(object)_content, false);
			row.Go.AddComponent<LayoutElement>().preferredHeight = 34f;
			Image background = AddImage(row.Go, Color.white);
			row.Selected = MakeSelectedOverlay(row.Go.transform);
			RectTransform val = MakeRect("IconFrame", row.Go.transform, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), Vector2.zero, Vector2.zero);
			val.sizeDelta = new Vector2(28f, 28f);
			val.anchoredPosition = new Vector2(22f, 0f);
			((Graphic)AddImage(((Component)val).gameObject, FrameColor)).raycastTarget = false;
			RectTransform val2 = MakeRect("Icon", (Transform)(object)val, Vector2.zero, Vector2.one, new Vector2(2f, 2f), new Vector2(-2f, -2f));
			row.Icon = AddImage(((Component)val2).gameObject, Color.white);
			row.Icon.preserveAspect = true;
			((Graphic)row.Icon).raycastTarget = false;
			row.IconPlaceholder = MakeText("Placeholder", (Transform)(object)val, "?", _gm.Bold, 16, Muted, (TextAnchor)4);
			Stretch(((Graphic)row.IconPlaceholder).rectTransform, Vector2.zero, Vector2.one);
			row.Name = MakeText("Name", row.Go.transform, string.Empty, _gm.Bold, 16, Cream, (TextAnchor)3);
			Stretch(((Graphic)row.Name).rectTransform, Vector2.zero, Vector2.one, new Vector2(44f, 0f), new Vector2(-26f, 0f));
			row.Name.resizeTextForBestFit = true;
			row.Name.resizeTextMinSize = 12;
			row.Name.resizeTextMaxSize = 16;
			row.StudiedMark = MakeDiamond(row.Go.transform, 9f, _gm.Gui.ValheimOrange, null);
			row.DiscoveredMark = MakeDiamond(row.Go.transform, 9f, _gm.Gui.ValheimBeige, (Color?)new Color(0.1f, 0.07f, 0.05f, 1f));
			row.UnknownMark = MakeText("Unknown", row.Go.transform, "?", _gm.Bold, 14, Muted, (TextAnchor)4);
			RectTransform rectTransform = ((Graphic)row.UnknownMark).rectTransform;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(1f, 0.5f);
			rectTransform.anchorMax = val3;
			rectTransform.anchorMin = val3;
			rectTransform.sizeDelta = new Vector2(16f, 20f);
			rectTransform.anchoredPosition = new Vector2(-13f, 0f);
			((UnityEvent)AddRowButton(row.Go, background).onClick).AddListener((UnityAction)delegate
			{
				Select(row);
			});
			return row;
		}

		private void BuildDetail(RectTransform body)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: Unknown result type (might be due to invalid IL or missing references)
			float num = 432f;
			RectTransform val = MakeRect("Detail", (Transform)(object)body, Vector2.zero, Vector2.one, new Vector2(num, 0f), Vector2.zero);
			AddImage(((Component)val).gameObject, PanelColor);
			_page = new CodexDetailPage(this, val);
		}

		private void StyleRow(Row row)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			CodexKnowledge knowledge = row.Species.Knowledge;
			bool flag = knowledge != CodexKnowledge.Unknown;
			row.Name.text = (flag ? row.Species.DisplayName : CodexText.UnknownName);
			((Graphic)row.Name).color = (flag ? Cream : Muted);
			row.Name.font = (flag ? _gm.Bold : _gm.Regular);
			row.Name.fontStyle = (FontStyle)((!flag) ? 2 : 0);
			Sprite val = (flag ? CodexIcons.GetTrophyIcon(row.Data) : null);
			row.Icon.sprite = val;
			((Behaviour)row.Icon).enabled = (Object)(object)val != (Object)null;
			((Behaviour)row.IconPlaceholder).enabled = (Object)(object)val == (Object)null;
			row.StudiedMark.SetActive(knowledge == CodexKnowledge.Studied);
			row.DiscoveredMark.SetActive(knowledge == CodexKnowledge.Discovered);
			((Component)row.UnknownMark).gameObject.SetActive(!flag);
		}

		private void UpdateProgress()
		{
			int speciesCount = CreatureCatalog.SpeciesCount;
			int num = 0;
			int num2 = 0;
			foreach (CreatureSpecies item in CreatureCatalog.Species)
			{
				if (item.Knowledge >= CodexKnowledge.Discovered)
				{
					num2++;
				}
				if (item.Knowledge == CodexKnowledge.Studied)
				{
					num++;
				}
			}
			_progress.text = string.Format(CodexText.ProgressFormat, num, num2, speciesCount);
		}

		private void SetFilter(Biome biome)
		{
			//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_000b: 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)
			if (_filter != biome)
			{
				_filter = biome;
				_selected = null;
				ApplyFilter();
			}
		}

		private void ApplyFilter()
		{
			//IL_001c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			UpdateStateFilterLabel();
			foreach (CategoryRow category in _categories)
			{
				bool flag = category.Biome == _filter;
				category.Selected.SetActive(flag);
				((Graphic)category.Label).color = (flag ? Color.white : Cream);
			}
			_visible.Clear();
			foreach (Row row2 in _rows)
			{
				bool flag2 = Matches(row2);
				row2.Go.SetActive(flag2);
				if (flag2)
				{
					_visible.Add(row2);
				}
			}
			_emptyMessage.text = ((_stateFilter != CodexStateFilter.All) ? CodexText.EmptyFilters : ((_query.Length > 0) ? CodexText.NoSearchResults : CodexText.EmptyCategory));
			((Component)_emptyMessage).gameObject.SetActive(_visible.Count == 0);
			Row row = _visible.FirstOrDefault((Row r) => r.Species == _selected);
			if (row != null)
			{
				Select(row);
				return;
			}
			if (_visible.Count > 0)
			{
				_content.anchoredPosition = Vector2.zero;
				Select(_visible[0]);
				return;
			}
			_selected = null;
			foreach (Row row3 in _rows)
			{
				row3.Selected.SetActive(false);
			}
			ShowDetail(null);
		}

		private bool Matches(Row row)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			if (!CodexPresentation.ShowSpecies(PluginConfig.ShowUnknownCreatures.Value, row.Species.Knowledge))
			{
				return false;
			}
			if ((int)_filter == -1)
			{
				if (row.Species.IsBoss)
				{
					return CodexFilters.Matches(_stateFilter, row.Species.Knowledge, biomeMatches: true, row.SortKey, _query, CodexText.UnknownName);
				}
				return false;
			}
			bool allBiomes = (int)_filter == 0;
			bool dataBiomeMatches = row.Data != null && (row.Data.Biomes & _filter) > 0;
			return CodexFilters.Matches(_stateFilter, row.Species.Knowledge, CodexFilters.MatchesBiome(row.Species.Knowledge, allBiomes, dataBiomeMatches), row.SortKey, _query, CodexText.UnknownName);
		}

		private void SortRows()
		{
			_rows.Sort((Row a, Row b) => CodexFilters.CompareForDisplay(a.Species.Knowledge, a.SortKey, a.Species.DisplayToken, b.Species.Knowledge, b.SortKey, b.Species.DisplayToken));
			for (int num = 0; num < _rows.Count; num++)
			{
				_rows[num].Go.transform.SetSiblingIndex(num);
			}
		}

		private void Select(Row row)
		{
			_selected = row.Species;
			foreach (Row row2 in _rows)
			{
				row2.Selected.SetActive(row2 == row);
			}
			ShowDetail(row);
			ScrollIntoView(_visible.IndexOf(row));
			LogLayout();
		}

		private void LogLayout()
		{
			//IL_0064: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.VerboseBookLogging.Value)
			{
				Transform parent = Root.transform.parent;
				RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				RectTransform val2 = (((Object)(object)_scrollbar != (Object)null) ? _scrollbar.handleRect : null);
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				object[] array = new object[11];
				float num;
				Rect rect;
				if (!((Object)(object)val != (Object)null))
				{
					num = 0f;
				}
				else
				{
					rect = val.rect;
					num = ((Rect)(ref rect)).width;
				}
				array[0] = num;
				float num2;
				if (!((Object)(object)val != (Object)null))
				{
					num2 = 0f;
				}
				else
				{
					rect = val.rect;
					num2 = ((Rect)(ref rect)).height;
				}
				array[1] = num2;
				array[2] = Root.transform.localScale.x;
				array[3] = _visible.Count;
				rect = _viewport.rect;
				array[4] = ((Rect)(ref rect)).height;
				rect = _content.rect;
				array[5] = ((Rect)(ref rect)).height;
				array[6] = _content.anchoredPosition.y;
				array[7] = (((Object)(object)_scrollbar != (Object)null) ? _scrollbar.size : (-1f));
				array[8] = (((Object)(object)_scrollbar != (Object)null) ? _scrollbar.value : (-1f));
				array[9] = (((Object)(object)val2 != (Object)null) ? val2.anchorMin.y : (-1f));
				array[10] = (((Object)(object)val2 != (Object)null) ? val2.anchorMax.y : (-1f));
				Logger.LogInfo((object)string.Format(invariantCulture, "Creature Codex book layout: canvas {0:0}x{1:0}, scale {2:0.00}, visible rows {3}, viewport h {4:0}, content h {5:0}, content y {6:0}, scrollbar size {7:0.00} value {8:0.00}, handle anchors y {9:0.00}-{10:0.00}", array));
			}
		}

		private void ShowDetail(Row row)
		{
			_page.Show(row?.Species, row?.Data);
		}

		private void ScrollIntoView(int index)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (index >= 0)
			{
				Rect rect = _viewport.rect;
				float height = ((Rect)(ref rect)).height;
				float num = 8f + (float)_visible.Count * 34f + (float)Mathf.Max(0, _visible.Count - 1) * 2f;
				float num2 = 4f + (float)index * 36f;
				float num3 = _content.anchoredPosition.y;
				if (num2 < num3)
				{
					num3 = num2;
				}
				else if (num2 + 34f > num3 + height)
				{
					num3 = num2 + 34f - height;
				}
				num3 = Mathf.Clamp(num3, 0f, Mathf.Max(0f, num - height));
				_content.anchoredPosition = new Vector2(_content.anchoredPosition.x, num3);
			}
		}

		private static Button AddRowButton(GameObject go, Image background)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			Button obj = go.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)background;
			((Selectable)obj).transition = (Transition)1;
			ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock;
			((ColorBlock)(ref defaultColorBlock)).normalColor = RowColor;
			((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(0.32f, 0.23f, 0.13f, 0.45f);
			((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.42f, 0.3f, 0.16f, 0.55f);
			((ColorBlock)(ref defaultColorBlock)).selectedColor = RowColor;
			((ColorBlock)(ref defaultColorBlock)).disabledColor = RowColor;
			((ColorBlock)(ref defaultColorBlock)).colorMultiplier = 1f;
			((ColorBlock)(ref defaultColorBlock)).fadeDuration = 0.08f;
			((Selectable)obj).colors = defaultColorBlock;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj).navigation = navigation;
			return obj;
		}

		private GameObject MakeSelectedOverlay(Transform parent)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Color valheimOrange = _gm.Gui.ValheimOrange;
			RectTransform val = MakeRect("Selected", parent, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero);
			((Graphic)AddImage(((Component)val).gameObject, new Color(valheimOrange.r, valheimOrange.g, valheimOrange.b, 0.2f))).raycastTarget = false;
			((Graphic)AddImage(((Component)MakeRect("Accent", (Transform)(object)val, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(3f, 0f))).gameObject, valheimOrange)).raycastTarget = false;
			((Transform)val).SetAsFirstSibling();
			((Component)val).gameObject.SetActive(false);
			return ((Component)val).gameObject;
		}

		private static GameObject MakeDiamond(Transform parent, float size, Color color, Color? hole)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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)
			RectTransform val = MakeRect("Mark", parent, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), Vector2.zero, Vector2.zero);
			val.sizeDelta = new Vector2(size, size);
			val.anchoredPosition = new Vector2(-13f, 0f);
			((Transform)val).localRotation = Quaternion.Euler(0f, 0f, 45f);
			((Graphic)AddImage(((Component)val).gameObject, color)).raycastTarget = false;
			if (hole.HasValue)
			{
				((Graphic)AddImage(((Component)MakeRect("Hole", (Transform)(object)val, Vector2.zero, Vector2.one, new Vector2(2f, 2f), new Vector2(-2f, -2f))).gameObject, hole.Value)).raycastTarget = false;
			}
			((Component)val).gameObject.SetActive(false);
			return ((Component)val).gameObject;
		}

		internal static string BiomeLabel(Biome biome)
		{
			//IL_0005: 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)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!BiomeLabels.TryGetValue(biome, out var value))
			{
				value = ReadBiomeLabel(biome);
				BiomeLabels[biome] = value;
			}
			return value;
		}

		private unsafe static string ReadBiomeLabel(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected I4, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			if ((int)biome <= 32)
			{
				switch (biome - -1)
				{
				default:
					if ((int)biome != 16)
					{
						if ((int)biome != 32)
						{
							break;
						}
						return LocalizeOr("$biome_ashlands", "Ashlands");
					}
					return LocalizeOr("$biome_plains", "Plains");
				case 1:
					return CodexText.CategoryAll;
				case 0:
					return CodexText.CategoryBosses;
				case 2:
					return LocalizeOr("$biome_meadows", "Meadows");
				case 9:
					return LocalizeOr("$biome_blackforest", "Black Forest");
				case 3:
					return LocalizeOr("$biome_swamp", "Swamp");
				case 5:
					return LocalizeOr("$biome_mountain", "Mountain");
				case 4:
				case 6:
				case 7:
				case 8:
					break;
				}
			}
			else
			{
				if ((int)biome == 64)
				{
					return LocalizeOr("$biome_deepnorth", "Deep North");
				}
				if ((int)biome == 256)
				{
					return LocalizeOr("$biome_ocean", "Ocean");
				}
				if ((int)biome == 512)
				{
					return LocalizeOr("$biome_mistlands", "Mistlands");
				}
			}
			return ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString();
		}

		internal static string LocalizeOr(string token, string fallback)
		{
			if (Localization.instance == null)
			{
				return fallback;
			}
			string text = Localization.instance.Localize(token);
			if (!string.IsNullOrEmpty(text) && !(text == "[" + token.Substring(1) + "]"))
			{
				return text;
			}
			return fallback;
		}

		internal static RectTransform MakeRect(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			//IL_0046: 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_004f: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform val2 = (RectTransform)val.transform;
			val2.anchorMin = anchorMin;
			val2.anchorMax = anchorMax;
			val2.offsetMin = offsetMin;
			val2.offsetMax = offsetMax;
			return val2;
		}

		internal static Image AddImage(GameObject go, Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Image obj = go.AddComponent<Image>();
			((Graphic)obj).color = color;
			return obj;
		}

		internal static Text MakeText(string name, Transform parent, string text, Font font, int size, Color color, TextAnchor alignment)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			Text obj = val.AddComponent<Text>();
			obj.font = font;
			obj.fontSize = size;
			((Graphic)obj).color = color;
			obj.alignment = alignment;
			obj.text = text;
			obj.supportRichText = true;
			obj.horizontalOverflow = (HorizontalWrapMode)0;
			obj.verticalOverflow = (VerticalWrapMode)0;
			((Graphic)obj).raycastTarget = false;
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = new Color(0f, 0f, 0f, 0.9f);
			((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
			return obj;
		}

		internal static void Stretch(RectTransform rect, Vector2 anchorMin, Vector2 anchorMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Stretch(rect, anchorMin, anchorMax, Vector2.zero, Vector2.zero);
		}

		internal static void Stretch(RectTransform rect, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = anchorMin;
			rect.anchorMax = anchorMax;
			rect.offsetMin = offsetMin;
			rect.offsetMax = offsetMax;
		}

		internal static void TopBand(RectTransform rect, float centerY, float height)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(1f, 1f);
			rect.offsetMin = new Vector2(16f, centerY - height * 0.5f);
			rect.offsetMax = new Vector2(-16f, centerY + height * 0.5f);
		}

		static CodexBookView()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Biome[] array = new Biome[11];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Categories = (Biome[])(object)array;
			BiomeLabels = new Dictionary<Biome, string>();
		}
	}
	internal sealed class CodexDetailPage
	{
		private enum LineStyle
		{
			Entry,
			Title,
			Minor,
			Gap
		}

		private sealed class Line
		{
			public GameObject Go;

			public LayoutElement Element;

			public Text Label;

			public Text Value;
		}

		private sealed class Section
		{
			public GameObject Go;

			public Text Message;

			public readonly List<Line> Lines = new List<Line>();

			public int Used;
		}

		private sealed class DropRow
		{
			public GameObject Go;

			public Image Icon;

			public Text Name;

			public Text Amount;

			public Text Chance;
		}

		private sealed class WeaponRow
		{
			internal GameObject Go;

			internal Image Icon;

			internal Text Name;

			internal Text Reason;
		}

		private const float HeaderHeight = 128f;

		private const float EntryHeight = 22f;

		private const float TitleHeight = 24f;

		private const float MinorHeight = 20f;

		private const float GapHeight = 6f;

		private const float DropRowHeight = 28f;

		private const float WeakSpotIndent = 14f;

		private const float ValueColumn = 0.45f;

		private const float AmountRight = -62f;

		private const float ColumnWidth = 52f;

		private const int BiomesPerLine = 3;

		private const string FadedHex = "9E9480";

		private static readonly Color Minor = new Color(0.8f, 0.76f, 0.66f, 1f);

		private static readonly DamageModifier[] ModifierOrder;

		private readonly CodexBookView _view;

		private readonly Font _bold;

		private readonly Font _regular;

		private readonly Color _orange;

		private readonly Color _beige;

		private readonly StringBuilder _sb = new StringBuilder();

		private readonly List<DropRow> _dropRows = new List<DropRow>();

		private readonly List<string> _parts = new List<string>();

		private readonly Dictionary<DamageType, string> _typeLabels = new Dictionary<DamageType, string>();

		private readonly Dictionary<DamageModifier, string> _modifierLabels = new Dictionary<DamageModifier, string>();

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

		private ScrollRect _scroll;

		private RectTransform _content;

		private Image _icon;

		private Text _iconPlaceholder;

		private Text _name;

		private Text _state;

		private Text _defeated;

		private Text _hint;

		private Section _biomes;

		private Section _health;

		private Text _healthValue;

		private Text _healthCaption;

		private Text _healthNote;

		private Section _damage;

		private Section _weakSpots;

		private Section _drops;

		private GameObject _dropsHeader;

		private Text _dropsNote;

		private Section _weapons;

		private Text _weaponsNote;

		private readonly List<WeaponRow> _weaponRows = new List<WeaponRow>();

		private CreatureSpecies _shown;

		internal CodexDetailPage(CodexBookView view, RectTransform panel)
		{
			//IL_0085: 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_0095: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			_view = view;
			_bold = GUIManager.Instance.AveriaSerifBold;
			_regular = GUIManager.Instance.AveriaSerif;
			_orange = GUIManager.Instance.ValheimOrange;
			_beige = GUIManager.Instance.ValheimBeige;
			BuildScroll(panel);
			BuildHeader();
			_hint = CodexBookView.MakeText("Hint", (Transform)(object)_content, string.Empty, _regular, 16, CodexBookView.Muted, (TextAnchor)1);
			_hint.fontStyle = (FontStyle)2;
			_hint.lineSpacing = 1.15f;
			_damage = MakeSection("Damage", CodexText.SectionDamage);
			_weapons = MakeSection("Weapons", CodexText.SectionWeapons);
			_weaponsNote = CodexBookView.MakeText("Note", _weapons.Go.transform, CodexText.WeaponsNote, _regular, 13, Minor, (TextAnchor)0);
			_weaponsNote.lineSpacing = 1.1f;
			_weakSpots = MakeSection("WeakSpots", CodexText.SectionWeakSpots);
			_health = MakeSection("Health", CodexText.SectionHealth);
			BuildHealth();
			_biomes = MakeSection("Biomes", CodexText.SectionBiomes);
			_drops = MakeSection("Drops", CodexText.SectionDrops);
			BuildDropsHeader();
			_dropsNote = CodexBookView.MakeText("Note", _drops.Go.transform, string.Empty, _regular, 13, CodexBookView.Muted, (TextAnchor)0);
			_dropsNote.lineSpacing = 1.1f;
			Show(null, null);
		}

		internal void Show(CreatureSpecies species, CreatureData data)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (species != _shown)
			{
				_shown = species;
				_scroll.StopMovement();
				_content.anchoredPosition = Vector2.zero;
			}
			if (species == null)
			{
				SetHeader(null, string.Empty, string.Empty, string.Empty, showFrame: false, known: false);
				SetHint(string.Empty);
				ShowSections(show: false);
				return;
			}
			CodexKnowledge knowledge = species.Knowledge;
			bool num = knowledge != CodexKnowledge.Unknown;
			Sprite icon = (num ? (CodexIcons.GetTrophyIcon(data) ?? CodexPortraits.Get(species, data)) : null);
			string name = (num ? species.DisplayName : CodexText.UnknownName);
			switch (knowledge)
			{
			case CodexKnowledge.Studied:
				SetHeader(icon, name, CodexText.StateStudied, string.Format(CodexText.DefeatedFormat, species.TimesSlain), showFrame: true, known: true);
				break;
			case CodexKnowledge.Discovered:
				SetHeader(icon, name, CodexText.StateDiscovered, string.Empty, showFrame: true, known: true);
				break;
			default:
				SetHeader(null, name, CodexText.StateUnknown, string.Empty, showFrame: true, known: false);
				break;
			}
			bool flag = knowledge == CodexKnowledge.Studied && data != null && data.Primary != null;
			ShowSections(flag);
			if (!flag)
			{
				SetHint(knowledge switch
				{
					CodexKnowledge.Discovered => CodexText.HintDiscovered, 
					CodexKnowledge.Studied => CodexText.NoRecordedData, 
					_ => CodexText.HintUnknown, 
				});
				return;
			}
			SetHint(string.Empty);
			FillBiomes(data);
			if (PluginConfig.ShowCombatStats.Value)
			{
				FillHealth(data);
				FillDamage(data.Resistances);
				FillWeakSpots(data.WeakSpots);
				FillWeapons(data.Resistances);
			}
			if (PluginConfig.ShowDrops.Value)
			{
				FillDrops(data.Drops);
			}
		}

		private void BuildScroll(RectTransform panel)
		{
			//IL_004b: 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)
			//IL_005f: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			_scroll = ((Component)panel).gameObject.AddComponent<ScrollRect>();
			_scroll.horizontal = false;
			_scroll.vertical = true;
			_scroll.movementType = (MovementType)2;
			_scroll.scrollSensitivity = 120f;
			RectTransform val = CodexBookView.MakeRect("Viewport", (Transform)(object)panel, Vector2.zero, Vector2.one, new Vector2(6f, 6f), new Vector2(-18f, -6f));
			((Component)val).gameObject.AddComponent<RectMask2D>();
			_content = CodexBookView.MakeRect("Content", (Transform)(object)val, new Vector2(0f, 1f), Vector2.one, Vector2.zero, Vector2.zero);
			_content.pivot = new Vector2(0.5f, 1f);
			VerticalLayoutGroup obj = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(18, 12, 4, 20);
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 16f;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			((Component)_content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_scroll.viewport = val;
			_scroll.content = _content;
			_scroll.verticalScrollbar = _view.BuildScrollbar(panel);
			_scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1;
		}

		private void BuildHeader()
		{
			//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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_013f: 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_015f: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Header", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)_content, false);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			obj.minHeight = 128f;
			obj.preferredHeight = 128f;
			RectTransform parent = (RectTransform)val.transform;
			RectTransform val2 = CodexBookView.MakeRect("PortraitFrame", (Transform)(object)parent, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), Vector2.zero, Vector2.zero);
			val2.sizeDelta = new Vector2(112f, 112f);
			val2.anchoredPosition = new Vector2(-92f, -62f);
			((Graphic)CodexBookView.AddImage(((Component)val2).gameObject, CodexBookView.FrameColor)).raycastTarget = false;
			RectTransform val3 = CodexBookView.MakeRect("Portrait", (Transform)(object)val2, Vector2.zero, Vector2.one, new Vector2(6f, 6f), new Vector2(-6f, -6f));
			_icon = CodexBookView.AddImage(((Component)val3).gameObject, Color.white);
			_icon.preserveAspect = true;
			((Graphic)_icon).raycastTarget = false;
			_iconPlaceholder = CodexBookView.MakeText("Placeholder", (Transform)(object)val2, "?", _bold, 50, CodexBookView.Muted, (TextAnchor)4);
			CodexBookView.Stretch(((Graphic)_iconPlaceholder).rectTransform, Vector2.zero, Vector2.one);
			_name = CodexBookView.MakeText("Name", (Transform)(object)parent, string.Empty, _bold, 28, _orange, (TextAnchor)3);
			_name.resizeTextForBestFit = true;
			_name.resizeTextMinSize = 16;
			_name.resizeTextMaxSize = 28;
			CodexBookView.Stretch(((Graphic)_name).rectTransform, new Vector2(0.5f, 1f), new Vector2(1f, 1f), new Vector2(-30f, -52f), new Vector2(-8f, -16f));
			_state = CodexBookView.MakeText("State", (Transform)(object)parent, string.Empty, _bold, 14, _beige, (TextAnchor)3);
			CodexBookView.Stretch(((Graphic)_state).rectTransform, new Vector2(0.5f, 1f), new Vector2(1f, 1f), new Vector2(-30f, -78f), new Vector2(-8f, -56f));
			_defeated = CodexBookView.MakeText("Defeated", (Transform)(object)parent, string.Empty, _regular, 14, CodexBookView.Muted, (TextAnchor)3);
			CodexBookView.Stretch(((Graphic)_defeated).rectTransform, new Vector2(0.5f, 1f), new Vector2(1f, 1f), new Vector2(-30f, -102f), new Vector2(-8f, -80f));
		}

		private Section MakeSection(string name, string title)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Section_" + name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)_content, false);
			VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 3f;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			CodexBookView.MakeText("Title", val.transform, title, _bold, 14, _orange, (TextAnchor)3);
			GameObject val2 = new GameObject("Rule", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			((Graphic)CodexBookView.AddImage(val2, new Color(_orange.r, _orange.g, _orange.b, 0.28f))).raycastTarget = false;
			LayoutElement obj2 = val2.AddComponent<LayoutElement>();
			obj2.minHeight = 1f;
			obj2.preferredHeight = 1f;
			GameObject val3 = new GameObject("Space", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val.transform, false);
			LayoutElement obj3 = val3.AddComponent<LayoutElement>();
			obj3.minHeight = 3f;
			obj3.preferredHeight = 3f;
			Text val4 = CodexBookView.MakeText("Message", val.transform, string.Empty, _regular, 16, CodexBookView.Cream, (TextAnchor)0);
			val4.lineSpacing = 1.15f;
			((Component)val4).gameObject.SetActive(false);
			return new Section
			{
				Go = val,
				Message = val4
			};
		}

		private void BuildHealth()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Value", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(_health.Go.transform, false);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			obj.minHeight = 36f;
			obj.preferredHeight = 36f;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)6;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			_healthValue = CodexBookView.MakeText("Number", val.transform, string.Empty, _bold, 30, CodexBookView.Cream, (TextAnchor)6);
			_healthValue.horizontalOverflow = (HorizontalWrapMode)1;
			_healthCaption = CodexBookView.MakeText("Caption", val.transform, CodexText.BaseHpCaption, _regular, 15, _beige, (TextAnchor)6);
			_healthCaption.horizontalOverflow = (HorizontalWrapMode)1;
			_healthNote = CodexBookView.MakeText("Note", _health.Go.transform, CodexText.BaseHealthNote, _regular, 13, CodexBookView.Muted, (TextAnchor)0);
		}

		private void BuildDropsHeader()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0088: 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_00a7: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			_dropsHeader = new GameObject("Columns", new Type[1] { typeof(RectTransform) });
			_dropsHeader.transform.SetParent(_drops.Go.transform, false);
			LayoutElement obj = _dropsHeader.AddComponent<LayoutElement>();
			obj.minHeight = 16f;
			obj.preferredHeight = 16f;
			RectTransform parent = (RectTransform)_dropsHeader.transform;
			CodexBookView.Stretch(((Graphic)CodexBookView.MakeText("Amount", (Transform)(object)parent, CodexText.DropsAmountHeader, _regular, 13, CodexBookView.Muted, (TextAnchor)5)).rectTransform, new Vector2(1f, 0f), Vector2.one, new Vector2(-114f, 0f), new Vector2(-62f, 0f));
			CodexBookView.Stretch(((Graphic)CodexBookView.MakeText("Chance", (Transform)(object)parent, CodexText.DropsChanceHeader, _regular, 13, CodexBookView.Muted, (TextAnchor)5)).rectTransform, new Vector2(1f, 0f), Vector2.one, new Vector2(-58f, 0f), new Vector2(-6f, 0f));
		}

		private void SetHeader(Sprite icon, string name, string state, string defeated, bool showFrame, bool known)
		{
			//IL_0055: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			_icon.sprite = icon;
			((Behaviour)_icon).enabled = (Object)(object)icon != (Object)null;
			((Behaviour)_iconPlaceholder).enabled = showFrame && (Object)(object)icon == (Object)null;
			_name.text = name;
			((Graphic)_name).color = (known ? _orange : CodexBookView.Muted);
			_name.fontStyle = (FontStyle)((!known) ? 2 : 0);
			_state.text = state.ToUpper(CultureInfo.CurrentCulture);
			((Graphic)_state).color = (known ? _beige : CodexBookView.Muted);
			_defeated.text = defeated;
		}

		private void SetHint(string text)
		{
			_hint.text = text;
			((Component)_hint).gameObject.SetActive(!string.IsNullOrEmpty(text));
		}

		private void ShowSections(bool show)
		{
			_biomes.Go.SetActive(show);
			bool active = show && PluginConfig.ShowCombatStats.Value;
			_health.Go.SetActive(active);
			_damage.Go.SetActive(active);
			_weakSpots.Go.SetActive(active);
			_weapons.Go.SetActive(active);
			_drops.Go.SetActive(show && PluginConfig.ShowDrops.Value);
		}

		private void FillWeapons(CreatureResistances resistances)
		{
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			foreach (WeaponRow weaponRow2 in _weaponRows)
			{
				weaponRow2.Go.SetActive(false);
			}
			((Component)_weaponsNote).gameObject.SetActive(false);
			List<WeaponRecommendation> list;
			try
			{
				list = CodexWeapons.Recommend(Player.m_localPlayer, resistances);
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("Creature Codex: weapon suggestions unavailable. " + ex.Message));
				_weapons.Message.text = CodexText.WeaponsUnavailable;
				((Component)_weapons.Message).gameObject.SetActive(true);
				return;
			}
			_weapons.Message.text = ((list.Count == 0) ? CodexText.WeaponsEmpty : string.Empty);
			if (list.Count > 0 && !list.Exists((WeaponRecommendation entry) => entry.ExploitsWeakness))
			{
				_weapons.Message.text = CodexText.WeaponsFallback;
			}
			((Component)_weapons.Message).gameObject.SetActive(!string.IsNullOrEmpty(_weapons.Message.text));
			for (int num = 0; num < list.Count; num++)
			{
				if (num >= _weaponRows.Count)
				{
					_weaponRows.Add(BuildWeaponRow());
				}
				WeaponRow weaponRow = _weaponRows[num];
				WeaponRecommendation weaponRecommendation = list[num];
				ItemData weapon = weaponRecommendation.Weapon;
				Sprite[] icons = weapon.m_shared.m_icons;
				weaponRow.Icon.sprite = ((icons != null && icons.Length != 0) ? icons[0] : null);
				((Behaviour)weaponRow.Icon).enabled = (Object)(object)weaponRow.Icon.sprite != (Object)null;
				weaponRow.Name.text = CodexBookView.LocalizeOr(weapon.m_shared.m_name, weapon.m_shared.m_name);
				if (weaponRecommendation.Ammo != null)
				{
					Text name = weaponRow.Name;
					name.text = name.text + " + " + CodexBookView.LocalizeOr(weaponRecommendation.Ammo.m_shared.m_name, weaponRecommendation.Ammo.m_shared.m_name);
				}
				weaponRow.Reason.text = (weaponRecommendation.ExploitsWeakness ? string.Format(CodexText.WeaponWeaknessFormat, TypeLabel(weaponRecommendation.WeaknessType)) : CodexText.WeaponAlternative) + "\n" + string.Format(CodexText.WeaponScoreFormat, weaponRecommendation.BaseDamage.ToString("0.#", CultureInfo.CurrentCulture), weaponRecommendation.EffectiveDamage.ToString("0.#", CultureInfo.CurrentCulture)) + FormatWeaponCosts(weaponRecommendation);
				weaponRow.Go.SetActive(true);
			}
			((Component)_weaponsNote).transform.SetAsLastSibling();
			((Component)_weaponsNote).gameObject.SetActive(list.Count > 0);
		}

		private string FormatWeaponCosts(WeaponRecommendation recommendation)
		{
			_parts.Clear();
			if (recommendation.StaminaCost > 0.05f)
			{
				_parts.Add(string.Format(CodexText.WeaponStaminaFormat, recommendation.StaminaCost.ToString("0.#", CultureInfo.CurrentCulture)));
			}
			if (recommendation.EitrCost > 0.05f)
			{
				_parts.Add(string.Format(CodexText.WeaponEitrFormat, recommendation.EitrCost.ToString("0.#", CultureInfo.CurrentCulture)));
			}
			if (recommendation.HealthCost > 0.05f)
			{
				_parts.Add(string.Format(CodexText.WeaponHealthFormat, recommendation.HealthCost.ToString("0.#", CultureInfo.CurrentCulture)));
			}
			if (recommendation.DrawSeconds > 0.01f)
			{
				_parts.Add(string.Format(CodexText.WeaponDrawFormat, recommendation.DrawSeconds.ToString("0.#", CultureInfo.CurrentCulture)));
			}
			if (recommendation.ReloadSeconds > 0.01f)
			{
				_parts.Add(string.Format(CodexText.WeaponReloadFormat, recommendation.ReloadSeconds.ToString("0.#", CultureInfo.CurrentCulture)));
			}
			if (_parts.Count != 0)
			{
				return "\n" + string.Join("  •  ", _parts.ToArray());
			}
			return string.Empty;
		}

		private WeaponRow BuildWeaponRow()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0071: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WeaponSuggestion", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(_weapons.Go.transform, false);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			float minHeight = (obj.preferredHeight = 126f);
			obj.minHeight = minHeight;
			RectTransform parent = (RectTransform)val.transform;
			Image val2 = CodexBookView.AddImage(((Component)CodexBookView.MakeRect("Icon", (Transform)(object)parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, -34f), new Vector2(30f, -4f))).gameObject, Color.white);
			val2.preserveAspect = true;
			((Graphic)val2).raycastTarget = false;
			Text val3 = CodexBookView.MakeText("Name", (Transform)(object)parent, string.Empty, _bold, 15, CodexBookView.Cream, (TextAnchor)0);
			val3.resizeTextForBestFit = true;
			val3.resizeTextMinSize = 12;
			val3.resizeTextMaxSize = 15;
			CodexBookView.Stretch(((Graphic)val3).rectTransform, new Vector2(0f, 1f), Vector2.one, new Vector2(38f, -42f), Vector2.zero);
			Text val4 = CodexBookView.MakeText("Reason", (Transform)(object)parent, string.Empty, _regular, 13, Minor, (TextAnchor)0);
			CodexBookView.Stretch(((Graphic)val4).rectTransform, Vector2.zero, new Vector2(1f, 0f), new Vector2(38f, 2f), new Vector2(0f, 66f));
			return new WeaponRow
			{
				Go = val,
				Icon = val2,
				Name = val3,
				Reason = val4
			};
		}

		private void FillBiomes(CreatureData data)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			_parts.Clear();
			Biome[] categories = CodexBookView.Categories;
			foreach (Biome val in categories)
			{
				if ((int)val != 0 && (data.Biomes & val) != 0)
				{
					_parts.Add(CodexBookView.BiomeLabel(val));
				}
			}
			if (_parts.Count == 0)
			{
				SetMessage(_biomes, Faded(CodexText.BiomesNone));
				return;
			}
			_sb.Length = 0;
			for (int j = 0; j < _parts.Count; j++)
			{
				if (j > 0)
				{
					_sb.Append((j % 3 == 0) ? "\n" : "   •   ");
				}
				_sb.Append(_parts[j]);
			}
			SetMessage(_biomes, _sb.ToString());
		}

		private void FillHealth(CreatureData data)
		{
			_healthValue.text = data.BaseHealth.ToString("0", CultureInfo.CurrentCulture);
		}

		private void FillDamage(CreatureResistances resistances)
		{
			Begin(_damage);
			AddModifierLines(_damage, resistances, 0f);
			if (_damage.Used == 0)
			{
				SetMessage(_damage, Faded(CodexText.DamageAllNormal));
			}
			End(_damage);
		}

		private void FillWeakSpots(IReadOnlyList<CreatureWeakSpot> weakSpots)
		{
			if (weakSpots == null || weakSpots.Count == 0)
			{
				_weakSpots.Go.SetActive(false);
				return;
			}
			Begin(_weakSpots);
			for (int i = 0; i < weakSpots.Count; i++)
			{
				if (i > 0)
				{
					AddLine(_weakSpots, LineStyle.Gap, string.Empty, string.Empty, 0f);
				}
				CreatureWeakSpot creatureWeakSpot = weakSpots[i];
				AddLine(_weakSpots, LineStyle.Title, CodexDetailFormat.WeakSpotName(creatureWeakSpot.Name), string.Empty, 0f);
				int used = _weakSpots.Used;
				AddModifierLines(_weakSpots, creatureWeakSpot.Resistances, 14f);
				if (_weakSpots.Used == used)
				{
					AddLine(_weakSpots, LineStyle.Entry, Faded(CodexText.DamageAllNormal), string.Empty, 14f);
				}
			}
			End(_weakSpots);
		}

		private void AddModifierLines(Section section, CreatureResistances resistances, float indent)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (resistances == null)
			{
				return;
			}
			int num = -1;
			DamageModifier[] modifierOrder = ModifierOrder;
			foreach (DamageModifier val in modifierOrder)
			{
				DamageType[] shownTypes = CreatureResistances.ShownTypes;
				foreach (DamageType type in shownTypes)
				{
					if (resistances.Get(type) == val)
					{
						int num2 = ModifierGroup(val);
						if (num >= 0 && num2 != num)
						{
							AddLine(section, LineStyle.Gap, string.Empty, string.Empty, 0f);
						}
						num = num2;
						string text = ModifierLabel(val);
						if (PluginConfig.ShowDamageMultipliers.Value && (int)val != 4)
						{
							text = string.Format(CodexText.DamageMultiplierFormat, text, resistances.Multiplier(type).ToString("0.##", CultureInfo.CurrentCulture));
						}
						AddLine(section, LineStyle.Entry, TypeLabel(type), text, indent);
					}
				}
			}
		}

		private void FillDrops(IReadOnlyList<CreatureDrop> drops)
		{
			int num = 0;
			bool flag = false;
			bool flag2 = false;
			if (drops != null)
			{
				foreach (CreatureDrop drop in drops)
				{
					string text = ItemName(drop.ItemToken);
					if (text != null)
					{
						DropRow dropRow = GetDropRow(num++);
						dropRow.Icon.sprite = drop.Icon;
						((Behaviour)dropRow.Icon).enabled = (Object)(object)drop.Icon != (Object)null;
						dropRow.Name.text = text;
						string text2 = ((drop.EffectiveMax > drop.AmountMin) ? (drop.AmountMin.ToString(CultureInfo.CurrentCulture) + "–" + drop.EffectiveMax.ToString(CultureInfo.CurrentCulture)) : drop.AmountMin.ToString(CultureInfo.CurrentCulture));
						dropRow.Amount.text = (drop.OnePerPlayer ? (text2 + "*") : text2);
						dropRow.Chance.text = FormatChance(drop.Chance);
						dropRow.Go.SetActive(true);
						dropRow.Go.transform.SetAsLastSibling();
						flag |= drop.LevelMultiplier;
						flag2 |= drop.OnePerPlayer;
					}
				}
			}
			for (int i = num; i < _dropRows.Count; i++)
			{
				_dropRows[i].Go.SetActive(false);
			}
			_dropsHeader.SetActive(num