Decompiled source of Idavoll v0.1.3

plugins/Idavoll.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GBV.Highseat;
using GBV.Shared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Guys Being Vikings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+8be74b0670e553dffe2c4de3a0b50ed2e436c5c2")]
[assembly: AssemblyProduct("Idavoll")]
[assembly: AssemblyTitle("Idavoll")]
[assembly: AssemblyVersion("0.1.3.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 GBV.Shared
{
	internal static class Theme
	{
		public static readonly Color StoneDeep = Hex("0A0B0D");

		public static readonly Color Stone = Hex("14161A");

		public static readonly Color StoneHi = Hex("1F2329");

		public static readonly Color StoneLit = Hex("2D323A");

		public static readonly Color Carve = Hex("060708");

		public static readonly Color Brass = Hex("C9A45C");

		public static readonly Color BrassHi = Hex("F2D9A0");

		public static readonly Color BrassDim = Hex("6B5630");

		public static readonly Color BrassInk = Hex("17110478");

		public static readonly Color TextHi = Hex("F7F4EE");

		public static readonly Color Text = Hex("D8D4CC");

		public static readonly Color Muted = Hex("9FA0A2");

		public static readonly Color Faint = Hex("74767A");

		public static readonly Color Good = Hex("A6C978");

		public static readonly Color Bad = Hex("DD6A57");

		public static readonly Color Warn = Hex("E8B25C");

		public const float Pad = 30f;

		public const float Inlay = 9f;

		public const float TabH = 46f;

		public const float RowH = 30f;

		public const float FooterH = 44f;

		public static GUIStyle Blank;

		public static GUIStyle Wordmark;

		public static GUIStyle TabOn;

		public static GUIStyle TabOff;

		public static GUIStyle Heading;

		public static GUIStyle Body;

		public static GUIStyle BodyHi;

		public static GUIStyle Dim;

		public static GUIStyle Small;

		public static GUIStyle SmallRight;

		public static GUIStyle Mono;

		public static GUIStyle MonoDim;

		public static GUIStyle MonoEcho;

		public static GUIStyle Search;

		public static GUIStyle Field;

		public static GUIStyle FieldText;

		public static GUIStyle FieldArea;

		public static GUIStyle Console_;

		public static GUIStyle Link;

		public static GUIStyle LinkOn;

		public static GUIStyle Chip;

		public static GUIStyle ChipOn;

		public static GUIStyle Row;

		public static GUIStyle Action;

		public static GUIStyle ActionKey;

		public static GUIStyle Danger;

		public static GUIStyle Btn;

		public static GUIStyle BtnOn;

		public static GUIStyle BtnPrimary;

		public static GUIStyle BtnDanger;

		public static GUIStyle BtnSmall;

		public static GUIStyle DropItem;

		public static GUIStyle TileName;

		public static GUIStyle TileNameHot;

		public static GUIStyle Glyph;

		public static GUIStyle ScrollbarV;

		public static GUIStyle ScrollbarThumb;

		public static GUIStyle Scroll;

		public static Texture2D Grain;

		public static Texture2D Px;

		private static bool _built;

		public static void EnsureBuilt()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0039: 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_005d: 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_0081: 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_00a5: 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_00d4: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: 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_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: 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_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Expected O, but got Unknown
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Expected O, but got Unknown
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Expected O, but got Unknown
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Expected O, but got Unknown
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Expected O, but got Unknown
			//IL_0602: Expected O, but got Unknown
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Expected O, but got Unknown
			//IL_063a: Expected O, but got Unknown
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Expected O, but got Unknown
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Expected O, but got Unknown
			//IL_0680: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Expected O, but got Unknown
			//IL_06b3: Expected O, but got Unknown
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_0751: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Expected O, but got Unknown
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Expected O, but got Unknown
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_0829: Unknown result type (might be due to invalid IL or missing references)
			//IL_0833: Expected O, but got Unknown
			//IL_0833: Unknown result type (might be due to invalid IL or missing references)
			//IL_0838: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Expected O, but got Unknown
			//IL_0847: Expected O, but got Unknown
			//IL_0851: Unknown result type (might be due to invalid IL or missing references)
			//IL_0856: Unknown result type (might be due to invalid IL or missing references)
			//IL_085c: Unknown result type (might be due to invalid IL or missing references)
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0871: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a4: Expected O, but got Unknown
			//IL_08a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08be: Expected O, but got Unknown
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Expected O, but got Unknown
			//IL_08d2: Expected O, but got Unknown
			//IL_0959: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			if (!_built)
			{
				_built = true;
				Px = Solid(Color.white);
				Grain = StoneGrain(128);
				Blank = new GUIStyle();
				Wordmark = Label(26, (FontStyle)1, TextHi);
				Heading = Label(11, (FontStyle)1, Brass);
				Body = Label(13, (FontStyle)0, Text);
				BodyHi = Label(13, (FontStyle)1, TextHi);
				Dim = Label(13, (FontStyle)0, Muted);
				Small = Label(11, (FontStyle)0, Muted);
				SmallRight = Label(11, (FontStyle)0, Muted);
				SmallRight.alignment = (TextAnchor)5;
				Mono = Label(12, (FontStyle)0, TextHi);
				MonoDim = Label(12, (FontStyle)0, Muted);
				MonoEcho = Label(12, (FontStyle)1, Brass);
				TabOff = Ghost(46f, 13, (FontStyle)0, Muted, TextHi);
				TabOn = Ghost(46f, 13, (FontStyle)1, BrassHi, BrassHi);
				TabOff.alignment = (TextAnchor)4;
				TabOn.alignment = (TextAnchor)4;
				Link = Ghost(30f, 13, (FontStyle)0, Text, BrassHi);
				LinkOn = Ghost(30f, 13, (FontStyle)1, BrassHi, BrassHi);
				Link.alignment = (TextAnchor)4;
				LinkOn.alignment = (TextAnchor)4;
				Chip = Ghost(26f, 12, (FontStyle)0, Muted, BrassHi);
				ChipOn = Ghost(26f, 12, (FontStyle)1, Brass, BrassHi);
				Chip.alignment = (TextAnchor)4;
				ChipOn.alignment = (TextAnchor)4;
				Row = Ghost(30f, 13, (FontStyle)0, Text, BrassHi);
				Row.alignment = (TextAnchor)3;
				Row.padding = new RectOffset(12, 12, 0, 0);
				Action = Ghost(34f, 13, (FontStyle)1, Brass, BrassHi);
				Action.alignment = (TextAnchor)4;
				ActionKey = Ghost(34f, 13, (FontStyle)1, BrassInk, BrassInk);
				ActionKey.alignment = (TextAnchor)4;
				Danger = Ghost(34f, 13, (FontStyle)1, Bad, Hex("FF8B78"));
				Danger.alignment = (TextAnchor)4;
				Btn = Plate(34, 4, Hex("1B1F25"), Hex("272D35"), Hex("3B434E"), Hex("262D36"), Hex("39424E"), Hex("6E5F3A"), Hex("14171C"), Hex("1B2027"), Brass, Text, 13);
				BtnOn = Plate(34, 4, Hex("312B18"), Hex("43391F"), Brass, Hex("3B3320"), Hex("4E4227"), BrassHi, Hex("2A2515"), Hex("352E1A"), BrassHi, BrassHi, 13);
				BtnPrimary = Plate(34, 4, Hex("A8873A"), Hex("D0A63A"), Hex("F2D9A0"), Hex("C09A38"), Hex("EBC97A"), Hex("F7E6BE"), Hex("8A6E2C"), Hex("A8873A"), Hex("F2D9A0"), Hex("151003"), 13);
				BtnPrimary.fontStyle = (FontStyle)1;
				BtnDanger = Plate(34, 4, Hex("5A2621"), Hex("7A332C"), Hex("A8453A"), Hex("7A332C"), Hex("9C4239"), Hex("DD6A57"), Hex("431B17"), Hex("5A2621"), Hex("DD6A57"), Hex("F3C8C0"), 13);
				BtnDanger.fontStyle = (FontStyle)1;
				BtnSmall = Plate(26, 3, Hex("1B1F25"), Hex("272D35"), Hex("3B434E"), Hex("262D36"), Hex("39424E"), Hex("6E5F3A"), Hex("14171C"), Hex("1B2027"), Brass, Text, 12);
				DropItem = Ghost(28f, 13, (FontStyle)0, Text, BrassHi);
				DropItem.alignment = (TextAnchor)3;
				DropItem.padding = new RectOffset(12, 12, 0, 0);
				GUIStyle val = new GUIStyle(GUI.skin.textField);
				val.normal.background = Solid(Carve);
				val.normal.textColor = TextHi;
				val.hover.background = Solid(Carve);
				val.hover.textColor = TextHi;
				val.focused.background = Solid(Carve);
				val.focused.textColor = TextHi;
				val.border = new RectOffset(0, 0, 0, 0);
				val.padding = new RectOffset(10, 10, 0, 0);
				val.margin = new RectOffset(0, 0, 0, 0);
				val.fontSize = 15;
				val.fixedHeight = 34f;
				val.alignment = (TextAnchor)3;
				Search = val;
				Field = new GUIStyle(Search)
				{
					fontSize = 13,
					fixedHeight = 26f,
					alignment = (TextAnchor)4,
					padding = new RectOffset(2, 2, 0, 0)
				};
				FieldText = new GUIStyle(Search)
				{
					fontSize = 13,
					fixedHeight = 26f,
					alignment = (TextAnchor)3,
					padding = new RectOffset(8, 8, 0, 0)
				};
				FieldArea = new GUIStyle(Search)
				{
					fontSize = 13,
					fixedHeight = 0f,
					alignment = (TextAnchor)0,
					padding = new RectOffset(10, 10, 8, 8),
					wordWrap = true
				};
				Console_ = new GUIStyle(Search)
				{
					fontSize = 13,
					fixedHeight = 0f,
					alignment = (TextAnchor)3,
					padding = new RectOffset(4, 4, 0, 0)
				};
				Console_.normal.textColor = TextHi;
				Console_.focused.textColor = TextHi;
				Console_.hover.textColor = TextHi;
				Texture2D background = Solid(new Color(0f, 0f, 0f, 0f));
				Console_.normal.background = background;
				Console_.focused.background = background;
				Console_.hover.background = background;
				Console_.active.background = background;
				TileName = Label(11, (FontStyle)0, Text);
				TileName.alignment = (TextAnchor)1;
				TileName.wordWrap = true;
				TileName.clipping = (TextClipping)1;
				TileNameHot = Label(11, (FontStyle)1, TextHi);
				TileNameHot.alignment = (TextAnchor)1;
				TileNameHot.wordWrap = true;
				TileNameHot.clipping = (TextClipping)1;
				Glyph = Label(20, (FontStyle)0, Hex("4A3F33"));
				Glyph.alignment = (TextAnchor)4;
				Scroll = new GUIStyle();
				GUIStyle val2 = new GUIStyle(GUI.skin.verticalScrollbar);
				val2.normal.background = Solid(Hex("0A0807"));
				val2.border = new RectOffset(0, 0, 0, 0);
				val2.fixedWidth = 3f;
				val2.margin = new RectOffset(10, 0, 0, 0);
				val2.padding = new RectOffset(0, 0, 0, 0);
				ScrollbarV = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.verticalScrollbarThumb);
				val3.normal.background = Solid(BrassDim);
				val3.hover.background = Solid(Brass);
				val3.active.background = Solid(BrassHi);
				val3.border = new RectOffset(0, 0, 0, 0);
				val3.fixedWidth = 3f;
				val3.margin = new RectOffset(0, 0, 0, 0);
				val3.padding = new RectOffset(0, 0, 0, 0);
				ScrollbarThumb = val3;
				GUI.skin.verticalScrollbarUpButton = GUIStyle.none;
				GUI.skin.verticalScrollbarDownButton = GUIStyle.none;
				GUI.skin.horizontalScrollbarLeftButton = GUIStyle.none;
				GUI.skin.horizontalScrollbarRightButton = GUIStyle.none;
				GUI.skin.verticalScrollbar = ScrollbarV;
				GUI.skin.verticalScrollbarThumb = ScrollbarThumb;
				GUI.skin.settings.selectionColor = new Color(Brass.r, Brass.g, Brass.b, 0.3f);
				GUI.skin.settings.cursorColor = BrassHi;
			}
		}

		public static void DrawSlab(Rect r)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0024: 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_0064: 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_0092: 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_00c7: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			Fill(r, Stone);
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, 0.95f);
			GUI.DrawTextureWithTexCoords(r, (Texture)(object)Grain, new Rect(0f, 0f, ((Rect)(ref r)).width / (float)((Texture)Grain).width, ((Rect)(ref r)).height / (float)((Texture)Grain).height));
			GUI.color = color;
			FillFade(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 34f), Carve, 0.6f, topDown: true);
			FillFade(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 34f, ((Rect)(ref r)).width, 34f), Carve, 0.6f, topDown: false);
			Outline(r, Hex("000000"), 1f);
			Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width - 2f, 1f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.9f));
			Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, 1f, ((Rect)(ref r)).height - 2f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.7f));
			Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).yMax - 2f, ((Rect)(ref r)).width - 2f, 1f), new Color(0f, 0f, 0f, 0.65f));
			Fill(new Rect(((Rect)(ref r)).xMax - 2f, ((Rect)(ref r)).y + 1f, 1f, ((Rect)(ref r)).height - 2f), new Color(0f, 0f, 0f, 0.5f));
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 9f, ((Rect)(ref r)).y + 9f, ((Rect)(ref r)).width - 18f, ((Rect)(ref r)).height - 18f);
			Outline(r2, new Color(Brass.r, Brass.g, Brass.b, 0.75f), 1f);
			Outline(new Rect(((Rect)(ref r2)).x + 1f, ((Rect)(ref r2)).y + 1f, ((Rect)(ref r2)).width - 2f, ((Rect)(ref r2)).height - 2f), new Color(0f, 0f, 0f, 0.55f), 1f);
			Rivet(((Rect)(ref r2)).x, ((Rect)(ref r2)).y);
			Rivet(((Rect)(ref r2)).xMax, ((Rect)(ref r2)).y);
			Rivet(((Rect)(ref r2)).x, ((Rect)(ref r2)).yMax);
			Rivet(((Rect)(ref r2)).xMax, ((Rect)(ref r2)).yMax);
		}

		private static void Rivet(float cx, float cy)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(cx - 3f, cy - 3f, 6f, 6f);
			Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width + 2f, ((Rect)(ref r)).height + 2f), new Color(0f, 0f, 0f, 0.6f));
			Fill(r, BrassDim);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 2f), Brass);
			Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, 2f, 2f), BrassHi);
		}

		public static void Fill(Rect r, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)Px);
			GUI.color = color;
		}

		private static void FillFade(Rect r, Color c, float alpha, bool topDown)
		{
			//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_0056: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			int num = 8;
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / (float)num;
				float num3 = alpha * (topDown ? (1f - num2) : num2);
				float num4 = ((Rect)(ref r)).height / (float)num;
				Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + num4 * (float)i, ((Rect)(ref r)).width, num4 + 1f), new Color(c.r, c.g, c.b, num3));
			}
		}

		public static void Outline(Rect r, Color c, float w)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_005a: 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_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)
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, w), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - w, ((Rect)(ref r)).width, w), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c);
			Fill(new Rect(((Rect)(ref r)).xMax - w, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c);
		}

		public static void Hairline(Rect r, float alpha = 0.28f)
		{
			//IL_001a: 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)
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 1f), new Color(Brass.r, Brass.g, Brass.b, alpha));
		}

		public static void Groove(Rect r)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 1f), Carve);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width, 1f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.8f));
		}

		public static string Spaced(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return s;
			}
			StringBuilder stringBuilder = new StringBuilder(s.Length * 2);
			string text = s.ToUpperInvariant();
			foreach (char value in text)
			{
				stringBuilder.Append(value).Append(' ');
			}
			return stringBuilder.ToString().TrimEnd();
		}

		private static GUIStyle Label(int size, FontStyle style, Color colour)
		{
			//IL_000a: 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)
			//IL_0017: 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_0023: 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_0038: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = size,
				fontStyle = style
			};
			val.normal.textColor = colour;
			val.margin = new RectOffset(0, 0, 0, 0);
			val.padding = new RectOffset(0, 0, 0, 0);
			val.alignment = (TextAnchor)3;
			val.wordWrap = false;
			return val;
		}

		private static GUIStyle Ghost(float h, int size, FontStyle style, Color normal, Color hover)
		{
			//IL_0014: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00aa: 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_00bc: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//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_00e1: Expected O, but got Unknown
			//IL_00e1: 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
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			Texture2D background = Solid(new Color(0f, 0f, 0f, 0f));
			GUIStyle val = new GUIStyle(GUI.skin.button);
			val.normal.background = background;
			val.normal.textColor = normal;
			val.hover.background = background;
			val.hover.textColor = hover;
			val.active.background = background;
			val.active.textColor = hover;
			val.onNormal.background = background;
			val.onNormal.textColor = hover;
			val.onHover.background = background;
			val.onHover.textColor = hover;
			val.onActive.background = background;
			val.onActive.textColor = hover;
			val.border = new RectOffset(0, 0, 0, 0);
			val.padding = new RectOffset(8, 8, 0, 0);
			val.margin = new RectOffset(0, 0, 0, 0);
			val.fixedHeight = h;
			val.fontSize = size;
			val.fontStyle = style;
			val.alignment = (TextAnchor)3;
			val.wordWrap = false;
			val.clipping = (TextClipping)1;
			return val;
		}

		private static GUIStyle Plate(int h, int radius, Color nBot, Color nTop, Color nEdge, Color hBot, Color hTop, Color hEdge, Color aBot, Color aTop, Color aEdge, Color text, int fontSize)
		{
			//IL_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_002b: 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_003a: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0057: 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_0061: 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_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00ab: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_011e: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.button);
			val.normal.background = PlateTex(h, radius, nBot, nTop, nEdge);
			val.normal.textColor = text;
			val.hover.background = PlateTex(h, radius, hBot, hTop, hEdge);
			val.hover.textColor = text;
			val.active.background = PlateTex(h, radius, aBot, aTop, aEdge);
			val.active.textColor = text;
			val.onNormal.background = PlateTex(h, radius, aBot, aTop, aEdge);
			val.onNormal.textColor = text;
			val.onHover.background = PlateTex(h, radius, aBot, aTop, aEdge);
			val.onHover.textColor = text;
			val.onActive.background = PlateTex(h, radius, aBot, aTop, aEdge);
			val.onActive.textColor = text;
			val.border = new RectOffset(radius + 3, radius + 3, 0, 0);
			val.padding = new RectOffset(10, 10, 0, 0);
			val.margin = new RectOffset(0, 0, 0, 0);
			val.fixedHeight = h;
			val.fontSize = fontSize;
			val.alignment = (TextAnchor)4;
			val.wordWrap = false;
			val.clipping = (TextClipping)1;
			return val;
		}

		private static Texture2D PlateTex(int h, int radius, Color bottom, Color top, Color edge)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_002a: 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_002d: 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_003a: 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: 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_00b5: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			int num = radius * 2 + 8;
			Texture2D val = new Texture2D(num, h, (TextureFormat)5, false);
			for (int i = 0; i < h; i++)
			{
				float num2 = ((h <= 1) ? 0f : ((float)i / (float)(h - 1)));
				Color val2 = Color.Lerp(bottom, top, num2);
				if (i >= h - 1)
				{
					val2 = Color.Lerp(val2, Color.white, 0.12f);
				}
				for (int j = 0; j < num; j++)
				{
					float num3 = Sdf(j, i, num, h, radius);
					float num4 = Mathf.Clamp01(0.5f - num3);
					if (num4 <= 0f)
					{
						val.SetPixel(j, i, new Color(0f, 0f, 0f, 0f));
						continue;
					}
					float num5 = Mathf.Clamp01(0.5f - (num3 + 1.15f));
					Color val3 = Color.Lerp(edge, val2, num5);
					val.SetPixel(j, i, new Color(val3.r, val3.g, val3.b, num4));
				}
			}
			return Finish(val);
		}

		private static float Sdf(float x, float y, int w, int h, int radius)
		{
			float num = Mathf.Min((float)radius, (float)Mathf.Min(w, h) * 0.5f);
			float num2 = x + 0.5f;
			float num3 = y + 0.5f;
			float num4 = Mathf.Clamp(num2, num, (float)w - num);
			float num5 = Mathf.Clamp(num3, num, (float)h - num);
			float num6 = num2 - num4;
			float num7 = num3 - num5;
			return Mathf.Sqrt(num6 * num6 + num7 * num7) - num;
		}

		private static Color Hex(string hex)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			int num = Convert.ToInt32(hex.Substring(0, 2), 16);
			int num2 = Convert.ToInt32(hex.Substring(2, 2), 16);
			int num3 = Convert.ToInt32(hex.Substring(4, 2), 16);
			float num4 = ((hex.Length >= 8) ? ((float)Convert.ToInt32(hex.Substring(6, 2), 16) / 255f) : 1f);
			return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, num4);
		}

		private static Texture2D Finish(Texture2D t)
		{
			((Object)t).hideFlags = (HideFlags)61;
			((Texture)t).filterMode = (FilterMode)1;
			((Texture)t).wrapMode = (TextureWrapMode)0;
			t.Apply();
			return t;
		}

		private static Texture2D Solid(Color c)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false);
			val.SetPixel(0, 0, c);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return Finish(val);
		}

		private static Texture2D StoneGrain(int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_00c4: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)5, false);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = (0f + Tileable(j, i, size, 8f) * 0.5f + Tileable(j, i, size, 19f) * 0.32f + Tileable(j, i, size, 43f) * 0.18f - 0.5f) * 2f;
					float num2 = Mathf.Abs(num) * 0.55f;
					Color val2 = ((num >= 0f) ? new Color(StoneHi.r, StoneHi.g, StoneHi.b, num2) : new Color(Carve.r, Carve.g, Carve.b, num2 * 1.5f));
					val.SetPixel(j, i, val2);
				}
			}
			return Finish(val);
		}

		private static float Tileable(int x, int y, int size, float freq)
		{
			float num = (float)x / (float)size;
			float num2 = (float)y / (float)size;
			float num3 = Mathf.PerlinNoise(num * freq, num2 * freq);
			float num4 = Mathf.PerlinNoise((num - 1f) * freq, num2 * freq);
			float num5 = Mathf.PerlinNoise(num * freq, (num2 - 1f) * freq);
			float num6 = Mathf.PerlinNoise((num - 1f) * freq, (num2 - 1f) * freq);
			return Mathf.Lerp(Mathf.Lerp(num3, num4, num), Mathf.Lerp(num5, num6, num), num2);
		}
	}
	public class JsonException : Exception
	{
		public JsonException(string message)
			: base(message)
		{
		}
	}
	public sealed class JsonValue
	{
		public enum Kind
		{
			Null,
			Bool,
			Number,
			String,
			Array,
			Object
		}

		private bool _bool;

		private double _number;

		private bool _isFloat;

		private string _string;

		private List<JsonValue> _array;

		private Dictionary<string, JsonValue> _object;

		public static readonly JsonValue Null = new JsonValue
		{
			ValueKind = Kind.Null
		};

		private const int MaxDepth = 64;

		public Kind ValueKind { get; private set; }

		public bool IsNull => ValueKind == Kind.Null;

		public JsonValue this[string key]
		{
			get
			{
				if (ValueKind != Kind.Object)
				{
					return Null;
				}
				if (!_object.TryGetValue(key, out var value))
				{
					return Null;
				}
				return value;
			}
		}

		public JsonValue this[int index]
		{
			get
			{
				if (ValueKind != Kind.Array || index < 0 || index >= _array.Count)
				{
					return Null;
				}
				return _array[index];
			}
		}

		public int Count
		{
			get
			{
				if (ValueKind == Kind.Array)
				{
					return _array.Count;
				}
				if (ValueKind == Kind.Object)
				{
					return _object.Count;
				}
				return 0;
			}
		}

		public IEnumerable<KeyValuePair<string, JsonValue>> Members
		{
			get
			{
				if (ValueKind != Kind.Object)
				{
					return new KeyValuePair<string, JsonValue>[0];
				}
				return _object;
			}
		}

		public IEnumerable<JsonValue> Items
		{
			get
			{
				if (ValueKind != Kind.Array)
				{
					return new JsonValue[0];
				}
				return _array;
			}
		}

		private JsonValue()
		{
		}

		public static JsonValue Bool(bool v)
		{
			return new JsonValue
			{
				ValueKind = Kind.Bool,
				_bool = v
			};
		}

		public static JsonValue Number(double v)
		{
			return new JsonValue
			{
				ValueKind = Kind.Number,
				_number = v
			};
		}

		public static JsonValue Number(float v)
		{
			return new JsonValue
			{
				ValueKind = Kind.Number,
				_number = v,
				_isFloat = true
			};
		}

		public static JsonValue String(string v)
		{
			if (v != null)
			{
				return new JsonValue
				{
					ValueKind = Kind.String,
					_string = v
				};
			}
			return Null;
		}

		public static JsonValue NewArray()
		{
			return new JsonValue
			{
				ValueKind = Kind.Array,
				_array = new List<JsonValue>()
			};
		}

		public static JsonValue NewObject()
		{
			return new JsonValue
			{
				ValueKind = Kind.Object,
				_object = new Dictionary<string, JsonValue>(StringComparer.Ordinal)
			};
		}

		public JsonValue Add(JsonValue v)
		{
			if (ValueKind != Kind.Array)
			{
				throw new JsonException("Add called on a " + ValueKind);
			}
			_array.Add(v ?? Null);
			return this;
		}

		public JsonValue Set(string key, JsonValue v)
		{
			if (ValueKind != Kind.Object)
			{
				throw new JsonException("Set called on a " + ValueKind);
			}
			_object[key] = v ?? Null;
			return this;
		}

		public JsonValue Set(string key, string v)
		{
			return Set(key, String(v));
		}

		public JsonValue Set(string key, double v)
		{
			return Set(key, Number(v));
		}

		public JsonValue Set(string key, float v)
		{
			return Set(key, Number(v));
		}

		public JsonValue Set(string key, int v)
		{
			return Set(key, Number((double)v));
		}

		public JsonValue Set(string key, long v)
		{
			return Set(key, Number((double)v));
		}

		public JsonValue Set(string key, bool v)
		{
			return Set(key, Bool(v));
		}

		public string AsString(string fallback = null)
		{
			if (ValueKind != Kind.String)
			{
				return fallback;
			}
			return _string;
		}

		public double AsDouble(double fallback = 0.0)
		{
			if (ValueKind != Kind.Number)
			{
				return fallback;
			}
			return _number;
		}

		public float AsFloat(float fallback = 0f)
		{
			if (ValueKind != Kind.Number)
			{
				return fallback;
			}
			return (float)_number;
		}

		public int AsInt(int fallback = 0)
		{
			if (ValueKind != Kind.Number)
			{
				return fallback;
			}
			return (int)Math.Round(_number);
		}

		public long AsLong(long fallback = 0L)
		{
			if (ValueKind != Kind.Number)
			{
				return fallback;
			}
			return (long)Math.Round(_number);
		}

		public bool AsBool(bool fallback = false)
		{
			if (ValueKind != Kind.Bool)
			{
				return fallback;
			}
			return _bool;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			Write(stringBuilder, this, -1, 0);
			return stringBuilder.ToString();
		}

		public string ToPrettyString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			Write(stringBuilder, this, 2, 0);
			return stringBuilder.ToString();
		}

		private static void Write(StringBuilder sb, JsonValue v, int indent, int depth)
		{
			bool flag = indent >= 0;
			switch (v.ValueKind)
			{
			case Kind.Null:
				sb.Append("null");
				break;
			case Kind.Bool:
				sb.Append(v._bool ? "true" : "false");
				break;
			case Kind.Number:
				WriteNumber(sb, v._number, v._isFloat);
				break;
			case Kind.String:
				WriteString(sb, v._string);
				break;
			case Kind.Array:
			{
				if (v._array.Count == 0)
				{
					sb.Append("[]");
					break;
				}
				sb.Append('[');
				for (int i = 0; i < v._array.Count; i++)
				{
					if (i > 0)
					{
						sb.Append(',');
					}
					if (flag)
					{
						NewLine(sb, indent, depth + 1);
					}
					Write(sb, v._array[i], indent, depth + 1);
				}
				if (flag)
				{
					NewLine(sb, indent, depth);
				}
				sb.Append(']');
				break;
			}
			case Kind.Object:
			{
				if (v._object.Count == 0)
				{
					sb.Append("{}");
					break;
				}
				sb.Append('{');
				bool flag2 = true;
				foreach (KeyValuePair<string, JsonValue> item in v._object)
				{
					if (!flag2)
					{
						sb.Append(',');
					}
					flag2 = false;
					if (flag)
					{
						NewLine(sb, indent, depth + 1);
					}
					WriteString(sb, item.Key);
					sb.Append(':');
					if (flag)
					{
						sb.Append(' ');
					}
					Write(sb, item.Value, indent, depth + 1);
				}
				if (flag)
				{
					NewLine(sb, indent, depth);
				}
				sb.Append('}');
				break;
			}
			}
		}

		private static void NewLine(StringBuilder sb, int indent, int depth)
		{
			sb.Append('\n');
			sb.Append(' ', indent * depth);
		}

		private static void WriteNumber(StringBuilder sb, double d, bool asFloat)
		{
			if (double.IsNaN(d) || double.IsInfinity(d))
			{
				sb.Append('0');
			}
			else
			{
				sb.Append(asFloat ? ((float)d).ToString("R", CultureInfo.InvariantCulture) : d.ToString("R", CultureInfo.InvariantCulture));
			}
		}

		private static void WriteString(StringBuilder sb, string s)
		{
			sb.Append('"');
			foreach (char c in s)
			{
				switch (c)
				{
				case '"':
					sb.Append("\\\"");
					continue;
				case '\\':
					sb.Append("\\\\");
					continue;
				case '\b':
					sb.Append("\\b");
					continue;
				case '\f':
					sb.Append("\\f");
					continue;
				case '\n':
					sb.Append("\\n");
					continue;
				case '\r':
					sb.Append("\\r");
					continue;
				case '\t':
					sb.Append("\\t");
					continue;
				}
				if (c < ' ')
				{
					StringBuilder stringBuilder = sb.Append("\\u");
					int num = c;
					stringBuilder.Append(num.ToString("x4", CultureInfo.InvariantCulture));
				}
				else
				{
					sb.Append(c);
				}
			}
			sb.Append('"');
		}

		public static JsonValue Parse(string text)
		{
			if (text == null)
			{
				throw new JsonException("Cannot parse null.");
			}
			int pos = 0;
			JsonValue result = ParseValue(text, ref pos, 0);
			SkipWhitespace(text, ref pos);
			if (pos != text.Length)
			{
				throw new JsonException("Trailing content at offset " + pos + ".");
			}
			return result;
		}

		public static JsonValue TryParse(string text)
		{
			try
			{
				return Parse(text);
			}
			catch (JsonException)
			{
				return null;
			}
		}

		private static JsonValue ParseValue(string s, ref int pos, int depth)
		{
			if (depth > 64)
			{
				throw new JsonException("Nested too deeply.");
			}
			SkipWhitespace(s, ref pos);
			if (pos >= s.Length)
			{
				throw new JsonException("Unexpected end of input.");
			}
			switch (s[pos])
			{
			case '{':
				return ParseObject(s, ref pos, depth);
			case '[':
				return ParseArray(s, ref pos, depth);
			case '"':
				return String(ParseString(s, ref pos));
			case 't':
				Expect(s, ref pos, "true");
				return Bool(v: true);
			case 'f':
				Expect(s, ref pos, "false");
				return Bool(v: false);
			case 'n':
				Expect(s, ref pos, "null");
				return Null;
			default:
				return Number(ParseNumber(s, ref pos));
			}
		}

		private static JsonValue ParseObject(string s, ref int pos, int depth)
		{
			pos++;
			JsonValue jsonValue = NewObject();
			SkipWhitespace(s, ref pos);
			if (pos < s.Length && s[pos] == '}')
			{
				pos++;
				return jsonValue;
			}
			while (true)
			{
				SkipWhitespace(s, ref pos);
				if (pos >= s.Length || s[pos] != '"')
				{
					throw new JsonException("Expected a member name at offset " + pos + ".");
				}
				string key = ParseString(s, ref pos);
				SkipWhitespace(s, ref pos);
				if (pos >= s.Length || s[pos] != ':')
				{
					throw new JsonException("Expected ':' at offset " + pos + ".");
				}
				pos++;
				jsonValue._object[key] = ParseValue(s, ref pos, depth + 1);
				SkipWhitespace(s, ref pos);
				if (pos >= s.Length)
				{
					throw new JsonException("Unterminated object.");
				}
				if (s[pos] != ',')
				{
					break;
				}
				pos++;
			}
			if (s[pos] == '}')
			{
				pos++;
				return jsonValue;
			}
			throw new JsonException("Expected ',' or '}' at offset " + pos + ".");
		}

		private static JsonValue ParseArray(string s, ref int pos, int depth)
		{
			pos++;
			JsonValue jsonValue = NewArray();
			SkipWhitespace(s, ref pos);
			if (pos < s.Length && s[pos] == ']')
			{
				pos++;
				return jsonValue;
			}
			while (true)
			{
				jsonValue._array.Add(ParseValue(s, ref pos, depth + 1));
				SkipWhitespace(s, ref pos);
				if (pos >= s.Length)
				{
					throw new JsonException("Unterminated array.");
				}
				if (s[pos] != ',')
				{
					break;
				}
				pos++;
			}
			if (s[pos] == ']')
			{
				pos++;
				return jsonValue;
			}
			throw new JsonException("Expected ',' or ']' at offset " + pos + ".");
		}

		private static string ParseString(string s, ref int pos)
		{
			pos++;
			StringBuilder stringBuilder = new StringBuilder();
			while (pos < s.Length)
			{
				char c = s[pos++];
				switch (c)
				{
				case '"':
					return stringBuilder.ToString();
				default:
					stringBuilder.Append(c);
					break;
				case '\\':
				{
					if (pos >= s.Length)
					{
						throw new JsonException("Unterminated escape.");
					}
					char c2 = s[pos++];
					switch (c2)
					{
					case '"':
						stringBuilder.Append('"');
						break;
					case '\\':
						stringBuilder.Append('\\');
						break;
					case '/':
						stringBuilder.Append('/');
						break;
					case 'b':
						stringBuilder.Append('\b');
						break;
					case 'f':
						stringBuilder.Append('\f');
						break;
					case 'n':
						stringBuilder.Append('\n');
						break;
					case 'r':
						stringBuilder.Append('\r');
						break;
					case 't':
						stringBuilder.Append('\t');
						break;
					case 'u':
					{
						if (pos + 4 > s.Length)
						{
							throw new JsonException("Truncated \\u escape.");
						}
						if (!int.TryParse(s.Substring(pos, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result))
						{
							throw new JsonException("Bad \\u escape at offset " + pos + ".");
						}
						stringBuilder.Append((char)result);
						pos += 4;
						break;
					}
					default:
						throw new JsonException("Unknown escape '\\" + c2 + "' at offset " + (pos - 1) + ".");
					}
					break;
				}
				}
			}
			throw new JsonException("Unterminated string.");
		}

		private static double ParseNumber(string s, ref int pos)
		{
			int num = pos;
			if (pos < s.Length && (s[pos] == '-' || s[pos] == '+'))
			{
				pos++;
			}
			while (pos < s.Length)
			{
				char c = s[pos];
				if ((c < '0' || c > '9') && c != '.' && c != 'e' && c != 'E' && c != '-' && c != '+')
				{
					break;
				}
				pos++;
			}
			string text = s.Substring(num, pos - num);
			if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				throw new JsonException("Bad number '" + text + "' at offset " + num + ".");
			}
			return result;
		}

		private static void Expect(string s, ref int pos, string literal)
		{
			if (pos + literal.Length > s.Length || string.CompareOrdinal(s, pos, literal, 0, literal.Length) != 0)
			{
				throw new JsonException("Expected '" + literal + "' at offset " + pos + ".");
			}
			pos += literal.Length;
		}

		private static void SkipWhitespace(string s, ref int pos)
		{
			while (pos < s.Length)
			{
				switch (s[pos])
				{
				case '\t':
				case '\n':
				case '\r':
				case ' ':
					pos++;
					break;
				case '/':
					if (pos + 1 < s.Length && s[pos + 1] == '/')
					{
						pos += 2;
						while (pos < s.Length && s[pos] != '\n')
						{
							pos++;
						}
						break;
					}
					return;
				default:
					return;
				}
			}
		}
	}
}
namespace GBV.Idavoll
{
	internal static class Clock
	{
		public static double WorldSeconds()
		{
			if (!((Object)(object)ZNet.instance != (Object)null))
			{
				return 0.0;
			}
			return ZNet.instance.GetTimeSeconds();
		}

