Decompiled source of Call Of Lethal Duty v2.5.5

jumpmod.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using jumpmod.patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("jumpmod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("jumpmod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb679c7d-f27d-49b4-bcdb-9baff653387f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace jumpmod
{
	[BepInPlugin("poseidon.jumpmod", "Jump Mod", "1.0.0")]
	public class JumpModBase : BaseUnityPlugin
	{
		private const string modGUID = "poseidon.jumpmod";

		private const string modName = "Jump Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("poseidon.jumpmod");

		private static JumpModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("poseidon.jumpmod");
			mls.LogInfo((object)"ITS ALIVEEEEE");
			harmony.PatchAll(typeof(JumpModBase));
			harmony.PatchAll(typeof(jumpchange));
		}
	}
}
namespace jumpmod.patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class jumpchange
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void JumpFunPatch(ref float ___jumpForce)
		{
			___jumpForce = 20f;
		}
	}
}

InfHealth.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using InfHealth.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Lethal_company_test_mod_1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lethal_company_test_mod_1")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6220c874-f2fe-4b97-bb38-eff4c0a1b8aa")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace InfHealth
{
	[BepInPlugin("Masti.Inf_Health", "Infinity Health", "1.0.0")]
	public class InfHealthBase : BaseUnityPlugin
	{
		private const string modGUID = "Masti.Inf_Health";

		private const string modName = "Infinity Health";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Masti.Inf_Health");

		private static InfHealthBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Masti.Inf_Health");
			mls.LogInfo((object)"Infinity Health Loaded");
			harmony.PatchAll(typeof(InfHealthBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace InfHealth.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infinityHealthPatch(ref float ___health)
		{
			___health = 1E-42f;
		}
	}
}

MaskStun.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MaskStun.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MaskStun")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MaskStun")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bae5f807-647b-4919-8bfd-9157acebd4f9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MaskStun
{
	[BepInPlugin("Ex.MaskStun", "Ex Masked Enemy Stun Mod", "1.0.0")]
	public class MaskStunBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.MaskStun";

		private const string modName = "Ex Masked Enemy Stun Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Ex.MaskStun");

		private static MaskStunBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.MaskStun");
			mls.LogInfo((object)"Masked Enemy Stun mod has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "MaskStun.dll";
			location.TrimEnd(text.ToCharArray());
			harmony.PatchAll(typeof(MaskStunBase));
			harmony.PatchAll(typeof(MaskStunPatch));
			mls.LogInfo((object)"Hit it 'til it dies!");
		}
	}
}
namespace MaskStun.Patches
{
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskStunPatch
	{
		[HarmonyPatch("HitEnemy")]
		[HarmonyPostfix]
		public static void StunMaskPostFix(MaskedPlayerEnemy __instance)
		{
			((EnemyAI)__instance).stunNormalizedTimer = 0.2f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void MaskSpeed(MaskedPlayerEnemy __instance)
		{
			if (((EnemyAI)__instance).movingTowardsTargetPlayer)
			{
				((EnemyAI)__instance).agent.speed = 8f;
			}
			else
			{
				((EnemyAI)__instance).agent.speed = 8f;
			}
		}
	}
}

LCBetterEXP.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LCBetterEXP.patches;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LCBetterEXP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCBetterEXP")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3d1909e4-ce70-48f2-a2d1-28b67cea8eee")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCBetterEXP
{
	[BepInPlugin("Swaggies.BetterEXP", "BetterEXP", "1.1.2")]
	public class BetterEXPPlugin : BaseUnityPlugin
	{
		private const string _GUID = "Swaggies.BetterEXP";

		private const string _NAME = "BetterEXP";

		private const string _VER = "1.1.2";

		private readonly Harmony harmony = new Harmony("Swaggies.BetterEXP");

		private static BetterEXPPlugin Instance;

		public static ManualLogSource logr;

		public static ConfigEntry<bool> showEnemyKillNotifs;

		public static ConfigEntry<bool> showRoundSummary;

		public static ConfigEntry<bool> showRankInMenu;

		public static bool hasAssignedInitialRank;

		public static bool hasLoaded;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logr = Logger.CreateLogSource("Swaggies.BetterEXP");
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(BetterEXPPlugin));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(VisualEXPPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(WeatherPatch));
			harmony.PatchAll(typeof(PauseDisplayPatch));
			logr.LogInfo((object)"BetterEXP up and running.");
			int num = Saving.Load();
			if (num != -1)
			{
				hasLoaded = true;
			}
			else
			{
				logr.LogInfo((object)"Couldn't load xp.");
			}
			showEnemyKillNotifs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowEnemyKillNotifications", false, "Whether you should receive a notification about your BXP gain when an enemy dies. This may spoil gameplay.");
			showRoundSummary = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowRoundSummary", true, "Whether to show a breakdown of your BXP gains at the end of each day. Doesn't affect gameplay.");
			showRankInMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowRankInPauseMenu", true, "Whether to show your current BXP rank in the pause menu. Doesn't affect gameplay, but could conflict or overlap with other elements from other mods.");
		}

		public static int AssignInitialRank(int currentPlayerVanillaEXP)
		{
			if (hasAssignedInitialRank || hasLoaded)
			{
				return XPPatch.betterXp;
			}
			if (currentPlayerVanillaEXP >= 0)
			{
				XPPatch.betterXp = 0;
			}
			if (currentPlayerVanillaEXP >= 25)
			{
				XPPatch.betterXp = 25;
			}
			if (currentPlayerVanillaEXP >= 75)
			{
				XPPatch.betterXp = 50;
			}
			if (currentPlayerVanillaEXP >= 175)
			{
				XPPatch.betterXp = 100;
			}
			if (currentPlayerVanillaEXP >= 500)
			{
				XPPatch.betterXp = 200;
			}
			if (currentPlayerVanillaEXP >= 1000)
			{
				XPPatch.betterXp = 300;
			}
			if (currentPlayerVanillaEXP >= 1500)
			{
				XPPatch.betterXp = 400;
			}
			if (currentPlayerVanillaEXP >= 2000)
			{
				XPPatch.betterXp = 500;
			}
			if (currentPlayerVanillaEXP >= 2500)
			{
				XPPatch.betterXp = 600;
			}
			if (currentPlayerVanillaEXP >= 3000)
			{
				XPPatch.betterXp = 800;
			}
			hasAssignedInitialRank = true;
			XPPatch.level = XPPatch.GetPlayerBetterLevelIndex(XPPatch.betterXp);
			Task.Delay(3000).ContinueWith(delegate
			{
				HUDManager.Instance.DisplayTip("<color=#009600ff><size=80%>Thanks for installing BetterEXP!</size></color>", "<size=90%>Based on your vanilla EXP, your BXP Rank has been automatically assigned to <color=#0096ffff>" + XPPatch.GetPlayerBetterLevel(XPPatch.betterXp).name + "</color>! Remember to be a great asset.</size>", false, false, "LC_Tip1");
			});
			return XPPatch.betterXp;
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static void RunChatCommand(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			string text2 = text.ToLower();
			logr.LogInfo((object)text2);
			if (text2.StartsWith("bxp/"))
			{
				string[] array = new string[1] { text2 };
				if (text2.Contains(" "))
				{
					array = text2.Split(new char[1] { ' ' });
				}
				string text3 = array[0].Remove(0, 4);
				logr.LogInfo((object)text3);
				logr.LogInfo((object)array);
				int num = ChatCommand.Command(text3, array);
				__instance.chatTextField.text = "";
				if (num == 0)
				{
					Helpers.DisplayGlobalMessage("<color=#ff0000ff>BetterXP command not found.</color>");
				}
			}
		}
	}
}
namespace LCBetterEXP.patches
{
	internal class ChatCommand
	{
		public static int Command(string command, string[] args)
		{
			if (command.Contains("level"))
			{
				return LevelCommand();
			}
			if (command.Contains("vanilla"))
			{
				return VanillaLevelCommand();
			}
			return 0;
		}

