Please disclose if any significant portion of your mod was created 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 StarlancerEnemyEscape v3.0.0
StarlancerEnemyEscape.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EnemyEscape; using HarmonyLib; using Microsoft.CodeAnalysis; using StarlancerAIFix.Patches; using StarlancerEnemyEscape; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("StarlancerEnemyEscape")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+59295cca759c482e1cb3a7e3cce1b058dec3b59b")] [assembly: AssemblyProduct("StarlancerEnemyEscape")] [assembly: AssemblyTitle("StarlancerEnemyEscape")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace StarlancerEnemyEscape { [BepInPlugin("AudioKnight.StarlancerEnemyEscape", "Starlancer EnemyEscape", "3.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class StarlancerEnemyEscapeBase : BaseUnityPlugin { public enum ConfigPreset { Disabled, ReasonableDefaults, Minimal, Chaos } private const string modGUID = "AudioKnight.StarlancerEnemyEscape"; private const string modName = "Starlancer EnemyEscape"; private const string modVersion = "3.0.0"; private readonly Harmony harmony = new Harmony("AudioKnight.StarlancerEnemyEscape"); public static StarlancerEnemyEscapeBase Instance; internal static ManualLogSource logger; internal static ConfigFile EnemyEscapeConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "AudioKnight.StarlancerEnemyEscape.cfg"), true); public static ConfigEntry<ConfigPreset> configEscapePreset; internal static Dictionary<string, ConfigEntry<int>> EnemyEscapeConfigDictionary = new Dictionary<string, ConfigEntry<int>>(); internal static Dictionary<string, ConfigEntry<int>> configEscapeInteriorRange = new Dictionary<string, ConfigEntry<int>>(); internal static Dictionary<string, ConfigEntry<int>> configEscapeExteriorRange = new Dictionary<string, ConfigEntry<int>>(); internal static Dictionary<string, ConfigEntry<int>> configEscapeCooldownTime = new Dictionary<string, ConfigEntry<int>>(); internal static Dictionary<string, string> EnemyBlacklist = new Dictionary<string, string> { { "Girl", "Unneeded" }, { "Masked", "Unneeded" }, { "Docile Locust Bees", "Unneeded" }, { "Manticoil", "Unneeded" }, { "Lasso", "Unimplemented" }, { "Red pill", "Unimplemented" }, { "Red Locust Bees", "Buggy" }, { "Cadaver Growths", "Unneeded" }, { "GiantKiwi", "Buggy" }, { "Stingray", "Buggy" }, { "Bush Wolf", "Buggy" }, { "Feiopar", "Buggy" } }; internal static Dictionary<string, string> VanillaEnemyList = new Dictionary<string, string> { { "Blob", "" }, { "Bunker Spider", "" }, { "Butler", "" }, { "Butler Bees", "" }, { "Centipede", "" }, { "Crawler", "" }, { "Flowerman", "" }, { "Hoarding bug", "" }, { "Jester", "" }, { "Nutcracker", "" }, { "Puffer", "" }, { "Spring", "" }, { "Baboon hawk", "" }, { "Earth Leviathan", "" }, { "ForestGiant", "" }, { "MouthDog", "" }, { "RadMech", "" }, { "Tulip Snake", "" }, { "Clay Surgeon", "" }, { "Maneater", "" }, { "Cadaver Bloom", "" } }; internal static Dictionary<string, int> DefaultPresetValues = new Dictionary<string, int> { { "Blob", 2 }, { "Bunker Spider", 10 }, { "Butler", 5 }, { "Butler Bees", 5 }, { "Centipede", 0 }, { "Crawler", 10 }, { "Flowerman", 10 }, { "Hoarding bug", 10 }, { "Jester", 1 }, { "Nutcracker", 5 }, { "Puffer", 10 }, { "Spring", 5 }, { "Baboon hawk", 15 }, { "Earth Leviathan", 1 }, { "ForestGiant", 0 }, { "MouthDog", 0 }, { "RadMech", 0 }, { "Tulip Snake", 5 }, { "Clay Surgeon", 5 }, { "Maneater", 1 }, { "Cadaver Bloom", 8 } }; internal static Dictionary<string, int> DisabledPresetValues = new Dictionary<string, int> { { "Blob", 0 }, { "Bunker Spider", 0 }, { "Butler", 0 }, { "Butler Bees", 0 }, { "Centipede", 0 }, { "Crawler", 0 }, { "Flowerman", 0 }, { "Hoarding bug", 0 }, { "Jester", 0 }, { "Nutcracker", 0 }, { "Puffer", 0 }, { "Spring", 0 }, { "Baboon hawk", 0 }, { "Earth Leviathan", 0 }, { "ForestGiant", 0 }, { "MouthDog", 0 }, { "RadMech", 0 }, { "Tulip Snake", 0 }, { "Clay Surgeon", 0 }, { "Maneater", 0 }, { "Cadaver Bloom", 0 } }; internal static Dictionary<string, int> MinimalPresetValues = new Dictionary<string, int> { { "Blob", 1 }, { "Bunker Spider", 1 }, { "Butler", 1 }, { "Butler Bees", 1 }, { "Centipede", 1 }, { "Crawler", 1 }, { "Flowerman", 1 }, { "Hoarding bug", 1 }, { "Jester", 1 }, { "Nutcracker", 1 }, { "Puffer", 1 }, { "Spring", 1 }, { "Baboon hawk", 1 }, { "Earth Leviathan", 1 }, { "ForestGiant", 1 }, { "MouthDog", 1 }, { "RadMech", 1 }, { "Tulip Snake", 1 }, { "Clay Surgeon", 1 }, { "Maneater", 1 }, { "Cadaver Bloom", 1 } }; internal static Dictionary<string, int> ChaosPresetValues = new Dictionary<string, int> { { "Blob", 100 }, { "Bunker Spider", 100 }, { "Butler", 100 }, { "Butler Bees", 100 }, { "Centipede", 100 }, { "Crawler", 100 }, { "Flowerman", 100 }, { "Hoarding bug", 100 }, { "Jester", 100 }, { "Nutcracker", 100 }, { "Puffer", 100 }, { "Spring", 100 }, { "Baboon hawk", 100 }, { "Earth Leviathan", 100 }, { "ForestGiant", 100 }, { "MouthDog", 100 }, { "RadMech", 100 }, { "Tulip Snake", 100 }, { "Clay Surgeon", 100 }, { "Maneater", 100 }, { "Cadaver Bloom", 100 } }; private void Awake() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } EnemyEscapeConfig = ((BaseUnityPlugin)this).Config; logger = ((BaseUnityPlugin)this).Logger; logger.LogInfo((object)"Starlancer is allowing enemies to roam."); configEscapePreset = ((BaseUnityPlugin)this).Config.Bind<ConfigPreset>("EnemyEscape", "EscapePreset", ConfigPreset.ReasonableDefaults, new ConfigDescription("Which preset to use. If an enemy has a value manually set below, it will take priority.\nReasonableDefaults: Blob:2, Bunker Spider:10, Butler:5, Butler Bees:5, Centipede:0, Crawler:10, Flowerman:10, Hoarding bug:10, Jester:1, Nutcracker:5, Puffer:10, Spring:5, Baboon hawk:15, Earth Leviathan:1, ForestGiant:0, MouthDog:0, RadMech:0, Tulip Snake:5, Clay Surgeon:5, Maneater:1, Cadaver Bloom:8\nDisabled: All 0s, Minimal: All 1s, Chaos: All 100s (Use at your own risk)", (AcceptableValueBase)null, Array.Empty<object>())); harmony.PatchAll(typeof(StarlancerEnemyEscapeBase)); harmony.PatchAll(typeof(StarlancerEscapeComponent)); } internal static Dictionary<string, int> GetPresetValues(ConfigPreset preset) { return preset switch { ConfigPreset.Disabled => DisabledPresetValues, ConfigPreset.ReasonableDefaults => DefaultPresetValues, ConfigPreset.Minimal => MinimalPresetValues, ConfigPreset.Chaos => ChaosPresetValues, _ => DefaultPresetValues, }; } internal static Dictionary<string, int> GetCurrentlySelectedPreset() { return GetPresetValues(configEscapePreset.Value); } } } namespace EnemyEscape { internal class StarlancerEscapeComponent : MonoBehaviour { private const int UpdateInterval = 1; private const float TeleportCooldownTime = 5f; private const float TeleportRange = 1f; private const int intPathRangeDefault = 20; private const int extPathRangeDefault = 200; private const int cooldownTimeDefault = 30; internal static EntranceTeleport[] entranceTeleports; internal static List<EntranceTeleport> outsideTeleports = new List<EntranceTeleport>(); internal static List<EntranceTeleport> insideTeleports = new List<EntranceTeleport>(); internal static List<EnemyAI> enemiesThatCanEscape = new List<EnemyAI>(); internal static bool isSomethingBroken; internal static bool isMineshaft; internal int chanceToEscape; internal int interiorPathRange; internal int exteriorPathRange; internal int pathCooldownTime; private bool ignoreStateCheck; private bool preventPathing; private bool pathingToTeleport; private bool teleportFound; private bool closeToTeleport; private int pathRange; private float lastTeleportCheck; private float lastTeleportTime; private float lastPathAttempt; private float prevPathDistance; private Vector3 closestTeleportPosition; private Vector3 randomEnemyDestination; private Random random; private EnemyAI enemy; private NavMeshPath pathToTeleport; private EntranceTeleport closestTeleport; private Transform insideFavoriteSpot; private Transform outsideFavoriteSpot; private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003a: 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) enemy = ((Component)this).GetComponent<EnemyAI>(); pathToTeleport = new NavMeshPath(); lastTeleportCheck = Time.time; lastTeleportTime = Time.time; lastPathAttempt = Time.time; closestTeleportPosition = Vector3.negativeInfinity; prevPathDistance = float.PositiveInfinity; random = new Random(StartOfRound.Instance.randomMapSeed); interiorPathRange = StarlancerEnemyEscapeBase.configEscapeInteriorRange[enemy.enemyType.enemyName].Value; exteriorPathRange = StarlancerEnemyEscapeBase.configEscapeExteriorRange[enemy.enemyType.enemyName].Value; pathCooldownTime = StarlancerEnemyEscapeBase.configEscapeCooldownTime[enemy.enemyType.enemyName].Value; StarlancerEnemyEscapeBase.logger.LogDebug((object)("Adding EscapeComponent to " + ((Object)((Component)enemy).gameObject).name + ". It may now roam freely.")); if (StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[enemy.enemyType.enemyName].Value == -1) { chanceToEscape = StarlancerEnemyEscapeBase.GetCurrentlySelectedPreset().GetValueOrDefault(enemy.enemyType.enemyName, 0); } else { chanceToEscape = StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[enemy.enemyType.enemyName].Value; } if (chanceToEscape == 0) { StarlancerEnemyEscapeBase.logger.LogDebug((object)("ChanceToEscape is 0, removing EscapeComponent from " + ((Object)((Component)this).gameObject).name)); Object.Destroy((Object)(object)this); } else { enemiesThatCanEscape.Add(enemy); } if (enemy.isOutside) { outsideFavoriteSpot = enemy.favoriteSpot; insideFavoriteSpot = AIFix.insideAINodes[random.Next(0, AIFix.insideAINodes.Length - 1)].transform; pathRange = exteriorPathRange; } else { insideFavoriteSpot = enemy.favoriteSpot; outsideFavoriteSpot = AIFix.outsideAINodes[random.Next(0, AIFix.outsideAINodes.Length - 1)].transform; pathRange = interiorPathRange; } if (enemy is FlowermanAI) { preventPathing = true; } } private void Update() { //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Invalid comparison between Unknown and I4 //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) if (enemy.isEnemyDead || StartOfRound.Instance.allPlayersDead || RoundManager.Instance.playersManager.livingPlayers == 0) { Object.Destroy((Object)(object)this); } if (Time.time - lastTeleportCheck <= 1f) { return; } lastTeleportCheck = Time.time; if (!ignoreStateCheck && enemy.currentBehaviourStateIndex != 0) { lastPathAttempt += Time.deltaTime; } if (Time.time - lastPathAttempt > (float)pathCooldownTime || pathingToTeleport) { EnemyAI obj = enemy; HoarderBugAI val = (HoarderBugAI)(object)((obj is HoarderBugAI) ? obj : null); if (val != null) { if (val.heldItem != null) { pathingToTeleport = false; preventPathing = true; } else { preventPathing = false; } } else { EnemyAI obj2 = enemy; BaboonBirdAI val2 = (BaboonBirdAI)(object)((obj2 is BaboonBirdAI) ? obj2 : null); if (val2 != null) { if ((Object)(object)val2.heldScrap != (Object)null || (Object)(object)val2.focusedScrap != (Object)null) { pathingToTeleport = false; preventPathing = true; } else { preventPathing = false; } } } if (pathingToTeleport) { enemy.SetDestinationToPosition(closestTeleportPosition, false); enemy.agent.SetDestination(closestTeleportPosition); EnemyAI obj3 = enemy; SandSpiderAI val3 = (SandSpiderAI)(object)((obj3 is SandSpiderAI) ? obj3 : null); if (val3 != null) { Vector3 meshContainerPosition = val3.meshContainerPosition; val3.meshContainerPosition = Vector3.MoveTowards(val3.meshContainerPosition, closestTeleportPosition, val3.spiderSpeed * Time.deltaTime); val3.refVel = meshContainerPosition - val3.meshContainerPosition; val3.meshContainer.position = val3.meshContainerPosition; val3.meshContainer.rotation = Quaternion.Lerp(val3.meshContainer.rotation, val3.meshContainerTargetRotation, 8f * Time.deltaTime); } else { EnemyAI obj4 = enemy; BaboonBirdAI val4 = (BaboonBirdAI)(object)((obj4 is BaboonBirdAI) ? obj4 : null); if (val4 != null) { val4.scoutTimer = 0f; } } } else if (random.Next(0, 100) <= chanceToEscape && !preventPathing) { EntranceTeleport[] array = entranceTeleports; foreach (EntranceTeleport val5 in array) { if (!val5.FindExitPoint() || (isMineshaft && val5.entranceId == 0 && val5.isEntranceToBuilding)) { continue; } NavMesh.CalculatePath(((Component)enemy).transform.position, ((Component)val5.entrancePoint).transform.position, enemy.agent.areaMask, pathToTeleport); if ((int)pathToTeleport.status <= 0) { Vector3[] corners = pathToTeleport.corners; float num = 0f; for (int j = 1; j < corners.Length; j++) { num += Vector3.Distance(corners[j - 1], corners[j]); } if (!(num > (float)pathRange) && num < prevPathDistance) { teleportFound = true; prevPathDistance = num; closestTeleport = val5; closestTeleportPosition = ((Component)val5.entrancePoint).transform.position; } } } if (teleportFound) { pathingToTeleport = true; enemy.SetDestinationToPosition(closestTeleportPosition, false); enemy.agent.SetDestination(closestTeleportPosition); EnemyAI obj5 = enemy; SandSpiderAI val6 = (SandSpiderAI)(object)((obj5 is SandSpiderAI) ? obj5 : null); if (val6 != null) { Vector3 meshContainerPosition2 = val6.meshContainerPosition; val6.meshContainerPosition = Vector3.MoveTowards(val6.meshContainerPosition, closestTeleportPosition, val6.spiderSpeed * Time.deltaTime); val6.refVel = meshContainerPosition2 - val6.meshContainerPosition; val6.meshContainer.position = val6.meshContainerPosition; val6.meshContainer.rotation = Quaternion.Lerp(val6.meshContainer.rotation, val6.meshContainerTargetRotation, 8f * Time.deltaTime); } else { EnemyAI obj6 = enemy; BaboonBirdAI val7 = (BaboonBirdAI)(object)((obj6 is BaboonBirdAI) ? obj6 : null); if (val7 != null) { val7.LeaveCurrentScoutingGroup(true); } } } } lastPathAttempt = Time.time; } if (Time.time - lastTeleportTime < 5f) { return; } if (!pathingToTeleport) { if (enemy.isOutside) { foreach (EntranceTeleport outsideTeleport in outsideTeleports) { if (Vector3.Distance(((Component)enemy).transform.position, ((Component)outsideTeleport.entrancePoint).transform.position) < 1f) { closestTeleport = outsideTeleport; closeToTeleport = true; } } } if (!enemy.isOutside) { foreach (EntranceTeleport insideTeleport in insideTeleports) { if (Vector3.Distance(((Component)enemy).transform.position, ((Component)insideTeleport.entrancePoint).transform.position) < 1f) { closestTeleport = insideTeleport; closeToTeleport = true; } } } } if (Vector3.Distance(((Component)enemy).transform.position, closestTeleportPosition) <= 1f || closeToTeleport) { TeleportAndRefresh(); } } private void TeleportAndRefresh() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_0193: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) if (enemy.isOutside) { StarlancerEnemyEscapeBase.logger.LogDebug((object)("Warping " + ((Object)enemy).name + " inside.")); enemy.agent.Warp(insideTeleports[closestTeleport.entranceId].entrancePoint.position); enemy.SetEnemyOutside(false); pathRange = interiorPathRange; enemy.favoriteSpot = insideFavoriteSpot; } else if (!enemy.isOutside) { StarlancerEnemyEscapeBase.logger.LogDebug((object)("Warping " + ((Object)enemy).name + " outside.")); enemy.agent.Warp(outsideTeleports[closestTeleport.entranceId].entrancePoint.position); enemy.SetEnemyOutside(true); pathRange = exteriorPathRange; enemy.favoriteSpot = outsideFavoriteSpot; } EnemyAI obj = enemy; BlobAI val = (BlobAI)(object)((obj is BlobAI) ? obj : null); if (val != null) { val.centerPoint.position = ((Component)enemy.agent).transform.position; for (int i = 0; i < val.maxDistanceForSlimeRays.Length; i++) { val.maxDistanceForSlimeRays[i] = 3.7f; val.SlimeBonePositions[i] = ((Component)val.SlimeBones[i]).transform.position; } } closeToTeleport = false; lastTeleportTime = Time.time; prevPathDistance = float.PositiveInfinity; pathingToTeleport = false; teleportFound = false; randomEnemyDestination = enemy.allAINodes[random.Next(0, enemy.allAINodes.Length - 1)].transform.position; enemy.SetDestinationToPosition(randomEnemyDestination, false); enemy.agent.SetDestination(randomEnemyDestination); enemy.StopSearch(enemy.currentSearch, true); enemy.DoAIInterval(); EnemyAI val2 = enemy; if (1 == 0) { } BaboonBirdAI val3 = (BaboonBirdAI)(object)((val2 is BaboonBirdAI) ? val2 : null); AISearchRoutine val7; if (val3 == null) { HoarderBugAI val4 = (HoarderBugAI)(object)((val2 is HoarderBugAI) ? val2 : null); if (val4 == null) { BlobAI val5 = (BlobAI)(object)((val2 is BlobAI) ? val2 : null); if (val5 == null) { SandSpiderAI val6 = (SandSpiderAI)(object)((val2 is SandSpiderAI) ? val2 : null); val7 = (AISearchRoutine)((val6 == null) ? ((object)new AISearchRoutine()) : ((object)val6.patrolHomeBase)); } else { val7 = val5.searchForPlayers; } } else { val7 = val4.searchForItems; } } else { val7 = val3.scoutingSearchRoutine; } if (1 == 0) { } AISearchRoutine val8 = val7; EnemyAI obj2 = enemy; BaboonBirdAI val9 = (BaboonBirdAI)(object)((obj2 is BaboonBirdAI) ? obj2 : null); if (val9 != null) { val9.scoutingSearchRoutine.unsearchedNodes = ((EnemyAI)val9).allAINodes.ToList(); if ((Object)(object)val9.heldScrap != (Object)null) { return; } } else { EnemyAI obj3 = enemy; HoarderBugAI val10 = (HoarderBugAI)(object)((obj3 is HoarderBugAI) ? obj3 : null); if (val10 != null) { val10.searchForItems.unsearchedNodes = ((EnemyAI)val10).allAINodes.ToList(); if (val10.heldItem != null) { return; } } else { EnemyAI obj4 = enemy; CrawlerAI val11 = (CrawlerAI)(object)((obj4 is CrawlerAI) ? obj4 : null); if (val11 != null) { ((EnemyAI)val11).StartSearch(((Component)enemy).transform.position, val11.searchForPlayers); } else { EnemyAI obj5 = enemy; SpringManAI val12 = (SpringManAI)(object)((obj5 is SpringManAI) ? obj5 : null); if (val12 != null) { ((EnemyAI)val12).StartSearch(((Component)enemy).transform.position, val12.searchForPlayers); } else { EnemyAI obj6 = enemy; SandSpiderAI val13 = (SandSpiderAI)(object)((obj6 is SandSpiderAI) ? obj6 : null); if (val13 != null) { val13.homeNode = enemy.favoriteSpot; } } } } } enemy.StartSearch(((Component)enemy).transform.position, val8); } [HarmonyPatch(typeof(EnemyAI), "Start")] [HarmonyPostfix] private static void EscapeSetup(EnemyAI __instance) { //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Expected O, but got Unknown //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Expected O, but got Unknown //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Expected O, but got Unknown if (StarlancerEnemyEscapeBase.EnemyBlacklist.ContainsKey(__instance.enemyType.enemyName)) { return; } if (!StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary.ContainsKey(__instance.enemyType.enemyName)) { if (StarlancerEnemyEscapeBase.VanillaEnemyList.ContainsKey(__instance.enemyType.enemyName)) { StarlancerEnemyEscapeBase.logger.LogDebug((object)("Adding " + __instance.enemyType.enemyName + " to the StarlancerEnemyEscape config.")); StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") ?? "", -1, new ConfigDescription("Chance for " + __instance.enemyType.enemyName + " to go into or out of the facility. Set to -1 to use the value from the chosen preset.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())); StarlancerEnemyEscapeBase.logger.LogInfo((object)("Adding " + __instance.enemyType.enemyName + " to the StarlancerEnemyEscape config.")); StarlancerEnemyEscapeBase.configEscapeExteriorRange[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Exterior Range", 200, new ConfigDescription("Range at which " + __instance.enemyType.enemyName + " can detect a teleport while outside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeInteriorRange[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Interior Range", 20, new ConfigDescription("Range at which " + __instance.enemyType.enemyName + " can detect a teleport while inside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeCooldownTime[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Cooldown Time", 30, new ConfigDescription("Length of the cooldown between attempts at pathing to a nearby EntranceTeleport for " + __instance.enemyType.enemyName + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); } else { StarlancerEnemyEscapeBase.logger.LogDebug((object)("Adding " + __instance.enemyType.enemyName + " to the StarlancerEnemyEscape config.")); StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") ?? "", -1, new ConfigDescription("Chance for " + __instance.enemyType.enemyName + " to go into or out of the facility. Set to -1 to use the value from the chosen preset.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 100), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeExteriorRange[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Exterior Range", 200, new ConfigDescription("Range at which " + __instance.enemyType.enemyName + " can detect a teleport while outside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeInteriorRange[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Interior Range", 20, new ConfigDescription("Range at which " + __instance.enemyType.enemyName + " can detect a teleport while inside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeCooldownTime[__instance.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", __instance.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Cooldown Time", 30, new ConfigDescription("Length of the cooldown between attempts at pathing to a nearby EntranceTeleport for " + __instance.enemyType.enemyName + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); } } if (!isSomethingBroken && AIFix.insideAINodes.Length != 0 && (Object)(object)((Component)__instance).gameObject.GetComponent<StarlancerEscapeComponent>() == (Object)null) { StarlancerEscapeComponent starlancerEscapeComponent = ((Component)__instance).gameObject.AddComponent<StarlancerEscapeComponent>(); } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] [HarmonyPriority(0)] private static void BindRegisteredEnemies() { //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Expected O, but got Unknown //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Expected O, but got Unknown //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Expected O, but got Unknown //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Expected O, but got Unknown //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown EnemyAI[] array = Resources.FindObjectsOfTypeAll<EnemyAI>(); EnemyAI[] array2 = array; foreach (EnemyAI val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.enemyType == (Object)null) && val.enemyType.enemyName != null && !StarlancerEnemyEscapeBase.EnemyBlacklist.ContainsKey(val.enemyType.enemyName) && !StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary.ContainsKey(val.enemyType.enemyName)) { if (StarlancerEnemyEscapeBase.VanillaEnemyList.ContainsKey(val.enemyType.enemyName)) { StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") ?? "", -1, new ConfigDescription("Chance for " + val.enemyType.enemyName + " to go into or out of the facility. Set to -1 to use the value from the chosen preset.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeExteriorRange[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Exterior Range", 200, new ConfigDescription("Range at which " + val.enemyType.enemyName + " can detect a teleport while outside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeInteriorRange[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Interior Range", 20, new ConfigDescription("Range at which " + val.enemyType.enemyName + " can detect a teleport while inside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeCooldownTime[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Vanilla Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Cooldown Time", 30, new ConfigDescription("Length of the cooldown between attempts at pathing to a nearby EntranceTeleport for " + val.enemyType.enemyName + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); } else { StarlancerEnemyEscapeBase.EnemyEscapeConfigDictionary[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") ?? "", -1, new ConfigDescription("Chance for " + val.enemyType.enemyName + " to go into or out of the facility. Set to -1 to use the value from the chosen preset.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeExteriorRange[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Exterior Range", 200, new ConfigDescription("Range at which " + val.enemyType.enemyName + " can detect a teleport while outside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeInteriorRange[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Interior Range", 20, new ConfigDescription("Range at which " + val.enemyType.enemyName + " can detect a teleport while inside.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); StarlancerEnemyEscapeBase.configEscapeCooldownTime[val.enemyType.enemyName] = StarlancerEnemyEscapeBase.EnemyEscapeConfig.Bind<int>("Mod Enemies", val.enemyType.enemyName.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", "") + " Cooldown Time", 30, new ConfigDescription("Length of the cooldown between attempts at pathing to a nearby EntranceTeleport for " + val.enemyType.enemyName + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 9999), Array.Empty<object>())); } } } } [HarmonyPatch(typeof(RoundManager), "SetLevelObjectVariables")] [HarmonyPostfix] private static void EntranceTeleportsAndAINodes() { isSomethingBroken = false; isMineshaft = false; enemiesThatCanEscape.Clear(); outsideTeleports.Clear(); insideTeleports.Clear(); if (RoundManager.Instance.currentLevel.sceneName != "CompanyBuilding" && (Object)(object)RoundManager.Instance.dungeonGenerator == (Object)null && (Object)(object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow == (Object)null) { isSomethingBroken = true; StarlancerEnemyEscapeBase.logger.LogError((object)("Something related to dungeon generation is null. Aborting registration of EntranceTeleports and disabling escape functionality for this round. Moon is " + RoundManager.Instance.currentLevel.PlanetName + ". Please report this error to the author of this moon.")); return; } if (((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name == "Level3Flow") { isMineshaft = true; } entranceTeleports = Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0); for (int i = 0; i < entranceTeleports.Length; i++) { int entranceId = entranceTeleports[i].entranceId; if (entranceTeleports[i].isEntranceToBuilding) { if (!entranceTeleports[i].FindExitPoint()) { StarlancerEnemyEscapeBase.logger.LogError((object)$"EntranceTeleport {entranceId} does not have a matching interior EntranceTeleport. Interior is {((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name}. Please report this error to the author of this interior."); isSomethingBroken = true; continue; } if ((Object)(object)entranceTeleports[i].entrancePoint == (Object)null) { StarlancerEnemyEscapeBase.logger.LogError((object)$"EntranceTeleport {entranceId} does not have an entrancePoint. Moon is {RoundManager.Instance.currentLevel.PlanetName}. Please report this error to the author of this moon."); isSomethingBroken = true; continue; } outsideTeleports.Add(entranceTeleports[i]); outsideTeleports.Sort((EntranceTeleport entranceA, EntranceTeleport entranceB) => entranceA.entranceId.CompareTo(entranceB.entranceId)); StarlancerEnemyEscapeBase.logger.LogDebug((object)$"Registering exterior EntranceTeleport({entranceId})."); } else if (!entranceTeleports[i].FindExitPoint()) { StarlancerEnemyEscapeBase.logger.LogError((object)$"EntranceTeleport {entranceId} does not have a matching exterior EntranceTeleport. Moon is {RoundManager.Instance.currentLevel.PlanetName}. Please report this error to the author of this moon."); isSomethingBroken = true; } else if ((Object)(object)entranceTeleports[i].entrancePoint == (Object)null) { StarlancerEnemyEscapeBase.logger.LogError((object)$"EntranceTeleport {entranceId} does not have an entrancePoint. Interior is {((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name}. Please report this error to the author of this interior."); isSomethingBroken = true; } else { insideTeleports.Add(entranceTeleports[i]); insideTeleports.Sort((EntranceTeleport entranceA, EntranceTeleport entranceB) => entranceA.entranceId.CompareTo(entranceB.entranceId)); StarlancerEnemyEscapeBase.logger.LogDebug((object)$"Registering interior EntranceTeleport({entranceId})."); } } if (isSomethingBroken) { StarlancerEnemyEscapeBase.logger.LogWarning((object)"Escaping is disabled for this round as there is an issue with the EntranceTeleports. Please see the error logged above."); } } [HarmonyPatch(typeof(EnemyAI), "SetDestinationToPosition")] [HarmonyPrefix] private static void SetDestinationToPositionPrefix(EnemyAI __instance, ref Vector3 position, ref bool checkForPath) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) //IL_00e1: Invalid comparison between Unknown and I4 //IL_021a: 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_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Invalid comparison between Unknown and I4 //IL_010c: 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_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) if (!enemiesThatCanEscape.Contains(__instance)) { return; } StarlancerEscapeComponent component = ((Component)__instance).GetComponent<StarlancerEscapeComponent>(); bool flag = false; NavMeshPath val = new NavMeshPath(); float num = float.PositiveInfinity; if (__instance.isOutside) { Vector3[] outsideNodePositions = AIFix.outsideNodePositions; foreach (Vector3 val2 in outsideNodePositions) { if (Vector3.Distance(val2, position) < 10f) { flag = false; break; } flag = true; } if (flag) { foreach (EntranceTeleport outsideTeleport in outsideTeleports) { NavMesh.CalculatePath(((Component)__instance).transform.position, ((Component)outsideTeleport.entrancePoint).transform.position, __instance.agent.areaMask, val); if ((int)val.status <= 0) { Vector3[] corners = val.corners; float num2 = 0f; for (int j = 1; j < corners.Length; j++) { num2 += Vector3.Distance(corners[j - 1], corners[j]); } if (num2 < num) { num = num2; checkForPath = false; position = ((Component)outsideTeleport.entrancePoint).transform.position; __instance.destination = position; } } } } } if (__instance.isOutside) { return; } Vector3[] insideNodePositions = AIFix.insideNodePositions; foreach (Vector3 val3 in insideNodePositions) { if (Vector3.Distance(val3, position) < 10f) { flag = false; break; } flag = true; } if (!flag) { return; } foreach (EntranceTeleport insideTeleport in insideTeleports) { NavMesh.CalculatePath(((Component)__instance).transform.position, ((Component)insideTeleport.entrancePoint).transform.position, __instance.agent.areaMask, val); if ((int)val.status <= 0) { Vector3[] corners2 = val.corners; float num3 = 0f; for (int l = 1; l < corners2.Length; l++) { num3 += Vector3.Distance(corners2[l - 1], corners2[l]); } if (num3 < num) { num = num3; checkForPath = false; position = ((Component)insideTeleport.entrancePoint).transform.position; __instance.destination = position; } } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }