Decompiled source of Utility Mod v2.4.0

UMM/Mods/Utility Mod/Utility Mod.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using HarmonyLib;
using RocketLib;
using RocketLib.Loggers;
using RocketLib.Settings;
using RocketLib.UMM;
using RocketLib.Utils;
using TFBGames.Management.Asset;
using TFBGames.Systems;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityModManagerNet;
using Utility;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Utility Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Utility Mod")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b81b6335-6838-4e83-bfa1-c667cd1e99e7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Utility_Mod;

public class ContextMenu
{
	private readonly List<MenuItem> items = new List<MenuItem>();

	private Vector2 position;

	private float width = 280f;

	private readonly float itemHeight = 28f;

	private readonly float padding = 5f;

	private int hoveredIndex = -1;

	private GUIStyle menuStyle;

	private GUIStyle itemStyle;

	private GUIStyle itemHoverStyle;

	private GUIStyle separatorStyle;

	private GUIStyle submenuArrowStyle;

	private GUIStyle headerStyle;

	private bool stylesInitialized;

	private bool widthCalculated;

	private static int windowIdCounter = 1000;

	private readonly int windowId;

	private ContextMenu activeSubmenu;

	private int submenuParentIndex = -1;

	public Action<MenuItem, bool> OnCheckboxToggled;

	public float Width => width;

	public Vector2 Position => position;

	public ContextMenu()
	{
		windowId = windowIdCounter++;
	}

	public void InvalidateStyles()
	{
		stylesInitialized = false;
		widthCalculated = false;
	}

	private void InitializeStyles()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Expected O, but got Unknown
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Expected O, but got Unknown
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Expected O, but got Unknown
		//IL_017e: 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)
		//IL_01b1: Expected O, but got Unknown
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Expected O, but got Unknown
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Expected O, but got Unknown
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		Settings settings = Main.settings;
		menuStyle = new GUIStyle(GUI.skin.box);
		menuStyle.normal.background = CreateTexture(2, 2, new Color(settings.menuBackgroundR, settings.menuBackgroundG, settings.menuBackgroundB, settings.menuBackgroundAlpha));
		menuStyle.border = new RectOffset(2, 2, 2, 2);
		menuStyle.padding = new RectOffset((int)padding, (int)padding, (int)padding, (int)padding);
		itemStyle = new GUIStyle(GUI.skin.label);
		itemStyle.normal.textColor = new Color(settings.menuTextR, settings.menuTextG, settings.menuTextB);
		itemStyle.fontSize = settings.menuFontSize;
		itemStyle.alignment = (TextAnchor)3;
		itemStyle.padding = new RectOffset(10, 10, 0, 0);
		itemStyle.wordWrap = false;
		itemHoverStyle = new GUIStyle(itemStyle);
		itemHoverStyle.normal.background = CreateTexture(2, 2, new Color(settings.menuHighlightR, settings.menuHighlightG, settings.menuHighlightB, settings.menuHighlightAlpha));
		separatorStyle = new GUIStyle();
		separatorStyle.normal.background = CreateTexture(2, 2, new Color(0.5f, 0.5f, 0.5f, 0.5f));
		separatorStyle.fixedHeight = 1f;
		separatorStyle.margin = new RectOffset(5, 5, 5, 5);
		submenuArrowStyle = new GUIStyle(itemStyle);
		submenuArrowStyle.alignment = (TextAnchor)5;
		submenuArrowStyle.padding = new RectOffset(0, 10, 0, 0);
		headerStyle = new GUIStyle(itemStyle);
		headerStyle.alignment = (TextAnchor)4;
		headerStyle.fontSize = itemStyle.fontSize;
		headerStyle.fontStyle = (FontStyle)0;
		headerStyle.normal.textColor = new Color(Main.settings.menuTextR * 0.8f, Main.settings.menuTextG * 0.8f, Main.settings.menuTextB * 0.8f);
	}

	private Texture2D CreateTexture(int width, int height, Color color)
	{
		//IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = color;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	public void SetPosition(Vector2 mousePosition)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		position = new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y);
	}

	public void AddItem(MenuItem item)
	{
		items.Add(item);
	}

	public void AddSeparator()
	{
		items.Add(MenuItem.CreateSeparator());
	}

	public List<MenuItem> GetItems()
	{
		return items;
	}

	public void Draw()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Expected O, but got Unknown
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		if (!stylesInitialized)
		{
			InitializeStyles();
			stylesInitialized = true;
		}
		if (!widthCalculated && stylesInitialized)
		{
			CalculateDynamicWidth();
			widthCalculated = true;
			float menuHeight = GetMenuHeight();
			if (position.x + width > (float)Screen.width)
			{
				position.x = (float)Screen.width - width - 10f;
			}
			if (position.y + menuHeight > (float)Screen.height)
			{
				position.y = (float)Screen.height - menuHeight - 10f;
			}
		}
		float menuHeight2 = GetMenuHeight();
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(position.x, position.y, width, menuHeight2);
		GUI.Window(windowId, val, new WindowFunction(DrawWindow), "", GUIStyle.none);
		if (activeSubmenu != null)
		{
			activeSubmenu.Draw();
		}
	}

	public void CalculateWidthOnly()
	{
		if (!stylesInitialized)
		{
			InitializeStyles();
			stylesInitialized = true;
		}
		if (!widthCalculated)
		{
			CalculateDynamicWidth();
			widthCalculated = true;
		}
	}

	private void DrawWindow(int id)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Expected O, but got Unknown
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Expected O, but got Unknown
		float menuHeight = GetMenuHeight();
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(0f, 0f, width, menuHeight);
		GUI.Box(val, "", menuStyle);
		UpdateHoveredIndex(val);
		if (hoveredIndex >= 0 && hoveredIndex < items.Count && items[hoveredIndex].HasSubMenu && submenuParentIndex != hoveredIndex)
		{
			CloseSubmenu();
			OpenSubmenu(hoveredIndex);
			submenuParentIndex = hoveredIndex;
		}
		float num = padding;
		Rect val2 = default(Rect);
		for (int i = 0; i < items.Count; i++)
		{
			MenuItem menuItem = items[i];
			if (menuItem.IsSeparator)
			{
				GUI.Box(new Rect(padding, num + itemHeight / 2f, width - padding * 2f, 1f), "", separatorStyle);
				num += itemHeight;
				continue;
			}
			((Rect)(ref val2))..ctor(padding, num, width - padding * 2f, itemHeight);
			bool flag = i == hoveredIndex && !menuItem.IsHeader;
			GUIStyle val3 = (flag ? itemHoverStyle : itemStyle);
			if (menuItem.MultiButtons != null && menuItem.MultiButtons.Count > 0)
			{
				float num3 = (((Rect)(ref val2)).height = 40f);
				if (flag)
				{
					GUI.Box(val2, "", itemHoverStyle);
				}
				GUIStyle val4 = new GUIStyle(GUI.skin.button);
				val4.fontSize = 24;
				val4.alignment = (TextAnchor)4;
				val4.normal.textColor = new Color(Main.settings.menuTextR, Main.settings.menuTextG, Main.settings.menuTextB);
				float num4 = 60f;
				float num5 = 8f;
				float num6 = (float)menuItem.MultiButtons.Count * num4 + (float)(menuItem.MultiButtons.Count - 1) * num5;
				float num7 = ((Rect)(ref val2)).x + (((Rect)(ref val2)).width - num6) / 2f;
				float num8 = ((Rect)(ref val2)).y + 4f;
				float num9 = num3 - 8f;
				for (int j = 0; j < menuItem.MultiButtons.Count; j++)
				{
					MenuItem.ButtonInfo buttonInfo = menuItem.MultiButtons[j];
					if (GUI.Button(new Rect(num7 + (float)j * (num4 + num5), num8, num4, num9), new GUIContent(buttonInfo.Text, buttonInfo.Tooltip), val4))
					{
						buttonInfo.OnClick?.Invoke();
					}
				}
				num += num3;
				continue;
			}
			if (menuItem.ShowCheckbox)
			{
				float num10 = 20f;
				bool flag2 = GUI.Toggle(new Rect(padding, num + (itemHeight - num10) / 2f, num10, num10), menuItem.IsChecked, "");
				if (flag2 != menuItem.IsChecked)
				{
					if (menuItem.IsToggleAction)
					{
						menuItem.IsChecked = flag2;
						menuItem.OnToggle?.Invoke(flag2);
					}
					else
					{
						OnCheckboxToggled?.Invoke(menuItem, flag2);
					}
				}
				((Rect)(ref val2)).x = ((Rect)(ref val2)).x + (num10 + 5f);
				((Rect)(ref val2)).width = ((Rect)(ref val2)).width - (num10 + 5f);
			}
			if (menuItem.IsHeader)
			{
				GUI.Label(val2, menuItem.Text, headerStyle);
			}
			else if (!menuItem.Enabled)
			{
				GUIStyle val5 = new GUIStyle(itemStyle);
				val5.normal.textColor = new Color(itemStyle.normal.textColor.r * 0.5f, itemStyle.normal.textColor.g * 0.5f, itemStyle.normal.textColor.b * 0.5f, 0.7f);
				GUI.Label(val2, menuItem.Text, val5);
			}
			else if (GUI.Button(val2, menuItem.Text, val3) && !menuItem.HasSubMenu)
			{
				if ((Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) && menuItem.MenuAction != null && !menuItem.IsToggleAction)
				{
					OnCheckboxToggled?.Invoke(menuItem, arg2: true);
				}
				menuItem.OnClick?.Invoke();
			}
			if (menuItem.HasSubMenu)
			{
				GUI.Label(val2, "►", submenuArrowStyle);
			}
			num += itemHeight;
		}
	}

	public float GetMenuHeight()
	{
		float num = padding * 2f;
		foreach (MenuItem item in items)
		{
			num = ((item.MultiButtons == null || item.MultiButtons.Count <= 0) ? (num + itemHeight) : (num + 40f));
		}
		return num;
	}

	private void CalculateDynamicWidth()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		float num = 0f;
		float num2 = 30f;
		float num3 = 30f;
		float num4 = 200f;
		float num5 = 40f;
		foreach (MenuItem item in items)
		{
			if (!item.IsSeparator)
			{
				GUIContent val = new GUIContent(item.Text);
				float num6 = itemStyle.CalcSize(val).x;
				if (item.ShowCheckbox)
				{
					num6 += num2;
				}
				if (item.HasSubMenu)
				{
					num6 += num3;
				}
				num = Mathf.Max(num, num6);
			}
		}
		width = Mathf.Max(num4, num + num5 + padding * 2f);
		float num7 = (float)Screen.width * 0.4f;
		width = Mathf.Min(width, num7);
	}

	private void UpdateHoveredIndex(Rect localMenuRect)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		Vector2 mousePosition = Event.current.mousePosition;
		if (activeSubmenu != null && activeSubmenu.IsMouseOver())
		{
			hoveredIndex = -1;
			return;
		}
		if (!((Rect)(ref localMenuRect)).Contains(mousePosition))
		{
			hoveredIndex = -1;
			return;
		}
		float num = mousePosition.y - padding;
		float num2 = 0f;
		hoveredIndex = -1;
		for (int i = 0; i < items.Count; i++)
		{
			float num3 = ((items[i].MultiButtons != null && items[i].MultiButtons.Count > 0) ? 40f : itemHeight);
			if (num >= num2 && num < num2 + num3 && !items[i].IsSeparator && !items[i].IsHeader && items[i].Enabled)
			{
				hoveredIndex = i;
				break;
			}
			num2 += num3;
		}
	}

	public bool IsMouseOver()
	{
		//IL_002d: 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_004f: Unknown result type (might be due to invalid IL or missing references)
		float menuHeight = GetMenuHeight();
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(position.x, position.y, width, menuHeight);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y);
		bool flag = ((Rect)(ref val)).Contains(val2);
		if (!flag && activeSubmenu != null)
		{
			return activeSubmenu.IsMouseOver();
		}
		return flag;
	}

	private bool IsMouseOverSubmenu()
	{
		if (activeSubmenu != null)
		{
			return activeSubmenu.IsMouseOver();
		}
		return false;
	}

	private void OpenSubmenu(int parentIndex)
	{
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		if (parentIndex < 0 || parentIndex >= items.Count || !items[parentIndex].HasSubMenu)
		{
			return;
		}
		activeSubmenu = new ContextMenu();
		activeSubmenu.OnCheckboxToggled = OnCheckboxToggled;
		foreach (MenuItem subItem in items[parentIndex].SubItems)
		{
			if (subItem.IsSeparator)
			{
				activeSubmenu.AddSeparator();
			}
			else
			{
				activeSubmenu.AddItem(subItem);
			}
		}
		float num = Position.y + padding;
		for (int i = 0; i < parentIndex; i++)
		{
			num = ((items[i].MultiButtons == null || items[i].MultiButtons.Count <= 0) ? (num + itemHeight) : (num + 40f));
		}
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(Position.x + width - 5f, num);
		activeSubmenu.SetPosition(new Vector2(val.x, (float)Screen.height - val.y));
		activeSubmenu.CalculateWidthOnly();
		float menuHeight = activeSubmenu.GetMenuHeight();
		if (val.x + activeSubmenu.Width > (float)Screen.width)
		{
			val.x = Position.x - activeSubmenu.Width + 5f;
		}
		if (val.y + menuHeight > (float)Screen.height)
		{
			val.y = (float)Screen.height - menuHeight - 10f;
		}
		activeSubmenu.SetPosition(new Vector2(val.x, (float)Screen.height - val.y));
	}

	private void CloseSubmenu()
	{
		activeSubmenu = null;
		submenuParentIndex = -1;
	}
}
public class ContextMenuManager : MonoBehaviour
{
	public enum ContextMenuMode
	{
		Normal,
		Clone,
		ZiplinePlacement,
		Grab,
		MassDelete
	}

