Decompiled source of PouetHunterGame v1.0.1

PouetHunterGame.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using PouetHunterGame.Object;
using PouetHunterGame.Useful;
using TMPro;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PouetHunterGame")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PouetHunterGame")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4bfd40e1-a03f-48d7-9539-7b383e562621")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PouetHunterGame
{
	[BepInPlugin("Xelan.PouetHunterGame", "PouetHunterGame", "1.0.0")]
	public class PouetHunterGame : BaseUnityPlugin
	{
		private const string modGUID = "Xelan.PouetHunterGame";

		private const string modName = "PouetHunterGame";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Xelan.PouetHunterGame");

		private static PouetHunterGame Instance;

		public static ManualLogSource Logger;

		public static ConfigEntry<bool> SpawnJetpack;

		public static ConfigEntry<bool> SpawnBeltbagForHunters;

		public static ConfigEntry<bool> SpawnMapperForHunters;

		public static ConfigEntry<bool> DisplayNewHunterName;

		public static ConfigEntry<bool> CanChosenScrapBeTwoHanded;

		public static ConfigEntry<bool> MonstersInside;

		public static ConfigEntry<bool> MonstersOutside;

		public static ConfigEntry<int> ShotgunAmount;

		public static ConfigEntry<int> AmmoAmount;

		public static ConfigEntry<int> StartingHour;

		public static ConfigEntry<int> EndingHour;

		public static ConfigEntry<int> TotalRounds;

		public static ConfigEntry<int> NbScraps;

		public static PlayerControllerB[] players;

		public static HashSet<PlayerControllerB> hunters = new HashSet<PlayerControllerB>();

		public static HashSet<ulong> welcomedPlayers = new HashSet<ulong>();

		public static HashSet<GrabbableObject> AlreadyCollectedScraps = new HashSet<GrabbableObject>();

		public static Dictionary<string, int> WinsAsHunter = new Dictionary<string, int>();

		public static Dictionary<string, int> WinsAsPouet = new Dictionary<string, int>();

		public static Dictionary<string, string> playersColor = new Dictionary<string, string>();

		public static string scrapChosenName;

		public static int numRound = 1;

		public static bool HuntersWon = true;

		public static bool GameAlreadyOver = false;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("Xelan.PouetHunterGame");
			Logger.LogInfo((object)"╔═══════════════════════════════════════════════╗");
			Logger.LogInfo((object)"║            PouetHunterGame is UP !            ║");
			Logger.LogInfo((object)"╚═══════════════════════════════════════════════╝");
			LoadConfig();
			harmony.PatchAll();
		}

		private void LoadConfig()
		{
			SpawnJetpack = Bind("Paramètre de la partie", "Jetpack", defaultValue: false, "Fait apparaître des Jetpack pour chaque joueur au début de la partie");
			StartingHour = Bind("Paramètre de la partie", "Heure de départ", 9, "Heure à partir de laquelle les Pouets ne peuvent plus sortir de la Facility sans l'objet recherché");
			EndingHour = Bind("Paramètre de la partie", "Heure de fin", 24, "Heure à partir de laquelle la partie se termine");
			TotalRounds = Bind("Paramètre de la partie", "Nombre de manche", 5, "Nombre de manche dans la partie (1 Manche = 1 Jour)");
			NbScraps = Bind("Paramètre de la partie", "Nombre de Scraps", 3, "Nombre de Scraps permettant de devenir Hunter");
			CanChosenScrapBeTwoHanded = Bind("Paramètre de la partie", "Scraps à 2 mains", defaultValue: true, "Est-ce que l'objet à récupérer peut être un objet à 2 mains ?");
			MonstersInside = Bind("Paramètre de la partie", "Monstres Interieur", defaultValue: true, "Est-ce que les monstres apparaissent à l'intérieur ?");
			MonstersOutside = Bind("Paramètre de la partie", "Monstres Exterieur", defaultValue: true, "Est-ce que les monstres apparaissent à l'extérieur ?");
			ShotgunAmount = Bind("Paramètre des Hunters", "Nombre de Shotgun", 1, "Nombre de Shotgun à faire apparaître pour les Hunters");
			AmmoAmount = Bind("Paramètre des Hunters", "Nombre de Munition", 8, "Nombre de Munition à faire apparaître pour les Hunters");
			SpawnBeltbagForHunters = Bind("Paramètre des Hunters", "Beltbag", defaultValue: false, "Fait apparaître des Beltbags pour les Hunters");
			SpawnMapperForHunters = Bind("Paramètre des Hunters", "Mapper", defaultValue: false, "Fait apparaître des Mappers pour les Hunters 2h avant la fin du temps");
			DisplayNewHunterName = Bind("Paramètre des Hunters", "Afficher nouveau Hunter", defaultValue: false, "Lorsque quelqu'un devient Hunter, affiche son nom via Transmit");
			CreateIntConfig(StartingHour, 9, 23);
			CreateIntConfig(EndingHour, 12, 24);
			CreateIntConfig(TotalRounds, 1, 10);
			CreateIntConfig(NbScraps, 1, 10);
			CreateIntConfig(ShotgunAmount, 0, 5);
			CreateIntConfig(AmmoAmount, 0, 20);
		}

		private ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
		{
			return ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}

		private void CreateIntConfig(ConfigEntry<int> configEntry, int min = 0, int max = 100)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = min;
			((BaseRangeOptions<int>)val).Max = max;
			((BaseOptions)val).RequiresRestart = false;
			IntSliderConfigItem val2 = new IntSliderConfigItem(configEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}
	}
}
namespace PouetHunterGame.Useful
{
	internal class ColorManager
	{
		private static readonly Regex HexColorRegex = new Regex("^#([0-9a-fA-F]{6})$", RegexOptions.Compiled);

		public static string GetRandomHexColor()
		{
			Random random = new Random();
			int num = random.Next(256);
			int num2 = random.Next(256);
			int num3 = random.Next(256);
			return $"#{num:X2}{num2:X2}{num3:X2}";
		}

		public static string GetPlayerColor(PlayerControllerB player)
		{
			return PouetHunterGame.playersColor.ContainsKey(player.playerUsername) ? PouetHunterGame.playersColor[player.playerUsername] : "white";
		}

