using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FairAI.Component; using FairAI.Patches; using GameNetcodeStuff; using HarmonyLib; using LethalThings; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FairAI")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FairAI")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("42deea12-f73e-4d63-81e9-5359e98c8d53")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace FairAI { [BepInPlugin("GoldenKitten.FairAI", "Fair AI", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string modGUID = "GoldenKitten.FairAI"; private const string modName = "Fair AI"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("GoldenKitten.FairAI"); public static Plugin Instance; public static ManualLogSource logger; public static List enemies; public static List items; public static int wallsAndEnemyLayerMask = 524288; private void Awake() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = Logger.CreateLogSource("GoldenKitten.FairAI"); logger.LogInfo((object)"Fair AI initiated!"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(RoundManagerPatch)); harmony.PatchAll(typeof(StartOfRoundPatch)); harmony.PatchAll(typeof(MineAIPatch)); harmony.PatchAll(typeof(TurretAIPatch)); harmony.PatchAll(typeof(EnemyAIPatch)); harmony.PatchAll(typeof(BoombaPatch)); MethodInfo methodInfo = AccessTools.Method(typeof(EnemyAI), "KillEnemyOnOwnerClient", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyAIPatch), "PatchKillEnemyOnOwnerClient", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static bool CanMob(string parentIdentifier, string identifier, string mobName) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string text = FairAIUtilities.RemoveInvalidCharacters(mobName).ToUpper(); logger.LogInfo((object)("Mob Name: " + text)); if (((BaseUnityPlugin)Instance).Config[new ConfigDefinition("Mobs", parentIdentifier)].BoxedValue.ToString().ToUpper().Equals("TRUE")) { foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys) { if (FairAIUtilities.RemoveInvalidCharacters(key.Key.ToUpper()).Equals(FairAIUtilities.RemoveInvalidCharacters(text + identifier.ToUpper()))) { logger.LogInfo((object)("Value of mob: " + ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString())); return ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString().ToUpper().Equals("TRUE"); } } logger.LogInfo((object)(identifier + ": No mob found!")); return false; } logger.LogInfo((object)(parentIdentifier + ": All mobs disabled!")); return false; } } internal class FairAIUtilities { private static float onMeshThreshold = 3f; public static bool IsAgentOnNavMesh(GameObject agentObject) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector3 position = agentObject.transform.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, onMeshThreshold, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z)) { return position.y >= ((NavMeshHit)(ref val)).position.y; } return false; } public static string RemoveWhitespaces(string source) { return string.Join("", source.Split((string[]?)null, StringSplitOptions.RemoveEmptyEntries)); } public static string RemoveSpecialCharacters(string source) { StringBuilder stringBuilder = new StringBuilder(); foreach (char c in source) { if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } public static string RemoveInvalidCharacters(string source) { return RemoveWhitespaces(RemoveSpecialCharacters(source)); } } } namespace FairAI.Patches { [HarmonyPatch(typeof(RoombaAI))] internal class BoombaPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void PatchStart(ref RoombaAI __instance) { ((Component)__instance).gameObject.AddComponent(); } [HarmonyPatch("DoAIInterval")] [HarmonyPrefix] public static void PatchDoAIInterval(ref RoombaAI __instance) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_0206: Unknown result type (might be due to invalid IL or missing references) if (!FairAIUtilities.IsAgentOnNavMesh(((Component)__instance).gameObject) || (((EnemyAI)__instance).currentSearch == null && !((EnemyAI)__instance).movingTowardsTargetPlayer) || (!__instance.mineAudio.isPlaying && !__instance.mineFarAudio.isPlaying) || !((Component)__instance).GetComponent().IsActiveBomb()) { return; } Vector3 val = ((Component)__instance).transform.position + Vector3.up; Collider[] array = Physics.OverlapSphere(val, 6f, 2621448, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { float num = Vector3.Distance(val, ((Component)array[i]).transform.position); if ((num > 4f && Physics.Linecast(val, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) || !((Object)(object)((Component)array[i]).gameObject.GetComponent() != (Object)null)) { continue; } EnemyAICollisionDetect component = ((Component)array[i]).gameObject.GetComponent(); if (!((Object)(object)((Component)component.mainScript).gameObject != (Object)(object)((Component)__instance).gameObject) || !Plugin.CanMob("BoombaAllMobs", ".Boomba", component.mainScript.enemyType.enemyName)) { continue; } if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component.mainScript).IsOwner && !component.mainScript.isEnemyDead) { Object.Instantiate(StartOfRound.Instance.explosionPrefab, val, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true); if (num < 3f) { component.mainScript.KillEnemyOnOwnerClient(true); } else if (num < 6f) { component.mainScript.HitEnemyOnLocalClient(2, default(Vector3), (PlayerControllerB)null, false); } } if (((NetworkBehaviour)__instance).IsServer) { ((EnemyAI)__instance).KillEnemy(true); } else { ((EnemyAI)__instance).KillEnemyServerRpc(true); } } } } [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { [HarmonyPatch("KillEnemyOnOwnerClient")] [HarmonyPrefix] public static void PatchKillEnemyOnOwnerClient(ref EnemyAI __instance, bool overrideDestroy = false) { if ((Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Landmine))] internal class MineAIPatch { [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] private static void PatchOnTriggerEnter(ref Landmine __instance, Collider other, ref float ___pressMineDebounceTimer) { EnemyAICollisionDetect component = ((Component)other).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && !component.mainScript.isEnemyDead && Plugin.CanMob("ExplodeAllMobs", ".Mine", component.mainScript.enemyType.enemyName.ToUpper())) { ___pressMineDebounceTimer = 0.5f; __instance.PressMineServerRpc(); } } [HarmonyPatch("OnTriggerExit")] [HarmonyPrefix] private static void PatchOnTriggerExit(ref Landmine __instance, Collider other, ref bool ___sendingExplosionRPC) { EnemyAICollisionDetect component = ((Component)other).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && !component.mainScript.isEnemyDead && Plugin.CanMob("ExplodeAllMobs", ".Mine", component.mainScript.enemyType.enemyName.ToUpper()) && !__instance.hasExploded) { __instance.SetOffMineAnimation(); ___sendingExplosionRPC = true; __instance.ExplodeMineServerRpc(); } } [HarmonyPatch("SpawnExplosion")] [HarmonyPrefix] private static void PatchSpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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) Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position); if ((num > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) || !((Object)(object)((Component)array[i]).gameObject.GetComponent() != (Object)null)) { continue; } EnemyAICollisionDetect component = ((Component)array[i]).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component.mainScript).IsOwner && !component.mainScript.isEnemyDead) { if (num < killRange) { component.mainScript.KillEnemyOnOwnerClient(true); } else if (num < damageRange) { component.mainScript.HitEnemyOnLocalClient(2, default(Vector3), (PlayerControllerB)null, false); } } } } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PatchStart() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown Plugin.enemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType)) where (Object)(object)e != (Object)null select e).ToList(); Plugin.items = (from Item i in Resources.FindObjectsOfTypeAll(typeof(Item)) where (Object)(object)i != (Object)null select i).ToList(); if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "ExplodeAllMobs"))) { ConfigEntry val = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "ExplodeAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Mines."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "BoombaAllMobs"))) { ConfigEntry val2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "BoombaAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Boombas."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretTargetAllMobs"))) { ConfigEntry val3 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "TurretTargetAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Targeted By Turrets."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretDamageAllMobs"))) { ConfigEntry val4 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "TurretDamageAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Killed By Turrets."); } foreach (EnemyType enemy in Plugin.enemies) { string text = FairAIUtilities.RemoveInvalidCharacters(enemy.enemyName); if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Mine"))) { ConfigEntry val5 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Mine", true, "Does it set off the landmine or not?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Boomba"))) { ConfigEntry val6 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Boomba", true, "Does it set off the boomba or not?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Target"))) { ConfigEntry val7 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Turret Target", true, "Is it targetable by turrets?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Damage"))) { ConfigEntry val8 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Turret Damage", true, "Is it damageable by turrets?"); } } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PatchStart() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown Plugin.enemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType)) where (Object)(object)e != (Object)null select e).ToList(); Plugin.items = (from Item i in Resources.FindObjectsOfTypeAll(typeof(Item)) where (Object)(object)i != (Object)null select i).ToList(); if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "ExplodeAllMobs"))) { ConfigEntry val = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "ExplodeAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Mines."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "BoombaAllMobs"))) { ConfigEntry val2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "BoombaAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Boombas."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretTargetAllMobs"))) { ConfigEntry val3 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "TurretTargetAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Targeted By Turrets."); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretDamageAllMobs"))) { ConfigEntry val4 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", "TurretDamageAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Killed By Turrets."); } foreach (EnemyType enemy in Plugin.enemies) { string text = FairAIUtilities.RemoveInvalidCharacters(enemy.enemyName); if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Mine"))) { ConfigEntry val5 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Mine", true, "Does it set off the landmine or not?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Boomba"))) { ConfigEntry val6 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Boomba", true, "Does it set off the boomba or not?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Target"))) { ConfigEntry val7 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Turret Target", true, "Is it targetable by turrets?"); } if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Damage"))) { ConfigEntry val8 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("Mobs", text + ".Turret Damage", true, "Is it damageable by turrets?"); } } } } [HarmonyPatch(typeof(Turret))] internal class TurretAIPatch { public static float viewRadius = 10f; public static float viewAngle = 90f; [HarmonyPatch("Update")] [HarmonyPrefix] public static void PatchUpdateBefore(ref Turret __instance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.turretModeLastFrame == 0) { List actualTargets = GetActualTargets(GetTargets(__instance)); if (actualTargets.Any()) { __instance.turretMode = (TurretMode)1; } } else if ((int)__instance.turretModeLastFrame == 1) { List actualTargets2 = GetActualTargets(GetTargets(__instance)); if (actualTargets2.Any()) { __instance.turretMode = (TurretMode)2; } } if ((int)__instance.turretMode != 2 && (int)__instance.turretMode != 3) { return; } List actualTargets3 = GetActualTargets(GetTargets(__instance)); if (!HitEnemies(__instance, actualTargets3) && ((int)__instance.turretModeLastFrame == 2 || (int)__instance.turretModeLastFrame == 3)) { __instance.turretMode = (TurretMode)0; } if ((Object)(object)__instance.CheckForPlayersInLineOfSight(3f, false) == (Object)(object)GameNetworkManager.Instance.localPlayerController) { if (GameNetworkManager.Instance.localPlayerController.health - 33 > 0) { GameNetworkManager.Instance.localPlayerController.DamagePlayer(33, true, true, (CauseOfDeath)7, 0, false, default(Vector3)); } else { GameNetworkManager.Instance.localPlayerController.KillPlayer(__instance.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0); } } } [HarmonyPatch("TurnTowardsTargetIfHasLOS")] [HarmonyPrefix] public static void PatchTurnTowardsTargetIfHasLOS(ref Turret __instance) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) List actualTargets = GetActualTargets(GetTargets(__instance)); if (actualTargets.Any()) { using List.Enumerator enumerator = actualTargets.GetEnumerator(); if (enumerator.MoveNext()) { EnemyAICollisionDetect current = enumerator.Current; __instance.hasLineOfSight = true; __instance.lostLOSTimer = 0f; __instance.tempTransform.position = ((Component)current.mainScript).transform.position; Transform tempTransform = __instance.tempTransform; tempTransform.position -= Vector3.up * 0.15f; __instance.turnTowardsObjectCompass.LookAt(__instance.tempTransform); } } if (__instance.hasLineOfSight) { __instance.hasLineOfSight = false; __instance.lostLOSTimer = 0f; } } public static bool HitEnemies(Turret turret, List visibleEnemies) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00db: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Quaternion.Euler(0f, (float)(int)(0f - turret.rotationRange) / 2f, 0f) * turret.aimPoint.forward; Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(turret.forwardFacingPos.position, val); RaycastHit[] array = Physics.RaycastAll(val2, 30f, 2621448, (QueryTriggerInteraction)2); bool result = false; if (!array.Any()) { return result; } RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val3 = array2[i]; EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val3)).collider).GetComponent(); if (visibleEnemies.Contains(component) && Plugin.CanMob("TurretDamageAllMobs", ".Turret Damage", component.mainScript.enemyType.enemyName)) { component.mainScript.HitEnemyOnLocalClient(3, default(Vector3), (PlayerControllerB)null, false); result = true; } } return result; } public static List GetActualTargets(List targets) { List actual = new List(); targets.ForEach(delegate(EnemyAICollisionDetect target) { if (!target.mainScript.isEnemyDead && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", target.mainScript.enemyType.enemyName)) { actual.Add(target); } }); return actual; } private static List GetTargets(Turret turret, float radius = 2f, bool angleRangeCheck = false) { List enemies = new List(); List list = FindVisibleTargets(turret); list.ForEach(delegate(Transform e) { EnemyAICollisionDetect component = ((Component)e).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)((Component)e).GetComponent() == (Object)null && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", component.mainScript.enemyType.enemyName)) { enemies.Add(component); } }); return enemies; } public static Vector3 DirectionFromAngle(Turret turret, float angleInDegrees, bool angleIsGlobal) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!angleIsGlobal) { angleInDegrees += ((Component)turret).transform.eulerAngles.y; } return new Vector3(Mathf.Sin(angleInDegrees * ((float)Math.PI / 180f)), 0f, Mathf.Cos(angleInDegrees * ((float)Math.PI / 180f))); } public static List FindVisibleTargets(Turret turret) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) Collider[] array = Physics.OverlapSphere(turret.aimPoint.position, viewRadius, 2621448); List list = new List(); for (int i = 0; i < array.Length; i++) { Transform transform = ((Component)array[i]).transform; Vector3 val = transform.position - turret.aimPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if (Vector3.Angle(turret.aimPoint.forward, normalized) < viewAngle / 2f) { float num = Vector3.Distance(turret.aimPoint.position, transform.position); if (!Physics.Raycast(turret.aimPoint.position, normalized, num, -2621449) && (Object)(object)((Component)transform).GetComponent() != (Object)null && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", ((Component)transform).GetComponent().mainScript.enemyType.enemyName)) { list.Add(transform); } } } return list; } } } namespace FairAI.Component { internal class BoombaTimer : MonoBehaviour { private bool isActiveBomb = false; private bool timerStarted = false; private void Start() { ((MonoBehaviour)this).StartCoroutine(StartBombTimer()); Plugin.logger.LogInfo((object)"Boomba has been set active."); } public IEnumerator StartBombTimer() { SetActiveBomb(isActive: false); yield return (object)new WaitForSeconds(3f); SetActiveBomb(isActive: true); } public void SetActiveBomb(bool isActive) { isActiveBomb = isActive; } public bool IsActiveBomb() { return isActiveBomb; } } internal class FAIR_AI : MonoBehaviour { private void Awake() { Plugin.logger.LogInfo((object)"Fairness has been dealt."); } } }