Decompiled source of StatMod v1.0.4

StatMod.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using Assets.Scripts.Inventory__Items__Pickups.Stats;
using Assets.Scripts.Menu.Shop;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StatModMod
{
	[BepInPlugin("anro_StatMod", "StatMod", "1.0.2")]
	public class Plugin : BasePlugin
	{
		public class StatModUI : MonoBehaviour
		{
			private enum StatCategory
			{
				Offensive,
				Defensive,
				Movement,
				Utility,
				Misc
			}

			private class ButtonInfo
			{
				public string label;

				public float value;

				public ButtonInfo(string label, float value)
				{
					this.label = label;
					this.value = value;
				}
			}

			private static bool showMenu = false;

			private static Vector2 scrollPosition = Vector2.zero;

			private static Rect windowRect = new Rect(50f, 50f, 900f, 700f);

			private static string searchText = "";

			private static Texture2D backgroundTexture;

			private static GUIStyle windowStyle;

			private static GUIStyle labelStyle;

			private static GUIStyle buttonStyle;

			private static GUIStyle headerStyle;

			private static GUIStyle searchBoxStyle;

			private static bool stylesInitialized = false;

			private static Dictionary<EStat, float> modAppliedTotals = new Dictionary<EStat, float>();

			private static EStat[] allStats;

			private static EStat[] playerStats;

			private static string[] statNames;

			public StatModUI(IntPtr ptr)
				: base(ptr)
			{
			}

			private void Start()
			{
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				allStats = (EStat[])Enum.GetValues(typeof(EStat));
				statNames = Enum.GetNames(typeof(EStat));
				playerStats = (from stat in allStats.Where((EStat stat) => !IsExcludedStat(stat)).ToList()
					orderby GetStatCategory(stat), statNames[stat]
					select stat).ToArray();
				log.LogInfo((object)"StatMod UI initialized!");
			}

			private static StatCategory GetStatCategory(EStat stat)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Expected I4, but got Unknown
				switch ((int)stat)
				{
				case 9:
				case 10:
				case 11:
				case 12:
				case 14:
				case 15:
				case 16:
				case 17:
				case 18:
				case 19:
				case 20:
				case 21:
				case 22:
				case 23:
				case 24:
				case 42:
				case 43:
				case 44:
				case 45:
				case 56:
					return StatCategory.Offensive;
				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 7:
				case 8:
				case 47:
				case 48:
					return StatCategory.Defensive;
				case 25:
				case 26:
				case 27:
				case 28:
				case 46:
					return StatCategory.Movement;
				case 29:
				case 30:
				case 31:
				case 32:
				case 33:
				case 34:
				case 35:
				case 40:
				case 41:
				case 49:
					return StatCategory.Utility;
				default:
					return StatCategory.Misc;
				}
			}

			private static Color GetCategoryColor(StatCategory category)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: 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_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				return (Color)(category switch
				{
					StatCategory.Offensive => new Color(1f, 0.4f, 0.4f), 
					StatCategory.Defensive => new Color(0.4f, 0.7f, 1f), 
					StatCategory.Movement => new Color(0.4f, 1f, 0.5f), 
					StatCategory.Utility => new Color(1f, 0.9f, 0.3f), 
					StatCategory.Misc => new Color(0.9f, 0.6f, 1f), 
					_ => Color.white, 
				});
			}

			private static bool IsExcludedStat(EStat stat)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Invalid comparison between Unknown and I4
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				//IL_000a: 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_000f: Invalid comparison between Unknown and I4
				if ((int)stat == 13 || (int)stat == 39 || stat - 50 <= 5)
				{
					return true;
				}
				return false;
			}

			private void Update()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				if (Input.GetKeyDown((KeyCode)285))
				{
					showMenu = !showMenu;
					if (showMenu)
					{
						searchText = "";
					}
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Stat mod menu ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(showMenu ? "opened" : "closed");
					}
					log.LogInfo(val);
				}
				if (showMenu)
				{
					HandleSearchInput();
				}
			}

			private void OnGUI()
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				if (!showMenu)
				{
					return;
				}
				GameManager instance = GameManager.Instance;
				if ((Object)(object)instance == (Object)null || instance.GetPlayerInventory() == null)
				{
					return;
				}
				if (stylesInitialized && (Object)(object)backgroundTexture == (Object)null)
				{
					stylesInitialized = false;
				}
				if (!stylesInitialized)
				{
					InitializeStyles();
				}
				try
				{
					windowRect = GUI.Window(54321, windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "Stat Modifier v1.0.2 - Press F4 to close", windowStyle);
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("GUI.Window failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val);
				}
			}

			private static void HandleSearchInput()
			{
				string inputString = Input.inputString;
				for (int i = 0; i < inputString.Length; i++)
				{
					char c = inputString[i];
					switch (c)
					{
					case '\b':
						if (searchText.Length > 0)
						{
							searchText = searchText.Substring(0, searchText.Length - 1);
						}
						break;
					default:
						if (char.IsLetterOrDigit(c) || c == ' ')
						{
							searchText += c;
						}
						break;
					case '\n':
					case '\r':
						break;
					}
				}
			}

			private static void InitializeStyles()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Expected O, but got Unknown
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Expected O, but got Unknown
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Expected O, but got Unknown
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Expected O, but got Unknown
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Expected O, but got Unknown
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				backgroundTexture = new Texture2D(1, 1);
				backgroundTexture.SetPixel(0, 0, new Color(0.15f, 0.15f, 0.15f, 0.95f));
				backgroundTexture.Apply();
				windowStyle = new GUIStyle(GUI.skin.window);
				windowStyle.normal.background = backgroundTexture;
				windowStyle.onNormal.background = backgroundTexture;
				windowStyle.normal.textColor = Color.white;
				windowStyle.fontSize = 14;
				labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.normal.textColor = Color.white;
				labelStyle.fontSize = 12;
				buttonStyle = new GUIStyle(GUI.skin.button);
				buttonStyle.normal.textColor = Color.white;
				buttonStyle.fontSize = 11;
				headerStyle = new GUIStyle(GUI.skin.label);
				headerStyle.normal.textColor = Color.yellow;
				headerStyle.fontSize = 13;
				headerStyle.fontStyle = (FontStyle)1;
				searchBoxStyle = new GUIStyle(GUI.skin.box);
				searchBoxStyle.normal.textColor = Color.white;
				searchBoxStyle.fontSize = 13;
				stylesInitialized = true;
			}

			private static void DrawWindow(int windowID)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e8: Expected O, but got Unknown
				//IL_00a1: 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_00a6: 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_00b2: Expected O, but got Unknown
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0234: Unknown result type (might be due to invalid IL or missing references)
				//IL_0238: Unknown result type (might be due to invalid IL or missing references)
				//IL_023d: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
					int num = 25;
					GUI.Label(new Rect(10f, (float)num, 100f, 25f), "Search:", labelStyle);
					GUI.Box(new Rect(75f, (float)num, 640f, 25f), "");
					string text = (string.IsNullOrEmpty(searchText) ? "Type to search..." : searchText);
					Color textColor = (Color)(string.IsNullOrEmpty(searchText) ? new Color(0.6f, 0.6f, 0.6f) : Color.white);
					GUIStyle val = new GUIStyle(labelStyle);
					val.normal.textColor = textColor;
					GUI.Label(new Rect(80f, (float)(num + 1), 630f, 23f), text + "_", val);
					if (GUI.Button(new Rect(725f, (float)num, 80f, 25f), "Clear", buttonStyle))
					{
						searchText = "";
					}
					if (GUI.Button(new Rect(815f, (float)num, 75f, 25f), "Reset All", buttonStyle))
					{
						ResetAllModStats();
					}
					num += 30;
					EStat[] filteredStats = GetFilteredStats();
					string value = " (Note: Some stats like XP may be capped by the game)";
					GUI.Label(new Rect(10f, (float)num, 880f, 20f), $"Found {filteredStats.Length} of {playerStats.Length} player stats{value}", labelStyle);
					num += 22;
					GUI.Box(new Rect(10f, (float)num, 880f, 2f), "");
					num += 5;
					int num2 = CalculateScrollContentHeight(filteredStats);
					Rect val2 = new Rect(10f, (float)num, 880f, 590f);
					Rect val3 = default(Rect);
					((Rect)(ref val3))..ctor(0f, 0f, 860f, (float)num2);
					scrollPosition = GUI.BeginScrollView(val2, scrollPosition, val3, false, true);
					int num3 = 0;
					StatCategory? statCategory = null;
					int num4 = 0;
					for (int i = 0; i < filteredStats.Length; i++)
					{
						StatCategory statCategory2 = GetStatCategory(filteredStats[i]);
						if (!statCategory.HasValue || statCategory != statCategory2)
						{
							DrawCategoryHeader(statCategory2, num3);
							num3 += 28;
							statCategory = statCategory2;
							num4 = 0;
						}
						DrawStatRow(filteredStats[i], num4, num3, statCategory2);
						num3 += 32;
						num4++;
					}
					GUI.EndScrollView();
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("DrawWindow error: ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val4);
				}
			}

			private static int CalculateScrollContentHeight(EStat[] stats)
			{
				if (stats.Length == 0)
				{
					return 0;
				}
				int num = 0;
				StatCategory? statCategory = null;
				for (int i = 0; i < stats.Length; i++)
				{
					StatCategory statCategory2 = GetStatCategory(stats[i]);
					if (!statCategory.HasValue || statCategory != statCategory2)
					{
						num += 28;
						statCategory = statCategory2;
					}
					num += 32;
				}
				return num;
			}

			private static void DrawCategoryHeader(StatCategory category, int yPos)
			{
				//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_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				Color categoryColor = GetCategoryColor(category);
				GUIStyle val = new GUIStyle(headerStyle);
				val.normal.textColor = categoryColor;
				string text = "";
				switch (category)
				{
				case StatCategory.Offensive:
					text = "⚔\ufe0f";
					break;
				case StatCategory.Defensive:
					text = "\ud83d\udee1\ufe0f";
					break;
				case StatCategory.Movement:
					text = "\ud83d\udc5f";
					break;
				case StatCategory.Utility:
					text = "\ud83c\udf92";
					break;
				case StatCategory.Misc:
					text = "✨";
					break;
				}
				GUI.Box(new Rect(0f, (float)yPos, 860f, 26f), "", GUI.skin.box);
				GUI.Label(new Rect(10f, (float)(yPos + 3), 840f, 22f), text + " " + category, val);
			}

			private static void DrawStatRow(EStat stat, int index, int yPos, StatCategory category)
			{
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bd: Expected O, but got Unknown
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: 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_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					GameManager instance = GameManager.Instance;
					if ((Object)(object)instance == (Object)null)
					{
						return;
					}
					PlayerInventory playerInventory = instance.GetPlayerInventory();
					if (playerInventory == null)
					{
						return;
					}
					PlayerStatsNew val = playerInventory.playerStats;
					if (val == null)
					{
						return;
					}
					if (index % 2 == 0)
					{
						GUI.Box(new Rect(0f, (float)yPos, 860f, 30f), "", GUI.skin.box);
					}
					string text = FormatStatName(statNames[stat]);
					float stat2 = val.GetStat(stat);
					GUIStyle val2 = new GUIStyle(labelStyle);
					val2.normal.textColor = GetCategoryColor(category);
					GUI.Label(new Rect(10f, (float)(yPos + 5), 200f, 25f), text, val2);
					GUI.Label(new Rect(220f, (float)(yPos + 5), 100f, 25f), $"Current: {stat2:F2}", labelStyle);
					List<ButtonInfo> buttonsForStat = GetButtonsForStat(stat);
					int num = 330;
					foreach (ButtonInfo item in buttonsForStat)
					{
						if (GUI.Button(new Rect((float)num, (float)(yPos + 3), 70f, 24f), item.label, buttonStyle))
						{
							ModifyStat(stat, item.value, playerInventory);
						}
						num += 75;
					}
					if (GUI.Button(new Rect(780f, (float)(yPos + 3), 70f, 24f), "Reset", buttonStyle))
					{
						ResetStat(stat, playerInventory);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("DrawStatRow error: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val3);
				}
			}

			private static string FormatStatName(string name)
			{
				if (string.IsNullOrEmpty(name))
				{
					return name;
				}
				return Regex.Replace(Regex.Replace(name, "([a-z])([A-Z])", "$1 $2"), "([A-Z]+)([A-Z][a-z])", "$1 $2");
			}

			private static List<ButtonInfo> GetButtonsForStat(EStat stat)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Expected I4, but got Unknown
				List<ButtonInfo> list = new List<ButtonInfo>();
				switch ((int)stat)
				{
				case 5:
				case 18:
				case 30:
				case 38:
				case 41:
				case 42:
				case 43:
					list.Add(new ButtonInfo("+1%", 0.01f));
					list.Add(new ButtonInfo("+5%", 0.05f));
					list.Add(new ButtonInfo("+10%", 0.1f));
					list.Add(new ButtonInfo("+25%", 0.25f));
					break;
				case 16:
				case 45:
				case 46:
					list.Add(new ButtonInfo("+1", 1f));
					list.Add(new ButtonInfo("+2", 2f));
					list.Add(new ButtonInfo("+5", 5f));
					list.Add(new ButtonInfo("+10", 10f));
					break;
				case 26:
				case 28:
				case 29:
					list.Add(new ButtonInfo("+1", 1f));
					list.Add(new ButtonInfo("+5", 5f));
					list.Add(new ButtonInfo("+10", 10f));
					list.Add(new ButtonInfo("+25", 25f));
					break;
				case 0:
				case 2:
				case 47:
					list.Add(new ButtonInfo("+50", 50f));
					list.Add(new ButtonInfo("+100", 100f));
					list.Add(new ButtonInfo("+250", 250f));
					list.Add(new ButtonInfo("+500", 500f));
					break;
				case 7:
				case 8:
				case 9:
				case 10:
				case 11:
				case 12:
				case 14:
				case 23:
				case 24:
				case 25:
				case 31:
				case 32:
				case 33:
				case 34:
				case 40:
				case 48:
				case 49:
				case 50:
				case 51:
				case 52:
				case 53:
				case 54:
				case 55:
				case 56:
					list.Add(new ButtonInfo("+0.1x", 0.1f));
					list.Add(new ButtonInfo("+0.5x", 0.5f));
					list.Add(new ButtonInfo("+1.0x", 1f));
					list.Add(new ButtonInfo("+2.0x", 2f));
					break;
				case 1:
				case 3:
				case 4:
				case 6:
				case 15:
				case 17:
				case 19:
				case 20:
				case 21:
				case 22:
				case 27:
				case 35:
				case 36:
				case 37:
				case 39:
				case 44:
					list.Add(new ButtonInfo("+1", 1f));
					list.Add(new ButtonInfo("+5", 5f));
					list.Add(new ButtonInfo("+10", 10f));
					list.Add(new ButtonInfo("+25", 25f));
					break;
				default:
					list.Add(new ButtonInfo("+1", 1f));
					list.Add(new ButtonInfo("+5", 5f));
					list.Add(new ButtonInfo("+10", 10f));
					list.Add(new ButtonInfo("+25", 25f));
					break;
				}
				return list;
			}

			private static void ModifyStat(EStat stat, float value, PlayerInventory playerInventory)
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Expected O, but got Unknown
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				//IL_0016: 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_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				bool flag = default(bool);
				try
				{
					StatInventory statInventory = playerInventory.statInventory;
					if (statInventory != null)
					{
						StatModifier val = new StatModifier();
						val.stat = stat;
						val.modifyType = (EStatModifyType)2;
						val.modification = value;
						if (modAppliedTotals.ContainsKey(stat))
						{
							modAppliedTotals[stat] += value;
						}
						else
						{
							modAppliedTotals[stat] = value;
						}
						statInventory.ChangeStat(val, true, 0f, false);
						ManualLogSource log = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Modified ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<EStat>(stat);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by +");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(value);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (total mod: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(modAppliedTotals[stat]);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
						}
						log.LogInfo(val2);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log2 = Plugin.log;
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(24, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to modify stat ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<EStat>(stat);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log2.LogError(val3);
				}
			}

			private static void ResetStat(EStat stat, PlayerInventory playerInventory)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Expected O, but got Unknown
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				//IL_0060: 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_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Expected O, but got Unknown
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				bool flag = default(bool);
				try
				{
					if (!modAppliedTotals.ContainsKey(stat))
					{
						ManualLogSource log = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No mod changes to reset for ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EStat>(stat);
						}
						log.LogInfo(val);
						return;
					}
					StatInventory statInventory = playerInventory.statInventory;
					if (statInventory != null)
					{
						float num = modAppliedTotals[stat];
						StatModifier val2 = new StatModifier();
						val2.stat = stat;
						val2.modifyType = (EStatModifyType)2;
						val2.modification = 0f - num;
						statInventory.ChangeStat(val2, true, 0f, false);
						modAppliedTotals.Remove(stat);
						ManualLogSource log2 = Plugin.log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Reset ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EStat>(stat);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (removed total modification of ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
						}
						log2.LogInfo(val);
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log3 = Plugin.log;
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(23, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to reset stat ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<EStat>(stat);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log3.LogError(val3);
				}
			}

			private static void ResetAllModStats()
			{
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					GameManager instance = GameManager.Instance;
					if ((Object)(object)instance == (Object)null)
					{
						return;
					}
					PlayerInventory playerInventory = instance.GetPlayerInventory();
					if (playerInventory == null)
					{
						return;
					}
					foreach (EStat item in modAppliedTotals.Keys.ToList())
					{
						ResetStat(item, playerInventory);
					}
					Plugin.log.LogInfo((object)"Reset all mod-applied stats");
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to reset all stats: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val);
				}
			}

			private static EStat[] GetFilteredStats()
			{
				if (string.IsNullOrEmpty(searchText))
				{
					return playerStats;
				}
				return playerStats.Where(delegate(EStat stat)
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					int num = Array.IndexOf(allStats, stat);
					return statNames[num].ToLower().Contains(searchText.ToLower());
				}).ToArray();
			}
		}

		public const string MODNAME = "StatMod";

		public const string AUTHOR = "anro";

		public const string GUID = "anro_StatMod";

		public const string VERSION = "1.0.2";

		private static ManualLogSource log;

		public Plugin()
		{
			log = ((BasePlugin)this).Log;
		}

		public override void Load()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			ManualLogSource obj = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("StatMod");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.2");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("anro");
			}
			obj.LogInfo(val);
			ClassInjector.RegisterTypeInIl2Cpp<StatModUI>();
			((BasePlugin)this).AddComponent<StatModUI>();
			ManualLogSource obj2 = log;
			val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("StatMod");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded! Press F4 to open stat modifier menu.");
			}
			obj2.LogInfo(val);
		}
	}
}