Decompiled source of PlayerUpgrades v1.0.1

PlayerUpgrades.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using HarmonyLib;
using Il2Cpp;
using Il2CppFishNet;
using Il2CppFishNet.Connection;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSteamworks;
using Il2CppSystem;
using Il2CppTMPro;
using Il2Cppmadeinfairyland.fairyengine;
using Il2Cppmadeinfairyland.fairyengine.actor;
using Il2Cppmadeinfairyland.fairyengine.actor.player;
using Il2Cppmadeinfairyland.fairyengine.generation;
using Il2Cppmadeinfairyland.fairyengine.ui;
using Il2Cppmadeinfairyland.forsakenfrontiers;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.Carrier;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.Mist;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.Packrat;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.butcher;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.shambler;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.theabandonedone;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.ai.ventress;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.player;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.player.datadeck;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.player.equipment;
using Il2Cppmadeinfairyland.forsakenfrontiers.hazards;
using Il2Cppmadeinfairyland.forsakenfrontiers.train;
using Il2Cppmadeinfairyland.forsakenfrontiers.ui.mainmenu;
using MelonLoader;
using Microsoft.CodeAnalysis;
using PlayerUpgrades;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "PlayerUpgrades", "1.0.0", "evan527", null)]
[assembly: MelonGame("made in fairyland", "Forsaken Frontiers")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PlayerUpgrades")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+76eb3bbac5c397bac97d7669b8d7e6bdb59285d4")]
[assembly: AssemblyProduct("PlayerUpgrades")]
[assembly: AssemblyTitle("PlayerUpgrades")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PlayerUpgrades
{
	public class Core : MelonMod
	{
		public class Upgrade
		{
			public string upgName;

			public string upgDcr;

			public Texture2D upgImg;

			public int upgLvl;

			public int upgLvlMax;

			public Color boxColor;

			public int initCost;

			public int costScaler;

			public float upgScaler;
		}

		public static int[] UpgradeLevels = new int[5];

		public static Upgrade upgradeSelected = null;

		private int x_adj = 10;

		private int y_adj = 20;

		public static bool upgradePrepped = false;

		public static List<Upgrade> upgrades;

		public static List<int> GlobalUpgradeLevels = new List<int> { 0, 0, 0, 0, 0 };

		public static bool worldGenUpgradesSet = false;

		private bool _menuEnabled = false;

		public static bool inGame = false;

		private KeyCode menuKey = (KeyCode)113;

		private KeyCode testingKey = (KeyCode)116;

		public static bool _slide = false;

		public static bool debug = false;

		public static FFTrain train;

		public static FFWorld world;

		public static bool waitingForSceneObjects = false;

		public static bool arrivingToPOI = false;

		public static bool amIHost = false;

		public static bool doNotProcessCreditsOrUpgrades = false;

		public static int settleTimer = 0;

		public static bool playerInitSettled = false;

		public static int triggerTimer = 0;

		public static bool triggerCreditUpdateSoon = false;

		public static bool containersSet = false;

		public static int brokenMinChance = 0;

		public static bool brokenMinConsecutive = false;

		public static bool consecutiveTick = false;

		public static int minute = 0;

		public static int hour = 6;

		public static float brokenMinuteTimer = 0f;

		public static bool runForerunnerBrokenMinuteTimer = false;

		public static bool triedBrokenMinute = false;

		public static int gameSeed = Random.Range(1, 500);

		public static int syncTimer = 0;

		public static bool syncReady = false;

		public static int threeHundredTimer = 0;

		public static bool sendin300ticks = false;

		public static FairyCoreManager coreManager;

		public static FFSaveFileButton[] saveButtons;

		public static string currentHover;

		public static bool currentSaveFound;

		public static bool saveLoaded = false;

		public static int settleSettleTimer = 0;

		public static bool playerInitSettledSettled = false;

		public static bool secondTrigger = false;

		public static FFSaveFileButton currentSave = null;

		public static FFPlayer[] players;

		public static int truePlayerCount = 0;

		public static float playerCheckTimer;

		public static Texture2D _menuTexture;

		public static Texture2D _indicatorTexture;

		public static Sprite _menuSprite;

		public static Sprite _indicatorSprite;

		public static int menuX;

		public static int menuY;

		public static bool inDataDeck = false;

		public static Random seededRandom;

		public static int seed;

		public static AssetBundle CustomBundle;

		public static Font CustomFont;

		public static int indicatorTimer = 0;

		public static int indicatorBegin = 200;

		public static int indicatorX = 48;

		public static int indicatorY = 118;

		public static bool showIndicator = false;

		public static float indicatorTransparency = 0.3f;

		public static FFPlayer myPlayer = null;

		public static FFDataDeck myDataDeck = null;

		public static bool gameEndReset = false;

		public static bool vulnerable = false;

		public static float globalStatUpSpeed;

		public static ulong localSteamID
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					return SteamUser.GetSteamID().m_SteamID;
				}
				catch
				{
					return 0uL;
				}
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main Menu")
			{
				UpgradeInit.GetMainMenuItems();
				UpgradeInit.InitializeCodex();
				UpgradeInit.GetMainMenuEnemies();
				UpgradeMenu.MenuAdjustmentsInit();
				coreManager = Object.FindObjectOfType<FairyCoreManager>();
				saveButtons = Il2CppArrayBase<FFSaveFileButton>.op_Implicit(Object.FindObjectsOfType<FFSaveFileButton>());
				saveButtons = saveButtons.OrderBy((FFSaveFileButton b) => ExtractSaveNumber(b.saveFile)).ToArray();
				int num = 0;
				FFSaveFileButton[] array = saveButtons;
				foreach (FFSaveFileButton val in array)
				{
					MelonLogger.Msg(val.saveFile ?? "");
				}
				CustomBundle = UpgradeMenu.EmbeddedBundleLoader.LoadEmbeddedBundle("PlayerUpgrades.customfontbundle");
				if ((Object)(object)CustomBundle != (Object)null)
				{
					CustomFont = CustomBundle.LoadAsset<Font>("mago1");
				}
			}
			if (sceneName == "Forsaken Frontiers")
			{
				amIHost = SteamIDUses.IsHost(localSteamID);
				waitingForSceneObjects = true;
				inGame = false;
				UpgradeInit.InitializeCodex();
				MelonLogger.Msg("Save File to Load: " + currentHover);
				MelonLogger.Msg($"Save File Found? {currentSaveFound}");
				inDataDeck = false;
				_slide = false;
				return;
			}
			train = null;
			world = null;
			inGame = false;
			upgradeSelected = null;
			_menuEnabled = false;
			waitingForSceneObjects = false;
			arrivingToPOI = false;
			settleTimer = 0;
			truePlayerCount = 0;
			playerInitSettled = false;
			saveLoaded = false;
			settleSettleTimer = 0;
			playerInitSettledSettled = false;
			currentSave = null;
			amIHost = false;
			doNotProcessCreditsOrUpgrades = false;
			settleTimer = 0;
			playerInitSettled = false;
			syncTimer = 0;
			syncReady = false;
			triggerTimer = 0;
			triggerCreditUpdateSoon = false;
			containersSet = false;
			minute = 0;
			hour = 0;
			brokenMinConsecutive = false;
			consecutiveTick = false;
			threeHundredTimer = 0;
			sendin300ticks = false;
			inDataDeck = false;
			_slide = false;
			UpgradeMenu.animationOffset = -300;
			indicatorTimer = 0;
			indicatorX = 48;
			indicatorBegin = 200;
			showIndicator = false;
			indicatorTransparency = 0.3f;
			myPlayer = null;
			myDataDeck = null;
			gameEndReset = false;
			vulnerable = false;
			static int ExtractSaveNumber(string saveFileName)
			{
				string[] array2 = saveFileName.Split('_');
				int result;
				return int.TryParse(array2[1], out result) ? result : 0;
			}
		}

		public override void OnUpdate()
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			saveDetector();
			loadWorldVars();
			if (!inGame || (Object)(object)train == (Object)null)
			{
				return;
			}
			upgradeConditionalVarReset();
			if (playerInitSettled && train.IsStoppedAtPOI && !triedBrokenMinute)
			{
				MelonLogger.Msg("[TRYING BROKEN MINUTE]");
				triedBrokenMinute = true;
				if (upgrades[4].upgLvl >= 2)
				{
					MelonLogger.Msg("[BROKEN MINUTE TIMER PASSED]");
					runForerunnerBrokenMinuteTimer = true;
				}
				else
				{
					MelonLogger.Msg("[BROKEN MINUTE TIMER FAILED]");
				}
			}
			if (runForerunnerBrokenMinuteTimer)
			{
				forerunnerBrokenMinuteTimer();
			}
			if (playerInitSettled)
			{
				playerAmountChange();
			}
			runTimers();
			saveLoader();
			if (playerInitSettled && (Object)(object)myPlayer == (Object)null)
			{
				myPlayer = SteamIDUses.findMyPlayer(localSteamID);
				MelonLogger.Msg("myPlayer SET");
			}
			if (playerInitSettled && (Object)(object)myPlayer != (Object)null && (Object)(object)myDataDeck == (Object)null)
			{
				myDataDeck = myPlayer.DataDeck;
				MelonLogger.Msg("myDataDeck SET");
			}
			if (Input.GetKeyDown(menuKey) && inGame && myDataDeck.DataDeckOpen && !myDataDeck.IsAccessingShop)
			{
				_slide = !_slide;
				_menuEnabled = true;
				indicatorTimer = 0;
				indicatorTransparency = 0.3f;
				showIndicator = false;
			}
			if (!myDataDeck.DataDeckOpen)
			{
				_slide = false;
			}
			if (upgradeSelected != null && !train.IsStoppedAtPOI)
			{
				int num = Random.Range(1, 201);
				string name = ((num >= 198) ? "blank" : ((num < 60) ? (upgradeSelected.upgName + (upgradeSelected.upgLvl + 1) + "-crt-vhs-camcorder-effect") : (upgradeSelected.upgName + (upgradeSelected.upgLvl + 1) + "-crt")));
				upgradeSelected.upgImg = UpgradeInit.loadTextures(name);
			}
			if (Input.GetKeyDown((KeyCode)109) && inGame)
			{
				MelonLogger.Msg($"seed = {gameSeed}");
			}
			if (Input.GetKeyDown((KeyCode)106) && inGame)
			{
				train.Credits = 20000;
			}
			if (sendin300ticks)
			{
				threeHundredTimer++;
				if (threeHundredTimer >= 1200)
				{
					threeHundredTimer = 0;
					sendin300ticks = false;
					UpgradeApplier.SyncUpgradesAcrossServer();
					MelonLogger.Msg("SENDING 300 UPG");
				}
			}
			if (train.PlayersAreBeingExecuted && !gameEndReset)
			{
				gameEndReset = true;
				((Object)train).name = "UPG:0,0,0,0,0";
				UpgradeApplier.ApplyUpgradesServer();
			}
			if (!train.PlayersAreBeingExecuted && gameEndReset)
			{
				gameEndReset = false;
			}
			if (vulnerable)
			{
				if (myPlayer.IsBleeding)
				{
					((FairyCharacterController)myPlayer).maxStableMoveSpeed = ((FairyCharacterController)myPlayer).StartingMaxStableMoveSpeed * 2f;
				}
				else
				{
					((FairyPlayer)myPlayer).staminaDrainRate = ((FairyPlayer)myPlayer).startingStaminaDrainRate / globalStatUpSpeed;
				}
			}
		}

		public static void updateSeed()
		{
			seededRandom = new Random(gameSeed);
		}

		public override void OnGUI()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			if (!inGame || (Object)(object)train == (Object)null)
			{
				return;
			}
			if (train.IsStoppedAtPOI || arrivingToPOI)
			{
				_menuEnabled = false;
				upgradeSelected = null;
			}
			else
			{
				if ((Object)(object)_menuTexture != (Object)null)
				{
					GUI.DrawTexture(new Rect((float)(10 + menuX + UpgradeMenu.animationOffset), (float)(10 + menuY), 288f, 477f), (Texture)(object)_menuTexture);
				}
				UpgradeMenu.Draw(upgrades, ref upgradeSelected);
			}
			if (myDataDeck.DataDeckOpen && !myDataDeck.IsAccessingShop && !_slide)
			{
				indicatorTimer++;
				if (indicatorTimer >= indicatorBegin)
				{
					indicatorTransparency += 0.01f;
					showIndicator = true;
				}
			}
			else
			{
				indicatorTimer = 0;
				indicatorTransparency = 0f;
				showIndicator = false;
			}
			if (showIndicator && !train.IsStoppedAtPOI)
			{
				GUI.color = new Color(1f, 1f, 1f, indicatorTransparency);
				GUI.DrawTexture(new Rect((float)(10 + menuX + indicatorX), (float)(10 + menuY + indicatorY), 123f, 81f), (Texture)(object)_indicatorTexture);
				GUI.color = Color.white;
			}
		}

		public static void saveDetector()
		{
			if (inGame)
			{
				return;
			}
			FFSaveFileButton[] array = saveButtons;
			foreach (FFSaveFileButton val in array)
			{
				if (((FairyUIObject)val).IsHovering && val.SaveFile != currentHover)
				{
					currentHover = val.saveFile;
					currentSave = val;
					if ((Object)(object)UpgradeApplier.mainMedkit == (Object)null)
					{
						UpgradeApplier.mainMedkit = UpgradeInit.FindObjectByName<FFEquipment>("FirstAidKit");
					}
					MelonLogger.Msg("Save file: '" + currentHover + "' hovered.");
				}
				else if (((FairyUIObject)val).IsHovering && val.SaveFile == currentHover)
				{
					currentHover = val.saveFile;
					currentSave = val;
					MelonLogger.Msg("Save file: '" + currentHover + "' REhovered.");
				}
			}
			if ((Object)(object)currentSave != (Object)null)
			{
				currentSaveFound = currentSave.FoundSave;
				MelonLogger.Msg($"Save found? '{currentSaveFound}'");
			}
		}

		public static void loadWorldVars()
		{
			if (!waitingForSceneObjects)
			{
				return;
			}
			world = Object.FindObjectOfType<FFWorld>();
			train = Object.FindObjectOfType<FFTrain>();
			if ((Object)(object)world != (Object)null && (Object)(object)train != (Object)null)
			{
				upgrades = UpgradeInit.initUpgrades(upgrades);
				if (!((Object)train).name.StartsWith("UPG:"))
				{
					((Object)train).name = "UPG:0,0,0,0,0";
				}
				else
				{
					UpgradeApplier.ApplyUpgradesServer();
				}
				waitingForSceneObjects = false;
				inGame = true;
			}
		}

		public static void upgradeConditionalVarReset()
		{
			if (!train.IsStoppedAtPOI && worldGenUpgradesSet)
			{
				MelonLogger.Msg("\n[RANSACKER] worldGenUpgradesSet PROPERLY RESET.\n");
				worldGenUpgradesSet = false;
				arrivingToPOI = false;
				UpgradeInit.InitializeCodex();
			}
			if (!train.IsStoppedAtPOI && runForerunnerBrokenMinuteTimer)
			{
				MelonLogger.Msg("\n[FORERUNNER] runForerunnerBrokenMinuteTimer PROPERLY RESET.\n");
				runForerunnerBrokenMinuteTimer = false;
			}
		}

		public static void forerunnerBrokenMinuteTimer()
		{
			brokenMinuteTimer += Time.deltaTime;
			if (brokenMinuteTimer < 0.5f)
			{
				return;
			}
			brokenMinuteTimer = 0f;
			if (minute == world.Minute)
			{
				return;
			}
			if (!consecutiveTick || brokenMinConsecutive)
			{
				int num = seededRandom.Next(1, 101);
				if (num <= brokenMinChance)
				{
					MelonLogger.Msg("\n[FORERUNNER] BROKEN MINUTE\n");
					world.Minute = minute;
					world.Hour = hour;
					consecutiveTick = true;
				}
				else
				{
					minute = world.Minute;
					hour = world.Hour;
				}
			}
			else
			{
				consecutiveTick = false;
			}
		}

		public static void playerAmountChange()
		{
			playerCheckTimer += Time.deltaTime;
			if (!train.IsStoppedAtPOI && playerCheckTimer >= 1f)
			{
				playerCheckTimer = 0f;
				players = Il2CppArrayBase<FFPlayer>.op_Implicit(Object.FindObjectsOfType<FFPlayer>());
			}
			if (!inGame || !playerInitSettled || train.IsStoppedAtPOI)
			{
				return;
			}
			int num = players.Length;
			if (num == truePlayerCount)
			{
				return;
			}
			if (SteamIDUses.IsHost(localSteamID))
			{
				if (num > truePlayerCount)
				{
					MelonLogger.Msg($"[HOST] PlayerCount Increased from [{truePlayerCount} -> {num}] ");
				}
				else if (num < truePlayerCount)
				{
					MelonLogger.Msg($"[HOST] PlayerCount Decreased from [{truePlayerCount} -> {num}] ");
				}
				truePlayerCount = num;
				sendin300ticks = true;
				UpgradeInit.UpdateCostsAccToPlayerCount(truePlayerCount);
			}
			else
			{
				if (num > truePlayerCount)
				{
					MelonLogger.Msg($"PlayerCount Increased from [{truePlayerCount} -> {num}] ");
				}
				else if (num < truePlayerCount)
				{
					MelonLogger.Msg($"PlayerCount Decreased from [{truePlayerCount} -> {num}] ");
				}
				truePlayerCount = num;
				UpgradeInit.UpdateCostsAccToPlayerCount(truePlayerCount);
			}
		}

		public static void runTimers()
		{
			if (settleTimer < 12)
			{
				settleTimer++;
			}
			else
			{
				playerInitSettled = true;
			}
			if (settleSettleTimer < 100)
			{
				settleSettleTimer++;
			}
			else
			{
				playerInitSettledSettled = true;
			}
			if (triggerCreditUpdateSoon && playerInitSettled)
			{
				triggerTimer++;
				if (triggerTimer == 200)
				{
					MelonLogger.Msg("\n TRIGGER TIMER 20\n");
					UpgradeApplier.SyncUpgradesAcrossServer3();
				}
				if (triggerTimer == 400)
				{
					MelonLogger.Msg("\n TRIGGER TIMER 40\n");
					UpgradeApplier.SyncUpgradesAcrossServer2();
				}
				if (triggerTimer == 600)
				{
					MelonLogger.Msg("\n TRIGGER TIMER 60\n");
					secondTrigger = true;
					UpgradeApplier.SyncUpgradesAcrossServer3();
				}
				if (triggerTimer >= 620)
				{
					MelonLogger.Msg("\n TRIGGER TIMER 62\n");
					secondTrigger = false;
					triggerTimer = 0;
					triggerCreditUpdateSoon = false;
				}
			}
		}

		public static void saveLoader()
		{
			if (playerInitSettledSettled && currentSaveFound && !saveLoaded)
			{
				saveLoaded = true;
				MelonLogger.Msg("Entered SaveLoader WITH SAVE...");
				if (SteamIDUses.IsHost(localSteamID))
				{
					string text = Path.Combine(Application.dataPath, "../UserLibs/Saves");
					string text2 = Path.Combine(text, currentHover + ".txt");
					Directory.CreateDirectory(text);
					if (!File.Exists(text2))
					{
						File.WriteAllText(text2, "00000");
						MelonLogger.Msg("[!] SAVE CREATED: " + text2);
					}
					string input = File.ReadAllText(text2);
					int[] array = (from Match m in Regex.Matches(input, "\\d")
						select int.Parse(m.Value)).Take(5).ToArray();
					if (array.Length < 5)
					{
						MelonLogger.Warning("[!] Save file has fewer than five upgrade levels. Resetting to 00000.");
						array = new int[5];
						File.WriteAllText(text2, "00000");
					}
					for (int num = 0; num < 5; num++)
					{
						upgrades[num].upgLvl = array[num];
					}
					((Object)((Component)train).gameObject).name = "UPG:" + string.Join(",", upgrades.Select((Upgrade u) => u.upgLvl));
					MelonLogger.Msg($"[!] UPGRADES FOUND: {array[0]},{array[1]},{array[2]},{array[3]},{array[4]}");
					MelonLogger.Msg("[!] TRAIN NAME: " + ((Object)((Component)train).gameObject).name);
					triggerTimer = 0;
					UpgradeApplier.SyncUpgradesAcrossServer();
				}
				else
				{
					MelonLogger.Msg("NOT HOST");
				}
			}
			else
			{
				if (!playerInitSettledSettled || currentSaveFound || saveLoaded || triggerTimer != 0)
				{
					return;
				}
				saveLoaded = true;
				MelonLogger.Msg("Entered SaveLoader WITHOUT SAVE...");
				if (SteamIDUses.IsHost(localSteamID))
				{
					string text3 = Path.Combine(Application.dataPath, "../UserLibs/Saves");
					string text4 = Path.Combine(text3, currentHover + ".txt");
					Directory.CreateDirectory(text3);
					if (!File.Exists(text4))
					{
						File.WriteAllText(text4, "00000");
						MelonLogger.Msg("[!] NEW SAVE CREATED: " + text4);
					}
					else
					{
						MelonLogger.Msg("[!] SAVE ALREADY EXISTS: " + text4);
					}
				}
				else
				{
					MelonLogger.Msg("NOT HOST");
				}
			}
		}

		public static void UpdateCostsAccToPlayerCount(int playerCount)
		{
			float num = 0.25f;
			float num2 = 1f + (float)(playerCount - 1) * num;
			foreach (Upgrade upgrade in upgrades)
			{
				upgrade.initCost *= (int)num2;
				upgrade.costScaler *= (int)num2;
			}
		}
	}
	internal class Harmony
	{
		[HarmonyPatch(typeof(FFPlayer), "obr_AllPlayersDown")]
		public static class AllDeadPrefix
		{
			[HarmonyPostfix]
			public static void AllDeadPrefixHarmony(FFPlayer __instance)
			{
				MelonLogger.Msg("[ALL PLAYERS DEAD]");
				Core.arrivingToPOI = !Core.arrivingToPOI;
			}
		}

		[HarmonyPatch(typeof(FFTrainBrake), "OnUsed")]
		public static class BrakePrefix
		{
			[HarmonyPrefix]
			public static void BrakePrefixServer(FFTrainBrake __instance)
			{
				Core.amIHost = SteamIDUses.IsHost(Core.localSteamID);
				Core.arrivingToPOI = !Core.arrivingToPOI;
				if (localDebug)
				{
					MelonLogger.Msg("\n\nEntered 'FFTrainBrake.OnUsed' Prefix.");
					if (Core.arrivingToPOI)
					{
						MelonLogger.Msg("Traveling to POI; Disabling Door Decoder\n\n");
					}
					else
					{
						MelonLogger.Msg("Returning from POI; Enabling Door Decoder\n\n");
					}
				}
			}
		}

		[HarmonyPatch(typeof(FFTrader), "BuyItem")]
		public static class BuyItemPrefix
		{
			[HarmonyPostfix]
			public static void BuyItemForDupe(FFTrader __instance, ShopItem shopItem, FFPlayer playerWhoPurchased)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: 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_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_028a: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: 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)
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				MelonLogger.Msg("[ITEM BOUGHT: " + shopItem.OriginalItemName + "]");
				if (SteamIDUses.IsHost(Core.localSteamID) && Core.upgrades[2].upgLvl >= 5)
				{
					int num = Random.Range(1, 101);
					if (num >= 50)
					{
						Vector3 val = Vector3.zero;
						if ((Object)(object)__instance != (Object)null)
						{
							val = ((Component)__instance).transform.position + ((Component)__instance).transform.forward * spawnDistance + Vector3.up * upwardOffset;
						}
						else if ((Object)(object)playerWhoPurchased != (Object)null)
						{
							val = ((Component)playerWhoPurchased).transform.position;
						}
						FFEquipment val2 = (FFEquipment)((shopItem.OriginalItemName == "glowstick") ? UpgradeApplier.mainGlowstick : ((shopItem.OriginalItemName == "lantern") ? UpgradeApplier.mainLantern : ((shopItem.OriginalItemName == "flashlight") ? UpgradeApplier.mainFlashlight : ((shopItem.OriginalItemName == "medkit") ? UpgradeApplier.mainMedkit : ((shopItem.OriginalItemName == "adrenaline") ? UpgradeApplier.mainAdrenaline : ((shopItem.OriginalItemName == "walkie-talkie") ? UpgradeApplier.mainWalkie : ((shopItem.OriginalItemName == "boltcutters") ? UpgradeApplier.mainBoltcutter : ((shopItem.OriginalItemName == "sledgehammer") ? UpgradeApplier.mainSledgehammer : ((shopItem.OriginalItemName == "firecrackers") ? UpgradeApplier.mainFirecrackers : ((shopItem.OriginalItemName == "environment marker") ? UpgradeApplier.mainMarker : ((shopItem.OriginalItemName == "gasmask") ? UpgradeApplier.mainGasMask : ((shopItem.OriginalItemName == "soda") ? UpgradeApplier.mainSoda : ((!(shopItem.OriginalItemName == "dynamite")) ? ((object)UpgradeApplier.mainGlowstick) : ((object)UpgradeApplier.mainDynamite))))))))))))));
						GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val, Quaternion.identity);
						NetworkObject component = val3.GetComponent<NetworkObject>();
						InstanceFinder.ServerManager.Spawn(component, (NetworkConnection)null, default(Scene));
						MelonLogger.Msg("[ITEM BOUGHT] ITEM DUPED!");
					}
					else
					{
						MelonLogger.Msg("[ITEM BOUGHT] Chance failed.");
					}
				}
				else
				{
					MelonLogger.Msg("[ITEM BOUGHT] Not host or not lvl 5");
				}
			}
		}

		[HarmonyPatch(typeof(FFTrain), "OpenDoors")]
		public static class DoorsPostfix
		{
			[HarmonyPostfix]
			public static void DoorsPostfixServer(FFTrain __instance)
			{
				if (localDebug)
				{
					MelonLogger.Msg("Entered 'FFTrain.OpenDoors' Postfix.");
				}
				if (Core.arrivingToPOI || Core.train.IsStoppedAtPOI)
				{
					return;
				}
				if (localDebug)
				{
					MelonLogger.Msg("[NOT AT POI] Doors Opened. Attempting UpgradeRequest Read/Decode/Apply\n");
					MelonLogger.Msg($"[SERVER:BEFORE] __instance.Credits: {__instance.Credits}");
					MelonLogger.Msg($"[SERVER:BEFORE] train.Credits: {Core.train.Credits}\n");
				}
				int num = -1;
				num = __instance.Credits % 10;
				MelonLogger.Msg($"[Index found = [{num}] in [{Core.train.Credits}] credits.]");
				switch (num)
				{
				case 9:
					MelonLogger.Msg($"[Index 9] Credits to decode: {__instance.Credits}");
					__instance.Credits -= 9;
					__instance.Credits /= 10;
					foreach (Core.Upgrade upgrade2 in Core.upgrades)
					{
						int num2 = (upgrade2.upgLvl = __instance.Credits % 10);
						__instance.Credits -= num2;
						__instance.Credits /= 10;
						MelonLogger.Msg($"[Index 9] Extracked Upgrade: {num2}");
					}
					((Object)((Component)Core.train).gameObject).name = "UPG:" + string.Join(",", Core.upgrades.Select((Core.Upgrade u) => u.upgLvl));
					UpgradeApplier.ApplyUpgradesServer();
					MelonLogger.Msg("[Index 9] Extracked and Applied All Upgrades\n");
					return;
				case 7:
					__instance.Credits -= 7;
					__instance.Credits /= 10;
					Core.gameSeed = __instance.Credits;
					Core.updateSeed();
					MelonLogger.Msg("[Index 7] Seed Synced to Server\n");
					return;
				case 8:
					__instance.Credits -= 8;
					__instance.Credits /= 10;
					if (__instance.Credits == 1)
					{
						__instance.Credits -= 1;
					}
					MelonLogger.Msg("[Index 8] Credits Synced to Server\n");
					return;
				}
				num = __instance.Credits % 1000;
				__instance.Credits -= num;
				__instance.Credits /= 1000;
				if (__instance.Credits == 1)
				{
					__instance.Credits -= 1;
				}
				Core.train.Credits = __instance.Credits;
				if (localDebug)
				{
					MelonLogger.Msg($"[SERVER:AFTER] Processing upgrade index: {num}");
					MelonLogger.Msg($"[SERVER:AFTER] __instance.Credits: {__instance.Credits}");
					MelonLogger.Msg($"[SERVER:AFTER] train.Credits: {Core.train.Credits}\n");
				}
				switch (num)
				{
				case -1:
					return;
				case 9:
					((Object)((Component)Core.train).gameObject).name = "UPG:" + string.Join(",", Core.upgrades.Select((Core.Upgrade u) => u.upgLvl));
					UpgradeApplier.ApplyUpgradesServer();
					return;
				}
				Core.Upgrade upgrade = Core.upgrades[num];
				int num3 = upgrade.initCost + upgrade.costScaler * upgrade.upgLvl;
				upgrade.upgLvl++;
				__instance.Credits -= num3;
				((Object)((Component)Core.train).gameObject).name = "UPG:" + string.Join(",", Core.upgrades.Select((Core.Upgrade u) => u.upgLvl));
				if (localDebug)
				{
					MelonLogger.Msg($"[SERVER:AFTER_UPGRADED] cost: {num3}");
					MelonLogger.Msg($"[SERVER:AFTER_UPGRADED] __instance.Credits: {__instance.Credits}");
					MelonLogger.Msg($"[SERVER:AFTER_UPGRADED] train.Credits: {Core.train.Credits}\n");
				}
				UpgradeApplier.ApplyUpgradesServer();
			}

			[HarmonyPostfix]
			private static void ApplyLurkerToAllWorldLandmines()
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				if (!Core.arrivingToPOI || !Core.train.IsStoppedAtPOI)
				{
					return;
				}
				if (localDebug)
				{
					MelonLogger.Msg("[AT POI] Doors Opened. Attempting Lurker buff.");
				}
				if (!SteamIDUses.IsHost(Core.localSteamID) || Core.upgrades[1].upgLvl != 5)
				{
					return;
				}
				FFLandmine[] array = Il2CppArrayBase<FFLandmine>.op_Implicit(Object.FindObjectsOfType<FFLandmine>());
				if (array == null || array.Length == 0)
				{
					MelonLogger.Warning("[LURKER] No spawned FFLandmines were found in the scene.");
				}
				else
				{
					int num = 0;
					FFLandmine[] array2 = array;
					foreach (FFLandmine val in array2)
					{
						val.Disarmed = true;
						Transform val2 = ((Component)val).transform.Find("Light (4)");
						if ((Object)(object)val2 != (Object)null)
						{
							UL_FastLight component = ((Component)val2).GetComponent<UL_FastLight>();
							if ((Object)(object)component != (Object)null)
							{
								component.color = Color.green;
							}
						}
						num++;
					}
					if (localDebug)
					{
						MelonLogger.Msg($"[LURKER] Successfully disarmed {num} landmines.");
					}
				}
				FFTripwireTrigger[] array3 = Il2CppArrayBase<FFTripwireTrigger>.op_Implicit(Object.FindObjectsOfType<FFTripwireTrigger>());
				if (array3 == null || array3.Length == 0)
				{
					MelonLogger.Warning("[LURKER] No spawned FFTripwires were found in the scene.");
					return;
				}
				int num2 = 0;
				FFTripwireTrigger[] array4 = array3;
				foreach (FFTripwireTrigger val3 in array4)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						Object.Destroy((Object)(object)val3);
						num2++;
					}
				}
				if (localDebug)
				{
					MelonLogger.Msg($"[LURKER] Successfully disarmed {num2} tripwires.");
				}
			}

			[HarmonyPostfix]
			private static void ApplyForerunnerToWorldTIme()
			{
				if (!Core.arrivingToPOI || !Core.train.IsStoppedAtPOI)
				{
					return;
				}
				if (localDebug)
				{
					MelonLogger.Msg("[AT POI] Doors Opened. Attempting Forerunner buff.");
				}
				if (SteamIDUses.IsHost(Core.localSteamID) && !Core.worldGenUpgradesSet)
				{
					if (Core.upgrades[4].upgLvl == 5)
					{
						FFWorld world = Core.world;
						world.Hour -= 3;
					}
					else if (Core.upgrades[4].upgLvl >= 3)
					{
						FFWorld world2 = Core.world;
						world2.Hour -= 2;
					}
					else if (Core.upgrades[4].upgLvl >= 1)
					{
						FFWorld world3 = Core.world;
						world3.Hour -= 1;
					}
					if (localDebug)
					{
						MelonLogger.Msg("Forerunner Upg Set.");
					}
				}
				else if (localDebug)
				{
					MelonLogger.Msg("Not Host/Already applied worldGen Buffs.");
				}
			}

			[HarmonyPostfix]
			private static void ApplyRansackerToAllWorldLoot()
			{
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e2: 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_02c9: Unknown result type (might be due to invalid IL or missing references)
				if (!Core.arrivingToPOI || !Core.train.IsStoppedAtPOI)
				{
					return;
				}
				if (localDebug)
				{
					MelonLogger.Msg("\n[AT POI] Doors Opened. Attempting Ransacker buff.\n");
				}
				if (!SteamIDUses.IsHost(Core.localSteamID) || Core.worldGenUpgradesSet)
				{
					if (localDebug)
					{
						MelonLogger.Msg("\n[RANSACKER] Not host or worldGenUpgradesSet var not reset.\n");
					}
					if (localDebug)
					{
						MelonLogger.Msg($"\n[RANSACKER] worldGenUpgradesSet = {Core.worldGenUpgradesSet}.\n");
					}
					return;
				}
				Core.worldGenUpgradesSet = true;
				int upgLvl = Core.upgrades[3].upgLvl;
				if (upgLvl <= 0)
				{
					if (localDebug)
					{
						MelonLogger.Msg("[RANSACKER] Upgrade level is 0. Skipping loot buff.");
					}
					return;
				}
				FFLootItem[] array = Il2CppArrayBase<FFLootItem>.op_Implicit(Object.FindObjectsOfType<FFLootItem>());
				if (array == null || array.Length == 0)
				{
					MelonLogger.Warning("[RANSACKER] No spawned FFLootItems were found in the scene.");
				}
				FFGenerator[] array2 = Il2CppArrayBase<FFGenerator>.op_Implicit(Object.FindObjectsOfType<FFGenerator>());
				if (array2 == null || array2.Length == 0)
				{
					MelonLogger.Warning("[RANSACKER] No spawned FFLootContainers were found in the scene.");
				}
				int num = 0;
				int num2 = 0;
				float num3 = 1f;
				int num4 = 0;
				int num5 = 0;
				int num6 = 0;
				if (upgLvl >= 3)
				{
					num3 = 1.25f;
				}
				else if (upgLvl >= 1)
				{
					num3 = 1.1f;
				}
				if (upgLvl >= 2)
				{
					num6 = 2;
				}
				if (upgLvl >= 4)
				{
					num6 = 4;
				}
				FFLootItem[] array3 = array;
				Scene scene;
				foreach (FFLootItem val in array3)
				{
					if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null)
					{
						continue;
					}
					scene = ((Component)val).gameObject.scene;
					if (!((Scene)(ref scene)).isLoaded || ((FairyItem)val).value <= 0)
					{
						continue;
					}
					if (Random.Range(0, 100) == 0 && upgLvl == 5)
					{
						((FairyItem)val).value = Mathf.CeilToInt((float)(((FairyItem)val).value * 5));
						num2++;
						if (localDebug)
						{
							MelonLogger.Msg("[RANSACKER] Lucky Multiplier!");
						}
					}
					else
					{
						((FairyItem)val).value = Mathf.CeilToInt((float)((FairyItem)val).value * num3);
					}
					num++;
				}
				FFGenerator[] array4 = array2;
				foreach (FFGenerator val2 in array4)
				{
					if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null))
					{
						scene = ((Component)val2).gameObject.scene;
						if (((Scene)(ref scene)).isLoaded)
						{
							int num7 = ((upgLvl < 5) ? Random.Range(0, num6 + 1) : Random.Range(1, num6 + 1));
							((FairyGenerator)val2).amount = ((FairyGenerator)val2).amount + num7;
							num4++;
						}
					}
				}
				float num8 = 100 * (num2 / num);
				if (localDebug)
				{
					MelonLogger.Msg($"[RANSACKER] Successfully buffed {num}/{array.Length} loot items by {num3}x multiplier.");
				}
				if (localDebug)
				{
					MelonLogger.Msg($"[RANSACKER] Successfully buffed {num2}/{array.Length} loot items by 5x lucky multiplier.");
				}
				if (localDebug)
				{
					MelonLogger.Msg($"[RANSACKER] Successfully buffed {num4} loot container spots to have between 0-{num6} Max possible items.");
				}
				if (localDebug)
				{
					MelonLogger.Msg("All World UpgradesSet.\n");
				}
			}
		}

		public static bool localDebug = true;

		public static int playerCount = 0;

		public static float spawnDistance = 1f;

		public static float upwardOffset = 1f;
	}
	internal class SaveManager
	{
		[Serializable]
		public class ModSaveData
		{
			public List<int> Levels = new List<int> { 0, 0, 0, 0, 0 };
		}
	}
	internal class SteamIDUses
	{
		public static FFPlayer findMyPlayer(ulong localSteamID)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			FFPlayer[] array = Il2CppArrayBase<FFPlayer>.op_Implicit(Object.FindObjectsOfType<FFPlayer>());
			FFPlayer[] array2 = array;
			foreach (FFPlayer val in array2)
			{
				if (((FairyPlayer)val).SteamID.m_SteamID == localSteamID)
				{
					return val;
				}
			}
			MelonLogger.Warning("ERROR: No matching Steam ID found across all players.");
			return null;
		}

		public static bool IsHost(ulong localSteamID)
		{
			//IL_001c: 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)
			FFPlayer[] array = Il2CppArrayBase<FFPlayer>.op_Implicit(Object.FindObjectsOfType<FFPlayer>());
			FFPlayer[] array2 = array;
			foreach (FFPlayer val in array2)
			{
				if (((FairyPlayer)val).SteamID.m_SteamID == localSteamID && ((NetworkBehaviour)val).IsHost)
				{
					return true;
				}
				MelonLogger.Msg($"[HOST CHECK] || p.SteamID.m_SteamID: {((FairyPlayer)val).SteamID.m_SteamID} || localSteamID: {localSteamID} || p.IsHost: {((NetworkBehaviour)val).IsHost}\n");
			}
			MelonLogger.Msg("[HOST CHECK] returning false\n");
			return false;
		}

		public static bool IsHostList(ulong localSteamID)
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			FFPlayer[] array = Il2CppArrayBase<FFPlayer>.op_Implicit(Object.FindObjectsOfType<FFPlayer>());
			bool flag = false;
			int num = 0;
			MelonLogger.Msg("HOST TEST\n");
			MelonLogger.Msg($"Players ingame: {array.Length}\n\n");
			MelonLogger.Msg($"Player's Local Steam ID: {localSteamID}\n");
			FFPlayer[] array2 = array;
			foreach (FFPlayer val in array2)
			{
				num++;
				MelonLogger.Msg($"Test {num}/{array.Length}");
				MelonLogger.Msg($"Comparing to Steam ID: {localSteamID}...");
				if (((FairyPlayer)val).SteamID.m_SteamID == localSteamID)
				{
					MelonLogger.Msg(" TRUE. ");
					MelonLogger.Msg("Checking if host: ...");
					if (((NetworkBehaviour)val).IsHost)
					{
						MelonLogger.Msg(" TRUE. Host found.\n");
						flag = true;
						continue;
					}
				}
				MelonLogger.Msg(" FALSE.\n");
			}
			if (flag)
			{
				return true;
			}
			return false;
		}
	}
	public class UpgradeApplier
	{
		public static int indexOfUpgrade = -1;

		public static int costOfUpgrade = -1;

		public static int testVar = 100;

		public static FFSprayTool mainMarker;

		public static FFBoltcutters mainBoltcutter;

		public static FFSledgehammer mainSledgehammer;

		public static FFStunLight mainStunlight;

		public static FFGlowstick mainGlowstick;

		public static FFLantern mainLantern;

		public static FFFlashlight mainFlashlight;

		public static FFEquipment mainMedkit = null;

		public static FFAdrenalineShot mainAdrenaline;

		public static FFWalkieTalkie mainWalkie;

		public static FFFirecrackers mainFirecrackers;

		public static FFGasmask mainGasMask;

		public static FFNoiseMaker mainSoda;

		public static FFDynamite mainDynamite;

		public static int[] originalItemDurabilityValues = new int[4] { 32, 8, 15, 5 };

		public static double[] originalItemLightValues = new double[3] { 6.0, 15.0, 28.0 };

		public static FFAICore[] enemyAIRadius;

		public static FFAICore[] enemyAIDelay;

		public static FFSpiderAI mainSpider;

		public static FFVentressAI mainVentress;

		public static FFButcherAI mainNButcher;

		public static FFForsakenAI mainForsaken;

		public static FFShambler mainShambler;

		public static FFTheAbandonedOneAI mainAbandoned;

		public static FFForsakenAI mainPatient;

		public static FFCarrierAI mainCarrier;

		public static FFButcherAI mainButcher;

		public static FFShambler mainNShambler;

		public static FFSpiderAI mainNSpider;

		public static FFMistAI mainShepherd;

		public static FFPackratAI mainPackrat;

		public static float[] initDetectRadius;

		public static int[] initDetectChance;

		public static float[] initDetectDelay;

		public static int originalCredits = -1;

		public static bool localDebug = true;

		public static int ransackerApplied = 0;

		public static FFEquipment[] equipment;

		public static void ServerApplyUpgrade(int index)
		{
			if (localDebug)
			{
				MelonLogger.Msg("Triggering train.OpenDoors & requesting credits * 1000.");
			}
			if (Core.train.Credits == 0)
			{
				FFTrain train = Core.train;
				int credits = train.Credits;
				train.Credits = credits + 1;
			}
			int num = Core.train.Credits * 999 + index;
			if (localDebug)
			{
				MelonLogger.Msg("ENCODE:");
				MelonLogger.Msg($"Credits: {Core.train.Credits}");
				MelonLogger.Msg($"Index: {index}");
				MelonLogger.Msg($"Encoded: {num}");
			}
			Core.train.RpcWriter___Server_svr_RequestAddCredits_3316948804(num);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(true);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(false);
		}

		public static void ApplyUpgradesServer()
		{
			if (SteamIDUses.IsHost(Core.localSteamID) && Core.playerInitSettledSettled)
			{
				string path = Path.Combine(Application.dataPath, "../UserLibs/Saves", Core.currentHover + ".txt");
				string contents = string.Join("", from u in Core.upgrades.Take(5)
					select u.upgLvl);
				File.WriteAllText(path, contents);
				MelonLogger.Msg("OVERWROTE " + Core.currentHover + ".\n");
			}
			string text = ((Object)((Component)Core.train).gameObject).name.Substring(4);
			string[] array = text.Split(',');
			for (int num = 0; num < Core.upgrades.Count && num < array.Length; num++)
			{
				if (int.TryParse(array[num], out var result))
				{
					Core.upgrades[num].upgLvl = result;
					string name = Core.upgrades[num].upgName + (result + 1) + "-crt";
					Core.upgrades[num].upgImg = UpgradeInit.loadTextures(name);
				}
			}
			if (localDebug)
			{
				MelonLogger.Msg("Parsed Train Name.\n");
			}
			findWorldObjects();
			if (localDebug)
			{
				MelonLogger.Msg("Found World Objects.\n");
			}
			applyUpgradeEvader(Core.upgrades[0].upgLvl, Core.upgrades[0].upgScaler, Core.myPlayer);
			applyUpgradeLurker(Core.upgrades[1].upgLvl, Core.upgrades[1].upgScaler, Core.myPlayer);
			applyUpgradeHacker(Core.upgrades[2].upgLvl, Core.upgrades[2].upgScaler, Core.myPlayer);
			if (Core.upgrades[4].upgLvl >= 1)
			{
				Core.hour = 5;
			}
			if (Core.upgrades[4].upgLvl >= 2)
			{
				Core.brokenMinChance = 5;
			}
			if (Core.upgrades[4].upgLvl >= 3)
			{
				Core.hour = 4;
			}
			if (Core.upgrades[4].upgLvl >= 4)
			{
				Core.brokenMinChance = 12;
			}
			if (Core.upgrades[4].upgLvl >= 5)
			{
				Core.hour = 3;
				Core.brokenMinConsecutive = true;
			}
			if (localDebug)
			{
				MelonLogger.Msg("All upgrades applied.");
			}
		}

		private static void findWorldObjects()
		{
			equipment = Il2CppArrayBase<FFEquipment>.op_Implicit(Object.FindObjectsOfType<FFEquipment>());
		}

		private static void applyUpgradeEvader(int lvl, float scaler, FFPlayer player)
		{
			if (lvl != 0)
			{
				float num = 1f;
				float num2 = 1f;
				if (lvl >= 1)
				{
					num = 1.1f;
				}
				if (lvl >= 2)
				{
					num2 = 1.1f;
				}
				if (lvl >= 3)
				{
					num = 1.25f;
				}
				if (lvl >= 4)
				{
					num2 = 1.25f;
				}
				if (lvl >= 5)
				{
					num = 1.3f;
					num2 = 1.3f;
					Core.vulnerable = true;
				}
				if (lvl < 5)
				{
					Core.vulnerable = false;
				}
				Core.globalStatUpSpeed = num;
				((FairyCharacterController)player).maxStableMoveSpeed = ((FairyCharacterController)player).StartingMaxStableMoveSpeed * num;
				((FairyPlayer)player).staminaDrainRate = ((FairyPlayer)player).startingStaminaDrainRate / num2;
			}
		}

		private static void applyUpgradeLurker(int lvl, float scaler, FFPlayer player)
		{
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			float crouchMoveSpeedSubtractive = 1f;
			float num = 1f;
			MelonLogger.Msg("\n");
			MelonLogger.Msg("\n");
			MelonLogger.Msg("\n");
			if (lvl >= 1)
			{
				crouchMoveSpeedSubtractive = 0.72f;
			}
			if (lvl >= 2)
			{
				num = 0.85f;
			}
			if (lvl >= 3)
			{
				crouchMoveSpeedSubtractive = 0f;
			}
			if (lvl >= 4)
			{
				num = 0.65f;
			}
			if (lvl >= 5)
			{
				crouchMoveSpeedSubtractive = -0.59f;
				num = 0.6f;
			}
			((FairyCharacterController)player).crouchMoveSpeedSubtractive = crouchMoveSpeedSubtractive;
			FFAICore[] array = (FFAICore[])(object)new FFAICore[12]
			{
				(FFAICore)mainSpider,
				(FFAICore)mainVentress,
				(FFAICore)mainNButcher,
				(FFAICore)mainForsaken,
				(FFAICore)mainShambler,
				(FFAICore)mainAbandoned,
				(FFAICore)mainPatient,
				(FFAICore)mainCarrier,
				(FFAICore)mainButcher,
				(FFAICore)mainNShambler,
				(FFAICore)mainShepherd,
				(FFAICore)mainPackrat
			};
			for (int i = 0; i < array.Length; i++)
			{
				array[i].checkFarPlayerRadius = (int)Math.Ceiling(initDetectRadius[i] * num);
				array[i].checkFarPlayerChance = Percent.op_Implicit((float)(int)Math.Ceiling((float)initDetectChance[i] * num));
				array[i].checkFarPlayersDelay = (int)Math.Ceiling(initDetectDelay[i] * num);
			}
			MelonLogger.Msg("\n");
			MelonLogger.Msg("\n");
		}

		private static void applyUpgradeHacker(float lvl, float scaler, FFPlayer player)
		{
			if (lvl != 0f)
			{
				if (localDebug)
				{
					MelonLogger.Msg($"[BEFORE] mainMarker.paint = {mainMarker.paint}");
					MelonLogger.Msg($"[BEFORE] mainBoltcutter.maxDurability = {((FFEquipment)mainBoltcutter).maxDurability}");
					MelonLogger.Msg($"[BEFORE] mainSledgehammer.maxDurability = {((FFEquipment)mainSledgehammer).maxDurability}");
					MelonLogger.Msg($"[BEFORE] mainStunlight.maxDurability = {((FFEquipment)mainStunlight).maxDurability}");
					MelonLogger.Msg($"[BEFORE] mainGlowstick.light.range = {mainGlowstick.light.range}");
					MelonLogger.Msg($"[BEFORE] mainLantern.light.range = {mainLantern.light.range}");
					MelonLogger.Msg($"[BEFORE] mainFlashlight.light.range = {mainFlashlight.light.range}\n");
					MelonLogger.Msg("Applying Hacker Buff\n");
				}
				float num = 1f;
				float num2 = 1f;
				if (lvl >= 1f)
				{
					num = 1.3f;
				}
				if (lvl >= 2f)
				{
					num2 = 5f;
				}
				if (lvl >= 3f)
				{
					num = 1.45f;
				}
				if (lvl >= 4f)
				{
					num2 = 10f;
				}
				if (lvl >= 5f)
				{
					num = 2.5f;
					num2 = 12f;
				}
				int num3 = (int)Math.Ceiling((float)originalItemDurabilityValues[0] * num) - originalItemDurabilityValues[0];
				int num4 = (int)Math.Ceiling((float)originalItemDurabilityValues[1] * num) - originalItemDurabilityValues[1];
				int num5 = (int)Math.Ceiling((float)originalItemDurabilityValues[2] * num) - originalItemDurabilityValues[2];
				int num6 = (int)Math.Ceiling((float)originalItemDurabilityValues[3] * num) - originalItemDurabilityValues[3];
				mainMarker.paint = originalItemDurabilityValues[0] + num3;
				((FFEquipment)mainBoltcutter).maxDurability = originalItemDurabilityValues[1] + num4;
				((FFEquipment)mainSledgehammer).maxDurability = originalItemDurabilityValues[2] + num5;
				((FFEquipment)mainStunlight).maxDurability = originalItemDurabilityValues[3] + num6;
				if (localDebug)
				{
					MelonLogger.Msg($"[AFTER] mainMarker.paint = {mainMarker.paint}; +{num3} charges");
					MelonLogger.Msg($"[AFTER] mainBoltcutter.maxDurability = {((FFEquipment)mainBoltcutter).maxDurability}; +{num4} charges");
					MelonLogger.Msg($"[AFTER] mainSledgehammer.maxDurability = {((FFEquipment)mainSledgehammer).maxDurability}; +{num5} charges");
					MelonLogger.Msg($"[AFTER] mainStunlight.maxDurability = {((FFEquipment)mainStunlight).maxDurability}; +{num6} charges");
				}
				double num7 = Math.Ceiling(originalItemLightValues[0] * (double)num2) - originalItemLightValues[0];
				double num8 = Math.Ceiling(originalItemLightValues[1] * (double)num2) - originalItemLightValues[1];
				double num9 = Math.Ceiling(originalItemLightValues[2] * (double)num2) - originalItemLightValues[2];
				mainGlowstick.light.range = (float)(originalItemLightValues[0] + num7);
				mainLantern.light.range = (float)(originalItemLightValues[1] + num8);
				mainFlashlight.light.range = (float)(originalItemLightValues[2] + num9);
				if (localDebug)
				{
					MelonLogger.Msg($"[AFTER] mainGlowstick.light.range = {mainGlowstick.light.range}; +{num7}%");
					MelonLogger.Msg($"[AFTER] mainLantern.light.range = {mainLantern.light.range}; +{num8}%");
					MelonLogger.Msg($"[AFTER] mainFlashlight.light.range = {mainFlashlight.light.range}; +{num9}%\n");
				}
			}
		}

		public static void SyncUpgradesAcrossServer()
		{
			originalCredits = Core.train.Credits;
			int num = 9;
			string text = ((Object)((Component)Core.train).gameObject).name.Substring(4);
			string[] array = text.Split(',');
			int num2 = 10;
			for (int num3 = Core.upgrades.Count - 1; num3 >= 0; num3--)
			{
				if (num3 < array.Length && int.TryParse(array[num3], out var result))
				{
					num2 += result;
					num2 *= 10;
				}
			}
			int num4 = num2 + num;
			num4 -= Core.train.Credits;
			if (localDebug)
			{
				MelonLogger.Msg("[ENCODE]");
				MelonLogger.Msg($"Credits: {Core.train.Credits}");
				MelonLogger.Msg($"Index: {num}");
				MelonLogger.Msg($"Encoded: {num4}");
			}
			Core.train.RpcWriter___Server_svr_RequestAddCredits_3316948804(num4);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(true);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(false);
			Core.triggerCreditUpdateSoon = true;
		}

		public static void SyncUpgradesAcrossServer2()
		{
			int num = 7;
			int num2 = Core.gameSeed * 10 + num - Core.train.Credits;
			if (localDebug)
			{
				MelonLogger.Msg("[ENCODE]");
				MelonLogger.Msg($"Seed: {Core.gameSeed}");
				MelonLogger.Msg($"Index: {num}");
				MelonLogger.Msg($"Encoded: {num2}");
			}
			Core.train.RpcWriter___Server_svr_RequestAddCredits_3316948804(num2);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(true);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(false);
		}

		public static void SyncUpgradesAcrossServer3()
		{
			int num = 8;
			int num2 = (Core.secondTrigger ? (originalCredits * 10 + num - Core.gameSeed) : (originalCredits * 10 + num - 1));
			if (localDebug)
			{
				MelonLogger.Msg("[ENCODE]");
				MelonLogger.Msg($"Credits: {Core.train.Credits}");
				MelonLogger.Msg($"Index: {num}");
				MelonLogger.Msg($"Encoded: {num2}");
			}
			Core.train.RpcWriter___Server_svr_RequestAddCredits_3316948804(num2);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(true);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(false);
		}

		public static void BrokenMinuteServer()
		{
			int num = 7;
			int num2 = originalCredits * 10 + num - 1;
			if (localDebug)
			{
				MelonLogger.Msg("[ENCODE]");
				MelonLogger.Msg($"Credits: {Core.train.Credits}");
				MelonLogger.Msg($"Index: {num}");
				MelonLogger.Msg($"Encoded: {num2}");
			}
			Core.train.RpcWriter___Server_svr_RequestAddCredits_3316948804(num2);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(true);
			Core.train.RpcWriter___Server_svr_ToggleDoors_1140765316(false);
		}
	}
	internal static class UpgradeInit
	{
		public static string[] evaderDescriptions = new string[6] { "All movement speed increased by 10%", "Sprinting stamina decreases 10% slower", "All movement speed increased by 15%\n(25% total)", "Sprinting stamina decreases 15% slower\n(25% total)", "All movement speed increased by 70% while bleeding\n\nAll movement speed increased by 5%(30% total)\n\nSprinting stamina decreases 5% slower\n(30% total", "Haste mumbles of a nearing end" };

		public static string[] lurkerDescriptions = new string[6] { "+40% crouched movement speed", "Monster's player detection range, chance, and frequency reduced by 15%", "+60% crouched movement speed\n(100% total)", "Monster's player detection range, chance, and frequency reduced by 20%\n(35% total)", "Landmine and Tripwire immunity\n\n+25% crouched movement speed\n(125% total)\n\nMonster's player detection range, chance, and frequency reduced by 5%\n(40% total)", "The eternal resonate silence" };

		public static string[] supplierDescriptions = new string[6] { "+30% tool equipment durability", "+4ft all light equipment range", "+45% tool equipment durability\n(75% total)", "+6ft all light equipment range\n(10ft total)", "+50% chance for shop items purchased to be duplicated\n\n+75% tool equipment durability\n(150% total)\n\n+2ft all light equipment range\n(12ft total)", "Vigor and glow\nWither and vanish" };

		public static string[] ransackerDescriptions = new string[6] { "Non-container loot items are 10% more valuable", "Loot containers contain up to 2 additional loot items\n(+0-2 possible)", "Non-container loot items are 15% more valuable\n(25% total)", "Loot containers contain up to 4 additional loot items\n(+0-4 possible)", "Non-container loot items have a 1% chance to have 500% value\n\nLoot containers contain at least 1 additional loot item\n(+1-4 possible)", "Fortune feeds upon the feeble" };

		public static string[] forerunnerDescriptions = new string[6] { "Arrive to each destination 1 hour earlier\n(6:00am -> 5:00am)", "+5% chance for a minute to not pass when it normally world\n(Cannot occur consecutively)", "Arrive to each destination 1 hour earlier\n(5:00am -> 4:00am)", "+7% chance for a minute to not pass when it normally world\n(12% total)\n(Cannot occur consecutively)", "Minutes not passing can occur consecutively\n\nArrive to each destination 1 hour earlier\n(4:00am -> 3:00am)", "Time dissipates\nYou are forsaken." };

		public static string[] evaderCurrentDescriptions = new string[6] { "", "All movement speed: +10%", "All movement speed: +10%\n\nStamina duration: +10%", "All movement speed: +25%\n\nStamina duration: +10%", "All movement speed: +25%\n\nStamina duration: +25%", "All movement speed: +30%\n\nStamina duration: +30%\n\nMovement speed while bleeding: +70%" };

		public static string[] lurkerCurrentDescriptions = new string[6] { "", "Crouch movement speed: +40%", "Crouch movement speed: +40%\n\nEach monster's player detection range, chance, and frequency: -15%", "Crouch movement speed: +100%\n\nEach monster's player detection range, chance, and frequency: -15%", "Crouch movement speed: +100%\n\nEach monster's player detection range, chance, and frequency: -35%", "Crouch movement speed: +125%\n\nEach monster's player detection range, chance, and frequency: -40%\n\nImmune to: Landmines\nImmune to: Tripwires" };

		public static string[] supplierCurrentDescriptions = new string[6] { "", "Tool durability: +30%", "Tool durability: +30%\n\nLight equipment range: +4ft", "Tool durability: +75%\n\nLight equipment range: +4ft", "Tool durability: +75%\n\nLight equipment range: +10ft", "Tool durability: +150%\n\nLight equipment range: +12ft\n\nShop items duplication chance: +50%" };

		public static string[] ransackerCurrentDescriptions = new string[6] { "", "Non-container loot item value: +10%", "Non-container loot item value: +10%\n\nLoot containers contain (0-2) additional items", "Non-container loot item value: +25%\n\nLoot containers contain (0-2) additional items", "Non-container loot item value: +25%\n\nLoot containers contain (0-4) additional items", "Non-container loot item value: +25%\n\nLoot containers contain (1-4) additional items\n\nChance for 500% value non-container loot: +1%" };

		public static string[] forerunnerCurrentDescriptions = new string[6] { "", "Arrive to each destination 1 hour earlier\n(6:00am -> 5:00am)", "Arrive to each destination 1 hour earlier\n(6:00am -> 5:00am)\n\n+5% chance for a minute to not pass when it normally world\n(Cannot occur consecutively)", "Arrive to each destination 2 hours earlier\n(6:00am -> 4:00am)\n\n+5% chance for a minute to not pass when it normally world\n(Cannot occur consecutively)", "Arrive to each destination 2 hours earlier\n(6:00am -> 4:00am)\n\n+12% chance for a minute to not pass when it normally world\n(Cannot occur consecutively)", "Arrive to each destination 3 hours earlier\n(6:00am -> 3:00am)\n\n+12% chance for a minute to not pass when it normally world\n(Can occur consecutively)" };

		public static string noneDescription = "Select an upgrade below";

		public static void GetMainMenuItems()
		{
			UpgradeApplier.mainMarker = UpgradeInit.FindObjectByName<FFSprayTool>("SprayMark");
			UpgradeApplier.mainBoltcutter = UpgradeInit.FindObjectByName<FFBoltcutters>("Buoltcutters");
			UpgradeApplier.mainSledgehammer = UpgradeInit.FindObjectByName<FFSledgehammer>("SledgeHammer");
			UpgradeApplier.mainStunlight = UpgradeInit.FindObjectByName<FFStunLight>("StunLight");
			UpgradeApplier.mainGlowstick = UpgradeInit.FindObjectByName<FFGlowstick>("Glowstick");
			UpgradeApplier.mainLantern = UpgradeInit.FindObjectByName<FFLantern>("Lantern");
			UpgradeApplier.mainFlashlight = UpgradeInit.FindObjectByName<FFFlashlight>("Flashlight");
			UpgradeApplier.mainAdrenaline = UpgradeInit.FindObjectByName<FFAdrenalineShot>("Adrenaline Shot");
			UpgradeApplier.mainWalkie = UpgradeInit.FindObjectByName<FFWalkieTalkie>("Walkie Talkie");
			UpgradeApplier.mainFirecrackers = UpgradeInit.FindObjectByName<FFFirecrackers>("Firecrackers");
			UpgradeApplier.mainGasMask = UpgradeInit.FindObjectByName<FFGasmask>("Gasmask");
			UpgradeApplier.mainSoda = UpgradeInit.FindObjectByName<FFNoiseMaker>("Noisemaker (soda can)");
			UpgradeApplier.mainDynamite = UpgradeInit.FindObjectByName<FFDynamite>("Dynamite");
		}

		public static T FindObjectByName<T>(string name) where T : Object
		{
			foreach (T item in Resources.FindObjectsOfTypeAll<T>())
			{
				if (((Object)item).name.Equals(name, StringComparison.OrdinalIgnoreCase))
				{
					MelonLogger.Msg("[" + name + "] loaded!");
					return item;
				}
			}
			return default(T);
		}

		public static void InitializeCodex()
		{
			//IL_0045: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			Core._menuTexture = loadTextures("codex_long");
			if ((Object)(object)Core._menuTexture != (Object)null)
			{
				Core._menuSprite = Sprite.Create(Core._menuTexture, new Rect(0f, 0f, (float)((Texture)Core._menuTexture).width, (float)((Texture)Core._menuTexture).height), new Vector2(0.5f, 0.5f));
			}
			Core._indicatorTexture = loadTextures("codex_indicator_2");
			if ((Object)(object)Core._indicatorTexture != (Object)null)
			{
				Core._indicatorSprite = Sprite.Create(Core._indicatorTexture, new Rect(0f, 0f, (float)((Texture)Core._indicatorTexture).width, (float)((Texture)Core._indicatorTexture).height), new Vector2(0.5f, 0.5f));
			}
		}

		public static void GetMainMenuEnemies()
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			UpgradeApplier.mainSpider = UpgradeInit.FindObjectByName<FFSpiderAI>("The Spider");
			UpgradeApplier.mainVentress = UpgradeInit.FindObjectByName<FFVentressAI>("The Ventress");
			UpgradeApplier.mainNButcher = UpgradeInit.FindObjectByName<FFButcherAI>("Nightmare Butcher");
			UpgradeApplier.mainForsaken = UpgradeInit.FindObjectByName<FFForsakenAI>("The Forsaken ECD");
			UpgradeApplier.mainShambler = UpgradeInit.FindObjectByName<FFShambler>("The Shambler");
			UpgradeApplier.mainAbandoned = UpgradeInit.FindObjectByName<FFTheAbandonedOneAI>("The Abandoned One");
			UpgradeApplier.mainPatient = UpgradeInit.FindObjectByName<FFForsakenAI>("The Forsaken (Patient)");
			UpgradeApplier.mainCarrier = UpgradeInit.FindObjectByName<FFCarrierAI>("The Carrier");
			UpgradeApplier.mainButcher = UpgradeInit.FindObjectByName<FFButcherAI>("The Butcher");
			UpgradeApplier.mainNShambler = UpgradeInit.FindObjectByName<FFShambler>("Nightmare Shambler");
			UpgradeApplier.mainNSpider = UpgradeInit.FindObjectByName<FFSpiderAI>("Nightmare Spider");
			UpgradeApplier.mainShepherd = UpgradeInit.FindObjectByName<FFMistAI>("The Shepherd");
			UpgradeApplier.mainPackrat = UpgradeInit.FindObjectByName<FFPackratAI>("The Packrat");
			UpgradeApplier.initDetectRadius = new float[12]
			{
				((FFAICore)UpgradeApplier.mainSpider).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainVentress).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainNButcher).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainForsaken).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainShambler).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainAbandoned).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainPatient).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainCarrier).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainButcher).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainNShambler).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainShepherd).checkFarPlayerRadius,
				((FFAICore)UpgradeApplier.mainPackrat).checkFarPlayerRadius
			};
			UpgradeApplier.initDetectChance = new int[12]
			{
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainSpider).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainVentress).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainNButcher).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainForsaken).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainShambler).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainAbandoned).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainPatient).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainCarrier).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainButcher).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainNShambler).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainShepherd).checkFarPlayerChance),
				(int)Percent.op_Implicit(((FFAICore)UpgradeApplier.mainPackrat).checkFarPlayerChance)
			};
			UpgradeApplier.initDetectDelay = new float[12]
			{
				((FFAICore)UpgradeApplier.mainSpider).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainVentress).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainNButcher).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainForsaken).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainShambler).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainAbandoned).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainPatient).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainCarrier).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainButcher).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainNShambler).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainShepherd).checkFarPlayersDelay,
				((FFAICore)UpgradeApplier.mainPackrat).checkFarPlayersDelay
			};
		}

		public static List<Core.Upgrade> initUpgrades(List<Core.Upgrade> upgrades)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (upgrades == null)
			{
				upgrades = new List<Core.Upgrade>();
			}
			else
			{
				upgrades.Clear();
			}
			AddUpgrade(upgrades, "Evader", "Run from the inevitable.", loadTextures("evader1-crt"), 0, 5, new Color(1f, 1f, 1f, 1f), 3000, 1500, 8f);
			AddUpgrade(upgrades, "Lurker", "Become undetectable.", loadTextures("lurker1-crt"), 0, 5, new Color(1f, 1f, 1f, 1f), 1500, 1250, 0.1f);
			AddUpgrade(upgrades, "Supplier", "Fully utilize your limited resources.", loadTextures("supplier1-crt"), 0, 5, new Color(1f, 1f, 1f, 1f), 1250, 1000, 33f);
			AddUpgrade(upgrades, "Ransacker", "Scavenge greater loot.", loadTextures("ransacker1-crt"), 0, 5, new Color(1f, 1f, 1f, 1f), 3500, 2000, 20f);
			AddUpgrade(upgrades, "Forerunner", "Get ahead of your opposition.", loadTextures("forerunner1-crt"), 0, 5, new Color(1f, 1f, 1f, 1f), 2500, 1250, 1f);
			return upgrades;
		}

		private static void AddUpgrade(List<Core.Upgrade> list, string name, string description, Texture2D img, int lvl, int lvlMax, Color color, int costInit, int costScaler, float upgScaler)
		{
			//IL_002d: 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)
			Core.Upgrade upgrade = new Core.Upgrade();
			upgrade.upgName = name;
			upgrade.upgDcr = description;
			upgrade.upgImg = img;
			upgrade.upgLvl = lvl;
			upgrade.upgLvlMax = lvlMax;
			upgrade.boxColor = color;
			upgrade.initCost = costInit;
			upgrade.costScaler = costScaler;
			upgrade.upgScaler = upgScaler;
			list.Add(upgrade);
		}

		public static void UpdateCostsAccToPlayerCount(int numberOfValidPlayers)
		{
			MelonLogger.Msg($"[Adjusting LOCAL Upgrade costs based on *{numberOfValidPlayers}* players.]\n\n");
			MelonLogger.Msg($"[Initial Upgrade Costs before:    [{Core.upgrades[0].initCost}, {Core.upgrades[1].initCost}, {Core.upgrades[2].initCost}, {Core.upgrades[3].initCost}, {Core.upgrades[4].initCost}]]");
			MelonLogger.Msg($"[Subsequent Upgrade Costs before: [{Core.upgrades[0].costScaler}, {Core.upgrades[1].costScaler},{Core.upgrades[2].costScaler},{Core.upgrades[3].costScaler},{Core.upgrades[4].costScaler},]]");
			int num = numberOfValidPlayers - 1;
			double num2 = 1.0;
			num2 = ((num != 0) ? ((double)(1f + (float)num * 0.3f)) : 1.0);
			Core.upgrades[0].initCost = getRoundedInt((int)Math.Ceiling(3000.0 * num2));
			Core.upgrades[0].costScaler = getRoundedInt((int)Math.Ceiling(1500.0 * num2));
			Core.upgrades[1].initCost = getRoundedInt((int)Math.Ceiling(1500.0 * num2));
			Core.upgrades[1].costScaler = getRoundedInt((int)Math.Ceiling(1250.0 * num2));
			Core.upgrades[2].initCost = getRoundedInt((int)Math.Ceiling(1250.0 * num2));
			Core.upgrades[2].costScaler = getRoundedInt((int)Math.Ceiling(1000.0 * num2));
			Core.upgrades[3].initCost = getRoundedInt((int)Math.Ceiling(3500.0 * num2));
			Core.upgrades[3].costScaler = getRoundedInt((int)Math.Ceiling(2000.0 * num2));
			Core.upgrades[4].initCost = getRoundedInt((int)Math.Ceiling(2500.0 * num2));
			Core.upgrades[4].costScaler = getRoundedInt((int)Math.Ceiling(1250.0 * num2));
			MelonLogger.Msg($"[Initial Upgrade Costs after:    [{Core.upgrades[0].initCost}, {Core.upgrades[1].initCost}, {Core.upgrades[2].initCost}, {Core.upgrades[3].initCost}, {Core.upgrades[4].initCost}]]");
			MelonLogger.Msg($"[Subsequent Upgrade Costs after: [{Core.upgrades[0].costScaler}, {Core.upgrades[1].costScaler},{Core.upgrades[2].costScaler},{Core.upgrades[3].costScaler},{Core.upgrades[4].costScaler},]]");
		}

		public static int getRoundedInt(int value)
		{
			int num = value % 250;
			return value - num;
		}

		public static Texture2D loadTextures(string name)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string x) => x.EndsWith(name + ".png", StringComparison.OrdinalIgnoreCase));
			if (text == null)
			{
				MelonLogger.Warning("Embedded image not found: " + name + ".png");
				return null;
			}
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				MelonLogger.Warning("Could not open embedded image: " + text);
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			byte[] array = memoryStream.ToArray();
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array)))
			{
				MelonLogger.Warning("Failed to load embedded image: " + text);
				return null;
			}
			((Texture)val).filterMode = (FilterMode)0;
			return val;
		}
	}
	public static class UpgradeMenuConfig
	{
		public static int MainX = 10;

		public static int MainY = 20;

		public static float MainWidth = 250f;

		public static float MainHeight = 300f;

		public static int TitleFontSize = 24;

		public static FontStyle TitleFontStyle = (FontStyle)1;

		public static float ButtonXOffset = 30f;

		public static float ButtonYOffset = 20f;

		public static float ButtonWidth = 210f;

		public static float ButtonHeight = 40f;

		public static float ButtonSpacing = 50f;

		public static float DetailXOffset = 0f;

		public static float DetailYOffset = 320f;

		public static float DetailWidth = 300f;

		public static float DetailHeight = 320f;

		public static int TitleY = 3;

		public static float ImageXOffset = 90f;

		public static float ImageYOffset = 45f;

		public static float ImageWidth = 100f;

		public static float ImageHeight = 100f;

		public static int StatsFontSize = 12;

		public static TextAnchor StatsFontAlignment = (TextAnchor)1;

		public static FontStyle StatsFontStyle = (FontStyle)1;

		public static float CurrentHeaderX = 20f;

		public static float CurrentHeaderY = 185f;

		public static float CurrentHeaderWidth = 100f;

		public static float CurrentHeaderHeight = 40f;

		public static float FutureHeaderX = 150f;

		public static float FutureHeaderY = 185f;

		public static float FutureHeaderWidth = 130f;

		public static float FutureHeaderHeight = 40f;

		public static float CurrentValueX = 20f;

		public static float CurrentValueY = 195f;

		public static float FutureValueX = 150f;

		public static float FutureValueY = 195f;

		public static float EffectWidth = 120f;

		public static float EffectHeight = 40f;

		public static float SecondEffectYOffset = 15f;

		public static float DetailX = 0f;

		public static float DetailY = 0f;

		public static float LevelX = 30f;

		public static float LevelY = 105f;

		public static float CostX = 30f;

		public static float CostY = 120f;

		public static float CostWidth = 200f;

		public static float CostHeight = 40f;

		public static float BuyButtonXOffset = 30f;

		public static float BuyButtonYOffset = 40f;

		public static float BuyButtonWidth = 210f;

		public static float BuyButtonHeight = 40f;

		public static float ErrorX = 0f;

		public static float ErrorYOffset = 80f;

		public static float ErrorWidth = 300f;

		public static float ErrorHeight = 40f;

		public static int ErrorFontSize = 9;

		public static float ErrorDuration = 1.5f;

		public static Color MainMenuBackgroundColor = Color.red;

		public static Color NormalTextColor = Color.white;

		public static Color ErrorTextColor = Color.red;

		public static int DetailTitleFontSize = 24;

		public static float ForerunnerCurrentYOffset = 215f;

		public static float ForerunnerFutureYOffset = 215f;

		public static Color ButtonColor = Color.white;
	}
	public static class UpgradeMenu
	{
		public static class ModAssets
		{
			public static TMP_FontAsset CustomTmpFont { get; private set; }

			public static Font CustomGuiFont { get; private set; }

			public static void LoadFont()
			{
				if ((Object)(object)CustomTmpFont != (Object)null)
				{
					return;
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string text = null;
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				foreach (string text2 in manifestResourceNames)
				{
					if (text2.EndsWith("customfontbundle"))
					{
						text = text2;
						break;
					}
				}
				if (text == null)
				{
					Debug.LogError(Object.op_Implicit("[PlayerUpgrades DEBUG] FAILED: Embedded resource missing!"));
					return;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Il2CppStructArray<byte> val = Il2CppStructArray<byte>.op_Implicit(array);
				AssetBundle val2 = AssetBundle.LoadFromMemory(val);
				if ((Object)(object)val2 != (Object)null)
				{
					CustomTmpFont = ((Il2CppObjectBase)val2.LoadAsset("mago1 SDF", Il2CppType.Of<TMP_FontAsset>())).Cast<TMP_FontAsset>();
					if ((Object)(object)CustomTmpFont != (Object)null)
					{
						CustomGuiFont = CustomTmpFont.sourceFontFile;
						Debug.Log(Object.op_Implicit("[PlayerUpgrades DEBUG] Embedded TMP Font loaded: " + ((Object)CustomTmpFont).name));
					}
					else
					{
						Debug.LogError(Object.op_Implicit("[PlayerUpgrades DEBUG] Could not load 'mago1 SDF' asset from bundle."));
					}
				}
				else
				{
					Debug.LogError(Object.op_Implicit("[PlayerUpgrades DEBUG] AssetBundle.LoadFromMemory returned null."));
				}
			}
		}

		public static class EmbeddedBundleLoader
		{
			[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
			private static extern IntPtr UnityEngine_AssetBundle_LoadFromFile_Internal(string path, uint crc, ulong offset);

			public static AssetBundle LoadEmbeddedBundle(string resourceName)
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
				if (stream == null)
				{
					MelonLogger.Error("[EmbeddedBundleLoader] Could not find embedded resource: '" + resourceName + "'");
					return null;
				}
				string text = Path.Combine(Directory.GetCurrentDirectory(), "UserData", "Temp");
				Directory.CreateDirectory(text);
				string path = Path.Combine(text, resourceName + ".bundle");
				try
				{
					using (FileStream destination = File.Create(path))
					{
						stream.CopyTo(destination);
					}
					IntPtr intPtr = UnityEngine_AssetBundle_LoadFromFile_Internal(path, 0u, 0uL);
					if (intPtr == IntPtr.Zero)
					{
						MelonLogger.Error("[EmbeddedBundleLoader] Native AssetBundle.LoadFromFile returned null pointer.");
						return null;
					}
					return IL2CPP.PointerToValueGeneric<AssetBundle>(intPtr, false, false);
				}
				catch (Exception value)
				{
					MelonLogger.Error($"[EmbeddedBundleLoader] Failed to load embedded bundle via native call: {value}");
					return null;
				}
				finally
				{
					if (File.Exists(path))
					{
						try
						{
							File.Delete(path);
						}
						catch
						{
						}
					}
				}
			}
		}

		private static GUIStyle _menuStyle;

		private static GUIStyle _titleStyle;

		private static GUIStyle _costStyle;

		private static GUIStyle _statsStyle;

		private static GUIStyle _currentStyle;

		private static GUIStyle _errorStyle;

		private static float _errorTimer = 0f;

		private static string _errorMessage = "";

		private static float _errorAlpha = 0f;

		public static int errorY = -11;

		private static int _spacing = 0;

		public static string LvlDescriptionCurrent;

		public static string CurrentEffectsDescription;

		public static string prependCurrent1;

		public static string postpendCurrent1;

		public static string prependCurrent2;

		public static string postpendCurrent2;

		public static string prependFuture1;

		public static string postpendFuture1;

		public static string prependFuture2;

		public static string postpendFuture2;

		public static string midDisplayErrorText = "Not enough credits.";

		public static string midDisplayDecider;

		public static GUIStyle styleDecider;

		public static Color evaderColor = Color.lightYellow;

		public static Color lurkerColor = Color.lightSkyBlue;

		public static Color supplierColor = Color.softRed;

		public static Color ransackerColor = Color.orange;

		public static Color forerunnerColor = Color.indigo;

		public static int animationOffset = -300;

		public static float divMultRate = 1.1f;

		public static Core.Upgrade globalSelected = null;

		public static int CurrentEX = 0;

		public static int CurrentEY = 0;

		public static int CurrentEWidth = 0;

		public static int CurrentEHeight = 0;

		public static string GetMidDisplayRegularText(int cost)
		{
			return $"Upg Cost: {cost}";
		}

		public static void Draw(List<Core.Upgrade> upgrades, ref Core.Upgrade selected)
		{
			//IL_006a: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			InitStyles();
			AnimationOffset(animationOffset);
			if (Core._slide && animationOffset <= -1 && Core.myDataDeck.DataDeckOpen)
			{
				slideEnable(animationOffset);
			}
			else if (!Core._slide && animationOffset > -300)
			{
				slideDisable(animationOffset);
			}
			_spacing = 0;
			GUI.backgroundColor = UpgradeMenuConfig.MainMenuBackgroundColor;
			foreach (Core.Upgrade upgrade in upgrades)
			{
				GUI.backgroundColor = UpgradeMenuConfig.ButtonColor;
				if (GUI.Button(new Rect((float)UpgradeMenuConfig.MainX + UpgradeMenuConfig.ButtonXOffset + (float)_spacing, (float)UpgradeMenuConfig.MainY + UpgradeMenuConfig.ButtonYOffset, UpgradeMenuConfig.ButtonWidth, UpgradeMenuConfig.ButtonHeight), ""))
				{
					selected = ((selected == upgrade) ? null : upgrade);
					globalSelected = selected;
				}
				_spacing += (int)UpgradeMenuConfig.ButtonSpacing;
			}
			if (selected != null)
			{
				DrawUpgradeDetails(upgrades, selected);
			}
		}

		private static void DrawUpgradeDetails(List<Core.Upgrade> upgrades, Core.Upgrade upgrade)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)UpgradeMenuConfig.MainX + UpgradeMenuConfig.DetailXOffset;
			float num2 = (float)UpgradeMenuConfig.MainY + UpgradeMenuConfig.DetailYOffset;
			if ((Object)(object)upgrade.upgImg == (Object)null)
			{
				upgrade.upgImg = UpgradeInit.loadTextures(upgrade.upgName);
			}
			if ((Object)(object)upgrade.upgImg != (Object)null)
			{
				GUI.DrawTexture(new Rect(num + UpgradeMenuConfig.ImageXOffset, num2 + UpgradeMenuConfig.ImageYOffset, UpgradeMenuConfig.ImageWidth, UpgradeMenuConfig.ImageHeight), (Texture)(object)upgrade.upgImg);
			}
			if (Time.time < _errorTimer)
			{
				_errorStyle.normal.textColor = new Color(UpgradeMenuConfig.ErrorTextColor.r, UpgradeMenuConfig.ErrorTextColor.g, UpgradeMenuConfig.ErrorTextColor.b, _errorAlpha);
				_errorAlpha -= 0.001f;
				if (_errorAlpha < 0f)
				{
					_errorAlpha = 0f;
				}
			}
			if (upgrade.upgLvl < upgrade.upgLvlMax && GUI.Button(new Rect(num + UpgradeMenuConfig.BuyButtonXOffset, num2 + (float)_spacing + UpgradeMenuConfig.BuyButtonYOffset, UpgradeMenuConfig.BuyButtonWidth, UpgradeMenuConfig.BuyButtonHeight), "Buy"))
			{
				int num3 = upgrade.initCost + upgrade.costScaler * upgrade.upgLvl;
				if (Core.train.Credits >= num3)
				{
					UpgradeApplier.ServerApplyUpgrade(upgrades.IndexOf(upgrade));
				}
				else
				{
					TriggerError("Not enough credits...");
				}
			}
			DisplayUpgradeBenefits(upgrade, num, num2);
		}

		private static void DisplayUpgradeBenefits(Core.Upgrade upgrade, float detailX, float detailY)
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0914: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: 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_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_076d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: 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_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			SetDefaultEffectText();
			if (upgrade.upgName == "Evader")
			{
				prependCurrent1 = "Max Speed +";
				postpendCurrent1 = "%";
				prependCurrent2 = "Stamina Drain -";
				postpendCurrent2 = "%";
				prependFuture1 = "+";
				postpendFuture1 = "% Max Speed";
				prependFuture2 = "-";
				postpendFuture2 = "% Stamina Drain";
				flag2 = true;
			}
			else if (upgrade.upgName == "Elusive")
			{
				SetNA();
				flag2 = false;
			}
			else if (upgrade.upgName == "Hacker")
			{
				SetNA();
				flag2 = false;
			}
			else if (upgrade.upgName == "Ransacker")
			{
				SetNA();
				flag2 = false;
			}
			else if (upgrade.upgName == "Forerunner")
			{
				prependCurrent1 = "Current Arrival Time: ";
				postpendCurrent1 = ":00 AM";
				prependFuture1 = "Arrive +";
				postpendFuture1 = " Hour Earlier";
				flag = true;
			}
			_statsStyle.normal.textColor = UpgradeMenuConfig.NormalTextColor;
			if (globalSelected == null)
			{
				_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
				LvlDescriptionCurrent = UpgradeInit.noneDescription;
			}
			else if (upgrade.upgName == "Evader")
			{
				if (upgrade.upgLvl == 5)
				{
					int num = Random.Range(1, 101);
					if (num >= 93)
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
					}
					else
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.black);
					}
					_titleStyle.normal.textColor = Color.lightGray;
					_costStyle.normal.textColor = Color.lightGray;
					LvlDescriptionCurrent = UpgradeInit.evaderDescriptions[upgrade.upgLvl];
				}
				else
				{
					_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = evaderColor);
					LvlDescriptionCurrent = UpgradeInit.evaderDescriptions[upgrade.upgLvl];
					_titleStyle.normal.textColor = evaderColor;
					_costStyle.normal.textColor = evaderColor;
				}
				CurrentEffectsDescription = UpgradeInit.evaderCurrentDescriptions[upgrade.upgLvl];
				_currentStyle.normal.textColor = evaderColor;
			}
			else if (upgrade.upgName == "Lurker")
			{
				if (upgrade.upgLvl == 5)
				{
					int num2 = Random.Range(1, 101);
					if (num2 >= 93)
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
					}
					else
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.black);
					}
					_titleStyle.normal.textColor = Color.lightGray;
					_costStyle.normal.textColor = Color.lightGray;
					LvlDescriptionCurrent = UpgradeInit.lurkerDescriptions[upgrade.upgLvl];
				}
				else
				{
					_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = lurkerColor);
					LvlDescriptionCurrent = UpgradeInit.lurkerDescriptions[upgrade.upgLvl];
					_titleStyle.normal.textColor = lurkerColor;
					_costStyle.normal.textColor = lurkerColor;
				}
				CurrentEffectsDescription = UpgradeInit.lurkerCurrentDescriptions[upgrade.upgLvl];
				_currentStyle.normal.textColor = lurkerColor;
			}
			else if (upgrade.upgName == "Supplier")
			{
				if (upgrade.upgLvl == 5)
				{
					int num3 = Random.Range(1, 101);
					if (num3 >= 93)
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
					}
					else
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.black);
					}
					_titleStyle.normal.textColor = Color.lightGray;
					_costStyle.normal.textColor = Color.lightGray;
					LvlDescriptionCurrent = UpgradeInit.supplierDescriptions[upgrade.upgLvl];
				}
				else
				{
					_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = supplierColor);
					LvlDescriptionCurrent = UpgradeInit.supplierDescriptions[upgrade.upgLvl];
					_titleStyle.normal.textColor = supplierColor;
					_costStyle.normal.textColor = supplierColor;
				}
				CurrentEffectsDescription = UpgradeInit.supplierCurrentDescriptions[upgrade.upgLvl];
				_currentStyle.normal.textColor = supplierColor;
			}
			else if (upgrade.upgName == "Ransacker")
			{
				if (upgrade.upgLvl == 5)
				{
					int num4 = Random.Range(1, 101);
					if (num4 >= 93)
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
					}
					else
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.black);
					}
					_titleStyle.normal.textColor = Color.lightGray;
					_costStyle.normal.textColor = Color.lightGray;
					LvlDescriptionCurrent = UpgradeInit.ransackerDescriptions[upgrade.upgLvl];
				}
				else
				{
					_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = ransackerColor);
					LvlDescriptionCurrent = UpgradeInit.ransackerDescriptions[upgrade.upgLvl];
					_titleStyle.normal.textColor = ransackerColor;
					_costStyle.normal.textColor = ransackerColor;
				}
				CurrentEffectsDescription = UpgradeInit.ransackerCurrentDescriptions[upgrade.upgLvl];
				_currentStyle.normal.textColor = ransackerColor;
			}
			else if (upgrade.upgName == "Forerunner")
			{
				if (upgrade.upgLvl == 5)
				{
					int num5 = Random.Range(1, 101);
					if (num5 >= 93)
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.lightGray);
					}
					else
					{
						_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = Color.black);
					}
					_titleStyle.normal.textColor = Color.lightGray;
					_costStyle.normal.textColor = Color.lightGray;
					LvlDescriptionCurrent = UpgradeInit.forerunnerDescriptions[upgrade.upgLvl];
				}
				else
				{
					_statsStyle.normal.textColor = (UpgradeMenuConfig.NormalTextColor = forerunnerColor);
					LvlDescriptionCurrent = UpgradeInit.forerunnerDescriptions[upgrade.upgLvl];
					_titleStyle.normal.textColor = forerunnerColor;
					_costStyle.normal.textColor = forerunnerColor;
				}
				CurrentEffectsDescription = UpgradeInit.forerunnerCurrentDescriptions[upgrade.upgLvl];
				_currentStyle.normal.textColor = forerunnerColor;
			}
			GUI.Label(new Rect(detailX + UpgradeMenuConfig.CurrentValueX, detailY + UpgradeMenuConfig.CurrentValueY, UpgradeMenuConfig.EffectWidth, UpgradeMenuConfig.EffectHeight), LvlDescriptionCurrent, _statsStyle);
			GUI.Box(new Rect(detailX + UpgradeMenuConfig.DetailX, detailY + UpgradeMenuConfig.DetailY + (float)UpgradeMenuConfig.TitleY, UpgradeMenuConfig.DetailWidth, UpgradeMenuConfig.DetailHeight), upgrade.upgName, _titleStyle);
			if (upgrade.upgLvl != upgrade.upgLvlMax)
			{
				int cost = upgrade.initCost + upgrade.costScaler * upgrade.upgLvl;
				if (Time.time >= _errorTimer)
				{
					midDisplayDecider = GetMidDisplayRegularText(cost);
					styleDecider = _costStyle;
					GUI.Label(new Rect(detailX + UpgradeMenuConfig.CostX, detailY + UpgradeMenuConfig.CostY, UpgradeMenuConfig.CostWidth, UpgradeMenuConfig.CostHeight), midDisplayDecider, styleDecider);
				}
				else
				{
					midDisplayDecider = midDisplayErrorText;
					styleDecider = _errorStyle;
					GUI.Label(new Rect(detailX + UpgradeMenuConfig.CostX, detailY + UpgradeMenuConfig.CostY + (float)errorY, UpgradeMenuConfig.CostWidth, UpgradeMenuConfig.CostHeight), midDisplayDecider, styleDecider);
				}
			}
			else
			{
				styleDecider = _costStyle;
				GUI.Label(new Rect(detailX + UpgradeMenuConfig.CostX, detailY + UpgradeMenuConfig.CostY, UpgradeMenuConfig.CostWidth, UpgradeMenuConfig.CostHeight), "MAX LEVEL", styleDecider);
			}
			GUI.Box(new Rect(detailX + (float)CurrentEX, detailY + (float)CurrentEY, (float)CurrentEWidth, (float)CurrentEHeight), "Active Effects:\n\n" + CurrentEffectsDescription, _currentStyle);
		}

		private static void SetDefaultEffectText()
		{
			prependCurrent1 = "";
			postpendCurrent1 = "";
			prependCurrent2 = "";
			postpendCurrent2 = "";
			prependFuture1 = "";
			postpendFuture1 = "";
			prependFuture2 = "";
			postpendFuture2 = "";
		}

		private static void SetNA()
		{
			prependCurrent1 = "N/A";
			postpendCurrent1 = "";
			prependCurrent2 = "N/A";
			postpendCurrent2 = "";
			prependFuture1 = "N/A";
			postpendFuture1 = "";
			prependFuture2 = "N/A";
			postpendFuture2 = "";
		}

		private static void InitStyles()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0096: 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_00b0: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01d2: 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)
			//IL_01ec: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.TitleFontSize,
				fontStyle = UpgradeMenuConfig.TitleFontStyle,
				alignment = (TextAnchor)1
			};
			val.normal.background = null;
			_menuStyle = val;
			_menuStyle.normal.textColor = UpgradeMenuConfig.NormalTextColor;
			GUIStyle val2 = new GUIStyle(GUI.skin.box)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.TitleFontSize,
				fontStyle = UpgradeMenuConfig.TitleFontStyle,
				alignment = (TextAnchor)1
			};
			val2.normal.background = null;
			_titleStyle = val2;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.StatsFontSize,
				fontStyle = UpgradeMenuConfig.StatsFontStyle,
				alignment = UpgradeMenuConfig.StatsFontAlignment
			};
			val3.normal.background = null;
			_costStyle = val3;
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.StatsFontSize,
				fontStyle = UpgradeMenuConfig.StatsFontStyle,
				alignment = UpgradeMenuConfig.StatsFontAlignment
			};
			val4.normal.background = null;
			_statsStyle = val4;
			GUIStyle val5 = new GUIStyle(GUI.skin.label)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.StatsFontSize,
				fontStyle = UpgradeMenuConfig.StatsFontStyle,
				alignment = UpgradeMenuConfig.StatsFontAlignment
			};
			val5.normal.background = null;
			_currentStyle = val5;
			GUIStyle val6 = new GUIStyle(GUI.skin.label)
			{
				font = Core.CustomFont,
				fontSize = UpgradeMenuConfig.ErrorFontSize,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val6.normal.background = null;
			_errorStyle = val6;
			_errorStyle.normal.textColor = UpgradeMenuConfig.ErrorTextColor;
		}

		public static void TriggerError(string message)
		{
			_errorMessage = message;
			_errorTimer = Time.time + UpgradeMenuConfig.ErrorDuration;
			_errorAlpha = 1f;
		}

		public static void MenuAdjustmentsInit()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due