Decompiled source of Deep Lethal Galactic v0.5.2

DLGMod.dll

Decompiled 2 days ago
using System;
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 BepInEx;
using BepInEx.Logging;
using DLGMod;
using DLGMod.Patches;
using GameNetcodeStuff;
using HarmonyLib;
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("DLGMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DLGMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bcc02f41-881a-4161-b4d1-19abd8fe6da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class SwarmAllocation : MonoBehaviour
{
	public int[] enemiesTargeting;

	public int maxEnemiesPerPlayer;

	public PlayerControllerB[] players;
}
public class DLGEnemyAI : MonoBehaviour
{
	public enum DLGEnemyType
	{
		EnemyPrefab,
		SwarmEnemy,
		StrongSwarmEnemy,
		CuteUWULootbug
	}

	public DLGEnemyType dLGEnemyType;

	private SwarmAllocation swarmAllocation;

	public EnemyAI enemyAI;

	private float timer = 0f;

	public int targetPlayerIndex = -1;

	private int prevTargetPlayerIndex = -1;

	private GameObject[] allAINodes;

	private Vector3 targetPlayerPosition = Vector3.zero;

	private void Start()
	{
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		if (((Object)((Component)this).gameObject).name.Contains("Swarm"))
		{
			if (((Object)((Component)this).gameObject).name.Contains("Strong"))
			{
				dLGEnemyType = DLGEnemyType.StrongSwarmEnemy;
			}
			else
			{
				dLGEnemyType = DLGEnemyType.SwarmEnemy;
			}
		}
		else
		{
			dLGEnemyType = DLGEnemyType.CuteUWULootbug;
		}
		if (!((Object)((Component)this).gameObject).name.Contains("Clone"))
		{
			dLGEnemyType = DLGEnemyType.EnemyPrefab;
		}
		swarmAllocation = Object.FindObjectOfType<SwarmAllocation>();
		enemyAI = ((Component)this).GetComponent<EnemyAI>();
		allAINodes = enemyAI.allAINodes;
		if (dLGEnemyType == DLGEnemyType.StrongSwarmEnemy)
		{
			enemyAI.enemyHP = 7;
			((Component)enemyAI).gameObject.AddComponent<Light>();
			((Component)enemyAI).gameObject.GetComponent<Light>().color = Color.red;
			((Component)enemyAI).gameObject.GetComponent<Light>().intensity = 15f;
			((Component)enemyAI).gameObject.GetComponent<Light>().range = 15f;
		}
	}

	private void Update()
	{
		//IL_00c1: 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)
		if (dLGEnemyType == DLGEnemyType.EnemyPrefab || enemyAI.currentBehaviourStateIndex == 1 || dLGEnemyType == DLGEnemyType.CuteUWULootbug)
		{
			return;
		}
		timer += Time.deltaTime;
		if (timer < 10f)
		{
			return;
		}
		if (targetPlayerIndex == -1 || enemyAI.currentSearch.unsearchedNodes.Count == 0)
		{
			targetPlayerIndex = CalculateTargetPlayer(targetPlayerIndex);
		}
		if (targetPlayerIndex != -1)
		{
			if (!enemyAI.GetPathDistance(((Component)swarmAllocation.players[targetPlayerIndex]).transform.position, ((Component)this).gameObject.transform.position))
			{
				DLGModMain.logger.LogInfo((object)("Swarm Enemy cannot get to the player: " + swarmAllocation.players[targetPlayerIndex].playerUsername));
				swarmAllocation.enemiesTargeting[targetPlayerIndex]--;
				targetPlayerIndex = -1;
				timer = 0f;
				return;
			}
			DLGModMain.logger.LogInfo((object)("Swarm Enemy is moving towards the player: " + swarmAllocation.players[targetPlayerIndex].playerUsername));
			List<GameObject> list = new List<GameObject>();
			list.Add(((Component)swarmAllocation.players[targetPlayerIndex]).gameObject);
			enemyAI.allAINodes = list.ToArray();
			enemyAI.currentSearch.inProgress = false;
		}
		else if ((enemyAI.currentSearch.unsearchedNodes.Count == 0 && prevTargetPlayerIndex != -1) || (prevTargetPlayerIndex != -1 && !swarmAllocation.players[prevTargetPlayerIndex].isInsideFactory))
		{
			DLGModMain.logger.LogInfo((object)"Swarm Enemy doesnt see any player inside anymore. Switching to default roaming...");
			swarmAllocation.enemiesTargeting[prevTargetPlayerIndex]--;
			enemyAI.allAINodes = allAINodes;
			enemyAI.currentSearch.inProgress = false;
		}
		else
		{
			DLGModMain.logger.LogInfo((object)"...but nobody came");
		}
		prevTargetPlayerIndex = targetPlayerIndex;
		timer = 0f;
	}

	private int CalculateTargetPlayer(int currentTargetPlayer)
	{
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		int result = -1;
		DLGModMain.logger.LogInfo((object)"Swarm Enemy is calculating new target player...");
		for (int i = 0; i < swarmAllocation.players.Length; i++)
		{
			PlayerControllerB val = swarmAllocation.players[i];
			if (val.isPlayerControlled && val.isInsideFactory != enemyAI.enemyType.isOutsideEnemy)
			{
				if (swarmAllocation.enemiesTargeting[i] <= swarmAllocation.maxEnemiesPerPlayer && enemyAI.GetPathDistance(((Component)swarmAllocation.players[i]).transform.position, ((Component)this).gameObject.transform.position))
				{
					result = i;
					if (i != currentTargetPlayer)
					{
						swarmAllocation.enemiesTargeting[i]++;
					}
					break;
				}
			}
			else
			{
				swarmAllocation.enemiesTargeting[i] = 0;
			}
		}
		return result;
	}
}
[HarmonyPatch(typeof(CrawlerAI))]
internal class SwarmCrawlerDamagePatch
{
	[HarmonyPatch("OnCollideWithPlayer")]
	[HarmonyPrefix]
	public static void SetSwarmCrawlerDamage(CrawlerAI __instance, ref Collider other)
	{
		//IL_009a: 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)
		float num = Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue<float>();
		EnemyAI component = ((Component)__instance).GetComponent<EnemyAI>();
		if (!(num < 0.65f))
		{
			int num2 = 5;
			if ((Object)(object)((Component)__instance).GetComponent<DLGEnemyAI>() != (Object)null)
			{
				switch (((Component)__instance).GetComponent<DLGEnemyAI>().dLGEnemyType)
				{
				case DLGEnemyAI.DLGEnemyType.SwarmEnemy:
					num2 = 5;
					break;
				case DLGEnemyAI.DLGEnemyType.StrongSwarmEnemy:
					num2 = 20;
					break;
				}
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				num = 0f;
				val.DamagePlayer(num2, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				component.agent.speed = 0f;
				__instance.HitPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
			}
		}
		Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)num);
	}
}
[HarmonyPatch(typeof(EnemyAI))]
internal class DLGEnemyAIPatch
{
	[HarmonyPatch("KillEnemy")]
	[HarmonyPostfix]
	public static void OnEnemyDied(EnemyAI __instance)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)((Component)__instance).gameObject.GetComponent<DLGEnemyAI>() != (Object)null))
		{
			return;
		}
		if (((Component)__instance).gameObject.GetComponent<DLGEnemyAI>().dLGEnemyType == DLGEnemyAI.DLGEnemyType.CuteUWULootbug)
		{
			DLGModMain.logger.LogError((object)"WHAT HAVE YOU DONE? DID YOU JUST KILL THAT REALLY CUTE LOOTBUG?! YOU SOULLESS BEAST!");
			List<Item> itemsList = Resources.FindObjectsOfTypeAll<AllItemsList>()[0].itemsList;
			int index = itemsList.FindIndex((Item item) => item.itemName == "Gold bar");
			GameObject val = Object.Instantiate<GameObject>(itemsList[index].spawnPrefab, ((Component)__instance).transform.position, default(Quaternion));
			val.GetComponent<GrabbableObject>().fallTime = 0f;
			val.GetComponent<GrabbableObject>().SetScrapValue(Random.Range(100, 200));
			val.GetComponent<NetworkObject>().Spawn(false);
		}
		else
		{
			Object.FindObjectOfType<SwarmAllocation>().enemiesTargeting[((Component)__instance).gameObject.GetComponent<DLGEnemyAI>().targetPlayerIndex]--;
		}
	}
}
namespace DLGMod
{
	[BepInPlugin("XRTG074TheDeveloper.DeepLethalGalactic", "Deep Lethal Galactic", "0.5.2")]
	public class DLGModMain : BaseUnityPlugin
	{
		internal const string GUID = "XRTG074TheDeveloper.DeepLethalGalactic";

