Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Deep Lethal Galactic v0.5.5
DLGMod.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; 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 maxEnemiesAtTime; public Tuple<int, int> currentMaxEnemiesPerPlayer; public PlayerControllerB[] players; private float timer = 0f; private void Update() { timer += Time.deltaTime; if (timer < 10f) { return; } int num = 0; int num2 = 0; PlayerControllerB[] array = players; foreach (PlayerControllerB val in array) { if (val.isInsideFactory) { num++; } else { num2++; } } int item = 0; if (num != 0) { item = maxEnemiesAtTime / num; } int item2 = 0; if (num2 != 0) { item2 = maxEnemiesAtTime / num2; } currentMaxEnemiesPerPlayer = new Tuple<int, int>(item, item2); timer = 0f; } } 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 GameObject[] allAINodes; private void Start() { SetUpEnemy(); } private void OnEnable() { SetUpEnemy(); } private void SetUpEnemy() { //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() { if (dLGEnemyType == DLGEnemyType.EnemyPrefab && ((((NetworkBehaviour)enemyAI).IsHost && (Object)(object)swarmAllocation == (Object)null) || (!((NetworkBehaviour)enemyAI).IsHost && (Object)(object)Object.FindObjectOfType<Terminal>() == (Object)null))) { ((Component)this).gameObject.SetActive(false); } else if (dLGEnemyType != 0 && ((((NetworkBehaviour)enemyAI).IsHost && (Object)(object)swarmAllocation == (Object)null) || (!((NetworkBehaviour)enemyAI).IsHost && (Object)(object)Object.FindObjectOfType<Terminal>() == (Object)null))) { Object.Destroy((Object)(object)((Component)this).gameObject); } if (enemyAI.isEnemyDead || dLGEnemyType == DLGEnemyType.EnemyPrefab || enemyAI.currentBehaviourStateIndex == 1 || dLGEnemyType == DLGEnemyType.CuteUWULootbug) { return; } if (!((NetworkBehaviour)enemyAI).IsHost) { ((Behaviour)((Component)this).gameObject.GetComponent<DLGEnemyAI>()).enabled = false; } timer += Time.deltaTime; if (!(timer < 7f)) { if (targetPlayerIndex == -1 || !IsValidTarget(targetPlayerIndex)) { targetPlayerIndex = CalculateTargetPlayer(); } if (targetPlayerIndex != -1) { DLGModMain.logger.LogInfo((object)(((Object)((Component)this).gameObject).name + " is moving towards the player: " + swarmAllocation.players[targetPlayerIndex].playerUsername)); List<GameObject> list = new List<GameObject> { ((Component)swarmAllocation.players[targetPlayerIndex]).gameObject }; enemyAI.allAINodes = list.ToArray(); enemyAI.currentSearch.inProgress = false; } else { DLGModMain.logger.LogInfo((object)"...but there is no player that could be targeted"); enemyAI.allAINodes = allAINodes; enemyAI.currentSearch.inProgress = false; } timer = 0f; } } private int CalculateTargetPlayer() { int num = -1; DLGModMain.logger.LogInfo((object)(((Object)((Component)this).gameObject).name + " 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) { int num2 = (enemyAI.enemyType.isOutsideEnemy ? swarmAllocation.currentMaxEnemiesPerPlayer.Item2 : swarmAllocation.currentMaxEnemiesPerPlayer.Item1); if (swarmAllocation.enemiesTargeting[i] < num2) { num = i; } else { DLGModMain.logger.LogError((object)$"Player: {val.playerUsername} is not valid for targeting cuz it is overtargeted: {swarmAllocation.enemiesTargeting[i]}"); } } else { DLGModMain.logger.LogError((object)("Player: " + val.playerUsername + " is not valid for targeting cuz it is not in the correct area or dead")); } } if (num != -1) { swarmAllocation.enemiesTargeting[num]++; } return num; } private bool IsValidTarget(int playerIndex) { PlayerControllerB val = swarmAllocation.players[playerIndex]; bool flag = !val.isPlayerDead && val.isInsideFactory != enemyAI.enemyType.isOutsideEnemy; if (!flag) { swarmAllocation.enemiesTargeting[playerIndex]--; DLGModMain.logger.LogInfo((object)(((Object)((Component)this).gameObject).name + " is no longer targeting the player: " + val.playerUsername + " because ")); if (val.isPlayerDead) { DLGModMain.logger.LogInfo((object)"the player is already dead"); } else { DLGModMain.logger.LogInfo((object)"the player is not in the correct area anymore"); } } return flag; } } [HarmonyPatch(typeof(CrawlerAI))] internal class SwarmCrawlerPatch { [HarmonyPatch("MakeScreech")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SetSwarmCralwerScreechVolume(IEnumerable<CodeInstruction> instructions) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; for (int i = 0; i < list.Count; i++) { if (i < list.Count - 2 && list[i].opcode == OpCodes.Ldloc_0 && list[i + 1].opcode == OpCodes.Ldelem_Ref && !flag) { list.Insert(i + 2, new CodeInstruction(OpCodes.Ldc_R4, (object)0.2f)); list[i + 3] = new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(AudioSource), "PlayOneShot", new Type[2] { typeof(AudioClip), typeof(float) }, (Type[])null)); flag = true; } else if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand.ToString() == "0.75") { list[i] = new CodeInstruction(OpCodes.Ldc_R4, (object)0.2f); } } return list.AsEnumerable(); } [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 if (((Component)__instance).gameObject.GetComponent<DLGEnemyAI>().targetPlayerIndex != -1) { Object.FindObjectOfType<SwarmAllocation>().enemiesTargeting[((Component)__instance).gameObject.GetComponent<DLGEnemyAI>().targetPlayerIndex]--; ((Component)__instance).gameObject.GetComponent<DLGEnemyAI>().targetPlayerIndex = -1; } } } namespace DLGMod { [BepInPlugin("XRTG074TheDeveloper.DeepLethalGalactic", "Deep Lethal Galactic", "0.5.5")] 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 + "\\swarmmusic"); 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(SwarmCrawlerPatch)); harmonyInstance.PatchAll(typeof(NetworkManagerPatch)); } internal static void SendAmmunition(int _playersAmount) { playersAmount = _playersAmount; AmmunitionPatch.shouldBeSent = true; } } } namespace DLGMod.Patches { [HarmonyPatch(typeof(NetworkManager))] internal class NetworkManagerPatch { [HarmonyPatch("Awake")] [HarmonyPrefix] public static void SetUpSwarmEnemiesNetworkPrefabs(NetworkManager __instance) { uint num = 1u; GameObject[] array = CreateNewSwarmEnemyNetworkPrefab<CrawlerAI>("DLG[isOutside?][isStrong?]SwarmCrawler", "Crawler"); foreach (GameObject val in array) { val.SetActive(false); uint? num2 = (Traverse.Create((object)val.GetComponent<NetworkObject>()).Field("GlobalObjectIdHash").GetValue() as uint?) + num; Traverse.Create((object)val.GetComponent<NetworkObject>()).Field("GlobalObjectIdHash").SetValue((object)num2); __instance.AddNetworkPrefab(val); num++; } } private static GameObject[] CreateNewSwarmEnemyNetworkPrefab<T>(string swarmEnemyName, string originalEnemyName) where T : EnemyAI { GameObject[] array = (GameObject[])(object)new GameObject[4]; 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; } array[i] = Object.Instantiate<GameObject>(((Component)(object)Resources.FindObjectsOfTypeAll<T>().ToList().Find((T enemy) => ((Object)(object)enemy).name == originalEnemyName)).gameObject); ((Object)array[i]).name = text; array[i].AddComponent<DLGEnemyAI>(); Object.DontDestroyOnLoad((Object)(object)array[i]); } return array; } } [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 int 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 float chanceMultiplier = 1f; 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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); } if (((NetworkBehaviour)val).IsHost) { chanceMultiplier = Random.Range(0.01f, 1f); maxEnemiesAtTime = Mathf.CeilToInt((float)(hazardLevel * Mathf.CeilToInt(dangerLevel / 10f)) * (1f + (float)(DLGModMain.playersAmount / 4))); swarmAllocation = new GameObject(); ((Object)swarmAllocation).name = "SwarmAllocation"; swarmAllocation.AddComponent<SwarmAllocation>(); swarmAllocation.GetComponent<SwarmAllocation>().maxEnemiesAtTime = maxEnemiesAtTime; 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) where T : EnemyAI { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown for (int i = 0; i < 4; i++) { switch (i) { case 0: swarmEnemyName = swarmEnemyName.Replace("[isStrong?]", ""); swarmEnemyName = swarmEnemyName.Replace("[isOutside?]", ""); break; case 1: swarmEnemyName = swarmEnemyName.Replace("[isStrong?]", ""); swarmEnemyName = swarmEnemyName.Replace("[isOutside?]", "Outside"); break; case 2: swarmEnemyName = swarmEnemyName.Replace("[isStrong?]", "Strong"); swarmEnemyName = swarmEnemyName.Replace("[isOutside?]", ""); break; case 3: swarmEnemyName = swarmEnemyName.Replace("[isStrong?]", "Strong"); swarmEnemyName = swarmEnemyName.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 gameObject = ((Component)Object.FindObjectsOfType<DLGEnemyAI>(true).ToList().Find((DLGEnemyAI enemy) => ((Object)((Component)enemy).gameObject).name == swarmEnemyName)).gameObject; gameObject.SetActive(true); val.enemyType = ScriptableObject.CreateInstance<EnemyType>(); val.enemyType.enemyPrefab = gameObject; ((Object)val.enemyType.enemyPrefab).name = swarmEnemyName; ((Object)val.enemyType).name = swarmEnemyName; val.enemyType.enemyName = swarmEnemyName; if (i % 2 != 0) { val.enemyType.isOutsideEnemy = true; } ((EnemyAI)gameObject.GetComponent<T>()).enemyType = val.enemyType; 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}\n" + $"Chance multiplier: {chanceMultiplier}")); int num2 = 0; int num3 = 0; EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); foreach (EnemyAI val2 in array) { if (!val2.isEnemyDead && ((Object)val2).name.ToString().Contains("Swarm") && !((Object)val2).name.ToString().Contains("Outside")) { num2++; } } EnemyAI[] array2 = Object.FindObjectsOfType<EnemyAI>(); foreach (EnemyAI val3 in array2) { if (!val3.isEnemyDead && ((Object)val3).name.ToString().Contains("Swarm") && ((Object)val3).name.ToString().Contains("Outside")) { num3++; } } if ((float)num < chance && enemiesToSpawn == 0) { enemiesToSpawn = Mathf.CeilToInt((float)Mathf.CeilToInt((0.75f + (float)(DLGModMain.playersAmount / 4)) * (float)hazardLevel * (float)Mathf.CeilToInt(dangerLevel / 4f)) * Random.Range(0.5f, 3f)); SpawnSwarmEnemies(val, num2, num3); isSwarm = true; hudManager.AddTextToChatOnServer("dlgnetsync_swarm_start", -1); chanceMultiplier = 0.01f; chance = 0f; } else if (enemiesToSpawn > 0) { if (isSwarm && (num2 < maxEnemiesAtTime || num3 < maxEnemiesAtTime)) { SpawnSwarmEnemies(val, num2, num3); } chance += dangerLevel * __instance.normalizedTimeOfDay * (float)hazardLevel * chanceMultiplier; } else { if (isSwarm) { hudManager.AddTextToChatOnServer("dlgnetsync_swarm_finish", -1); isSwarm = false; } chance += dangerLevel * __instance.normalizedTimeOfDay * Random.Range(0.5f, 1f) * (float)hazardLevel * 2f * chanceMultiplier; if (chanceMultiplier < 1f) { chanceMultiplier += Random.Range(0.001f, 0.01f); } } hasBeenCalled = true; } private static void SpawnSwarmEnemies(RoundManager roundManager, int currentEnemiesAmount, int currentOutsideEnemiesAmount) { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) float num = 0f; PlayerControllerB[] allPlayerScripts = roundManager.playersManager.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && val.isInsideFactory) { num += 1f / (float)DLGModMain.playersAmount; } } DLGModMain.logger.LogInfo((object)($"Current Inside enemies amount: {currentEnemiesAmount}\n\t" + $"Current Outside enemies amount: {currentOutsideEnemiesAmount}\n\t" + $"Enemies to spawn left: {enemiesToSpawn}\n\t" + $"Spawn coefficient: {num}")); for (float num2 = currentEnemiesAmount; num2 < (float)maxEnemiesAtTime * num; num2 += 1f) { if (enemiesToSpawn == 0) { break; } int num3 = Random.Range(0, swarmEnemiesIndex.Count / 4); EnemyVent val2 = roundManager.allEnemyVents[Random.Range(1, roundManager.allEnemyVents.Length)]; float num4 = Random.Range(0f, 1f); num3 = ((!(num4 > 0.8f)) ? swarmEnemiesIndex[num3 * 4] : swarmEnemiesIndex[2 + num3 * 4]); roundManager.SpawnEnemyOnServer(((Component)val2).transform.position, ((Component)val2).transform.eulerAngles.y, num3); enemiesToSpawn--; } for (float num5 = currentOutsideEnemiesAmount; num5 < (float)maxEnemiesAtTime * (1f - num); num5 += 1f) { if (enemiesToSpawn == 0) { break; } int num6 = Random.Range(0, swarmEnemiesIndex.Count / 4); Transform transform = outsideAINodes[Random.Range(1, outsideAINodes.Length)].transform; float num7 = Random.Range(0f, 1f); num6 = ((!(num7 > 0.8f)) ? swarmEnemiesIndex[1 + num6 * 4] : swarmEnemiesIndex[3 + num6 * 4]); roundManager.SpawnEnemyOnServer(transform.position, 0f, num6); enemiesToSpawn--; } } [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) { 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 = 5f; 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); 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[1]); break; case "loopSwarmMusic": val.TimeOfDayMusic.clip = DLGModMain.swarmSFX[0]; 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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) { int index = allItemsList.FindIndex((Item item) => ((Object)item).name == "Shotgun"); int index2 = allItemsList.FindIndex((Item item) => ((Object)item).name == "GunAmmo"); DLGModMain.logger.LogInfo((object)"Dropship opened. Spawning:"); for (int j = 0; j < DLGModMain.playersAmount; j++) { DLGModMain.logger.LogInfo((object)"\tShotgun"); GameObject val = Object.Instantiate<GameObject>(allItemsList[index].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 * DLGModMain.playersAmount; k++) { DLGModMain.logger.LogInfo((object)"\tShotgun Ammo"); GameObject val2 = Object.Instantiate<GameObject>(allItemsList[index2].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) { int index3 = allItemsList.FindIndex((Item item) => ((Object)item).name == "GunAmmo"); int index4 = allItemsList.FindIndex((Item item) => ((Object)item).name == "TZPInhalant"); 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[index3].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[index4].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"); } } } } }