		private static int LevelCommand()
		{
			int betterXp = XPPatch.betterXp;
			string name = XPPatch.GetPlayerBetterLevel(betterXp).name;
			Helpers.DisplayGlobalMessage($"Your current rank is <color=#00ff00ff>{name}</color>.\nBetterXP: <color=#00ff00ff>{betterXp} BXP</color>.");
			return 1;
		}

		private static int VanillaLevelCommand()
		{
			int localPlayerXP = HUDManager.Instance.localPlayerXP;
			Helpers.DisplayGlobalMessage($"Your current vanilla xp is <color=#00ff00ff>{localPlayerXP} EXP</color>.");
			return 2;
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		public class EnemyKillBonus
		{
			public int experience = 0;

			public string name = "";

			public EnemyKillBonus(string enemyName, int expGain)
			{
				experience = expGain;
				name = enemyName;
			}
		}

		public static int enemyKillBonus;

		public static int maskedKillCount;

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void KillEnemyPatch(ref EnemyAI __instance)
		{
			EnemyKillBonus enemyKillBonus = null;
			if (__instance is HoarderBugAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Hoarding Bug", 4);
			}
			if (__instance is BaboonBirdAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Baboon Hawk", 10);
			}
			if (__instance is CentipedeAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Snare Flea", 3);
			}
			if (__instance is CrawlerAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Thumper", 6);
			}
			if (__instance is FlowermanAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Bracken", 12);
			}
			if (__instance is MouthDogAI)
			{
				enemyKillBonus = new EnemyKillBonus("an Eyeless Dog", 15);
			}
			if (__instance is NutcrackerEnemyAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Nutcracker", 9);
			}
			if (__instance is SandSpiderAI)
			{
				enemyKillBonus = new EnemyKillBonus("a Bunker Spider", 9);
			}
			if (__instance is MaskedPlayerEnemy)
			{
				enemyKillBonus = new EnemyKillBonus("a Masked", 100);
			}
			if (enemyKillBonus != null)
			{
				EnemyAIPatch.enemyKillBonus += enemyKillBonus.experience;
				if (BetterEXPPlugin.showEnemyKillNotifs.Value)
				{
					Helpers.DisplayGlobalMessage(string.Format("Killed a zombie ! Got 100 points", enemyKillBonus.name, enemyKillBonus.experience));
				}
			}
		}
	}
	internal class Helpers
	{
		public static void DisplayGlobalMessage(string msg)
		{
			HUDManager.Instance.globalNotificationAnimator.SetTrigger("TriggerNotif");
			((TMP_Text)HUDManager.Instance.globalNotificationText).text = msg;
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.globalNotificationSFX);
		}

