Decompiled source of Skeid v0.5.1

plugins/Skeid.dll

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

[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.5.1.0")]
[assembly: AssemblyInformationalVersion("0.5.1+44db88bccd832defe49fd85839f768855d621b2d")]
[assembly: AssemblyProduct("Skeid")]
[assembly: AssemblyTitle("Skeid")]
[assembly: AssemblyVersion("0.5.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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 Title;

		public static GUIStyle Lead;

		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 BtnSmallOn;

		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_00b7: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: 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_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: 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_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: 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_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Expected O, but got Unknown
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Expected O, but got Unknown
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Expected O, but got Unknown
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Expected O, but got Unknown
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Expected O, but got Unknown
			//IL_0652: 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_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Expected O, but got Unknown
			//IL_0685: Expected O, but got Unknown
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Expected O, but got Unknown
			//IL_06bd: Expected O, but got Unknown
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06da: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Expected O, but got Unknown
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Expected O, but got Unknown
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Expected O, but got Unknown
			//IL_0736: Expected O, but got Unknown
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_0768: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0859: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Expected O, but got Unknown
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0891: Unknown result type (might be due to invalid IL or missing references)
			//IL_089b: Expected O, but got Unknown
			//IL_089b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b6: Expected O, but got Unknown
			//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c5: Expected O, but got Unknown
			//IL_08ca: Expected O, but got Unknown
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08df: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0903: Unknown result type (might be due to invalid IL or missing references)
			//IL_0909: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Unknown result type (might be due to invalid IL or missing references)
			//IL_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0927: Expected O, but got Unknown
			//IL_0927: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_0937: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Expected O, but got Unknown
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0950: Expected O, but got Unknown
			//IL_0955: Expected O, but got Unknown
			//IL_09dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f0: 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(28, (FontStyle)1, TextHi);
				Title = Label(22, (FontStyle)1, TextHi);
				Lead = Label(17, (FontStyle)0, Text);
				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);
				BtnSmallOn = Plate(26, 3, Hex("312B18"), Hex("43391F"), Brass, Hex("3B3320"), Hex("4E4227"), BrassHi, Hex("2A2515"), Hex("352E1A"), BrassHi, TextHi, 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(StoneHi);
				val.hover.textColor = TextHi;
				val.focused.background = Solid(StoneLit);
				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.Skeid
{
	internal static class Assets
	{
		internal static string Override => Path.Combine(Paths.ConfigPath, "Skeid");

		internal static string PluginFolder
		{
			get
			{
				try
				{
					return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				}
				catch
				{
					return null;
				}
			}
		}

		internal static string Find(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			try
			{
				if (Path.IsPathRooted(name))
				{
					return File.Exists(name) ? name : null;
				}
				string text = Path.Combine(Override, name);
				if (File.Exists(text))
				{
					return text;
				}
				string pluginFolder = PluginFolder;
				if (!string.IsNullOrEmpty(pluginFolder))
				{
					string text2 = Path.Combine(pluginFolder, name);
					if (File.Exists(text2))
					{
						return text2;
					}
				}
			}
			catch
			{
			}
			return null;
		}

		internal static void EnsureOverride()
		{
			try
			{
				if (!Directory.Exists(Override))
				{
					Directory.CreateDirectory(Override);
				}
			}
			catch (Exception ex)
			{
				Safety.Once("Assets.EnsureOverride", "could not create " + Override + " (" + ex.Message + "). The shipped car still loads; you just cannot override it from there.");
			}
		}
	}
	internal static class CarKey
	{
		private const float Cooldown = 0.2f;

		private static float _last;

		internal static void Use(Player by, ItemData key)
		{
			if ((Object)(object)by == (Object)null || Time.realtimeSinceStartup - _last < 0.2f)
			{
				return;
			}
			_last = Time.realtimeSinceStartup;
			try
			{
				Act(by, key);
			}
			catch (Exception ex)
			{
				Safety.Failed("CarKey.Use", ex);
			}
		}

		private static void Act(Player by, ItemData key)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			long playerID = by.GetPlayerID();
			Vector3 position = ((Component)by).transform.position;
			CarKeyItem.Kind kind = CarKeyItem.KindOf(key);
			string text = ((kind != null) ? kind.Car : "SK_Skeid");
			List<SkeidCar> list = new List<SkeidCar>();
			List<CarKeyLogic.Candidate> list2 = new List<CarKeyLogic.Candidate>();
			foreach (SkeidCar item in SkeidCar.All())
			{
				if (!((Object)(object)item == (Object)null))
				{
					CarPrefab.Made made = CarPrefab.Of(((Component)item).gameObject);
					if (string.Equals((made?.Spec != null) ? made.Spec.Name : "SK_Skeid", text, StringComparison.Ordinal))
					{
						list.Add(item);
						list2.Add(new CarKeyLogic.Candidate(item.Owner, Vector3.Distance(position, ((Component)item).transform.position)));
					}
				}
			}
			float range = ((SkeidPlugin.KeyRange != null) ? SkeidPlugin.KeyRange.Value : 20f);
			int which;
			switch (CarKeyLogic.Decide(playerID, list2, range, out which))
			{
			case CarKeyLogic.Act.PutAway:
			{
				SkeidCar skeidCar = list[which];
				if (skeidCar.Occupied)
				{
					((Character)by).Message((MessageType)2, "Somebody is in your car", 0, (Sprite)null, false);
				}
				else if (!Cars.Remove(skeidCar))
				{
					((Character)by).Message((MessageType)2, "Could not put the car away", 0, (Sprite)null, false);
				}
				break;
			}
			case CarKeyLogic.Act.BringOut:
				if ((Object)(object)Cars.Spawn(by, Spray.Remembered(key), text) == (Object)null)
				{
					((Character)by).Message((MessageType)2, "Could not bring the car out", 0, (Sprite)null, false);
				}
				break;
			case CarKeyLogic.Act.TooFar:
				break;
			}
		}
	}
	internal static class CarKeyItem
	{
		internal sealed class Kind
		{
			public string Name;

			public string Car;

			public string Title;

			public string Icon;

			public string Description;

			public GameObject Prefab;
		}

		internal const string PrefabName = "SK_CarKey";

		internal const string LowriderPrefabName = "SK_LowriderKey";

		internal const string PlanePrefabName = "SK_PlaneKey";

		internal const string BikePrefabName = "SK_BikeKey";

		internal static readonly Kind[] Kinds = new Kind[4]
		{
			new Kind
			{
				Name = "SK_CarKey",
				Car = "SK_Skeid",
				Title = "Car Key",
				Icon = "skeid_carkey.png",
				Description = "Brings your car out, and puts it away again. Any key will do."
			},
			new Kind
			{
				Name = "SK_LowriderKey",
				Car = "SK_Lowrider",
				Title = "Lowrider Key",
				Icon = "skeid_lowriderkey.png",
				Description = "Brings your lowrider out, and puts it away again. Top stays down."
			},
			new Kind
			{
				Name = "SK_PlaneKey",
				Car = "SK_Plane",
				Title = "Aeroplane Key",
				Icon = "skeid_planekey.png",
				Description = "Brings your aeroplane out, and puts it away again. Double-tap Jump to fly."
			},
			new Kind
			{
				Name = "SK_BikeKey",
				Car = "SK_Bike",
				Title = "Motorcycle Key",
				Icon = "skeid_bikekey.png",
				Description = "Brings your motorcycle out, and puts it away again. One rider."
			}
		};

		private const string SourceName = "CryptKey";

		internal const string IconFile = "skeid_carkey.png";

		private static GameObject _prefab;

		internal static Kind KindOf(ItemData item)
		{
			if (item == null)
			{
				return null;
			}
			Kind[] kinds = Kinds;
			foreach (Kind kind in kinds)
			{
				if ((Object)(object)kind.Prefab != (Object)null && (Object)(object)item.m_dropPrefab != (Object)null && string.Equals(((Object)item.m_dropPrefab).name, kind.Name, StringComparison.Ordinal))
				{
					return kind;
				}
				SharedData val = ((!((Object)(object)kind.Prefab != (Object)null)) ? null : kind.Prefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared);
				if (val != null && item.m_shared == val)
				{
					return kind;
				}
			}
			return null;
		}

		internal static bool Is(ItemData item)
		{
			return KindOf(item) != null;
		}

		private static void Build()
		{
			Kind[] kinds = Kinds;
			for (int i = 0; i < kinds.Length; i++)
			{
				Build(kinds[i]);
			}
		}

		private static void Build(Kind kind)
		{
			if ((Object)(object)kind.Prefab != (Object)null)
			{
				return;
			}
			ObjectDB instance = ObjectDB.instance;
			GameObject val = (((Object)(object)instance == (Object)null) ? null : instance.GetItemPrefab("CryptKey"));
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = Object.Instantiate<GameObject>(val, Nursery.Transform(), false);
				((Object)val2).name = kind.Name;
				ItemDrop component = val2.GetComponent<ItemDrop>();
				if ((Object)(object)component == (Object)null)
				{
					Safety.Once("CarKeyItem.NoItemDrop", "the cloned key has no ItemDrop, so the Car Key cannot be made.");
					Object.Destroy((Object)(object)val2);
					return;
				}
				if (component.m_itemData.m_shared == val.GetComponent<ItemDrop>().m_itemData.m_shared)
				{
					Safety.Once("CarKeyItem.SharedAliased", "the cloned key shares its data with the vanilla crypt key, so it has been abandoned rather than renaming a real item.");
					Object.Destroy((Object)(object)val2);
					return;
				}
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = kind.Title;
				shared.m_description = kind.Description;
				shared.m_maxStackSize = 1;
				shared.m_questItem = false;
				shared.m_teleportable = true;
				Icons.Apply(shared, kind.Icon, kind.Name + "Icon");
				kind.Prefab = val2;
			}
		}

		private static void Register()
		{
			Kind[] kinds = Kinds;
			for (int i = 0; i < kinds.Length; i++)
			{
				Register(kinds[i]);
			}
		}

		private static void Register(Kind kind)
		{
			GameObject prefab = kind.Prefab;
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			ObjectDB instance = ObjectDB.instance;
			if ((Object)(object)instance != (Object)null && instance.m_items != null && !instance.m_items.Contains(prefab))
			{
				instance.m_items.Add(prefab);
				AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null)?.Invoke(instance, null);
			}
			ZNetScene instance2 = ZNetScene.instance;
			if ((Object)(object)instance2 == (Object)null || instance2.m_prefabs == null)
			{
				return;
			}
			if (!instance2.m_prefabs.Contains(prefab))
			{
				instance2.m_prefabs.Add(prefab);
			}
			if (!(AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs")?.GetValue(instance2) is Dictionary<int, GameObject> dictionary))
			{
				Safety.Once("CarKeyItem.NoNamedPrefabs", "ZNetScene.m_namedPrefabs could not be reached, so a dropped Car Key will not come back after a reload.");
				return;
			}
			int stableHashCode = StringExtensionMethods.GetStableHashCode(kind.Name);
			if (!dictionary.ContainsKey(stableHashCode))
			{
				dictionary[stableHashCode] = prefab;
			}
		}

		internal static void Sync()
		{
			try
			{
				Build();
				Register();
			}
			catch (Exception ex)
			{
				Safety.Failed("CarKeyItem.Sync", ex);
			}
		}

		internal static bool Give(Player to, string which = "SK_CarKey")
		{
			if ((Object)(object)to == (Object)null)
			{
				return false;
			}
			Sync();
			Kind[] kinds = Kinds;
			foreach (Kind kind in kinds)
			{
				if (string.Equals(kind.Name, which, StringComparison.OrdinalIgnoreCase))
				{
					if ((Object)(object)kind.Prefab == (Object)null)
					{
						return false;
					}
					return ((Humanoid)to).GetInventory().AddItem(kind.Prefab, 1);
				}
			}
			return false;
		}
	}
	internal static class CarKeyLogic
	{
		internal enum Act
		{
			BringOut,
			PutAway,
			TooFar,
			Nothing
		}

		internal struct Candidate
		{
			public long Owner;

			public float Distance;

			public Candidate(long owner, float distance)
			{
				Owner = owner;
				Distance = distance;
			}
		}

		internal static Act Decide(long me, IList<Candidate> loaded, float range, out int which)
		{
			which = -1;
			if (me == 0L)
			{
				return Act.Nothing;
			}
			if (loaded == null || loaded.Count == 0)
			{
				return Act.BringOut;
			}
			float num = float.MaxValue;
			for (int i = 0; i < loaded.Count; i++)
			{
				if (loaded[i].Owner == me && !(loaded[i].Distance >= num))
				{
					num = loaded[i].Distance;
					which = i;
				}
			}
			if (which < 0)
			{
				return Act.BringOut;
			}
			if (num > range)
			{
				which = -1;
				return Act.TooFar;
			}
			return Act.PutAway;
		}
	}
	internal static class CarPaint
	{
		internal static int Apply(SkeidCar car, int packed)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)car == (Object)null)
			{
				return packed;
			}
			try
			{
				CarPrefab.Made car2 = CarPrefab.Of(((Component)car).gameObject);
				Color paint = Paint.Unpack(packed);
				Material[] array = CarPrefab.MaterialsFor(car2, paint, body: true);
				Material[] array2 = CarPrefab.MaterialsFor(car2, paint, body: false);
				if (array == null && array2 == null)
				{
					return packed;
				}
				MeshRenderer[] componentsInChildren = ((Component)car).GetComponentsInChildren<MeshRenderer>(true);
				foreach (MeshRenderer val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)null))
					{
						Material[] array3 = ((((Object)((Component)val).transform).name ?? string.Empty).StartsWith("wheel_", StringComparison.Ordinal) ? array2 : array);
						if (array3 != null && array3.Length == ((Renderer)val).sharedMaterials.Length)
						{
							((Renderer)val).sharedMaterials = array3;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Safety.Failed("CarPaint.Apply", ex);
			}
			return packed;
		}

		internal static int Wanted(SkeidCar car)
		{
			int result = Default(car);
			ZDO val = (((Object)(object)car != (Object)null) ? car.Zdo : null);
			if (val == null)
			{
				return result;
			}
			int num = val.GetInt(Keys.Paint, 0);
			if (num != 0)
			{
				return num;
			}
			return result;
		}

		internal static int Default(SkeidCar car)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			CarPrefab.Made made = (((Object)(object)car != (Object)null) ? CarPrefab.Of(((Component)car).gameObject) : null);
			if (made == null || made.Spec?.Paint == null)
			{
				return Paint.Pack(Paint.Configured());
			}
			return made.Spec.Paint();
		}
	}
	internal static class CarPrefab
	{
		internal sealed class Spec
		{
			public string Name;

			public Func<string> File;

			public Func<float> Length;

			public Func<float> Yaw;

			public Func<Vector2> Seat;

			public Func<float> Lift;

			public Func<int> Paint;

			public Func<float> Hop;

			public int Seats;

			public Func<float> RearRow;

			public bool Textured;

			public bool ShowRiders;

			public bool Paintable = true;

			public float PaintSpread = 0.12f;

			public string Title;

			public bool Tidy = true;

			public Func<Wheels.Gearing> Gear;

			public bool Flies;

			public bool TwoWheeled;

			public string Spinner;
		}

		internal sealed class Made
		{
			public Spec Spec;

			public GameObject Prefab;

			public Wheels.Rig Rig;

			public Bounds BodyBounds;

			public string[] BodySurfaces;

			public string[] WheelSurfaces;

			public Paint.Palette Palette;
		}

		internal const string PrefabName = "SK_Skeid";

		internal const string LowriderPrefabName = "SK_Lowrider";

		internal const string PlanePrefabName = "SK_Plane";

		internal const string BikePrefabName = "SK_Bike";

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

		internal static readonly Spec[] Specs = new Spec[4]
		{
			new Spec
			{
				Name = "SK_Skeid",
				File = () => SkeidPlugin.ModelFile.Value,
				Length = () => SkeidPlugin.BodyLength.Value,
				Yaw = () => 0f,
				Seat = () => Vector2.zero,
				Lift = () => 0f,
				Hop = () => 0f,
				Paint = () => Paint.Pack(Paint.Configured()),
				Seats = 2,
				RearRow = () => 0f,
				Textured = false,
				ShowRiders = false,
				Title = "Skeid"
			},
			new Spec
			{
				Name = "SK_Lowrider",
				File = () => SkeidPlugin.LowriderFile.Value,
				Length = () => SkeidPlugin.LowriderLength.Value,
				Yaw = () => SkeidPlugin.LowriderYaw.Value,
				Seat = () => new Vector2(SkeidPlugin.LowriderSeatForward.Value, SkeidPlugin.LowriderSeatHeight.Value),
				Lift = () => SkeidPlugin.LowriderRideHeight.Value,
				Hop = () => SkeidPlugin.LowriderHop.Value,
				Paint = () => 1333810,
				Seats = 4,
				RearRow = () => SkeidPlugin.LowriderRearRow.Value,
				Textured = true,
				ShowRiders = true,
				Title = "Lowrider"
			},
			new Spec
			{
				Name = "SK_Plane",
				File = () => SkeidPlugin.PlaneFile.Value,
				Length = () => SkeidPlugin.PlaneLength.Value,
				Yaw = () => 90f,
				Seat = () => new Vector2(SkeidPlugin.PlaneSeatForward.Value, SkeidPlugin.PlaneSeatHeight.Value),
				Lift = () => 0f,
				Hop = () => 0f,
				Paint = () => 4872747,
				Seats = 1,
				RearRow = () => 0f,
				Textured = true,
				ShowRiders = false,
				Title = "Aeroplane",
				PaintSpread = 0.04f,
				Tidy = false,
				Gear = () => new Wheels.Gearing
				{
					Forward = SkeidPlugin.PlaneGearForward.Value,
					Back = SkeidPlugin.PlaneGearBack.Value,
					Track = SkeidPlugin.PlaneGearTrack.Value,
					Radius = SkeidPlugin.PlaneGearRadius.Value,
					Clearance = SkeidPlugin.PlaneClearance.Value
				},
				Flies = true,
				Spinner = "Cylinder.002"
			},
			new Spec
			{
				Name = "SK_Bike",
				File = () => SkeidPlugin.BikeFile.Value,
				Length = () => SkeidPlugin.BikeLength.Value,
				Yaw = () => SkeidPlugin.BikeYaw.Value,
				Seat = () => new Vector2(SkeidPlugin.BikeSeatForward.Value, SkeidPlugin.BikeSeatHeight.Value),
				Lift = () => 0f,
				Hop = () => 0f,
				Paint = () => Paint.Pack(Paint.Configured()),
				Seats = 1,
				RearRow = () => 0f,
				Textured = false,
				ShowRiders = true,
				Title = "Motorcycle",
				Tidy = false,
				TwoWheeled = true
			}
		};

		internal const string DriverSeatName = "seat_driver";

		internal const string WheelPrefix = "wheel_";

		internal const string StereoMountName = "stereo";

		private static GameObject _prefab;

		private static Transform _nursery;

		private static readonly List<Mesh> Meshes = new List<Mesh>();

		private static Paint.Palette _palette;

		private static Material[] _bodyMaterials;

		internal const string LeftGripName = "grip_left";

		internal const string RightGripName = "grip_right";

		internal const string SpinnerName = "spinner";

		private const char KeySplit = '\0';

		internal static IEnumerable<Made> All => Cars.Values;

		internal static string[] BodySurfaces { get; private set; }

		internal static string[] WheelSurfaces { get; private set; }

		internal static GameObject Prefab => _prefab;

		internal static Wheels.Rig Rig { get; private set; }

		internal static Bounds BodyBounds { get; private set; }

		private static void Shift(Wheels.Rig rig, float[] by)
		{
			if (rig == null || by == null || by.Length < 3)
			{
				return;
			}
			foreach (Wheels.Slot slot in rig.Slots)
			{
				slot.X += by[0];
				slot.Y += by[1];
				slot.Z += by[2];
			}
		}

		private static Wheels.Rig Scaled(Wheels.Rig rig, float scale)
		{
			if (rig == null || Math.Abs(scale - 1f) < 0.0001f)
			{
				return rig;
			}
			Wheels.Rig rig2 = new Wheels.Rig
			{
				Wheelbase = rig.Wheelbase * scale,
				Track = rig.Track * scale,
				Radius = rig.Radius * scale
			};
			foreach (Wheels.Slot slot in rig.Slots)
			{
				Wheels.Slot item = new Wheels.Slot
				{
					Where = slot.Where,
					X = slot.X * scale,
					Y = slot.Y * scale,
					Z = slot.Z * scale,
					Radius = slot.Radius * scale,
					HalfWidth = slot.HalfWidth * scale
				};
				rig2.Slots.Add(item);
			}
			return rig2;
		}

		private static string Bodywork(ObjModel model, Wheels.Rig rig)
		{
			HashSet<ObjModel.Part> hashSet = new HashSet<ObjModel.Part>();
			if (rig != null)
			{
				foreach (Wheels.Slot slot in rig.Slots)
				{
					foreach (ObjModel.Part part in slot.Parts)
					{
						hashSet.Add(part);
					}
				}
				foreach (ObjModel.Part source in rig.Sources)
				{
					hashSet.Add(source);
				}
			}
			string result = null;
			int num = 0;
			foreach (ObjModel.Part part2 in model.Parts)
			{
				if (!hashSet.Contains(part2) && !part2.LooksLikeAWheel() && !string.IsNullOrEmpty(part2.Material) && !(part2.SizeZ < model.SizeZ * 0.6f) && part2.TriangleCount > num)
				{
					num = part2.TriangleCount;
					result = part2.Material;
				}
			}
			return result;
		}

		internal static void PumpPaint()
		{
			foreach (Made value in Cars.Values)
			{
				value?.Palette?.Pump();
			}
		}

		internal static Made Of(string prefabName)
		{
			if (string.IsNullOrEmpty(prefabName))
			{
				return null;
			}
			if (!Cars.TryGetValue(prefabName, out var value))
			{
				return null;
			}
			return value;
		}

		internal static Made Of(GameObject instance)
		{
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			string text = ((Object)instance).name ?? string.Empty;
			int num = text.IndexOf("(Clone)", StringComparison.Ordinal);
			if (num >= 0)
			{
				text = text.Substring(0, num);
			}
			return Of(text.Trim());
		}

		internal static string PassengerSeatName(int index)
		{
			if (index > 0)
			{
				return "seat_passenger" + (index + 1);
			}
			return "seat_passenger";
		}

		internal static Material[] MaterialsFor(Made car, Color paint, bool body)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (car == null)
			{
				return null;
			}
			string[] array = (body ? car.BodySurfaces : car.WheelSurfaces);
			if (array == null || car.Palette == null)
			{
				return null;
			}
			Material[] array2 = (Material[])(object)new Material[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i] ?? string.Empty;
				int num = text.IndexOf('\0');
				string name = ((num >= 0) ? text.Substring(0, num) : text);
				string material = ((num >= 0) ? text.Substring(num + 1) : null);
				array2[i] = car.Palette.For(name, material, paint);
			}
			return array2;
		}

		private static Transform Nursery()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if ((Object)(object)_nursery != (Object)null)
			{
				return _nursery;
			}
			GameObject val = new GameObject("SkeidPrefabs");
			val.SetActive(false);
			Object.DontDestroyOnLoad((Object)val);
			_nursery = val.transform;
			return _nursery;
		}

		internal static void EnsureBuilt()
		{
			Spec[] specs = Specs;
			foreach (Spec spec in specs)
			{
				if (!Cars.ContainsKey(spec.Name))
				{
					try
					{
						Build(spec);
					}
					catch (ObjException ex)
					{
						Safety.Once("CarPrefab.Model." + spec.Name, "could not read the model for " + spec.Name + ": " + ex.Message + ". Looked for '" + spec.File() + "' in " + Assets.Override + " and next to Skeid.dll.");
					}
					catch (Exception ex2)
					{
						Safety.Failed("CarPrefab.Build." + spec.Name, ex2);
					}
				}
			}
		}

		private static void Build(Spec spec)
		{
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Expected O, but got Unknown
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			string text = spec.File();
			string text2 = Assets.Find(text);
			if (text2 == null)
			{
				Safety.Once("CarPrefab.Missing." + spec.Name, "there is no car model called '" + text + "'. Looked in " + Assets.Override + " and next to Skeid.dll.");
				return;
			}
			bool num = text2.EndsWith(".glb", StringComparison.OrdinalIgnoreCase) || text2.EndsWith(".gltf", StringComparison.OrdinalIgnoreCase);
			Dictionary<string, byte[]> textures = new Dictionary<string, byte[]>(StringComparer.Ordinal);
			Dictionary<string, GlbModel.Shade> shades = new Dictionary<string, GlbModel.Shade>(StringComparer.Ordinal);
			ObjModel objModel = (num ? GlbModel.Parse(File.ReadAllBytes(text2), out textures, out shades) : ObjModel.Parse(File.ReadAllText(text2)));
			foreach (string item in ModelTidy.Tidy(objModel, spec.Tidy))
			{
				ManualLogSource log = SkeidPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("Skeid: " + spec.Name + " - dropped a " + item));
				}
			}
			float degrees = SkeidPlugin.ModelYaw.Value + spec.Yaw();
			ModelTidy.Turn(objModel, degrees);
			Wheels.Gearing gearing = spec.Gear?.Invoke();
			Wheels.Rig rig = ((gearing != null) ? Wheels.Improvise(objModel, gearing, (Action<string>)SkeidPlugin.Log.LogInfo) : (spec.TwoWheeled ? Wheels.Inline(objModel, (Action<string>)SkeidPlugin.Log.LogInfo) : Wheels.Map(objModel)));
			float[] array = ModelTidy.Recentre(objModel, rig);
			if (Math.Abs(array[0]) > 0.001f || Math.Abs(array[1]) > 0.001f || Math.Abs(array[2]) > 0.001f)
			{
				ManualLogSource log2 = SkeidPlugin.Log;
				if (log2 != null)
				{
					log2.LogInfo((object)("Skeid: " + spec.Name + " - recentred by " + array[0].ToString("0.00") + ", " + array[1].ToString("0.00") + ", " + array[2].ToString("0.00") + " so it stands on the ground."));
				}
				if (gearing == null)
				{
					rig = ((!spec.TwoWheeled) ? Wheels.Map(objModel) : Wheels.Inline(objModel));
				}
				else
				{
					Shift(rig, array);
				}
			}
			if (rig == null)
			{
				Safety.Once("CarPrefab.Wheels." + spec.Name, "could not find four wheels in '" + Path.GetFileName(text2) + "'. Wheels are recognised by 'wheel', 'tyre', 'tire' or 'rim' appearing in an object or material name, and failing that by shape - four matching round parts at the corners. Without them there is nothing to hang the suspension on.");
				return;
			}
			float num2 = 1f;
			float num3 = spec.Length();
			if (num3 > 0.01f && objModel.SizeZ > 0.0001f)
			{
				num2 = num3 / objModel.SizeZ;
			}
			float num4 = 0f;
			Color paint = Paint.Configured();
			_palette = new Paint.Palette();
			_palette.Skins = (spec.Textured ? textures : null);
			_palette.Shades = (spec.Textured ? shades : null);
			_palette.Spread = spec.PaintSpread;
			_palette.BodyMaterial = ((spec.Textured && spec.Paintable) ? Bodywork(objModel, rig) : null);
			if (_palette.BodyMaterial != null)
			{
				ManualLogSource log3 = SkeidPlugin.Log;
				if (log3 != null)
				{
					log3.LogInfo((object)("Skeid: " + spec.Name + " - '" + _palette.BodyMaterial + "' is the bodywork, so it takes the paint."));
				}
			}
			GameObject val = new GameObject(spec.Name);
			val.transform.SetParent(Nursery(), false);
			Quaternion val2 = Quaternion.Euler(0f, num4, 0f);
			ObjModel.Part part = Named(objModel, spec.Spinner);
			if (part != null)
			{
				rig.Sources.Add(part);
			}
			Bounds val3 = (BodyBounds = BuildBody(val.transform, objModel, rig, num2, val2, paint));
			if (part != null)
			{
				BuildSpinner(val.transform, part, num2, val2, paint);
			}
			if (spec.Seats < 2)
			{
				BuildGrips(val.transform, objModel, num2, val2);
			}
			foreach (Wheels.Slot slot2 in rig.Slots)
			{
				BuildWheel(val.transform, slot2, num2, val2, paint);
			}
			Transform obj = val.transform.Find("body");
			MeshRenderer val5 = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null);
			if ((Object)(object)val5 != (Object)null && _bodyMaterials != null)
			{
				((Renderer)val5).sharedMaterials = _bodyMaterials;
			}
			BoxCollider obj2 = val.AddComponent<BoxCollider>();
			float num5 = (rig.Slots[0].Y + rig.Radius) * num2;
			float num6 = Mathf.Max(((Bounds)(ref val3)).min.y, num5 * 0.55f);
			obj2.center = new Vector3(0f, (num6 + ((Bounds)(ref val3)).max.y) * 0.5f, ((Bounds)(ref val3)).center.z);
			obj2.size = new Vector3(Mathf.Max(0.2f, ((Bounds)(ref val3)).size.x * 0.92f), Mathf.Max(0.2f, ((Bounds)(ref val3)).max.y - num6), Mathf.Max(0.2f, ((Bounds)(ref val3)).size.z * 0.98f));
			Rigidbody obj3 = val.AddComponent<Rigidbody>();
			obj3.mass = 1200f;
			obj3.linearDamping = 0.15f;
			obj3.angularDamping = 1.6f;
			obj3.useGravity = true;
			obj3.interpolation = (RigidbodyInterpolation)0;
			obj3.collisionDetectionMode = (CollisionDetectionMode)2;
			obj3.centerOfMass = new Vector3(0f, num5 * 0.65f, ((Bounds)(ref val3)).center.z - ((Bounds)(ref val3)).size.z * 0.05f);
			Wheels.Slot slot = rig.Get(Wheels.Corner.FrontLeft);
			float num7 = ((val2 == Quaternion.identity) ? (slot.Y * num2) : (val2 * new Vector3(slot.X, slot.Y, slot.Z) * num2).y) - rig.Radius * num2 * 0.45f;
			float num8 = (rig.Get(Wheels.Corner.FrontLeft).Z + rig.Get(Wheels.Corner.FrontRight).Z) * 0.5f;
			float num9 = (rig.Get(Wheels.Corner.RearLeft).Z + rig.Get(Wheels.Corner.RearRight).Z) * 0.5f;
			float num10 = ((num8 + num9) * 0.5f - rig.Wheelbase * 0.14f) * num2;
			float num11 = rig.Track * num2 * 0.26f;
			ObjModel.Part part2 = ((spec.Seats < 2) ? Saddle(objModel) : null);
			if (part2 != null)
			{
				num10 = (part2.MaxZ - part2.SizeZ * 0.3f) * num2;
				ManualLogSource log4 = SkeidPlugin.Log;
				if (log4 != null)
				{
					log4.LogInfo((object)("Skeid: " + spec.Name + " - seating the rider forward on its saddle at z " + num10.ToString("0.00") + " (the saddle runs " + part2.MinZ.ToString("0.00") + " to " + part2.MaxZ.ToString("0.00") + ") rather than from the wheelbase."));
				}
			}
			Vector2 val6 = spec.Seat();
			num10 += val6.x;
			num7 += val6.y;
			bool flag = spec.Seats < 2;
			Seat(val.transform, "seat_driver", new Vector3(flag ? 0f : (0f - num11), num7, num10));
			if (!flag)
			{
				Seat(val.transform, PassengerSeatName(0), new Vector3(num11, num7, num10));
			}
			int num12 = Mathf.Max(0, spec.Seats - 2);
			if (num12 > 0)
			{
				float num13 = rig.Wheelbase * num2 * spec.RearRow();
				for (int i = 0; i < num12 && i + 1 < Keys.Passengers.Length; i++)
				{
					float num14 = ((i % 2 == 0) ? (0f - num11) : num11);
					Seat(val.transform, PassengerSeatName(i + 1), new Vector3(num14, num7, num10 - num13));
				}
			}
			Seat(val.transform, "stereo", new Vector3(0f, num7 + rig.Radius * num2 * 0.8f, num10));
			ZNetView obj4 = val.AddComponent<ZNetView>();
			obj4.m_persistent = true;
			obj4.m_type = (ObjectType)0;
			obj4.m_distant = false;
			obj4.m_syncInitialScale = false;
			ZSyncTransform obj5 = val.AddComponent<ZSyncTransform>();
			obj5.m_syncPosition = true;
			obj5.m_syncRotation = true;
			obj5.m_syncScale = false;
			obj5.m_syncBodyVelocity = true;
			val.AddComponent<SkeidCar>();
			val.AddComponent<Chassis>();
			val.AddComponent<Impacts>();
			val.AddComponent<Engine>();
			val.AddComponent<Stereo>();
			_prefab = val;
			Rig = rig;
			SkeidPlugin.Log.LogInfo((object)("Skeid: built " + spec.Name + " from " + Path.GetFileName(text2) + " - " + objModel.TriangleCount + " triangles, " + objModel.Parts.Count + " parts, wheelbase " + (rig.Wheelbase * num2).ToString("0.00") + " m, track " + (rig.Track * num2).ToString("0.00") + " m, wheel radius " + (rig.Radius * num2).ToString("0.00") + " m" + (spec.Textured ? ", textured" : ", painted") + " (model units " + rig.Wheelbase.ToString("0.00") + " / " + rig.Track.ToString("0.00") + " / " + rig.Radius.ToString("0.00") + " at scale " + num2.ToString("0.000") + ")."));
			Cars[spec.Name] = new Made
			{
				Spec = spec,
				Prefab = _prefab,
				Rig = Scaled(rig, num2),
				BodyBounds = BodyBounds,
				BodySurfaces = BodySurfaces,
				WheelSurfaces = WheelSurfaces,
				Palette = _palette
			};
		}

		private static Bounds BuildBody(Transform parent, ObjModel model, Wheels.Rig rig, float scale, Quaternion turn, Color paint)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			HashSet<ObjModel.Part> hashSet = new HashSet<ObjModel.Part>();
			if (rig != null)
			{
				foreach (Wheels.Slot slot in rig.Slots)
				{
					foreach (ObjModel.Part part in slot.Parts)
					{
						hashSet.Add(part);
					}
				}
				foreach (ObjModel.Part source in rig.Sources)
				{
					hashSet.Add(source);
				}
			}
			Dictionary<string, List<ObjModel.Part>> dictionary = new Dictionary<string, List<ObjModel.Part>>(StringComparer.Ordinal);
			foreach (ObjModel.Part part2 in model.Parts)
			{
				if (!hashSet.Contains(part2))
				{
					Group(dictionary, part2);
				}
			}
			GameObject val = new GameObject("body");
			val.transform.SetParent(parent, false);
			Material[] order;
			string[] surfaces;
			Mesh val2 = Combine(dictionary, scale, turn, Vector3.zero, paint, out order, out surfaces);
			BodySurfaces = surfaces;
			Meshes.Add(val2);
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			_bodyMaterials = order;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)obj).receiveShadows = true;
			Stabilise(obj);
			return val2.bounds;
		}

		private static ObjModel.Part Saddle(ObjModel model)
		{
			if (model == null)
			{
				return null;
			}
			ObjModel.Part part = null;
			foreach (ObjModel.Part part2 in model.Parts)
			{
				string text = (part2.Material + " " + part2.Name).ToLowerInvariant();
				if ((text.Contains("leather") || text.Contains("saddle")) && (part == null || part2.TriangleCount > part.TriangleCount))
				{
					part = part2;
				}
			}
			return part;
		}

		private static ObjModel.Part Handlebars(ObjModel model)
		{
			if (model == null)
			{
				return null;
			}
			ObjModel.Part part = null;
			foreach (ObjModel.Part part2 in model.Parts)
			{
				if (!(part2.SizeX < part2.SizeY * 2.5f) && !(part2.SizeX < part2.SizeZ * 2.5f) && !(part2.CentreY < model.MinY + model.SizeY * 0.5f) && !(part2.CentreZ < model.MinZ + model.SizeZ * 0.5f) && (part == null || part2.SizeX > part.SizeX))
				{
					part = part2;
				}
			}
			return part;
		}

		private static void BuildGrips(Transform parent, ObjModel model, float scale, Quaternion turn)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			ObjModel.Part part = Handlebars(model);
			if (part != null)
			{
				float num = part.SizeX * 0.5f * 0.82f;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(part.CentreX, part.CentreY, part.CentreZ);
				Grip(parent, "grip_left", turn * (val + Vector3.left * num) * scale, Vector3.left);
				Grip(parent, "grip_right", turn * (val + Vector3.right * num) * scale, Vector3.right);
				ManualLogSource log = SkeidPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("Skeid: handlebars are '" + (part.Name ?? "?") + "', " + part.SizeX.ToString("0.00") + " across at y " + part.CentreY.ToString("0.00") + ", z " + part.CentreZ.ToString("0.00") + " - riders will hold them."));
				}
			}
		}

		private static void Grip(Transform parent, string name, Vector3 at, Vector3 along)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = at;
			val.transform.localRotation = Quaternion.AngleAxis(SkeidPlugin.GripTwist.Value, along) * Quaternion.LookRotation(Vector3.forward, Vector3.up);
		}

		private static ObjModel.Part Named(ObjModel model, string name)
		{
			if (model == null || string.IsNullOrEmpty(name))
			{
				return null;
			}
			foreach (ObjModel.Part part in model.Parts)
			{
				if (part.Name != null && part.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return part;
				}
			}
			return null;
		}

		private static void BuildSpinner(Transform parent, ObjModel.Part part, float scale, Quaternion turn, Color paint)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("spinner");
			Vector3 val2 = turn * new Vector3(part.CentreX, part.CentreY, part.CentreZ) * scale;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = val2;
			Dictionary<string, List<ObjModel.Part>> dictionary = new Dictionary<string, List<ObjModel.Part>>(StringComparer.Ordinal);
			Group(dictionary, part);
			Material[] order;
			string[] surfaces;
			Mesh val3 = Combine(dictionary, scale, turn, val2, paint, out order, out surfaces);
			Meshes.Add(val3);
			val.AddComponent<MeshFilter>().sharedMesh = val3;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterials = order;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)obj).receiveShadows = true;
			Stabilise(obj);
		}

		private static void BuildWheel(Transform parent, Wheels.Slot slot, float scale, Quaternion turn, Color paint)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_00a4: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("wheel_" + slot.Where);
			Vector3 val2 = turn * new Vector3(slot.X, slot.Y, slot.Z) * scale;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = val2;
			Dictionary<string, List<ObjModel.Part>> dictionary = new Dictionary<string, List<ObjModel.Part>>(StringComparer.Ordinal);
			foreach (ObjModel.Part part in slot.Parts)
			{
				Group(dictionary, part);
			}
			Material[] order;
			string[] surfaces;
			Mesh val3 = Combine(dictionary, scale, turn, val2, paint, out order, out surfaces);
			WheelSurfaces = surfaces;
			Meshes.Add(val3);
			val.AddComponent<MeshFilter>().sharedMesh = val3;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterials = order;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)obj).receiveShadows = true;
			Stabilise(obj);
		}

		private static void Group(Dictionary<string, List<ObjModel.Part>> into, ObjModel.Part part)
		{
			string key = (part.Name ?? string.Empty) + "\0" + (part.Material ?? string.Empty);
			if (!into.TryGetValue(key, out var value))
			{
				value = (into[key] = new List<ObjModel.Part>());
			}
			value.Add(part);
		}

		private static Mesh Combine(Dictionary<string, List<ObjModel.Part>> byPart, float scale, Quaternion turn, Vector3 offset, Color paint, out Material[] order, out string[] surfaces)
		{
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<List<int>> list4 = new List<List<int>>();
			List<Material> list5 = new List<Material>();
			Dictionary<Material, int> dictionary = new Dictionary<Material, int>();
			List<string> list6 = new List<string>();
			foreach (KeyValuePair<string, List<ObjModel.Part>> item in byPart)
			{
				string text = item.Key ?? string.Empty;
				int num = text.IndexOf('\0');
				string text2 = ((num >= 0) ? text.Substring(0, num) : text);
				string text3 = ((num >= 0) ? text.Substring(num + 1) : null);
				Material val = _palette.For(text2, text3, paint);
				if (!dictionary.TryGetValue(val, out var value))
				{
					value = (dictionary[val] = list4.Count);
					list4.Add(new List<int>());
					list5.Add(val);
					list6.Add(text2 + "\0" + text3);
				}
				List<int> list7 = list4[value];
				bool flag = _palette != null && _palette.Skins != null;
				foreach (ObjModel.Part item2 in item.Value)
				{
					int count2 = list.Count;
					for (int i = 0; i + 2 < item2.Vertices.Length; i += 3)
					{
						Vector3 val2 = turn * new Vector3(item2.Vertices[i], item2.Vertices[i + 1], item2.Vertices[i + 2]) * scale;
						list.Add(val2 - offset);
						if (item2.Normals != null)
						{
							list2.Add(turn * new Vector3(item2.Normals[i], item2.Normals[i + 1], item2.Normals[i + 2]));
						}
						int num2 = i / 3 * 2;
						list3.Add((Vector2)((flag && item2.Uvs != null && num2 + 1 < item2.Uvs.Length) ? new Vector2(item2.Uvs[num2], item2.Uvs[num2 + 1]) : Vector2.zero));
					}
					for (int j = 0; j < item2.Triangles.Length; j++)
					{
						list7.Add(count2 + item2.Triangles[j]);
					}
				}
			}
			Mesh val3 = new Mesh
			{
				name = "SK_Mesh",
				hideFlags = (HideFlags)61,
				indexFormat = (IndexFormat)(list.Count > 65000)
			};
			val3.SetVertices(list);
			if (list2.Count == list.Count)
			{
				val3.SetNormals(list2);
			}
			val3.SetUVs(0, list3);
			val3.subMeshCount = list4.Count;
			for (int k = 0; k < list4.Count; k++)
			{
				val3.SetTriangles(list4[k], k, false);
			}
			order = list5.ToArray();
			surfaces = list6.ToArray();
			if (list2.Count != list.Count)
			{
				val3.RecalculateNormals();
			}
			val3.RecalculateBounds();
			Vector4[] array = (Vector4[])(object)new Vector4[list.Count];
			float[] array2 = new float[4];
			List<Vector3> list8 = ((list2.Count == list.Count) ? list2 : new List<Vector3>(val3.normals));
			for (int l = 0; l < array.Length; l++)
			{
				Vector3 val4 = ((l < list8.Count) ? list8[l] : Vector3.up);
				ObjModel.Part.Tangent(val4.x, val4.y, val4.z, array2, 0);
				array[l] = new Vector4(array2[0], array2[1], array2[2], array2[3]);
			}
			val3.tangents = array;
			Color32[] array3 = (Color32[])(object)new Color32[list.Count];
			for (int m = 0; m < array3.Length; m++)
			{
				array3[m] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
			}
			val3.colors32 = array3;
			return val3;
		}

		private static void Stabilise(MeshRenderer renderer)
		{
			if (!((Object)(object)renderer == (Object)null))
			{
				((Renderer)renderer).receiveShadows = false;
				((Renderer)renderer).lightProbeUsage = (LightProbeUsage)0;
				((Renderer)renderer).reflectionProbeUsage = (ReflectionProbeUsage)0;
				((Renderer)renderer).allowOcclusionWhenDynamic = false;
			}
		}

		private static void Seat(Transform parent, string name, Vector3 where)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unkn