Decompiled source of Frami v0.1.0

plugins/Frami.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GBV.Shared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[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.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+3282a85faf9b442c1dc17daa9d5a143b7f7824b1")]
[assembly: AssemblyProduct("Frami")]
[assembly: AssemblyTitle("Frami")]
[assembly: AssemblyVersion("0.1.0.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);
		}
	}
}
namespace GBV.Frami
{
	public struct Frame
	{
		public float Alpha;

		public float Scale;

		public float OffsetY;

		public float GlowAlpha;

		public float RaysAlpha;

		public float RaysScale;

		public float BeamAlpha;

		public float BeamGrow;

		public float RaysAngle;

		public float NumberScale;

		public float ShineAlpha;

		public float ShineAngle;
	}
	public static class Anim
	{
		public const float RiseEnd = 0.28f;

		public const float SettleEnd = 0.46f;

		public const float FallLength = 0.64f;

		private const float FlashStart = 0.1f;

		private const float FlashEnd = 0.7f;

		private const float FlashPeak = 0.28f;

		private const float StampStart = 0.34f;

		private const float StampEnd = 0.62f;

		private const float ShineStart = 0.3f;

		private const float ShineEnd = 1.1f;

		private const float RaysSpin = 6f;

		public static float Total(float hold)
		{
			return 0.46f + Max(0f, hold) + 0.64f;
		}

		public static Frame At(float t, float hold)
		{
			if (t < 0f)
			{
				t = 0f;
			}
			float num = 0.46f + Max(0f, hold);
			float num2 = num + 0.64f;
			Frame result = new Frame
			{
				Alpha = 1f,
				Scale = 1f,
				OffsetY = 0f,
				NumberScale = 1f,
				RaysScale = 1f,
				RaysAngle = t * 6f
			};
			if (t < 0.28f)
			{
				float t2 = (result.Alpha = EaseOutCubic(t / 0.28f));
				result.OffsetY = Lerp(34f, 0f, t2);
				result.Scale = Lerp(0.82f, 1.06f, t2);
			}
			else if (t < 0.46f)
			{
				float t3 = EaseOutCubic((t - 0.28f) / 0.18f);
				result.Scale = Lerp(1.06f, 1f, t3);
			}
			if (t >= num)
			{
				float num3 = Clamp01((t - num) / 0.64f);
				result.Alpha = 1f - EaseInQuad(num3);
				result.OffsetY = Lerp(0f, -18f, EaseInOutSine(num3));
				result.Scale = Lerp(1f, 0.97f, num3);
			}
			if (t >= num2)
			{
				result.Alpha = 0f;
			}
			float u = Window(t, 0.1f, 0.7f);
			result.GlowAlpha = Spike(u, 0.28f) * 0.42f;
			result.RaysAlpha = Spike(u, 0.28f) * 0.3f;
			if (t > 0.1f)
			{
				result.GlowAlpha = Max(result.GlowAlpha, 0.1f * Clamp01((t - 0.1f) / 0.2f));
				result.RaysAlpha = Max(result.RaysAlpha, 0.12f * Clamp01((t - 0.1f) / 0.2f));
			}
			result.RaysScale = Lerp(0.6f, 1f, EaseOutBack(Window(t, 0.1f, 0.85f)));
			float u2 = Window(t, 0f, 0.55f);
			result.BeamGrow = EaseOutCubic(u2);
			float a = Spike(u2, 0.3f) * 0.55f;
			float b = 0.16f * Clamp01(1f - Window(t, 0.55f, 1.3f));
			result.BeamAlpha = Max(a, b);
			result.GlowAlpha *= result.Alpha;
			result.RaysAlpha *= result.Alpha;
			result.BeamAlpha *= result.Alpha;
			if (t < 0.34f)
			{
				result.NumberScale = 1.55f;
			}
			else if (t < 0.62f)
			{
				result.NumberScale = Lerp(1.55f, 1f, EaseOutCubic((t - 0.34f) / 0.28f));
			}
			float num4 = Window(t, 0.3f, 1.1f);
			result.ShineAngle = num4 * 360f;
			result.ShineAlpha = ((t <= 0.3f || t >= 1.1f) ? 0f : ((float)Math.Sin(Math.PI * (double)num4) * 0.5f * result.Alpha));
			return result;
		}

		public static float EaseOutCubic(float u)
		{
			u = Clamp01(u);
			float num = 1f - u;
			return 1f - num * num * num;
		}

		public static float EaseInQuad(float u)
		{
			u = Clamp01(u);
			return u * u;
		}

		public static float EaseOutQuad(float u)
		{
			u = Clamp01(u);
			return 1f - (1f - u) * (1f - u);
		}

		public static float EaseInOutSine(float u)
		{
			u = Clamp01(u);
			return 0.5f - 0.5f * (float)Math.Cos(Math.PI * (double)u);
		}

		public static float EaseOutBack(float u)
		{
			u = Clamp01(u);
			float num = u - 1f;
			return 1f + 2.70158f * num * num * num + 1.70158f * num * num;
		}

		public static float Spike(float u, float peak)
		{
			if (u <= 0f || u >= 1f)
			{
				return 0f;
			}
			if (!(u < peak))
			{
				return 1f - EaseInQuad((u - peak) / (1f - peak));
			}
			return EaseOutQuad(u / peak);
		}

		private static float Window(float t, float from, float to)
		{
			if (to <= from)
			{
				if (!(t >= to))
				{
					return 0f;
				}
				return 1f;
			}
			return Clamp01((t - from) / (to - from));
		}

		private static float Clamp01(float v)
		{
			if (!(v < 0f))
			{
				if (!(v > 1f))
				{
					return v;
				}
				return 1f;
			}
			return 0f;
		}

		private static float Lerp(float a, float b, float t)
		{
			return a + (b - a) * t;
		}