		public static double HoursSince(DungeonState state, RuleTable table)
		{
			if (state == null)
			{
				return double.MaxValue;
			}
			if (table != null && table.TimeSource == TimeSource.WallClock)
			{
				if (state.LastResetUtcTicks <= 0)
				{
					return double.MaxValue;
				}
				return (DateTime.UtcNow - new DateTime(state.LastResetUtcTicks)).TotalHours;
			}
			if (state.LastResetWorldTime <= 0.0)
			{
				return double.MaxValue;
			}
			double num = WorldSeconds();
			if (num < state.LastResetWorldTime)
			{
				return double.MaxValue;
			}
			return (num - state.LastResetWorldTime) / 3600.0;
		}

		public static string Humanise(double hours)
		{
			if (double.IsInfinity(hours) || hours >= 1000000.0)
			{
				return "never";
			}
			if (hours < 0.0)
			{
				hours = 0.0;
			}
			if (hours < 1.0)
			{
				return Math.Max(1, (int)Math.Round(hours * 60.0)) + "m";
			}
			if (hours < 24.0)
			{
				int num = (int)hours;
				int num2 = (int)Math.Round((hours - (double)num) * 60.0);
				if (num2 <= 0)
				{
					return num + "h";
				}
				return num + "h " + num2 + "m";
			}
			int num3 = (int)(hours / 24.0);
			int num4 = (int)Math.Round(hours - (double)num3 * 24.0);
			if (num4 <= 0)
			{
				return num3 + "d";
			}
			return num3 + "d " + num4 + "h";
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Commands
	{
		private static bool _registered;

		[HarmonyPostfix]
		public static void Postfix()
		{
			if (_registered)
			{
				return;
			}
			_registered = true;
			try
			{
				Register();
			}
			catch (Exception ex)
			{
				Safety.Failed("Terminal.InitTerminal command registration", ex);
			}
		}

		private static void Register()
		{
			Cmd("idavoll_status", "idavoll_status [filter|radius <m>] - dungeons, when they last reset and when they are due. Defaults to the 20 nearest.");
			Cmd("idavoll_locations", "idavoll_locations [filter] - every KIND of location in this world with a count, and whether a rule covers it. This is how you find out what to write rules for.");
			Cmd("idavoll_dryrun", "idavoll_dryrun <x> <z> | here - show exactly what a reset would destroy and keep, and change nothing. Run this before trusting a reset.");
			Cmd("idavoll_reset", "idavoll_reset <x> <z> | here [force] - reset one dungeon now. Refuses if a player is nearby; force overrides that, but never if somebody is inside.");
			Cmd("idavoll_pending", "idavoll_pending - what the scheduler is waiting for, and what is in flight.");
			Cmd("idavoll_forget", "idavoll_forget <x> <z> | all - clear stored reset times so they count from now. What you want after restoring a world backup.");
			Cmd("idavoll_reload", "idavoll_reload [defaults] - re-read the rule table from disk and push it to every client. 'defaults' rewrites the file first, keeping a .bak.");
			Cmd("idavoll_abort", "idavoll_abort - abandon the reset in flight. The dungeon is left as it is.");
		}

		private static void Cmd(string name, string help)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			new ConsoleCommand(name, help, (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				try
				{
					string line = string.Join(" ", args.Args);
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString(Dispatch(line, args.Context));
					}
				}
				catch (Exception ex)
				{
					Safety.Failed(name, ex);
					Terminal context2 = args.Context;
					if (context2 != null)
					{
						context2.AddString("Idavoll: " + name + " failed. See the log.");
					}
				}
			}, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		private static string Dispatch(string line, Terminal context)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return "Idavoll: load into a world first.";
			}
			if (!ZNet.instance.IsServer())
			{
				if (!ZNet.instance.LocalPlayerIsAdminOrHost())
				{
					return "Idavoll: you need to be an admin on this server to do that.";
				}
				ConfigSync.RequestCommand(ResolveHere(line));
				return "Idavoll: asked the server. The answer appears in the Dungeons tab.";
			}
			return RunForPeer(ResolveHere(line), 0L);
		}