		public static double Interpolate(double value, double min, double max, bool clamp = true)
		{
			double num = max - min;
			double num2 = value - min;
			if (!clamp)
			{
				return num2;
			}
			return Clamp(num2 / num, 0.0, 1.0);
		}

		public static double Clamp(double value, double min, double max)
		{
			return Math.Min(Math.Max(value, min), max);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("SetSavedValues")]
		[HarmonyPostfix]
		private static void OnHudStart()
		{
			if (!BetterEXPPlugin.hasAssignedInitialRank)
			{
				int localPlayerXP = HUDManager.Instance.localPlayerXP;
				int num = BetterEXPPlugin.AssignInitialRank(localPlayerXP);
				BetterEXPPlugin.logr.LogInfo((object)$"Vanilla XP: {localPlayerXP} -> BetterXP: {num}");
			}
		}
	}
	internal class PauseDisplayPatch
	{
		private static TextMeshProUGUI bxpText;

		private static TextMeshProUGUI rankText;

		private static GameObject displayObject;

		private static GameObject bxpProgress;

		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		[HarmonyPostfix]
		private static void PauseMenuPatch(QuickMenuManager __instance)
		{
			if (__instance.isMenuOpen)
			{
				if (!Object.op_Implicit((Object)(object)displayObject) || !Object.op_Implicit((Object)(object)bxpProgress))
				{
					CreateRankDisplayObject();
				}
				displayObject.SetActive(true);
				bxpProgress.SetActive(true);
			}
		}

		[HarmonyPatch(typeof(QuickMenuManager), "Update")]
		[HarmonyPostfix]
		private static void PauseMenuUpdatePatch(QuickMenuManager __instance)
		{
			if (Object.op_Implicit((Object)(object)displayObject) && Object.op_Implicit((Object)(object)bxpProgress))
			{
				if (!BetterEXPPlugin.showRankInMenu.Value)
				{
					displayObject.SetActive(false);
					bxpProgress.SetActive(false);
					((Component)rankText).gameObject.SetActive(false);
					((Component)bxpText).gameObject.SetActive(false);
					return;
				}
				displayObject.SetActive(__instance.mainButtonsPanel.activeSelf);
				bxpProgress.SetActive(__instance.mainButtonsPanel.activeSelf);
				((Component)rankText).gameObject.SetActive(__instance.mainButtonsPanel.activeSelf);
				((Component)bxpText).gameObject.SetActive(__instance.mainButtonsPanel.activeSelf);
				XPPatch.BetterLevel playerBetterLevel = XPPatch.GetPlayerBetterLevel(XPPatch.betterXp);
				int num = XPPatch.betterXp - playerBetterLevel.xp;
				int num2 = playerBetterLevel.xpEnd - playerBetterLevel.xp;
				((TMP_Text)bxpText).text = $"{XPPatch.betterXp} BXP";
				((TMP_Text)rankText).text = $"{XPPatch.GetPlayerBetterLevel(XPPatch.betterXp).name} <size=70%><color=#ff00ffff>{num}/{num2}</color></size>";
				bxpProgress.GetComponent<Image>().fillAmount = XPPatch.GetRankProgress(XPPatch.betterXp);
				((TMP_Text)bxpText).outlineWidth = 0f;
				((TMP_Text)rankText).outlineWidth = 0f;
				((TMP_Text)rankText).enableWordWrapping = false;
			}
		}