	private ContextMenuBuilder builder;

	public ContextMenuModes modes;

	private ContextMenuUI ui;

	private static ContextMenuManager instance;

	public bool isMenuOpen;

	private float rightClickHoldTime;

	private bool isHoldingRightClick;

	private Vector2 menuOpenPosition;

	private ModEntry mod;

	public MenuAction lastExecutedAction;

	private string quickActionFeedback = "";

	private float quickActionFeedbackTimer;

	private const float FEEDBACK_DISPLAY_TIME = 2f;

	private static Dictionary<string, Dictionary<string, Block>> themeBlockCaches;

	private static Dictionary<string, GameObject> boulderPrefabCache;

	public ContextMenuMode CurrentMode { get; set; }

	public ContextMenu CurrentMenu { get; private set; }

	public static ContextMenuManager Instance => instance;

	public ZiplinePoint PendingZiplinePoint
	{
		get
		{
			return modes?.pendingZiplinePoint;
		}
		set
		{
			if (modes != null)
			{
				modes.pendingZiplinePoint = value;
			}
		}
	}

	public Vector3 FirstZiplinePosition
	{
		get
		{
			//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)
			return modes?.firstZiplinePosition ?? Vector3.zero;
		}
		set
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (modes != null)
			{
				modes.firstZiplinePosition = value;
			}
		}
	}

	public Unit unitToClone
	{
		get
		{
			return modes?.unitToClone;
		}
		set
		{
			if (modes != null)
			{
				modes.unitToClone = value;
			}
		}
	}

	public Block blockToClone
	{
		get
		{
			return modes?.blockToClone;
		}
		set
		{
			if (modes != null)
			{
				modes.blockToClone = value;
			}
		}
	}

	public Unit grabbedUnit
	{
		get
		{
			return modes?.grabbedUnit;
		}
		set
		{
			if (modes != null)
			{
				modes.grabbedUnit = value;
			}
		}
	}

	private void Awake()
	{
		instance = this;
		mod = Main.mod;
		builder = new ContextMenuBuilder(this);
		modes = new ContextMenuModes(this);
		ui = new ContextMenuUI(this);
	}

	private void OnDestroy()
	{
		if ((Object)(object)instance == (Object)(object)this)
		{
			instance = null;
		}
	}

	private void Update()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
		if (!Main.enabled)
		{
			return;
		}
		if (quickActionFeedbackTimer > 0f)
		{
			quickActionFeedbackTimer -= Time.unscaledDeltaTime;
		}
		if (ui.showHelpDialog || !ShouldProcessInput())
		{
			return;
		}
		if (CurrentMode == ContextMenuMode.ZiplinePlacement)
		{
			if (Input.GetMouseButtonDown(1))
			{
				Vector3 mouseWorldPosition = GetMouseWorldPosition();
				modes.HandleZiplinePlacement(mouseWorldPosition);
				return;
			}
			if (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(0))
			{
				CurrentMode = ContextMenuMode.Normal;
				modes.pendingZiplinePoint = null;
				return;
			}
		}
		if (CurrentMode == ContextMenuMode.Clone)
		{
			if (Input.GetMouseButtonDown(1))
			{
				Vector3 mouseWorldPosition2 = GetMouseWorldPosition();
				if ((Object)(object)modes.unitToClone != (Object)null)
				{
					UnitType unitType = UnitTypes.GetUnitType(modes.unitToClone);
					Main.SpawnUnit(unitType, mouseWorldPosition2);
					if (Main.settings.isRecordingLevelEdits)
					{
						MenuAction action = MenuAction.CreateSpawnEnemy(unitType);
						ui.TrackLevelEdit(action, mouseWorldPosition2);
					}
				}
				else
				{
					if (!((Object)(object)modes.blockToClone != (Object)null))
					{
						return;
					}
					Vector3 position = default(Vector3);
					((Vector3)(ref position))..ctor(Mathf.Round(mouseWorldPosition2.x / 16f) * 16f, Mathf.Round(mouseWorldPosition2.y / 16f) * 16f, 0f);
					if (TryCloneBlockExact(modes.blockToClone, position))
					{
						return;
					}
					BlockType? blockTypeFromGroundType = GetBlockTypeFromGroundType(modes.blockToClone.groundType, modes.blockToClone);
					if (blockTypeFromGroundType.HasValue)
					{
						Main.SpawnBlock(position, blockTypeFromGroundType.Value);
						if (Main.settings.isRecordingLevelEdits)
						{
							MenuAction action2 = MenuAction.CreateSpawnBlock(blockTypeFromGroundType.Value);
							ui.TrackLevelEdit(action2, position);
						}
					}
				}
				return;
			}
			if (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(0))
			{
				modes.ExitCloneMode();
				return;
			}
		}
		if (CurrentMode == ContextMenuMode.Grab)
		{
			if ((Object)(object)modes.grabbedUnit != (Object)null && !((BroforceObject)modes.grabbedUnit).destroyed && ((BroforceObject)modes.grabbedUnit).health > 0)
			{
				((BroforceObject)modes.grabbedUnit).xI = 0f;
				((BroforceObject)modes.grabbedUnit).yI = 0f;
				modes.grabbedUnit.invulnerable = true;
				if (Input.GetMouseButtonDown(1))
				{
					modes.ReleaseGrabbedUnit();
					return;
				}
				if (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(0))
				{
					modes.ReleaseGrabbedUnit();
					return;
				}
			}
			else
			{
				CurrentMode = ContextMenuMode.Normal;
				modes.ReleaseGrabbedUnit();
				modes.grabbedUnit = null;
			}
		}
		if (CurrentMode == ContextMenuMode.MassDelete)
		{
			if (Input.GetMouseButtonDown(0))
			{
				modes.massDeleteStartPos = GetMouseWorldPosition();
				modes.isDraggingMassDelete = true;
			}
			else if (Input.GetMouseButtonUp(0) && modes.isDraggingMassDelete)
			{
				Vector3 mouseWorldPosition3 = GetMouseWorldPosition();
				modes.ExecuteMassDelete(modes.massDeleteStartPos, mouseWorldPosition3);
				CurrentMode = ContextMenuMode.Normal;
				modes.isDraggingMassDelete = false;
			}
			else if (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(1))
			{
				CurrentMode = ContextMenuMode.Normal;
				modes.isDraggingMassDelete = false;
			}
		}
		HandleContextMenuInput();
		if (CurrentMode == ContextMenuMode.ZiplinePlacement && (Object)(object)modes.pendingZiplinePoint == (Object)null)
		{
			CurrentMode = ContextMenuMode.Normal;
		}
	}

	private void LateUpdate()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		if (CurrentMode == ContextMenuMode.Grab && (Object)(object)modes.grabbedUnit != (Object)null && !((BroforceObject)modes.grabbedUnit).destroyed && ((BroforceObject)modes.grabbedUnit).health > 0)
		{
			Vector3 mouseWorldPosition = GetMouseWorldPosition();
			mouseWorldPosition.y -= 2f * modes.grabbedUnit.height;
			((BroforceObject)modes.grabbedUnit).X = mouseWorldPosition.x;
			((BroforceObject)modes.grabbedUnit).Y = mouseWorldPosition.y;
			((BroforceObject)modes.grabbedUnit).xI = 0f;
			((BroforceObject)modes.grabbedUnit).yI = 0f;
			((Component)modes.grabbedUnit).transform.position = mouseWorldPosition;
			((Component)modes.grabbedUnit).transform.rotation = Quaternion.identity;
		}
	}

	private void OnGUI()
	{
		if (!Main.enabled)
		{
			return;
		}
		if (isMenuOpen && CurrentMenu != null)
		{
			try
			{
				CurrentMenu.Draw();
			}
			catch
			{
				CloseMenu();
			}
		}
		if (ui.showHelpDialog)
		{
			ui.DrawHelpDialog();
		}
		if (Main.settings.showHoldProgressIndicator && IsHoldingForMenu() && !isMenuOpen)
		{
			DrawHoldProgressIndicator();
		}
		if (CurrentMode == ContextMenuMode.ZiplinePlacement && (Object)(object)modes.pendingZiplinePoint != (Object)null)
		{
			modes.DrawZiplinePreview();
		}
		if (CurrentMode == ContextMenuMode.Clone)
		{
			modes.DrawCloneModeUI();
		}
		if (CurrentMode == ContextMenuMode.Grab)
		{
			modes.DrawGrabModeUI();
		}
		if (CurrentMode == ContextMenuMode.MassDelete)
		{
			modes.DrawMassDeleteUI();
		}
		if (quickActionFeedbackTimer > 0f && !string.IsNullOrEmpty(quickActionFeedback))
		{
			DrawQuickActionFeedback();
		}
		ContextMenuBuilder.DrawProfileNameDialog();
	}

	private bool ShouldProcessInput()
	{
		if (!Main.settings.contextMenuEnabled)
		{
			return false;
		}
		return true;
	}

	private void HandleContextMenuInput()
	{
		bool mouseButtonDown = Input.GetMouseButtonDown(1);
		bool mouseButton = Input.GetMouseButton(1);
		bool mouseButtonUp = Input.GetMouseButtonUp(1);
		if (mouseButtonDown)
		{
			_ = mod;
		}
		if (isMenuOpen && CurrentMode == ContextMenuMode.Normal && (Input.GetMouseButtonDown(0) || Input.GetKeyDown((KeyCode)27)) && !IsMouseOverMenu())
		{
			CloseMenu();
		}
		else if (Main.settings.contextMenuEnabled)
		{
			HandleEnabledMode(mouseButtonDown, mouseButton, mouseButtonUp);
		}
	}

	private void HandleEnabledMode(bool pressed, bool held, bool released)
	{
		if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
		{
			modes.HandlePaintMode(pressed, held, released);
		}
		else if (pressed && isMenuOpen && CurrentMode == ContextMenuMode.Normal)
		{
			if (lastExecutedAction != null)
			{
				ExecuteAction(lastExecutedAction, useCurrentMousePosition: true);
			}
		}
		else if (pressed && !isMenuOpen)
		{
			isHoldingRightClick = true;
			rightClickHoldTime = 0f;
		}
		else if (held && isHoldingRightClick)
		{
			rightClickHoldTime += Time.unscaledDeltaTime;
			if (rightClickHoldTime >= Main.settings.contextMenuHoldDuration && !isMenuOpen)
			{
				OpenMenu();
				isHoldingRightClick = false;
			}
		}
		else
		{
			if (!released)
			{
				return;
			}
			if (isHoldingRightClick && !isMenuOpen && rightClickHoldTime < Main.settings.contextMenuHoldDuration)
			{
				if (Main.settings.selectedQuickAction != null)
				{
					ExecuteAction(Main.settings.selectedQuickAction, useCurrentMousePosition: true);
				}
				else
				{
					OpenMenu();
				}
			}
			isHoldingRightClick = false;
			rightClickHoldTime = 0f;
		}
	}

	private void OpenMenu()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		if (isMenuOpen)
		{
			return;
		}
		try
		{
			CurrentMenu = new ContextMenu();
			CurrentMenu.OnCheckboxToggled = HandleCheckboxToggled;
			builder.BuildMenuItems();
			menuOpenPosition = Vector2.op_Implicit(Input.mousePosition);
			CurrentMenu.SetPosition(menuOpenPosition);
			isMenuOpen = true;
		}
		catch
		{
			isMenuOpen = false;
			CurrentMenu = null;
		}
	}

	public void CloseMenu()
	{
		if (isMenuOpen)
		{
			isMenuOpen = false;
			CurrentMenu = null;
		}
	}

	private bool IsMouseOverMenu()
	{
		if (CurrentMenu == null)
		{
			return false;
		}
		return CurrentMenu.IsMouseOver();
	}

	private void HandleCheckboxToggled(MenuItem item, bool isChecked)
	{
		if (isChecked)
		{
			Main.settings.selectedQuickAction = item.MenuAction;
			if (Main.settings.selectedQuickAction != null)
			{
				Main.settings.selectedQuickAction.TargetUnit = null;
				Main.settings.selectedQuickAction.TargetBlock = null;
			}
			if (CurrentMenu != null)
			{
				UpdateCheckboxStates(CurrentMenu.GetItems(), item.ActionId);
			}
			if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307))
			{
				ShowQuickActionFeedback(item.Text, wasSet: true);
			}
		}
		else if (Main.settings.selectedQuickAction != null && Main.settings.selectedQuickAction.Id == item.ActionId)
		{
			Main.settings.selectedQuickAction = null;
			ShowQuickActionFeedback(item.Text, wasSet: false);
		}
		item.IsChecked = isChecked;
	}

	private void ShowQuickActionFeedback(string actionName, bool wasSet)
	{
		if (wasSet)
		{
			quickActionFeedback = "Quick action set: " + actionName;
		}
		else
		{
			quickActionFeedback = "Quick action cleared";
		}
		quickActionFeedbackTimer = 2f;
	}

	private void DrawQuickActionFeedback()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0047: 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_0061: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp01(quickActionFeedbackTimer / 2f);
		GUIStyle val = new GUIStyle(GUI.skin.label);
		val.fontSize = 28;
		val.alignment = (TextAnchor)4;
		val.normal.textColor = new Color(1f, 1f, 1f, num);
		GUIStyle val2 = new GUIStyle(GUI.skin.box);
		val2.normal.background = CreateTexture(2, 2, new Color(0f, 0f, 0f, 0.8f * num));
		Rect val3 = new Rect((float)(Screen.width / 2 - 300), 100f, 600f, 70f);
		GUI.Box(val3, "", val2);
		GUI.Label(val3, quickActionFeedback, val);
	}

	private Texture2D CreateTexture(int width, int height, Color color)
	{
		//IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = color;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private void DrawHoldProgressIndicator()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		float holdProgress = GetHoldProgress();
		if (!(holdProgress <= 0f))
		{
			Vector2 mousePosition = Event.current.mousePosition;
			float num = 20f;
			float thickness = 3f;
			int segments = 32;
			float startAngle = -90f;
			float arcAngle = holdProgress * 360f;
			Vector2 center = default(Vector2);
			((Vector2)(ref center))..ctor(mousePosition.x + num + 10f, mousePosition.y);
			GUI.color = new Color(0.2f, 0.2f, 0.2f, 0.5f);
			DrawCircularProgress(center, num, thickness, 0f, 360f, segments);
			GUI.color = new Color(1f, 1f, 1f, 0.8f);
			DrawCircularProgress(center, num, thickness, startAngle, arcAngle, segments);
			GUI.color = Color.white;
		}
	}

	private void DrawCircularProgress(Vector2 center, float radius, float thickness, float startAngle, float arcAngle, int segments)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0088: 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)
		if (!(arcAngle <= 0f))
		{
			Matrix4x4 matrix = GUI.matrix;
			int num = Mathf.Max(1, Mathf.RoundToInt((float)segments * (arcAngle / 360f)));
			float num2 = arcAngle / (float)num;
			for (int i = 0; i < num; i++)
			{
				float num3 = startAngle + (float)i * num2;
				float num4 = num3 * ((float)Math.PI / 180f);
				Vector2 val = center + new Vector2(Mathf.Cos(num4), Mathf.Sin(num4)) * radius;
				GUIUtility.RotateAroundPivot(num3 + 90f, val);
				GUI.DrawTexture(new Rect(val.x - thickness / 2f, val.y, thickness, thickness), (Texture)(object)Texture2D.whiteTexture);
				GUI.matrix = matrix;
			}
		}
	}

	private void UpdateCheckboxStates(List<MenuItem> items, string selectedActionId)
	{
		foreach (MenuItem item in items)
		{
			if (item.ShowCheckbox && item.ActionId != selectedActionId)
			{
				item.IsChecked = false;
			}
			if (item.HasSubMenu)
			{
				UpdateCheckboxStates(item.SubItems, selectedActionId);
			}
		}
	}

	public void UpdateSpawnToggleStates(List<MenuItem> items)
	{
		foreach (MenuItem item in items)
		{
			if (item.Text == "Spawn at Custom Waypoint")
			{
				item.IsChecked = Main.settings.changeSpawn;
			}
			else if (item.Text == "Spawn at Final Checkpoint")
			{
				item.IsChecked = Main.settings.changeSpawnFinal;
			}
			if (item.HasSubMenu)
			{
				UpdateSpawnToggleStates(item.SubItems);
			}
		}
	}

	public void ExecuteAction(MenuAction action, bool useCurrentMousePosition = false)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		if (action == null)
		{
			return;
		}
		lastExecutedAction = action;
		AddToRecentlyUsed(action);
		Vector3 position = Vector3.zero;
		if (useCurrentMousePosition)
		{
			position = GetMouseWorldPosition();
		}
		else
		{
			Camera val = Camera.main ?? Camera.current;
			if ((Object)(object)val != (Object)null)
			{
				position = val.ScreenToWorldPoint(Vector2.op_Implicit(menuOpenPosition));
				position.z = 0f;
			}
		}
		if (action.Type == MenuActionType.ZiplinePlacement)
		{
			if (CurrentMode == ContextMenuMode.ZiplinePlacement)
			{
				position = GetMouseWorldPosition();
			}
			modes.HandleZiplinePlacement(position);
			if (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305))
			{
				CloseMenu();
			}
		}
		else if (action.Type == MenuActionType.MassDelete)
		{
			CurrentMode = ContextMenuMode.MassDelete;
			modes.isDraggingMassDelete = false;
			CloseMenu();
		}
		else if (action.Type == MenuActionType.GrabEnemy || action.Type == MenuActionType.GrabPlayer)
		{
			action.Execute(position, useCurrentMousePosition);
			if (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305))
			{
				CloseMenu();
			}
		}
		else
		{
			action.Execute(position, useCurrentMousePosition);
			if (Main.settings.isRecordingLevelEdits)
			{
				ui.TrackLevelEdit(action, position);
			}
			if (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305))
			{
				CloseMenu();
			}
		}
	}

	private void AddToRecentlyUsed(MenuAction action)
	{
		Main.settings.recentlyUsedItems.RemoveAll((MenuAction a) => a.Id == action.Id);
		Main.settings.recentlyUsedItems.Insert(0, action);
		while (Main.settings.recentlyUsedItems.Count > Main.settings.maxRecentItems)
		{
			Main.settings.recentlyUsedItems.RemoveAt(Main.settings.recentlyUsedItems.Count - 1);
		}
	}

	public float GetHoldProgress()
	{
		if (!isHoldingRightClick || !Main.settings.contextMenuEnabled)
		{
			return 0f;
		}
		return Mathf.Clamp01(rightClickHoldTime / Main.settings.contextMenuHoldDuration);
	}

	public bool IsHoldingForMenu()
	{
		if (isHoldingRightClick)
		{
			return Main.settings.contextMenuEnabled;
		}
		return false;
	}

	public bool IsMenuOpenOrPending()
	{
		if (!isMenuOpen)
		{
			return isHoldingRightClick;
		}
		return true;
	}

	public Vector3 GetMouseWorldPosition()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		Camera val = Camera.main ?? Camera.current;
		if ((Object)(object)val != (Object)null)
		{
			Vector3 result = val.ScreenToWorldPoint(Input.mousePosition);
			result.z = 0f;
			return result;
		}
		return Vector3.zero;
	}

	public void ShowHelpDialog()
	{
		ui.ShowHelpDialog();
	}

	public void ShowHelpMenu()
	{
		ui.ShowHelpMenu();
	}

	public void QuickCloneUnderCursor()
	{
		modes?.QuickCloneUnderCursor();
	}

	public bool TryCloneBlockExact(Block sourceBlock, Vector3 position)
	{
		//IL_0013: 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_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)sourceBlock == (Object)null || ((BroforceObject)sourceBlock).destroyed)
		{
			return false;
		}
		int num = (int)Mathf.Round(position.x / 16f);
		int num2 = (int)Mathf.Round(position.y / 16f);
		if (Map.MapData == null || num < 0 || num >= Map.MapData.Width || num2 < 0 || num2 >= Map.MapData.Height)
		{
			return false;
		}
		if (Map.blocks != null && (Object)(object)Map.blocks[num, num2] != (Object)null && !((BroforceObject)Map.blocks[num, num2]).destroyed)
		{
			return false;
		}
		try
		{
			if (themeBlockCaches == null)
			{
				BuildBlockPrefabCache();
			}
			string text = ((Object)sourceBlock).name.Replace("(Clone)", "").Trim();
			int num3 = text.LastIndexOf('_');
			if (num3 > 0 && Regex.IsMatch(text.Substring(num3 + 1), "^\\d+$"))
			{
				int num4 = num3;
				while (num4 > 0)
				{
					int num5 = text.LastIndexOf('_', num4 - 1);
					if (num5 < 0 || !Regex.IsMatch(text.Substring(num5 + 1, num4 - num5 - 1), "^\\d+$"))
					{
						break;
					}
					num4 = num5;
				}
				text = text.Substring(0, num4);
			}
			string currentThemeName = GetCurrentThemeName();
			Block val = null;
			GameObject val2 = null;
			if (sourceBlock is BoulderBlock && boulderPrefabCache != null && boulderPrefabCache.ContainsKey(text))
			{
				val2 = boulderPrefabCache[text];
				if ((Object)(object)val2 != (Object)null)
				{
					val = val2.GetComponent<Block>();
				}
			}
			else if (themeBlockCaches != null)
			{
				if (!string.IsNullOrEmpty(currentThemeName) && themeBlockCaches.ContainsKey(currentThemeName))
				{
					Dictionary<string, Block> dictionary = themeBlockCaches[currentThemeName];
					if (dictionary.ContainsKey(text))
					{
						val = dictionary[text];
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					foreach (KeyValuePair<string, Dictionary<string, Block>> themeBlockCache in themeBlockCaches)
					{
						if (!(themeBlockCache.Key == currentThemeName) && themeBlockCache.Value.ContainsKey(text))
						{
							val = themeBlockCache.Value[text];
							break;
						}
					}
				}
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject == (Object)null)
				{
					val = null;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				BlockType? blockTypeFromGroundType = GetBlockTypeFromGroundType(sourceBlock.groundType, sourceBlock);
				Main.SpawnBlockInternal(num2, num, blockTypeFromGroundType.GetValueOrDefault(BlockType.Brick), val);
				if (Main.settings.isRecordingLevelEdits && blockTypeFromGroundType.HasValue)
				{
					MenuAction action = MenuAction.CreateSpawnBlock(blockTypeFromGroundType.Value);
					ui.TrackLevelEdit(action, new Vector3((float)num * 16f, (float)num2 * 16f, 5f));
				}
				return true;
			}
		}
		catch
		{
		}
		return false;
	}

	private static string GetCurrentThemeName()
	{
		if ((Object)(object)Map.Instance == (Object)null || (Object)(object)Map.Instance.activeTheme == (Object)null)
		{
			return "";
		}
		if (Map.Instance.jungleThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.jungleThemeReference).Asset)
		{
			return "jungle";
		}
		if (Map.Instance.cityThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.cityThemeReference).Asset)
		{
			return "city";
		}
		if (Map.Instance.desertThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.desertThemeReference).Asset)
		{
			return "desert";
		}
		if (Map.Instance.burningJungleThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.burningJungleThemeReference).Asset)
		{
			return "burningJungle";
		}
		if (Map.Instance.forestThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.forestThemeReference).Asset)
		{
			return "forest";
		}
		if (Map.Instance.hellThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.hellThemeReference).Asset)
		{
			return "hell";
		}
		if (Map.Instance.americaThemeReference != null && (Object)(object)Map.Instance.activeTheme == (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.americaThemeReference).Asset)
		{
			return "america";
		}
		return "";
	}

	private static void BuildBlockPrefabCache()
	{
		if (themeBlockCaches != null)
		{
			return;
		}
		themeBlockCaches = new Dictionary<string, Dictionary<string, Block>>();
		boulderPrefabCache = new Dictionary<string, GameObject>();
		if ((Object)(object)Map.Instance == (Object)null)
		{
			return;
		}
		if (Map.Instance.jungleThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.jungleThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("jungle", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.jungleThemeReference).Asset);
		}
		if (Map.Instance.cityThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.cityThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("city", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.cityThemeReference).Asset);
		}
		if (Map.Instance.desertThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.desertThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("desert", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.desertThemeReference).Asset);
		}
		if (Map.Instance.burningJungleThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.burningJungleThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("burningJungle", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.burningJungleThemeReference).Asset);
		}
		if (Map.Instance.forestThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.forestThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("forest", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.forestThemeReference).Asset);
		}
		if (Map.Instance.hellThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.hellThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("hell", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.hellThemeReference).Asset);
		}
		if (Map.Instance.americaThemeReference != null && (Object)(object)((AssetBundleReference<ThemeHolder>)(object)Map.Instance.americaThemeReference).Asset != (Object)null)
		{
			BuildThemeCache("america", ((AssetBundleReference<ThemeHolder>)(object)Map.Instance.americaThemeReference).Asset);
		}
		if (Map.Instance.sharedObjectsReference == null || !((Object)(object)((AssetBundleReference<SharedLevelObjectsHolder>)(object)Map.Instance.sharedObjectsReference).Asset != (Object)null))
		{
			return;
		}
		Dictionary<string, Block> dictionary = new Dictionary<string, Block>();
		themeBlockCaches["shared"] = dictionary;
		SharedLevelObjectsHolder asset = ((AssetBundleReference<SharedLevelObjectsHolder>)(object)Map.Instance.sharedObjectsReference).Asset;
		FieldInfo[] fields = ((object)asset).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (typeof(Block).IsAssignableFrom(fieldInfo.FieldType))
			{
				object? value = fieldInfo.GetValue(asset);
				Block val = (Block)((value is Block) ? value : null);
				if ((Object)(object)val != (Object)null)
				{
					string key = ((Object)val).name.Replace("(Clone)", "").Trim();
					dictionary[key] = val;
				}
			}
		}
	}

	private static void BuildThemeCache(string themeName, ThemeHolder theme)
	{
		if ((Object)(object)theme == (Object)null)
		{
			return;
		}
		Dictionary<string, Block> dictionary = new Dictionary<string, Block>();
		themeBlockCaches[themeName] = dictionary;
		FieldInfo[] fields = ((object)theme).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (typeof(Block).IsAssignableFrom(fieldInfo.FieldType))
			{
				object? value = fieldInfo.GetValue(theme);
				Block val = (Block)((value is Block) ? value : null);
				if ((Object)(object)val != (Object)null)
				{
					string key = ((Object)val).name.Replace("(Clone)", "").Trim();
					dictionary[key] = val;
				}
			}
			else if (fieldInfo.FieldType.IsArray && typeof(Block).IsAssignableFrom(fieldInfo.FieldType.GetElementType()))
			{
				if (!(fieldInfo.GetValue(theme) is Block[] array))
				{
					continue;
				}
				Block[] array2 = array;
				foreach (Block val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						string key2 = ((Object)val2).name.Replace("(Clone)", "").Trim();
						dictionary[key2] = val2;
					}
				}
			}
			else if (fieldInfo.Name == "boulders" && (object)fieldInfo.FieldType == typeof(GameObject[]))
			{
				if (!(fieldInfo.GetValue(theme) is GameObject[] array3))
				{
					continue;
				}
				GameObject[] array4 = array3;
				foreach (GameObject val3 in array4)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						string key3 = ((Object)val3).name.Replace("(Clone)", "").Trim();
						boulderPrefabCache[key3] = val3;
					}
				}
			}
			else
			{
				if (!(fieldInfo.Name == "crateDoodads") || (object)fieldInfo.FieldType != typeof(SpriteSM[]) || !(fieldInfo.GetValue(theme) is SpriteSM[] array5))
				{
					continue;
				}
				SpriteSM[] array6 = array5;
				foreach (SpriteSM val4 in array6)
				{
					if ((Object)(object)val4 != (Object)null && (Object)(object)((Component)val4).gameObject != (Object)null)
					{
						Block component = ((Component)val4).gameObject.GetComponent<Block>();
						if ((Object)(object)component != (Object)null)
						{
							string key4 = ((Object)component).name.Replace("(Clone)", "").Trim();
							dictionary[key4] = component;
						}
					}
				}
			}
		}
	}

	private BlockType? MapAmmoCrateType(object ammoType)
	{
		if (ammoType == null)
		{
			return BlockType.Crate;
		}
		return ammoType.ToString() switch
		{
			"Standard" => BlockType.AmmoCrate, 
			"Airstrike" => BlockType.AirStrikeAmmoCrate, 
			"Timeslow" => BlockType.TimeAmmoCrate, 
			"RemoteControlCar" => BlockType.RCCarAmmoCrate, 
			"MechDrop" => BlockType.MechDropAmmoCrate, 
			"AlienPheromones" => BlockType.AlienPheromonesAmmoCrate, 
			"Steroids" => BlockType.SteroidsAmmoCrate, 
			"Piggy" => BlockType.PigAmmoCrate, 
			"Perk" => BlockType.FlexAmmoCrate, 
			"Dollars" => BlockType.MoneyCrate, 
			"Revive" => BlockType.PillsCrate, 
			_ => BlockType.Crate, 
		};
	}

	public BlockType? GetBlockTypeFromGroundType(GroundType groundType, Block block = null)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Expected I4, but got Unknown
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_045b: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Expected I4, but got Unknown
		if ((Object)(object)block != (Object)null && block is DoodadCrate)
		{
			return BlockType.Crate;
		}
		switch ((int)groundType)
		{
		case 0:
		case 1:
		case 2:
			return BlockType.Dirt;
		case 42:
			return BlockType.CaveRock;
		case 48:
			return BlockType.SandyEarth;
		case 101:
			return BlockType.DesertSand;
		case 69:
			return BlockType.CaveEarth;
		case 75:
			return BlockType.HellRock;
		case 98:
			return BlockType.DesertCaveRock;
		case 99:
			return BlockType.DesertCaveEarth;
		case 82:
			return BlockType.DesertEarth;
		case 83:
			return BlockType.CityEarth;
		case 70:
			return BlockType.Skulls;
		case 71:
			return BlockType.Bones;
		case 55:
			return BlockType.AlienEarth;
		case 62:
			return BlockType.AlienFlesh;
		case 63:
			return BlockType.AlienExplodingFlesh;
		case 79:
			return BlockType.AlienDirt;
		case 6:
		case 7:
			return BlockType.Brick;
		case 5:
			return BlockType.BrickTop;
		case 40:
			return BlockType.Steel;
		case 115:
			return BlockType.Metal;
		case 38:
			return BlockType.Bunker;
		case 43:
			return BlockType.WatchTower;
		case 41:
			return BlockType.Roof;
		case 52:
			return BlockType.ThatchRoof;
		case 60:
			return BlockType.FactoryRoof;
		case 97:
			return BlockType.DesertRoof;
		case 107:
			return BlockType.DesertRoofRed;
		case 108:
			return BlockType.TentRoof;
		case 84:
			return BlockType.SacredTemple;
		case 112:
			return BlockType.SacredTempleGold;
		case 85:
			return BlockType.CityBrick;
		case 86:
			return BlockType.DesertBrick;
		case 104:
			return BlockType.CityRoad;
		case 96:
			return BlockType.CityAssMouth;
		case 9:
		case 12:
			return BlockType.Bridge;
		case 61:
			return BlockType.Bridge2;
		case 87:
			return BlockType.MetalBridge;
		case 100:
			return BlockType.MetalBridge2;
		case 88:
			return BlockType.SacredBridge;
		case 66:
			return BlockType.AlienBridge;
		case 16:
			return BlockType.Ladder;
		case 65:
			return BlockType.AlienLadder;
		case 89:
			return BlockType.MetalLadder;
		case 90:
			return BlockType.CityLadder;
		case 91:
			return BlockType.DesertLadder;
		case 32:
			return BlockType.FallingBlock;
		case 102:
			return BlockType.Quicksand;
		case 113:
			return BlockType.Boulder;
		case 114:
			return BlockType.BoulderBig;
		case 109:
			return BlockType.Sandbag;
		case 77:
			return BlockType.Vault;
		case 80:
			return BlockType.SmallCageBlock;
		case 81:
			return BlockType.StandardCage;
		case 18:
			return BlockType.BigBlock;
		case 93:
			return BlockType.SacredBigBlock;
		case 26:
			return BlockType.ExplosiveBarrel;
		case 27:
			return BlockType.PropaneTank;
		case 105:
			return BlockType.DesertOilBarrel;
		case 106:
			return BlockType.OilTank;
		case 44:
			return BlockType.BeeHive;
		case 47:
			return BlockType.AlienEgg;
		case 68:
			return BlockType.AlienEggExplosive;
		case 14:
			return BlockType.Crate;
		case 73:
			return BlockType.AmmoCrate;
		case 110:
			return BlockType.MoneyCrate;
		case 111:
			return BlockType.PillsCrate;
		case 49:
			return BlockType.Pipe;
		case 103:
			return BlockType.OilPipe;
		case 54:
			return BlockType.Statue;
		case 58:
			return BlockType.TyreBlock;
		case 64:
			return BlockType.AlienBarbShooter;
		case 57:
			return BlockType.BuriedRocket;
		case 33:
			if ((Object)(object)block != (Object)null)
			{
				CrateBlock val = (CrateBlock)(object)((block is CrateBlock) ? block : null);
				if ((Object)(object)val != (Object)null && val.containsPresent)
				{
					PockettedSpecialAmmoType ammoType = val.ammoType;
					return (ammoType - 1) switch
					{
						0 => BlockType.AmmoCrate, 
						1 => BlockType.AirStrikeAmmoCrate, 
						2 => BlockType.TimeAmmoCrate, 
						3 => BlockType.RCCarAmmoCrate, 
						4 => BlockType.MechDropAmmoCrate, 
						5 => BlockType.AlienPheromonesAmmoCrate, 
						6 => BlockType.SteroidsAmmoCrate, 
						7 => BlockType.PigAmmoCrate, 
						8 => BlockType.FlexAmmoCrate, 
						9 => BlockType.MoneyCrate, 
						10 => BlockType.PillsCrate, 
						_ => BlockType.Crate, 
					};
				}
			}
			return BlockType.Crate;
		case 35:
		case 36:
			return BlockType.Crate;
		case 29:
			return BlockType.StandardCage;
		case 74:
			return BlockType.HellRock;
		case 56:
			return BlockType.CityAssMouth;
		case 3:
		case 92:
			return BlockType.Dirt;
		case 8:
		case 50:
		case 94:
		case 95:
			return BlockType.Brick;
		case 39:
			return BlockType.Bunker;
		case 67:
			return BlockType.AlienEarth;
		case 34:
		case 53:
			return BlockType.Crate;
		case 45:
		case 46:
		case 59:
		case 76:
		case 78:
			return BlockType.Brick;
		case 10:
		case 11:
			return BlockType.Brick;
		case 4:
		case 13:
		case 15:
		case 17:
		case 19:
		case 20:
		case 21:
		case 22:
		case 23:
		case 24:
		case 25:
		case 28:
		case 30:
		case 31:
		case 37:
		case 51:
		case 72:
			return null;
		default:
			return null;
		}
	}

	public int GetLevelCountForCampaign(int campaignIndex)
	{
		int num = campaignIndex + 1;
		int num2 = 1;
		return num switch
		{
			1 => 4, 
			2 => 4, 
			3 => 4, 
			4 => 4, 
			5 => 3, 
			6 => 4, 
			7 => 5, 
			8 => 4, 
			9 => 4, 
			10 => 4, 
			11 => 6, 
			12 => 5, 
			13 => 5, 
			14 => 5, 
			15 => 14, 
			_ => 1, 
		};
	}

	public GameObject GetObjectUnderCursor()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: 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_0093: 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)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		Vector3 mouseWorldPosition = GetMouseWorldPosition();
		Camera val = Camera.main ?? Camera.current;
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		Ray val2 = val.ScreenPointToRay(Input.mousePosition);
		RaycastHit[] array = Physics.SphereCastAll(val2, 8f, 100f);
		GameObject val3 = null;
		float num = float.MaxValue;
		RaycastHit[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			RaycastHit val4 = array2[i];
			Unit val5 = ((Component)((RaycastHit)(ref val4)).collider).GetComponent<Unit>();
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<Unit>();
			}
			if ((Object)(object)val5 != (Object)null)
			{
				float num2 = Vector3.Distance(mouseWorldPosition, ((Component)val5).transform.position);
				if (num2 < num)
				{
					num = num2;
					val3 = ((Component)val5).gameObject;
				}
				continue;
			}
			Block val6 = ((Component)((RaycastHit)(ref val4)).collider).GetComponent<Block>();
			if ((Object)(object)val6 == (Object)null)
			{
				val6 = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<Block>();
			}
			if ((Object)(object)val6 != (Object)null && !((BroforceObject)val6).destroyed)
			{
				float num3 = Vector3.Distance(mouseWorldPosition, ((Component)val6).transform.position);
				if (num3 < num)
				{
					num = num3;
					val3 = ((Component)val6).gameObject;
				}
			}
		}
		if ((Object)(object)val3 != (Object)null)
		{
			return val3;
		}
		RaycastHit val7 = default(RaycastHit);
		if (Physics.Raycast(val2, ref val7, 100f))
		{
			Unit val8 = ((Component)((RaycastHit)(ref val7)).collider).GetComponent<Unit>();
			if ((Object)(object)val8 == (Object)null)
			{
				val8 = ((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent<Unit>();
			}
			if ((Object)(object)val8 != (Object)null)
			{
				return ((Component)val8).gameObject;
			}
			Block val9 = ((Component)((RaycastHit)(ref val7)).collider).GetComponent<Block>();
			if ((Object)(object)val9 == (Object)null)
			{
				val9 = ((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent<Block>();
			}
			if ((Object)(object)val9 != (Object)null && !((BroforceObject)val9).destroyed)
			{
				return ((Component)val9).gameObject;
			}
		}
		int num4 = (int)Mathf.Round(mouseWorldPosition.x / 16f);
		int num5 = (int)Mathf.Round(mouseWorldPosition.y / 16f);
		if (Map.MapData != null && Map.blocks != null && num4 >= 0 && num4 < Map.MapData.Width && num5 >= 0 && num5 < Map.MapData.Height && (Object)(object)Map.blocks[num4, num5] != (Object)null && !((BroforceObject)Map.blocks[num4, num5]).destroyed)
		{
			return ((Component)Map.blocks[num4, num5]).gameObject;
		}
		return null;
	}

	public void TrackLevelEdit(MenuAction action, Vector3 position)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		ui.TrackLevelEdit(action, position);
	}

	public static void ReplayLevelEdits()
	{
		ContextMenuUI.ReplayLevelEdits();
	}
}
public class ContextMenuBuilder
{
	private readonly ContextMenuManager manager;

	private static bool showProfileNameDialog = false;

	private static string profileNameInput = "";

	private static bool isOverwriteMode = false;

	private static string profileToOverwrite = "";

	private static Action<string> profileNameCallback = null;

	public ContextMenuBuilder(ContextMenuManager manager)
	{
		this.manager = manager;
	}

	public void BuildMenuItems()
	{
		if (manager.CurrentMenu != null)
		{
			GameObject objectUnderCursor = manager.GetObjectUnderCursor();
			bool flag = false;
			if ((Object)(object)objectUnderCursor != (Object)null)
			{
				flag = BuildContextActions(objectUnderCursor);
			}
			if (flag)
			{
				manager.CurrentMenu.AddItem(MenuItem.CreateHeader("General Actions"));
				manager.CurrentMenu.AddSeparator();
			}
			if (Main.settings.enableRecentItems || Main.settings.selectedQuickAction != null)
			{
				BuildRecentlyUsedSection();
			}
			MenuAction teleportAction = MenuAction.CreateTeleport();
			MenuItem item = new MenuItem(teleportAction.DisplayName, delegate
			{
				manager.ExecuteAction(teleportAction);
			})
			{
				ActionId = teleportAction.Id,
				MenuAction = teleportAction
			};
			manager.CurrentMenu.AddItem(item);
			manager.CurrentMenu.AddSeparator();
			MenuItem menuItem = new MenuItem("Spawn Enemy");
			BuildEnemySubmenu(menuItem);
			manager.CurrentMenu.AddItem(menuItem);
			MenuItem menuItem2 = new MenuItem("Spawn Object");
			BuildObjectSubmenu(menuItem2);
			manager.CurrentMenu.AddItem(menuItem2);
			MenuItem menuItem3 = new MenuItem("Player Cheats");
			BuildPlayerCheatsSubmenu(menuItem3);
			manager.CurrentMenu.AddItem(menuItem3);
			MenuItem menuItem4 = new MenuItem("Level Control");
			BuildLevelControlSubmenu(menuItem4);
			manager.CurrentMenu.AddItem(menuItem4);
			MenuItem menuItem5 = new MenuItem("Teleport");
			BuildTeleportSubmenu(menuItem5);
			manager.CurrentMenu.AddItem(menuItem5);
			MenuItem menuItem6 = new MenuItem("Level Edit Recording");
			BuildLevelEditRecordingSubmenu(menuItem6);
			manager.CurrentMenu.AddItem(menuItem6);
			MenuItem menuItem7 = new MenuItem("Debug Options");
			BuildDebugOptionsSubmenu(menuItem7);
			manager.CurrentMenu.AddItem(menuItem7);
			manager.CurrentMenu.AddSeparator();
			manager.CurrentMenu.AddItem(new MenuItem("Help", delegate
			{
				manager.ShowHelpDialog();
			}));
			manager.CurrentMenu.AddItem(new MenuItem("Cancel", delegate
			{
				manager.CloseMenu();
			}));
		}
	}

	public void BuildRecentlyUsedSection()
	{
		bool flag = false;
		if (Main.settings.selectedQuickAction != null)
		{
			bool flag2 = false;
			foreach (MenuAction recentlyUsedItem in Main.settings.recentlyUsedItems)
			{
				if (recentlyUsedItem.Id == Main.settings.selectedQuickAction.Id)
				{
					flag2 = true;
					break;
				}
			}
			if (!flag2)
			{
				Main.settings.recentlyUsedItems.Insert(0, Main.settings.selectedQuickAction);
			}
		}
		foreach (MenuAction action in Main.settings.recentlyUsedItems.Take(Main.settings.maxRecentItems))
		{
			MenuItem item = new MenuItem(action.DisplayName, delegate
			{
				manager.ExecuteAction(action);
			})
			{
				ActionId = action.Id,
				MenuAction = action,
				ShowCheckbox = true,
				IsChecked = (Main.settings.selectedQuickAction != null && action.Id == Main.settings.selectedQuickAction.Id)
			};
			manager.CurrentMenu.AddItem(item);
			flag = true;
		}
		if (flag)
		{
			manager.CurrentMenu.AddSeparator();
		}
	}

	public void BuildEnemySubmenu(MenuItem parentMenu)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0414: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		MenuItem menuItem = new MenuItem("Normal");
		UnitType[] normalUnits = UnitTypes.NormalUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num = (int)normalUnits[i];
			UnitType unitType = (UnitType)num;
			MenuAction action8 = MenuAction.CreateSpawnEnemy(unitType);
			menuItem.AddSubItem(new MenuItem(action8.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action8);
			})
			{
				ActionId = action8.Id,
				MenuAction = action8
			});
		}
		parentMenu.AddSubItem(menuItem);
		MenuItem menuItem2 = new MenuItem("Aliens");
		normalUnits = UnitTypes.AlienUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num2 = (int)normalUnits[i];
			UnitType unitType2 = (UnitType)num2;
			MenuAction action7 = MenuAction.CreateSpawnEnemy(unitType2);
			menuItem2.AddSubItem(new MenuItem(action7.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action7);
			})
			{
				ActionId = action7.Id,
				MenuAction = action7
			});
		}
		parentMenu.AddSubItem(menuItem2);
		MenuItem menuItem3 = new MenuItem("Hell");
		normalUnits = UnitTypes.HellUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num3 = (int)normalUnits[i];
			UnitType unitType3 = (UnitType)num3;
			MenuAction action6 = MenuAction.CreateSpawnEnemy(unitType3);
			menuItem3.AddSubItem(new MenuItem(action6.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action6);
			})
			{
				ActionId = action6.Id,
				MenuAction = action6
			});
		}
		parentMenu.AddSubItem(menuItem3);
		MenuItem menuItem4 = new MenuItem("Worms");
		normalUnits = UnitTypes.WormUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num4 = (int)normalUnits[i];
			UnitType unitType4 = (UnitType)num4;
			MenuAction action5 = MenuAction.CreateSpawnEnemy(unitType4);
			menuItem4.AddSubItem(new MenuItem(action5.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action5);
			})
			{
				ActionId = action5.Id,
				MenuAction = action5
			});
		}
		parentMenu.AddSubItem(menuItem4);
		MenuItem menuItem5 = new MenuItem("Bosses");
		normalUnits = UnitTypes.BossUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num5 = (int)normalUnits[i];
			UnitType unitType5 = (UnitType)num5;
			MenuAction action4 = MenuAction.CreateSpawnEnemy(unitType5);
			menuItem5.AddSubItem(new MenuItem(action4.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action4);
			})
			{
				ActionId = action4.Id,
				MenuAction = action4
			});
		}
		parentMenu.AddSubItem(menuItem5);
		MenuItem menuItem6 = new MenuItem("Vehicles");
		normalUnits = UnitTypes.VehicleEnemies;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num6 = (int)normalUnits[i];
			UnitType unitType6 = (UnitType)num6;
			MenuAction action3 = MenuAction.CreateSpawnEnemy(unitType6);
			menuItem6.AddSubItem(new MenuItem(action3.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action3);
			})
			{
				ActionId = action3.Id,
				MenuAction = action3
			});
		}
		parentMenu.AddSubItem(menuItem6);
		MenuItem menuItem7 = new MenuItem("Friendly");
		normalUnits = UnitTypes.FriendlyUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num7 = (int)normalUnits[i];
			UnitType unitType7 = (UnitType)num7;
			MenuAction action2 = MenuAction.CreateSpawnEnemy(unitType7);
			menuItem7.AddSubItem(new MenuItem(action2.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action2);
			})
			{
				ActionId = action2.Id,
				MenuAction = action2
			});
		}
		parentMenu.AddSubItem(menuItem7);
		MenuItem menuItem8 = new MenuItem("Other");
		normalUnits = UnitTypes.OtherUnits;
		for (int i = 0; i < normalUnits.Length; i++)
		{
			int num8 = (int)normalUnits[i];
			UnitType unitType8 = (UnitType)num8;
			MenuAction action = MenuAction.CreateSpawnEnemy(unitType8);
			menuItem8.AddSubItem(new MenuItem(action.DisplayName.Replace("Spawn ", ""), delegate
			{
				manager.ExecuteAction(action);
			})
			{
				ActionId = action.Id,
				MenuAction = action
			});
		}
		parentMenu.AddSubItem(menuItem8);
	}

	public void BuildObjectSubmenu(MenuItem parentMenu)
	{
		MenuItem menuItem = new MenuItem("Terrain Blocks");
		BuildTerrainBlocksSubmenu(menuItem);
		parentMenu.AddSubItem(menuItem);
		MenuItem menuItem2 = new MenuItem("Building & Structures");
		BuildStructuresSubmenu(menuItem2);
		parentMenu.AddSubItem(menuItem2);
		MenuItem menuItem3 = new MenuItem("Bridges, Platforms & Ladders");
		BuildPlatformsSubmenu(menuItem3);
		parentMenu.AddSubItem(menuItem3);
		MenuItem menuItem4 = new MenuItem("Special Blocks");
		BuildSpecialBlocksSubmenu(menuItem4);
		parentMenu.AddSubItem(menuItem4);
		parentMenu.AddSeparator();
		MenuItem menuItem5 = new MenuItem("Destructibles & Organics");
		BuildDestructiblesSubmenu(menuItem5);
		parentMenu.AddSubItem(menuItem5);
		MenuItem menuItem6 = new MenuItem("Crates");
		BuildCratesSubmenu(menuItem6);
		parentMenu.AddSubItem(menuItem6);
		MenuItem menuItem7 = new MenuItem("Interactive Objects");
		BuildInteractiveObjectsSubmenu(menuItem7);
		parentMenu.AddSubItem(menuItem7);
		MenuItem menuItem8 = new MenuItem("Hazards");
		BuildHazardsSubmenu(menuItem8);
		parentMenu.AddSubItem(menuItem8);
		MenuItem menuItem9 = new MenuItem("Environment & Props");
		BuildEnvironmentSubmenu(menuItem9);
		parentMenu.AddSubItem(menuItem9);
	}

	public void BuildTerrainBlocksSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.Dirt, "Dirt");
		AddBlockMenuItem(parentMenu, BlockType.CaveRock, "Cave Rock");
		AddBlockMenuItem(parentMenu, BlockType.SandyEarth, "Sandy Earth");
		AddBlockMenuItem(parentMenu, BlockType.DesertSand, "Desert Sand");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.CaveEarth, "Cave Earth");
		AddBlockMenuItem(parentMenu, BlockType.HellRock, "Hell Rock");
		AddBlockMenuItem(parentMenu, BlockType.DesertCaveRock, "Desert Cave Rock");
		AddBlockMenuItem(parentMenu, BlockType.DesertCaveEarth, "Desert Cave Earth");
		AddBlockMenuItem(parentMenu, BlockType.DesertEarth, "Desert Earth");
		AddBlockMenuItem(parentMenu, BlockType.CityEarth, "City Earth");
		AddBlockMenuItem(parentMenu, BlockType.Skulls, "Skulls");
		AddBlockMenuItem(parentMenu, BlockType.Bones, "Bones");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.AlienEarth, "Alien Earth");
		AddBlockMenuItem(parentMenu, BlockType.AlienFlesh, "Alien Flesh");
		AddBlockMenuItem(parentMenu, BlockType.AlienExplodingFlesh, "Alien Exploding Flesh");
		AddBlockMenuItem(parentMenu, BlockType.AlienDirt, "Alien Dirt");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.BigBlock, "Big Block");
		AddBlockMenuItem(parentMenu, BlockType.SacredBigBlock, "Sacred Big Block");
	}

	public void BuildStructuresSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.Brick, "Brick");
		AddBlockMenuItem(parentMenu, BlockType.BrickTop, "Brick Top");
		AddBlockMenuItem(parentMenu, BlockType.Metal, "Metal");
		AddBlockMenuItem(parentMenu, BlockType.Steel, "Steel (Indestructible)");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Bunker, "Urban Brick");
		AddBlockMenuItem(parentMenu, BlockType.WatchTower, "Watch Tower Floor");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Roof, "Roof");
		AddBlockMenuItem(parentMenu, BlockType.ThatchRoof, "Thatch Roof");
		AddBlockMenuItem(parentMenu, BlockType.FactoryRoof, "Factory Roof");
		AddBlockMenuItem(parentMenu, BlockType.DesertRoof, "Desert Roof");
		AddBlockMenuItem(parentMenu, BlockType.DesertRoofRed, "Desert Roof Red");
		AddBlockMenuItem(parentMenu, BlockType.TentRoof, "Tent Roof");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.CityBrick, "City Brick");
		AddBlockMenuItem(parentMenu, BlockType.DesertBrick, "Desert Brick");
		AddBlockMenuItem(parentMenu, BlockType.SacredTemple, "Sacred Temple");
		AddBlockMenuItem(parentMenu, BlockType.SacredTempleGold, "Sacred Temple Gold");
		AddBlockMenuItem(parentMenu, BlockType.CityRoad, "City Road");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Pipe, "Pipe");
		AddBlockMenuItem(parentMenu, BlockType.OilPipe, "Oil Pipe");
		AddBlockMenuItem(parentMenu, BlockType.Statue, "Statue");
		AddBlockMenuItem(parentMenu, BlockType.TyreBlock, "Tyre Block");
		AddBlockMenuItem(parentMenu, BlockType.CityAssMouth, "City Ass Mouth");
	}

	public void BuildPlatformsSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.Bridge, "Bridge");
		AddBlockMenuItem(parentMenu, BlockType.Bridge2, "Bridge 2");
		AddBlockMenuItem(parentMenu, BlockType.MetalBridge, "Metal Bridge");
		AddBlockMenuItem(parentMenu, BlockType.MetalBridge2, "Metal Bridge 2");
		AddBlockMenuItem(parentMenu, BlockType.SacredBridge, "Sacred Bridge");
		AddBlockMenuItem(parentMenu, BlockType.AlienBridge, "Alien Bridge");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Ladder, "Ladder");
		AddBlockMenuItem(parentMenu, BlockType.MetalLadder, "Metal Ladder");
		AddBlockMenuItem(parentMenu, BlockType.CityLadder, "City Ladder");
		AddBlockMenuItem(parentMenu, BlockType.DesertLadder, "Desert Ladder");
		AddBlockMenuItem(parentMenu, BlockType.AlienLadder, "Alien Ladder");
	}

	public void BuildSpecialBlocksSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.FallingBlock, "Falling Block");
		AddBlockMenuItem(parentMenu, BlockType.Quicksand, "Quicksand");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Boulder, "Boulder");
		AddBlockMenuItem(parentMenu, BlockType.BoulderBig, "Boulder Big");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.Sandbag, "Sandbag");
		AddBlockMenuItem(parentMenu, BlockType.Vault, "Vault");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.SmallCageBlock, "Small Cage Block");
		AddBlockMenuItem(parentMenu, BlockType.StandardCage, "Standard Cage");
	}

	public void BuildDestructiblesSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.ExplosiveBarrel, "Explosive Barrel");
		AddBlockMenuItem(parentMenu, BlockType.RedExplosiveBarrel, "Red Explosive Barrel");
		AddBlockMenuItem(parentMenu, BlockType.PropaneTank, "Propane Tank");
		AddBlockMenuItem(parentMenu, BlockType.DesertOilBarrel, "Desert Oil Barrel");
		AddBlockMenuItem(parentMenu, BlockType.OilTank, "Oil Tank");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.BeeHive, "Beehive");
		AddBlockMenuItem(parentMenu, BlockType.AlienEgg, "Alien Egg");
		AddBlockMenuItem(parentMenu, BlockType.AlienEggExplosive, "Alien Egg (Explosive)");
	}

	public void BuildCratesSubmenu(MenuItem parentMenu)
	{
		AddBlockMenuItem(parentMenu, BlockType.Crate, "Wooden Crate");
		AddBlockMenuItem(parentMenu, BlockType.AmmoCrate, "Ammo Crate");
		AddBlockMenuItem(parentMenu, BlockType.TimeAmmoCrate, "Time Slow Crate");
		AddBlockMenuItem(parentMenu, BlockType.RCCarAmmoCrate, "RC Car Crate");
		AddBlockMenuItem(parentMenu, BlockType.AirStrikeAmmoCrate, "Airstrike Crate");
		AddBlockMenuItem(parentMenu, BlockType.MechDropAmmoCrate, "Mech Drop Crate");
		AddBlockMenuItem(parentMenu, BlockType.AlienPheromonesAmmoCrate, "Alien Pheromones Crate");
		AddBlockMenuItem(parentMenu, BlockType.SteroidsAmmoCrate, "Steroids Crate");
		AddBlockMenuItem(parentMenu, BlockType.PigAmmoCrate, "Pig Crate");
		AddBlockMenuItem(parentMenu, BlockType.FlexAmmoCrate, "Flex Crate");
		AddBlockMenuItem(parentMenu, BlockType.MoneyCrate, "Money Crate");
		AddBlockMenuItem(parentMenu, BlockType.PillsCrate, "Pills Crate");
	}

	public void BuildInteractiveObjectsSubmenu(MenuItem parentMenu)
	{
		MenuAction checkpointAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.CheckPoint);
		parentMenu.AddSubItem(new MenuItem("Checkpoint Flag", delegate
		{
			manager.ExecuteAction(checkpointAction);
		})
		{
			ActionId = checkpointAction.Id,
			MenuAction = checkpointAction
		});
		parentMenu.AddSeparator();
		MenuAction doorAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Door);
		parentMenu.AddSubItem(new MenuItem("Door", delegate
		{
			manager.ExecuteAction(doorAction);
		})
		{
			ActionId = doorAction.Id,
			MenuAction = doorAction
		});
		MenuAction mookDoorAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.MookDoor);
		parentMenu.AddSubItem(new MenuItem("Mook Door", delegate
		{
			manager.ExecuteAction(mookDoorAction);
		})
		{
			ActionId = mookDoorAction.Id,
			MenuAction = mookDoorAction
		});
		parentMenu.AddSeparator();
		MenuAction hangingVinesAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.HangingVines);
		parentMenu.AddSubItem(new MenuItem("Hanging Vines", delegate
		{
			manager.ExecuteAction(hangingVinesAction);
		})
		{
			ActionId = hangingVinesAction.Id,
			MenuAction = hangingVinesAction
		});
		MenuAction hangingBrazierAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.HangingBrazier);
		parentMenu.AddSubItem(new MenuItem("Hanging Brazier", delegate
		{
			manager.ExecuteAction(hangingBrazierAction);
		})
		{
			ActionId = hangingBrazierAction.Id,
			MenuAction = hangingBrazierAction
		});
	}

	public void BuildHazardsSubmenu(MenuItem parentMenu)
	{
		MenuAction spikesAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Spikes);
		parentMenu.AddSubItem(new MenuItem("Spikes", delegate
		{
			manager.ExecuteAction(spikesAction);
		})
		{
			ActionId = spikesAction.Id,
			MenuAction = spikesAction
		});
		MenuAction minesAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Mines);
		parentMenu.AddSubItem(new MenuItem("Mine Field", delegate
		{
			manager.ExecuteAction(minesAction);
		})
		{
			ActionId = minesAction.Id,
			MenuAction = minesAction
		});
		MenuAction sawBladeAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.SawBlade);
		parentMenu.AddSubItem(new MenuItem("Saw Blade", delegate
		{
			manager.ExecuteAction(sawBladeAction);
		})
		{
			ActionId = sawBladeAction.Id,
			MenuAction = sawBladeAction
		});
		MenuAction hiddenExplosivesAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.HiddenExplosives);
		parentMenu.AddSubItem(new MenuItem("Hidden Explosives", delegate
		{
			manager.ExecuteAction(hiddenExplosivesAction);
		})
		{
			ActionId = hiddenExplosivesAction.Id,
			MenuAction = hiddenExplosivesAction
		});
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.AlienBarbShooter, "Alien Barb Shooter");
		parentMenu.AddSeparator();
		AddBlockMenuItem(parentMenu, BlockType.BuriedRocket, "Buried Rocket");
	}

	public void BuildEnvironmentSubmenu(MenuItem parentMenu)
	{
		MenuAction scaffoldingAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Scaffolding);
		parentMenu.AddSubItem(new MenuItem("Scaffolding", delegate
		{
			manager.ExecuteAction(scaffoldingAction);
		})
		{
			ActionId = scaffoldingAction.Id,
			MenuAction = scaffoldingAction
		});
		MenuAction fenceAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Fence);
		parentMenu.AddSubItem(new MenuItem("Fence", delegate
		{
			manager.ExecuteAction(fenceAction);
		})
		{
			ActionId = fenceAction.Id,
			MenuAction = fenceAction
		});
		parentMenu.AddSeparator();
		MenuAction ziplineAction = MenuAction.CreateZiplinePlacement();
		parentMenu.AddSubItem(new MenuItem((manager.CurrentMode == ContextMenuManager.ContextMenuMode.ZiplinePlacement) ? "Zipline (Place second point)" : "Zipline", delegate
		{
			manager.ExecuteAction(ziplineAction);
		})
		{
			ShowCheckbox = (manager.CurrentMode == ContextMenuManager.ContextMenuMode.ZiplinePlacement),
			IsChecked = (manager.CurrentMode == ContextMenuManager.ContextMenuMode.ZiplinePlacement),
			ActionId = ziplineAction.Id,
			MenuAction = ziplineAction
		});
		parentMenu.AddSeparator();
		MenuAction treeAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Tree);
		parentMenu.AddSubItem(new MenuItem("Tree", delegate
		{
			manager.ExecuteAction(treeAction);
		})
		{
			ActionId = treeAction.Id,
			MenuAction = treeAction
		});
		MenuAction bushAction = MenuAction.CreateSpawnDoodad(SpawnableDoodadType.Bush);
		parentMenu.AddSubItem(new MenuItem("Bush", delegate
		{
			manager.ExecuteAction(bushAction);
		})
		{
			ActionId = bushAction.Id,
			MenuAction = bushAction
		});
	}

	public void BuildPlayerCheatsSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Invincibility", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.invulnerable,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.invulnerable = isChecked;
				if ((Object)(object)Main.currentCharacter != (Object)null)
				{
					if (isChecked)
					{
						Main.currentCharacter.SetInvulnerable(float.MaxValue, false, false);
					}
					else
					{
						Main.currentCharacter.SetInvulnerable(0f, false, false);
					}
				}
			}
		});
		parentMenu.AddSubItem(new MenuItem("Infinite Lives", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.infiniteLives,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.infiniteLives = isChecked;
				if ((Object)(object)Main.currentCharacter != (Object)null)
				{
					if (isChecked)
					{
						for (int i = 0; i < 4; i++)
						{
							HeroController.SetLives(i, int.MaxValue);
						}
					}
					else
					{
						for (int j = 0; j < 4; j++)
						{
							HeroController.SetLives(j, 1);
						}
					}
				}
			}
		});
		parentMenu.AddSubItem(new MenuItem("Infinite Specials", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.infiniteSpecials,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.infiniteSpecials = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Flight Mode", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.enableFlight,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.enableFlight = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Disable Gravity", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.disableGravity,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.disableGravity = isChecked;
			}
		});
	}

	public void BuildLevelControlSubmenu(MenuItem parentMenu)
	{
		string arg = "Unknown";
		int num = LevelSelectionController.CurrentLevelNum + 1;
		if (GameState.Instance != null && !string.IsNullOrEmpty(GameState.Instance.campaignName))
		{
			for (int i = 0; i < Main.actualCampaignNames.Length && i < Main.campaignDisplayNames.Length; i++)
			{
				if (Main.actualCampaignNames[i] == GameState.Instance.campaignName)
				{
					arg = Main.campaignDisplayNames[i];
					break;
				}
			}
		}
		parentMenu.AddSubItem(MenuItem.CreateHeader($"Current: {arg} - Level {num}"));
		parentMenu.AddSeparator();
		MenuItem menuItem = new MenuItem("Go to Level");
		BuildGoToLevelSubmenu(menuItem);
		parentMenu.AddSubItem(menuItem);
		MenuItem menuItem2 = new MenuItem("Starting Level");
		BuildStartingLevelSubmenu(menuItem2);
		parentMenu.AddSubItem(menuItem2);
		MenuItem menuItem3 = new MenuItem("", (Action)null);
		menuItem3.MultiButtons = new List<MenuItem.ButtonInfo>
		{
			new MenuItem.ButtonInfo
			{
				Text = "◄",
				Tooltip = "Previous Level",
				OnClick = delegate
				{
					MenuAction action3 = MenuAction.CreatePreviousLevel();
					manager.ExecuteAction(action3);
				}
			},
			new MenuItem.ButtonInfo
			{
				Text = "↻",
				Tooltip = "Restart Current Level",
				OnClick = delegate
				{
					MenuAction action2 = MenuAction.CreateRestartLevel();
					manager.ExecuteAction(action2);
				}
			},
			new MenuItem.ButtonInfo
			{
				Text = "►",
				Tooltip = "Next Level",
				OnClick = delegate
				{
					MenuAction action = MenuAction.CreateNextLevel();
					manager.ExecuteAction(action);
				}
			}
		};
		parentMenu.AddSubItem(menuItem3);
		parentMenu.AddSubItem(new MenuItem("Return to World Map", delegate
		{
			manager.CloseMenu();
			GameModeController.Instance.ReturnToWorldMap();
		}));
		parentMenu.AddSubItem(new MenuItem("Loop Current Level", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.loopCurrent,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.loopCurrent = isChecked;
			}
		});
	}

	public void BuildGoToLevelSubmenu(MenuItem parentMenu)
	{
		for (int i = 0; i < Main.campaignDisplayNames.Length; i++)
		{
			int campaignIndex = i;
			MenuItem menuItem = new MenuItem(Main.campaignDisplayNames[i]);
			int levelCountForCampaign = manager.GetLevelCountForCampaign(i);
			for (int j = 0; j < levelCountForCampaign; j++)
			{
				int levelIndex = j;
				MenuAction action = MenuAction.CreateGoToLevel(campaignIndex, levelIndex);
				menuItem.AddSubItem(new MenuItem($"Level {j + 1}", delegate
				{
					manager.ExecuteAction(action);
				})
				{
					MenuAction = action
				});
			}
			parentMenu.AddSubItem(menuItem);
		}
	}

	public void BuildStartingLevelSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Go to Level on Startup", delegate
		{
		})
		{
			IsToggleAction = true,
			ShowCheckbox = true,
			IsChecked = Main.settings.goToLevelOnStartup,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.goToLevelOnStartup = isChecked;
			}
		});
		parentMenu.AddSeparator();
		string arg = ((Main.settings.campaignNum < Main.campaignDisplayNames.Length) ? Main.campaignDisplayNames[Main.settings.campaignNum] : $"Campaign {Main.settings.campaignNum + 1}");
		MenuItem menuItem = new MenuItem($"Starting Level: {arg} - Level {Main.settings.levelNum + 1}");
		for (int i = 0; i < Main.campaignDisplayNames.Length; i++)
		{
			int num = i;
			MenuItem menuItem2 = new MenuItem(Main.campaignDisplayNames[i]);
			int levelCountForCampaign = manager.GetLevelCountForCampaign(i);
			for (int j = 0; j < levelCountForCampaign; j++)
			{
				int num2 = j;
				MenuAction action = MenuAction.CreateSetSpecificLevelAsStarting(num, num2);
				bool flag = num == Main.settings.campaignNum && num2 == Main.settings.levelNum;
				menuItem2.AddSubItem(new MenuItem((flag ? "✓ " : "") + $"Level {j + 1}", delegate
				{
					manager.ExecuteAction(action);
					manager.CloseMenu();
				})
				{
					MenuAction = action
				});
			}
			menuItem.AddSubItem(menuItem2);
		}
		parentMenu.AddSubItem(menuItem);
		parentMenu.AddSeparator();
		MenuAction goToStartingAction = MenuAction.CreateGoToStartingLevel();
		parentMenu.AddSubItem(new MenuItem(goToStartingAction.DisplayName, delegate
		{
			manager.ExecuteAction(goToStartingAction);
		})
		{
			MenuAction = goToStartingAction
		});
		MenuAction setCurrentAction = MenuAction.CreateSetCurrentLevelAsStarting();
		parentMenu.AddSubItem(new MenuItem(setCurrentAction.DisplayName, delegate
		{
			manager.ExecuteAction(setCurrentAction);
			manager.CloseMenu();
		})
		{
			MenuAction = setCurrentAction
		});
		MenuAction clearAction = MenuAction.CreateClearStartingLevel();
		parentMenu.AddSubItem(new MenuItem(clearAction.DisplayName, delegate
		{
			manager.ExecuteAction(clearAction);
			manager.CloseMenu();
		})
		{
			MenuAction = clearAction
		});
	}

	public void BuildDebugOptionsSubmenu(MenuItem parentMenu)
	{
		MenuItem menuItem = new MenuItem("Test Dummy");
		BuildTestDummySubmenu(menuItem);
		parentMenu.AddSubItem(menuItem);
		MenuItem menuItem2 = new MenuItem("Audio");
		BuildAudioSubmenu(menuItem2);
		parentMenu.AddSubItem(menuItem2);
		MenuItem menuItem3 = new MenuItem("Mouse");
		BuildMouseSubmenu(menuItem3);
		parentMenu.AddSubItem(menuItem3);
		parentMenu.AddSeparator();
		MenuItem menuItem4 = new MenuItem("Game Modifiers");
		BuildGameModifiersSubmenu(menuItem4);
		parentMenu.AddSubItem(menuItem4);
		MenuItem menuItem5 = new MenuItem("Slow Time");
		BuildSlowTimeSubmenu(menuItem5);
		parentMenu.AddSubItem(menuItem5);
		MenuItem menuItem6 = new MenuItem("Set Zoom");
		BuildSetZoomSubmenu(menuItem6);
		parentMenu.AddSubItem(menuItem6);
		parentMenu.AddSeparator();
		MenuItem menuItem7 = new MenuItem("Settings Profiles");
		BuildSettingsProfilesSubmenu(menuItem7);
		parentMenu.AddSubItem(menuItem7);
		parentMenu.AddSubItem(new MenuItem("Save All Mod Settings", delegate
		{
			UnityModManager.SaveSettingsAndParams();
			manager.CloseMenu();
		}));
	}

	public void BuildTestDummySubmenu(MenuItem parentMenu)
	{
		MenuAction spawnTestDummy = MenuAction.CreateSpawnTestDummy();
		parentMenu.AddSubItem(new MenuItem("Spawn Test Dummy", delegate
		{
			manager.ExecuteAction(spawnTestDummy);
		})
		{
			ActionId = spawnTestDummy.Id,
			MenuAction = spawnTestDummy
		});
		parentMenu.AddSubItem(new MenuItem("Clear All Test Dummies", delegate
		{
			TestDummyManager.RemoveAllDummies();
			if (Main.settings.isRecordingLevelEdits)
			{
				LevelEditAction item = LevelEditAction.CreateClearTestDummies();
				string currentLevelKey = Main.GetCurrentLevelKey();
				if (!string.IsNullOrEmpty(currentLevelKey))
				{
					if (!Main.settings.levelEditRecords.ContainsKey(currentLevelKey))
					{
						Main.settings.levelEditRecords[currentLevelKey] = new LevelEditRecord
						{
							LevelKey = currentLevelKey
						};
					}
					Main.settings.levelEditRecords[currentLevelKey].Actions.Add(item);
				}
			}
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem("Reset All Dummies", delegate
		{
			TestDummyManager.ResetAllDummies();
			manager.CloseMenu();
		}));
		parentMenu.AddSeparator();
		parentMenu.AddSubItem(new MenuItem("Show DPS Overlay", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.showTestDummyDPS.GetValueOrDefault(true),
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.showTestDummyDPS = isChecked;
				TestDummyManager.SetDPSOverlayVisibility(isChecked);
			}
		});
	}

	public void BuildAudioSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Print Audio Played", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.printAudioPlayed,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.printAudioPlayed = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Suppress Announcer", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.suppressAnnouncer,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.suppressAnnouncer = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Disable Flag Noise", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.disableFlagNoise,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.disableFlagNoise = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Disable Helicopter Noise", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.disableHelicopterNoise,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.disableHelicopterNoise = isChecked;
			}
		});
	}

	public void BuildMouseSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Show Mouse Position", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.showMousePosition,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.showMousePosition = isChecked;
			}
		});
		MenuAction copyPositionAction = MenuAction.CreateCopyMousePosition();
		parentMenu.AddSubItem(new MenuItem("Copy Mouse Position", delegate
		{
			manager.ExecuteAction(copyPositionAction);
		})
		{
			ActionId = copyPositionAction.Id,
			MenuAction = copyPositionAction
		});
	}

	public void BuildGameModifiersSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("One Hit Enemies", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.oneHitEnemies,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.oneHitEnemies = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Disable Enemy Spawns", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.disableEnemySpawn,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.disableEnemySpawn = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("Max Cage Spawns", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.maxCageSpawns,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.maxCageSpawns = isChecked;
			}
		});
		parentMenu.AddSubItem(new MenuItem("On-Screen Log", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = RocketMain.settings.ShowLogOnScreen,
			OnToggle = delegate(bool isChecked)
			{
				RocketMain.settings.ShowLogOnScreen = isChecked;
				if (isChecked)
				{
					ScreenLogger.Load();
				}
			}
		});
	}

	public void BuildSlowTimeSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Enable Slow Time", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.slowTime,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.slowTime = isChecked;
				if (isChecked)
				{
					Main.StartTimeSlow();
				}
				else
				{
					Main.StopTimeSlow();
				}
			}
		});
		parentMenu.AddSeparator();
		float slowTimeFactor = Main.settings.slowTimeFactor;
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(slowTimeFactor, 0.25f) ? "✓ " : "") + "0.25x", delegate
		{
			Main.settings.slowTimeFactor = 0.25f;
			Main.settings.slowTime = true;
			Main.StartTimeSlow();
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(slowTimeFactor, 0.5f) ? "✓ " : "") + "0.5x", delegate
		{
			Main.settings.slowTimeFactor = 0.5f;
			Main.settings.slowTime = true;
			Main.StartTimeSlow();
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(slowTimeFactor, 0.75f) ? "✓ " : "") + "0.75x", delegate
		{
			Main.settings.slowTimeFactor = 0.75f;
			Main.settings.slowTime = true;
			Main.StartTimeSlow();
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(slowTimeFactor, 1f) ? "✓ " : "") + "1.0x (Default)", delegate
		{
			Main.settings.slowTimeFactor = 1f;
			Main.settings.slowTime = false;
			Main.StopTimeSlow();
			manager.CloseMenu();
		}));
	}

	public void BuildSetZoomSubmenu(MenuItem parentMenu)
	{
		parentMenu.AddSubItem(new MenuItem("Enable Zoom", (Action)null)
		{
			ShowCheckbox = true,
			IsToggleAction = true,
			IsChecked = Main.settings.setZoom,
			OnToggle = delegate(bool isChecked)
			{
				Main.settings.setZoom = isChecked;
				if (isChecked)
				{
					SortOfFollow.zoomLevel = Main.settings.zoomLevel;
				}
				else
				{
					SortOfFollow.zoomLevel = 1f;
				}
			}
		});
		parentMenu.AddSeparator();
		float zoomLevel = Main.settings.zoomLevel;
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 0.25f) ? "✓ " : "") + "0.25x", delegate
		{
			SortOfFollow.zoomLevel = 0.25f;
			Main.settings.zoomLevel = 0.25f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 0.5f) ? "✓ " : "") + "0.5x", delegate
		{
			SortOfFollow.zoomLevel = 0.5f;
			Main.settings.zoomLevel = 0.5f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 0.75f) ? "✓ " : "") + "0.75x", delegate
		{
			SortOfFollow.zoomLevel = 0.75f;
			Main.settings.zoomLevel = 0.75f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 1f) ? "✓ " : "") + "1.0x (Default)", delegate
		{
			SortOfFollow.zoomLevel = 1f;
			Main.settings.zoomLevel = 1f;
			Main.settings.setZoom = false;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 1.25f) ? "✓ " : "") + "1.25x", delegate
		{
			SortOfFollow.zoomLevel = 1.25f;
			Main.settings.zoomLevel = 1.25f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 1.5f) ? "✓ " : "") + "1.5x", delegate
		{
			SortOfFollow.zoomLevel = 1.5f;
			Main.settings.zoomLevel = 1.5f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 1.75f) ? "✓ " : "") + "1.75x", delegate
		{
			SortOfFollow.zoomLevel = 1.75f;
			Main.settings.zoomLevel = 1.75f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
		parentMenu.AddSubItem(new MenuItem((Mathf.Approximately(zoomLevel, 2f) ? "✓ " : "") + "2.0x", delegate
		{
			SortOfFollow.zoomLevel = 2f;
			Main.settings.zoomLevel = 2f;
			Main.settings.setZoom = true;
			manager.CloseMenu();
		}));
	}

	public void BuildSettingsProfilesSubmenu(MenuItem parentMenu)
	{
		if (!string.IsNullOrEmpty(Main.settings.lastLoadedProfileName))
		{
			MenuItem menuItem = new MenuItem("Current: " + Main.settings.lastLoadedProfileName);
			menuItem.Enabled = false;
			parentMenu.AddSubItem(menuItem);
			parentMenu.AddSeparator();