Decompiled source of LethalStats FR v1.2.0

OrianaGames-Stats/LethalProgression.dll

Decompiled 6 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using LethalProgression.Config;
using LethalProgression.GUI;
using LethalProgression.Network;
using LethalProgression.Patches;
using LethalProgression.Properties;
using LethalProgression.Saving;
using LethalProgression.Skills;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Steamworks;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalProgression")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lethal Progression FR Version Orianagames")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0")]
[assembly: AssemblyProduct("LethalProgression")]
[assembly: AssemblyTitle("LethalProgression")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalProgression
{
	[HarmonyPatch]
	internal class LP_NetworkManager
	{
		public static LC_XP xpInstance;

		public static GameObject xpNetworkObject;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!((Object)(object)xpNetworkObject != (Object)null))
			{
				xpNetworkObject = (GameObject)LethalPlugin.skillBundle.LoadAsset("LP_XPHandler");
				xpNetworkObject.AddComponent<LC_XP>();
				NetworkManager.Singleton.AddNetworkPrefab(xpNetworkObject);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0024: 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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(xpNetworkObject, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				xpInstance = val.GetComponent<LC_XP>();
				LethalPlugin.Log.LogInfo((object)"XPHandler Initialized.");
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("OrianaGames.LethalStats", "LethalStats", "1.1.1")]
	internal class LethalPlugin : BaseUnityPlugin
	{
		private const string modGUID = "OrianaGames.LethalStats";

		private const string modName = "LethalStats";

		private const string modVersion = "1.2.0";

		private const string modAuthor = "Lunastellia";

		public static AssetBundle skillBundle;

		internal static ManualLogSource Log;

		internal static bool ReservedSlots;

		internal static bool MikesTweaks;

		public static LethalPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Instance = this;
			Harmony val = new Harmony("OrianaGames.LethalStats");
			val.PatchAll();
			skillBundle = AssetBundle.LoadFromMemory(Resources.skillmenu);
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"LethalStats loaded.");
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				if (pluginInfo.Value.Metadata.GUID.IndexOf("ReservedItem") >= 0)
				{
					ReservedSlots = true;
				}
				if (pluginInfo.Value.Metadata.GUID.IndexOf("mikestweaks") < 0)
				{
					continue;
				}
				ConfigEntryBase[] configEntries = pluginInfo.Value.Instance.Config.GetConfigEntries();
				MikesTweaks = true;
				ConfigEntryBase[] array = configEntries;
				foreach (ConfigEntryBase val2 in array)
				{
					if (val2.Definition.Key == "ExtraItemSlots" && int.Parse(val2.GetSerializedValue()) > 0)
					{
						ReservedSlots = true;
					}
				}
			}
			SkillConfig.InitConfig();
		}

		public void BindConfig<T>(string section, string key, T defaultValue, string description = "")
		{
			((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}

		public IDictionary<string, string> GetAllConfigEntries()
		{
			return ((BaseUnityPlugin)this).Config.GetConfigEntries().ToDictionary((ConfigEntryBase entry) => entry.Definition.Key, (ConfigEntryBase entry) => entry.GetSerializedValue());
		}
	}
	internal class LC_XP : NetworkBehaviour
	{
		public LethalNetworkVariable<int> teamLevel = new LethalNetworkVariable<int>("teamLevel")
		{
			Value = 0
		};

		public LethalNetworkVariable<int> teamXP = new LethalNetworkVariable<int>("teamXP")
		{
			Value = 0
		};

		public LethalNetworkVariable<int> teamTotalValue = new LethalNetworkVariable<int>("teamTotalValue")
		{
			Value = 0
		};

		public LethalNetworkVariable<int> teamXPRequired = new LethalNetworkVariable<int>("teamXPRequired")
		{
			Value = 0
		};

		public LethalNetworkVariable<int> teamLootLevel = new LethalNetworkVariable<int>("teamLootLevel")
		{
			Value = 0
		};

		public LethalClientEvent playerConnectClientEvent = new LethalClientEvent("playerConnectEvent", (Action)null, (Action<ulong>)null);

		public LethalServerEvent playerConnectServerEvent = new LethalServerEvent("playerConnectEvent", (Action<ulong>)null);

		public LethalClientEvent evaluateXPRequirementClientEvent = new LethalClientEvent("evaluateXPRequirementEvent", (Action)null, (Action<ulong>)null);

		public LethalServerEvent evaluateXPRequirementServerEvent = new LethalServerEvent("evaluateXPRequirementEvent", (Action<ulong>)null);

		public LethalClientEvent calculateAllPlayersHandSlotsClientEvent = new LethalClientEvent("calculateAllPlayersHandSlotsEvent", (Action)null, (Action<ulong>)null);

		public LethalServerEvent calculateAllPlayersHandSlotsServerEvent = new LethalServerEvent("calculateAllPlayersHandSlotsEvent", (Action<ulong>)null);

		public LethalServerMessage<string> sendConfigServerMessage = new LethalServerMessage<string>("sendConfigMessage", (Action<string, ulong>)null);

		public LethalClientMessage<string> sendConfigClientMessage = new LethalClientMessage<string>("sendConfigMessage", (Action<string>)null, (Action<string, ulong>)null);

		public LethalServerMessage<ulong> requestProfileDataServerMessage = new LethalServerMessage<ulong>("requestProfileDataMessage", (Action<ulong, ulong>)null);

		public LethalClientMessage<ulong> requestProfileDataClientMessage = new LethalClientMessage<ulong>("requestProfileDataMessage", (Action<ulong>)null, (Action<ulong, ulong>)null);

		public LethalServerMessage<string> sendProfileDataServerMessage = new LethalServerMessage<string>("sendProfileDataMessage", (Action<string, ulong>)null);

		public LethalClientMessage<string> receiveProfileDataClientMessage = new LethalClientMessage<string>("sendProfileDataMessage", (Action<string>)null, (Action<string, ulong>)null);

		public LethalServerMessage<string> saveProfileDataServerMessage = new LethalServerMessage<string>("saveProfileDataMessage", (Action<string, ulong>)null);

		public LethalClientMessage<string> saveProfileDataClientMessage = new LethalClientMessage<string>("saveProfileDataMessage", (Action<string>)null, (Action<string, ulong>)null);

		public LethalServerMessage<int> updateTeamLootLevelServerMessage = new LethalServerMessage<int>("updateTeamLootLevelMessage", (Action<int, ulong>)null);

		public LethalClientMessage<int> updateTeamLootLevelClientMessage = new LethalClientMessage<int>("updateTeamLootLevelMessage", (Action<int>)null, (Action<int, ulong>)null);

		public LethalServerMessage<int> updateTeamXPServerMessage = new LethalServerMessage<int>("updateTeamXPMessage", (Action<int, ulong>)null);

		public LethalClientMessage<int> updateTeamXPClientMessage = new LethalClientMessage<int>("updateTeamXPMessage", (Action<int>)null, (Action<int, ulong>)null);

		public LethalServerMessage<int> updatePlayerSkillpointsServerMessage = new LethalServerMessage<int>("updatePlayerSkillPointsMessage", (Action<int, ulong>)null);

		public LethalClientMessage<int> updatePlayerSkillpointsClientMessage = new LethalClientMessage<int>("updatePlayerSkillPointsMessage", (Action<int>)null, (Action<int, ulong>)null);

		public LethalServerMessage<int> updateSPHandSlotsServerMessage = new LethalServerMessage<int>("updateSPHandSlotsMessage", (Action<int, ulong>)null);

		public LethalClientMessage<int> updateSPHandSlotsClientMessage = new LethalClientMessage<int>("updateSPHandSlotsMessage", (Action<int>)null, (Action<int, ulong>)null);

		public LethalServerMessage<PlayerHandSlotData> updatePlayerHandSlotsServerMessage = new LethalServerMessage<PlayerHandSlotData>("updatePlayerHandSlotsMessage", (Action<PlayerHandSlotData, ulong>)null);

		public LethalClientMessage<PlayerHandSlotData> updatePlayerHandSlotsClientMessage = new LethalClientMessage<PlayerHandSlotData>("updatePlayerHandSlotsMessage", (Action<PlayerHandSlotData>)null, (Action<PlayerHandSlotData, ulong>)null);

		public LethalServerMessage<PlayerJumpHeightData> updatePlayerJumpForceServerMessage = new LethalServerMessage<PlayerJumpHeightData>("updatePlayerJumpForceMessage", (Action<PlayerJumpHeightData, ulong>)null);

		public LethalClientMessage<PlayerJumpHeightData> updatePlayerJumpForceClientMessage = new LethalClientMessage<PlayerJumpHeightData>("updatePlayerJumpForceMessage", (Action<PlayerJumpHeightData>)null, (Action<PlayerJumpHeightData, ulong>)null);

		public int skillPoints;

		public SkillList skillList;

		public SkillsGUI guiObj;

		public bool Initialized = false;

		public bool loadedSave = false;

		public void Start()
		{
			LethalPlugin.Log.LogInfo((object)"XP Network Behavior Made!");
			teamLevel.OnValueChanged += OnTeamLevelChange;
			teamXP.OnValueChanged += OnTeamXPChange;
			playerConnectServerEvent.OnReceived += PlayerConnect_C2SEvent;
			evaluateXPRequirementServerEvent.OnReceived += EvaluateXPRequirements_C2SEvent;
			calculateAllPlayersHandSlotsServerEvent.OnReceived += RefreshAllPlayerHandSlots_C2SEvent;
			requestProfileDataServerMessage.OnReceived += RequestSavedData_C2SMessage;
			saveProfileDataServerMessage.OnReceived += SaveProfileData_C2SMessage;
			updateTeamLootLevelServerMessage.OnReceived += UpdateTeamLootLevel_C2SMessage;
			updateTeamXPServerMessage.OnReceived += UpdateTeamXP_C2SMessage;
			updateSPHandSlotsServerMessage.OnReceived += UpdateSPHandSlots_C2SMessage;
			updatePlayerJumpForceServerMessage.OnReceived += UpdatePlayerJumpHeight_C2SMessage;
			sendConfigClientMessage.OnReceived += SendHostConfig_S2CMessage;
			receiveProfileDataClientMessage.OnReceived += LoadProfileData_S2CMessage;
			updatePlayerSkillpointsClientMessage.OnReceived += UpdateSkillPoints_S2CMessage;
			updatePlayerHandSlotsClientMessage.OnReceived += UpdatePlayerHandSlots_S2CMessage;
			updatePlayerJumpForceClientMessage.OnReceived += UpdatePlayerJumpHeight_S2CMessage;
			playerConnectClientEvent.InvokeServer();
		}

		public override void OnDestroy()
		{
			teamLevel.OnValueChanged -= OnTeamLevelChange;
			teamXP.OnValueChanged -= OnTeamXPChange;
			teamLootLevel.OnValueChanged -= guiObj.TeamLootHudUpdate;
			playerConnectServerEvent.OnReceived -= PlayerConnect_C2SEvent;
			evaluateXPRequirementServerEvent.OnReceived -= EvaluateXPRequirements_C2SEvent;
			calculateAllPlayersHandSlotsServerEvent.OnReceived -= RefreshAllPlayerHandSlots_C2SEvent;
			requestProfileDataServerMessage.OnReceived -= RequestSavedData_C2SMessage;
			saveProfileDataServerMessage.OnReceived -= SaveProfileData_C2SMessage;
			updateTeamLootLevelServerMessage.OnReceived -= UpdateTeamLootLevel_C2SMessage;
			updateTeamXPServerMessage.OnReceived -= UpdateTeamXP_C2SMessage;
			updateSPHandSlotsServerMessage.OnReceived -= UpdateSPHandSlots_C2SMessage;
			sendConfigClientMessage.OnReceived -= SendHostConfig_S2CMessage;
			receiveProfileDataClientMessage.OnReceived -= LoadProfileData_S2CMessage;
			updatePlayerSkillpointsClientMessage.OnReceived -= UpdateSkillPoints_S2CMessage;
			updatePlayerHandSlotsClientMessage.OnReceived -= UpdatePlayerHandSlots_S2CMessage;
			((NetworkBehaviour)this).OnDestroy();
		}

		private void OnTeamLevelChange(int newLevel)
		{
			((MonoBehaviour)this).StartCoroutine(WaitUntilInitialisedThenAction(HUDManagerPatch.ShowLevelUp));
		}

		private void OnTeamXPChange(int newXP)
		{
			((MonoBehaviour)this).StartCoroutine(WaitUntilInitialisedThenAction(HUDManagerPatch.ShowXPUpdate));
		}

		public IEnumerator WaitUntilInitialisedThenAction(Action callback)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => Initialized));
			callback();
		}

		public void PlayerConnect_C2SEvent(ulong clientId)
		{
			LethalPlugin.Log.LogInfo((object)$"Connexion reçue par : {clientId}");
			IDictionary<string, string> allConfigEntries = LethalPlugin.Instance.GetAllConfigEntries();
			string text = JsonConvert.SerializeObject((object)allConfigEntries);
			LethalPlugin.Log.LogInfo((object)("Sauvegarde des configs -> " + text));
			sendConfigServerMessage.SendAllClients(text, true);
		}

		public void LoadSharedData()
		{
			SaveSharedData saveSharedData = SaveManager.LoadSharedFile();
			if (saveSharedData == null)
			{
				LethalPlugin.Log.LogInfo((object)"données partagé innexistante");
				return;
			}
			LethalPlugin.Log.LogInfo((object)"Chargement du lobby, partage des données en cour");
			teamXP.Value = saveSharedData.xp;
			teamLevel.Value = saveSharedData.level;
			teamTotalValue.Value = saveSharedData.quota;
			teamXPRequired.Value = CalculateXPRequirement();
			LethalPlugin.Log.LogInfo((object)$"{saveSharedData.level} niveau actuel, {saveSharedData.xp} EXP, {saveSharedData.quota} Profit, {teamXPRequired.Value} teamXPRequired");
		}

		public IEnumerator LoadProfileData(string data)
		{
			LethalPlugin.Log.LogInfo((object)("Reception des données du joueur depuis le joueur host -> " + data));
			yield return (object)new WaitUntil((Func<bool>)(() => Initialized));
			if (loadedSave)
			{
				LethalPlugin.Log.LogWarning((object)"Données des joueurs charger par le Host.");
				yield return null;
			}
			loadedSave = true;
			SaveData saveData = JsonConvert.DeserializeObject<SaveData>(data);
			skillPoints = saveData.skillPoints;
			LethalPlugin.Log.LogDebug((object)$"skillPoints -> {skillPoints}");
			int skillCheck = 0;
			foreach (KeyValuePair<UpgradeType, int> skill in saveData.skillAllocation)
			{
				LethalPlugin.Log.LogDebug((object)$"{skill.Key} -> {skill.Value}");
				skillList.skills[skill.Key].SetLevel(skill.Value, triggerHostProfileSave: false);
				skillCheck += skill.Value;
				LethalPlugin.Log.LogDebug((object)$"Skill list -> {skillCheck}");
			}
			if (skillCheck + skillPoints < teamLevel.Value + 5)
			{
				LethalPlugin.Log.LogInfo((object)$"Skill check pour le niveau actuel, Ajout {teamLevel.Value + 5 - (skillCheck + skillPoints)} points.");
				skillPoints += teamLevel.Value + 5 - (skillCheck + skillPoints);
			}
			LP_NetworkManager.xpInstance.guiObj.UpdateAllStats();
		}

		public int CalculateXPRequirement()
		{
			int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount;
			int timesFulfilledQuota = TimeOfDay.Instance.timesFulfilledQuota;
			int num = int.Parse(SkillConfig.hostConfig["EXP Minimum"]);
			int num2 = int.Parse(SkillConfig.hostConfig["EXP Maximum"]);
			int num3 = int.Parse(SkillConfig.hostConfig["EXP par Joueur"]);
			int num4 = connectedPlayersAmount * num3;
			int num5 = num + num4;
			int num6 = int.Parse(SkillConfig.hostConfig["Quota Multiplier"]);
			int num7 = timesFulfilledQuota * num6;
			num5 += (int)((float)num5 * ((float)num7 / 100f));
			if (num5 > num2)
			{
				num5 = num2;
			}
			LethalPlugin.Log.LogInfo((object)$"{connectedPlayersAmount} joueurs, {timesFulfilledQuota} quotas, {num} cout initial, {num4} valeur par personne additionnel, {num7} valeur du quota additionnel, {num5} cout total.");
			return num5;
		}

		public int GetXP()
		{
			return teamXP.Value;
		}

		public int GetLevel()
		{
			return teamLevel.Value;
		}

		public int GetProfit()
		{
			return teamTotalValue.Value;
		}

		public int GetSkillPoints()
		{
			return skillPoints;
		}

		public void SetSkillPoints(int num)
		{
			skillPoints = num;
		}

		public void EvaluateXPRequirements_C2SEvent(ulong clientId)
		{
			((MonoBehaviour)this).StartCoroutine(XPRequirementCoroutine());
		}

		public IEnumerator XPRequirementCoroutine()
		{
			yield return (object)new WaitForSeconds(0.5f);
			teamXPRequired.Value = CalculateXPRequirement();
		}

		public void UpdateTeamXP_C2SMessage(int xpToAdd, ulong clientId)
		{
			LethalNetworkVariable<int> obj = teamXP;
			obj.Value += xpToAdd;
			LethalNetworkVariable<int> obj2 = teamTotalValue;
			obj2.Value += xpToAdd;
			int num = GetXP();
			if (num >= teamXPRequired.Value)
			{
				int num2 = 0;
				while (num >= teamXPRequired.Value)
				{
					num2++;
					num -= teamXPRequired.Value;
				}
				teamXP.Value = num;
				LethalNetworkVariable<int> obj3 = teamLevel;
				obj3.Value += num2;
				updatePlayerSkillpointsServerMessage.SendAllClients(num2, true);
			}
		}

		public void UpdateSkillPoints_S2CMessage(int pointsToAdd)
		{
			skillPoints += pointsToAdd;
		}

		public void UpdateTeamLootLevel_C2SMessage(int change, ulong clientId)
		{
			int value = teamLootLevel.Value;
			if (value + change < 0)
			{
				teamLootLevel.Value = 0;
			}
			else
			{
				LethalNetworkVariable<int> obj = teamLootLevel;
				obj.Value += change;
			}
			LethalPlugin.Log.LogInfo((object)$"la valeur du taux de loot à changer -> {change} pour un total de {teamLootLevel.Value}.");
		}

		public void UpdateSPHandSlots_C2SMessage(int slotChange, ulong clientId)
		{
			if (!LethalPlugin.ReservedSlots)
			{
				LethalPlugin.Log.LogInfo((object)$"Client > Host(ServerRPC) : Mise à jour du Joueur {clientId} -> {slotChange} slots !");
				PlayerHandSlotData playerHandSlotData = new PlayerHandSlotData(clientId, slotChange);
				LethalPlugin.Log.LogDebug((object)$"Envoie des données à tous les joueurs par le joueur {playerHandSlotData.clientId} -> {playerHandSlotData.additionalSlots} slots !");
				updatePlayerHandSlotsServerMessage.SendAllClients(playerHandSlotData, true);
			}
		}

		public void UpdatePlayerHandSlots_S2CMessage(PlayerHandSlotData data)
		{
			LethalPlugin.Log.LogInfo((object)$"Host(ServerRPC) > Client : Mise à jour reçu par le joueur {data.clientId} -> {data.additionalSlots} slots !");
			if (data.additionalSlots == 0)
			{
				LethalPlugin.Log.LogWarning((object)"Valeur = 0, possible perte d'information, si les valeurs sont différente entre le Client > Host(ServerRPC) et le Host(ServerRPC) > Client. Sinon ignorez ce message.");
			}
			SetHandSlot(data.clientId, data.additionalSlots);
		}

		public void SetHandSlot(ulong playerID, int additionalSlots)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.playerClientId != playerID)
				{
					continue;
				}
				int num = 4 + additionalSlots;
				List<GrabbableObject> list = val.ItemSlots.ToList();
				if (val.currentItemSlot > num - 1)
				{
					HandSlots.SwitchItemSlots(val, num - 1);
				}
				for (int j = 0; j < list.Count; j++)
				{
					if (j > num - 1 && (Object)(object)list[j] != (Object)null)
					{
						HandSlots.SwitchItemSlots(val, j);
						val.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
						LethalPlugin.Log.LogWarning((object)"Le joueur porter un objet et viens de le lâcher !");
					}
				}
				val.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[num];
				for (int k = 0; k < list.Count; k++)
				{
					if (!((Object)(object)list[k] == (Object)null))
					{
						val.ItemSlots[k] = list[k];
					}
				}
				LethalPlugin.Log.LogDebug((object)$"Le joueur {playerID} dispose de {val.ItemSlots.Length} slots après le partage des configs");
				if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					LethalPlugin.Log.LogDebug((object)"Mise à jour de l'interface du joueur.");
					HandSlots.UpdateHudSlots();
				}
				break;
			}
		}

		public void RefreshAllPlayerHandSlots_C2SEvent(ulong clientId)
		{
			if (LethalPlugin.ReservedSlots || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HandSlot))
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (((Component)val).gameObject.activeSelf)
				{
					ulong playerClientId = val.playerClientId;
					int additionalSlots = val.ItemSlots.Length - 4;
					LethalPlugin.Log.LogInfo((object)"Valeurs rafraichis des slots pour l'ensemble des joueurs.");
					updatePlayerHandSlotsServerMessage.SendAllClients(new PlayerHandSlotData(playerClientId, additionalSlots), true);
				}
			}
		}

		public void SendHostConfig_S2CMessage(string serializedConfig)
		{
			IDictionary<string, string> dictionary = JsonConvert.DeserializeObject<IDictionary<string, string>>(serializedConfig);
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				SkillConfig.hostConfig[item.Key] = item.Value;
				LethalPlugin.Log.LogInfo((object)("Chargement des configs : " + item.Key + " = " + item.Value));
			}
			if (!Initialized)
			{
				Initialized = true;
				LP_NetworkManager.xpInstance = this;
				skillList = new SkillList();
				skillList.InitializeSkills();
				if (GameNetworkManager.Instance.isHostingGame)
				{
					LoadSharedData();
				}
				guiObj = new SkillsGUI();
				teamLootLevel.OnValueChanged += guiObj.TeamLootHudUpdate;
				skillPoints = teamLevel.Value + int.Parse(SkillConfig.hostConfig["Point(s) de Statistiques Initial"]);
				calculateAllPlayersHandSlotsClientEvent.InvokeServer();
				evaluateXPRequirementClientEvent.InvokeServer();
			}
		}

		public void RequestSavedData_C2SMessage(ulong steamID, ulong clientId)
		{
			string text = SaveManager.LoadPlayerFile(steamID);
			PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(clientId);
			sendProfileDataServerMessage.SendClient(text, playerController.actualClientId);
		}

		public void LoadProfileData_S2CMessage(string saveData)
		{
			LethalPlugin.Log.LogInfo((object)("Reception des configs : Host(ServerRPC) > Client -> " + saveData));
			if (saveData != null)
			{
				((MonoBehaviour)this).StartCoroutine(LoadProfileData(saveData));
			}
		}

		public void SaveProfileData_C2SMessage(string data, ulong clientId)
		{
			SaveProfileData saveProfileData = JsonConvert.DeserializeObject<SaveProfileData>(data);
			LethalPlugin.Log.LogInfo((object)$"Reception de la requête des données sauvegardé pour {saveProfileData.steamId}, données -> {JsonConvert.SerializeObject((object)saveProfileData.saveData)}");
			SaveManager.Save(saveProfileData.steamId, saveProfileData.saveData);
			SaveManager.SaveShared(teamXP.Value, teamLevel.Value, teamTotalValue.Value);
		}

		public void UpdatePlayerJumpHeight_C2SMessage(PlayerJumpHeightData playerData, ulong clientId)
		{
			LethalPlugin.Log.LogInfo((object)$"requête reçue par {clientId} [{playerData.clientId}] modification de la hauteur du saut {playerData.jumpSkillValue}");
			updatePlayerJumpForceServerMessage.SendAllClients(playerData, true);
		}

		public void UpdatePlayerJumpHeight_S2CMessage(PlayerJumpHeightData playerData)
		{
			PlayerControllerB playerController = LethalNetworkExtensions.GetPlayerController(playerData.clientId);
			Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.JumpHeight];
			float num = (float)playerData.jumpSkillValue * skill.GetMultiplier() / 100f * 13f;
			playerController.jumpForce = 13f + num;
			LethalPlugin.Log.LogInfo((object)$"Mise à jour client {playerData.clientId} hauteur de saut. ajout {num} - {playerController.jumpForce}");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalProgression";

		public const string PLUGIN_NAME = "LethalProgression";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalProgression.GUI
{
	[HarmonyPatch]
	internal class GUIUpdate
	{
		public static bool isMenuOpen;

		public static SkillsGUI guiInstance;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "Update")]
		private static void SkillMenuUpdate(QuickMenuManager __instance)
		{
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: 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)
			if (guiInstance == null || !Object.op_Implicit((Object)(object)guiInstance.mainPanel))
			{
				return;
			}
			if (!isMenuOpen)
			{
				guiInstance.mainPanel.SetActive(false);
			}
			else
			{
				if (!isMenuOpen)
				{
					return;
				}
				if (bool.Parse(SkillConfig.hostConfig["Respé Uniquement dans le vaisseau"]) && !bool.Parse(SkillConfig.hostConfig["Respé désactivé"]))
				{
					if (GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)
					{
						guiInstance.SetUnspec(show: true);
					}
					else
					{
						guiInstance.SetUnspec(show: false);
					}
				}
				if (bool.Parse(SkillConfig.hostConfig["Respé Uniquement en orbit"]))
				{
					if (StartOfRound.Instance.inShipPhase)
					{
						guiInstance.SetUnspec(show: true);
					}
					else
					{
						guiInstance.SetUnspec(show: false);
					}
				}
				if (bool.Parse(SkillConfig.hostConfig["Respé désactivé"]))
				{
					guiInstance.SetUnspec(show: false);
				}
				Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
				GameObject gameObject = ((Component)guiInstance.mainPanel.transform.GetChild(2)).gameObject;
				float x = gameObject.transform.position.x;
				Rect rect = gameObject.GetComponent<RectTransform>().rect;
				float num = x - ((Rect)(ref rect)).width;
				float x2 = gameObject.transform.position.x;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num2 = x2 + ((Rect)(ref rect)).width;
				float y = gameObject.transform.position.y;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num3 = y - ((Rect)(ref rect)).height;
				float y2 = gameObject.transform.position.y;
				rect = gameObject.GetComponent<RectTransform>().rect;
				float num4 = y2 + ((Rect)(ref rect)).height;
				if (val.x >= num && val.x <= num2)
				{
					if (val.y >= num3 && val.y <= num4)
					{
						((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(true);
					}
					else
					{
						((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(false);
					}
				}
				else
				{
					((Component)guiInstance.mainPanel.transform.GetChild(2).GetChild(2)).gameObject.SetActive(false);
				}
				guiInstance.mainPanel.SetActive(true);
				GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
				val2.SetActive(false);
				GameObject val3 = GameObject.Find("Systems/UI/Canvas/QuickMenu/PlayerList");
				val3.SetActive(false);
				RealTimeUpdateInfo();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		private static void SkillMenuClose(QuickMenuManager __instance)
		{
			isMenuOpen = false;
		}

		private static void RealTimeUpdateInfo()
		{
			GameObject gameObject = ((Component)guiInstance.mainPanel.transform.GetChild(2)).gameObject;
			gameObject = ((Component)gameObject.transform.GetChild(1)).gameObject;
			TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = LP_NetworkManager.xpInstance.GetSkillPoints().ToString();
		}
	}
	internal class SkillsGUI
	{
		public GameObject mainPanel;

		public GameObject infoPanel;

		public Skill activeSkill;

		public GameObject templateSlot;

		public List<GameObject> skillButtonsList = new List<GameObject>();

		public int shownSkills = 0;

		public SkillsGUI()
		{
			CreateSkillMenu();
			GUIUpdate.guiInstance = this;
		}

		public void OpenSkillMenu()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GUIUpdate.isMenuOpen = true;
			mainPanel.SetActive(true);
			if (Object.op_Implicit((Object)(object)GameObject.Find("SkillMenu/Scroll/SkillContents")))
			{
				GameObject.Find("SkillMenu/Scroll/SkillContents").gameObject.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
			}
		}

		public void CreateSkillMenu()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			mainPanel = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("SkillMenu"));
			((Object)mainPanel).name = "SkillMenu";
			mainPanel.SetActive(false);
			templateSlot = Object.Instantiate<GameObject>(GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3"));
			((Object)templateSlot).name = "TemplateSlot";
			templateSlot.SetActive(false);
			infoPanel = ((Component)mainPanel.transform.GetChild(1)).gameObject;
			infoPanel.SetActive(false);
			GameObject gameObject = ((Component)mainPanel.transform.GetChild(4)).gameObject;
			gameObject.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(BackButton));
			shownSkills = 0;
			if (LP_NetworkManager.xpInstance.skillList.skills == null)
			{
				return;
			}
			foreach (KeyValuePair<UpgradeType, Skill> skill in LP_NetworkManager.xpInstance.skillList.skills)
			{
				LethalPlugin.Log.LogInfo((object)("Creating button for " + skill.Value.GetShortName()));
				GameObject val = SetupUpgradeButton(skill.Value);
				LethalPlugin.Log.LogInfo((object)"Setup passed!");
				skillButtonsList.Add(val);
				LethalPlugin.Log.LogInfo((object)"Added to skill list..");
				LoadSkillData(skill.Value, val);
			}
			TeamLootHudUpdate(0);
		}

		public void BackButton()
		{
			GUIUpdate.isMenuOpen = false;
			GameObject val = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
			val.SetActive(true);
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/PlayerList");
			val2.SetActive(true);
		}

		public void SetUnspec(bool show)
		{
			GameObject gameObject = ((Component)infoPanel.transform.GetChild(6)).gameObject;
			GameObject gameObject2 = ((Component)infoPanel.transform.GetChild(7)).gameObject;
			GameObject gameObject3 = ((Component)infoPanel.transform.GetChild(8)).gameObject;
			gameObject.SetActive(show);
			gameObject2.SetActive(show);
			gameObject3.SetActive(show);
			if (!bool.Parse(SkillConfig.hostConfig["Respé désactivé"]))
			{
				GameObject gameObject4 = ((Component)infoPanel.transform.GetChild(9)).gameObject;
				gameObject4.SetActive(!show);
			}
			if (bool.Parse(SkillConfig.hostConfig["Respé Uniquement en orbit"]))
			{
				GameObject gameObject5 = ((Component)infoPanel.transform.GetChild(9)).gameObject;
				((TMP_Text)((Component)gameObject5.transform).GetComponent<TextMeshProUGUI>()).SetText("Respé Disponible en Orbit", true);
			}
		}

		public GameObject SetupUpgradeButton(Skill skill)
		{
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			GameObject gameObject = ((Component)mainPanel.transform.GetChild(0)).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject);
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				LethalPlugin.Log.LogError((object)"Couldn't find template button!");
				return null;
			}
			((Object)val).name = skill.GetShortName();
			GameObject gameObject2 = ((Component)mainPanel.transform.GetChild(3)).gameObject;
			GameObject gameObject3 = ((Component)gameObject2.transform.GetChild(1)).gameObject;
			val.transform.SetParent(gameObject3.transform, false);
			shownSkills++;
			GameObject gameObject4 = ((Component)val.transform.GetChild(0)).gameObject;
			((TMP_Text)gameObject4.GetComponent<TextMeshProUGUI>()).SetText(skill.GetShortName(), true);
			GameObject gameObject5 = ((Component)val.transform.GetChild(1)).gameObject;
			((TMP_Text)gameObject5.GetComponent<TextMeshProUGUI>()).SetText("", true);
			GameObject gameObject6 = ((Component)val.transform.GetChild(2)).gameObject;
			((TMP_Text)gameObject6.GetComponent<TextMeshProUGUI>()).SetText("[" + skill.GetLevel() + " " + skill.GetAttribute() + "]", true);
			((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() ?? "", true);
			val.SetActive(true);
			val.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				UpdateStatInfo(skill);
			});
			return val;
		}

		public void LoadSkillData(Skill skill, GameObject skillButton)
		{
			if (skill._teamShared)
			{
				return;
			}
			GameObject gameObject = ((Component)skillButton.transform.GetChild(1)).gameObject;
			((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).SetText("", true);
			GameObject gameObject2 = ((Component)skillButton.transform.GetChild(2)).gameObject;
			if (skill.GetMaxLevel() == 99999)
			{
				if (skill.GetLevel() == 0)
				{
					((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ff0000>" + skill.GetLevel() + "</color>] Augmente de <color=#ff0000>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> " + skill.GetAttribute() + ".", true);
				}
				else
				{
					((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ffff00>+" + skill.GetLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> " + skill.GetAttribute() + ".", true);
				}
			}
			else if (skill.GetLevel() == 0)
			{
				((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ff0000>" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#ff0000>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "%) " + skill.GetAttribute() + ".", true);
			}
			else if (skill.GetLevel() >= skill.GetMaxLevel())
			{
				((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText("[<color=#00ff00>+" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "%) " + skill.GetAttribute() + ".", true);
			}
			else
			{
				((TMP_Text)gameObject2.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ffff00>+" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "%) " + skill.GetAttribute() + ".", true);
			}
			((TMP_Text)skillButton.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() ?? "", true);
		}

		public void UpdateAllStats()
		{
			foreach (KeyValuePair<UpgradeType, Skill> skill in LP_NetworkManager.xpInstance.skillList.skills)
			{
				if (!skill.Value._teamShared)
				{
					GameObject skillButton = skillButtonsList.Find((GameObject x) => ((Object)x).name == skill.Value.GetShortName());
					LoadSkillData(skill.Value, skillButton);
				}
			}
		}

		public void UpdateStatInfo(Skill skill)
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			if (!infoPanel.activeSelf)
			{
				infoPanel.SetActive(true);
			}
			TextMeshProUGUI component = ((Component)infoPanel.transform.GetChild(0)).gameObject.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component2 = ((Component)infoPanel.transform.GetChild(1)).gameObject.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component3 = ((Component)infoPanel.transform.GetChild(2)).gameObject.GetComponent<TextMeshProUGUI>();
			activeSkill = skill;
			((TMP_Text)component).SetText(skill.GetName(), true);
			((TMP_Text)component2).SetText("", true);
			((TMP_Text)component3).SetText(skill.GetDescription(), true);
			GameObject gameObject = ((Component)infoPanel.transform.GetChild(3)).gameObject;
			GameObject gameObject2 = ((Component)infoPanel.transform.GetChild(4)).gameObject;
			GameObject gameObject3 = ((Component)infoPanel.transform.GetChild(5)).gameObject;
			gameObject.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 5);
			});
			gameObject2.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 2);
			});
			gameObject3.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				AddSkillPoint(skill, 1);
			});
			GameObject gameObject4 = ((Component)infoPanel.transform.GetChild(6)).gameObject;
			GameObject gameObject5 = ((Component)infoPanel.transform.GetChild(7)).gameObject;
			GameObject gameObject6 = ((Component)infoPanel.transform.GetChild(8)).gameObject;
			gameObject4.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 5);
			});
			gameObject5.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject5.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 2);
			});
			gameObject6.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)gameObject6.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				RemoveSkillPoint(skill, 1);
			});
		}

		public void AddSkillPoint(Skill skill, int amt)
		{
			if (LP_NetworkManager.xpInstance.GetSkillPoints() <= 0)
			{
				return;
			}
			int skillPoints = LP_NetworkManager.xpInstance.GetSkillPoints();
			if (skillPoints < amt)
			{
				amt = skillPoints;
			}
			if (skill.GetLevel() + amt > skill.GetMaxLevel())
			{
				amt = skill.GetMaxLevel() - skill.GetLevel();
			}
			LP_NetworkManager.xpInstance.SetSkillPoints(LP_NetworkManager.xpInstance.GetSkillPoints() - amt);
			skill.AddLevel(amt);
			UpdateStatInfo(skill);
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (((Object)skillButtons).name == skill.GetShortName())
				{
					LoadSkillData(skill, skillButtons);
				}
			}
		}

		public void RemoveSkillPoint(Skill skill, int amt)
		{
			if (skill.GetLevel() == 0)
			{
				return;
			}
			int level = skill.GetLevel();
			if (level < amt)
			{
				amt = level;
			}
			LP_NetworkManager.xpInstance.SetSkillPoints(LP_NetworkManager.xpInstance.GetSkillPoints() + amt);
			skill.AddLevel(-amt);
			UpdateStatInfo(skill);
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (((Object)skillButtons).name == skill.GetShortName())
				{
					LoadSkillData(skill, skillButtons);
				}
			}
		}

		public void TeamLootHudUpdate(int newValue)
		{
			foreach (GameObject skillButtons in skillButtonsList)
			{
				if (!(((Object)skillButtons).name == "         <color=#FF75FB>CHANCE</color>"))
				{
					continue;
				}
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value];
				LoadSkillData(skill, skillButtons);
				GameObject gameObject = ((Component)skillButtons.transform.GetChild(0)).gameObject;
				((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).SetText(skill.GetShortName(), true);
				GameObject gameObject2 = ((Component)skillButtons.transform.GetChild(1)).gameObject;
				((TMP_Text)skillButtons.GetComponentInChildren<TextMeshProUGUI>()).SetText(skill.GetShortName() ?? "", true);
				float multiplier = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value].GetMultiplier();
				float num = (float)newValue * multiplier;
				GameObject gameObject3 = ((Component)skillButtons.transform.GetChild(2)).gameObject;
				if (skill.GetMaxLevel() == 99999)
				{
					if (skill.GetLevel() == 0)
					{
						((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ff0000>" + skill.GetLevel() + "</color>] Augmente de <color=#ff0000>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Bonus d'équipe total : <color=#ff00ff>" + num + "%</color>) " + skill.GetAttribute() + ".", true);
					}
					else
					{
						((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ffff00>+" + skill.GetLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Bonus d'équipe total : <color=#ff00ff>" + num + "%</color>) " + skill.GetAttribute() + ".", true);
					}
				}
				else if (skill.GetLevel() == 0)
				{
					((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ff0000>" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#ff0000>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "% (Bonus d'équipe total : <color=#ff00ff>" + num + "%</color>) " + skill.GetAttribute() + ".", true);
				}
				else if (skill.GetLevel() >= skill.GetMaxLevel())
				{
					((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("[<color=#00ff00>+" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "% (Bonus d'équipe total : <color=#ff00ff>" + num + "%</color>) " + skill.GetAttribute() + ".", true);
				}
				else
				{
					((TMP_Text)gameObject3.GetComponent<TextMeshProUGUI>()).SetText("[<color=#ffff00>+" + skill.GetLevel() + "/" + skill.GetMaxLevel() + "</color>] Augmente de <color=#00ffff>" + (float)skill.GetLevel() * skill.GetMultiplier() + "%</color> (Max " + (float)skill.GetMaxLevel() * skill.GetMultiplier() + "% (Bonus d'équipe total : <color=#ff00ff>" + num + "%</color>) " + skill.GetAttribute() + ".", true);
				}
				LethalPlugin.Log.LogInfo((object)$"Setting team value hud to {num}");
			}
		}
	}
}
namespace LethalProgression.Skills
{
	public enum UpgradeType
	{
		HPRegen,
		Stamina,
		Battery,
		HandSlot,
		Value,
		Oxygen,
		JumpHeight,
		SprintSpeed,
		Strength,
		Resist,
		Critical
	}
	internal class SkillList
	{
		public static int OxyNoSpam = 0;

		public static string RespecText = "...";

		public Dictionary<UpgradeType, Skill> skills = new Dictionary<UpgradeType, Skill>();

		public void CreateSkill(UpgradeType upgrade, string name, string description, string shortname, string attribute, int cost, int maxLevel, float multiplier, Action<int> callback = null, bool teamShared = false)
		{
			Skill value = new Skill(name, description, shortname, attribute, upgrade, cost, maxLevel, multiplier, callback, teamShared);
			skills.Add(upgrade, value);
		}

		public bool IsSkillListValid()
		{
			if (skills.Count == 0)
			{
				return false;
			}
			return true;
		}

		public bool IsSkillValid(UpgradeType upgrade)
		{
			if (!skills.ContainsKey(upgrade))
			{
				if (!skills.ContainsKey(UpgradeType.Oxygen))
				{
					if (OxyNoSpam == 0)
					{
						LethalPlugin.Log.LogInfo((object)("Skill " + upgrade.ToString() + " is not in the skill list!"));
						OxyNoSpam = 1;
						return false;
					}
					return false;
				}
				LethalPlugin.Log.LogInfo((object)("Skill " + upgrade.ToString() + " is not in the skill list!"));
				return false;
			}
			return true;
		}

		public Skill GetSkill(UpgradeType upgrade)
		{
			if (!IsSkillValid(upgrade))
			{
				return null;
			}
			return skills[upgrade];
		}

		public Dictionary<UpgradeType, Skill> GetSkills()
		{
			return skills;
		}

		public void InitializeSkills()
		{
			if (bool.Parse(SkillConfig.hostConfig["Respé Uniquement dans le vaisseau"]) && !bool.Parse(SkillConfig.hostConfig["Respé désactivé"]))
			{
				RespecText = "Vous pouvez ajouter des points de caractéristiques à tout moment. Pour modifier votre spécialisation vous devez être à bord du vaisseau.";
			}
			else if (bool.Parse(SkillConfig.hostConfig["Respé Uniquement en orbit"]))
			{
				RespecText = "Vous pouvez ajouter des points de caractéristiques à tout moment. Pour modifier votre spécialisation vous devez être en Orbit.";
			}
			else if (bool.Parse(SkillConfig.hostConfig["Respé désactivé"]))
			{
				RespecText = "Vous pouvez ajouter des points de caractéristiques à tout moment. Toutefois, <color=#ff0000>Attention</color> ces choix sont définitifs et irréversibles.";
			}
			else
			{
				RespecText = "Vous pouvez modifier vos points de caractéristiques à tout moment.";
			}
			if (bool.Parse(SkillConfig.hostConfig["Constitution Actif"]))
			{
				CreateSkill(UpgradeType.Resist, "<color=#8A7B3F>CONSTITUTION</color>\n\n" + RespecText, " ", "         <color=#8A7B3F>CONSTITUTION</color>", "la résistance aux dégats des monstres, (Max 90%).", 1, int.Parse(SkillConfig.hostConfig["Constitution Niveau Max"]), float.Parse(SkillConfig.hostConfig["Constitution Augmentation"], CultureInfo.InvariantCulture), Resistance.ResistanceUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Vitalité Actif"]))
			{
				LethalPlugin.Log.LogInfo((object)"HP Regen check 1");
				CreateSkill(UpgradeType.HPRegen, "<color=#00cc00>VITALITE</color>\n\n" + RespecText, " ", "         <color=#00cc00>VITALITE</color>", "la régénération de points de vie passif", 1, int.Parse(SkillConfig.hostConfig["Vitalité Niveau Max"]), float.Parse(SkillConfig.hostConfig["Vitalité Augmentation"], CultureInfo.InvariantCulture));
			}
			if (bool.Parse(SkillConfig.hostConfig["Endurance Actif"]))
			{
				CreateSkill(UpgradeType.Stamina, "<color=#FFAB00>ENDURANCE</color>\n\n" + RespecText, " ", "         <color=#FFAB00>ENDURANCE</color>", "la quantité d'endurance maximum", 1, int.Parse(SkillConfig.hostConfig["Endurance Niveau Max"]), float.Parse(SkillConfig.hostConfig["Endurance Augmentation"], CultureInfo.InvariantCulture), Stamina.StaminaUpdate);
			}
			if (!LethalPlugin.MikesTweaks && bool.Parse(SkillConfig.hostConfig["Vitesse Actif"]))
			{
				CreateSkill(UpgradeType.SprintSpeed, "<color=#6DF0F9>VITESSE</color>\n\n" + RespecText, " ", "         <color=#6DF0F9>VITESSE</color>", "la vitesse de sprint", 1, int.Parse(SkillConfig.hostConfig["Vitesse Niveau Max"]), float.Parse(SkillConfig.hostConfig["Vitesse Augmentation"], CultureInfo.InvariantCulture), SprintSpeed.SprintSpeedUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Force Actif"]))
			{
				CreateSkill(UpgradeType.Strength, "<color=#C4774A>FORCE</color>\n\n" + RespecText, " ", "         <color=#C4774A>FORCE</color>", "la capacité à porter des charges lourdes", 1, int.Parse(SkillConfig.hostConfig["Force Niveau Max"]), float.Parse(SkillConfig.hostConfig["Force Augmentation"], CultureInfo.InvariantCulture), Strength.StrengthUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Agilité Actif"]))
			{
				CreateSkill(UpgradeType.JumpHeight, "<color=#00FF80>AGILITE</color>\n\n" + RespecText, " ", "         <color=#00FF80>AGILITE</color>", "la hauteur des sauts", 1, int.Parse(SkillConfig.hostConfig["Agilité Niveau Max"]), float.Parse(SkillConfig.hostConfig["Agilité Augmentation"], CultureInfo.InvariantCulture), JumpHeight.JumpHeightUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Critique Actif"]))
			{
				CreateSkill(UpgradeType.Critical, "<color=#ff4444>CRITIQUE</color>\n\n" + RespecText, " ", "         <color=#ff4444>CRITIQUE</color>", "Les chance de faire 1 coup critiques avec les armes de corps à corps", 1, int.Parse(SkillConfig.hostConfig["Critique Niveau Max"]), float.Parse(SkillConfig.hostConfig["Critique Augmentation"], CultureInfo.InvariantCulture), Critical.CriticalUpdate);
			}
			if (bool.Parse(SkillConfig.hostConfig["Energie Actif"]))
			{
				CreateSkill(UpgradeType.Battery, "<color=#F2FC66>ENERGIE</color>\n\n" + RespecText, " ", "         <color=#F2FC66>ENERGIE</color>", "la durée des batteries", 1, int.Parse(SkillConfig.hostConfig["Energie Niveau Max"]), float.Parse(SkillConfig.hostConfig["Energie Augmentation"], CultureInfo.InvariantCulture));
			}
			if (bool.Parse(SkillConfig.hostConfig["Oxygene Actif"]))
			{
				CreateSkill(UpgradeType.Oxygen, "<color=#3399FF>OXYGENE</color>\n\n" + RespecText, " ", "         <color=#3399FF>OXYGENE</color>", "la durée de respiration sous l'eau", 1, int.Parse(SkillConfig.hostConfig["Oxygene Niveau Max"]), float.Parse(SkillConfig.hostConfig["Oxygene Augmentation"], CultureInfo.InvariantCulture));
			}
			if (bool.Parse(SkillConfig.hostConfig["Chance Actif"]))
			{
				CreateSkill(UpgradeType.Value, "<color=#FF75FB>CHANCE</color>\n\n" + RespecText, " ", "         <color=#FF75FB>CHANCE</color>", "la valeur des objets à collecter", 1, int.Parse(SkillConfig.hostConfig["Chance Niveau Max"]), float.Parse(SkillConfig.hostConfig["Chance Augmentation"], CultureInfo.InvariantCulture), LootValue.LootValueUpdate, teamShared: true);
			}
			if (bool.Parse(SkillConfig.hostConfig["Charisme Actif"]) && !LethalPlugin.ReservedSlots)
			{
				CreateSkill(UpgradeType.HandSlot, "<color=#B16BF7>CHARISME</color>\n\n" + RespecText, " ", "         <color=#B16BF7>CHARISME</color>", "la quantité d'objet transportable", 1, int.Parse(SkillConfig.hostConfig["Charisme Niveau Max"]), float.Parse(SkillConfig.hostConfig["Charisme Augmentation"], CultureInfo.InvariantCulture), HandSlots.HandSlotsUpdate);
			}
		}
	}
	internal class Skill
	{
		private readonly string _shortName;

		private readonly string _name;

		private readonly string _attribute;

		private readonly string _description;

		private readonly UpgradeType _upgradeType;

		private readonly int _cost;

		private readonly int _maxLevel;

		private readonly float _multiplier;

		private readonly Action<int> _callback;

		public bool _teamShared;

		private int _level;

		public Skill(string name, string description, string shortname, string attribute, UpgradeType upgradeType, int cost, int maxLevel, float multiplier, Action<int> callback = null, bool teamShared = false)
		{
			_name = name;
			_shortName = shortname;
			_attribute = attribute;
			_description = description;
			_upgradeType = upgradeType;
			_cost = cost;
			_maxLevel = maxLevel;
			_multiplier = multiplier;
			_level = 0;
			_callback = callback;
			_teamShared = teamShared;
		}

		public string GetName()
		{
			return _name;
		}

		public string GetShortName()
		{
			return _shortName;
		}

		public string GetAttribute()
		{
			return _attribute;
		}

		public string GetDescription()
		{
			return _description;
		}

		public UpgradeType GetUpgradeType()
		{
			return _upgradeType;
		}

		public int GetCost()
		{
			return _cost;
		}

		public int GetMaxLevel()
		{
			return _maxLevel;
		}

		public int GetLevel()
		{
			return _level;
		}

		public float GetMultiplier()
		{
			return _multiplier;
		}

		public float GetTrueValue()
		{
			return _multiplier * (float)_level;
		}

		public void SetLevel(int newLevel, bool triggerHostProfileSave = true)
		{
			int level = _level;
			_level = newLevel;
			_callback?.Invoke(newLevel - level);
			if (triggerHostProfileSave)
			{
				SaveManager.TriggerHostProfileSave();
			}
		}

		public void AddLevel(int change)
		{
			_level += change;
			_callback?.Invoke(change);
			SaveManager.TriggerHostProfileSave();
		}
	}
	[HarmonyPatch]
	internal class BatteryLife
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GrabbableObject), "SyncBatteryServerRpc")]
		public static void BatteryUpdate(ref int charge)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Battery) && charge == 100)
			{
				charge += (int)LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Battery].GetTrueValue();
			}
		}
	}
	[HarmonyPatch]
	public static class Critical
	{
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		internal class GrabbableObjectPatch
		{
			public static void Prefix(GrabbableObject __instance)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				if (((object)__instance).GetType() == typeof(Shovel))
				{
					Shovel val = (Shovel)((__instance is Shovel) ? __instance : null);
					itemDamage = val.shovelHitForce;
					ShovelPatch.SuperCritDamage = itemDamage * 3;
					ShovelPatch.CritDamage = itemDamage * 2;
					ShovelPatch.InitialDamage = itemDamage;
					LethalPlugin.Log.LogWarning((object)$"Dégats sauvegardé pour cette arme : [{100f - critvalue}%] Dégâts normaux x{ShovelPatch.InitialDamage}, [{critvalue - critvalue2}%] Coup Critique x{ShovelPatch.CritDamage}, [{critvalue2}%] x{ShovelPatch.SuperCritDamage} !");
				}
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "EquipItem")]
		internal class EquipItemPatch
		{
			public static void Prefix(GrabbableObject __instance)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				if (((object)__instance).GetType() == typeof(Shovel))
				{
					Shovel val = (Shovel)((__instance is Shovel) ? __instance : null);
					itemDamage = val.shovelHitForce;
					ShovelPatch.SuperCritDamage = itemDamage * 3;
					ShovelPatch.CritDamage = itemDamage * 2;
					ShovelPatch.InitialDamage = itemDamage;
					LethalPlugin.Log.LogWarning((object)$"Dégats sauvegardé pour cette arme : [{100f - critvalue}%] Dégâts normaux x{ShovelPatch.InitialDamage}, [{critvalue - critvalue2}%] Coup Critique x{ShovelPatch.CritDamage}, [{critvalue2}%] x{ShovelPatch.SuperCritDamage} !");
				}
			}
		}

		[HarmonyPatch(typeof(Shovel), "SwingShovel")]
		public class ShovelPatch
		{
			public static readonly Random _random = new Random();

			public static int SuperCritDamage = itemDamage * 3;

			public static int CritDamage = itemDamage * 2;

			public static int InitialDamage = itemDamage;

			private static bool CriticalHit;

			private static bool SuperCriticalHit;

			public static void Prefix(Shovel __instance, bool cancel = false)
			{
				CriticalHit = (float)_random.Next(1, 101) <= critvalue;
				if (!CriticalHit)
				{
					LethalPlugin.Log.LogWarning((object)$"Dégâts x{InitialDamage}.");
					__instance.shovelHitForce = InitialDamage;
					return;
				}
				SuperCriticalHit = (float)_random.Next(1, 101) <= critvalue;
				if (!SuperCriticalHit)
				{
					LethalPlugin.Log.LogWarning((object)$"Dégats x{CritDamage} Coup Critique !");
					__instance.shovelHitForce = CritDamage;
				}
				else
				{
					LethalPlugin.Log.LogWarning((object)$"Dégats x{SuperCritDamage} Coup Critique !");
					__instance.shovelHitForce = SuperCritDamage;
				}
			}

			public static void Postfix(Shovel __instance, bool cancel = false)
			{
				__instance.shovelHitForce = InitialDamage;
			}
		}

		[HarmonyPatch(typeof(KnifeItem), "ItemActivate")]
		public class KnifeItemPatch
		{
			public static readonly Random _random = new Random();

			public static int CritDamage = 2;

			public static int InitialDamage = 1;

			private static bool CriticalHit;

			public static void Prefix(KnifeItem __instance, bool used, bool buttonDown = true)
			{
				CriticalHit = (float)_random.Next(1, 101) <= critvalue;
				if (!CriticalHit)
				{
					LethalPlugin.Log.LogWarning((object)$"Dégâts x{InitialDamage}.");
					__instance.knifeHitForce = InitialDamage;
				}
				else
				{
					LethalPlugin.Log.LogWarning((object)$"Dégats x{CritDamage} Coup Critique !");
					__instance.knifeHitForce = CritDamage;
				}
			}
		}

		public static float critvalue = 0f;

		public static float Icrit = 0.01f;

		public static float critvalue2 = 0f;

		public static int itemDamage = 1;

		public static void CriticalUpdate(int updatedValue)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Critical))
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Critical];
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				float num = (float)updatedValue * skill.GetMultiplier();
				critvalue += num;
				if (critvalue != 0f)
				{
					Icrit = (float)Math.Round(100f / critvalue, 2);
					critvalue2 = critvalue / Icrit;
					LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, Adding {num} resulting in {critvalue}% Critical rate ({critvalue2}% x3) ");
				}
				else
				{
					LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, Adding {num} resulting in {critvalue}% Critical rate !");
				}
			}
		}
	}
	internal class HandSlots
	{
		public static int currentSlotCount = 4;

		public static void HandSlotsUpdate(int updateValue)
		{
			if (!LethalPlugin.ReservedSlots && LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HandSlot))
			{
				LC_XP xpInstance = LP_NetworkManager.xpInstance;
				int num = (int)xpInstance.skillList.skills[UpgradeType.HandSlot].GetTrueValue();
				int num2 = (int)Math.Floor((double)(num / 100));
				ulong playerClientId = GameNetworkManager.Instance.localPlayerController.playerClientId;
				LethalPlugin.Log.LogInfo((object)$"Updating Player HandSlot {playerClientId}");
				xpInstance.updateSPHandSlotsClientMessage.SendServer(num2);
			}
		}

		public static void UpdateHudSlots()
		{
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			LC_XP xpInstance = LP_NetworkManager.xpInstance;
			float num = xpInstance.skillList.skills[UpgradeType.HandSlot].GetTrueValue() / 100f;
			int num2 = 4 + (int)Math.Floor(num);
			int num3 = num2 - currentSlotCount;
			GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory");
			List<string> list = new List<string> { "Slot0", "Slot1", "Slot2", "Slot3" };
			for (int i = 0; i < val.transform.childCount; i++)
			{
				Transform child = val.transform.GetChild(i);
				if (!list.Contains(((Object)((Component)child).gameObject).name))
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
			int num4 = (int)xpInstance.skillList.skills[UpgradeType.HandSlot].GetTrueValue();
			int num5 = (int)Math.Floor((double)(num4 / 100));
			Image[] array = (Image[])(object)new Image[num2];
			array[0] = HUDManager.Instance.itemSlotIconFrames[0];
			array[1] = HUDManager.Instance.itemSlotIconFrames[1];
			array[2] = HUDManager.Instance.itemSlotIconFrames[2];
			array[3] = HUDManager.Instance.itemSlotIconFrames[3];
			Image[] array2 = (Image[])(object)new Image[num2];
			array2[0] = HUDManager.Instance.itemSlotIcons[0];
			array2[1] = HUDManager.Instance.itemSlotIcons[1];
			array2[2] = HUDManager.Instance.itemSlotIcons[2];
			array2[3] = HUDManager.Instance.itemSlotIcons[3];
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3");
			GameObject templateSlot = xpInstance.guiObj.templateSlot;
			GameObject val3 = val2;
			currentSlotCount = num2;
			for (int j = 0; j < (int)num; j++)
			{
				GameObject val4 = Object.Instantiate<GameObject>(templateSlot);
				((Object)val4).name = $"Slot{3 + (j + 1)}";
				val4.transform.SetParent(val.transform);
				Vector3 localPosition = val3.transform.localPosition;
				val4.transform.SetLocalPositionAndRotation(new Vector3(localPosition.x + 50f, localPosition.y, localPosition.z), val3.transform.localRotation);
				val3 = val4;
				array[3 + (j + 1)] = val4.GetComponent<Image>();
				array2[3 + (j + 1)] = ((Component)val4.transform.GetChild(0)).GetComponent<Image>();
				val4.SetActive(true);
			}
			for (int k = 0; k < array.Length; k++)
			{
				Vector3 localPosition2 = ((Component)array[k]).transform.localPosition;
				((Component)array[k]).transform.SetLocalPositionAndRotation(new Vector3(localPosition2.x - (float)(num3 * 25), localPosition2.y, localPosition2.z), ((Component)array[k]).transform.localRotation);
			}
			HUDManager.Instance.itemSlotIconFrames = array;
			HUDManager.Instance.itemSlotIcons = array2;
		}

		public static bool IsItemSwitchPossible(PlayerControllerB player)
		{
			return (double)player.timeSinceSwitchingSlots >= 0.01 && !player.inTerminalMenu && !player.isGrabbingObjectAnimation && !player.inSpecialInteractAnimation && !player.throwingObject && !player.isTypingChat && !player.twoHanded && !player.activatingItem && !player.jetpackControls && !player.disablingJetpackControls;
		}

		public static bool SwitchItemSlots(PlayerControllerB player, int requestedSlot)
		{
			if (!IsItemSwitchPossible(player) || player.currentItemSlot == requestedSlot)
			{
				LethalPlugin.Log.LogDebug((object)"TEST");
				return false;
			}
			LethalPlugin.Log.LogDebug((object)$"Trying to switch to slot {requestedSlot}");
			int num = player.currentItemSlot - requestedSlot;
			bool flag = num > 0;
			if (Math.Abs(num) == player.ItemSlots.Length - 1)
			{
				player.SwitchItemSlotsServerRpc(flag);
			}
			else
			{
				do
				{
					player.SwitchItemSlotsServerRpc(flag);
					num += ((!flag) ? 1 : (-1));
				}
				while (num != 0);
			}
			ShipBuildModeManager.Instance.CancelBuildMode(true);
			player.playerBodyAnimator.SetBool("GrabValidated", false);
			LethalPlugin.Log.LogDebug((object)$"Switched to slot {requestedSlot}");
			player.SwitchToItemSlot(requestedSlot, (GrabbableObject)null);
			if ((Object)(object)player.currentlyHeldObjectServer != (Object)null)
			{
				((Component)player.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(player.currentlyHeldObjectServer.itemProperties.grabSFX, 0.6f);
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class HPRegen
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void HPRegenUpdate(PlayerControllerB __instance)
		{
			if (!((NetworkBehaviour)__instance).IsOwner || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject) || !__instance.isPlayerControlled || __instance.health >= 100 || __instance.isPlayerDead || !LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.HPRegen) || LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.HPRegen].GetLevel() == 0)
			{
				return;
			}
			if (__instance.healthRegenerateTimer <= 0f)
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.HPRegen];
				float trueValue = skill.GetTrueValue();
				__instance.healthRegenerateTimer = 1f / trueValue;
				__instance.health++;
				if (__instance.health >= 20)
				{
					__instance.MakeCriticallyInjured(false);
				}
				HUDManager.Instance.UpdateHealthUI(__instance.health, false);
			}
			else
			{
				__instance.healthRegenerateTimer -= Time.deltaTime;
			}
		}
	}
	internal class JumpHeight
	{
		public static void JumpHeightUpdate(int updatedValue)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.JumpHeight))
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.JumpHeight];
				PlayerJumpHeightData playerJumpHeightData = new PlayerJumpHeightData
				{
					clientId = localPlayerController.playerClientId,
					jumpSkillValue = skill.GetLevel()
				};
				LethalPlugin.Log.LogInfo((object)$"Jump skill now {skill.GetLevel()}, sending to Server");
				LP_NetworkManager.xpInstance.updatePlayerJumpForceClientMessage.SendServer(playerJumpHeightData);
			}
		}
	}
	[HarmonyPatch]
	internal class LootValue
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		private static void AddLootValue()
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Value))
			{
				float multiplier = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value].GetMultiplier();
				float num = (float)LP_NetworkManager.xpInstance.teamLootLevel.Value * multiplier;
				float num2 = num / 100f;
				try
				{
					RoundManager instance = RoundManager.Instance;
					instance.scrapValueMultiplier += num2;
				}
				catch
				{
				}
				LethalPlugin.Log.LogDebug((object)$"Added {num2} to scrap value multiplier, resulting in {RoundManager.Instance.scrapValueMultiplier}");
			}
		}

		public static void LootValueUpdate(int change)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Value))
			{
				LP_NetworkManager.xpInstance.updateTeamLootLevelClientMessage.SendServer(change);
			}
		}
	}
	[HarmonyPatch]
	internal class Oxygen
	{
		private static GameObject oxygenBar;

		private static float oxygen = 0f;

		private static float oxygenTimer = 0f;

		private static bool inWater = false;

		private static bool canDrown = true;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceUnderwaterClientRpc")]
		private static void EnteredWater(PlayerControllerB __instance)
		{
			inWater = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceOutOfWaterClientRpc")]
		private static void LeftWater(PlayerControllerB __instance)
		{
			inWater = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFaceUnderwaterFilters")]
		private static void ShouldDrown(PlayerControllerB __instance)
		{
			if (!canDrown)
			{
				StartOfRound.Instance.drowningTimer = 99f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void OxygenUpdate(PlayerControllerB __instance)
		{
			if (!Object.op_Implicit((Object)(object)LP_NetworkManager.xpInstance) || !LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Oxygen))
			{
				return;
			}
			if (__instance.isPlayerDead)
			{
				if (Object.op_Implicit((Object)(object)oxygenBar))
				{
					oxygenBar.SetActive(false);
				}
				return;
			}
			if (LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Oxygen].GetLevel() == 0)
			{
				if (Object.op_Implicit((Object)(object)oxygenBar))
				{
					oxygenBar.SetActive(false);
				}
				if (!canDrown)
				{
					canDrown = true;
					StartOfRound.Instance.drowningTimer = 1f;
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)oxygenBar))
			{
				CreateOxygenBar();
			}
			Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Oxygen];
			float trueValue = skill.GetTrueValue();
			if (inWater)
			{
				oxygenBar.SetActive(true);
				if (oxygenTimer <= 0f)
				{
					oxygenTimer = 0.1f;
					if (oxygen > 0f)
					{
						oxygen -= 0.1f;
					}
					else if (!canDrown)
					{
						canDrown = true;
						StartOfRound.Instance.drowningTimer = 1f;
					}
				}
				else
				{
					oxygenTimer -= Time.deltaTime;
				}
			}
			if (!inWater)
			{
				if (oxygenTimer <= 0f)
				{
					oxygenTimer = 0.1f;
					if (oxygen < trueValue)
					{
						oxygenBar.SetActive(true);
						oxygen += 0.1f;
						canDrown = false;
					}
					else
					{
						oxygenBar.SetActive(false);
					}
				}
				else
				{
					oxygenTimer -= Time.deltaTime;
				}
			}
			if (oxygen > trueValue)
			{
				oxygenBar.SetActive(false);
				oxygen = trueValue;
			}
			if (oxygenBar.activeSelf)
			{
				float fillAmount = oxygen / trueValue;
				((Component)oxygenBar.transform.GetChild(0).GetChild(0)).GetComponent<Image>().fillAmount = fillAmount;
			}
		}

		public static void CreateOxygenBar()
		{
			oxygenBar = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("OxygenBar"));
			oxygenBar.SetActive(false);
		}
	}
	[HarmonyPatch]
	internal class Resistance
	{
		public static void ResistanceUpdate(int updatedValue)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Resist))
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Resist];
				float num = skill.GetMultiplier() * (float)skill.GetLevel();
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				float num2 = 0.5f;
				float num3 = 100f - num;
				float num4 = num2 * num3;
				float num5 = (int)Math.Round(num4);
				LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, reduction {num} / {num3}% - fake new damage (base 50) {num5} = {num5}.");
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPrefix]
		public static void DamagePlayer(PlayerControllerB __instance, ref int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			try
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Resist];
				float num = skill.GetMultiplier() * (float)skill.GetLevel();
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)__instance && !fallDamage && (int)causeOfDeath != 2)
				{
					float num2 = (float)damageNumber * 0.01f;
					float num3 = 100f - num;
					float num4 = num3;
					num4 = ((!(num3 > 90f)) ? num3 : 90f);
					float num5 = num2 * num4;
					damageNumber = (int)Math.Round(num5);
				}
			}
			catch (Exception)
			{
			}
		}
	}
	[HarmonyPatch]
	public static class SprintSpeed
	{
		public static float sprintSpeed = 2.25f;

		public static void SprintSpeedUpdate(int updatedValue)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.SprintSpeed))
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.SprintSpeed];
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				float num = (float)updatedValue * skill.GetMultiplier() / 100f * 2.25f;
				sprintSpeed += num;
				LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, Adding {num} resulting in {sprintSpeed} run speed");
			}
		}

		public static float GetSprintSpeed()
		{
			return sprintSpeed;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			if (LethalPlugin.MikesTweaks)
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 2.25f)
				{
					list[i] = new CodeInstruction(OpCodes.Call, (object)typeof(SprintSpeed).GetMethod("GetSprintSpeed"));
				}
			}
			return list.AsEnumerable();
		}
	}
	internal class Stamina
	{
		public static void StaminaUpdate(int updatedValue)
		{
			if (LP_NetworkManager.xpInstance.skillList.IsSkillListValid() && LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Stamina))
			{
				Skill skill = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Stamina];
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				float num = (float)updatedValue * skill.GetMultiplier() / 100f * 11f;
				localPlayerController.sprintTime += num;
				LethalPlugin.Log.LogInfo((object)$"{updatedValue} change, Adding {num} resulting in {localPlayerController.sprintTime} stamina");
			}
		}
	}
	[HarmonyPatch]
	internal class Strength
	{
		public static void StrengthUpdate(int change = 0)
		{
			if (!LP_NetworkManager.xpInstance.skillList.IsSkillListValid() || !LP_NetworkManager.xpInstance.skillList.IsSkillValid(UpgradeType.Strength) || LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Strength].GetLevel() == 0)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			List<GrabbableObject> list = localPlayerController.ItemSlots.ToList();
			LethalPlugin.Log.LogDebug((object)$"Carry weight was {localPlayerController.carryWeight}");
			float trueValue = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Strength].GetTrueValue();
			float num = trueValue / 100f;
			float num2 = 0f;
			foreach (GrabbableObject item in list)
			{
				if (!((Object)(object)item == (Object)null))
				{
					float num3 = item.itemProperties.weight - 1f;
					num3 *= 1f - num;
					num2 += num3;
					LethalPlugin.Log.LogDebug((object)$"Item weight was {item.itemProperties.weight - 1f} and is now {num3}");
					LethalPlugin.Log.LogDebug((object)$"Adding carryweight.. now up to {num2}");
				}
			}
			localPlayerController.carryWeight = Math.Clamp(1f + num2, 0f, 10f);
			LethalPlugin.Log.LogDebug((object)$"Player carry weight is now {localPlayerController.carryWeight}");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		private static void UpdateObjects()
		{
			StrengthUpdate();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "DiscardItem")]
		private static void UpdateByDiscard(GrabbableObject __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				StrengthUpdate();
			}
		}
	}
}
namespace LethalProgression.Saving
{
	internal class SaveData
	{
		public ulong steamId;