		public static string SetNewColorForPlayer(PlayerControllerB player, string newColor)
		{
			string text = PouetHunterGame.playersColor[player.playerUsername];
			if (CouleursToHEX.CouleursHEX.TryGetValue(newColor.ToLower(), out var value))
			{
				text = value;
			}
			else if (HexColorRegex.IsMatch(newColor))
			{
				text = newColor;
			}
			PouetHunterGame.playersColor[player.playerUsername] = text;
			return text;
		}
	}
	internal class GameOverManager
	{
		public static bool IsGameOver()
		{
			if (!TimeOfDay.Instance.timeHasStarted)
			{
				return false;
			}
			bool allPlayersDead = StartOfRound.Instance.allPlayersDead;
			bool flag = TimeOfDay.Instance.hour >= GameUtils.GetValidHour(PouetHunterGame.EndingHour.Value, 12, 24);
			if (allPlayersDead || flag || (!IsThereAChoosenScrapLeftInside() && AllHuntersAreDead() && !IsThereAChoosenScrapBeingHeldOutside()))
			{
				PouetHunterGame.HuntersWon = false;
				return true;
			}
			if (AllPouetsAreDead())
			{
				return true;
			}
			if (OnlyOnePlayerRemain())
			{
				PouetHunterGame.HuntersWon = false;
				return true;
			}
			return false;
		}

		public static bool AllHuntersAreDead()
		{
			return PouetHunterGame.hunters.All((PlayerControllerB x) => x.isPlayerDead);
		}

		public static bool AllPouetsAreDead()
		{
			return PouetHunterGame.players.Where((PlayerControllerB x) => !x.isPlayerDead).All((PlayerControllerB x) => PouetHunterGame.hunters.Contains(x));
		}

		public static bool OnlyOnePlayerRemain()
		{
			return PouetHunterGame.players.Count((PlayerControllerB x) => !x.isPlayerDead) == 1;
		}

		public static bool IsThereAChoosenScrapLeftInside()
		{
			List<GrabbableObject> list = (from x in Object.FindObjectsOfType<GrabbableObject>()
				where x.itemProperties.itemName.Equals(PouetHunterGame.scrapChosenName) && x.isInFactory
				select x).ToList();
			return list.Count != 0;
		}

		public static bool IsThereAChoosenScrapBeingHeldOutside()
		{
			List<GrabbableObject> list = (from x in Object.FindObjectsOfType<GrabbableObject>()
				where x.itemProperties.itemName.Equals(PouetHunterGame.scrapChosenName) && !x.isInFactory && x.isHeld
				select x).ToList();
			return list.Count != 0;
		}

		public static void DisplaysWinners()
		{
			Dictionary<PlayerControllerB, int> dictionary = new Dictionary<PlayerControllerB, int>();
			PlayerControllerB[] players = PouetHunterGame.players;
			foreach (PlayerControllerB val in players)
			{
				string playerUsername = val.playerUsername;
				int num = (PouetHunterGame.WinsAsHunter.ContainsKey(playerUsername) ? PouetHunterGame.WinsAsHunter[playerUsername] : 0);
				int num2 = (PouetHunterGame.WinsAsPouet.ContainsKey(playerUsername) ? PouetHunterGame.WinsAsPouet[playerUsername] : 0);
				dictionary[val] = num + num2;
			}
			int maxWins = dictionary.Values.Max();
			List<PlayerControllerB> list = (from x in dictionary
				where x.Value == maxWins
				select x.Key).ToList();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("<color=white>[</color><color=#FFC000>Partie Terminée</color><color=white>]</color>\n");
			if (list.Count > 1)
			{
				stringBuilder.Append("<color=#FFC000>Gagnants :</color>\n");
			}
			else
			{
				stringBuilder.Append("<color=#FFC000>Gagnant :</color>\n");
			}
			foreach (PlayerControllerB item in list)
			{
				stringBuilder.Append("<color=" + ColorManager.GetPlayerColor(item) + ">" + item.playerUsername + "</color>\n");
			}
			HUDManager.Instance.AddTextToChatOnServer(stringBuilder.ToString(), -1);
		}

		public static IEnumerator KillRemainingPlayerWithDelay()
		{
			yield return (object)new WaitForSeconds(5f);
			foreach (PlayerControllerB player in PouetHunterGame.players.Where((PlayerControllerB x) => !x.isPlayerDead))
			{
				player.DamagePlayerFromOtherClientServerRpc(200, Vector3.zero, 0);
				PouetHunterGame.Logger.LogInfo((object)("Killing " + player.playerUsername + " as he was still ALIVE"));
			}
		}
	}
	internal class GameUtils
	{
		public static void DisplayTip(string title, string msg, bool isWarning = false)
		{
			HUDManager.Instance.DisplayTip(title, msg, isWarning, false, "LC_Tip1");
		}

		public static void ClearChat()
		{
			HUDManager instance = HUDManager.Instance;
			if (instance != null)
			{
				for (int i = 0; i < 3; i++)
				{
					instance.AddTextToChatOnServer("\u00a0", -1);
					instance.AddTextToChatOnServer("\u00a0\u00a0", -1);
				}
			}
		}

		public static bool IsPlayerHolding(PlayerControllerB player, string scrapName)
		{
			return player.ItemSlots.Where((GrabbableObject scrap) => (Object)(object)scrap != (Object)null).Any((GrabbableObject scrap) => string.Equals(scrap.itemProperties.itemName, scrapName, StringComparison.OrdinalIgnoreCase));
		}

		public static int GetValidHour(int hour, int min, int max)
		{
			if (hour < min)
			{
				return min - 6;
			}
			if (hour > max)
			{
				return max - 6;
			}
			return hour - 6;
		}

		public static void ResetRound()
		{
			PouetHunterGame.hunters.Clear();
			PouetHunterGame.HuntersWon = true;
			PouetHunterGame.GameAlreadyOver = false;
			PouetHunterGame.AlreadyCollectedScraps.Clear();
		}