		internal readonly Harmony harmonyInstance = new Harmony("XRTG074TheDeveloper.DeepLethalGalactic");

		internal static ManualLogSource logger;

		internal static string filesPath;

		internal static List<AudioClip> swarmSFX;

		internal static int playersAmount;

		private void Awake()
		{
			logger = Logger.CreateLogSource("XRTG074TheDeveloper.DeepLethalGalactic");
			filesPath = ((BaseUnityPlugin)this).Info.Location;
			filesPath = filesPath.TrimEnd("DLGMod.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(filesPath + "\\swarm");
			if ((Object)(object)val != (Object)null)
			{
				swarmSFX = val.LoadAllAssets<AudioClip>().ToList();
			}
			harmonyInstance.PatchAll(typeof(GameControllerPatch));
			harmonyInstance.PatchAll(typeof(AmmunitionPatch));
			harmonyInstance.PatchAll(typeof(ChatCommandsPatch));
			harmonyInstance.PatchAll(typeof(SwarmPatch));
			harmonyInstance.PatchAll(typeof(DLGTipsPatch));
			harmonyInstance.PatchAll(typeof(SpawnAmmunitionPatch));
			harmonyInstance.PatchAll(typeof(PlayerControllerPatch));
			harmonyInstance.PatchAll(typeof(MissionControllerPatch));
			harmonyInstance.PatchAll(typeof(DLGNetStuffSync));
			harmonyInstance.PatchAll(typeof(DLGEnemyAIPatch));
			harmonyInstance.PatchAll(typeof(SwarmCrawlerDamagePatch));
		}

		internal static void SendAmmunition(int _playersAmount)
		{
			playersAmount = _playersAmount;
			AmmunitionPatch.shouldBeSent = true;
		}
	}
}
namespace DLGMod.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class SwarmPatch
	{
		internal static bool hasStarted = false;

		internal static bool hasBeenCalled = false;

		internal static float dangerLevel = 10f;

		internal static int hazardLevel = 2;

		internal static float maxEnemiesAtTime;

		internal static GameObject[] outsideAINodes;

		internal static List<int> swarmEnemiesIndex = new List<int>();

		internal static float chance = 0f;

		internal static int enemiesToSpawn = 0;