		public static void CreateRankDisplayObject()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu");
			if (!Object.op_Implicit((Object)(object)displayObject))
			{
				displayObject = Object.Instantiate<GameObject>(GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpBox"));
				((Object)displayObject).name = "BXPDisplay";
				displayObject.transform.SetParent(val.transform, false);
				displayObject.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
				displayObject.transform.position = new Vector3(-20.7097f, -60.2553f, 12.2f);
				bxpProgress = Object.Instantiate<GameObject>(GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpMeter"));
				((Object)bxpProgress).name = "BXPBarProgress";
				bxpProgress.transform.SetParent(displayObject.transform, false);
				bxpProgress.transform.localScale = new Vector3(0.597f, 5.21f, 1f);
				bxpProgress.transform.Translate(-0.775f, 0.186f, 0f);
				bxpText = Object.Instantiate<GameObject>(GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/Total")).GetComponent<TextMeshProUGUI>();
				((Object)bxpText).name = "BXPText";
				((TMP_Text)bxpText).alignment = (TextAlignmentOptions)516;
				((TMP_Text)bxpText).transform.SetParent(displayObject.transform, false);
				((TMP_Text)bxpText).transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
				((TMP_Text)bxpText).transform.position = new Vector3(-20.6526f, -60.3364f, 12.4f);
				rankText = Object.Instantiate<GameObject>(GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/Total")).GetComponent<TextMeshProUGUI>();
				((Object)rankText).name = "BXPRankText";
				((TMP_Text)rankText).alignment = (TextAlignmentOptions)513;
				((TMP_Text)rankText).transform.SetParent(displayObject.transform, false);
				((TMP_Text)rankText).transform.localScale = new Vector3(1f, 1f, 1f);
				((TMP_Text)rankText).transform.position = new Vector3(-20.6526f, -60.1911f, 12.4f);
			}
		}
	}
	internal class Saving
	{
		public static string bxpFileLocation = GetSavePathLocation() + "/bxp.txt";

		public static string enemyNotifSettingFile = GetSavePathLocation() + "/bxp_enemy.txt";

		public static string GetSavePathLocation()
		{
			return Application.persistentDataPath + "/swaggies/BetterEXP";
		}

		public static void Save()
		{
			BetterEXPPlugin.logr.LogInfo((object)"Saving data...");
			if (!Directory.Exists(GetSavePathLocation()))
			{
				Directory.CreateDirectory(GetSavePathLocation());
			}
			File.WriteAllText(bxpFileLocation, XPPatch.betterXp.ToString());
		}

		public static int Load()
		{
			BetterEXPPlugin.logr.LogInfo((object)"Attempting to load...");
			if (!Directory.Exists(GetSavePathLocation()))
			{
				return -1;
			}
			if (File.Exists(bxpFileLocation))
			{
				XPPatch.betterXp = int.Parse(File.ReadAllText(bxpFileLocation));
				XPPatch.level = XPPatch.GetPlayerBetterLevelIndex(XPPatch.betterXp);
				BetterEXPPlugin.logr.LogInfo((object)$"Loaded {XPPatch.betterXp} BXP - rank {XPPatch.GetPlayerBetterLevel(XPPatch.betterXp).name}.");
			}
			return 1;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		public class NotesComparer
		{
			public int id = 0;

			public float stat = 0f;
		}

		[HarmonyPatch("WritePlayerNotes")]
		[HarmonyPrefix]
		private static bool NotesOverride()
		{
			EndOfGameStats gameStats = StartOfRound.Instance.gameStats;
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			PlayerStats[] allPlayerStats = gameStats.allPlayerStats;
			for (int i = 0; i < gameStats.allPlayerStats.Length; i++)
			{
				StartOfRound.Instance.gameStats.allPlayerStats[i].isActivePlayer = StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame || StartOfRound.Instance.allPlayerScripts[i].isPlayerDead || StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled;
			}
			NotesComparer notesComparer = new NotesComparer();
			NotesComparer notesComparer2 = new NotesComparer();
			NotesComparer notesComparer3 = new NotesComparer();
			NotesComparer notesComparer4 = new NotesComparer();
			NotesComparer notesComparer5 = new NotesComparer();
			NotesComparer notesComparer6 = new NotesComparer();
			for (int j = 0; j < allPlayerStats.Length; j++)
			{
				PlayerStats val = allPlayerStats[j];
				if (!val.isActivePlayer)
				{
					continue;
				}
				if (j == 0)
				{
					notesComparer.stat = val.stepsTaken;
					notesComparer2.stat = val.stepsTaken;
					notesComparer3.stat = val.turnAmount;
					notesComparer4.stat = val.damageTaken;
					notesComparer5.stat = val.profitable;
					notesComparer6.stat = val.profitable;
					continue;
				}
				if ((float)val.stepsTaken < notesComparer.stat)
				{
					notesComparer.stat = val.stepsTaken;
					notesComparer.id = j;
				}
				if ((float)val.stepsTaken > notesComparer2.stat)
				{
					notesComparer2.stat = val.stepsTaken;
					notesComparer2.id = j;
				}
				if ((float)val.turnAmount > notesComparer3.stat)
				{
					notesComparer3.stat = val.turnAmount;
					notesComparer3.id = j;
				}
				if ((float)val.damageTaken > notesComparer4.stat)
				{
					notesComparer4.stat = val.damageTaken;
					notesComparer4.id = j;
				}
				if ((float)val.profitable > notesComparer5.stat)
				{
					notesComparer5.stat = val.profitable;
					notesComparer5.id = j;
				}
				if ((float)val.profitable < notesComparer6.stat)
				{
					notesComparer6.stat = val.profitable;
					notesComparer6.id = j;
				}
			}
			bool flag = connectedPlayersAmount > 0;
			for (int k = 0; k < allPlayerStats.Length; k++)
			{
				PlayerStats val2 = allPlayerStats[k];
				if (val2.isActivePlayer)
				{
					if (notesComparer5.id == k && notesComparer5.stat > 0f)
					{
						AddNote(k, "Most Profitable", $"${(int)notesComparer5.stat}");
					}
					if (notesComparer2.id == k && notesComparer2.stat > 0f)
					{
						AddNote(k, "Most Active", $"{(int)notesComparer2.stat} steps");
					}
					if (notesComparer4.id == k && notesComparer4.stat > 0f)
					{
						AddNote(k, "Most Injured", $"{(int)notesComparer4.stat} damage");
					}
					if (notesComparer3.id == k && notesComparer3.stat > 0f && flag)
					{
						AddNote(k, "Most Paranoid", $"{notesComparer3.stat} turns");
					}
					if (notesComparer.id == k && flag)
					{
						AddNote(k, "The Laziest", $"{(int)notesComparer.stat} steps");
					}
					if (notesComparer6.id == k && flag)
					{
						AddNote(k, "Least Profitable", $"${(int)notesComparer6.stat}");
					}
				}
			}
			XPPatch.isMostProfitable = (int)GameNetworkManager.Instance.localPlayerController.playerClientId == notesComparer5.id;
			return false;
		}

		private static void AddNote(int id, string note, string value)
		{
			StartOfRound.Instance.gameStats.allPlayerStats[id].playerNotes.Add(note + " <size=75%><color=#ff96bb>(" + value + ")</color></size>");
		}

		[HarmonyPatch("ResetStats")]
		[HarmonyPrefix]
		private static bool ResetStatsFix()
		{
			for (int i = 0; i < StartOfRound.Instance.gameStats.allPlayerStats.Length; i++)
			{
				StartOfRound.Instance.gameStats.allPlayerStats[i].damageTaken = 0;
				StartOfRound.Instance.gameStats.allPlayerStats[i].jumps = 0;
				StartOfRound.Instance.gameStats.allPlayerStats[i].stepsTaken = 0;
				StartOfRound.Instance.gameStats.allPlayerStats[i].profitable = 0;
				StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount = 0;
				StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Clear();
			}
			return false;
		}
	}
	internal class VisualEXPPatch
	{
		private static float expGainAmountAtATime;

		private static int _expGain;

		private static int _deadReduction;

		private static int _scrapBonus;

		private static int _scrapCollected;

		private static int _profitable;

		private static int _enemyBonus;

		private static int _weather;

		private static bool _hadWeather;

		[HarmonyPatch(typeof(HUDManager), "SetPlayerLevelSmoothly")]
		[HarmonyPrefix]
		private static bool SetPlayerLevelSmoothlyPatch(ref int XPGain)
		{
			if (XPGain < 0)
			{
				HUDManager.Instance.LevellingAudio.clip = HUDManager.Instance.decreaseXPSFX;
			}
			else
			{
				HUDManager.Instance.LevellingAudio.clip = HUDManager.Instance.increaseXPSFX;
			}
			HUDManager.Instance.LevellingAudio.Play();
			StartEXPProcess(Time.realtimeSinceStartup, XPGain, XPPatch.betterXp, XPPatch.level, Mathf.Max(XPPatch.betterXp + XPGain, 0), conditionMet: false);
			return false;
		}

		public static void StartEXPProcess(float timeAtStart, int XPGain, float changingPlayerXP, int changingPlayerLevel, int targetXPLevel, bool conditionMet)
		{
			expGainAmountAtATime = ((XPGain < 0) ? Math.Abs((float)XPGain / 18f) : Math.Abs((float)XPGain / 40f));
			EXPProcess(timeAtStart, XPGain, changingPlayerXP, changingPlayerLevel, targetXPLevel, conditionMet);
		}

		public static void EXPProcess(float timeAtStart, int XPGain, float changingPlayerXP, int changingPlayerLevel, int targetXPLevel, bool conditionMet)
		{
			if (targetXPLevel < 0)
			{
				targetXPLevel = 0;
			}
			if (targetXPLevel > 99999)
			{
				targetXPLevel = 99999;
			}
			if (conditionMet || Time.realtimeSinceStartup - timeAtStart > 3f)
			{
				FinishEXPProcess(targetXPLevel);
				return;
			}
			if (XPGain < 0)
			{
				changingPlayerXP -= expGainAmountAtATime;
				if (changingPlayerXP < 0f)
				{
					changingPlayerXP = 0f;
				}
				if (changingPlayerXP <= (float)targetXPLevel)
				{
					conditionMet = true;
					changingPlayerXP = targetXPLevel;
				}
				if (changingPlayerLevel - 1 >= 0 && changingPlayerXP < (float)XPPatch.betterLevels[changingPlayerLevel].xp)
				{
					changingPlayerLevel--;
					HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.levelDecreaseSFX);
					HUDManager.Instance.playerLevelBoxAnimator.SetTrigger("Shake");
				}
			}
			else
			{
				changingPlayerXP += expGainAmountAtATime;
				if (changingPlayerXP >= (float)targetXPLevel)
				{
					conditionMet = true;
					changingPlayerXP = targetXPLevel;
				}
				if (changingPlayerLevel + 1 < XPPatch.betterLevels.Length && changingPlayerXP >= (float)XPPatch.betterLevels[changingPlayerLevel].xpEnd)
				{
					changingPlayerLevel++;
					HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.levelIncreaseSFX);
					HUDManager.Instance.playerLevelBoxAnimator.SetTrigger("Shake");
				}
			}
			HUDManager.Instance.playerLevelMeter.fillAmount = (changingPlayerXP - (float)XPPatch.betterLevels[changingPlayerLevel].xp) / (float)(XPPatch.betterLevels[changingPlayerLevel].xpEnd - XPPatch.betterLevels[changingPlayerLevel].xp);
			((TMP_Text)HUDManager.Instance.playerLevelText).text = XPPatch.betterLevels[changingPlayerLevel].name;
			((TMP_Text)HUDManager.Instance.playerLevelXPCounter).text = $"{Mathf.RoundToInt(changingPlayerXP)} BXP";
			Task.Delay(50).ContinueWith(delegate
			{
				EXPProcess(timeAtStart, XPGain, changingPlayerXP, changingPlayerLevel, targetXPLevel, conditionMet);
			});
		}

		public static void FinishEXPProcess(int targetXPLevel)
		{
			HUDManager.Instance.LevellingAudio.Stop();
			XPPatch.betterXp = targetXPLevel;
			XPPatch.level = XPPatch.GetPlayerBetterLevelIndex(targetXPLevel);
			((TMP_Text)HUDManager.Instance.playerLevelText).text = XPPatch.betterLevels[XPPatch.level].name;
			((TMP_Text)HUDManager.Instance.playerLevelXPCounter).text = $"{Mathf.RoundToInt((float)XPPatch.betterXp)} BXP";
			HUDManager.Instance.SyncPlayerLevelServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId, HUDManager.Instance.localPlayerLevel, false);
			Saving.Save();
		}

		private static void HandleOldLevelling(bool isDead, bool mostProfitable, bool allPlayersDead)
		{
			int num = (isDead ? (-3) : 10);
			if (mostProfitable)
			{
				num += 15;
			}
			if (allPlayersDead)
			{
				num -= 5;
			}
			if (num > 0)
			{
				float num2 = (float)RoundManager.Instance.scrapCollectedInLevel / RoundManager.Instance.totalScrapValueInLevel;
				num = (int)((float)num * num2);
			}
			HUDManager instance = HUDManager.Instance;
			instance.localPlayerXP += num;
			int localPlayerLevel = 0;
			for (int i = 0; i < HUDManager.Instance.playerLevels.Length; i++)
			{
				if (i == HUDManager.Instance.playerLevels.Length - 1)
				{
					localPlayerLevel = i;
					break;
				}
				if (HUDManager.Instance.localPlayerXP >= HUDManager.Instance.playerLevels[i].XPMin && HUDManager.Instance.localPlayerXP < HUDManager.Instance.playerLevels[i].XPMax)
				{
					localPlayerLevel = i;
					break;
				}
			}
			HUDManager.Instance.localPlayerLevel = localPlayerLevel;
		}

		[HarmonyPatch(typeof(HUDManager), "SetPlayerLevel")]
		[HarmonyPrefix]
		private static bool CancelOGExp(ref bool isDead, ref bool allPlayersDead)
		{
			ReplaceEXP(isDead, allPlayersDead);
			return false;
		}

		private static int GetWeatherModifier()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected I4, but got Unknown
			LevelWeatherType currentWeather = WeatherPatch.currentWeather;
			LevelWeatherType val = currentWeather;
			return (val - -1) switch
			{
				0 => 0, 
				2 => 4, 
				4 => 8, 
				5 => 15, 
				3 => 25, 
				6 => 25, 
				_ => 0, 
			};
		}