		public Dictionary<UpgradeType, int> skillAllocation = new Dictionary<UpgradeType, int>();

		public int skillPoints { get; set; }
	}
	internal class SaveSharedData
	{
		public int xp { get; set; }

		public int level { get; set; }

		public int quota { get; set; }

		public SaveSharedData(int xp, int level, int quota)
		{
			this.xp = xp;
			this.level = level;
			this.quota = quota;
		}
	}
	internal static class SaveManager
	{
		public static int saveFileSlot;

		public static void TriggerHostProfileSave()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ulong num = SteamId.op_Implicit(SteamClient.SteamId);
			SaveData saveData = new SaveData
			{
				steamId = num,
				skillPoints = LP_NetworkManager.xpInstance.skillPoints
			};
			foreach (KeyValuePair<UpgradeType, Skill> skill in LP_NetworkManager.xpInstance.skillList.skills)
			{
				LethalPlugin.Log.LogInfo((object)$"Skill is {skill.Key} and value is {skill.Value.GetLevel()}");
				saveData.skillAllocation.Add(skill.Key, skill.Value.GetLevel());
			}
			LethalPlugin.Log.LogInfo((object)$"Invoke saveProfileDataClientMessage({num}, {JsonConvert.SerializeObject((object)saveData)})");
			LP_NetworkManager.xpInstance.saveProfileDataClientMessage.SendServer(JsonConvert.SerializeObject((object)new SaveProfileData(num, saveData)));
		}