		internal static int outsideEnemiesToSpawn = 0;

		internal static bool isSwarm = false;

		internal static bool isSwarmSFXFading = false;

		internal static HUDManager hudManager = Object.FindObjectOfType<HUDManager>();

		internal static GameObject swarmAllocation;

		public static void SetUpSwarmStuff(PlayerControllerB[] allPlayersScripts)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			if (hasStarted)
			{
				return;
			}
			RoundManager val = Object.FindObjectOfType<RoundManager>();
			for (int i = 0; i < val.currentLevel.Enemies.Count; i++)
			{
				if (val.currentLevel.Enemies[i].enemyType.enemyName.Contains("DLG"))
				{
					val.currentLevel.Enemies.RemoveAt(i);
					i--;
				}
			}
			if (val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Crawler") != -1)
			{
				CreateNewSwarmEnemy<CrawlerAI>("DLG[isOutside?][isStrong?]SwarmCrawler", "Crawler", val, new CrawlerAI());
			}
			maxEnemiesAtTime = (float)(hazardLevel * Mathf.CeilToInt(dangerLevel / 10f)) * (0.75f + (float)(DLGModMain.playersAmount / allPlayersScripts.Length));
			swarmAllocation = new GameObject();
			swarmAllocation.AddComponent<SwarmAllocation>();
			swarmAllocation.GetComponent<SwarmAllocation>().maxEnemiesPerPlayer = Mathf.CeilToInt(maxEnemiesAtTime / (float)DLGModMain.playersAmount);
			swarmAllocation.GetComponent<SwarmAllocation>().players = allPlayersScripts;
			swarmAllocation.GetComponent<SwarmAllocation>().enemiesTargeting = new int[allPlayersScripts.Length];
			outsideAINodes = null;
			hasStarted = true;
		}

		private static void CreateNewSwarmEnemy<T>(string swarmEnemyName, string originalEnemyName, RoundManager roundManager, T enemyAIType) where T : EnemyAI
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			for (int i = 0; i < 4; i++)
			{
				string text = swarmEnemyName;
				switch (i)
				{
				case 0:
					text = text.Replace("[isStrong?]", "");
					text = text.Replace("[isOutside?]", "");
					break;
				case 1:
					text = text.Replace("[isStrong?]", "");
					text = text.Replace("[isOutside?]", "Outside");
					break;
				case 2:
					text = text.Replace("[isStrong?]", "Strong");
					text = text.Replace("[isOutside?]", "");
					break;
				case 3:
					text = text.Replace("[isStrong?]", "Strong");
					text = text.Replace("[isOutside?]", "Outside");
					break;
				}
				SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
				val.enemyType = roundManager.currentLevel.Enemies.Find((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == originalEnemyName).enemyType;
				val.rarity = 0;
				GameObject val2 = Object.Instantiate<GameObject>(val.enemyType.enemyPrefab);
				val.enemyType = ScriptableObject.CreateInstance<EnemyType>();
				val.enemyType.enemyPrefab = val2;
				((Object)val.enemyType.enemyPrefab).name = text;
				((Object)val.enemyType).name = text;
				val.enemyType.enemyName = text;
				if (i % 2 != 0)
				{
					val.enemyType.isOutsideEnemy = true;
				}
				DLGModMain.logger.LogInfo((object)text);
				((EnemyAI)val2.GetComponent<T>()).enemyType = val.enemyType;
				val2.AddComponent<DLGEnemyAI>();
				roundManager.currentLevel.Enemies.Add(val);
			}
		}