		public static void ReplaceEXP(bool isDead, bool allPlayersDead, int force = 0)
		{
			int betterXp = XPPatch.betterXp;
			bool isMostProfitable = XPPatch.isMostProfitable;
			int num = 0;
			if (isDead)
			{
				num += 15 + betterXp / 240;
			}
			if (allPlayersDead)
			{
				num = (int)((double)num * 1.5);
			}
			if (num > 99)
			{
				num = 99;
			}
			int num2 = RoundManager.Instance.scrapCollectedInLevel;
			if (num2 > 1500)
			{
				num2 = 1500;
			}
			double num3 = 0.0;
			num3 += Helpers.Interpolate(num2, 0.0, 100.0) * 5.0;
			num3 += Helpers.Interpolate(num2, 100.0, 400.0) * 30.0;
			num3 += Helpers.Interpolate(num2, 400.0, 700.0) * 15.0;
			num3 += Helpers.Interpolate(num2, 700.0, 1000.0) * 10.0;
			num3 += Helpers.Interpolate(num2, 1000.0, 1500.0) * 15.0;
			int num4 = (int)Math.Ceiling(num3);
			int num5 = 0;
			if (isMostProfitable)
			{
				num5 = (int)((double)num4 * 0.25);
			}
			if (num4 + num5 > 99)
			{
				num5 = 100 - num4;
			}
			if (allPlayersDead)
			{
				num4 = (int)((double)num4 * 0.5);
				num5 = 0;
			}
			int num6 = EnemyAIPatch.enemyKillBonus;
			if (isDead)
			{
				num6 = (int)((double)num6 * 0.25);
			}
			float num7 = (float)GetWeatherModifier() / 100f;
			int num8 = 0;
			if (num7 != 0f)
			{
				num8 -= (int)((float)num * num7);
				num8 += (int)((float)num4 * num7);
			}
			HandleOldLevelling(isDead, isMostProfitable, allPlayersDead);
			int XPGain = -num + (num4 + num5) + num6 + num8;
			if (force != 0)
			{
				XPGain = force;
				SetExpGains(XPGain, 0, 0, 0, force, 0, 0, hadWeather: false);
			}
			else
			{
				EnemyAIPatch.enemyKillBonus = 0;
				SetExpGains(XPGain, num, num4, num2, num5, num6, num8, num7 != 0f);
			}
			if (XPGain == 0)
			{
				HUDManager.Instance.playerLevelMeter.fillAmount = ((float)betterXp - (float)XPPatch.betterLevels[XPPatch.level].xp) / (float)(XPPatch.betterLevels[XPPatch.level].xpEnd - XPPatch.betterLevels[XPPatch.level].xp);
				((TMP_Text)HUDManager.Instance.playerLevelXPCounter).text = $"{XPPatch.betterXp} BXP";
				((TMP_Text)HUDManager.Instance.playerLevelText).text = XPPatch.betterLevels[XPPatch.level].name;
				Saving.Save();
			}
			else
			{
				SetPlayerLevelSmoothlyPatch(ref XPGain);
			}
		}