		private static string ResolveHere(string line)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			if (line == null)
			{
				return string.Empty;
			}
			if (line.IndexOf("here", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return line;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return line;
			}
			Vector2s zone = ZoneSystem.GetZone(((Component)localPlayer).transform.position);
			return ReplaceWord(line, "here", zone.x + " " + zone.y);
		}

		private static string ReplaceWord(string line, string word, string with)
		{
			string[] array = line.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				if (string.Equals(array[i], word, StringComparison.OrdinalIgnoreCase))
				{
					array[i] = with;
				}
			}
			return string.Join(" ", array);
		}

		internal static string RunForPeer(string line, long peer)
		{
			string[] array = (line ?? string.Empty).Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return "Idavoll: nothing to do.";
			}
			string text = array[0].ToLowerInvariant();
			return text switch
			{
				"idavoll_status" => Status(array), 
				"idavoll_locations" => Locations(array), 
				"idavoll_dryrun" => DryRun(array), 
				"idavoll_reset" => Reset(array, peer), 
				"idavoll_pending" => Pending(), 
				"idavoll_forget" => Forget(array), 
				"idavoll_reload" => Reload(array), 
				"idavoll_abort" => Abort(), 
				_ => "Idavoll: unknown command '" + text + "'.", 
			};
		}

		private static string Status(string[] a)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<DungeonRecord> readOnlyList = Dungeons.All();
			List<DungeonRecord> list = new List<DungeonRecord>();
			string value = ((a.Length > 1) ? a[1] : null);
			if (!string.IsNullOrEmpty(value))
			{
				foreach (DungeonRecord item in readOnlyList)
				{
					if (item.Prefab.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						list.Add(item);
					}
				}
			}
			else
			{
				list.AddRange(Dungeons.Nearest(AnchorPosition(), 20));
			}
			if (list.Count == 0)
			{
				return "Idavoll: nothing here resets. " + Dungeons.TotalLocations + " location(s) in this world, none of them covered by an enabled rule. Run idavoll_locations to see what is out there.";
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Idavoll: " + list.Count + " of " + readOnlyList.Count + " resettable location(s) (" + Dungeons.TotalLocations + " in the world), clock is " + RuleTable.Current.TimeSource.ToString() + ".");
			foreach (DungeonRecord item2 in list)
			{
				string text = ((!item2.NeverResets) ? (item2.Placed ? ((!item2.Due) ? ("in " + Clock.Humanise(item2.HoursUntilDue.Value)) : "DUE") : "not generated yet") : (item2.Unique ? "never (unique)" : "never (by rule)"));
				string text2 = ((item2.Resets == 0) ? "never reset" : (Clock.Humanise(item2.HoursSinceReset) + " ago, " + item2.Resets + "x"));
				stringBuilder.AppendLine("  " + item2.Prefab.PadRight(28) + ("(" + item2.Zone.x + "," + item2.Zone.y + ")").PadRight(12) + text.PadRight(18) + text2);
			}
			return stringBuilder.ToString();
		}

		private static string Locations(string[] a)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZoneSystem.instance == (Object)null)
			{
				return "Idavoll: no world loaded.";
			}
			string value = ((a.Length > 1) ? a[1] : null);
			RuleTable current = RuleTable.Current;
			Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.Ordinal);
			Dictionary<string, bool> dictionary2 = new Dictionary<string, bool>(StringComparer.Ordinal);
			int num = 0;
			foreach (KeyValuePair<Vector2s, LocationInstance> locationInstance in ZoneSystem.instance.m_locationInstances)
			{
				ZoneLocation location = locationInstance.Value.m_location;
				if (location == null)
				{
					continue;
				}
				string text = location.m_prefabName;
				if (string.IsNullOrEmpty(text))
				{
					text = location.m_prefab.Name;
				}
				if (!string.IsNullOrEmpty(text))
				{
					num++;
					if (string.IsNullOrEmpty(value) || text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						dictionary.TryGetValue(text, out var value2);
						dictionary[text] = value2 + 1;
						dictionary2[text] = location.m_interiorRadius > 0f;
					}
				}
			}
			if (dictionary.Count == 0)
			{
				return "Idavoll: no location kinds matched.";
			}
			List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>(dictionary);
			list.Sort((KeyValuePair<string, int> x, KeyValuePair<string, int> y) => y.Value.CompareTo(x.Value));
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Idavoll: " + dictionary.Count + " kind(s) of location, " + num + " instance(s) in the world. 'i' means it has an interior.");
			stringBuilder.AppendLine("  count  i  name                            rule");
			int num2 = 0;
			foreach (KeyValuePair<string, int> item in list)
			{
				double? num3 = current.IntervalFor(item.Key);
				ResetRule resetRule = current.Match(item.Key);
				string text2;
				if (num3.HasValue)
				{
					text2 = "every " + num3.Value.ToString("0.##") + "h (" + resetRule.Key + ")";
					num2 += item.Value;
				}
				else
				{
					text2 = ((resetRule == null) ? "never (no rule)" : ("never (" + resetRule.Key + ")"));
				}
				stringBuilder.AppendLine("  " + item.Value.ToString().PadLeft(5) + "  " + (dictionary2[item.Key] ? "i" : " ") + "  " + item.Key.PadRight(30) + "  " + text2);
			}
			stringBuilder.AppendLine("  " + num2 + " instance(s) would ever reset.");
			return stringBuilder.ToString();
		}

		private static string DryRun(string[] a)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b0: 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)
			//IL_00be: 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)
			if (!TryZone(a, 1, out var zone, out var error))
			{
				return error;
			}
			if (!Protection.EnsureBuilt())
			{
				return "Idavoll: the protection index is not ready yet. Try again in a moment.";
			}
			if (!ZoneSystem.instance.m_locationInstances.TryGetValue(zone, out var value))
			{
				return "Idavoll: no location registered in zone " + zone.x + "," + zone.y + ".";
			}
			string error2;
			DungeonPin dungeonPin = PinForDryRun(zone, value, out error2);
			if (dungeonPin == null)
			{
				return "Idavoll: " + error2;
			}
			ScanResult scanResult = SectorScan.Scan(zone, dungeonPin);
			if (scanResult.Error != null)
			{
				return "Idavoll: " + scanResult.Error;
			}
			string text = SectorScan.Format(zone, dungeonPin, scanResult);
			string text2 = Occupancy.Blocking(zone, value, force: false);
			if (text2 != null)
			{
				text = text + "  blocked: " + text2 + Environment.NewLine;
			}
			if (value.m_location.m_unique && RuleTable.Current.SkipUniqueLocations)
			{
				text = text + "  skipped: this is a unique location" + Environment.NewLine;
			}
			return text;
		}

		private static DungeonPin PinForDryRun(Vector2s zone, LocationInstance li, out string error)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00b3: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_0135: 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)
			error = null;
			List<ZDO> list = new List<ZDO>();
			ZDOMan.instance.FindSectorObjects(zone, new SimulationDistance(0, 0, false), list, (List<ZDO>)null);
			ZDO val = null;
			foreach (ZDO item in list)
			{
				if (item != null && item.GetPrefab() == Protection.LocationProxyHash)
				{
					val = item;
					break;
				}
			}
			if (val == null)
			{
				error = "no location proxy in zone " + zone.x + "," + zone.y + ". The zone is not loaded on the server, so there is nothing to scan. Have somebody stand near it and try again.";
				return null;
			}
			return new DungeonPin
			{
				Zone = zone,
				Prefab = (li.m_location.m_prefabName ?? li.m_location.m_prefab.Name),
				Position = val.GetPosition(),
				Rotation = val.GetRotation(),
				LocationHash = val.GetInt(ZDOVars.s_location, 0),
				Seed = val.GetInt(ZDOVars.s_seed, 0),
				Radius = Mathf.Max(li.m_location.m_exteriorRadius, li.m_location.m_interiorRadius),
				Location = li.m_location
			};
		}

		private static string Reset(string[] a, long peer)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!TryZone(a, 1, out var zone, out var error))
			{
				return error;
			}
			bool force = false;
			for (int i = 1; i < a.Length; i++)
			{
				if (string.Equals(a[i], "force", StringComparison.OrdinalIgnoreCase))
				{
					force = true;
				}
			}
			string text = Rebuild.Begin(zone, force, peer);
			if (text != null)
			{
				return "Idavoll: " + text;
			}
			return "Idavoll: resetting " + Rebuild.ActivePrefab + " in zone " + zone.x + "," + zone.y + ". Watch idavoll_pending; on a dedicated server the rebuild waits until somebody is near the zone.";
		}

		private static string Pending()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Idavoll: " + Rebuild.Status());
			stringBuilder.AppendLine("  scheduler: " + Scheduler.Reason);
			List<DungeonRecord> list = Dungeons.Due();
			stringBuilder.AppendLine("  " + list.Count + " dungeon(s) due:");
			int num = Math.Min(10, list.Count);
			for (int i = 0; i < num; i++)
			{
				DungeonRecord dungeonRecord = list[i];
				stringBuilder.AppendLine("    " + dungeonRecord.Prefab.PadRight(28) + "(" + dungeonRecord.Zone.x + "," + dungeonRecord.Zone.y + ")  overdue by " + Clock.Humanise(dungeonRecord.HoursSinceReset - dungeonRecord.IntervalHours.Value));
			}
			if (list.Count > num)
			{
				stringBuilder.AppendLine("    ... and " + (list.Count - num) + " more");
			}
			if (ResetState.Broken)
			{
				stringBuilder.AppendLine("  !! the reset history will not parse: " + ResetState.BrokenReason);
			}
			return stringBuilder.ToString();
		}

		private static string Forget(string[] a)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (a.Length > 1 && string.Equals(a[1], "all", StringComparison.OrdinalIgnoreCase))
			{
				int num = ResetState.ForgetAll();
				Dungeons.Invalidate();
				return "Idavoll: forgot " + num + " reset time(s). Everything counts from now.";
			}
			if (!TryZone(a, 1, out var zone, out var error))
			{
				return error;
			}
			bool num2 = ResetState.Forget(zone);
			Dungeons.Invalidate();
			if (!num2)
			{
				return "Idavoll: nothing stored for zone " + zone.x + "," + zone.y + ".";
			}
			return "Idavoll: forgot the reset time for zone " + zone.x + "," + zone.y + ".";
		}

		private static string Reload(string[] a)
		{
			bool flag = a.Length > 1 && string.Equals(a[1], "defaults", StringComparison.OrdinalIgnoreCase);
			string text = (flag ? ConfigSync.ResetToDefaults() : ConfigSync.LoadFromDisk());
			if (text != null)
			{
				return "Idavoll: " + text;
			}
			Protection.Invalidate();
			Dungeons.Invalidate();
			int num = ConfigSync.PushConfigToAllPeers();
			return "Idavoll: reloaded the rule table" + (flag ? " from defaults" : "") + " and pushed it to " + num + " peer(s).";
		}

		private static string Abort()
		{
			if (!Rebuild.Busy)
			{
				return "Idavoll: nothing in flight.";
			}
			string activePrefab = Rebuild.ActivePrefab;
			Rebuild.AbandonAll("an admin aborted it");
			return "Idavoll: abandoned the reset of " + activePrefab + ". Whatever was already destroyed stays destroyed; run the reset again to rebuild it.";
		}

		private static bool TryZone(string[] a, int from, out Vector2s zone, out string error)
		{
			//IL_0001: 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)
			zone = default(Vector2s);
			error = null;
			if (a.Length < from + 2)
			{
				error = "Idavoll: give a zone as two numbers, or 'here'. Try idavoll_status to find one.";
				return false;
			}
			if (!int.TryParse(a[from], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(a[from + 1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2))
			{
				error = "Idavoll: '" + a[from] + " " + a[from + 1] + "' is not a zone. Zones are two whole numbers, like 12 -31.";
				return false;
			}
			zone = new Vector2s(result, result2);
			return true;
		}

		private static Vector3 AnchorPosition()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0077: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				return ((Component)Player.m_localPlayer).transform.position;
			}
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				foreach (ZNetPeer peer in ZNet.instance.GetPeers())
				{
					if (peer != null && peer.IsReady())
					{
						return peer.GetRefPos();
					}
				}
			}
			return Vector3.zero;
		}
	}
	public static class ConfigSync
	{
		private const string RpcConfig = "GBV_Idavoll_Config";

		private const string RpcReport = "GBV_Idavoll_Report";

		private const string RpcRequest = "GBV_Idavoll_Request";

		private const int WireVersion = 1;

		public const string FileName = "gbv.valheim.idavoll.json";

		private static bool _registered;

		public static bool HasServerConfig { get; private set; }

		public static string LastReport { get; private set; } = string.Empty;

		public static int Revision { get; private set; }

		public static string ConfigPath => Path.Combine(Paths.ConfigPath, "gbv.valheim.idavoll.json");

		public static void SetLocalReport(string text)
		{
			LastReport = text ?? string.Empty;
			Revision++;
		}

		public static string LoadFromDisk()
		{
			try
			{
				string configPath = ConfigPath;
				if (!File.Exists(configPath))
				{
					Directory.CreateDirectory(Path.GetDirectoryName(configPath));
					File.WriteAllText(configPath, RuleTable.Defaults().ToJson());
					IdavollPlugin.Log.LogInfo((object)("Idavoll: wrote a default rule table to " + configPath));
				}
				RuleTable ruleTable = (RuleTable.Current = RuleTable.FromJson(File.ReadAllText(configPath)));
				Revision++;
				IdavollPlugin.Log.LogInfo((object)("Idavoll: loaded " + ruleTable.Rules.Count + " reset rule(s), default interval " + ruleTable.DefaultIntervalHours + "h on the " + ruleTable.TimeSource.ToString() + " clock. Engine is " + (ruleTable.Enabled ? "on" : "OFF in the rule table") + "."));
				return null;
			}
			catch (JsonException ex)
			{
				return "the rule table is not valid JSON (" + ex.Message + "). Keeping the previous table.";
			}
			catch (Exception ex2)
			{
				return "could not read the rule table: " + ex2.Message;
			}
		}

		public static string SaveToDisk(RuleTable table)
		{
			try
			{
				string configPath = ConfigPath;
				Directory.CreateDirectory(Path.GetDirectoryName(configPath));
				if (File.Exists(configPath))
				{
					File.Copy(configPath, configPath + ".bak", overwrite: true);
				}
				File.WriteAllText(configPath, table.ToJson());
				return null;
			}
			catch (Exception ex)
			{
				return "could not write the rule table (" + ex.Message + ").";
			}
		}

		public static string ResetToDefaults()
		{
			return SaveToDisk(RuleTable.Defaults()) ?? LoadFromDisk();
		}

		public static void Register()
		{
			if (ZRoutedRpc.instance == null)
			{
				return;
			}
			if (!_registered)
			{
				ZRoutedRpc.instance.Register<ZPackage>("GBV_Idavoll_Config", (Action<long, ZPackage>)OnConfigReceived);
				ZRoutedRpc.instance.Register<ZPackage>("GBV_Idavoll_Report", (Action<long, ZPackage>)OnReportReceived);
				ZRoutedRpc.instance.Register<ZPackage>("GBV_Idavoll_Request", (Action<long, ZPackage>)OnRequestReceived);
				_registered = true;
			}
			if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
			{
				string text = LoadFromDisk();
				if (text != null)
				{
					IdavollPlugin.Log.LogError((object)("Idavoll: " + text));
				}
				ResetState.EnsureLoaded();
				ZRoutedRpc instance = ZRoutedRpc.instance;
				instance.m_onNewPeer = (Action<long>)Delegate.Combine(instance.m_onNewPeer, new Action<long>(OnNewPeer));
			}
			else
			{
				HasServerConfig = false;
			}
		}

		public static void Unload()
		{
			HasServerConfig = false;
			LastReport = string.Empty;
			Revision++;
			ResetState.Unload();
		}

		private static void OnNewPeer(long peerId)
		{
			PushConfigTo(peerId);
		}

		private static void PushConfigTo(long peerId)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				ZPackage val = new ZPackage();
				val.Write(1);
				val.Write(RuleTable.Current.ToJson());
				ZRoutedRpc.instance.InvokeRoutedRPC(peerId, "GBV_Idavoll_Config", new object[1] { val });
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: failed to push the rule table to peer " + peerId + ": " + ex.Message));
			}
		}

		public static int PushConfigToAllPeers()
		{
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return -1;
			}
			List<ZNetPeer> peers = ZNet.instance.GetPeers();
			foreach (ZNetPeer item in peers)
			{
				PushConfigTo(item.m_uid);
			}
			return peers.Count;
		}

		public static void Report(long peerId, string text)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || peerId == 0L)
			{
				return;
			}
			try
			{
				ZPackage val = new ZPackage();
				val.Write(1);
				val.Write(text ?? string.Empty);
				ZRoutedRpc.instance.InvokeRoutedRPC(peerId, "GBV_Idavoll_Report", new object[1] { val });
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: failed to report to peer " + peerId + ": " + ex.Message));
			}
		}

		private static void OnConfigReceived(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				IdavollPlugin.Log.LogWarning((object)("Idavoll: ignoring a rule table pushed by " + sender + "; this instance is the server."));
				return;
			}
			try
			{
				if (pkg.ReadInt() != 1)
				{
					WrongWire();
					return;
				}
				RuleTable.Current = RuleTable.FromJson(pkg.ReadString());
				HasServerConfig = true;
				Revision++;
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: the server's rule table would not parse: " + ex.Message));
			}
		}

		private static void OnReportReceived(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				if (pkg.ReadInt() != 1)
				{
					WrongWire();
					return;
				}
				LastReport = pkg.ReadString();
				Revision++;
				EchoToConsole(LastReport);
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: a report from the server would not parse: " + ex.Message));
			}
		}

		public static void RequestSave(RuleTable table)
		{
			Send("save", table.ToJson());
		}

		public static void RequestCommand(string command)
		{
			Send("run", command);
		}

		private static void Send(string verb, string payload)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer() || ZRoutedRpc.instance == null)
			{
				return;
			}
			try
			{
				ZPackage val = new ZPackage();
				val.Write(1);
				val.Write(verb);
				val.Write(payload ?? string.Empty);
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GBV_Idavoll_Request", new object[1] { val });
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: could not send a request to the server: " + ex.Message));
			}
		}

		private static void OnRequestReceived(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				if (pkg.ReadInt() != 1)
				{
					WrongWire();
					return;
				}
				string text = pkg.ReadString();
				string text2 = pkg.ReadString();
				if (!IsAdminPeer(sender))
				{
					IdavollPlugin.Log.LogWarning((object)("Idavoll: refused a '" + text + "' request from peer " + sender + ", who is not an admin on this server."));
					Report(sender, "Idavoll: you are not an admin on this server.");
				}
				else if (!(text == "save"))
				{
					if (text == "run")
					{
						Report(sender, Commands.RunForPeer(text2, sender));
					}
					else
					{
						IdavollPlugin.Log.LogWarning((object)("Idavoll: unknown request verb '" + text + "'."));
					}
				}
				else
				{
					ApplyFromAdmin(sender, text2);
				}
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogError((object)("Idavoll: a client request would not parse: " + ex.Message));
			}
		}

		private static void ApplyFromAdmin(long sender, string json)
		{
			RuleTable ruleTable;
			try
			{
				ruleTable = RuleTable.FromJson(json);
			}
			catch (Exception ex)
			{
				Report(sender, "Idavoll: that table would not parse (" + ex.Message + "). Nothing changed.");
				return;
			}
			string text = SaveToDisk(ruleTable);
			if (text != null)
			{
				Report(sender, "Idavoll: " + text);
				return;
			}
			RuleTable.Current = ruleTable;
			Revision++;
			Dungeons.Invalidate();
			Protection.Invalidate();
			int num = PushConfigToAllPeers();
			IdavollPlugin.Log.LogInfo((object)("Idavoll: an admin saved a new rule table; pushed to " + num + " peer(s)."));
			Report(sender, "Idavoll: saved. The previous table is at " + ConfigPath + ".bak");
		}

		private static bool IsAdminPeer(long sender)
		{
			try
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (peer?.m_socket == null)
				{
					return false;
				}
				return ZNet.instance.IsAdmin(peer.m_socket.GetHostName());
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogWarning((object)("Idavoll: could not check admin for peer " + sender + ": " + ex.Message));
				return false;
			}
		}

		private static void EchoToConsole(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			try
			{
				Terminal instance = (Terminal)(object)Console.instance;
				if (!((Object)(object)instance == (Object)null))
				{
					string[] array = text.Split('\n');
					foreach (string text2 in array)
					{
						instance.AddString(text2.TrimEnd('\r'));
					}
				}
			}
			catch (Exception ex)
			{
				Safety.Failed("echoing a server report to the console", ex);
			}
		}

		private static void WrongWire()
		{
			IdavollPlugin.Log.LogError((object)"Idavoll: wire version mismatch. The server and this client are running different builds of Idavoll; update one of them.");
		}
	}
	[HarmonyPatch(typeof(ZNet), "Awake")]
	public static class ZNetAwakePatch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			try
			{
				ConfigSync.Register();
			}
			catch (Exception ex)
			{
				Safety.Failed("ZNet.Awake config sync registration", ex);
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnDestroy")]
	public static class ZNetOnDestroyPatch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			try
			{
				ConfigSync.Unload();
			}
			catch (Exception ex)
			{
				Safety.Failed("ZNet.OnDestroy config unload", ex);
			}
		}
	}
	internal sealed class DungeonRecord
	{
		internal Vector2s Zone;

		internal string Prefab = string.Empty;

		internal Vector3 Position;

		internal float Radius;

		internal bool Unique;

		internal bool Placed;

		internal double? IntervalHours;

		internal double HoursSinceReset;

		internal int Resets;

		internal bool NeverResets => !IntervalHours.HasValue;

		internal bool Due
		{
			get
			{
				if (IntervalHours.HasValue)
				{
					return HoursSinceReset >= IntervalHours.Value;
				}
				return false;
			}
		}

		internal double? HoursUntilDue
		{
			get
			{
				if (IntervalHours.HasValue)
				{
					return Math.Max(0.0, IntervalHours.Value - HoursSinceReset);
				}
				return null;
			}
		}
	}
	internal static class Dungeons
	{
		private static readonly List<DungeonRecord> _cache = new List<DungeonRecord>();

		private static bool _valid;

		private static float _builtAt;

		private const float MaxAgeSeconds = 5f;

		internal static int TotalLocations { get; private set; }

		internal static void Invalidate()
		{
			_valid = false;
		}

		internal static IReadOnlyList<DungeonRecord> All()
		{
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (_valid && Time.realtimeSinceStartup - _builtAt < 5f)
			{
				return _cache;
			}
			_cache.Clear();
			_valid = true;
			_builtAt = Time.realtimeSinceStartup;
			TotalLocations = 0;
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZoneSystem.instance == (Object)null)
			{
				return _cache;
			}
			ResetState.EnsureLoaded();
			RuleTable current = RuleTable.Current;
			foreach (KeyValuePair<Vector2s, LocationInstance> locationInstance in ZoneSystem.instance.m_locationInstances)
			{
				LocationInstance value = locationInstance.Value;
				if (value.m_location == null)
				{
					continue;
				}
				string text = value.m_location.m_prefabName;
				if (string.IsNullOrEmpty(text))
				{
					text = value.m_location.m_prefab.Name;
				}
				if (!string.IsNullOrEmpty(text))
				{
					TotalLocations++;
					bool flag = value.m_location.m_unique && current.SkipUniqueLocations;
					double? intervalHours = (flag ? ((double?)null) : current.IntervalFor(text));
					if (intervalHours.HasValue)
					{
						DungeonState dungeonState = ResetState.Get(locationInstance.Key) ?? ResetState.Baseline;
						_cache.Add(new DungeonRecord
						{
							Zone = locationInstance.Key,
							Prefab = text,
							Position = value.m_position,
							Radius = Mathf.Max(value.m_location.m_exteriorRadius, value.m_location.m_interiorRadius),
							Unique = flag,
							Placed = value.m_placed,
							IntervalHours = intervalHours,
							HoursSinceReset = Clock.HoursSince(dungeonState, current),
							Resets = (dungeonState?.Resets ?? 0)
						});
					}
				}
			}
			return _cache;
		}

		internal static DungeonRecord At(Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_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)
			Vector2s zone = ZoneSystem.GetZone(point);
			foreach (DungeonRecord item in All())
			{
				if (item.Zone == zone)
				{
					return item;
				}
			}
			return null;
		}

		internal static DungeonRecord InZone(Vector2s zone)
		{
			//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)
			foreach (DungeonRecord item in All())
			{
				if (item.Zone == zone)
				{
					return item;
				}
			}
			return null;
		}

		internal static List<DungeonRecord> Due()
		{
			List<DungeonRecord> list = new List<DungeonRecord>();
			foreach (DungeonRecord item in All())
			{
				if (item.Placed && !item.NeverResets && item.Due)
				{
					list.Add(item);
				}
			}
			list.Sort(delegate(DungeonRecord a, DungeonRecord b)
			{
				double value = a.HoursSinceReset - a.IntervalHours.Value;
				return (b.HoursSinceReset - b.IntervalHours.Value).CompareTo(value);
			});
			return list;
		}

		internal static List<DungeonRecord> Nearest(Vector3 point, int limit)
		{
			//IL_0007: 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)
			List<DungeonRecord> list = new List<DungeonRecord>();
			foreach (DungeonRecord item in All())
			{
				if (item.Placed)
				{
					list.Add(item);
				}
			}
			list.Sort(delegate(DungeonRecord a, DungeonRecord b)
			{
				//IL_0001: 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_0013: 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)
				float num = SqrXZ(a.Position, point);
				float value = SqrXZ(b.Position, point);
				return num.CompareTo(value);
			});
			if (list.Count > limit)
			{
				list.RemoveRange(limit, list.Count - limit);
			}
			return list;
		}

		private static float SqrXZ(Vector3 a, Vector3 b)
		{
			//IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			float num = a.x - b.x;
			float num2 = a.z - b.z;
			return num * num + num2 * num2;
		}
	}
	internal static class HighseatBridge
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HighseatTabDraw <0>__Draw;

			public static Action <1>__OnSelected;
		}

		private const string HighseatGuid = "gbv.valheim.highseat";

		internal static bool Registered { get; private set; }

		internal static bool TryRegister()
		{
			try
			{
				if (!Chainloader.PluginInfos.ContainsKey("gbv.valheim.highseat"))
				{
					IdavollPlugin.Log.LogInfo((object)"Idavoll: Highseat is not installed here, so there is no settings tab. The engine is unaffected; it only ever runs on the server anyway.");
					return false;
				}
				RegisterInner();
				Registered = true;
				IdavollPlugin.Log.LogInfo((object)"Idavoll: added the Dungeons tab to Highseat.");
				return true;
			}
			catch (Exception ex)
			{
				IdavollPlugin.Log.LogWarning((object)("Idavoll: could not add the Dungeons tab to Highseat (" + ex.Message + "). Highseat 0.11.0 or newer is needed for it. The console commands still work."));
				return false;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterInner()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing refer