		public static void ResetGame(bool resetWelcomePlayer = true)
		{
			if (resetWelcomePlayer)
			{
				PouetHunterGame.welcomedPlayers.Clear();
				PouetHunterGame.playersColor.Clear();
			}
			PouetHunterGame.WinsAsHunter.Clear();
			PouetHunterGame.WinsAsPouet.Clear();
			PouetHunterGame.numRound = 1;
			ResetRound();
			PouetHunterGame.Logger.LogInfo((object)"The Game has been reset");
		}

		public static void UnlockAllDoors()
		{
			IEnumerable<DoorLock> enumerable = from x in Object.FindObjectsOfType<DoorLock>()
				where x.isLocked
				select x;
			int num = 0;
			foreach (DoorLock item in enumerable)
			{
				item.UnlockDoorSyncWithServer();
				num++;
			}
			PouetHunterGame.Logger.LogInfo((object)(num + " doors have been Unlocked"));
		}

		public static void DisplayScoreBoard()
		{
			HUDManager instance = HUDManager.Instance;
			if (instance != null)
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("<color=white>[</color><color=#FFC000>Scoreboard</color><color=white>]</color>\n");
				PlayerControllerB[] players = PouetHunterGame.players;
				foreach (PlayerControllerB val in players)
				{
					string playerUsername = val.playerUsername;
					int num = (PouetHunterGame.WinsAsHunter.ContainsKey(playerUsername) ? PouetHunterGame.WinsAsHunter[playerUsername] : 0);
					int num2 = (PouetHunterGame.WinsAsPouet.ContainsKey(playerUsername) ? PouetHunterGame.WinsAsPouet[playerUsername] : 0);
					stringBuilder.Append($"<color={ColorManager.GetPlayerColor(val)}>{playerUsername}</color><color=white> : {num}</color><color=#FF0000>H</color><color=white> | {num2}</color><color=#D86ECC>P</color>\n");
				}
				instance.AddTextToChatOnServer(stringBuilder.ToString(), -1);
			}
		}

