Decompiled source of MuckinatorGrind v1.0.0

MuckinatorGrind.dll

Decompiled 11 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("pramodexe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Spawns mobs and auto-fights them to farm kills toward the Muckinator achievements in Muck.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+76e1b764d11e1f475dad1bff336899924408a871")]
[assembly: AssemblyProduct("MuckinatorGrind")]
[assembly: AssemblyTitle("MuckinatorGrind")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("pramodexe.muckinatorgrind", "MuckinatorGrind", "1.0.0")]
public class MuckinatorGrindPlugin : BaseUnityPlugin
{
	private enum RunState
	{
		Stopped,
		Running,
		Paused
	}

	private enum Tab
	{
		Spawn,
		Combat,
		Settings
	}

	private enum HotkeyTarget
	{
		None,
		StartPause,
		Menu
	}

	private enum NoticeLevel
	{
		Info,
		Success,
		Warning,
		Error
	}

	private struct Preset
	{
		public string Name;

		public string Hint;

		public int Batch;

		public int Max;

		public float Interval;

		public float Radius;
	}

	private sealed class Hotkey
	{
		public KeyCode Key;

		public bool Ctrl;

		public bool Alt;

		public bool Shift;

		public static bool IsModifier(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			if ((int)key != 306 && (int)key != 305 && (int)key != 308 && (int)key != 307 && (int)key != 304 && (int)key != 303 && (int)key != 310)
			{
				return (int)key == 309;
			}
			return true;
		}

		private static bool CtrlHeld()
		{
			if (!Input.GetKey((KeyCode)306))
			{
				return Input.GetKey((KeyCode)305);
			}
			return true;
		}

		private static bool AltHeld()
		{
			if (!Input.GetKey((KeyCode)308))
			{
				return Input.GetKey((KeyCode)307);
			}
			return true;
		}

		private static bool ShiftHeld()
		{
			if (!Input.GetKey((KeyCode)304))
			{
				return Input.GetKey((KeyCode)303);
			}
			return true;
		}

		public static Hotkey FromCurrentModifiers(KeyCode key)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return new Hotkey
			{
				Key = key,
				Ctrl = CtrlHeld(),
				Alt = AltHeld(),
				Shift = ShiftHeld()
			};
		}

		public static Hotkey Parse(string value, KeyCode fallback)
		{
			//IL_0087: 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_008b: 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)
			value = value ?? "";
			Hotkey obj = new Hotkey
			{
				Ctrl = value.Contains("Ctrl+"),
				Alt = value.Contains("Alt+"),
				Shift = value.Contains("Shift+")
			};
			string value2 = value.Replace("Ctrl+", "").Replace("Alt+", "").Replace("Shift+", "")
				.Trim();
			obj.Key = ((Enum.TryParse<KeyCode>(value2, ignoreCase: true, out KeyCode result) && (int)result != 0) ? result : fallback);
			return obj;
		}

		public bool IsPressed()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(Key) && Ctrl == CtrlHeld() && Alt == AltHeld())
			{
				return Shift == ShiftHeld();
			}
			return false;
		}

		public bool Equals(Hotkey other)
		{
			//IL_0004: 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)
			if (other != null && other.Key == Key && other.Ctrl == Ctrl && other.Alt == Alt)
			{
				return other.Shift == Shift;
			}
			return false;
		}

		public override string ToString()
		{
			return (Ctrl ? "Ctrl+" : "") + (Alt ? "Alt+" : "") + (Shift ? "Shift+" : "") + ((object)Unsafe.As<KeyCode, KeyCode>(ref Key)/*cast due to .constrained prefix*/).ToString();
		}
	}

	private sealed class Ui
	{
		private static readonly Color Bg = Hex("#14161B");

		private static readonly Color Surface = Hex("#1C1F26");

		private static readonly Color SurfaceHover = Hex("#252933");

		private static readonly Color Border = Hex("#2C313C");

		private static readonly Color InputBg = Hex("#0F1115");

		private static readonly Color Text = Hex("#E8EAED");

		private static readonly Color MutedText = Hex("#8B93A1");

		private static readonly Color AccentC = Hex("#F2853A");

		private static readonly Color AccentHover = Hex("#FF9A55");

		private static readonly Color AccentDark = Hex("#C7692B");

		private static readonly Color Green = Hex("#3FB950");

		private static readonly Color Amber = Hex("#D29922");

		private static readonly Color Red = Hex("#F85149");

		private readonly List<Texture2D> textures = new List<Texture2D>();

		public GUISkin Skin;

		public GUIStyle Window;

		public GUIStyle Card;

		public GUIStyle Hud;

		public GUIStyle Title;

		public GUIStyle Section;

		public GUIStyle Label;

		public GUIStyle LabelBold;

		public GUIStyle Muted;

		public GUIStyle Accent;

		public GUIStyle Hint;

		public GUIStyle HintSmall;

		public GUIStyle Placeholder;

		public GUIStyle TextGreen;

		public GUIStyle TextAmber;

		public GUIStyle TextRed;

		public GUIStyle StatValue;

		public GUIStyle StatCaption;

		public GUIStyle ProgressLabel;

		public GUIStyle EmptyTitle;

		public GUIStyle EmptyBody;

		public GUIStyle KeyCap;

		public GUIStyle Button;

		public GUIStyle ButtonSmall;

		public GUIStyle ButtonPrimary;

		public GUIStyle ButtonWarning;

		public GUIStyle ButtonDanger;

		public GUIStyle IconButton;

		public GUIStyle IconButtonDanger;

		public GUIStyle Tab;

		public GUIStyle TabActive;

		public GUIStyle MobButton;

		public GUIStyle MobSelected;

		public GUIStyle SwitchOn;

		public GUIStyle SwitchOff;

		public GUIStyle PillGreen;

		public GUIStyle PillAmber;

		public GUIStyle PillGray;

		public GUIStyle BannerError;

		public GUIStyle BannerWarning;

		public GUIStyle TextInput;

		public GUIStyle InputNumber;

		public GUIStyle SliderTrack;

		public GUIStyle Thumb;

		public Texture2D BorderTex;

		public Texture2D AccentTex;

		public Texture2D TrackTex;

		public Texture2D TrackFillDisabledTex;

		public Texture2D GreenTex;

		public void EnsureBuilt()
		{
			if (!((Object)(object)Skin != (Object)null) || !((Object)(object)BorderTex != (Object)null))
			{
				Dispose();
				Build();
			}
		}

		public void Dispose()
		{
			foreach (Texture2D texture in textures)
			{
				if ((Object)(object)texture != (Object)null)
				{
					Object.Destroy((Object)(object)texture);
				}
			}
			textures.Clear();
			if ((Object)(object)Skin != (Object)null)
			{
				Object.Destroy((Object)(object)Skin);
			}
			Skin = null;
		}

		private void Build()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_006d: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_019f: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: 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_0278: Expected O, but got Unknown
			//IL_0278: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_02c5: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: 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_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: 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_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Expected O, but got Unknown
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: 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_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Expected O, but got Unknown
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Expected O, but got Unknown
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: 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_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: 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_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Expected O, but got Unknown
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: 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_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: 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_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Expected O, but got Unknown
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Expected O, but got Unknown
			//IL_06fc: 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_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Expected O, but got Unknown
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_076f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0774: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Expected O, but got Unknown
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: 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_0803: Unknown result type (might be due to invalid IL or missing references)
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: 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_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: 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)
			//IL_0888: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Expected O, but got Unknown
			//IL_08fc: Expected O, but got Unknown
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0936: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_094b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Expected O, but got Unknown
			//IL_095e: Expected O, but got Unknown
			//IL_096e: Unknown result type (might be due to invalid IL or missing references)
			//IL_099d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_09af: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b9: Expected O, but got Unknown
			//IL_09b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09be: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Expected O, but got Unknown
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Expected O, but got Unknown
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ade: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Expected O, but got Unknown
			//IL_0af7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0b: Expected O, but got Unknown
			//IL_0b0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1b: Expected O, but got Unknown
			//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3c: Expected O, but got Unknown
			//IL_0b48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b91: Unknown result type (might be due to invalid IL or missing references)
			Skin = Object.Instantiate<GUISkin>(GUI.skin);
			((Object)Skin).hideFlags = (HideFlags)61;
			BorderTex = Solid(Border);
			AccentTex = Solid(AccentC);
			TrackTex = Solid(Hex("#2A2E37"));
			TrackFillDisabledTex = Solid(Hex("#555B66"));
			GreenTex = Solid(Green);
			Skin.verticalScrollbar.normal.background = Solid(Bg);
			Skin.verticalScrollbar.fixedWidth = 8f;
			Skin.verticalScrollbar.border = new RectOffset(0, 0, 0, 0);
			Skin.verticalScrollbar.margin = new RectOffset(4, 0, 0, 0);
			Skin.verticalScrollbarThumb.normal.background = Solid(Hex("#3A404C"));
			Skin.verticalScrollbarThumb.hover.background = Solid(Hex("#4A5160"));
			Skin.verticalScrollbarThumb.active.background = Solid(AccentC);
			Skin.verticalScrollbarThumb.fixedWidth = 8f;
			Skin.verticalScrollbarThumb.border = new RectOffset(0, 0, 0, 0);
			Skin.scrollView.padding = new RectOffset(0, 4, 0, 0);
			Skin.settings.cursorColor = AccentC;
			Skin.settings.selectionColor = new Color(AccentC.r, AccentC.g, AccentC.b, 0.35f);
			Window = new GUIStyle(Skin.window)
			{
				padding = new RectOffset(14, 14, 12, 12),
				border = new RectOffset(1, 1, 1, 1),
				overflow = new RectOffset(0, 0, 0, 0),
				contentOffset = Vector2.zero
			};
			SetAll(Window, Bordered(Bg, Border), Text);
			Card = Box(Surface, Border, new RectOffset(10, 10, 8, 8), new RectOffset(0, 0, 3, 3));
			Hud = Box(new Color(Bg.r, Bg.g, Bg.b, 0.88f), Border, new RectOffset(10, 10, 8, 8), new RectOffset(0, 0, 0, 0));
			Label = TextStyle(12, Text, (FontStyle)0);
			LabelBold = TextStyle(12, Text, (FontStyle)1);
			Muted = TextStyle(11, MutedText, (FontStyle)0);
			Accent = TextStyle(12, AccentC, (FontStyle)1);
			Hint = TextStyle(11, MutedText, (FontStyle)0);
			Hint.wordWrap = true;
			HintSmall = TextStyle(10, MutedText, (FontStyle)0);
			Placeholder = TextStyle(12, Hex("#5C6370"), (FontStyle)2);
			Title = TextStyle(15, Text, (FontStyle)1);
			Section = TextStyle(10, AccentC, (FontStyle)1);
			Section.margin = new RectOffset(2, 0, 2, 4);
			TextGreen = TextStyle(12, Green, (FontStyle)1);
			TextGreen.wordWrap = true;
			TextAmber = TextStyle(12, Amber, (FontStyle)1);
			TextAmber.wordWrap = true;
			TextRed = TextStyle(12, Red, (FontStyle)1);
			TextRed.wordWrap = true;
			StatValue = TextStyle(17, Text, (FontStyle)1);
			StatValue.alignment = (TextAnchor)4;
			StatCaption = TextStyle(9, MutedText, (FontStyle)1);
			StatCaption.alignment = (TextAnchor)4;
			ProgressLabel = TextStyle(11, Color.white, (FontStyle)1);
			ProgressLabel.alignment = (TextAnchor)4;
			EmptyTitle = TextStyle(14, Text, (FontStyle)1);
			EmptyTitle.alignment = (TextAnchor)4;
			EmptyBody = TextStyle(11, MutedText, (FontStyle)0);
			EmptyBody.alignment = (TextAnchor)4;
			EmptyBody.wordWrap = true;
			KeyCap = TextStyle(12, Text, (FontStyle)1);
			KeyCap.normal.background = Bordered(InputBg, Hex("#454B57"));
			KeyCap.border = new RectOffset(1, 1, 1, 1);
			KeyCap.padding = new RectOffset(10, 10, 4, 4);
			KeyCap.alignment = (TextAnchor)4;
			Button = Btn(Surface, SurfaceHover, Hex("#2E333E"), Border, Text);
			ButtonSmall = Btn(Surface, SurfaceHover, Hex("#2E333E"), Border, Text);
			ButtonSmall.fontSize = 11;
			ButtonSmall.padding = new RectOffset(4, 4, 3, 3);
			ButtonPrimary = Btn(AccentC, AccentHover, AccentDark, AccentDark, Hex("#1A1206"));
			ButtonPrimary.fontSize = 14;
			ButtonWarning = Btn(Amber, Hex("#E3AB33"), Hex("#A87A18"), Hex("#A87A18"), Hex("#1A1206"));
			ButtonWarning.fontSize = 13;
			ButtonDanger = Btn(Hex("#3A1D1F"), Hex("#4D2326"), Hex("#2B1517"), Hex("#6E2B2E"), Red);
			ButtonDanger.fontSize = 13;
			IconButton = Btn(Surface, SurfaceHover, Hex("#2E333E"), Border, Text);
			IconButton.fontSize = 14;
			IconButton.padding = new RectOffset(0, 0, 0, 2);
			IconButtonDanger = Btn(Surface, Hex("#4D2326"), Hex("#2B1517"), Border, Text);
			IconButtonDanger.fontSize = 15;
			IconButtonDanger.padding = new RectOffset(0, 0, 0, 2);
			IconButtonDanger.hover.textColor = Red;
			Tab = Btn(Bg, Surface, Surface, Bg, MutedText);
			Tab.hover.textColor = Text;
			Tab.margin = new RectOffset(0, 2, 0, 0);
			TabActive = Btn(Hex("#2A2119"), Hex("#33271C"), Hex("#33271C"), AccentDark, AccentC);
			TabActive.margin = new RectOffset(0, 2, 0, 0);
			MobButton = Btn(Surface, SurfaceHover, Hex("#2E333E"), Border, Text);
			MobButton.fontStyle = (FontStyle)0;
			MobButton.clipping = (TextClipping)1;
			MobSelected = Btn(Hex("#2A2119"), Hex("#33271C"), Hex("#33271C"), AccentC, AccentC);
			MobSelected.clipping = (TextClipping)1;
			SwitchOn = Btn(Hex("#1E3A24"), Hex("#244A2C"), Hex("#183020"), Green, Green);
			SwitchOff = Btn(InputBg, SurfaceHover, InputBg, Hex("#3A404C"), MutedText);
			PillGreen = Pill(Hex("#16301D"), Green);
			PillAmber = Pill(Hex("#33280F"), Amber);
			PillGray = Pill(Hex("#262A31"), MutedText);
			BannerError = Box(Hex("#2D1719"), Hex("#6E2B2E"), new RectOffset(10, 10, 6, 6), new RectOffset(0, 0, 0, 2));
			SetTextColor(BannerError, Hex("#FF9B95"));
			BannerError.fontSize = 12;
			BannerError.wordWrap = true;
			BannerWarning = Box(Hex("#2D2513"), Hex("#6B5420"), new RectOffset(10, 10, 6, 6), new RectOffset(0, 0, 2, 2));
			SetTextColor(BannerWarning, Hex("#F0C866"));
			BannerWarning.fontSize = 11;
			BannerWarning.wordWrap = true;
			TextInput = new GUIStyle(Skin.textField)
			{
				fontSize = 12,
				padding = new RectOffset(8, 8, 5, 5),
				border = new RectOffset(1, 1, 1, 1),
				fixedHeight = 26f
			};
			Texture2D background = Bordered(InputBg, Hex("#353B47"));
			Texture2D background2 = Bordered(InputBg, AccentC);
			TextInput.normal.background = background;
			TextInput.normal.textColor = Text;
			TextInput.hover.background = Bordered(InputBg, Hex("#4A5160"));
			TextInput.hover.textColor = Text;
			TextInput.focused.background = background2;
			TextInput.focused.textColor = Text;
			TextInput.active.background = background2;
			TextInput.active.textColor = Text;
			TextInput.onNormal = TextInput.normal;
			TextInput.onFocused = TextInput.focused;
			InputNumber = new GUIStyle(TextInput)
			{
				alignment = (TextAnchor)5,
				fontStyle = (FontStyle)1
			};
			SliderTrack = new GUIStyle
			{
				padding = new RectOffset(0, 0, 3, 3),
				fixedHeight = 20f
			};
			Thumb = new GUIStyle
			{
				fixedWidth = 14f,
				fixedHeight = 14f
			};
			Thumb.normal.background = Circle(AccentC, Bg, 14);
			Thumb.hover.background = Circle(AccentHover, Bg, 14);
			Thumb.active.background = Circle(Color.white, AccentC, 14);
		}

		private GUIStyle TextStyle(int size, Color color, FontStyle style = (FontStyle)0)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//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_0043: Expected O, but got Unknown
			//IL_0043: 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_004a: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(Skin.label)
			{
				fontSize = size,
				fontStyle = style,
				richText = false,
				padding = new RectOffset(2, 2, 2, 2),
				margin = new RectOffset(2, 2, 1, 1)
			};
			SetTextColor(val, color);
			return val;
		}

		private GUIStyle Btn(Color normal, Color hover, Color active, Color border, Color text)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0026: 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_0035: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//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_0055: Expected O, but got Unknown
			//IL_0056: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00d3: 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_00db: Expected O, but got Unknown
			//IL_00dc: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(Skin.button)
			{
				fontSize = 12,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4,
				border = new RectOffset(1, 1, 1, 1),
				padding = new RectOffset(10, 10, 6, 6),
				margin = new RectOffset(2, 2, 2, 2)
			};
			Texture2D background = Bordered(normal, border);
			Texture2D background2 = Bordered(hover, border);
			Texture2D background3 = Bordered(active, border);
			val.normal.background = background;
			val.onNormal.background = background;
			val.hover.background = background2;
			val.onHover.background = background2;
			val.active.background = background3;
			val.onActive.background = background3;
			val.focused.background = background;
			val.onFocused.background = background;
			SetTextColor(val, text);
			return val;
		}

		private GUIStyle Box(Color fill, Color border, RectOffset padding, RectOffset margin)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0049: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(Skin.box)
			{
				border = new RectOffset(1, 1, 1, 1),
				padding = padding,
				margin = margin,
				alignment = (TextAnchor)3
			};
			SetAll(val, Bordered(fill, border), Text);
			return val;
		}

		private GUIStyle Pill(Color fill, Color text)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_001e: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			GUIStyle obj = TextStyle(10, text, (FontStyle)1);
			obj.normal.background = Bordered(fill, new Color(text.r, text.g, text.b, 0.45f));
			obj.border = new RectOffset(1, 1, 1, 1);
			obj.padding = new RectOffset(9, 9, 4, 4);
			obj.margin = new RectOffset(0, 0, 3, 0);
			obj.alignment = (TextAnchor)4;
			return obj;
		}

		private static void SetAll(GUIStyle s, Texture2D bg, Color text)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			s.normal.background = bg;
			s.onNormal.background = bg;
			s.hover.background = bg;
			s.onHover.background = bg;
			s.active.background = bg;
			s.onActive.background = bg;
			s.focused.background = bg;
			s.onFocused.background = bg;
			SetTextColor(s, text);
		}

		private static void SetTextColor(GUIStyle s, Color c)
		{
			//IL_0006: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			s.normal.textColor = c;
			s.onNormal.textColor = c;
			s.hover.textColor = c;
			s.onHover.textColor = c;
			s.active.textColor = c;
			s.onActive.textColor = c;
			s.focused.textColor = c;
			s.onFocused.textColor = c;
		}

		private Texture2D Keep(Texture2D t)
		{
			((Object)t).hideFlags = (HideFlags)61;
			((Texture)t).wrapMode = (TextureWrapMode)1;
			textures.Add(t);
			return t;
		}

		private Texture2D Solid(Color c)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, c);
			val.Apply();
			return Keep(val);
		}

		private Texture2D Bordered(Color fill, Color border)
		{
			//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_0011: Expected O, but got Unknown
			//IL_0024: 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)
			Texture2D val = new Texture2D(3, 3, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0
			};
			for (int i = 0; i < 3; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					val.SetPixel(i, j, (i == 1 && j == 1) ? fill : border);
				}
			}
			val.Apply();
			return Keep(val);
		}

		private Texture2D Circle(Color fill, Color ring, int size)
		{
			//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_0011: Expected O, but got Unknown
			//IL_0032: 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_005e: 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_005f: 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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			float num = (float)size / 2f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = Vector2.Distance(new Vector2((float)i + 0.5f, (float)j + 0.5f), new Vector2(num, num));
					float num3 = Mathf.Clamp01(num - num2);
					Color val2 = ((num2 > num - 2.5f) ? ring : fill);
					val2.a *= num3;
					val.SetPixel(i, j, val2);
				}
			}
			val.Apply();
			return Keep(val);
		}

		public static void DrawRect(Rect r, Texture2D tex)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 7 && (Object)(object)tex != (Object)null)
			{
				GUI.DrawTexture(r, (Texture)(object)tex, (ScaleMode)0);
			}
		}

		private static Color Hex(string hex)
		{
			//IL_0010: 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)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString(hex, ref result))
			{
				return Color.magenta;
			}
			return result;
		}
	}

	public const string Version = "1.0.0";

	public const int MaxMobs = 1000;

	private const int SpawnsPerFrame = 40;

	private const uint LEFT_DOWN = 2u;

	private const uint LEFT_UP = 4u;

	private static readonly string[] TabNames = new string[3] { "Spawn", "Combat", "Settings" };

	private static readonly string[] AllowedMobs = new string[3] { "lil Dave", "Goblin", "Stone Golem" };

	private static readonly string[] AllowedMobLabels = new string[3] { "Lil Dave", "Goblin", "Stone Golem" };

	private const string DefaultMob = "Goblin";

	private Harmony harmony;

	private RunState state;

	private bool showGUI;

	private bool compact;

	private Tab activeTab;

	private HotkeyTarget capturing;

	private const int WindowId = 1296519758;

	private const float DefaultWindowWidth = 560f;

	private const float DefaultContentHeight = 340f;

	private const float MinWindowWidth = 480f;

	private const float MaxWindowWidth = 1200f;

	private const float MinContentHeight = 150f;

	private const float MaxContentHeight = 1000f;

	private const float GripSize = 16f;

	private float WindowWidth = 560f;

	private float ContentHeight = 340f;

	private float windowOpacity = 1f;

	private bool resizingWindow;

	private Vector2 resizeStartMouse;

	private Vector2 resizeStartSize;

	private Rect windowRect = new Rect(40f, 40f, 560f, 0f);

	private Vector2 contentScroll;

	private ConfigEntry<string> cfgMob;

	private ConfigEntry<int> cfgBatchSize;

	private ConfigEntry<int> cfgMaxActive;

	private ConfigEntry<float> cfgSpawnInterval;

	private ConfigEntry<float> cfgSpawnRadius;

	private ConfigEntry<bool> cfgUnlimitedHealth;

	private ConfigEntry<bool> cfgUnlimitedStamina;

	private ConfigEntry<bool> cfgAutoClick;

	private ConfigEntry<float> cfgClickInterval;

	private ConfigEntry<bool> cfgLimitEnabled;

	private ConfigEntry<int> cfgKillLimit;

	private ConfigEntry<string> cfgHotkey;

	private ConfigEntry<string> cfgMenuKey;

	private ConfigEntry<bool> cfgCloseOnStart;

	private ConfigEntry<bool> cfgShowHud;

	private ConfigEntry<float> cfgUiScale;

	private ConfigEntry<int> cfgTab;

	private ConfigEntry<float> cfgWindowX;

	private ConfigEntry<float> cfgWindowWidth;

	private ConfigEntry<float> cfgContentHeight;

	private ConfigEntry<float> cfgWindowOpacity;

	private ConfigEntry<float> cfgWindowY;

	private ConfigEntry<bool> cfgGodSword;

	private ConfigEntry<bool> cfgAutoAim;

	private ConfigEntry<bool> cfgTracker;

	private int selectedMobIndex = -1;

	private string selectedMobName = "Goblin";

	private int batchSize;

	private int maxActiveMobs;

	private float spawnInterval;

	private float spawnRadius;

	private bool unlimitedHealth;

	private bool unlimitedStamina;

	private bool autoClick;

	private float clickInterval;

	private bool limitEnabled;

	private int killLimit;

	private bool closeOnStart;

	private bool showHud;

	private float uiScale;

	private float pendingScale;

	private bool godSwordEnabled;

	private bool autoAimEnabled;

	private bool trackerEnabled;

	private bool wasInWorld;

	private bool swordReady;

	private float swordWaitStarted;

	private const float SwordWaitTimeout = 10f;

	private const string KillStat = "Kills";

	private const int MuckinatorTiers = 4;

	private static readonly int[] MuckinatorFallbackGoals = new int[4] { 100, 1000, 10000, 100000 };

	private readonly int[] muckinatorGoals = (int[])MuckinatorFallbackGoals.Clone();

	private readonly bool[] muckinatorTierUnlocked = new bool[4];

	private int steamKills = -1;

	private float nextStatRead;

	private float nextAchievementRead;

	private float killsPerMinute;

	private readonly Queue<KeyValuePair<float, int>> killSamples = new Queue<KeyValuePair<float, int>>();

	private bool draggingWindow;

	private Vector2 dragOffset;

	private int spawnQueue;

	private int waveSpawned;

	private float nextSwordCheck;

	private Mob aimTarget;

	private bool aimActive;

	private float aimYaw;

	private float aimPitch;

	private Hotkey startKey;

	private Hotkey menuKey;

	private float nextSpawnTime;

	private float nextClickTime;

	private float nextSaveCheck;

	private float nextNearbyRefresh;

	private int nearbyCount;

	private int sessionSpawned;

	private int sessionDefeated;

	private int totalSpawned;

	private int totalDefeated;

	private string notice;

	private NoticeLevel noticeLevel;

	private float noticeUntil;

	private float resetConfirmUntil;

	private readonly Dictionary<int, Mob> activeSpawned = new Dictionary<int, Mob>();

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

	private MobType[] cachedTypes;

	private string[] cachedNames;

	private static KeyCode[] allKeyCodes;

	private Ui ui;

	private static readonly Preset[] Presets = new Preset[5]
	{
		new Preset
		{
			Name = "Trickle",
			Hint = "5 mobs, slow waves",
			Batch = 5,
			Max = 10,
			Interval = 8f,
			Radius = 15f
		},
		new Preset
		{
			Name = "Standard",
			Hint = "25 mobs, default pacing",
			Batch = 25,
			Max = 50,
			Interval = 5f,
			Radius = 12f
		},
		new Preset
		{
			Name = "Horde",
			Hint = "60 mobs, fast waves",
			Batch = 60,
			Max = 120,
			Interval = 3f,
			Radius = 20f
		},
		new Preset
		{
			Name = "Swarm",
			Hint = "250 mobs, fast waves",
			Batch = 250,
			Max = 400,
			Interval = 2f,
			Radius = 30f
		},
		new Preset
		{
			Name = "Maximum",
			Hint = "1000 mobs, no waiting — heavy on performance",
			Batch = 1000,
			Max = 1000,
			Interval = 0.5f,
			Radius = 40f
		}
	};

	private readonly List<int> pruneBuffer = new List<int>();

	private const string GodSwordName = "God Sword";

	private const int GodSwordBaseItemId = 142;

	private static MethodInfo godPowersGetWeapon;

	private static bool godPowersSearched;

	public static MuckinatorGrindPlugin Instance { get; private set; }

	[DllImport("user32.dll")]
	private static extern void mouse_event(uint flags, uint dx, uint dy, uint data, UIntPtr extraInfo);

	private void Awake()
	{
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Expected O, but got Unknown
		Instance = this;
		cfgMob = ((BaseUnityPlugin)this).Config.Bind<string>("Spawning", "Mob", "Goblin", "Mob to spawn: Lil Dave, Goblin or Stone Golem.");
		cfgBatchSize = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "BatchSize", 25, (ConfigDescription)null);
		cfgMaxActive = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxActiveMobs", 50, (ConfigDescription)null);
		cfgSpawnInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnInterval", 5f, (ConfigDescription)null);
		cfgSpawnRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnRadius", 12f, (ConfigDescription)null);
		cfgUnlimitedHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "UnlimitedHealth", true, (ConfigDescription)null);
		cfgUnlimitedStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "UnlimitedStamina", true, "Keep your stamina full so you can sprint forever.");
		cfgAutoClick = ((BaseUnityPlugin)this).Config.Bind<bool>("Automation", "AutoClick", false, (ConfigDescription)null);
		cfgClickInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Automation", "AutoClickInterval", 0.15f, (ConfigDescription)null);
		cfgLimitEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Automation", "KillLimitEnabled", false, (ConfigDescription)null);
		cfgKillLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Automation", "KillLimit", 1000, (ConfigDescription)null);
		cfgHotkey = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkey", "StartPauseKey", "F8", (ConfigDescription)null);
		cfgMenuKey = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkey", "MenuKey", "F2", (ConfigDescription)null);
		cfgCloseOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "CloseMenuOnStart", true, (ConfigDescription)null);
		cfgShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "ShowHud", true, (ConfigDescription)null);
		cfgUiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "UiScale", 1f, (ConfigDescription)null);
		cfgTab = ((BaseUnityPlugin)this).Config.Bind<int>("Interface", "LastTab", 0, (ConfigDescription)null);
		cfgWindowX = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "WindowX", 40f, (ConfigDescription)null);
		cfgWindowWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "WindowWidth", 560f, "Menu width. Drag the bottom-right corner of the menu to change it.");
		cfgContentHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "WindowContentHeight", 340f, "Height of the menu's scrolling area. Drag the bottom-right corner of the menu to change it.");
		cfgWindowOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "WindowOpacity", 1f, "Menu opacity from 0.3 (very see-through) to 1 (solid).");
		cfgWindowY = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "WindowY", 40f, (ConfigDescription)null);
		cfgGodSword = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat", "AutoGodSword", true, "Give yourself a God Sword in hotbar slot 1 and attack with it while a session runs.");
		cfgTracker = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "MuckinatorTracker", true, "Show live progress toward your next Muckinator achievement (1-4) on the HUD.");
		cfgAutoAim = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat", "AutoAim", true, "Turn the camera toward the nearest mob while the God Sword is attacking.");
		LoadFromConfig();
		harmony = new Harmony("pramodexe.muckinatorgrind");
		harmony.PatchAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MuckinatorGrind 1.0.0 loaded.");
	}

	private void LoadFromConfig()
	{
		selectedMobName = AllowedMobName(cfgMob.Value);
		batchSize = Mathf.Clamp(cfgBatchSize.Value, 1, 1000);
		maxActiveMobs = Mathf.Clamp(cfgMaxActive.Value, 1, 1000);
		godSwordEnabled = cfgGodSword.Value;
		autoAimEnabled = cfgAutoAim.Value;
		trackerEnabled = cfgTracker.Value;
		spawnInterval = Mathf.Clamp(cfgSpawnInterval.Value, 0.5f, 120f);
		spawnRadius = Mathf.Clamp(cfgSpawnRadius.Value, 2f, 100f);
		unlimitedHealth = cfgUnlimitedHealth.Value;
		unlimitedStamina = cfgUnlimitedStamina.Value;
		autoClick = cfgAutoClick.Value;
		clickInterval = Mathf.Clamp(cfgClickInterval.Value, 0.05f, 1f);
		limitEnabled = cfgLimitEnabled.Value;
		killLimit = Mathf.Clamp(cfgKillLimit.Value, 1, 1000000);
		closeOnStart = cfgCloseOnStart.Value;
		showHud = cfgShowHud.Value;
		uiScale = Mathf.Clamp(cfgUiScale.Value, 0.75f, 2f);
		pendingScale = uiScale;
		activeTab = (Tab)Mathf.Clamp(cfgTab.Value, 0, TabNames.Length - 1);
		WindowWidth = Mathf.Clamp(cfgWindowWidth.Value, 480f, 1200f);
		ContentHeight = Mathf.Clamp(cfgContentHeight.Value, 150f, 1000f);
		windowOpacity = Mathf.Clamp(cfgWindowOpacity.Value, 0.3f, 1f);
		((Rect)(ref windowRect)).x = cfgWindowX.Value;
		((Rect)(ref windowRect)).y = cfgWindowY.Value;
		startKey = Hotkey.Parse(cfgHotkey.Value, (KeyCode)289);
		menuKey = Hotkey.Parse(cfgMenuKey.Value, (KeyCode)283);
	}

	private void Update()
	{
		if (capturing != HotkeyTarget.None)
		{
			CaptureHotkey();
		}
		else if (!IsTypingInField())
		{
			if (menuKey.IsPressed())
			{
				SetMenuVisible(!showGUI);
			}
			else if (startKey.IsPressed())
			{
				ToggleRun();
			}
		}
		bool flag = (Object)(object)PlayerMovement.Instance != (Object)null;
		if (wasInWorld && !flag)
		{
			OnLeftWorld();
		}
		wasInWorld = flag;
		PruneSpawnedMobs();
		if (unlimitedStamina && (Object)(object)PlayerStatus.Instance != (Object)null)
		{
			PlayerStatus.Instance.stamina = PlayerStatus.Instance.maxStamina;
		}
		if (trackerEnabled)
		{
			UpdateMuckinator();
		}
		if (Time.unscaledTime >= nextNearbyRefresh && (showGUI || showHud))
		{
			nearbyCount = CountNearbyMobs();
			nextNearbyRefresh = Time.unscaledTime + 0.5f;
		}
		if (Time.unscaledTime >= nextSaveCheck)
		{
			SaveSettings();
			nextSaveCheck = Time.unscaledTime + 1f;
		}
		aimActive = false;
		if (state != RunState.Running)
		{
			return;
		}
		if (limitEnabled && sessionDefeated >= killLimit)
		{
			Stop("Kill target of " + killLimit + " reached.", NoticeLevel.Success);
			return;
		}
		if (godSwordEnabled)
		{
			if (Time.unscaledTime >= nextSwordCheck)
			{
				bool num = EnsureGodSwordEquipped();
				nextSwordCheck = Time.unscaledTime + (swordReady ? 1.5f : 0.5f);
				if (num && !swordReady)
				{
					swordReady = true;
					nextSpawnTime = Time.time;
					Notify("God Sword ready in slot 1 — spawning.", NoticeLevel.Success);
				}
			}
			if (!swordReady)
			{
				if (Time.unscaledTime - swordWaitStarted > 10f)
				{
					state = RunState.Paused;
					Notify("Paused: couldn't put a God Sword in slot 1. Check BepInEx/LogOutput.log.", NoticeLevel.Error);
				}
				return;
			}
			if (!showGUI)
			{
				GodSwordAttack();
			}
		}
		else if (autoClick && !showGUI && Time.time >= nextClickTime)
		{
			PerformMouseClick();
			nextClickTime = Time.time + clickInterval;
		}
		if (spawnQueue > 0)
		{
			SpawnStep();
		}
		else if (Time.time >= nextSpawnTime && activeSpawned.Count == 0)
		{
			SpawnBatch();
		}
	}

	private void OnDestroy()
	{
		state = RunState.Stopped;
		SaveSettings();
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		if (ui != null)
		{
			ui.Dispose();
		}
	}

	private void ToggleRun()
	{
		if (state == RunState.Running)
		{
			Pause();
		}
		else
		{
			StartSession();
		}
	}

	private void StartSession()
	{
		if (!IsHost())
		{
			Notify("You must be hosting a game to spawn mobs.", NoticeLevel.Error);
			return;
		}
		if (state == RunState.Stopped)
		{
			sessionSpawned = 0;
			sessionDefeated = 0;
		}
		bool flag = state == RunState.Paused;
		state = RunState.Running;
		nextSpawnTime = Time.time;
		nextClickTime = Time.time;
		nextSwordCheck = 0f;
		swordReady = !godSwordEnabled;
		swordWaitStarted = Time.unscaledTime;
		if (godSwordEnabled)
		{
			swordReady = EnsureGodSwordEquipped();
			nextSwordCheck = Time.unscaledTime + (swordReady ? 1.5f : 0.5f);
		}
		if (showGUI && closeOnStart)
		{
			SetMenuVisible(visible: false);
		}
		if (!swordReady)
		{
			Notify("Getting God Sword into slot 1 before spawning…", NoticeLevel.Warning);
		}
		else
		{
			Notify(flag ? "Resumed." : ("Started — " + SelectedMobName() + " waves incoming."), NoticeLevel.Success);
		}
	}

	private void Pause()
	{
		if (state == RunState.Running)
		{
			state = RunState.Paused;
			aimActive = false;
			Notify("Paused. Existing mobs stay alive; session stats kept.", NoticeLevel.Warning);
		}
	}

	private void Stop(string message, NoticeLevel level)
	{
		if (state != RunState.Stopped)
		{
			state = RunState.Stopped;
			aimActive = false;
			aimTarget = null;
			Notify(message, level);
		}
	}

	private void SetMenuVisible(bool visible)
	{
		showGUI = visible;
		capturing = HotkeyTarget.None;
		bool flag = (Object)(object)PlayerMovement.Instance != (Object)null;
		if (visible)
		{
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
		}
		else if (flag)
		{
			Cursor.visible = false;
			Cursor.lockState = (CursorLockMode)1;
		}
		GUIUtility.keyboardControl = 0;
	}

	private void OnLeftWorld()
	{
		if (state != RunState.Stopped)
		{
			state = RunState.Stopped;
			Notify("Left the world — session stopped.", NoticeLevel.Info);
		}
		activeSpawned.Clear();
		spawnQueue = 0;
		aimActive = false;
		aimTarget = null;
		swordReady = false;
		cachedTypes = null;
		cachedNames = null;
	}

	private static Dictionary<int, InventoryItem> ItemDatabase()
	{
		ItemManager instance = ItemManager.Instance;
		if (instance != null && instance.allItems != null && instance.allItems.Count > 0)
		{
			return instance.allItems;
		}
		ItemManager val = Object.FindObjectOfType<ItemManager>();
		if ((Object)(object)val != (Object)null && val.allItems != null && val.allItems.Count > 0)
		{
			return val.allItems;
		}
		return null;
	}

	private void UpdateMuckinator()
	{
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime < nextStatRead)
		{
			return;
		}
		nextStatRead = unscaledTime + 0.25f;
		try
		{
			if (!SteamClient.IsValid)
			{
				steamKills = -1;
				return;
			}
			int num = (steamKills = SteamUserStats.GetStatInt("Kills"));
			killSamples.Enqueue(new KeyValuePair<float, int>(unscaledTime, num));
			while (killSamples.Count > 1 && unscaledTime - killSamples.Peek().Key > 60f)
			{
				killSamples.Dequeue();
			}
			KeyValuePair<float, int> keyValuePair = killSamples.Peek();
			float num2 = unscaledTime - keyValuePair.Key;
			killsPerMinute = ((num2 >= 5f) ? ((float)Mathf.Max(0, num - keyValuePair.Value) * 60f / num2) : 0f);
			if (unscaledTime >= nextAchievementRead)
			{
				nextAchievementRead = unscaledTime + 10f;
				foreach (Achievement achievement in SteamUserStats.Achievements)
				{
					Achievement current = achievement;
					int num3 = MuckinatorTierFromName(((Achievement)(ref current)).Name);
					if (num3 >= 0)
					{
						muckinatorTierUnlocked[num3] = ((Achievement)(ref current)).State;
						int num4 = FirstNumber(((Achievement)(ref current)).Description);
						if (num4 > 0)
						{
							muckinatorGoals[num3] = num4;
						}
					}
				}
			}
			for (int i = 0; i < 4; i++)
			{
				if (num >= muckinatorGoals[i])
				{
					muckinatorTierUnlocked[i] = true;
				}
			}
		}
		catch (Exception ex)
		{
			steamKills = -1;
			nextStatRead = unscaledTime + 5f;
			((BaseUnityPlugin)this).Logger.LogDebug((object)("Steam stat read failed: " + ex.Message));
		}
	}

	private static int MuckinatorTierFromName(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return -1;
		}
		string text = name.Trim();
		if (!text.StartsWith("Muckinator", StringComparison.OrdinalIgnoreCase))
		{
			return -1;
		}
		string text2 = text.Substring("Muckinator".Length).Trim().ToUpperInvariant();
		if (text2 != null)
		{
			switch (text2.Length)
			{
			case 1:
				switch (text2[0])
				{
				case '1':
				case 'I':
					break;
				case '2':
					goto IL_00cc;
				case '3':
					goto IL_00ce;
				case '4':
					goto IL_00d0;
				default:
					goto end_IL_004a;
				}
				goto case 0;
			case 2:
			{
				char c = text2[1];
				if (c != 'I')
				{
					if (c != 'V' || !(text2 == "IV"))
					{
						break;
					}
					goto IL_00d0;
				}
				if (!(text2 == "II"))
				{
					break;
				}
				goto IL_00cc;
			}
			case 3:
				if (!(text2 == "III"))
				{
					break;
				}
				goto IL_00ce;
			case 0:
				{
					return 0;
				}
				IL_00ce:
				return 2;
				IL_00cc:
				return 1;
				IL_00d0:
				return 3;
				end_IL_004a:
				break;
			}
		}
		return -1;
	}

	private static int FirstNumber(string text)
	{
		if (string.IsNullOrEmpty(text))
		{
			return -1;
		}
		long num = 0L;
		bool flag = false;
		for (int i = 0; i < text.Length; i++)
		{
			char c = text[i];
			if (c >= '0' && c <= '9')
			{
				flag = true;
				num = num * 10 + (c - 48);
				if (num > int.MaxValue)
				{
					return -1;
				}
			}
			else if ((!flag || (c != ',' && c != '.' && c != ' ') || i + 1 >= text.Length || !char.IsDigit(text[i + 1])) && flag)
			{
				break;
			}
		}
		if (!flag)
		{
			return -1;
		}
		return (int)num;
	}

	private int CurrentMuckinatorTier()
	{
		int num = -1;
		for (int i = 0; i < 4; i++)
		{
			if (!muckinatorTierUnlocked[i] && steamKills < muckinatorGoals[i] && (num < 0 || muckinatorGoals[i] < muckinatorGoals[num]))
			{
				num = i;
			}
		}
		return num;
	}

	private static string FormatDuration(float minutes)
	{
		if (minutes <= 0f || float.IsInfinity(minutes) || float.IsNaN(minutes))
		{
			return "—";
		}
		TimeSpan timeSpan = TimeSpan.FromMinutes(minutes);
		if (timeSpan.TotalDays >= 1.0)
		{
			return (int)timeSpan.TotalDays + "d " + timeSpan.Hours + "h";
		}
		if (timeSpan.TotalHours >= 1.0)
		{
			return (int)timeSpan.TotalHours + "h " + timeSpan.Minutes + "m";
		}
		return Mathf.Max(1, timeSpan.Minutes) + "m";
	}

	private void DrawMuckinator(bool compactLayout)
	{
		if (!trackerEnabled)
		{
			return;
		}
		GUILayout.Space((float)(compactLayout ? 4 : 6));
		int num = ((steamKills < 0) ? (-1) : CurrentMuckinatorTier());
		bool flag = steamKills >= 0 && num < 0;
		int num2 = (flag ? 3 : Mathf.Max(0, num));
		int num3 = muckinatorGoals[num2];
		int num4 = 0;
		for (int i = 0; i < 4; i++)
		{
			if (muckinatorTierUnlocked[i])
			{
				num4++;
			}
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label(flag ? "MUCKINATOR — ALL DONE" : ("MUCKINATOR " + (num2 + 1)), ui.Section, Array.Empty<GUILayoutOption>());
		GUILayout.FlexibleSpace();
		if (flag)
		{
			GUILayout.Label("4 / 4 UNLOCKED", ui.TextGreen, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		}
		else if (steamKills >= 0)
		{
			GUILayout.Label(num4 + " / 4 unlocked", ui.HintSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		}
		GUILayout.EndHorizontal();
		if (steamKills < 0)
		{
			GUILayout.Label("Steam stats unavailable.", ui.HintSmall, Array.Empty<GUILayoutOption>());
			return;
		}
		float num5 = Mathf.Clamp01((float)steamKills / (float)num3);
		ProgressBar(num5, steamKills.ToString("N0") + " / " + num3.ToString("N0") + "  (" + (num5 * 100f).ToString("0.0") + "%)", compactLayout ? 18f : 22f);
		int num6 = Mathf.Max(0, num3 - steamKills);
		string obj = ((killsPerMinute > 0.5f) ? (killsPerMinute.ToString("N0") + " kills/min") : "no recent kills");
		string text = ((num6 == 0) ? "done!" : ((killsPerMinute > 0.5f) ? ("ETA " + FormatDuration((float)num6 / killsPerMinute)) : (num6.ToString("N0") + " to go")));
		GUILayout.Label(obj + "   ·   " + text, ui.HintSmall, Array.Empty<GUILayoutOption>());
	}

	private void Notify(string message, NoticeLevel level)
	{
		notice = message;
		noticeLevel = level;
		noticeUntil = Time.unscaledTime + 4f;
		if (level == NoticeLevel.Error)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)message);
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}
	}

	private void PerformMouseClick()
	{
		try
		{
			mouse_event(2u, 0u, 0u, 0u, UIntPtr.Zero);
			mouse_event(4u, 0u, 0u, 0u, UIntPtr.Zero);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Automatic mouse click failed: " + ex));
			autoClick = false;
			Notify("Auto-click isn't supported here and was disabled.", NoticeLevel.Error);
		}
	}

	private bool IsHost()
	{
		if ((Object)(object)LocalClient.instance != (Object)null)
		{
			return LocalClient.serverOwner;
		}
		return false;
	}

	private bool IsTypingInField()
	{
		if (showGUI)
		{
			return GUIUtility.keyboardControl != 0;
		}
		return false;
	}

	private void CaptureHotkey()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Invalid comparison between Unknown and I4
		//IL_006a: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)27))
		{
			capturing = HotkeyTarget.None;
			Notify("Hotkey change cancelled.", NoticeLevel.Info);
			return;
		}
		if (allKeyCodes == null)
		{
			allKeyCodes = (KeyCode[])Enum.GetValues(typeof(KeyCode));
		}
		KeyCode[] array = allKeyCodes;
		foreach (KeyCode val in array)
		{
			if ((int)val == 0 || (int)val == 323 || (int)val == 324 || Hotkey.IsModifier(val) || !Input.GetKeyDown(val))
			{
				continue;
			}
			Hotkey hotkey = Hotkey.FromCurrentModifiers(val);
			if (capturing == HotkeyTarget.StartPause)
			{
				if (hotkey.Equals(menuKey))
				{
					Notify(hotkey?.ToString() + " is already the menu key.", NoticeLevel.Error);
					break;
				}
				startKey = hotkey;
				cfgHotkey.Value = hotkey.ToString();
			}
			else
			{
				if (hotkey.Equals(startKey))
				{
					Notify(hotkey?.ToString() + " is already the start/pause key.", NoticeLevel.Error);
					break;
				}
				menuKey = hotkey;
				cfgMenuKey.Value = hotkey.ToString();
			}
			((BaseUnityPlugin)this).Config.Save();
			capturing = HotkeyTarget.None;
			Notify("Hotkey set to " + hotkey?.ToString() + ".", NoticeLevel.Success);
			break;
		}
	}

	private void SaveSettings()
	{
		bool flag = false;
		flag |= Set(cfgMob, selectedMobName);
		flag |= Set(cfgBatchSize, batchSize);
		flag |= Set(cfgMaxActive, maxActiveMobs);
		flag |= Set(cfgSpawnInterval, spawnInterval);
		flag |= Set(cfgSpawnRadius, spawnRadius);
		flag |= Set(cfgUnlimitedHealth, unlimitedHealth);
		flag |= Set(cfgUnlimitedStamina, unlimitedStamina);
		flag |= Set(cfgAutoClick, autoClick);
		flag |= Set(cfgClickInterval, clickInterval);
		flag |= Set(cfgLimitEnabled, limitEnabled);
		flag |= Set(cfgKillLimit, killLimit);
		flag |= Set(cfgCloseOnStart, closeOnStart);
		flag |= Set(cfgShowHud, showHud);
		flag |= Set(cfgUiScale, uiScale);
		flag |= Set(cfgTab, (int)activeTab);
		flag |= Set(cfgWindowX, Mathf.Round(((Rect)(ref windowRect)).x));
		if (!resizingWindow)
		{
			flag |= Set(cfgWindowWidth, Mathf.Round(WindowWidth));
			flag |= Set(cfgContentHeight, Mathf.Round(ContentHeight));
		}
		flag |= Set(cfgWindowOpacity, Mathf.Round(windowOpacity * 100f) / 100f);
		flag |= Set(cfgWindowY, Mathf.Round(((Rect)(ref windowRect)).y));
		flag |= Set(cfgGodSword, godSwordEnabled);
		flag |= Set(cfgAutoAim, autoAimEnabled);
		if (flag | Set(cfgTracker, trackerEnabled))
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}

	private static bool Set<T>(ConfigEntry<T> entry, T value)
	{
		if (EqualityComparer<T>.Default.Equals(entry.Value, value))
		{
			return false;
		}
		entry.Value = value;
		return true;
	}

	private void ResetToDefaults()
	{
		ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[25]
		{
			(ConfigEntryBase)cfgMob,
			(ConfigEntryBase)cfgBatchSize,
			(ConfigEntryBase)cfgMaxActive,
			(ConfigEntryBase)cfgSpawnInterval,
			(ConfigEntryBase)cfgSpawnRadius,
			(ConfigEntryBase)cfgUnlimitedHealth,
			(ConfigEntryBase)cfgUnlimitedStamina,
			(ConfigEntryBase)cfgAutoClick,
			(ConfigEntryBase)cfgClickInterval,
			(ConfigEntryBase)cfgLimitEnabled,
			(ConfigEntryBase)cfgKillLimit,
			(ConfigEntryBase)cfgHotkey,
			(ConfigEntryBase)cfgMenuKey,
			(ConfigEntryBase)cfgCloseOnStart,
			(ConfigEntryBase)cfgShowHud,
			(ConfigEntryBase)cfgUiScale,
			(ConfigEntryBase)cfgTab,
			(ConfigEntryBase)cfgWindowX,
			(ConfigEntryBase)cfgWindowY,
			(ConfigEntryBase)cfgWindowWidth,
			(ConfigEntryBase)cfgContentHeight,
			(ConfigEntryBase)cfgWindowOpacity,
			(ConfigEntryBase)cfgGodSword,
			(ConfigEntryBase)cfgAutoAim,
			(ConfigEntryBase)cfgTracker
		};
		foreach (ConfigEntryBase obj in array)
		{
			obj.BoxedValue = obj.DefaultValue;
		}
		((BaseUnityPlugin)this).Config.Save();
		LoadFromConfig();
		fieldBuffers.Clear();
		((Rect)(ref windowRect)).height = 0f;
		Notify("All settings restored to defaults.", NoticeLevel.Success);
	}

	private MobType[] GetMobTypes()
	{
		if ((Object)(object)MobSpawner.Instance == (Object)null)
		{
			return null;
		}
		return MobSpawner.Instance.allMobs;
	}

	private string[] GetMobNames()
	{
		MobType[] mobTypes = GetMobTypes();
		if (mobTypes == null)
		{
			return null;
		}
		if (mobTypes != cachedTypes || cachedNames == null || cachedNames.Length != mobTypes.Length)
		{
			cachedTypes = mobTypes;
			cachedNames = new string[mobTypes.Length];
			for (int i = 0; i < mobTypes.Length; i++)
			{
				cachedNames[i] = (((Object)(object)mobTypes[i] != (Object)null) ? mobTypes[i].name : ("Unknown #" + i));
			}
		}
		return cachedNames;
	}

	private static string NormalizeMobName(string name)
	{
		return (name ?? "").Replace(" ", "").Trim().ToLowerInvariant();
	}

	private static string AllowedMobName(string value)
	{
		string text = NormalizeMobName(value);
		string[] allowedMobs = AllowedMobs;
		foreach (string text2 in allowedMobs)
		{
			if (NormalizeMobName(text2) == text)
			{
				return text2;
			}
		}
		return "Goblin";
	}

	private static string MobLabel(string name)
	{
		for (int i = 0; i < AllowedMobs.Length; i++)
		{
			if (AllowedMobs[i] == name)
			{
				return AllowedMobLabels[i];
			}
		}
		return name;
	}

	private int FindMobIndex(string name)
	{
		string[] mobNames = GetMobNames();
		if (mobNames == null)
		{
			return -1;
		}
		string text = NormalizeMobName(name);
		for (int i = 0; i < mobNames.Length; i++)
		{
			if (NormalizeMobName(mobNames[i]) == text)
			{
				return i;
			}
		}
		return -1;
	}

	private string SelectedMobName()
	{
		return MobLabel(selectedMobName);
	}

	private void SpawnBatch()
	{
		if (!IsHost())
		{
			Stop("Stopped — you are no longer the host.", NoticeLevel.Error);
			return;
		}
		MobType[] mobTypes = GetMobTypes();
		selectedMobIndex = FindMobIndex(selectedMobName);
		if (mobTypes == null || selectedMobIndex < 0 || selectedMobIndex >= mobTypes.Length || (Object)(object)mobTypes[selectedMobIndex] == (Object)null)
		{
			Pause();
			Notify("Pick a valid mob in the Spawn tab.", NoticeLevel.Error);
			return;
		}
		if ((Object)(object)MobManager.Instance == (Object)null || (Object)(object)MobSpawner.Instance == (Object)null || (Object)(object)PlayerMovement.Instance == (Object)null)
		{
			nextSpawnTime = Time.time + 2f;
			return;
		}
		int num = Mathf.Min(batchSize, maxActiveMobs - activeSpawned.Count);
		if (num <= 0)
		{
			nextSpawnTime = Time.time + spawnInterval;
			return;
		}
		spawnQueue = num;
		waveSpawned = 0;
		SpawnStep();
	}

	private void SpawnStep()
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_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_0087: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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_00a5: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)MobManager.Instance == (Object)null || (Object)(object)MobSpawner.Instance == (Object)null || (Object)(object)PlayerMovement.Instance == (Object)null || !IsHost())
		{
			spawnQueue = 0;
			return;
		}
		Transform transform = ((Component)PlayerMovement.Instance).transform;
		int num = Mathf.Min(spawnQueue, 40);
		spawnQueue -= num;
		RaycastHit val3 = default(RaycastHit);
		for (int i = 0; i < num; i++)
		{
			Vector2 val = Random.insideUnitCircle * spawnRadius;
			Vector3 val2 = transform.position + new Vector3(val.x, 0f, val.y);
			if (Physics.Raycast(val2 + Vector3.up * 100f, Vector3.down, ref val3, 250f))
			{
				val2 = ((RaycastHit)(ref val3)).point + Vector3.up;
			}
			int nextId = MobManager.Instance.GetNextId();
			try
			{
				MobSpawner.Instance.ServerSpawnNewMob(nextId, selectedMobIndex, val2, 1f, 1f, (BossType)0, -1);
				if (MobManager.Instance.mobs.TryGetValue(nextId, out var value) && (Object)(object)value != (Object)null)
				{
					activeSpawned[((Object)value).GetInstanceID()] = value;
					totalSpawned++;
					sessionSpawned++;
					waveSpawned++;
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Mob spawn failed: " + ex));
			}
		}
		if (spawnQueue == 0)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Spawned wave of " + waveSpawned + " mobs."));
			nextSpawnTime = Time.time + spawnInterval;
		}
	}

	private void PruneSpawnedMobs()
	{
		pruneBuffer.Clear();
		foreach (KeyValuePair<int, Mob> item in activeSpawned)
		{
			if ((Object)(object)item.Value == (Object)null || !((Component)item.Value).gameObject.activeInHierarchy)
			{
				pruneBuffer.Add(item.Key);
			}
		}
		foreach (int item2 in pruneBuffer)
		{
			activeSpawned.Remove(item2);
		}
	}

	public void HandleMobDeath(HitableMob hitable)
	{
		if (!((Object)(object)hitable == (Object)null) && !((Object)(object)hitable.mob == (Object)null) && activeSpawned.Remove(((Object)hitable.mob).GetInstanceID()))
		{
			totalDefeated++;
			sessionDefeated++;
			if (limitEnabled && sessionDefeated >= killLimit && state == RunState.Running)
			{
				Stop("Kill target of " + killLimit + " reached.", NoticeLevel.Success);
			}
		}
	}

	private int CountNearbyMobs()
	{
		//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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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)
		if ((Object)(object)PlayerMovement.Instance == (Object)null || (Object)(object)MobManager.Instance == (Object)null || MobManager.Instance.mobs == null)
		{
			return 0;
		}
		int num = 0;
		Vector3 position = ((Component)PlayerMovement.Instance).transform.position;
		float num2 = spawnRadius * spawnRadius;
		foreach (Mob value in MobManager.Instance.mobs.Values)
		{
			if ((Object)(object)value != (Object)null)
			{
				Vector3 val = ((Component)value).transform.position - position;
				if (((Vector3)(ref val)).sqrMagnitude <= num2)
				{
					num++;
				}
			}
		}
		return num;
	}

	public bool ShouldBlockPlayerDamage()
	{
		return unlimitedHealth;
	}

	public bool ShouldBlockGameClicks()
	{
		return showGUI;
	}

	private static bool GodPowersAvailable()
	{
		if (!godPowersSearched)
		{
			godPowersSearched = true;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				Type type = assemblies[i].GetType("MuckGodPowers2.Abilitys.SuperSword", throwOnError: false);
				if (type != null)
				{
					godPowersGetWeapon = type.GetMethod("GetWeapon", BindingFlags.Static | BindingFlags.Public);
					break;
				}
			}
		}
		return godPowersGetWeapon != null;
	}

	private static bool IsGodSword(InventoryItem item)
	{
		if ((Object)(object)item != (Object)null)
		{
			return item.name == "God Sword";
		}
		return false;
	}

	private InventoryCell[] HotbarCells()
	{
		InventoryUI instance = InventoryUI.Instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.hotkeysTransform == (Object)null)
		{
			return null;
		}
		return ((Component)instance.hotkeysTransform).GetComponentsInChildren<InventoryCell>(true);
	}

	private InventoryCell FindGodSwordCell()
	{
		InventoryUI instance = InventoryUI.Instance;
		if ((Object)(object)instance == (Object)null || instance.cells == null)
		{
			return null;
		}
		foreach (InventoryCell cell in instance.cells)
		{
			if ((Object)(object)cell != (Object)null && IsGodSword(cell.currentItem))
			{
				return cell;
			}
		}
		return null;
	}

	private InventoryItem CreateGodSword()
	{
		Dictionary<int, InventoryItem> dictionary = ItemDatabase();
		if (dictionary == null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"God Sword: item database not found.");
			return null;
		}
		if (GodPowersAvailable())
		{
			try
			{
				godPowersGetWeapon.Invoke(null, null);
				InventoryCell val = FindGodSwordCell();
				if ((Object)(object)val != (Object)null)
				{
					InventoryItem currentItem = val.currentItem;
					val.currentItem = null;
					val.UpdateCell();
					return currentItem;
				}
				if (dictionary.TryGetValue(142, out var value) && IsGodSword(value))
				{
					InventoryItem obj = ScriptableObject.CreateInstance<InventoryItem>();
					obj.Copy(value, 1);
					return obj;
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Muck God Powers GetWeapon failed, using fallback sword: " + ex.Message));
			}
		}
		if (!dictionary.TryGetValue(142, out var value2) || (Object)(object)value2 == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("God Sword: base item " + 142 + " missing from item database."));
			return null;
		}
		InventoryItem obj2 = ScriptableObject.CreateInstance<InventoryItem>();
		obj2.Copy(value2, 1);
		obj2.name = "God Sword";
		obj2.description = "The most powerful sword in Muck.";
		obj2.attackDamage = 500;
		obj2.attackRange = 15f;
		obj2.attackSpeed = 10f;
		return obj2;
	}

	private bool EnsureGodSwordEquipped()
	{
		InventoryCell[] array = HotbarCells();
		if (array == null || array.Length == 0 || (Object)(object)Hotbar.Instance == (Object)null || (Object)(object)PlayerMovement.Instance == (Object)null)
		{
			return false;
		}
		InventoryCell val = array[0];
		bool flag = false;
		if (!IsGodSword(val.currentItem))
		{
			InventoryCell val2 = FindGodSwordCell();
			InventoryItem val3;
			if ((Object)(object)val2 != (Object)null)
			{
				val3 = val2.currentItem;
				val2.currentItem = null;
				val2.UpdateCell();
			}
			else
			{
				val3 = CreateGodSword();
			}
			if ((Object)(object)val3 == (Object)null)
			{
				Notify("Couldn't create a God Sword — retrying…", NoticeLevel.Error);
				return false;
			}
			if ((Object)(object)val.currentItem != (Object)null)
			{
				InventoryItem currentItem = val.currentItem;
				if ((Object)(object)InventoryUI.Instance != (Object)null)
				{
					InventoryUI.Instance.DropItemIntoWorld(currentItem);
				}
				Notify("Dropped " + currentItem.name + " (x" + currentItem.amount + ") to make room for the God Sword.", NoticeLevel.Warning);
			}
			val.currentItem = val3;
			val.UpdateCell();
			flag = true;
		}
		Traverse val4 = Traverse.Create((object)Hotbar.Instance).Field("currentActive");
		if (flag || val4.GetValue<int>() != 0)
		{
			val4.SetValue((object)0);
			Hotbar.Instance.UpdateHotbar();
		}
		if (flag)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"God Sword equipped in slot 1.");
		}
		return IsGodSword(array[0].currentItem);
	}

	private Mob FindNearestMob(Vector3 from, float maxDistance)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)MobManager.Instance == (Object)null || MobManager.Instance.mobs == null)
		{
			return null;
		}
		Mob result = null;
		float num = maxDistance * maxDistance;
		foreach (Mob value in MobManager.Instance.mobs.Values)
		{
			if (!((Object)(object)value == (Object)null) && ((Component)value).gameObject.activeInHierarchy)
			{
				Vector3 val = ((Component)value).transform.position - from;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					result = value;
				}
			}
		}
		return result;
	}

	private void GodSwordAttack()
	{
		//IL_007f: 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_0084: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: 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_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		aimActive = false;
		if ((Object)(object)PlayerMovement.Instance == (Object)null || (Object)(object)UseInventory.Instance == (Object)null || (Object)(object)Hotbar.Instance == (Object)null || !IsGodSword(Hotbar.Instance.currentItem) || (Object)(object)PlayerStatus.Instance == (Object)null || PlayerStatus.Instance.IsPlayerDead())
		{
			return;
		}
		Camera main = Camera.main;
		Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.position : ((Component)PlayerMovement.Instance).transform.position);
		float num = 1.2f + Hotbar.Instance.currentItem.attackRange + 3f;
		aimTarget = FindNearestMob(val, Mathf.Max(60f, spawnRadius * 2f));
		if (!((Object)(object)aimTarget == (Object)null))
		{
			Vector3 val2 = ((Component)aimTarget).transform.position + Vector3.up * 1.2f - val;
			if (autoAimEnabled && ((Vector3)(ref val2)).sqrMagnitude > 0.01f)
			{
				Quaternion val3 = Quaternion.LookRotation(val2);
				Vector3 eulerAngles = ((Quaternion)(ref val3)).eulerAngles;
				aimYaw = eulerAngles.y;
				aimPitch = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles.x), -89f, 89f);
				aimActive = true;
			}
			if (((Vector3)(ref val2)).magnitude <= num)
			{
				UseInventory.Instance.Use();
			}
		}
	}

	public void ApplyAim(PlayerInput input)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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)
		if (aimActive && state == RunState.Running && godSwordEnabled && !showGUI && !((Object)(object)input == (Object)null) && (int)Cursor.lockState != 0 && !OtherInput.lockCamera)
		{
			Traverse obj = Traverse.Create((object)input);
			float value = obj.Field("desiredX").GetValue<float>();
			float value2 = obj.Field("xRotation").GetValue<float>();
			float num = 900f * Time.deltaTime;
			value = Mathf.MoveTowardsAngle(value, aimYaw, num);
			value2 = Mathf.MoveTowards(value2, aimPitch, num);
			obj.Field("desiredX").SetValue((object)value);
			obj.Field("xRotation").SetValue((object)value2);
			input.cameraRot = new Vector3(value2, value, input.cameraRot.z);
			Transform value3 = obj.Field("orientation").GetValue<Transform>();
			if ((Object)(object)value3 != (Object)null)
			{
				value3.localRotation = Quaternion.Euler(0f, value, 0f);
			}
		}
	}

	private string WaveStatus()
	{
		switch (state)
		{
		case RunState.Stopped:
			return "Idle — press " + startKey?.ToString() + " or Start to begin.";
		case RunState.Paused:
			return "Paused — " + activeSpawned.Count + " spawned mobs still alive.";
		default:
		{
			if (!IsHost())
			{
				return "Waiting for host…";
			}
			if (godSwordEnabled && !swordReady)
			{
				return "Equipping God Sword in slot 1…";
			}
			if (spawnQueue > 0)
			{
				return "Spawning wave… " + spawnQueue + " to go.";
			}
			if (activeSpawned.Count > 0)
			{
				return "Wave in progress — " + activeSpawned.Count + " left to defeat.";
			}
			float num = nextSpawnTime - Time.time;
			if (!(num > 0.05f))
			{
				return "Spawning next wave…";
			}
			return "Next wave in " + num.ToString("0.0") + "s";
		}
		}
	}

	private void OnGUI()
	{
		//IL_006d: 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_0083: 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_009e: 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_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: 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_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		bool flag = !showGUI && showHud && (state != RunState.Stopped || NoticeActive() || (trackerEnabled && (Object)(object)PlayerMovement.Instance != (Object)null));
		if (!showGUI && !flag)
		{
			return;
		}
		if (ui == null)
		{
			ui = new Ui();
		}
		ui.EnsureBuilt();
		GUISkin skin = GUI.skin;
		Matrix4x4 matrix = GUI.matrix;
		GUI.skin = ui.Skin;
		GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(uiScale, uiScale, 1f));
		if (showGUI)
		{
			if (draggingWindow)
			{
				if (Input.GetMouseButton(0))
				{
					Vector2 val = new Vector2(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y) / uiScale;
					((Rect)(ref windowRect)).x = val.x - dragOffset.x;
					((Rect)(ref windowRect)).y = val.y - dragOffset.y;
				}
				else
				{
					draggingWindow = false;
				}
			}
			if (resizingWindow)
			{
				if (Input.GetMouseButton(0))
				{
					Vector2 val2 = new Vector2(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y) / uiScale - resizeStartMouse;
					WindowWidth = Mathf.Clamp(Mathf.Round(resizeStartSize.x + val2.x), 480f, 1200f);
					ContentHeight = Mathf.Clamp(Mathf.Round(resizeStartSize.y + val2.y), 150f, 1000f);
					((Rect)(ref windowRect)).height = 0f;
				}
				else
				{
					resizingWindow = false;
				}
			}
			Color color = GUI.color;
			GUI.color = new Color(color.r, color.g, color.b, windowOpacity);
			((Rect)(ref windowRect)).width = WindowWidth;
			windowRect = GUILayout.Window(1296519758, windowRect, new WindowFunction(DrawWindow), GUIContent.none, ui.Window, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(WindowWidth) });
			GUI.color = color;
			float num = (float)Screen.width / uiScale;
			float num2 = (float)Screen.height / uiScale;
			((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, num - ((Rect)(ref windowRect)).width));
			((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, num2 - 40f));
		}
		else
		{
			DrawHud();
		}
		GUI.matrix = matrix;
		GUI.skin = skin;
	}

	private bool NoticeActive()
	{
		if (!string.IsNullOrEmpty(notice))
		{
			return Time.unscaledTime < noticeUntil;
		}
		return false;
	}

	private void DrawWindow(int id)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Invalid comparison between Unknown and I4
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Invalid comparison between Unknown and I4
		//IL_00a0: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Invalid comparison between Unknown and I4
		//IL_01f9: 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_004a: Invalid comparison between Unknown and I4
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Invalid comparison between Unknown and I4
		//IL_02b1: 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_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = new Color(1f, 1f, 1f, windowOpacity);
		Event current = Event.current;
		if ((int)current.type == 4 && GUIUtility.keyboardControl != 0 && ((int)current.keyCode == 13 || (int)current.keyCode == 271 || (int)current.keyCode == 27))
		{
			GUI.FocusControl((string)null);
			current.Use();
		}
		Rect val = DrawHeader();
		GUILayout.Space(10f);
		DrawControlBar();
		if (!compact)
		{
			GUILayout.Space(10f);
			DrawTabs();
			GUILayout.Space(6f);
			contentScroll = GUILayout.BeginScrollView(contentScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(ContentHeight) });
			switch (activeTab)
			{
			case Tab.Spawn:
				DrawMobsTab();
				DrawSpawningTab();
				DrawKillTargetSection();
				DrawStatsSection();
				break;
			case Tab.Combat:
				DrawCombatTab();
				break;
			case Tab.Settings:
				DrawSettingsTab();
				break;
			}
			GUILayout.EndScrollView();
		}
		GUILayout.Space(8f);
		DrawFooter();
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((Rect)(ref windowRect)).width - 16f - 2f, ((Rect)(ref windowRect)).height - 16f - 2f, 16f, 16f);
		if ((int)current.type == 7)
		{
			for (int i = 0; i < 3; i++)
			{
				for (int j = 2 - i; j < 3; j++)
				{
					Ui.DrawRect(new Rect(((Rect)(ref val2)).x + 3f + (float)(j * 4), ((Rect)(ref val2)).y + 3f + (float)(i * 4), 2f, 2f), (resizingWindow || ((Rect)(ref val2)).Contains(current.mousePosition)) ? ui.AccentTex : ui.BorderTex);
				}
			}
		}
		if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref val2)).Contains(current.mousePosition))
		{
			resizingWindow = true;
			resizeStartMouse = new Vector2(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y) / uiScale;
			resizeStartSize = new Vector2(WindowWidth, ContentHeight);
			GUI.FocusControl((string)null);
			current.Use();
		}
		if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
		{
			draggingWindow = true;
			dragOffset = current.mousePosition;
			GUI.FocusControl((string)null);
			current.Use();
		}
		if ((int)current.type == 0)
		{
			GUI.FocusControl((string)null);
		}
	}

	private Rect DrawHeader()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Expected O, but got Unknown
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("MUCKINATOR GRIND", ui.Title, Array.Empty<GUILayoutOption>());
		GUILayout.Label("v1.0.0", ui.Muted, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		GUILayout.FlexibleSpace();
		DrawStatePill();
		GUILayout.Space(8f);
		if (GUILayout.Button(new GUIContent(compact ? "+" : "–", compact ? "Expand" : "Collapse to controls only"), ui.IconButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(26f),
			GUILayout.Height(24f)
		}))
		{
			compact = !compact;
			((Rect)(ref windowRect)).height = 0f;
		}
		if (GUILayout.Button(new GUIContent("×", "Close menu (" + menuKey?.ToString() + ")"), ui.IconButtonDanger, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(26f),
			GUILayout.Height(24f)
		}))
		{
			SetMenuVisible(visible: false);
		}
		GUILayout.EndHorizontal();
		Rect lastRect = GUILayoutUtility.GetLastRect();
		Ui.DrawRect(new Rect(((Rect)(ref lastRect)).x - 12f, ((Rect)(ref lastRect)).yMax + 6f, ((Rect)(ref lastRect)).width + 24f, 1f), ui.BorderTex);
		return new Rect(0f, 0f, 10000f, ((Rect)(ref lastRect)).yMax + 6f);
	}

	private void DrawStatePill()
	{
		switch (state)
		{
		case RunState.Running:
			GUILayout.Label("● RUNNING", ui.PillGreen, Array.Empty<GUILayoutOption>());
			break;
		case RunState.Paused:
			GUILayout.Label("● PAUSED", ui.PillAmber, Array.Empty<GUILayoutOption>());
			break;
		default:
			GUILayout.Label("■ STOPPED", ui.PillGray, Array.Empty<GUILayoutOption>());
			break;
		}
	}

	private void DrawControlBar()
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Expected O, but got Unknown
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		if (!IsHost())
		{
			Banner("Not hosting — spawning only works when you are the lobby host.", ui.BannerError);
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		string text;
		string text2;
		GUIStyle val;
		switch (state)
		{
		case RunState.Running:
			text = "PAUSE";
			text2 = "Pause spawning and auto-click. Mobs and stats are kept.";
			val = ui.ButtonWarning;
			break;
		case RunState.Paused:
			text = "RESUME";
			text2 = "Continue the current session.";
			val = ui.ButtonPrimary;
			break;
		default:
			text = "START";
			text2 = "Start a new session (resets session stats).";
			val = ui.ButtonPrimary;
			break;
		}
		GUI.enabled = IsHost() || state == RunState.Running;
		if (GUILayout.Button(new GUIContent(text + "