		private static float Max(float a, float b)
		{
			if (!(a > b))
			{
				return b;
			}
			return a;
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Commands
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__2_0;

			public static ConsoleEvent <>9__2_1;

			public static ConsoleEvent <>9__2_2;

			internal void <Register>b__2_0(ConsoleEventArgs args)
			{
				try
				{
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString(Report());
					}
				}
				catch (Exception ex)
				{
					Safety.Failed("frami", ex);
				}
			}

			internal void <Register>b__2_1(ConsoleEventArgs args)
			{
				try
				{
					Test(args);
				}
				catch (Exception ex)
				{
					Safety.Failed("frami_test", ex);
				}
			}

			internal void <Register>b__2_2(ConsoleEventArgs args)
			{
				try
				{
					Levelups.Clear();
					Popup.Teardown();
					FlareSprites.Reset();
					SkillName.Clear();
					Terminal context = args.Context;
					if (context != null)
					{
						context.AddString("Frami: rebuilt. The next level-up uses the new settings.");
					}
				}
				catch (Exception ex)
				{
					Safety.Failed("frami_reload", ex);
				}
			}
		}

		private static bool _registered;

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

		private static void Register()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_006c: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					try
					{
						Terminal context = args.Context;
						if (context != null)
						{
							context.AddString(Report());
						}
					}
					catch (Exception ex)
					{
						Safety.Failed("frami", ex);
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("frami", "frami - say whether the skill popup is working, and what it is set to.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				ConsoleEvent val2 = delegate(ConsoleEventArgs args)
				{
					try
					{
						Test(args);
					}
					catch (Exception ex)
					{
						Safety.Failed("frami_test", ex);
					}
				};
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			new ConsoleCommand("frami_test", "frami_test [skill] [level] - play the popup for a skill without levelling it. Changes nothing about your character.", (ConsoleEvent)obj2, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			object obj3 = <>c.<>9__2_2;
			if (obj3 == null)
			{
				ConsoleEvent val3 = delegate(ConsoleEventArgs args)
				{
					try
					{
						Levelups.Clear();
						Popup.Teardown();
						FlareSprites.Reset();
						SkillName.Clear();
						Terminal context = args.Context;
						if (context != null)
						{
							context.AddString("Frami: rebuilt. The next level-up uses the new settings.");
						}
					}
					catch (Exception ex)
					{
						Safety.Failed("frami_reload", ex);
					}
				};
				<>c.<>9__2_2 = val3;
				obj3 = (object)val3;
			}
			new ConsoleCommand("frami_reload", "frami_reload - rebuild the popup from the current settings. Use after editing the config file by hand.", (ConsoleEvent)obj3, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		private static string Report()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("Frami ").Append("0.1.0").AppendLine();
			if (!FramiPlugin.Enabled.Value)
			{
				stringBuilder.AppendLine("  Off. The game is showing its own message in the top left.");
				return stringBuilder.ToString().TrimEnd();
			}
			stringBuilder.Append("  Popup: ").AppendLine(Popup.Ready ? "ready" : "NOT ready - the game's HUD is not where Frami expects it, so level-ups are being left alone entirely.");
			stringBuilder.Append("  Vanilla message: ").AppendLine(FramiPlugin.SuppressVanillaMessage.Value ? "hidden" : "also shown");
			stringBuilder.Append("  Showing: ");
			int value = FramiPlugin.MinimumLevel.Value;
			int num = Mathf.Max(1, FramiPlugin.Every.Value);
			stringBuilder.Append((num == 1) ? "every level" : ("every " + num + " levels"));
			if (value > 1)
			{
				stringBuilder.Append(" from level ").Append(value);
			}
			string text = (FramiPlugin.SkillFilter.Value ?? string.Empty).Trim();
			stringBuilder.AppendLine((text.Length == 0) ? ", all skills" : (", only " + text));
			stringBuilder.Append("  Timing: ").Append(FramiPlugin.HoldSeconds.Value.ToString("0.0", CultureInfo.InvariantCulture)).Append("s hold, ")
				.Append(FramiPlugin.GapSeconds.Value.ToString("0.00", CultureInfo.InvariantCulture))
				.AppendLine("s between");
			stringBuilder.Append("  Waiting: ").Append(Levelups.Waiting).AppendLine();
			if (Levelups.Waiting == 0 && !Popup.Alive)
			{
				stringBuilder.AppendLine("  Nothing queued. Try frami_test sneak 42.");
			}
			return stringBuilder.ToString().TrimEnd();
		}

		private static void Test(ConsoleEventArgs args)
		{
			//IL_0087: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length < 2)
			{
				Terminal context = args.Context;
				if (context != null)
				{
					context.AddString("Frami: frami_test [skill] [level], for example frami_test sneak 42.");
				}
				return;
			}
			if (!Resolve(args[1], out var skill))
			{
				Terminal context2 = args.Context;
				if (context2 != null)
				{
					context2.AddString("Frami: no skill called '" + args[1] + "'. " + Names());
				}
				return;
			}
			int level = 42;
			if (args.Length >= 3 && int.TryParse(args[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				level = Mathf.Clamp(result, 1, 100);
			}
			Levelups.Force(skill, IconFor(skill), level);
			Terminal context3 = args.Context;
			if (context3 != null)
			{
				context3.AddString("Frami: showing " + SkillName.Of(skill) + " " + level + ".");
			}
		}

		private static bool Resolve(string name, out SkillType skill)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected I4, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected I4, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_00b3: 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)
			skill = (SkillType)0;
			if (string.IsNullOrEmpty(name))
			{
				return false;
			}
			string[] names = Enum.GetNames(typeof(SkillType));
			foreach (string text in names)
			{
				if (string.Equals(text, name, StringComparison.OrdinalIgnoreCase))
				{
					skill = (SkillType)(int)(SkillType)Enum.Parse(typeof(SkillType), text);
					if (skill)
					{
						return (int)skill != 999;
					}
					return false;
				}
			}
			SkillType val = (SkillType)0;
			int num = 0;
			names = Enum.GetNames(typeof(SkillType));
			foreach (string text2 in names)
			{
				if (text2.StartsWith(name, StringComparison.OrdinalIgnoreCase))
				{
					SkillType val2 = (SkillType)Enum.Parse(typeof(SkillType), text2);
					if ((int)val2 != 0 && (int)val2 != 999)
					{
						val = val2;
						num++;
					}
				}
			}
			if (num != 1)
			{
				return false;
			}
			skill = (SkillType)(int)val;
			return true;
		}

		private static string Names()
		{
			StringBuilder stringBuilder = new StringBuilder("Try one of: ");
			bool flag = true;
			string[] names = Enum.GetNames(typeof(SkillType));
			foreach (string text in names)
			{
				if (!(text == "None") && !(text == "All"))
				{
					if (!flag)
					{
						stringBuilder.Append(", ");
					}
					stringBuilder.Append(text);
					flag = false;
				}
			}
			return stringBuilder.Append('.').ToString();
		}

		private static Sprite IconFor(SkillType skill)
		{
			//IL_005f: 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)
			try
			{
				Skills val = (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Character)Player.m_localPlayer).GetSkills() : null);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				List<Skill> skillList = val.GetSkillList();
				if (skillList == null)
				{
					return null;
				}
				foreach (Skill item in skillList)
				{
					if (item?.m_info != null && item.m_info.m_skill == skill)
					{
						return item.m_info.m_icon;
					}
				}
				return null;
			}
			catch (Exception ex)
			{
				Safety.Failed("Commands.IconFor", ex);
				return null;
			}
		}
	}
	public enum FlareGlyph
	{
		Ring,
		Rays,
		Glow,
		Beam,
		Shine,
		Veil,
		Rule
	}
	public static class FlareArt
	{
		private const float RingRadius = 0.845f;