		public static void DisplayBeginingRoundMessage()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("<color=white>[</color><color=#D86ECC>Pouet</color><color=#FF0000>Hunter</color><color=#FFC000>Game</color><color=white>]\n");
			stringBuilder.Append($"<color=white>[</color><color=#FFC000>Manche {PouetHunterGame.numRound}/{PouetHunterGame.TotalRounds.Value}</color><color=white>]</color>\n");
			stringBuilder.Append("Scrap à trouver :</color><color=#24A5FC>\n" + PouetHunterGame.scrapChosenName + "</color>\n");
			stringBuilder.Append("<color=white>Nombre :</color><color=#24A5FC>\n" + PouetHunterGame.NbScraps.Value + "</color>\n");
			stringBuilder.Append("<color=white>Heure Début-Fin :</color>\n<color=#24A5FC>" + PouetHunterGame.StartingHour.Value + "H</color><color=white> - </color><color=#24A5FC>" + PouetHunterGame.EndingHour.Value + "H</color>");
			HUDManager.Instance.AddTextToChatOnServer(stringBuilder.ToString(), -1);
		}

		public static void UnlockAllSuitsAndSignalTranslator()
		{
			int[] array = new int[8] { 0, 1, 2, 3, 17, 24, 25, 26 };
			int[] array2 = array;
			foreach (int num in array2)
			{
				UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables[num];
				if (!val.alreadyUnlocked)
				{
					StartOfRound.Instance.BuyShipUnlockableServerRpc(num, Object.FindObjectOfType<Terminal>().groupCredits);
					PouetHunterGame.Logger.LogInfo((object)(val.unlockableName + " has been unlock"));
				}
			}
		}

		public static void HideShipObjectWithID(int id, Vector3 position)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			PlaceableShipObject val = ((IEnumerable<PlaceableShipObject>)Object.FindObjectsOfType<PlaceableShipObject>()).FirstOrDefault((Func<PlaceableShipObject, bool>)((PlaceableShipObject x) => x.unlockableID == id));
			if (val == null)
			{
				PouetHunterGame.Logger.LogError((object)"Object not found");
				return;
			}
			if (val.parentObject == null)
			{
				PouetHunterGame.Logger.LogError((object)"Object Parent is null");
				return;
			}
			NetworkObjectReference val2 = NetworkObjectReference.op_Implicit(((Component)val.parentObject).GetComponent<NetworkObject>());
			ShipBuildModeManager instance = ShipBuildModeManager.Instance;
			Quaternion rotation = ((Component)val).transform.rotation;
			instance.PlaceShipObject(position, ((Quaternion)(ref rotation)).eulerAngles, val, false);
			ShipBuildModeManager instance2 = ShipBuildModeManager.Instance;
			rotation = ((Component)val).transform.rotation;
			instance2.PlaceShipObjectServerRpc(position, ((Quaternion)(ref rotation)).eulerAngles, val2, 0);
			PouetHunterGame.Logger.LogInfo((object)$"Object {id} hidden at {((Component)val).transform.position}");
		}

		public static void ChangeStartingDeadline(int newDeadLine)
		{
			TimeOfDay instance = TimeOfDay.Instance;
			instance.quotaVariables.deadlineDaysAmount = newDeadLine;
			instance.timeUntilDeadline = (float)(instance.quotaVariables.deadlineDaysAmount + newDeadLine) * instance.totalTime;
			TimeOfDay.Instance.timeUntilDeadline = (int)(TimeOfDay.Instance.totalTime * (float)TimeOfDay.Instance.quotaVariables.deadlineDaysAmount);
			TimeOfDay.Instance.SyncTimeClientRpc(instance.globalTime, (int)instance.timeUntilDeadline);
			((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n " + PouetHunterGame.TotalRounds.Value + " Days";
		}

		public static TerminalNode CreateTerminalNode(string message, bool clearPreviousText = true, int maxChar = 50)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = message;
			val.clearPreviousText = clearPreviousText;
			val.maxCharactersToType = maxChar;
			return val;
		}
	}
	internal class ScrapSpawningManager
	{
		private static readonly HashSet<string> blacklistedChoosenScraps = new HashSet<string> { "clown horn", "shotgun" };

		public static void SpawnHunterEquipment(PlayerControllerB player, int shotgunAmount = 1, int ammoAmount = 2)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (player == null || player.isPlayerDead)
			{
				return;
			}
			Vector3 spawnPosition = default(Vector3);
			((Vector3)(ref spawnPosition))..ctor(4f, 5f, -14f);
			List<ObjectToSpawn> list = new List<ObjectToSpawn>
			{
				new ObjectToSpawn(59, 1.15f, 0, shotgunAmount),
				new ObjectToSpawn(60, 1f, 0, ammoAmount)
			};
			if (PouetHunterGame.SpawnBeltbagForHunters.Value)
			{
				list.Add(new ObjectToSpawn(79, 1.15f, 0, 1));
			}
			if (PouetHunterGame.SpawnMapperForHunters.Value && TimeOfDay.Instance.hour + 6 >= PouetHunterGame.EndingHour.Value - 2)
			{
				list.Add(new ObjectToSpawn(8, 1f, 0, 1));
			}
			foreach (ObjectToSpawn item in list)
			{
				SpawnObject(item, spawnPosition);
			}
		}

		public static void SpawnPouetsEquipment()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Vector3 spawnPosition = default(Vector3);
			((Vector3)(ref spawnPosition))..ctor(4f, 5f, -14f);
			int amount = PouetHunterGame.players.Length;
			SpawnObject(new ObjectToSpawn(25, 1f, 0, amount), spawnPosition);
			if (PouetHunterGame.SpawnJetpack.Value)
			{
				SpawnObject(new ObjectToSpawn(4, 1.5f, 0, amount), spawnPosition);
			}
		}

		public static void SpawnObject(ObjectToSpawn o, Vector3 spawnPosition)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < o.Amount; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[o.Index].spawnPrefab, spawnPosition, Quaternion.identity);
				ScanNodeProperties val2 = val.GetComponent<ScanNodeProperties>() ?? val.AddComponent<ScanNodeProperties>();
				val2.scrapValue = o.Value;
				val2.subText = $"Value: ${o.Value}";
				GrabbableObject component = val.GetComponent<GrabbableObject>();
				component.fallTime = 0f;
				component.scrapValue = o.Value;
				if (o.Weight != -1f)
				{
					component.itemProperties.weight = o.Weight;
				}
				component.itemProperties.creditsWorth = o.Value;
				component.SetScrapValue(o.Value);
				val.GetComponent<NetworkObject>().Spawn(false);
				ManualLogSource logger = PouetHunterGame.Logger;
				string itemName = val.gameObject.GetComponent<GrabbableObject>().itemProperties.itemName;
				Vector3 val3 = spawnPosition;
				logger.LogInfo((object)("Spawning scrap " + itemName + " at " + ((object)(Vector3)(ref val3)).ToString()));
			}
		}

		public static void DespawnScrapsInShip(bool despawnEverything = true, string scrapName = "")
		{
			StartOfRound instance = StartOfRound.Instance;
			object obj2;
			if (instance == null)
			{
				obj2 = null;
			}
			else
			{
				Transform elevatorTransform = instance.elevatorTransform;
				obj2 = ((elevatorTransform != null) ? ((Component)elevatorTransform).gameObject : null);
			}
			GameObject val = (GameObject)obj2;
			if (val == null)
			{
				PouetHunterGame.Logger.LogError((object)"Ship not found");
				return;
			}
			List<GrabbableObject> list = (from obj in val.GetComponentsInChildren<GrabbableObject>()
				where !(obj is RagdollGrabbableObject) && !obj.isHeld
				select obj).ToList();
			foreach (GrabbableObject item in list)
			{
				if (despawnEverything || item.itemProperties.itemName.Equals(scrapName))
				{
					DespawnScraps(item);
				}
			}
		}

		public static void DespawnScraps(GrabbableObject scrapToDespawn)
		{
			NetworkObject component = ((Component)scrapToDespawn).gameObject.GetComponent<NetworkObject>();
			if ((Object)(object)component != (Object)null && component.IsSpawned && !scrapToDespawn.isHeld)
			{
				PouetHunterGame.Logger.LogInfo((object)("Despawning scrap : " + scrapToDespawn.itemProperties.itemName));
				Object.Destroy((Object)(object)((Component)scrapToDespawn).gameObject);
			}
		}

		public static void DespawnAllScrapsRemaining()
		{
			List<GrabbableObject> list = (from obj in Object.FindObjectsOfType<GrabbableObject>()
				where !(obj is RagdollGrabbableObject) && !obj.isHeld
				select obj).ToList();
			foreach (GrabbableObject item in list)
			{
				DespawnScraps(item);
			}
		}

		public static void SpawnMapperForHunters()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			foreach (PlayerControllerB item in PouetHunterGame.hunters.Where((PlayerControllerB x) => !x.isPlayerDead))
			{
				Vector3 position = ((Component)item).transform.position;
				SpawnObject(new ObjectToSpawn(8, 1f, 0, 1), position);
				PouetHunterGame.Logger.LogInfo((object)$"Spawning Mapper for {item.playerUsername} at {position}");
			}
		}

		public static void SelectAndSpawnChosenScraps()
		{
			SelectChosenScrap();
			SpawnChosenScrap();
			PouetHunterGame.Logger.LogInfo((object)$"Spawning {PouetHunterGame.NbScraps.Value} {PouetHunterGame.scrapChosenName}");
		}

		public static void SelectChosenScrap()
		{
			HashSet<string> allScrapsInLevel = (from x in Object.FindObjectsOfType<GrabbableObject>()
				where x.isInFactory && x.itemProperties.isScrap
				select x.itemProperties.itemName.ToLower()).ToHashSet();
			List<string> list = (from x in StartOfRound.Instance.allItemsList.itemsList
				where !allScrapsInLevel.Contains(x.itemName.ToLower()) && x.isScrap && !IsBlacklistedScrap(x.itemName) && AllowTwoHanded(x)
				select x.itemName).ToList();
			PouetHunterGame.scrapChosenName = list[Random.Range(0, list.Count)];
		}

		public static void SpawnChosenScrap()
		{
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			RoundManager instance = RoundManager.Instance;
			Item val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item x) => x.itemName.Equals(PouetHunterGame.scrapChosenName, StringComparison.OrdinalIgnoreCase)));
			if (val == null)
			{
				PouetHunterGame.Logger.LogError((object)(PouetHunterGame.scrapChosenName + " not found in itemsList"));
				return;
			}
			List<RandomScrapSpawn> list = (from spawn in Object.FindObjectsOfType<RandomScrapSpawn>()
				where !spawn.spawnUsed
				select spawn).ToList();
			Random anomalyRandom = instance.AnomalyRandom;
			List<NetworkObjectReference> list2 = new List<NetworkObjectReference>();
			List<int> list3 = new List<int>();
			for (int i = 0; i < PouetHunterGame.NbScraps.Value; i++)
			{
				if (list.Count == 0)
				{
					PouetHunterGame.Logger.LogError((object)"No Spawnpoint available");
					break;
				}
				RandomScrapSpawn val2 = list[anomalyRandom.Next(list.Count)];
				list.Remove(val2);
				val2.spawnUsed = true;
				Vector3 val3 = (val2.spawnedItemsCopyPosition ? ((Component)val2).transform.position : (instance.GetRandomNavMeshPositionInBoxPredictable(((Component)val2).transform.position, val2.itemSpawnRange, instance.navHit, anomalyRandom, -1, 1f) + Vector3.up * val.verticalOffset));
				GameObject val4 = Object.Instantiate<GameObject>(val.spawnPrefab, val3, Quaternion.identity, instance.spawnedScrapContainer);
				GrabbableObject component = val4.GetComponent<GrabbableObject>();
				((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
				component.fallTime = 0f;
				int item = (component.scrapValue = anomalyRandom.Next(val.minValue, val.maxValue));
				NetworkObject component2 = val4.GetComponent<NetworkObject>();
				component2.Spawn(false);
				list2.Add(NetworkObjectReference.op_Implicit(component2));
				list3.Add(item);
			}
			((MonoBehaviour)instance).StartCoroutine(WaitForChosenScrapsToSpawnToSync(list2.ToArray(), list3.ToArray()));
		}

		public static bool IsBlacklistedScrap(string scrapName)
		{
			return blacklistedChoosenScraps.Contains(scrapName.ToLower());
		}

		public static IEnumerator WaitForChosenScrapsToSpawnToSync(NetworkObjectReference[] spawnedScrap, int[] scrapValues)
		{
			yield return (object)new WaitForSeconds(11f);
			RoundManager.Instance.SyncScrapValuesClientRpc(spawnedScrap, scrapValues);
		}

		public static bool AllowTwoHanded(Item item)
		{
			if (item == null)
			{
				return false;
			}
			return PouetHunterGame.CanChosenScrapBeTwoHanded.Value || item.twoHanded;
		}
	}
}
namespace PouetHunterGame.Patches
{
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class CentipedeAIPatch
	{
		[HarmonyPatch("ClingToPlayer")]
		[HarmonyPostfix]
		public static void ClingToPlayer_Postfix(CentipedeAI __instance, PlayerControllerB playerScript)
		{
			__instance.StopClingingServerRpc(false);
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		[HarmonyPatch("SwitchToBehaviourState")]
		[HarmonyPrefix]
		public static bool SwitchToBehaviourState_Prefix(EnemyAI __instance, ref int stateIndex)
		{
			if (__instance is JesterAI && ((NetworkBehaviour)__instance).IsHost)
			{
				stateIndex = 0;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("SteamMatchmaking_OnLobbyCreated")]
		[HarmonyPrefix]
		public static void SteamMatchmaking_OnLobbyCreated_Prefix()
		{
			GameUtils.ResetGame();
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch("OnBroughtToShip")]
		[HarmonyPostfix]
		public static void OnBroughtToShip_Postfix(ref GrabbableObject __instance)
		{
			string itemName = __instance.itemProperties.itemName;
			if (itemName == null || !itemName.Equals(PouetHunterGame.scrapChosenName, StringComparison.OrdinalIgnoreCase))
			{
				return;
			}
			if (PouetHunterGame.AlreadyCollectedScraps.Contains(__instance))
			{
				PouetHunterGame.Logger.LogError((object)"This Scrap has already been collected");
				return;
			}
			PouetHunterGame.AlreadyCollectedScraps.Add(__instance);
			PlayerControllerB playerHeldBy = __instance.playerHeldBy;
			if (playerHeldBy == null)
			{
				PouetHunterGame.Logger.LogError((object)("Nobody is holding : " + __instance.itemProperties.itemName));
				return;
			}
			if (!PouetHunterGame.hunters.Contains(playerHeldBy))
			{
				PouetHunterGame.hunters.Add(playerHeldBy);
				PouetHunterGame.Logger.LogInfo((object)("Adding to hunters : " + playerHeldBy.playerUsername));
				if (!PouetHunterGame.WinsAsHunter.ContainsKey(playerHeldBy.playerUsername))
				{
					PouetHunterGame.WinsAsHunter.Add(playerHeldBy.playerUsername, 1);
				}
				else
				{
					PouetHunterGame.WinsAsHunter[playerHeldBy.playerUsername]++;
				}
				if (PouetHunterGame.DisplayNewHunterName.Value)
				{
					HUDManager.Instance.UseSignalTranslatorServerRpc("H->" + playerHeldBy.playerUsername);
				}
			}
			ScrapSpawningManager.SpawnHunterEquipment(playerHeldBy, PouetHunterGame.ShotgunAmount.Value, PouetHunterGame.AmmoAmount.Value);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("AddTextMessageClientRpc")]
		[HarmonyPrefix]
		public static bool AddTextMessageClientRpc_Prefix(string chatMessage)
		{
			if (chatMessage.Contains("was left behind") || chatMessage.Contains("joined the ship"))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("AddPlayerChatMessageClientRpc")]
		[HarmonyPrefix]
		public static bool AddPlayerChatMessageClientRpc_Prefix(string chatMessage, int playerId)
		{
			Regex regex = new Regex("^/couleur (?<valeurCouleur>.+)$");
			Match match = regex.Match(chatMessage);
			if (match.Success)
			{
				string text = ColorManager.SetNewColorForPlayer(StartOfRound.Instance.allPlayerScripts[playerId], match.Groups["valeurCouleur"].Value);
				PouetHunterGame.Logger.LogInfo((object)(StartOfRound.Instance.allPlayerScripts[playerId].playerUsername + " color is now : " + text));
				return false;
			}
			return true;
		}

		[HarmonyPatch("ApplyPenalty")]
		[HarmonyPrefix]
		public static bool ApplyPenalty_Prefix(int playersDead, int bodiesInsured)
		{
			Terminal val = Object.FindFirstObjectByType<Terminal>();
			if (val == null)
			{
				PouetHunterGame.Logger.LogError((object)"Terminal is null");
				return false;
			}
			val.SyncGroupCreditsServerRpc(100000, 0);
			PouetHunterGame.Logger.LogInfo((object)"Setting new group credits to 100 000");
			return false;
		}
	}
	[HarmonyPatch(typeof(MeteorShowers))]
	internal class MeteorShowersPatch
	{
		[HarmonyPatch("BeginDay")]
		[HarmonyPrefix]
		public static bool BeginDay_Prefix(ref MeteorShowers __instance, float timeOfDay)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			__instance.meteors.Clear();
			HUDManager.Instance.MeteorShowerWarningHUD();
			TimeOfDay.Instance.SetBeginMeteorShowerClientRpc();
			__instance.meteorsEnabled = true;
			return false;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static bool Update_Prefix(MeteorShowers __instance)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			if (!TimeOfDay.Instance.timeHasStarted || !StartOfRound.Instance.shipDoorsEnabled || !__instance.meteorsEnabled)
			{
				return false;
			}
			for (int i = 0; i < PouetHunterGame.players.Length; i++)
			{
				if (__instance.meteors.Count <= 3 && CanBeMeteorited(PouetHunterGame.players[i]))
				{
					Vector3 position = ((Component)PouetHunterGame.players[i]).transform.position;
					Meteor item = new Meteor
					{
						scale = 10f,
						landingPosition = position,
						skyDirection = Vector3.up * 0.1f,
						normalizedLandingTime = Mathf.Clamp(TimeOfDay.Instance.normalizedTimeOfDay, 0f, 0.99f)
					};
					__instance.meteors.Add(item);
					PouetHunterGame.Logger.LogInfo((object)("Summoning Meteor on " + PouetHunterGame.players[i].playerUsername));
					if (__instance.meteors.Count >= 4)
					{
						break;
					}
				}
			}
			foreach (Meteor meteor in __instance.meteors)
			{
				__instance.MeteorUpdate(meteor);
			}
			return false;
		}

		private static bool CanBeMeteorited(PlayerControllerB player)
		{
			return !player.isPlayerDead && !player.isInsideFactory && !PouetHunterGame.hunters.Contains(player) && !GameUtils.IsPlayerHolding(player, PouetHunterGame.scrapChosenName);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("SpawnMapObjects")]
		[HarmonyPostfix]
		public static void SpawnMapObjects_Postfix(RoundManager __instance)
		{
			GameUtils.ResetRound();
			ScrapSpawningManager.SelectAndSpawnChosenScraps();
			GameUtils.ClearChat();
			GameUtils.DisplayBeginingRoundMessage();
			ScrapSpawningManager.SpawnPouetsEquipment();
		}

		[HarmonyPatch("ShowStaticElectricityWarningServerRpc")]
		[HarmonyPrefix]
		public static bool ShowStaticElectricityWarningServerRpc_Prefix(NetworkObjectReference warningObject, float timeLeft)
		{
			return false;
		}

		[HarmonyPatch("LightningStrikeServerRpc")]
		[HarmonyPrefix]
		public static bool LightningStrikeServerRpc_Prefix(Vector3 strikePosition)
		{
			return false;
		}

		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		public static bool LoadNewLevel_Prefix(ref SelectableLevel newLevel)
		{
			if (!PouetHunterGame.MonstersInside.Value)
			{
				foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
				{
					enemy.rarity = 0;
				}
				PouetHunterGame.Logger.LogInfo((object)"Entities Inside removed");
			}
			if (!PouetHunterGame.MonstersOutside.Value)
			{
				foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
				{
					outsideEnemy.rarity = 0;
				}
				PouetHunterGame.Logger.LogInfo((object)"Entities Outside removed");
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("StartTrackingAllPlayerVoices")]
		[HarmonyPostfix]
		public static void StartTrackingAllPlayerVoices_Postfix()
		{
			if (!((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (val.isPlayerControlled && !PouetHunterGame.welcomedPlayers.Contains(val.actualClientId))
				{
					PouetHunterGame.welcomedPlayers.Add(val.actualClientId);
					string randomHexColor = ColorManager.GetRandomHexColor();
					PouetHunterGame.playersColor.Add(val.playerUsername, randomHexColor);
					string text = "<color=white>[</color><color=#D86ECC>Pouet</color><color=#FF0000>Hunter</color><color=#FFC000>Game</color><color=white>] Bienvenue à bord </color><color=" + randomHexColor + ">" + val.playerUsername + "</color><color=white>.</color>";
					HUDManager.Instance.AddTextToChatOnServer(text, -1);
				}
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start_Postfix()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameUtils.UnlockAllSuitsAndSignalTranslator();
			GameUtils.HideShipObjectWithID(17, new Vector3(2f, -5f, -14f));
			GameUtils.ChangeStartingDeadline(PouetHunterGame.TotalRounds.Value);
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPostfix]
		public static void EndOfGame_Postfix(ref StartOfRound __instance, int bodiesInsured = 0, int connectedPlayersOnServer = 0, int scrapCollected = 0)
		{
			ScrapSpawningManager.DespawnAllScrapsRemaining();
			GameUtils.DisplayScoreBoard();
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void Update_Postfix()
		{
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			PouetHunterGame.players = (from x in Object.FindObjectsOfType<PlayerControllerB>()
				where x.isPlayerControlled || x.isPlayerDead
				select x).ToArray();
			if (GameOverManager.IsGameOver() && !PouetHunterGame.GameAlreadyOver)
			{
				GameUtils.ClearChat();
				HUDManager.Instance.AddTextToChatOnServer("<color=white>[</color><color=#FFC000>Manche Terminée</color><color=white>]</color>", -1);
				PouetHunterGame.GameAlreadyOver = true;
				StringBuilder stringBuilder = new StringBuilder();
				if (StartOfRound.Instance.allPlayersDead)
				{
					stringBuilder.Append("<color=#FF0000>Pas de gagnant !</color>");
				}
				else
				{
					TimeOfDay.Instance.SetShipLeaveEarlyClientRpc(TimeOfDay.Instance.normalizedTimeOfDay, 4);
					if (PouetHunterGame.HuntersWon)
					{
						stringBuilder.Append("<color=white>Victoire des </color><color=#FF0000>Hunters</color><color=white>:</color>\n");
						foreach (PlayerControllerB hunter in PouetHunterGame.hunters)
						{
							stringBuilder.Append("<color=" + ColorManager.GetPlayerColor(hunter) + ">" + hunter.playerUsername + "</color>\n");
							if (!hunter.isPlayerDead)
							{
								if (!PouetHunterGame.WinsAsHunter.ContainsKey(hunter.playerUsername))
								{
									PouetHunterGame.WinsAsHunter.Add(hunter.playerUsername, 1);
								}
								else
								{
									PouetHunterGame.WinsAsHunter[hunter.playerUsername]++;
								}
							}
						}
					}
					else
					{
						stringBuilder.Append("<color=white>Victoire des </color><color=#D86ECC>Pouets</color><color=white>:\n");
						foreach (PlayerControllerB item in PouetHunterGame.players.Where((PlayerControllerB x) => !x.isPlayerDead))
						{
							if (!PouetHunterGame.hunters.Contains(item))
							{
								stringBuilder.Append("<color=" + ColorManager.GetPlayerColor(item) + ">" + item.playerUsername + "</color>\n");
								if (!PouetHunterGame.WinsAsPouet.ContainsKey(item.playerUsername))
								{
									PouetHunterGame.WinsAsPouet.Add(item.playerUsername, 1);
								}
								else
								{
									PouetHunterGame.WinsAsPouet[item.playerUsername]++;
								}
							}
						}
					}
				}
				if (!PouetHunterGame.HuntersWon && PouetHunterGame.hunters.Count > 0)
				{
					stringBuilder.Append("<color=white>[</color><color=#FF0000>Hunters</color><color=white>]</color>\n");
					foreach (PlayerControllerB hunter2 in PouetHunterGame.hunters)
					{
						stringBuilder.Append("<color=" + ColorManager.GetPlayerColor(hunter2) + ">" + hunter2.playerUsername + "</color>\n");
					}
				}
				HUDManager.Instance.AddTextToChatOnServer(stringBuilder.ToString(), -1);
				((MonoBehaviour)StartOfRound.Instance).StartCoroutine(GameOverManager.KillRemainingPlayerWithDelay());
			}
			if (!TimeOfDay.Instance.timeHasStarted || TimeOfDay.Instance.hour < GameUtils.GetValidHour(PouetHunterGame.StartingHour.Value, 9, 23))
			{
				return;
			}
			foreach (PlayerControllerB item2 in PouetHunterGame.players.Where((PlayerControllerB x) => !x.isPlayerDead))
			{
				if (!PouetHunterGame.hunters.Contains(item2) && item2.isInsideFactory && !GameUtils.IsPlayerHolding(item2, "Clown horn"))
				{
					PouetHunterGame.Logger.LogInfo((object)("Trying to kill " + item2.playerUsername + " ID : " + item2.actualClientId));
					item2.DamagePlayerFromOtherClientServerRpc(200, Vector3.zero, 0);
				}
			}
		}

		[HarmonyPatch("OnClientDisconnect")]
		[HarmonyPrefix]
		public static void OnClientDisconnect_Prefix(ulong clientId)
		{
			PouetHunterGame.welcomedPlayers.Remove(clientId);
			string text = StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId.Equals(clientId)).First()?.playerUsername;
			if (text != null)
			{
				PouetHunterGame.playersColor.Remove(text);
			}
		}

		[HarmonyPatch("EndGameServerRpc")]
		[HarmonyPrefix]
		public static bool EndGameServerRpc_Prefix(int playerClientId)
		{
			return false;
		}

		[HarmonyPatch("BuyShipUnlockableServerRpc")]
		[HarmonyPrefix]
		public static bool BuyShipUnlockableServerRpc_Prefix(int unlockableID, int newGroupCreditsAmount)
		{
			if (unlockableID == 5)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		public static void ResetShip_Postfix()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameUtils.UnlockAllSuitsAndSignalTranslator();
			GameUtils.HideShipObjectWithID(17, new Vector3(2f, -5f, -14f));
			GameUtils.ClearChat();
			GameOverManager.DisplaysWinners();
			GameUtils.ResetGame(resetWelcomePlayer: false);
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (val == null)
			{
				PouetHunterGame.Logger.LogError((object)"Terminal not found");
				return;
			}
			val.SyncGroupCreditsServerRpc(100000, 0);
			PouetHunterGame.Logger.LogInfo((object)"Setting new group credits to 100 000");
			TimeOfDay.Instance.SyncTimeClientRpc(TimeOfDay.Instance.globalTime, (int)TimeOfDay.Instance.timeUntilDeadline);
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start_Postfix(Terminal __instance, ref TerminalNodesList ___terminalNodes)
		{
			__instance.SyncGroupCreditsServerRpc(100000, 0);
			PouetHunterGame.Logger.LogInfo((object)"Setting new group credits to 100 000");
			int index = 1;
			string displayText = ___terminalNodes.specialNodes[index].displayText;
			string displayText2 = (displayText += "\n[PouetHunterGame]\nEntrez \"phg <nombre>\" pour changer le nombre de manche et recommencer la partie\nEntrez \"phg fin\" pour terminer la partie prématurément\n");
			___terminalNodes.specialNodes[index].displayText = displayText2;
		}

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static bool ParsePlayerSentencePatch(Terminal __instance, ref TerminalNode __result)
		{
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			if (text.Contains("phg fin"))
			{
				StartOfRound.Instance.ResetShip();
				__result = GameUtils.CreateTerminalNode("La partie a été réinitialisée \ud83d\ude01");
				return false;
			}
			Match match = Regex.Match(text, "phg\\s+(-?\\d+)", RegexOptions.IgnoreCase);
			if (match.Success)
			{
				int num = int.Parse(match.Groups[1].Value);
				if (num < 1 || num > 10)
				{
					__result = GameUtils.CreateTerminalNode($"{num} n'est pas une valeur valide.\nVeuillez saisir une valeur entre 1 et 10");
					return false;
				}
				PouetHunterGame.TotalRounds.Value = num;
				GameUtils.ChangeStartingDeadline(PouetHunterGame.TotalRounds.Value);
				StartOfRound.Instance.ResetShip();
				__result = GameUtils.CreateTerminalNode($"Nombre de manche : {PouetHunterGame.TotalRounds.Value}\nPartie réinitialisée !");
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("DecideRandomDayEvents")]
		[HarmonyPrefix]
		public static bool DecideRandomDayEvents_Prefix()
		{
			return false;
		}

		[HarmonyPatch("MoveTimeOfDay")]
		[HarmonyPostfix]
		public static void MoveTimeOfDay_Postfix(TimeOfDay __instance)
		{
			if (__instance.hour >= GameUtils.GetValidHour(PouetHunterGame.StartingHour.Value, 9, 23) && !__instance.MeteorWeather.meteorsEnabled)
			{
				__instance.MeteorWeather.SetStartMeteorShower();
				GameUtils.UnlockAllDoors();
			}
		}

		[HarmonyPatch("SetShipLeaveEarlyServerRpc")]
		[HarmonyPrefix]
		public static bool SetShipLeaveEarlyServerRpc_Prefix()
		{
			return false;
		}

		[HarmonyPatch("OnHourChanged")]
		[HarmonyPrefix]
		public static void OnHourChanged_Prefix(TimeOfDay __instance)
		{
			int num = __instance.hour + 6;
			if (num > 8 && num < PouetHunterGame.EndingHour.Value && num % 4 == 0)
			{
				HUDManager.Instance.UseSignalTranslatorServerRpc($"{num} Heures");
			}
			if (PouetHunterGame.SpawnMapperForHunters.Value && num == PouetHunterGame.EndingHour.Value - 2)
			{
				ScrapSpawningManager.SpawnMapperForHunters();
				HUDManager.Instance.UseSignalTranslatorServerRpc("H->Mapper");
			}
		}

		[HarmonyPatch("OnDayChanged")]
		[HarmonyPostfix]
		public static void OnDayChanged_Postfix(TimeOfDay __instance)
		{
			PouetHunterGame.numRound++;
			if (__instance.daysUntilDeadline == 0)
			{
				if (((NetworkBehaviour)__instance).IsServer)
				{
					GameNetworkManager.Instance.ResetSavedGameValues();
				}
				StartOfRound.Instance.ResetShip();
			}
		}
	}
}
namespace PouetHunterGame.Object
{
	internal class CouleursToHEX
	{
		public static readonly Dictionary<string, string> CouleursHEX = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			{ "rouge", "#FF0000" },
			{ "vert", "#00FF00" },
			{ "bleu", "#0000FF" },
			{ "blanc", "#FFFFFF" },
			{ "noir", "#000000" },
			{ "jaune", "#FFFF00" },
			{ "cyan", "#00FFFF" },
			{ "magenta", "#FF00FF" },
			{ "gris", "#808080" },
			{ "orange", "#FFA500" },
			{ "rose", "#FFC0CB" },
			{ "violet", "#800080" },
			{ "marron", "#A52A2A" },
			{ "turquoise", "#40E0D0" },
			{ "beige", "#F5F5DC" },
			{ "bordeaux", "#800000" },
			{ "lavande", "#E6E6FA" },
			{ "ivoire", "#FFFFF0" },
			{ "sable", "#F4A460" },
			{ "menthe", "#98FF98" },
			{ "pêche", "#FFDAB9" },
			{ "prune", "#DDA0DD" },
			{ "corail", "#FF7F50" },
			{ "indigo", "#4B0082" },
			{ "chocolat", "#D2691E" },
			{ "ardoise", "#708090" },
			{ "abricot", "#FBCEB1" },
			{ "aigue-marine", "#7FFFD4" },
			{ "améthyste", "#9966CC" },
			{ "anthracite", "#293133" },
			{ "azur", "#007FFF" },
			{ "bleu ciel", "#87CEEB" },
			{ "bleu roi", "#002366" },
			{ "carmin", "#960018" },
			{ "cerise", "#DE3163" },
			{ "chartreuse", "#7FFF00" },
			{ "cuivre", "#B87333" },
			{ "émeraude", "#50C878" },
			{ "framboise", "#E30B5C" },
			{ "fuchsia", "#FF00FF" },
			{ "jade", "#00A86B" },
			{ "kaki", "#F0E68C" },
			{ "lavande foncée", "#734F96" },
			{ "lime", "#BFFF00" },
			{ "lin", "#FAF0E6" },
			{ "marine", "#000080" },
			{ "moutarde", "#FFDB58" },
			{ "nacré", "#FDFD96" },
			{ "ocre", "#CC7722" },
			{ "olive", "#808000" },
			{ "or", "#FFD700" },
			{ "perle", "#EAE0C8" },
			{ "rose bonbon", "#FF69B4" },
			{ "rouille", "#B7410E" },
			{ "safran", "#F4C430" },
			{ "saphir", "#0F52BA" },
			{ "saumon", "#FA8072" },
			{ "sépia", "#704214" },
			{ "tomate", "#FF6347" },
			{ "vert forêt", "#228B22" },
			{ "vert pomme", "#8DB600" },
			{ "vert sapin", "#014421" },
			{ "violacé", "#6A5ACD" }
		};
	}
	internal class ObjectToSpawn
	{
		public int Index { get; set; }

		public float Weight { get; set; }

		public int Value { get; set; }

		public int Amount { get; set; }

		public ObjectToSpawn(int index, float weight, int value, int amount)
		{
			Index = index;
			Weight = weight;
			Value = value;
			Amount = amount;
		}
	}
}