		public static void Save(ulong steamid, SaveData data)
		{
			saveFileSlot = GameNetworkManager.Instance.saveFileNum;
			LethalPlugin.Log.LogInfo((object)$"Saving to slot {saveFileSlot + 1} in {GetSavePath()}");
			if (!Directory.Exists(GetSavePath()))
			{
				Directory.CreateDirectory(GetSavePath());
			}
			File.WriteAllText(GetSavePath() + steamid + ".json", JsonConvert.SerializeObject((object)data));
		}

		public static void SaveShared(int xp, int level, int quota)
		{
			saveFileSlot = GameNetworkManager.Instance.saveFileNum;
			LethalPlugin.Log.LogInfo((object)("Saving to slot " + saveFileSlot + 1));
			if (!Directory.Exists(GetSavePath()))
			{
				Directory.CreateDirectory(GetSavePath());
			}
			File.WriteAllText(GetSavePath() + "shared.json", JsonConvert.SerializeObject((object)new SaveSharedData(xp, level, quota)));
		}

		public static void DeleteSave(int _saveFileSlot)
		{
			saveFileSlot = _saveFileSlot;
			if (Directory.Exists(GetSavePath()))
			{
				Directory.Delete(Application.persistentDataPath + "/lethalprogression/save" + (saveFileSlot + 1), recursive: true);
			}
		}