		private const float RingWall = 0.1f;

		private const int Rivets = 12;

		private const float RivetRadius = 0.052f;

		private static void Ring(float x, float y, float aa, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = (float)Math.Sqrt(x * x + y * y);
			float d = Abs(num - 0.845f) - 0.1f;
			float d2 = Abs(Dist(x + aa * 1.6f, y - aa * 1.6f) - 0.845f) - 0.1f;
			Add(ref rr, ref gg, ref bb, ref aOut, 0.02f, 0.02f, 0.02f, Coverage(d2, aa) * 0.55f);
			float num2 = Coverage(d, aa);
			if (!(num2 <= 0f))
			{
				float num3 = Clamp((num - 0.845f) / 0.1f, -1f, 1f);
				float num4 = (float)Math.Sqrt(Max(0f, 1f - num3 * num3));
				float num5 = ((num > 1E-05f) ? (x / num) : 0f);
				float num6 = ((num > 1E-05f) ? (y / num) : 1f);
				float num7 = num5 * num3;
				float num8 = num6 * num3;
				float num9 = num4;
				float num10 = (float)Math.Atan2(y, x);
				float num11 = MathF.PI / 6f;
				float num12 = (float)Math.Round(num10 / num11) * num11;
				float num13 = (float)Math.Cos(num12) * 0.845f;
				float num14 = (float)Math.Sin(num12) * 0.845f;
				float num15 = Dist(x - num13, y - num14);
				if (num15 < 0.052f)
				{
					float num16 = num15 / 0.052f;
					float b = (float)Math.Sqrt(Max(0f, 1f - num16 * num16));
					float num17 = ((num15 > 1E-05f) ? ((x - num13) / num15) : 0f);
					float num18 = ((num15 > 1E-05f) ? ((y - num14) / num15) : 0f);
					float t = 1f - num16 * num16;
					num7 = Lerp(num7, num17 * num16, t);
					num8 = Lerp(num8, num18 * num16, t);
					num9 = Lerp(num9, b, t);
				}
				float num19 = (float)Math.Sqrt(num7 * num7 + num8 * num8 + num9 * num9);
				if (num19 > 1E-05f)
				{
					num7 /= num19;
					num8 /= num19;
					num9 /= num19;
				}
				float num20 = Clamp01(num7 * -0.502f + num8 * 0.623f + num9 * 0.6f);
				float num21 = 0.3f + 0.85f * num20;
				float num22 = Pow(num20, 10f) * 0.5f;
				float r = Clamp01(cr * num21 + num22);
				float g = Clamp01(cg * num21 + num22);
				float b2 = Clamp01(cb * num21 + num22);
				Add(ref rr, ref gg, ref bb, ref aOut, r, g, b2, num2);
				float d3 = Abs(num - 0.94500005f) - aa * 0.55f;
				Add(ref rr, ref gg, ref bb, ref aOut, 0.03f, 0.025f, 0.02f, Coverage(d3, aa) * 0.42f);
			}
		}

		private static void Rays(float x, float y, float aa, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = Dist(x, y);
			if (num < 0.3f || num > 1f)
			{
				return;
			}
			float num2 = MathF.PI / 8f;
			float num3 = (float)Math.Atan2(y, x);
			long num4 = (long)Math.Round(num3 / num2);
			float num5 = (float)num4 * num2;
			float num6 = Abs(WrapPi(num3 - num5)) * num;
			float num7 = (((num4 & 1) == 0L) ? 1f : 0.72f);
			float num8 = (num - 0.3f) / (num7 - 0.3f);
			if (!(num8 < 0f) && !(num8 > 1f))
			{
				float num9 = Lerp(0.07f, 0.01f, num8);
				float num10 = Coverage(num6 - num9, aa);
				if (!(num10 <= 0f))
				{
					float num11 = Pow(1f - num8, 1.4f) * Clamp01(num8 / 0.1f);
					Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, num10 * num11);
				}
			}
		}