		[HarmonyPatch("SyncTimeClientRpc")]
		[HarmonyPostfix]
		private static void RollSwarmDice(TimeOfDay __instance)
		{
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				return;
			}
			if (hasBeenCalled)
			{
				hasBeenCalled = false;
				return;
			}
			if (outsideAINodes == null)
			{
				outsideAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			}
			RoundManager val = Object.FindObjectOfType<RoundManager>();
			if (swarmEnemiesIndex.Count == 0 && val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Crawler") != -1)
			{
				swarmEnemiesIndex.Add(val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "DLGSwarmCrawler"));
				swarmEnemiesIndex.Add(val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "DLGOutsideSwarmCrawler"));
				swarmEnemiesIndex.Add(val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "DLGStrongSwarmCrawler"));
				swarmEnemiesIndex.Add(val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "DLGOutsideStrongSwarmCrawler"));
			}
			int num = Random.Range(30, 100);
			DLGModMain.logger.LogInfo((object)($"Current swarm chance: {chance}\n" + $"Randomly chosen swarm value: {num}"));
			int num2 = 0;
			int num3 = 0;
			DLGEnemyAI[] array = Object.FindObjectsOfType<DLGEnemyAI>();
			foreach (DLGEnemyAI dLGEnemyAI in array)
			{
				if (!dLGEnemyAI.enemyAI.isEnemyDead && ((Object)dLGEnemyAI).name.ToString().Contains("Swarm") && !((Object)dLGEnemyAI).name.ToString().Contains("Outside"))
				{
					num2++;
				}
			}
			DLGEnemyAI[] array2 = Object.FindObjectsOfType<DLGEnemyAI>();
			foreach (DLGEnemyAI dLGEnemyAI2 in array2)
			{
				if (!dLGEnemyAI2.enemyAI.isEnemyDead && ((Object)dLGEnemyAI2).name.ToString().Contains("Swarm") && ((Object)dLGEnemyAI2).name.ToString().Contains("Outside"))
				{
					num3++;
				}
			}
			if ((float)num < chance && enemiesToSpawn == 0)
			{
				StartOfRound val2 = Object.FindObjectOfType<StartOfRound>();
				enemiesToSpawn = Mathf.CeilToInt((0.75f + (float)(DLGModMain.playersAmount / val2.allPlayerScripts.Length)) * (float)hazardLevel * (float)Mathf.CeilToInt(dangerLevel / 10f));
				outsideEnemiesToSpawn = Mathf.CeilToInt((0.75f + (float)(DLGModMain.playersAmount / val2.allPlayerScripts.Length)) * (float)hazardLevel * (float)Mathf.CeilToInt(dangerLevel / 10f));
				SpawnSwarmEnemies(val, num2, num3);
				isSwarm = true;
				hudManager.AddTextToChatOnServer("dlgnetsync_swarm_start", -1);
				chance = 0f;
			}
			else if (enemiesToSpawn != 0)
			{
				if (isSwarm && ((float)num2 < maxEnemiesAtTime || (float)num3 < maxEnemiesAtTime))
				{
					SpawnSwarmEnemies(val, num2, num3);
				}
				chance += 0.01f * dangerLevel * __instance.normalizedTimeOfDay * (float)hazardLevel;
			}
			else
			{
				if (isSwarm)
				{
					hudManager.AddTextToChatOnServer("dlgnetsync_swarm_finish", -1);
					isSwarm = false;
				}
				chance += dangerLevel * __instance.normalizedTimeOfDay * Random.Range(0.5f, 1f) * (float)hazardLevel;
			}
			hasBeenCalled = true;
		}

		private static void SpawnSwarmEnemies(RoundManager roundManager, int currentEnemiesAmount, int currentOutsideEnemiesAmount)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = currentEnemiesAmount; (float)i < maxEnemiesAtTime; i++)
			{
				int num = Random.Range(0, swarmEnemiesIndex.Count / 4);
				EnemyVent val = roundManager.allEnemyVents[Random.Range(1, roundManager.allEnemyVents.Length)];
				float num2 = Random.Range(0f, 1f);
				num = ((!(num2 > 0.8f)) ? swarmEnemiesIndex[num * 4] : swarmEnemiesIndex[2 + num * 4]);
				roundManager.SpawnEnemyOnServer(((Component)val).transform.position, ((Component)val).transform.eulerAngles.y, num);
				enemiesToSpawn--;
				if (enemiesToSpawn == 0)
				{
					break;
				}
			}
			for (int j = currentOutsideEnemiesAmount; (float)j < maxEnemiesAtTime; j++)
			{
				int num3 = Random.Range(0, swarmEnemiesIndex.Count / 4);
				Transform transform = outsideAINodes[Random.Range(1, outsideAINodes.Length)].transform;
				float num4 = Random.Range(0f, 1f);
				num3 = ((!(num4 > 0.8f)) ? swarmEnemiesIndex[1 + num3 * 4] : swarmEnemiesIndex[3 + num3 * 4]);
				roundManager.SpawnEnemyOnServer(transform.position, 0f, num3);
				outsideEnemiesToSpawn--;
				if (outsideEnemiesToSpawn == 0)
				{
					break;
				}
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void ChangeSwarmSFX(TimeOfDay __instance)
		{
			if (isSwarm && !__instance.TimeOfDayMusic.isPlaying && !__instance.TimeOfDayMusic.loop)
			{
				ChatCommandsPatch.PerformSwarmAction("loopSwarmMusic");
			}
			if (!isSwarm && __instance.TimeOfDayMusic.isPlaying && isSwarmSFXFading)
			{
				if (__instance.TimeOfDayMusic.volume > 0f)
				{
					AudioSource timeOfDayMusic = __instance.TimeOfDayMusic;
					timeOfDayMusic.volume -= 0.08f * Time.deltaTime;
				}
				else
				{
					__instance.TimeOfDayMusic.Stop();
					isSwarmSFXFading = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class GameControllerPatch
	{
		internal static bool hasStartedHost;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StarterSetUp(StartOfRound __instance)
		{
			hasStartedHost = false;
			SwarmPatch.isSwarm = false;
			SwarmPatch.isSwarmSFXFading = false;
			SwarmPatch.chance = 0f;
			SwarmPatch.dangerLevel = 5f;
			SwarmPatch.enemiesToSpawn = 0;
			SwarmPatch.hasStarted = false;
			Object.FindObjectOfType<TimeOfDay>().TimeOfDayMusic.Stop();
			Object.FindObjectOfType<Terminal>().terminalNodes.specialNodes[13].displayText = ">MOONS\r\nTo see the list of moons the autopilot can route to.\r\n\r\n>DLGMISSION\r\nTo open DLG Mission Controller Hub, where you can changed properties of your mission.\r\n\r\n>STORE\r\nTo see the company store's selection of useful items.\r\n\r\n>BESTIARY\r\nTo see the list of wildlife on record.\r\n\r\n>STORAGE\r\nTo access objects placed into storage.\r\n\r\n>OTHER\r\nTo see the list of other commands\r\n\r\n[numberOfItemsOnRoute]\r\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.displayText = "You are not able to order ammunition pack unless you are on the mission!\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.terminalOptions = null;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.overrideOptions = false;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.displayText = "You are not able to order supply drop unless you are on the mission!\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.terminalOptions = null;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.overrideOptions = false;
			MissionControllerPatch.DLGMissionHub.displayText = "Welcome to DLG Mission Controller Hub! Here you can view and change your mission properties such as mission hazard (difficulty) level\n\nCurrent mission properties:\n" + $"Hazard level - {SwarmPatch.hazardLevel}: {MissionControllerPatch.hazardTitles[SwarmPatch.hazardLevel - 1]}\n\n" + ">HAZARD (1-5)\nTo change mission hazard (difficulty) level. Type this command with integer within the range (1-5)\n\n";
			MissionControllerPatch.isOnTheMission = false;
			SwarmPatch.swarmEnemiesIndex.Clear();
			SwarmPatch.hudManager = Object.FindObjectOfType<HUDManager>();
			DLGModMain.logger.LogInfo((object)"Initializing game:\n\tMission properties are unlocked\n\tAmmunition Pack and Ressuply Drop are unbuyable now");
		}

		[HarmonyPatch("OnPlayerConnectedClientRpc")]
		[HarmonyPostfix]
		public static void OnClientConnected(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost)
			{
				DLGModMain.logger.LogInfo((object)"New client connected. Sending DLG NetStuff sync request");
				Object.FindObjectOfType<HUDManager>().AddTextToChatOnServer($"dlgnetsync_missionhazard_{SwarmPatch.hazardLevel}", -1);
			}
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		public static void OnGameStarted(StartOfRound __instance)
		{
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.currentLevelID == 3 || hasStartedHost)
			{
				return;
			}
			hasStartedHost = true;
			if (((NetworkBehaviour)__instance).IsHost)
			{
				Object.FindObjectOfType<HUDManager>().AddTextToChatOnServer("dlgnetsync_onmission", -1);
			}
			DLGModMain.SendAmmunition(__instance.connectedPlayersAmount + 1);
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.displayText = "You have requested to order ammunition pack. Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.terminalOptions = AmmunitionPatch.ammunitionPackTO;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.overrideOptions = true;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.displayText = "You have requested to order resupply drop. Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.terminalOptions = AmmunitionPatch.supplyDropTO;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.overrideOptions = true;
			MissionControllerPatch.DLGMissionHub.displayText = "Welcome to DLG Mission Controller Hub! Here you can view and change your mission properties such as mission hazard (difficulty) level\n\nCurrent mission properties:\n" + $"Hazard level - {SwarmPatch.hazardLevel}: {MissionControllerPatch.hazardTitles[SwarmPatch.hazardLevel - 1]}\n\n" + "You are not able change your mission settings on the mission!\n\n";
			MissionControllerPatch.isOnTheMission = true;
			SwarmPatch.dangerLevel = 1f;
			string riskLevel = __instance.currentLevel.riskLevel;
			for (int i = 0; i < riskLevel.Length; i++)
			{
				switch (riskLevel[i])
				{
				case 'A':
					SwarmPatch.dangerLevel += 7f;
					break;
				case 'S':
					SwarmPatch.dangerLevel += 15f;
					break;
				case '+':
					SwarmPatch.dangerLevel += 5f;
					break;
				}
			}
			SwarmPatch.SetUpSwarmStuff(__instance.allPlayerScripts);
			RoundManager val = Object.FindObjectOfType<RoundManager>();
			val.currentLevel.Enemies[val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Hoarding bug")].enemyType.enemyPrefab.AddComponent<DLGEnemyAI>();
			val.currentLevel.Enemies[val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Hoarding bug")].enemyType.enemyPrefab.AddComponent<Light>().color = Color.yellow;
			val.currentLevel.Enemies[val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Hoarding bug")].enemyType.enemyPrefab.GetComponent<Light>().intensity = 15f;
			val.currentLevel.Enemies[val.currentLevel.Enemies.FindIndex((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Hoarding bug")].enemyType.enemyPrefab.GetComponent<Light>().range = 15f;
			DLGModMain.logger.LogInfo((object)("Starting game:\n" + $"\tMoon danger level: {SwarmPatch.dangerLevel}\n" + $"\tMission hazard level: {SwarmPatch.hazardLevel}\n\n" + "\tMission properties are locked\n\tAmmunition Pack and Ressuply Drop are buyable now"));
		}

		[HarmonyPatch("ShipLeave")]
		[HarmonyPostfix]
		public static void OnShipStartLeaving()
		{
			hasStartedHost = false;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.displayText = "You are not able to order ammunition pack unless you are on the mission!\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.terminalOptions = null;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex].result.overrideOptions = false;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.displayText = "You are not able to order supply drop unless you are on the mission!\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.terminalOptions = null;
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords[0].compatibleNouns[AmmunitionPatch.ammunitionCompatibleNodeIndex + 1].result.overrideOptions = false;
			MissionControllerPatch.DLGMissionHub.displayText = "Welcome to DLG Mission Controller Hub! Here you can view and change your mission properties such as mission hazard (difficulty) level\n\nCurrent mission properties:\n" + $"Hazard level - {SwarmPatch.hazardLevel}: {MissionControllerPatch.hazardTitles[SwarmPatch.hazardLevel - 1]}\n\n" + ">HAZARD (1-5)\nTo change mission hazard (difficulty) level. Type this command with integer within the range (1-5)\n\n";
			MissionControllerPatch.isOnTheMission = false;
			SwarmPatch.isSwarm = false;
			SwarmPatch.isSwarmSFXFading = false;
			SwarmPatch.chance = 0f;
			SwarmPatch.dangerLevel = 5f;
			SwarmPatch.enemiesToSpawn = 0;
			SwarmPatch.hasStarted = false;
			DLGTipsPatch.ammunitionRecieved = false;
			ChatCommandsPatch.PerformSwarmAction("finishSwarm");
			DLGModMain.logger.LogInfo((object)"Finishing game:\n\tMission properties are unlocked\n\tAmmunition Pack and Ressuply Drop are unbuyable now");
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class AmmunitionPatch
	{
		internal static bool shouldBeSent = false;

		internal static bool resupplyOrdered = false;

		internal static bool purchaseEnabled = false;

		internal static List<Item> allItemsList = Resources.FindObjectsOfTypeAll<AllItemsList>()[0].itemsList;

		internal static CompatibleNoun[] ammunitionPackTO;

		internal static CompatibleNoun[] supplyDropTO;

		internal static int ammunitionNodeIndex;

		internal static int ammunitionCompatibleNodeIndex;

		internal static int ammunitionItemIndex;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void SetUpAmmunition(Terminal __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_021d: 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_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_02be: 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_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			//IL_0335: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_03b3: Expected O, but got Unknown
			List<Item> list = __instance.buyableItemsList.ToList();
			if (ammunitionNodeIndex == 0)
			{
				ammunitionItemIndex = list.Count;
			}
			list.Add(new Item
			{
				itemName = "Ammunition Pack",
				creditsWorth = 100
			});
			list.Add(new Item
			{
				itemName = "Supply Drop",
				creditsWorth = 20
			});
			__instance.buyableItemsList = list.ToArray();
			if (((Object)__instance.terminalNodes.allKeywords[ammunitionNodeIndex]).name != "Ammunition Pack")
			{
				List<TerminalKeyword> list2 = __instance.terminalNodes.allKeywords.ToList();
				if (ammunitionNodeIndex == 0)
				{
					ammunitionNodeIndex = list2.Count;
				}
				list2.Add(new TerminalKeyword
				{
					word = "ammunition pack",
					defaultVerb = list2[0],
					name = "Ammunition Pack"
				});
				list2.Add(new TerminalKeyword
				{
					word = "supply drop",
					defaultVerb = list2[0],
					name = "Supply Drop"
				});
				__instance.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list3 = list2[0].compatibleNouns.ToList();
				if (ammunitionCompatibleNodeIndex == 0)
				{
					ammunitionCompatibleNodeIndex = list3.Count;
				}
				TerminalNode result = new TerminalNode
				{
					buyItemIndex = ammunitionItemIndex,
					isConfirmationNode = false,
					clearPreviousText = true,
					terminalEvent = "",
					displayText = "Ordered [variableAmount] ammunition packs. Your new balance is [playerCredits].\r\n\r\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n",
					name = "buyAmmunitionPack2",
					overrideOptions = false
				};
				TerminalNode result2 = new TerminalNode
				{
					buyItemIndex = ammunitionItemIndex + 1,
					isConfirmationNode = false,
					clearPreviousText = true,
					terminalEvent = "",
					displayText = "Ordered [variableAmount] supply drops. Your new balance is [playerCredits].\r\n\r\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n",
					name = "buyResupplyDrop2",
					overrideOptions = false
				};
				ammunitionPackTO = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = list2[3],
						result = result
					},
					new CompatibleNoun
					{
						noun = list2[4],
						result = list2[0].compatibleNouns[2].result.terminalOptions[1].result
					}
				};
				supplyDropTO = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = list2[3],
						result = result2
					},
					new CompatibleNoun
					{
						noun = list2[4],
						result = list2[0].compatibleNouns[2].result.terminalOptions[1].result
					}
				};
				list3.Add(new CompatibleNoun
				{
					noun = list2[ammunitionNodeIndex],
					result = new TerminalNode
					{
						buyItemIndex = ammunitionItemIndex,
						isConfirmationNode = true,
						clearPreviousText = true,
						itemCost = 100,
						displayText = "You are not able to order ammunition pack unless you are on the mission!\n\n",
						name = "buyAmmunitionPack1",
						terminalOptions = null,
						terminalEvent = "",
						overrideOptions = false
					}
				});
				list3.Add(new CompatibleNoun
				{
					noun = list2[ammunitionNodeIndex + 1],
					result = new TerminalNode
					{
						buyItemIndex = ammunitionItemIndex + 1,
						isConfirmationNode = true,
						clearPreviousText = true,
						itemCost = 20,
						displayText = "You are not able to order supply drop unless you are on the mission!\n\n",
						name = "buyResupplyDrop1",
						terminalOptions = null,
						terminalEvent = "",
						overrideOptions = false
					}
				});
				__instance.terminalNodes.allKeywords[0].compatibleNouns = list3.ToArray();
			}
		}

		[HarmonyPatch("InitializeItemSalesPercentages")]
		[HarmonyPostfix]
		public static void SetUpAmmunition2(Terminal __instance)
		{
			List<int> list = __instance.itemSalesPercentages.ToList();
			DLGModMain.logger.LogInfo((object)list.Count);
			list.Add(100);
			list.Add(100);
			__instance.itemSalesPercentages = list.ToArray();
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void SendAmmunition(Terminal __instance)
		{
			if (shouldBeSent && ((NetworkBehaviour)__instance).IsHost)
			{
				List<int> list = new List<int>();
				if (!resupplyOrdered)
				{
					list.Add(ammunitionItemIndex);
					__instance.orderedItemsFromTerminal = list;
					__instance.numberOfItemsInDropship = list.Count;
					DLGModMain.logger.LogInfo((object)"Ordered ammunition pack");
				}
				shouldBeSent = false;
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class MissionControllerPatch
	{
		internal static bool isDLGMissionHubOpened = false;

		internal static bool isOnTheMission = false;

		internal static TerminalNode DLGMissionHub = new TerminalNode
		{
			clearPreviousText = true,
			terminalEvent = ""
		};

		internal static string[] hazardTitles = new string[5] { "EASY", "NORMAL", "RISKY", "REALLY HARD", "LETHAL" };

		public static void UpdateMissionValues()
		{
			if (!isOnTheMission)
			{
				DLGMissionHub.displayText = "Welcome to DLG Mission Controller Hub! Here you can view and change your mission properties such as mission hazard (difficulty) level\n\nCurrent mission properties:\n" + $"Hazard level - {SwarmPatch.hazardLevel}: {hazardTitles[SwarmPatch.hazardLevel - 1]}\n\n" + ">HAZARD (1-5)\nTo change mission hazard (difficulty) level. Type this command with integer within the range (1-5)\n\n";
			}
			else
			{
				DLGMissionHub.displayText = "Welcome to DLG Mission Controller Hub! Here you can view and change your mission properties such as mission hazard (difficulty) level\n\nCurrent mission properties:\n" + $"Hazard level - {SwarmPatch.hazardLevel}: {hazardTitles[SwarmPatch.hazardLevel - 1]}\n\n" + "You are not able change your mission settings on the mission!\n\n";
			}
		}

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPostfix]
		public static void MissionControllerHub(ref TerminalNode __result, Terminal __instance)
		{
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: 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_0213: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			StringBuilder stringBuilder = new StringBuilder();
			string text2 = text;
			foreach (char c in text2)
			{
				if (!char.IsPunctuation(c))
				{
					stringBuilder.Append(c);
				}
			}
			text = stringBuilder.ToString().ToLower();
			if (text.Contains("dlg"))
			{
				for (int num = text.Length; num > 3; num--)
				{
					if ("dlgmission".StartsWith(text.Substring(0, num)))
					{
						isDLGMissionHubOpened = true;
						UpdateMissionValues();
						__result = DLGMissionHub;
						break;
					}
				}
			}
			else
			{
				if (!isDLGMissionHubOpened || isOnTheMission)
				{
					return;
				}
				string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
				for (int num2 = array[0].Length; num2 > 2; num2--)
				{
					if ("hazard".StartsWith(array[0].Substring(0, num2)))
					{
						if (array.Length > 1)
						{
							try
							{
								int num3 = int.Parse(array[1]);
								if (num3 > 0 && num3 < 6)
								{
									Object.FindObjectOfType<HUDManager>().AddTextToChatOnServer($"dlgnetsync_missionhazard_{num3}", -1);
									__result = new TerminalNode
									{
										displayText = "Successfully changed mission hazard level to\n" + $"{num3}: {hazardTitles[num3 - 1]}\n\n",
										clearPreviousText = true
									};
								}
								else
								{
									__result = new TerminalNode
									{
										displayText = "Operation failed because the integer you typed was out of bounds\n\n",
										clearPreviousText = true,
										terminalEvent = ""
									};
								}
							}
							catch
							{
								__result = new TerminalNode
								{
									displayText = "Operation failed because the text you typed wasn't an integer\n\n",
									clearPreviousText = true,
									terminalEvent = ""
								};
							}
						}
						else
						{
							__result = new TerminalNode
							{
								displayText = "Operation failed because you didn't type hazard level integer\n\n",
								clearPreviousText = true,
								terminalEvent = ""
							};
						}
					}
				}
				isDLGMissionHubOpened = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerPatch
	{
		internal static float currentHealProgress;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void TZP_Treatment(PlayerControllerB __instance)
		{
			if (__instance.drunknessInertia > 0f)
			{
				if (__instance.drunknessInertia > 1f)
				{
					__instance.drunknessInertia = 1f;
				}
				if ((float)__instance.health >= 20f && __instance.criticallyInjured && __instance.bleedingHeavily)
				{
					__instance.MakeCriticallyInjured(false);
				}
				__instance.drunkness = 0f;
				currentHealProgress += Time.deltaTime * 10f;
				if (currentHealProgress > 1f && (float)__instance.health < 100f)
				{
					DLGModMain.logger.LogInfo((object)"Healed 1HP from TZP-MedKit");
					__instance.health++;
					Object.FindObjectOfType<HUDManager>().UpdateHealthUI(__instance.health, false);
					currentHealProgress = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class ChatCommandsPatch
	{
		public static void PerformSwarmAction(string action)
		{
			TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
			switch (action)
			{
			case "startSwarm":
				val.TimeOfDayMusic.volume = 1f;
				val.TimeOfDayMusic.PlayOneShot(DLGModMain.swarmSFX[0]);
				break;
			case "loopSwarmMusic":
				val.TimeOfDayMusic.clip = DLGModMain.swarmSFX[1];
				val.TimeOfDayMusic.Play();
				val.TimeOfDayMusic.loop = true;
				break;
			case "finishSwarm":
				val.TimeOfDayMusic.loop = false;
				SwarmPatch.isSwarmSFXFading = true;
				break;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class DLGNetStuffSync
	{
		[HarmonyPatch("AddChatMessage")]
		[HarmonyPrefix]
		private static bool RecieveSyncRequest(ref string chatMessage, ref string nameOfUserWhoTyped)
		{
			DLGModMain.logger.LogInfo((object)chatMessage);
			if (nameOfUserWhoTyped == "" && chatMessage.ToLower().Contains("dlgnetsync"))
			{
				DLGModMain.logger.LogInfo((object)"Recieved DLG NetStuff sync request. Parsing request arguments...");
				string[] array = chatMessage.Split(new char[1] { '_' });
				switch (array[1])
				{
				case "onmission":
					DLGModMain.logger.LogInfo((object)"Set Client on the mission!");
					GameControllerPatch.OnGameStarted(Object.FindObjectOfType<StartOfRound>());
					break;
				case "missionhazard":
				{
					int num = (SwarmPatch.hazardLevel = int.Parse(array[2]));
					DLGModMain.logger.LogInfo((object)$"Set client hazard level to {num} - {MissionControllerPatch.hazardTitles[num - 1]}");
					break;
				}
				case "swarm":
					if (array[2] == "start")
					{
						ChatCommandsPatch.PerformSwarmAction("startSwarm");
						DLGModMain.logger.LogInfo((object)"Started swarm on Client!");
					}
					else if (array[2] == "finish")
					{
						ChatCommandsPatch.PerformSwarmAction("finishSwarm");
						DLGModMain.logger.LogInfo((object)"Finished swarm on Client!");
					}
					break;
				default:
					DLGModMain.logger.LogError((object)("Invalid DLG NetStuff sync request: " + chatMessage));
					break;
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemDropship))]
	internal class SpawnAmmunitionPatch
	{
		internal static Terminal terminal = Object.FindObjectOfType<Terminal>();

		internal static List<Item> allItemsList = Resources.FindObjectsOfTypeAll<AllItemsList>()[0].itemsList;

		[HarmonyPatch("OpenShipDoorsOnServer")]
		[HarmonyPrefix]
		public static void SetUpAmmunitionPacks(ItemDropship __instance)
		{
			//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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = Traverse.Create((object)__instance).Field("itemsToDeliver").GetValue() as List<int>;
			if (__instance.shipLanded && !__instance.shipDoorsOpened)
			{
				int num = 0;
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i] == AmmunitionPatch.ammunitionItemIndex)
					{
						DLGModMain.logger.LogInfo((object)"Dropship opened. Spawning:");
						for (int j = 0; j < 1; j++)
						{
							DLGModMain.logger.LogInfo((object)"\tShotgun");
							GameObject val = Object.Instantiate<GameObject>(allItemsList[59].spawnPrefab, __instance.itemSpawnPositions[num].position, Quaternion.identity);
							val.GetComponent<GrabbableObject>().fallTime = 0f;
							val.GetComponent<NetworkObject>().Spawn(false);
							num = ((num < 3) ? (num + 1) : 0);
						}
						for (int k = 0; k < 12; k++)
						{
							DLGModMain.logger.LogInfo((object)"\tShotgun Ammo");
							GameObject val2 = Object.Instantiate<GameObject>(allItemsList[60].spawnPrefab, __instance.itemSpawnPositions[num].position, Quaternion.identity);
							val2.GetComponent<GrabbableObject>().fallTime = 0f;
							val2.GetComponent<NetworkObject>().Spawn(false);
							num = ((num < 3) ? (num + 1) : 0);
						}
						list.Remove(AmmunitionPatch.ammunitionItemIndex);
						i--;
					}
					else if (list[i] == AmmunitionPatch.ammunitionItemIndex + 1)
					{
						DLGModMain.logger.LogInfo((object)"Dropship opened. Spawning:");
						for (int l = 0; l < DLGModMain.playersAmount * 7; l++)
						{
							DLGModMain.logger.LogInfo((object)"\tShotgun Ammo");
							GameObject val3 = Object.Instantiate<GameObject>(allItemsList[60].spawnPrefab, __instance.itemSpawnPositions[num].position, Quaternion.identity);
							val3.GetComponent<GrabbableObject>().fallTime = 0f;
							val3.GetComponent<NetworkObject>().Spawn(false);
							num = ((num < 3) ? (num + 1) : 0);
						}
						for (int m = 0; m < DLGModMain.playersAmount; m++)
						{
							DLGModMain.logger.LogInfo((object)"\tTZP-MedKit");
							GameObject val4 = Object.Instantiate<GameObject>(allItemsList[13].spawnPrefab, __instance.itemSpawnPositions[num].position, Quaternion.identity);
							val4.GetComponent<GrabbableObject>().fallTime = 0f;
							val4.GetComponent<NetworkObject>().Spawn(false);
							num = ((num < 3) ? (num + 1) : 0);
						}
						list.Remove(AmmunitionPatch.ammunitionItemIndex + 1);
						i--;
					}
				}
			}
			Traverse.Create((object)__instance).Field("itemsToDeliver").SetValue((object)list);
		}

		[HarmonyPatch("OpenShipClientRpc")]
		[HarmonyPostfix]
		public static void OpenDropshipDoors()
		{
			DLGTipsPatch.ammunitionRecieved = true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class DLGTipsPatch
	{
		internal static HUDManager hudManager = Object.FindObjectOfType<HUDManager>();

		internal static bool ammunitionRecieved = false;

		[HarmonyPatch("SyncTimeClientRpc")]
		[HarmonyPostfix]
		public static void CheckForTipMoment()
		{
			if (ammunitionRecieved)
			{
				List<GunAmmo> list = Object.FindObjectsOfType<GunAmmo>().ToList();
				if (list.Count <= 2)
				{
					DLGModMain.logger.LogInfo((object)"Try displaying Out of ammo Hint");
					hudManager.DisplayTip("Out of ammo?", "Don't worry! You can buy supply drop from the terminal store", false, true, "DLG_ResupplyTip");
				}
			}
		}
	}
}