Decompiled source of UpgradeMenu v1.0.0

UpgradeMenu.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MaliPrime.IMGUIFramework;
using MaliPrime.REPO.UpgradeMenu.Components;
using MaliPrime.REPO.UpgradeMenu.Core;
using MaliPrime.REPO.UpgradeMenu.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("UpgradeMenu")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UpgradeMenu")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c8d732de-884c-40c7-9cdb-3b56dc81fda2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MaliPrime.IMGUIFramework
{
	public static class GUIStateManager
	{
		private static Dictionary<string, string> _tempStringStates = new Dictionary<string, string>();

		private static string _focusedControlID = "";

		public static string GetTempString(string id, string defaultValue)
		{
			if (!_tempStringStates.ContainsKey(id))
			{
				_tempStringStates[id] = defaultValue;
			}
			return _tempStringStates[id];
		}

		public static void SetTempString(string id, string value)
		{
			_tempStringStates[id] = value;
		}

		public static bool CheckInteractionComplete(string controlID)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if (GUI.GetNameOfFocusedControl() == controlID)
			{
				_focusedControlID = controlID;
				if (current.isKey && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
				{
					GUI.FocusControl((string)null);
					return true;
				}
			}
			else if (_focusedControlID == controlID)
			{
				_focusedControlID = "";
				return true;
			}
			return false;
		}
	}
	public static class UIElements
	{
		public static bool IntStepper(string controlID, string labelText, int currentValue, out int newValue, int step = 1, int minValue = int.MinValue, int maxValue = int.MaxValue, float height = 45f, float buttonWidth = 45f)
		{
			int tempNewValue = currentValue;
			bool valueChanged = false;
			UIBuilder.Space(3f);
			UIBuilder.Label(labelText);
			UIBuilder.Row(delegate
			{
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Invalid comparison between Unknown and I4
				if (UIBuilder.Button("-", GUILayout.Width(buttonWidth), GUILayout.Height(height)))
				{
					tempNewValue = Mathf.Clamp(currentValue - step, minValue, maxValue);
					valueChanged = tempNewValue != currentValue;
					GUIStateManager.SetTempString(controlID, tempNewValue.ToString());
				}
				bool flag = GUI.GetNameOfFocusedControl() == controlID;
				if (!flag && (int)Event.current.type == 7)
				{
					GUIStateManager.SetTempString(controlID, currentValue.ToString());
				}
				string tempString = GUIStateManager.GetTempString(controlID, currentValue.ToString());
				string text = UIBuilder.NumberField(controlID, tempString, GUILayout.Height(height), GUILayout.MinWidth(0f), GUILayout.ExpandWidth(true));
				if (flag || GUI.GetNameOfFocusedControl() == controlID)
				{
					if (text != "" && text != "-")
					{
						if (long.TryParse(text, out var result))
						{
							if (result > maxValue)
							{
								text = maxValue.ToString();
							}
						}
						else
						{
							text = maxValue.ToString();
						}
					}
					GUIStateManager.SetTempString(controlID, text);
				}
				if (GUIStateManager.CheckInteractionComplete(controlID))
				{
					if (int.TryParse(text, out var result2))
					{
						tempNewValue = Mathf.Clamp(result2, minValue, maxValue);
						if (tempNewValue != currentValue)
						{
							valueChanged = true;
						}
					}
					GUIStateManager.SetTempString(controlID, tempNewValue.ToString());
				}
				if (UIBuilder.Button("+", GUILayout.Width(buttonWidth), GUILayout.Height(height)))
				{
					tempNewValue = Mathf.Clamp(currentValue + step, minValue, maxValue);
					valueChanged = tempNewValue != currentValue;
					GUIStateManager.SetTempString(controlID, tempNewValue.ToString());
				}
				GUILayout.Space(5f);
			});
			newValue = tempNewValue;
			return valueChanged;
		}
	}
	public class UITheme
	{
		public Color AccentColor;

		public Color AccentColorDark;

		public Color WindowBackground;

		public Color ButtonNormal;

		public Color TextFieldNormal;

		public Color TextFieldFocused;

		public Color TextColorNormal;

		public int FontSize;

		public RectOffset WindowPadding;

		public RectOffset ButtonPadding;

		public RectOffset TextFieldPadding;

		public static UITheme DarkOrange => new UITheme
		{
			AccentColor = new Color(1f, 0.5921569f, 0f, 1f),
			AccentColorDark = new Color(0.8f, 0.47058824f, 0f, 1f),
			WindowBackground = new Color(0.12f, 0.12f, 0.12f, 0.95f),
			ButtonNormal = new Color(0.18f, 0.18f, 0.18f, 1f),
			TextFieldNormal = new Color(0.1f, 0.1f, 0.1f, 1f),
			TextFieldFocused = new Color(0.16f, 0.16f, 0.16f, 1f),
			TextColorNormal = new Color(0.9f, 0.9f, 0.9f, 1f),
			FontSize = 16,
			WindowPadding = new RectOffset(15, 15, 35, 15),
			ButtonPadding = new RectOffset(0, 0, 0, 0),
			TextFieldPadding = new RectOffset(8, 8, 8, 8)
		};
	}
	public class UIBuilder
	{
		private static bool _stylesInitialized;

		private static UITheme _activeTheme;

		private static GUIStyle _windowStyle;

		private static GUIStyle _labelStyle;

		private static GUIStyle _buttonStyle;

		private static GUIStyle _textFieldStyle;

		private static GUIStyle _scrollViewStyle;

		public static void Initialize(UITheme theme)
		{
			//IL_0019: 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_0035: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Expected O, but got Unknown
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Expected O, but got Unknown
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Expected O, but got Unknown
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Expected O, but got Unknown
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Expected O, but got Unknown
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Expected O, but got Unknown
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Expected O, but got Unknown
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Expected O, but got Unknown
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Expected O, but got Unknown
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Expected O, but got Unknown
			if (!_stylesInitialized || _activeTheme != theme)
			{
				_activeTheme = theme;
				Texture2D background = MakeTex(2, 2, theme.WindowBackground);
				Texture2D background2 = MakeTex(2, 2, theme.ButtonNormal);
				Texture2D background3 = MakeTex(2, 2, theme.AccentColor);
				Texture2D background4 = MakeTex(2, 2, theme.AccentColorDark);
				Color bgColor = default(Color);
				((Color)(ref bgColor))..ctor(0.12f, 0.12f, 0.12f, 1f);
				Color borderCol = default(Color);
				((Color)(ref borderCol))..ctor(0.25f, 0.25f, 0.25f, 1f);
				Texture2D background5 = MakeBorderedTex(4, 4, bgColor, borderCol);
				Texture2D background6 = MakeBorderedTex(4, 4, bgColor, theme.AccentColor);
				_windowStyle = new GUIStyle(GUI.skin.window);
				_windowStyle.normal.background = background;
				_windowStyle.normal.textColor = theme.AccentColor;
				_windowStyle.onNormal.background = background;
				_windowStyle.onNormal.textColor = theme.AccentColor;
				_windowStyle.hover.background = background;
				_windowStyle.hover.textColor = theme.AccentColor;
				_windowStyle.onHover.background = background;
				_windowStyle.onHover.textColor = theme.AccentColor;
				_windowStyle.active.background = background;
				_windowStyle.active.textColor = theme.AccentColor;
				_windowStyle.onActive.background = background;
				_windowStyle.onActive.textColor = theme.AccentColor;
				_windowStyle.focused.background = background;
				_windowStyle.focused.textColor = theme.AccentColor;
				_windowStyle.onFocused.background = background;
				_windowStyle.onFocused.textColor = theme.AccentColor;
				_windowStyle.fontStyle = (FontStyle)1;
				_windowStyle.fontSize = theme.FontSize;
				_windowStyle.padding = theme.WindowPadding;
				_windowStyle.richText = true;
				_labelStyle = new GUIStyle(GUI.skin.label);
				_labelStyle.normal.textColor = theme.TextColorNormal;
				_labelStyle.fontSize = theme.FontSize - 1;
				_labelStyle.alignment = (TextAnchor)3;
				_labelStyle.margin = new RectOffset(0, 0, 5, 5);
				_labelStyle.wordWrap = true;
				_labelStyle.richText = true;
				_buttonStyle = new GUIStyle(GUI.skin.button);
				_buttonStyle.normal.background = background2;
				_buttonStyle.normal.textColor = theme.AccentColor;
				_buttonStyle.onNormal.background = background2;
				_buttonStyle.onNormal.textColor = theme.AccentColor;
				_buttonStyle.hover.background = background3;
				_buttonStyle.hover.textColor = Color.white;
				_buttonStyle.onHover.background = background3;
				_buttonStyle.onHover.textColor = Color.white;
				_buttonStyle.active.background = background4;
				_buttonStyle.active.textColor = Color.white;
				_buttonStyle.onActive.background = background4;
				_buttonStyle.onActive.textColor = Color.white;
				_buttonStyle.focused.background = background2;
				_buttonStyle.focused.textColor = theme.AccentColor;
				_buttonStyle.onFocused.background = background2;
				_buttonStyle.onFocused.textColor = theme.AccentColor;
				_buttonStyle.fontStyle = (FontStyle)1;
				_buttonStyle.fontSize = theme.FontSize;
				_buttonStyle.alignment = (TextAnchor)4;
				_buttonStyle.padding = theme.ButtonPadding;
				_buttonStyle.margin = new RectOffset(2, 2, 0, 0);
				_buttonStyle.wordWrap = false;
				_buttonStyle.clipping = (TextClipping)1;
				_textFieldStyle = new GUIStyle(GUI.skin.textField);
				_textFieldStyle.normal.background = background5;
				_textFieldStyle.normal.textColor = Color.white;
				_textFieldStyle.onNormal.background = background5;
				_textFieldStyle.onNormal.textColor = Color.white;
				_textFieldStyle.hover.background = background6;
				_textFieldStyle.hover.textColor = Color.white;
				_textFieldStyle.onHover.background = background6;
				_textFieldStyle.onHover.textColor = Color.white;
				_textFieldStyle.focused.background = background6;
				_textFieldStyle.focused.textColor = theme.AccentColor;
				_textFieldStyle.onFocused.background = background6;
				_textFieldStyle.onFocused.textColor = theme.AccentColor;
				_textFieldStyle.active.background = background6;
				_textFieldStyle.active.textColor = theme.AccentColor;
				_textFieldStyle.onActive.background = background6;
				_textFieldStyle.onActive.textColor = theme.AccentColor;
				_textFieldStyle.border = new RectOffset(1, 1, 1, 1);
				_textFieldStyle.fontSize = theme.FontSize;
				_textFieldStyle.alignment = (TextAnchor)4;
				_textFieldStyle.padding = theme.TextFieldPadding;
				_textFieldStyle.margin = new RectOffset(2, 2, 0, 0);
				_textFieldStyle.wordWrap = false;
				_textFieldStyle.clipping = (TextClipping)1;
				_scrollViewStyle = new GUIStyle(GUI.skin.scrollView);
				_scrollViewStyle.normal.background = null;
				Texture2D background7 = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.15f));
				Texture2D background8 = MakeTex(2, 2, theme.AccentColor);
				Texture2D background9 = MakeTex(2, 2, theme.AccentColorDark);
				GUIStyle val = new GUIStyle(GUI.skin.verticalScrollbar);
				val.normal.background = background7;
				val.fixedWidth = 8f;
				val.margin = new RectOffset(4, 6, 0, 0);
				GUI.skin.verticalScrollbar = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.verticalScrollbarThumb);
				val2.normal.background = background8;
				val2.hover.background = background9;
				val2.active.background = background9;
				val2.fixedWidth = 8f;
				GUI.skin.verticalScrollbarThumb = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.horizontalScrollbar);
				val3.normal.background = background7;
				val3.fixedHeight = 8f;
				val3.margin = new RectOffset(0, 0, 4, 6);
				GUI.skin.horizontalScrollbar = val3;
				GUIStyle val4 = new GUIStyle(GUI.skin.horizontalScrollbarThumb);
				val4.normal.background = background8;
				val4.hover.background = background9;
				val4.active.background = background9;
				val4.fixedHeight = 8f;
				GUI.skin.horizontalScrollbarThumb = val4;
				_stylesInitialized = true;
			}
		}

		private static Texture2D MakeBorderedTex(int width, int height, Color bgColor, Color borderCol)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					bool flag = j == 0 || j == width - 1 || i == 0 || i == height - 1;
					array[i * width + j] = (flag ? borderCol : bgColor);
				}
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)0;
			return val;
		}

		private static Texture2D MakeTex(int width, int height, Color col)
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)0;
			return val;
		}

		public static Rect Window(int id, Rect rect, string title, Action children, UITheme theme = null)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Initialize(theme);
			return GUI.Window(id, rect, (WindowFunction)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				if ((int)Event.current.type == 0)
				{
					GUIUtility.keyboardControl = 0;
				}
				children?.Invoke();
				GUI.DragWindow(new Rect(0f, 0f, 10000f, 50f));
			}, title, _windowStyle);
		}

		public static void Row(Action children, params GUILayoutOption[] options)
		{
			GUILayout.BeginHorizontal(options);
			try
			{
				children?.Invoke();
			}
			finally
			{
				GUILayout.EndHorizontal();
			}
		}

		public static void Column(Action children, params GUILayoutOption[] options)
		{
			GUILayout.BeginVertical(options);
			try
			{
				children?.Invoke();
			}
			finally
			{
				GUILayout.EndVertical();
			}
		}

		public static void Space(float pixels = 10f)
		{
			GUILayout.Space(pixels);
		}

		public static void Label(string text, params GUILayoutOption[] options)
		{
			GUILayout.Label(text, _labelStyle, options);
		}

		public static bool Button(string text, params GUILayoutOption[] options)
		{
			return GUILayout.Button(text, _buttonStyle, options);
		}

		public static string TextField(string controlID, string value, params GUILayoutOption[] options)
		{
			GUI.SetNextControlName(controlID);
			return GUILayout.TextField(value, _textFieldStyle, options);
		}

		public static string NumberField(string controlID, string value, params GUILayoutOption[] options)
		{
			GUI.SetNextControlName(controlID);
			string text = GUILayout.TextField(value, _textFieldStyle, options);
			string text2 = "";
			string text3 = text;
			for (int i = 0; i < text3.Length; i++)
			{
				char c = text3[i];
				if (char.IsDigit(c))
				{
					text2 += c;
				}
			}
			return text2;
		}

		public static Vector2 ScrollView(Vector2 scrollPosition, Action children, params GUILayoutOption[] options)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Vector2 result = GUILayout.BeginScrollView(scrollPosition, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, _scrollViewStyle, options);
			try
			{
				children?.Invoke();
			}
			finally
			{
				GUILayout.EndScrollView();
			}
			return result;
		}
	}
}
namespace MaliPrime.REPO.UpgradeMenu
{
	[BepInPlugin("com.maliprime.repo.upgrademenu", "MaliPrime R.E.P.O Upgrade Menu", "1.0.0")]
	internal class Plugin : BaseUnityPlugin
	{
		public const string GUID = "com.maliprime.repo.upgrademenu";