		private static void Glow(float x, float y, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float a = Pow(Clamp01(1f - Dist(x, y)), 2.4f);
			Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, a);
		}

		private static void Beam(float x, float y, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = Pow(Clamp01(1f - Abs(x) / 0.13f), 1.6f);
			float num2 = Pow(Clamp01(1f - Abs(x) / 0.44f), 2.6f) * 0.45f;
			float num3 = Clamp01(num + num2);
			if (!(num3 <= 0f))
			{
				float num4 = ((y >= 0f) ? Clamp01(1f - y) : Clamp01(1f + y / 0.7f));
				num4 = num4 * num4 * (3f - 2f * num4);
				Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, num3 * num4);
			}
		}

		private static void Shine(float x, float y, float aa, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = Coverage(Abs(Dist(x, y) - 0.845f) - 0.120000005f, aa);
			if (!(num <= 0f))
			{
				float num2 = Abs(WrapPi((float)Math.Atan2(y, x) - MathF.PI / 2f));
				float num3 = Clamp01(1f - num2 / 0.44f);
				num3 = num3 * num3 * (3f - 2f * num3);
				Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, num * num3);
			}
		}

		private static void Veil(float x, float y, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = Clamp01((1.02f - Dist(x, y)) / 0.62f);
			float a = num * num * (3f - 2f * num);
			Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, a);
		}

		private static void Rule(float x, float y, float aa, float cr, float cg, float cb, ref float rr, ref float gg, ref float bb, ref float aOut)
		{
			float num = Clamp01((1f - Abs(x)) / 0.22f);
			num = num * num * (3f - 2f * num);
			if (!(num <= 0f))
			{
				float num2 = Coverage(Abs(y + 0.55f) - 0.22f, aa);
				Add(ref rr, ref gg, ref bb, ref aOut, 0.03f, 0.025f, 0.02f, num2 * 0.55f * num);
				float num3 = Coverage(Abs(y - 0.1f) - 0.28f, aa);
				Add(ref rr, ref gg, ref bb, ref aOut, cr, cg, cb, num3 * num);
			}
		}

		public static void Render(int w, int h, FlareGlyph glyph, float cr, float cg, float cb, float[] rgba)
		{
			if (rgba == null || rgba.Length < w * h * 4)
			{
				throw new ArgumentException("rgba buffer is too small for " + w + "x" + h + ".");
			}
			float num = (float)w * 0.5f;
			float num2 = (float)h * 0.5f;
			float aa = 2f / Min(w, h);
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					float x = ((float)j + 0.5f - num) / num;
					float y = ((float)i + 0.5f - num2) / num2;
					float rr = 0f;
					float gg = 0f;
					float bb = 0f;
					float aOut = 0f;
					switch (glyph)
					{
					case FlareGlyph.Ring:
						Ring(x, y, aa, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Rays:
						Rays(x, y, aa, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Glow:
						Glow(x, y, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Beam:
						Beam(x, y, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Shine:
						Shine(x, y, aa, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Veil:
						Veil(x, y, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					case FlareGlyph.Rule:
						Rule(x, y, aa, cr, cg, cb, ref rr, ref gg, ref bb, ref aOut);
						break;
					}
					int num3 = (i * w + j) * 4;
					rgba[num3] = rr;
					rgba[num3 + 1] = gg;
					rgba[num3 + 2] = bb;
					rgba[num3 + 3] = aOut;
				}
			}
		}

		public static void SizeOf(FlareGlyph glyph, out int w, out int h)
		{
			switch (glyph)
			{
			case FlareGlyph.Rule:
				w = 96;
				h = 12;
				break;
			case FlareGlyph.Veil:
				w = 192;
				h = 192;
				break;
			case FlareGlyph.Beam:
				w = 128;
				h = 320;
				break;
			default:
				w = 256;
				h = 256;
				break;
			}
		}

		public static float Coverage(float d, float aa)
		{
			if (aa <= 0f)
			{
				if (!(d <= 0f))
				{
					return 0f;
				}
				return 1f;
			}
			return Clamp01(0.5f - d / aa);
		}

		private static void Add(ref float rr, ref float gg, ref float bb, ref float aa, float r, float g, float b, float a)
		{
			if (!(a <= 0f))
			{
				if (a > 1f)
				{
					a = 1f;
				}
				float num = a + aa * (1f - a);
				if (!(num <= 0f))
				{
					rr = (r * a + rr * aa * (1f - a)) / num;
					gg = (g * a + gg * aa * (1f - a)) / num;
					bb = (b * a + bb * aa * (1f - a)) / num;
					aa = num;
				}
			}
		}

		private static float WrapPi(float a)
		{
			while (a > MathF.PI)
			{
				a -= MathF.PI * 2f;
			}
			while (a < -MathF.PI)
			{
				a += MathF.PI * 2f;
			}
			return a;
		}

		private static float Dist(float x, float y)
		{
			return (float)Math.Sqrt(x * x + y * y);
		}

		private static float Pow(float v, float p)
		{
			return (float)Math.Pow(v, p);
		}

		private static float Abs(float v)
		{
			if (!(v < 0f))
			{
				return v;
			}
			return 0f - v;
		}

		private static float Min(float a, float b)
		{
			if (!(a < b))
			{
				return b;
			}
			return a;
		}

		private static float Max(float a, float b)
		{
			if (!(a > b))
			{
				return b;
			}
			return a;
		}

		private static float Clamp01(float v)
		{
			if (!(v < 0f))
			{
				if (!(v > 1f))
				{
					return v;
				}
				return 1f;
			}
			return 0f;
		}

		private static float Clamp(float v, float lo, float hi)
		{
			if (!(v < lo))
			{
				if (!(v > hi))
				{
					return v;
				}
				return hi;
			}
			return lo;
		}

		private static float Lerp(float a, float b, float t)
		{
			return a + (b - a) * t;
		}
	}
	internal static class FlareSprites
	{
		private static readonly Dictionary<FlareGlyph, Sprite> Cache = new Dictionary<FlareGlyph, Sprite>();

		public static Sprite For(FlareGlyph glyph)
		{
			if (Cache.TryGetValue(glyph, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Sprite val = Build(glyph);
			Cache[glyph] = val;
			return val;
		}

		public static void Reset()
		{
			foreach (Sprite value in Cache.Values)
			{
				if (!((Object)(object)value == (Object)null))
				{
					if ((Object)(object)value.texture != (Object)null)
					{
						Object.Destroy((Object)(object)value.texture);
					}
					Object.Destroy((Object)(object)value);
				}
			}
			Cache.Clear();
		}

		private static Color ColourOf(FlareGlyph glyph)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			switch (glyph)
			{
			case FlareGlyph.Ring:
			case FlareGlyph.Rule:
				return Theme.Brass;
			case FlareGlyph.Veil:
				return Theme.StoneDeep;
			default:
				return Color.white;
			}
		}

		private static Sprite Build(FlareGlyph glyph)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_003b: 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_005d: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00a4: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				FlareArt.SizeOf(glyph, out var w, out var h);
				Color val = ColourOf(glyph);
				float[] array = new float[w * h * 4];
				FlareArt.Render(w, h, glyph, val.r, val.g, val.b, array);
				Texture2D val2 = new Texture2D(w, h, (TextureFormat)5, false)
				{
					name = "FramiFlare" + glyph,
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1,
					hideFlags = (HideFlags)61
				};
				Color[] array2 = (Color[])(object)new Color[w * h];
				for (int i = 0; i < array2.Length; i++)
				{
					int num = i * 4;
					array2[i] = new Color(array[num], array[num + 1], array[num + 2], array[num + 3]);
				}
				val2.SetPixels(array2);
				val2.Apply(false);
				Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)w, (float)h), new Vector2(0.5f, 0.5f), 100f);
				((Object)obj).hideFlags = (HideFlags)61;
				return obj;
			}
			catch (Exception ex)
			{
				Safety.Failed("FlareSprites.Build(" + glyph.ToString() + ")", ex);
				return null;
			}
		}
	}
	internal static class Gate
	{
		private static int _armFrame = -1;

		private static bool _armLocal;

		private static SkillType _armSkill;

		private const int MaxExpected = 8;

		private static int _expectFrame = -1;

		private static readonly Sprite[] Expected = (Sprite[])(object)new Sprite[8];

		private static readonly bool[] Used = new bool[8];

		private static int _expectCount;

		private static MethodInfo _addLog;

		private static bool _addLogResolved;

		public static bool Armed
		{
			get
			{
				if (_armFrame == Time.frameCount)
				{
					return _armLocal;
				}
				return false;
			}
		}

		public static SkillType ArmedSkill => _armSkill;

		public static void Arm(Skills skills, SkillType type)
		{
			//IL_000a: 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)
			_armFrame = Time.frameCount;
			_armSkill = type;
			_armLocal = IsLocal(skills);
		}

		public static void Disarm()
		{
			_armFrame = -1;
			_armLocal = false;
		}

		private static bool IsLocal(Skills skills)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)skills == (Object)null)
			{
				return false;
			}
			return skills == ((Character)localPlayer).GetSkills();
		}

		public static void Expect(Sprite icon)
		{
			int frameCount = Time.frameCount;
			if (_expectFrame != frameCount)
			{
				_expectFrame = frameCount;
				_expectCount = 0;
			}
			if (_expectCount < 8)
			{
				Expected[_expectCount] = icon;
				Used[_expectCount] = false;
				_expectCount++;
			}
		}

		public unsafe static bool ShouldSwallow(MessageType type, string text, Sprite icon)
		{
			if (FramiPlugin.Enabled == null || !FramiPlugin.Enabled.Value)
			{
				return false;
			}
			if (!FramiPlugin.SuppressVanillaMessage.Value)
			{
				return false;
			}
			if (_expectCount <= 0)
			{
				return false;
			}
			if (_expectFrame != Time.frameCount)
			{
				_expectCount = 0;
				return false;
			}
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			if (!text.StartsWith("$msg_skillup", StringComparison.Ordinal))
			{
				return false;
			}
			for (int i = 0; i < _expectCount; i++)
			{
				if (!Used[i] && Expected[i] == icon)
				{
					Used[i] = true;
					MirrorToLog(text);
					Safety.Trace("hid the vanilla " + ((object)(*(MessageType*)(&type))/*cast due to .constrained prefix*/).ToString() + " message for " + text);
					return true;
				}
			}
			return false;
		}

		private static void MirrorToLog(string text)
		{
			try
			{
				if (!FramiPlugin.KeepMessageLog.Value || Hud.IsUserHidden())
				{
					return;
				}
				if (!_addLogResolved)
				{
					_addLogResolved = true;
					_addLog = AccessTools.Method(typeof(MessageHud), "AddLog", (Type[])null, (Type[])null);
					if (_addLog == null)
					{
						Safety.Warn("Gate.MirrorToLog.missing", "MessageHud.AddLog is not where it used to be, so skill-ups will not appear in the message log. Everything else still works.");
					}
				}
				if (!(_addLog == null) && !((Object)(object)MessageHud.instance == (Object)null))
				{
					string text2 = ((Localization.instance != null) ? Localization.instance.Localize(text) : text);
					_addLog.Invoke(MessageHud.instance, new object[1] { text2 });
				}
			}
			catch (Exception ex)
			{
				Safety.Failed("Gate.MirrorToLog", ex);
			}
		}
	}
	public static class Layout
	{
		public const float PopupW = 330f;

		public const float PopupH = 330f;

		public const float MedallionY = 99f;

		public const float MedallionSize = 120f;

		public const float IconSize = 63f;

		public const float ShineSize = 127.2f;

		public const float GlowSize = 240f;

		public const float RaysSize = 285f;

		public const float BeamW = 96f;

		public const float BeamH = 240f;

		public const float RuleW = 225f;

		public const float RuleH = 5f;

		public const float RuleTopY = 23f;

		public const float RuleBottomY = -27f;

		public const float NameY = -2f;

		public const float NumberY = -78f;

		public const float CaptionY = -129f;

		public const float NameFont = 0.86f;

		public const float NumberFont = 1.95f;

		public const float CaptionFont = 0.47f;

		public const float TextMargin = 30f;
	}
	internal static class Levelups
	{
		private struct Pending
		{
			public SkillType Skill;

			public Sprite Icon;

			public int Level;

			public float Stamp;
		}

		private static readonly List<Pending> Queue = new List<Pending>(8);

		private const float StaleAfter = 30f;

		private static float _gap;

		private static string _filterText;

		private static HashSet<SkillType> _filter;

		public static int Waiting => Queue.Count;

		private static bool InWorld()
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)ZNetScene.instance != (Object)null && (Object)(object)Game.instance != (Object)null)
			{
				return (Object)(object)Hud.instance != (Object)null;
			}
			return false;
		}

		public unsafe static void Record(SkillType skill, Sprite icon, int level)
		{
			//IL_00e0: 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_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			if (FramiPlugin.Enabled == null || !FramiPlugin.Enabled.Value || !InWorld())
			{
				return;
			}
			if (level < FramiPlugin.MinimumLevel.Value)
			{
				Safety.Trace("skipped " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + " " + level + ": below MinimumLevel.");
				return;
			}
			int num = Mathf.Max(1, FramiPlugin.Every.Value);
			if (level != 1 && level < 100 && level % num != 0)
			{
				Safety.Trace("skipped " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + " " + level + ": not every " + num + ".");
				return;
			}
			if (!Allowed(skill))
			{
				Safety.Trace("skipped " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + ": not in the Skills list.");
				return;
			}
			if (!Popup.Ready)
			{
				Safety.Trace("skipped " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + ": the popup is not ready, so vanilla stands.");
				return;
			}
			float unscaledTime = Time.unscaledTime;
			for (int i = 0; i < Queue.Count; i++)
			{
				if (Queue[i].Skill == skill)
				{
					Pending value = Queue[i];
					value.Level = level;
					value.Stamp = unscaledTime;
					Queue[i] = value;
					Gate.Expect(icon);
					Safety.Trace("merged " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + " into a waiting popup at level " + level + ".");
					return;
				}
			}
			int num2 = Mathf.Max(1, FramiPlugin.QueueLimit.Value);
			while (Queue.Count >= num2)
			{
				Pending pending = Queue[0];
				Safety.Trace("queue full, dropping " + ((object)(*(SkillType*)(&pending.Skill))/*cast due to .constrained prefix*/).ToString() + ".");
				Queue.RemoveAt(0);
			}
			Queue.Add(new Pending
			{
				Skill = skill,
				Icon = icon,
				Level = level,
				Stamp = unscaledTime
			});
			Gate.Expect(icon);
			Safety.Trace("queued " + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString() + " level " + level + ", " + Queue.Count + " waiting.");
		}

		public unsafe static void Tick()
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			if (FramiPlugin.Enabled == null || !FramiPlugin.Enabled.Value)
			{
				if (Queue.Count > 0)
				{
					Queue.Clear();
				}
				Popup.Teardown();
				return;
			}
			if (!InWorld())
			{
				if (Queue.Count > 0)
				{
					Queue.Clear();
				}
				Popup.Teardown();
				return;
			}
			if (Hud.IsUserHidden() && !FramiPlugin.ShowWhenHudHidden.Value)
			{
				Popup.Cancel();
				return;
			}
			float num = Mathf.Min(Time.unscaledDeltaTime, 0.1f);
			if (Popup.Alive)
			{
				Popup.Tick(num);
				if (!Popup.Alive)
				{
					_gap = Mathf.Max(0f, FramiPlugin.GapSeconds.Value);
				}
			}
			else
			{
				if (Queue.Count == 0)
				{
					return;
				}
				_gap -= num;
				if (!(_gap > 0f))
				{
					Pending pending = Queue[0];
					Queue.RemoveAt(0);
					if (Time.unscaledTime - pending.Stamp > 30f)
					{
						Safety.Trace("dropped a stale " + ((object)(*(SkillType*)(&pending.Skill))/*cast due to .constrained prefix*/).ToString() + " popup.");
					}
					else
					{
						Popup.Show(pending.Skill, pending.Icon, pending.Level);
					}
				}
			}
		}

		public static void Clear()
		{
			Queue.Clear();
			_gap = 0f;
		}

		public static void Force(SkillType skill, Sprite icon, int level)
		{
			//IL_0051: 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)
			if (!Popup.Ready)
			{
				Safety.Warn("Levelups.Force", "the popup is not ready, so there is nothing to show.");
				return;
			}
			int num = Mathf.Max(1, FramiPlugin.QueueLimit.Value);
			while (Queue.Count >= num)
			{
				Queue.RemoveAt(0);
			}
			Queue.Add(new Pending
			{
				Skill = skill,
				Icon = icon,
				Level = level,
				Stamp = Time.unscaledTime
			});
		}

		private static bool Allowed(SkillType skill)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			RebuildFilter();
			if (_filter != null)
			{
				return _filter.Contains(skill);
			}
			return true;
		}

		private static void RebuildFilter()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			string text = FramiPlugin.SkillFilter.Value ?? string.Empty;
			if (string.Equals(text, _filterText, StringComparison.Ordinal))
			{
				return;
			}
			_filterText = text;
			if (string.IsNullOrEmpty(text.Trim()))
			{
				_filter = null;
				return;
			}
			HashSet<SkillType> hashSet = new HashSet<SkillType>();
			string[] names = Enum.GetNames(typeof(SkillType));
			string[] array = text.Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length == 0)
				{
					continue;
				}
				bool flag = false;
				string[] array2 = names;
				foreach (string text3 in array2)
				{
					if (string.Equals(text3, text2, StringComparison.OrdinalIgnoreCase))
					{
						hashSet.Add((SkillType)Enum.Parse(typeof(SkillType), text3));
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					ManualLogSource log = FramiPlugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("Frami: no skill called '" + text2 + "', so it is being ignored. The names are the ones the console's raiseskill command uses."));
					}
				}
			}
			_filter = ((hashSet.Count > 0) ? hashSet : null);
		}
	}
	internal static class Patches
	{
		[HarmonyPatch(typeof(Skills), "RaiseSkill")]
		internal static class SkillsRaiseSkill
		{
			[HarmonyPrefix]
			private static void Prefix(Skills __instance, SkillType skillType)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					Gate.Arm(__instance, skillType);
				}
				catch (Exception ex)
				{
					Safety.Failed("Skills.RaiseSkill prefix", ex);
				}
			}

			[HarmonyFinalizer]
			private static Exception Finalizer(Exception __exception)
			{
				try
				{
					Gate.Disarm();
				}
				catch
				{
				}
				return __exception;
			}
		}

		[HarmonyPatch(typeof(MessageHud), "ShowMessage")]
		internal static class MessageHudShowMessage
		{
			[HarmonyPrefix]
			[HarmonyPriority(200)]
			private static bool Prefix(MessageType type, string text, Sprite icon)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					return !Gate.ShouldSwallow(type, text, icon);
				}
				catch (Exception ex)
				{
					Safety.Failed("MessageHud.ShowMessage prefix", ex);
					return true;
				}
			}
		}

		[HarmonyPatch(typeof(Localization), "SetLanguage")]
		internal static class LocalizationSetLanguage
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				try
				{
					SkillName.Clear();
				}
				catch (Exception ex)
				{
					Safety.Failed("Localization.SetLanguage", ex);
				}
			}
		}

		public static void ApplyManual(Harmony harmony)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Skill), "Raise", (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					ManualLogSource log = FramiPlugin.Log;
					if (log != null)
					{
						log.LogError((object)"Frami: Skills.Skill.Raise is not where it used to be, so no skill level-up can be detected and Frami will do nothing at all. The game keeps its own messages. This needs a new version of Frami.");
					}
				}
				else
				{
					MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(Patches), "SkillRaisePostfix", (Type[])null, (Type[])null);
					harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				Safety.Failed("Patches.ApplyManual", ex);
			}
		}

		private static void SkillRaisePostfix(Skill __instance, bool __result)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (__result && Gate.Armed && __instance != null && __instance.m_info != null)
				{
					Levelups.Record(Gate.ArmedSkill, __instance.m_info.m_icon, (int)__instance.m_level);
				}
			}
			catch (Exception ex)
			{
				Safety.Failed("Skills.Skill.Raise", ex);
			}
		}
	}
	[BepInPlugin("gbv.valheim.frami", "Frami", "0.1.0")]
	public class FramiPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "gbv.valheim.frami";

		public const string PluginName = "Frami";

		public const string PluginVersion = "0.1.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> SuppressVanillaMessage;

		internal static ConfigEntry<bool> KeepMessageLog;

		internal static ConfigEntry<int> MinimumLevel;

		internal static ConfigEntry<int> Every;

		internal static ConfigEntry<string> SkillFilter;

		internal static ConfigEntry<bool> ShowWhenHudHidden;

		internal static ConfigEntry<float> Scale;

		internal static ConfigEntry<float> VerticalPosition;

		internal static ConfigEntry<float> OffsetX;

		internal static ConfigEntry<float> OffsetY;

		internal static ConfigEntry<float> Backdrop;

		internal static ConfigEntry<bool> Rays;

		internal static ConfigEntry<float> HoldSeconds;

		internal static ConfigEntry<float> GapSeconds;

		internal static ConfigEntry<int> QueueLimit;

		internal static ConfigEntry<bool> ExtraSfx;

		internal static ConfigEntry<bool> VerboseLog;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace Valheim's skill level-up notice with a popup in the middle of the screen. Turned off, the game keeps its own small message in the top left and nothing else in this mod runs.");
			SuppressVanillaMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SuppressVanillaMessage", true, "Hide the game's own skill-up line while the popup is up. Turned off you get both: the popup in the middle and Valheim's message in the corner. They do not overlap either way.");
			KeepMessageLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "KeepMessageLog", true, "Keep the skill-up line in the message log you can read from the inventory, even when the on-screen message is hidden. There is no good reason to turn this off; it exists so there is somewhere to turn it off if it ever misbehaves.");
			MinimumLevel = ((BaseUnityPlugin)this).Config.Bind<int>("When", "MinimumLevel", 1, "Only celebrate levels at or above this. 1 shows every level. Raise it if the first few levels of a fresh skill feel noisy. Levels below it are not lost, they get the game's own small message in the corner instead.");
			Every = ((BaseUnityPlugin)this).Config.Bind<int>("When", "Every", 1, "Show one level in every so many. 1 shows all of them; 5 shows 5, 10, 15 and so on. The levels in between still get the game's own small message in the corner, so nothing goes unannounced. Level 1 and level 100 always get the popup whatever this is set to.");
			SkillFilter = ((BaseUnityPlugin)this).Config.Bind<string>("When", "Skills", "", "A comma-separated list of skills to celebrate, for example Swords,Bows,Sneak. Leave it empty for all of them. Anything unrecognised is ignored and noted in the log.");
			ShowWhenHudHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("When", "ShowWhenHudHidden", false, "Show the popup even with the HUD hidden on Ctrl+F. Off, so a popup never lands in the middle of a screenshot. It is held rather than thrown away: bring the HUD back within half a minute and it plays then.");
			Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Scale", 1f, "Overall size, where 1 is the size it was designed at. Anything outside half to double is clamped.");
			VerticalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "VerticalPosition", 0.17f, "Where the popup sits, as a fraction of the screen height above the middle. 0 is dead centre, 0.17 puts it above the crosshair, and a negative number moves it below. Measured against the game's own HUD scaling, so it lands in the same place on any resolution.");
			OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "OffsetX", 0f, "Nudge the popup sideways afterwards, in the HUD's own units.");
			OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "OffsetY", 0f, "Nudge the popup up or down afterwards, in the HUD's own units.");
			Backdrop = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Backdrop", 0.55f, "How dark the veil behind the popup gets, from 0 for none to 1. The veil is what keeps the level readable over snow or a lit fire.");
			Rays = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "Rays", true, "Draw the starburst behind the medallion. Off leaves the ring, the icon and the text, which is a quieter popup rather than a plain one.");
			HoldSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "HoldSeconds", 3f, "How long the popup stays fully up, between the flourish in and the fade out. The entrance and exit are about a second between them and are not affected by this.");
			GapSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "GapSeconds", 0.45f, "The pause between one popup finishing and the next starting, when several skills level at once.");
			QueueLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Timing", "QueueLimit", 6, "How many pending popups to hold. Level a dozen skills in one breath and the oldest are dropped rather than queued for half a minute.");
			ExtraSfx = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "ExtraSfx", false, "Play an extra fanfare on top of the level-up sound the game already makes. Off, because the game already plays one and two at once is worse than either.");
			VerboseLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLog", false, "Write every level-up, every hidden message and every queue decision to the log. For working out why a popup did not appear.");
			_harmony = new Harmony("gbv.valheim.frami");
			_harmony.PatchAll(typeof(FramiPlugin).Assembly);
			Patches.ApplyManual(_harmony);
			Log.LogInfo((object)"Frami 0.1.0 loaded.");
		}

		private void Update()
		{
			try
			{
				Levelups.Tick();
			}
			catch (Exception ex)
			{
				Safety.Failed("FramiPlugin.Update", ex);
			}
		}

		private void OnDestroy()
		{
			try
			{
				Popup.Teardown();
				FlareSprites.Reset();
			}
			catch (Exception ex)
			{
				Safety.Failed("FramiPlugin.OnDestroy", ex);
			}
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		internal static float ClampedScale()
		{
			return Mathf.Clamp((Scale != null) ? Scale.Value : 1f, 0.5f, 2f);
		}
	}
	internal static class Popup
	{
		private static readonly Vector2 OffScreen = new Vector2(-30000f, 0f);

		private const float MaxLevelBonus = 1.5f;

		private static GameObject _root;

		private static RectTransform _rootRt;

		private static CanvasGroup _group;

		private static Image _veil;

		private static Image _beam;

		private static Image _glow;

		private static Image _rays;

		private static Image _ring;

		private static Image _icon;

		private static Image _shine;

		private static RectTransform _beamRt;

		private static RectTransform _raysRt;

		private static RectTransform _shineRt;

		private static RectTransform _numberRt;

		private static TMP_Text _nameText;

		private static TMP_Text _numberText;

		private static TMP_Text _captionText;

		private static bool _alive;

		private static float _t;

		private static float _hold;

		private static float _wroteGroup = -1f;

		private static float _wroteBeam = -1f;

		private static float _wroteGlow = -1f;

		private static float _wroteRays = -1f;

		private static float _wroteShine = -1f;

		private static Vector2 _wrotePos = OffScreen;

		private static float _wroteScale = -1f;

		private static float _wroteNumber = -1f;

		private static float _wroteBeamH = -1f;

		private static bool _warnedNoHud;

		private const float AlphaEpsilon = 0.003921569f;

		public static bool Alive => _alive;

		public static bool Ready
		{
			get
			{
				try
				{
					if ((Object)(object)Hud.instance == (Object)null || (Object)(object)Hud.instance.m_rootObject == (Object)null)
					{
						return false;
					}
					if ((Object)(object)MessageHud.instance == (Object)null)
					{
						return false;
					}
					if ((Object)(object)MessageHud.instance.m_messageCenterText == (Object)null)
					{
						Safety.Warn("Popup.Ready.noCentreText", "the game's centre message text is missing, so there is no font to borrow and Frami will leave skill messages alone. Another mod has probably replaced the HUD.");
						return false;
					}
					return (Object)(object)FlareSprites.For(FlareGlyph.Ring) != (Object)null;
				}
				catch (Exception ex)
				{
					Safety.Failed("Popup.Ready", ex);
					return false;
				}
			}
		}

		public unsafe static void Show(SkillType skill, Sprite icon, int level)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!EnsureRoot())
				{
					return;
				}
				bool flag = level >= 100;
				_nameText.text = SkillName.Of(skill);
				_numberText.text = level.ToString();
				_captionText.text = SkillName.Caption();
				((Graphic)_numberText).color = (flag ? Theme.BrassHi : Theme.Brass);
				((Graphic)_ring).color = (Color)(flag ? new Color(1.3f, 1.25f, 1.15f, 1f) : Color.white);
				if ((Object)(object)icon != (Object)null)
				{
					_icon.sprite = icon;
					float num = IconUnits(icon);
					((Graphic)_icon).rectTransform.sizeDelta = new Vector2(num, num);
					if (!((Component)_icon).gameObject.activeSelf)
					{
						((Component)_icon).gameObject.SetActive(true);
					}
				}
				else if (((Component)_icon).gameObject.activeSelf)
				{
					((Component)_icon).gameObject.SetActive(false);
				}
				bool value = FramiPlugin.Rays.Value;
				if ((Object)(object)_rays != (Object)null && ((Component)_rays).gameObject.activeSelf != value)
				{
					((Component)_rays).gameObject.SetActive(value);
				}
				if ((Object)(object)_veil != (Object)null)
				{
					Color color = ((Graphic)_veil).color;
					color.a = Mathf.Clamp01(FramiPlugin.Backdrop.Value);
					((Graphic)_veil).color = color;
				}
				_hold =