		private static void SetExpGains(int expGain, int deadReduction, int scrapBonus, int scrapCollected, int profitable, int enemyBonus, int weatherBonus, bool hadWeather)
		{
			_expGain = expGain;
			_deadReduction = deadReduction;
			_scrapBonus = scrapBonus;
			_scrapCollected = scrapCollected;
			_profitable = profitable;
			_enemyBonus = enemyBonus;
			_weather = weatherBonus;
			_hadWeather = hadWeather;
		}

		[HarmonyPatch(typeof(StartOfRound), "PassTimeToNextDay")]
		[HarmonyPostfix]
		private static void BeginShowExpGains()
		{
			Saving.Save();
			if (StartOfRound.Instance.currentLevel.planetHasTime)
			{
				Task.Delay(1700).ContinueWith(delegate
				{
					ShowExpGains();
				});
			}
		}

		public static void ShowExpGains()
		{
			if (BetterEXPPlugin.showRoundSummary.Value)
			{
				string text = "#000096ff";
				string text2 = "#424242ff";
				string text3 = "#ff00ffff";
				string text4 = "#6900ffff";
				string arg = ((_expGain > 0) ? text4 : ((_expGain == 0) ? text2 : text));
				string text5 = $"Round Experience: <color={arg}>{_expGain} BXP</color>";
				string arg2 = ((_deadReduction == 0) ? text2 : text);
				string text6 = $"Death Penalty: <color={arg2}>-{_deadReduction} BXP</color>\n";
				string arg3 = ((_scrapCollected == 0) ? text2 : text4);
				string text7 = $"<size=65%>(MVP BONUS: {_profitable})</size>";
				string text8 = $"Scrap (${_scrapCollected}): <color={arg3}>{_scrapBonus} BXP</color>";
				string text9 = text8 + ((_profitable > 0) ? (" " + text7) : "") + "\n";
				string text10 = $"Enemy Kill Bonus: <color={text3}>{_enemyBonus} BXP</color>\n";
				string text11 = ((_enemyBonus > 0) ? text10 : "") ?? "";
				string arg4 = ((_weather > 0) ? text3 : ((_weather == 0) ? text2 : text));
				string text12 = $"Weather Bonus: <color={arg4}>{_weather} BXP</color>";
				string text13 = (_hadWeather ? text12 : "");
				HUDManager.Instance.DisplayTip(text5, "<size=90%>" + text6 + text9 + text11 + text13 + "</size>", false, false, "LC_Tip1");
			}
		}
	}
	internal class WeatherPatch
	{
		public static LevelWeatherType currentWeather = (LevelWeatherType)(-1);

		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void SetWeatherType()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			currentWeather = TimeOfDay.Instance.currentLevelWeather;
			BetterEXPPlugin.logr.LogInfo((object)$"current weather = {currentWeather}");
		}
	}
	internal class XPPatch : MonoBehaviour
	{
		public class BetterLevel
		{
			public string name;

			public int xp;

			public int xpEnd;

			public BetterLevel(string levelName, int startXp, int endXp)
			{
				name = levelName;
				xp = startXp;
				xpEnd = endXp;
			}
		}

		public static int level = -1;

		public static int betterXp = 0;

		public static bool isMostProfitable = false;

		public static BetterLevel[] betterLevels = new BetterLevel[31]
		{
			new BetterLevel("Intern", 0, 25),
			new BetterLevel("Trainee", 25, 50),
			new BetterLevel("Part-Timer", 50, 100),
			new BetterLevel("Full-Timer", 100, 200),
			new BetterLevel("Leader", 200, 300),
			new BetterLevel("Manager", 300, 400),
			new BetterLevel("Sr. Manager", 400, 500),
			new BetterLevel("3rd Boss", 500, 800),
			new BetterLevel("2nd Boss", 800, 1100),
			new BetterLevel("1st Boss", 1100, 1500),
			new BetterLevel("3rd Vice President", 1500, 2000),
			new BetterLevel("2nd Vice President", 2000, 2500),
			new BetterLevel("1st Vice President", 2500, 3000),
			new BetterLevel("3rd Executive V.P.", 3000, 3600),
			new BetterLevel("2nd Executive V.P.", 3600, 4200),
			new BetterLevel("1st Executive V.P.", 4200, 5000),
			new BetterLevel("Deputy President", 5000, 6000),
			new BetterLevel("President", 6000, 7000),
			new BetterLevel("Vice Chairman", 7000, 8000),
			new BetterLevel("Chairman", 8000, 9000),
			new BetterLevel("Co-Founder", 9000, 9999),
			new BetterLevel("The Company", 9999, 20000),
			new BetterLevel("The Company II", 20000, 30000),
			new BetterLevel("The Company III", 30000, 40000),
			new BetterLevel("The Company IV", 40000, 50000),
			new BetterLevel("The Company V", 50000, 60000),
			new BetterLevel("The Company VI", 60000, 70000),
			new BetterLevel("The Company VII", 70000, 80000),
			new BetterLevel("The Company VIII", 80000, 90000),
			new BetterLevel("The Company IX", 90000, 99999),
			new BetterLevel("The Company X", 99999, int.MaxValue)
		};

		public static int GetPlayerBetterLevelIndex(int bxp)
		{
			for (int i = 0; i < betterLevels.Length; i++)
			{
				if (bxp < betterLevels[i].xpEnd)
				{
					return i;
				}
			}
			return betterLevels.Length - 1;
		}

		public static BetterLevel GetPlayerBetterLevel(int bxp)
		{
			int playerBetterLevelIndex = GetPlayerBetterLevelIndex(bxp);
			return betterLevels[playerBetterLevelIndex];
		}

		public static float GetRankProgress(int bxp)
		{
			BetterLevel playerBetterLevel = GetPlayerBetterLevel(bxp);
			float num = bxp - playerBetterLevel.xp;
			float num2 = playerBetterLevel.xpEnd - playerBetterLevel.xp;
			return num / num2;
		}
	}
}