		public const string PluginName = "MaliPrime R.E.P.O Upgrade Menu";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			try
			{
				ModLogger.Init(((BaseUnityPlugin)this).Logger);
				_harmony = new Harmony("com.maliprime.repo.upgrademenu");
				_harmony.PatchAll(typeof(Plugin).Assembly);
				SceneManager.sceneLoaded += OnSceneLoaded;
			}
			catch (Exception message)
			{
				ModLogger.Error(message);
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//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_0016: Expected O, but got Unknown
			GameObject val = new GameObject("MaliPrime R.E.P.O Upgrade Menu Control Panel");
			val.AddComponent<ControlPanel>();
			Object.DontDestroyOnLoad((Object)val);
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}
	}
}
namespace MaliPrime.REPO.UpgradeMenu.Patches
{
	[HarmonyPatch(typeof(RunManager))]
	internal class RunManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ChangeLevel")]
		private static void PostfixChangeLevel()
		{
			LocalPlayer.Playable = IsPlayableLevel();
			LocalPlayer.Init();
		}

		private static bool IsPlayableLevel()
		{
			if (!SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop())
			{
				return SemiFunc.RunIsArena();
			}
			return true;
		}
	}
}
namespace MaliPrime.REPO.UpgradeMenu.Utils
{
	internal static class ModUI
	{
		public static void SetCursorVisible(bool visible)
		{
			Cursor.visible = visible;
			Cursor.lockState = (CursorLockMode)((!visible) ? 1 : 2);
		}
	}
	internal static class ModLogger
	{
		private static ManualLogSource _logger;

		public static void Init(ManualLogSource logger)
		{
			_logger = logger;
		}

		public static void Info(object message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogInfo(message);
			}
		}

		public static void Warning(object message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogWarning(message);
			}
		}

		public static void Error(object message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogError(message);
			}
		}
	}
}
namespace MaliPrime.REPO.UpgradeMenu.Core
{
	internal static class LocalPlayer
	{
		public static bool Playable { get; set; }

		public static string SteamID { get; set; }

		public static void Init()
		{
			if (Playable && string.IsNullOrEmpty(SteamID))
			{
				SteamID = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(SemiFunc.PhotonViewIDPlayerAvatarLocal()));
			}
		}

		public static string GetSteamID()
		{
			return SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(SemiFunc.PhotonViewIDPlayerAvatarLocal()));
		}

		public static int GetHealthValue()
		{
			StatsManager.instance.playerUpgradeHealth.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetEnergyValue()
		{
			StatsManager.instance.playerUpgradeStamina.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetSprintSpeedValue()
		{
			StatsManager.instance.playerUpgradeSpeed.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetCrouchRestValue()
		{
			StatsManager.instance.playerUpgradeCrouchRest.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetGrabStrengthValue()
		{
			StatsManager.instance.playerUpgradeStrength.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetGrabRangeValue()
		{
			StatsManager.instance.playerUpgradeRange.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetExtraJumpValue()
		{
			StatsManager.instance.playerUpgradeExtraJump.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetTumbleWingsValue()
		{
			StatsManager.instance.playerUpgradeTumbleWings.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetTumbleLaunchValue()
		{
			StatsManager.instance.playerUpgradeLaunch.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetTumbleClimbValue()
		{
			StatsManager.instance.playerUpgradeTumbleClimb.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetDeathHeadBatteryValue()
		{
			StatsManager.instance.playerUpgradeDeathHeadBattery.TryGetValue(SteamID, out var value);
			return value;
		}

		public static int GetDeathMapPlayerCountValue()
		{
			StatsManager.instance.playerUpgradeMapPlayerCount.TryGetValue(SteamID, out var value);
			return value;
		}
	}
	internal static class PlayerUpgrade
	{
		public static void UpgradeHealth(int value)
		{
			int num = value - LocalPlayer.GetHealthValue();
			PunManager.instance.UpgradePlayerHealth(LocalPlayer.SteamID, num);
		}

		public static void UpgradeEnergy(int value)
		{
			int num = value - LocalPlayer.GetEnergyValue();
			PunManager.instance.UpgradePlayerEnergy(LocalPlayer.SteamID, num);
		}

		public static void UpgradeSprintSpeed(int value)
		{
			int num = value - LocalPlayer.GetSprintSpeedValue();
			PunManager.instance.UpgradePlayerSprintSpeed(LocalPlayer.SteamID, num);
		}

		public static void UpgradeCrouchRest(int value)
		{
			int num = value - LocalPlayer.GetCrouchRestValue();
			PunManager.instance.UpgradePlayerCrouchRest(LocalPlayer.SteamID, num);
		}

		public static void UpgradeGrabStrength(int value)
		{
			int num = value - LocalPlayer.GetGrabStrengthValue();
			PunManager.instance.UpgradePlayerGrabStrength(LocalPlayer.SteamID, num);
		}

		public static void UpgradeGrabRange(int value)
		{
			int num = value - LocalPlayer.GetGrabRangeValue();
			PunManager.instance.UpgradePlayerGrabRange(LocalPlayer.SteamID, num);
		}

		public static void UpgradeExtraJump(int value)
		{
			int num = value - LocalPlayer.GetExtraJumpValue();
			PunManager.instance.UpgradePlayerExtraJump(LocalPlayer.SteamID, num);
		}

		public static void UpgradeTumbleWings(int value)
		{
			int num = value - LocalPlayer.GetTumbleWingsValue();
			PunManager.instance.UpgradePlayerTumbleWings(LocalPlayer.SteamID, num);
		}

		public static void UpgradeTumbleLaunch(int value)
		{
			int num = value - LocalPlayer.GetTumbleLaunchValue();
			PunManager.instance.UpgradePlayerTumbleLaunch(LocalPlayer.SteamID, num);
		}

		public static void UpgradeTumbleClimb(int value)
		{
			int num = value - LocalPlayer.GetTumbleClimbValue();
			PunManager.instance.UpgradePlayerTumbleClimb(LocalPlayer.SteamID, num);
		}

		public static void UpgradeDeathHeadBattery(int value)
		{
			int num = value - LocalPlayer.GetDeathHeadBatteryValue();
			PunManager.instance.UpgradeDeathHeadBattery(LocalPlayer.SteamID, num);
		}

		public static void UpgradeDeathMapPlayerCount(int value)
		{
			int num = value - LocalPlayer.GetDeathMapPlayerCountValue();
			PunManager.instance.UpgradeMapPlayerCount(LocalPlayer.SteamID, num);
		}
	}
}
namespace MaliPrime.REPO.UpgradeMenu.Components
{
	internal class ControlPanel : MonoBehaviour
	{
		private class StepperConfig
		{
			public string Id;

			public string Label;

			public int Value;

			public int Max;

			public Action<int> OnValueChanged;

			public StepperConfig(string id, string label, int value, int max, Action<int> onValueChanged = null)
			{
				Id = id;
				Label = label;
				Value = value;
				Max = max;
				OnValueChanged = onValueChanged;
			}
		}

		private Rect _windowRect = new Rect(20f, 20f, 400f, 600f);

		private bool _isVisible;

		private bool _syncValues;

		private Vector2 _scrollPosition = Vector2.zero;

		private List<StepperConfig> _stepperConfigs = new List<StepperConfig>
		{
			new StepperConfig("health", "Health", 0, 10000, PlayerUpgrade.UpgradeHealth),
			new StepperConfig("energy", "Energy", 0, 10000, PlayerUpgrade.UpgradeEnergy),
			new StepperConfig("sprint_speed", "Sprint Speed", 0, 1000, PlayerUpgrade.UpgradeSprintSpeed),
			new StepperConfig("crouch_rest", "Crouch Rest", 0, 1000, PlayerUpgrade.UpgradeCrouchRest),
			new StepperConfig("grab_strength", "Grab Strength", 0, 1000, PlayerUpgrade.UpgradeGrabStrength),
			new StepperConfig("grab_range", "Grab Range", 0, 1000, PlayerUpgrade.UpgradeGrabRange),
			new StepperConfig("extra_jump", "Extra Jump", 0, 10000, PlayerUpgrade.UpgradeExtraJump),
			new StepperConfig("tumble_wings", "Tumble Wings", 0, 1000, PlayerUpgrade.UpgradeTumbleWings),
			new StepperConfig("tumble_launch", "Tumble Launch", 0, 1000, PlayerUpgrade.UpgradeTumbleLaunch),
			new StepperConfig("tumble_climb", "Tumble Climb", 0, 1000, PlayerUpgrade.UpgradeTumbleClimb),
			new StepperConfig("death_head_battery", "Death Head Battery", 0, 10000, PlayerUpgrade.UpgradeDeathHeadBattery),
			new StepperConfig("map_player_count", "Map Player Count", 0, 1, PlayerUpgrade.UpgradeDeathMapPlayerCount)
		};

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(SyncLocalPlayerUpgradeValues());
		}

		private IEnumerator SyncLocalPlayerUpgradeValues()
		{
			while (!LocalPlayer.Playable)
			{
				yield return null;
			}
			UpdateSetting("health", LocalPlayer.GetHealthValue());
			UpdateSetting("energy", LocalPlayer.GetEnergyValue());
			UpdateSetting("sprint_speed", LocalPlayer.GetSprintSpeedValue());
			UpdateSetting("crouch_rest", LocalPlayer.GetCrouchRestValue());
			UpdateSetting("grab_strength", LocalPlayer.GetGrabStrengthValue());
			UpdateSetting("grab_range", LocalPlayer.GetGrabRangeValue());
			UpdateSetting("extra_jump", LocalPlayer.GetExtraJumpValue());
			UpdateSetting("tumble_wings", LocalPlayer.GetTumbleWingsValue());
			UpdateSetting("tumble_launch", LocalPlayer.GetTumbleLaunchValue());
			UpdateSetting("tumble_climb", LocalPlayer.GetTumbleClimbValue());
			UpdateSetting("death_head_battery", LocalPlayer.GetDeathHeadBatteryValue());
			UpdateSetting("map_player_count", LocalPlayer.GetDeathMapPlayerCountValue());
			_syncValues = true;
		}

		private void UpdateSetting(string id, int newValue)
		{
			StepperConfig stepperConfig = _stepperConfigs.Find((StepperConfig s) => s.Id == id);
			if (stepperConfig != null)
			{
				stepperConfig.Value = newValue;
			}
		}

		private void Update()
		{
			if (_syncValues && LocalPlayer.Playable && Input.GetKeyDown((KeyCode)283))
			{
				_isVisible = !_isVisible;
				ModUI.SetCursorVisible(_isVisible);
			}
		}

		private void OnGUI()
		{
			//IL_0016: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!_isVisible)
			{
				return;
			}
			CameraAim.Instance.OverrideAimStop();
			_windowRect = UIBuilder.Window(0, _windowRect, "MaliPrime Upgrade Menu", delegate
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				_scrollPosition = UIBuilder.ScrollView(_scrollPosition, delegate
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					UIBuilder.Space(8f);
					UIBuilder.Column(delegate
					{
						UIBuilder.Space(5f);
						for (int i = 0; i < _stepperConfigs.Count; i++)
						{
							StepperConfig stepperConfig = _stepperConfigs[i];
							if (UIElements.IntStepper(stepperConfig.Id, stepperConfig.Label, stepperConfig.Value, out var newValue, 1, 0, stepperConfig.Max))
							{
								stepperConfig.Value = newValue;
								stepperConfig.OnValueChanged?.Invoke(newValue);
							}
							if (i < _stepperConfigs.Count - 1)
							{
								UIBuilder.Space(4f);
							}
						}
						UIBuilder.Space(5f);
					});
					UIBuilder.Space(8f);
					GUILayout.EndHorizontal();
				});
			}, UITheme.DarkOrange);
		}
	}
}