		public static string GetSavePath()
		{
			return Application.persistentDataPath + "/lethalprogression/save" + (saveFileSlot + 1) + "/";
		}

		public static string LoadPlayerFile(ulong steamId)
		{
			saveFileSlot = GameNetworkManager.Instance.saveFileNum;
			if (!File.Exists(GetSavePath() + steamId + ".json"))
			{
				LethalPlugin.Log.LogInfo((object)$"Player file for {steamId} doesn't exist");
				return null;
			}
			LethalPlugin.Log.LogInfo((object)$"Player file for {steamId} found");
			return File.ReadAllText(GetSavePath() + steamId + ".json");
		}

		public static SaveSharedData LoadSharedFile()
		{
			saveFileSlot = GameNetworkManager.Instance.saveFileNum;
			if (!File.Exists(GetSavePath() + "shared.json"))
			{
				LethalPlugin.Log.LogInfo((object)"Shared file doesn't exist");
				return null;
			}
			LethalPlugin.Log.LogInfo((object)"Shared file exists");
			string text = File.ReadAllText(GetSavePath() + "shared.json");
			return JsonConvert.DeserializeObject<SaveSharedData>(text);
		}
	}
	[HarmonyPatch]
	internal class SavePatches : NetworkBehaviour
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameNetworkManager), "SaveGame")]
		[HarmonyPriority(800)]
		private static void SaveGamePrefix()
		{
			LethalPlugin.Log.LogDebug((object)"Invoked DoSave via SaveGame");
			SaveManager.TriggerHostProfileSave();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
		private static void DeleteSaveFile(DeleteFileButton __instance)
		{
			SaveManager.DeleteSave(__instance.fileToDelete);
		}
	}
}
namespace LethalProgression.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("LethalProgression.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] skillmenu
		{
			get
			{
				object @object = ResourceManager.GetObject("skillmenu", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace LethalProgression.Patches
{
	[HarmonyPatch]
	internal class EnemyAIPatch
	{
		private static Dictionary<string, int> _enemyReward = new Dictionary<string, int>
		{
			{
				"HoarderBug (EnemyType)",
				int.Parse(SkillConfig.hostConfig["HoarderBug"])
			},
			{
				"BaboonBird (EnemyType)",
				int.Parse(SkillConfig.hostConfig["BaboonBird"])
			},
			{
				"MouthDog (EnemyType)",
				int.Parse(SkillConfig.hostConfig["MouthDog"])
			},
			{
				"Centipede (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Centipede"])
			},
			{
				"Flowerman (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Flowerman"])
			},
			{
				"SandSpider (EnemyType)",
				int.Parse(SkillConfig.hostConfig["SandSpider"])
			},
			{
				"Crawler (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Crawler"])
			},
			{ "Puffer (EnemyType)", 10 },
			{
				"Peeper (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Peeper"])
			},
			{
				"Masked (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Masked"])
			},
			{
				"Maggie (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Maggie"])
			},
			{
				"Butler (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Butler"])
			},
			{
				"ForestGiant (EnemyType)",
				int.Parse(SkillConfig.hostConfig["ForestGiant"])
			},
			{
				"Nutcracker (EnemyType)",
				int.Parse(SkillConfig.hostConfig["Nutcracker"])
			},
			{
				"TulipSnake (EnemyType)",
				int.Parse(SkillConfig.hostConfig["TulipSnake"])
			}
		};

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
		private static void CalculateXPForEnemyDeath(EnemyAI __instance)
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				string text = ((object)__instance.enemyType).ToString();
				LethalPlugin.Log.LogInfo((object)("Enemy type: " + text));
				int num = 30;
				if (_enemyReward.ContainsKey(text))
				{
					num = _enemyReward[text];
				}
				LP_NetworkManager.xpInstance.updateTeamXPClientMessage.SendServer(num);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "HitEnemyServerRpc")]
		private static void HitEnemyTrigger(EnemyAI __instance, int force, int playerWhoHit)
		{
			LethalPlugin.Log.LogInfo((object)$"Player {playerWhoHit} hit enemy {((object)__instance).GetType()} with force {force}");
		}
	}
	[HarmonyPatch]
	internal class HUDManagerPatch
	{
		private static GameObject _tempBar;

		private static TextMeshProUGUI _tempText;

		private static float _tempBarTime;

		private static GameObject levelText;

		private static float levelTextTime;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "AddNewScrapFoundToDisplay")]
		private static void GiveXPForScrap(GrabbableObject GObject)
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				int scrapValue = GObject.scrapValue;
				LP_NetworkManager.xpInstance.updateTeamXPClientMessage.SendServer(scrapValue);
			}
		}

		public static void ShowXPUpdate()
		{
			if (!Object.op_Implicit((Object)(object)_tempBar))
			{
				MakeBar();
			}
			LC_XP xpInstance = LP_NetworkManager.xpInstance;
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPBarProgress");
			val.GetComponent<Image>().fillAmount = (float)xpInstance.teamXP.Value / (float)xpInstance.CalculateXPRequirement();
			((TMP_Text)_tempText).text = xpInstance.teamXP.Value + " / " + (float)xpInstance.CalculateXPRequirement();
			_tempBarTime = 2f;
			if (!_tempBar.activeSelf)
			{
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(XPBarCoroutine());
			}
		}

		private static IEnumerator XPBarCoroutine()
		{
			_tempBar.SetActive(true);
			while (_tempBarTime > 0f)
			{
				float time = _tempBarTime;
				_tempBarTime = 0f;
				yield return (object)new WaitForSeconds(time);
			}
			_tempBar.SetActive(false);
		}

		public static void ShowLevelUp()
		{
			if (!Object.op_Implicit((Object)(object)levelText))
			{
				MakeLevelUp();
			}
			levelTextTime = 5f;
			if (!levelText.gameObject.activeSelf)
			{
				((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(LevelUpCoroutine());
			}
		}

		public static void MakeLevelUp()
		{
			levelText = Object.Instantiate<GameObject>(LethalPlugin.skillBundle.LoadAsset<GameObject>("LevelUp"));
			((TMP_Text)((Component)levelText.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Level Up! Spend your skill points.";
			levelText.gameObject.SetActive(false);
		}

		private static IEnumerator LevelUpCoroutine()
		{
			levelText.gameObject.SetActive(true);
			while (levelTextTime > 0f)
			{
				float time = levelTextTime;
				levelTextTime = 0f;
				yield return (object)new WaitForSeconds(time);
			}
			levelText.gameObject.SetActive(false);
		}

		private static void MakeBar()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			QuickMenuManagerPatch.MakeNewXPBar();
			GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu/XpInfoContainer/XPBar");
			_tempBar = Object.Instantiate<GameObject>(val);
			((Object)_tempBar).name = "XPUpdate";
			_tempText = _tempBar.GetComponentInChildren<TextMeshProUGUI>();
			GameObject val2 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle");
			_tempBar.transform.SetParent(val2.transform, false);
			_tempBar.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
			GameObject val3 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPLevel");
			Object.Destroy((Object)(object)val3);
			GameObject val4 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/XPUpdate/XPProfit");
			Object.Destroy((Object)(object)val4);
			_tempBar.transform.Translate(3.1f, -2.1f, 0f);
			Vector3 localPosition = _tempBar.transform.localPosition;
			_tempBar.transform.localPosition = new Vector3(localPosition.x, localPosition.y + 5f, localPosition.z);
			_tempBar.SetActive(false);
		}
	}
	[HarmonyPatch]
	internal class QuickMenuManagerPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OpenSkillTree;
		}

		private static GameObject _xpBar;

		private static GameObject _xpInfoContainer;

		private static GameObject _xpBarProgress;

		private static TextMeshProUGUI _xpText;

		private static TextMeshProUGUI _xpLevel;

		private static TextMeshProUGUI _profit;

		private static GameObject skillTreeButton;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		private static void QuickMenuXPBar(QuickMenuManager __instance)
		{
			if (__instance.isMenuOpen)
			{
				if (!Object.op_Implicit((Object)(object)_xpBar) || !Object.op_Implicit((Object)(object)_xpBarProgress))
				{
					MakeNewXPBar();
				}
				_xpBar.SetActive(true);
				_xpBarProgress.SetActive(true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "Update")]
		private static void XPMenuUpdate(QuickMenuManager __instance)
		{
			if (Object.op_Implicit((Object)(object)_xpInfoContainer) && Object.op_Implicit((Object)(object)_xpBar) && Object.op_Implicit((Object)(object)_xpBarProgress))
			{
				LC_XP xpInstance = LP_NetworkManager.xpInstance;
				bool activeSelf = __instance.mainButtonsPanel.activeSelf;
				_xpInfoContainer.SetActive(activeSelf);
				((TMP_Text)_xpText).text = xpInstance.GetXP() + " / " + xpInstance.teamXPRequired.Value;
				((TMP_Text)_xpLevel).text = "Level: " + xpInstance.GetLevel();
				((TMP_Text)_profit).text = "You've made.. " + xpInstance.GetProfit() + "$";
				_xpBarProgress.GetComponent<Image>().fillAmount = (float)xpInstance.GetXP() / (float)xpInstance.teamXPRequired.Value;
			}
		}

		public static void MakeNewXPBar()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0068: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/QuickMenu");
			GameObject val2 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/Total");
			if (!Object.op_Implicit((Object)(object)_xpInfoContainer))
			{
				_xpInfoContainer = new GameObject("XpInfoContainer");
				_xpInfoContainer.transform.SetParent(val.transform, false);
				_xpInfoContainer.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
				_xpInfoContainer.transform.Translate(-1.7f, 0.9f, 0f);
			}
			if (!Object.op_Implicit((Object)(object)_xpBar))
			{
				GameObject val3 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpBox");
				_xpBar = Object.Instantiate<GameObject>(val3);
				_xpBar.transform.SetParent(_xpInfoContainer.transform, false);
				((Object)_xpBar).name = "XPBar";
				_xpText = Object.Instantiate<GameObject>(val2).GetComponent<TextMeshProUGUI>();
				((TMP_Text)_xpText).transform.SetParent(_xpBar.transform, false);
				((TMP_Text)_xpText).transform.Translate(-0.75f, 0.21f, 0f);
				((Object)_xpText).name = "XPText";
				((TMP_Text)_xpText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_xpText).SetText("0/1000", true);
				((Graphic)_xpText).color = new Color(1f, 0.6f, 0f, 1f);
				_xpLevel = Object.Instantiate<GameObject>(val2).GetComponent<TextMeshProUGUI>();
				((TMP_Text)_xpLevel).transform.SetParent(_xpInfoContainer.transform, false);
				((TMP_Text)_xpLevel).transform.position = new Vector3(_xpBar.transform.position.x, _xpBar.transform.position.y, _xpBar.transform.position.z);
				((TMP_Text)_xpLevel).transform.Translate(-0.3f, 0.2f, 0f);
				((Object)_xpLevel).name = "XPLevel";
				((TMP_Text)_xpLevel).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_xpLevel).SetText("Level: 0", true);
				((Graphic)_xpLevel).color = new Color(1f, 0.6f, 0f, 1f);
				_profit = Object.Instantiate<GameObject>(val2).GetComponent<TextMeshProUGUI>();
				((TMP_Text)_profit).transform.SetParent(_xpInfoContainer.transform, false);
				((TMP_Text)_profit).transform.position = new Vector3(_xpBar.transform.position.x, _xpBar.transform.position.y, _xpBar.transform.position.z);
				((TMP_Text)_profit).transform.Translate(-0.1f, -0.2f, 0f);
				((Object)_profit).name = "XPProfit";
				((TMP_Text)_profit).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_profit).SetText("You've made.. 0$.", true);
				((Graphic)_profit).color = new Color(1f, 0.6f, 0f, 1f);
			}
			if (!Object.op_Implicit((Object)(object)_xpBarProgress))
			{
				GameObject val4 = GameObject.Find("/Systems/UI/Canvas/EndgameStats/LevelUp/LevelUpMeter");
				_xpBarProgress = Object.Instantiate<GameObject>(val4);
				_xpBarProgress.transform.SetParent(_xpBar.transform, false);
				_xpBarProgress.transform.SetAsFirstSibling();
				_xpBarProgress.transform.localScale = new Vector3(0.597f, 5.21f, 1f);
				_xpBarProgress.transform.Translate(-0.8f, 0.2f, 0f);
				_xpBarProgress.transform.localPosition = new Vector3(0f, 0f, 0f);
				((Object)_xpBarProgress).name = "XPBarProgress";
				_xpBarProgress.GetComponent<Image>().fillAmount = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		private static void SkillTreeAwake(QuickMenuManager __instance)
		{
			if (__instance.isMenuOpen && !Object.op_Implicit((Object)(object)skillTreeButton))
			{
				MakeSkillTreeButton();
			}
		}

		private static void MakeSkillTreeButton()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			GameObject val = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons/Resume");
			skillTreeButton = Object.Instantiate<GameObject>(val);
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/QuickMenu/MainButtons");
			skillTreeButton.transform.SetParent(val2.transform, false);
			skillTreeButton.transform.position = new Vector3(0.55f + _xpBar.transform.position.x, 1.09f + _xpBar.transform.position.y, _xpBar.transform.position.z);
			((Object)skillTreeButton).name = "Skills";
			((TMP_Text)skillTreeButton.GetComponentInChildren<TextMeshProUGUI>()).text = "> Skills";
			Transform transform = ((TMP_Text)_xpText).transform;
			skillTreeButton.transform.localPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z);
			Transform transform2 = skillTreeButton.transform;
			transform2.position += new Vector3(-0.15f, 1.056f);
			ButtonClickedEvent val3 = new ButtonClickedEvent();
			object obj = <>O.<0>__OpenSkillTree;
			if (obj == null)
			{
				UnityAction val4 = OpenSkillTree;
				<>O.<0>__OpenSkillTree = val4;
				obj = (object)val4;
			}
			((UnityEvent)val3).AddListener((UnityAction)obj);
			skillTreeButton.GetComponent<Button>().onClick = val3;
			Button component = _xpBar.GetComponent<Button>();
			if (component == null)
			{
				component = _xpBar.AddComponent<Button>();
				component.onClick = val3;
			}
			component = _xpBarProgress.GetComponent<Button>();
			if (component == null)
			{
				component = _xpBarProgress.AddComponent<Button>();
				component.onClick = val3;
			}
		}

		private static void OpenSkillTree()
		{
			LP_NetworkManager.xpInstance.guiObj.OpenSkillMenu();
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "ResetMiscValues")]
		private static void ResetMiscValues_PrePatch()
		{
			JumpHeight.JumpHeightUpdate(0);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		private static void OnShipLandedMiscEvents_PrePatch()
		{
			JumpHeight.JumpHeightUpdate(0);
		}
	}
	[HarmonyPatch]
	internal class XPPatches : NetworkBehaviour
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "FirePlayersAfterDeadlineClientRpc")]
		private static void ResetXPValues(StartOfRound __instance)
		{
			if (bool.Parse(SkillConfig.hostConfig["Conservé la progression"]))
			{
				return;
			}
			LC_XP xpInstance = LP_NetworkManager.xpInstance;
			int saveFileSlot = GameNetworkManager.Instance.saveFileNum + 1;
			SaveManager.DeleteSave(saveFileSlot);
			xpInstance.teamXPRequired.Value = xpInstance.CalculateXPRequirement();
			foreach (Skill value in xpInstance.skillList.skills.Values)
			{
				value.SetLevel(0);
			}
			xpInstance.SetSkillPoints(int.Parse(SkillConfig.hostConfig["Point(s) de Statistiques Initial"]));
			xpInstance.teamXP.Value = 0;
			xpInstance.teamTotalValue.Value = 0;
			xpInstance.teamLevel.Value = 0;
			xpInstance.teamLootLevel.Value = 0;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
		private static void DisconnectXPHandler()
		{
			if (LP_NetworkManager.xpInstance.skillList.GetSkill(UpgradeType.Value).GetLevel() != 0)
			{
				int level = LP_NetworkManager.xpInstance.skillList.skills[UpgradeType.Value].GetLevel();
				LP_NetworkManager.xpInstance.updateTeamLootLevelClientMessage.SendServer(-level);
			}
			SprintSpeed.sprintSpeed = 2.25f;
			HandSlots.currentSlotCount = 4;
			GUIUpdate.isMenuOpen = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "C