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 NaturalSelectionLib v0.8.2
DLLs/fandovec03.NaturalSelectionLib.dll
Decompiled 7 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Bootstrap; using BepInEx.Logging; using Microsoft.CodeAnalysis; using NaturalSelectionLib.Comp; using NaturalSelectionLib.Tools; using PathfindingLib.API.SmartPathfinding; using PathfindingLib.Utilities; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Fandovec03")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Personal Library with functions for getting, sorting and filtering enemies")] [assembly: AssemblyFileVersion("0.8.2.0")] [assembly: AssemblyInformationalVersion("0.8.2+6407dfa9826e96fdff49f4912e62e824b9efff67")] [assembly: AssemblyProduct("NaturalSelectionLib")] [assembly: AssemblyTitle("fandovec03.NaturalSelectionLib")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Fandovec03/NaturalSelectionLib.git")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.8.2.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 NaturalSelectionLib { [BepInPlugin("fandovec03.NaturalSelectionLib", "NaturalSelectionLib", "0.8.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Library : BaseUnityPlugin { public static bool debugLibrary = false; public static bool debugSpam = false; public static bool usePathfindingLib = false; public static ManualLogSource LibraryLogger = new ManualLogSource("NaturalSelectionLib"); private static Dictionary<Type, List<EnemyAI>> globalEnemyLists = new Dictionary<Type, List<EnemyAI>>(); public static string ReturnVersion() { return "0.8.2"; } public static void UpdateEnemyList(Type instanceType, List<EnemyAI> list) { if (!globalEnemyLists.ContainsKey(instanceType)) { LibraryLogger.LogError((object)$"EnemyLists does not contain {instanceType}!"); CreateEnemyList(instanceType, list); return; } if (globalEnemyLists[instanceType].SequenceEqual(list)) { if (debugSpam && debugLibrary) { LibraryLogger.LogInfo((object)("/updateListInsideDictionary/ Sequence in " + instanceType?.ToString() + " is equal. Skipping.")); } return; } globalEnemyLists[instanceType] = list; if (debugSpam && debugLibrary) { LibraryLogger.LogInfo((object)("/updateListInsideDictionary/ updating list for " + instanceType)); } } public static void CreateEnemyList(Type instanceType, List<EnemyAI> list) { if (!globalEnemyLists.ContainsKey(instanceType)) { globalEnemyLists.Add(instanceType, list); if (debugSpam && debugLibrary) { LibraryLogger.LogInfo((object)("/updateListInsideDictionary/ created new list for " + instanceType)); } } } public static void DestroyEnemyList(Type instanceType, List<EnemyAI> list) { if (globalEnemyLists.ContainsKey(instanceType)) { globalEnemyLists.Remove(instanceType); if (debugSpam && debugLibrary) { LibraryLogger.LogInfo((object)("/updateListInsideDictionary/ created new list for " + instanceType)); } } } public static bool EnemyListContainsKey(Type instanceType) { return globalEnemyLists.ContainsKey(instanceType); } public static List<EnemyAI> GetEnemyList(Type instanceType) { return globalEnemyLists[instanceType]; } public static void ClearAllEnemyLists() { globalEnemyLists.Clear(); } public static void SetLibraryLoggers(ManualLogSource importLogger, bool spammyLogs = false, bool debuglibrary = false, bool usePathfindinglib = false) { LibraryLogger = importLogger; debugSpam = spammyLogs; debugLibrary = debuglibrary; usePathfindingLib = usePathfindinglib; LibraryMethods.LibraryLogger = importLogger; LibraryMethods.debugLibrary = debuglibrary; LibraryMethods.debugSpam = spammyLogs; LibraryMethods.usePathfindingLib = usePathfindinglib; } } public class LibraryMethods { [CompilerGenerated] private sealed class <>c__DisplayClass15_0 { public EnemyAI __instance; internal float <FindClosestEnemy>b__0(EnemyAI x) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(((Component)__instance).transform.position, ((Component)x).transform.position); } } [CompilerGenerated] private sealed class <FindClosestEnemy>d__15 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Action<EnemyAI?> ReturnOwnerResultPairDelegate; public List<EnemyAI> importEnemyList; public EnemyAI importClosestEnemy; public EnemyAI __instance; public int maxIterations; public bool useThreatVisibility; public bool usePathLengthAsDistance; public bool includeTheDead; private <>c__DisplayClass15_0 <>8__1; private int <iterations>5__2; private List<EnemyAI>.Enumerator <>s__3; private EnemyAI <enemy>5__4; private int <i>5__5; private bool <noValidPaths>5__6; private float[] <distance>5__7; private int <j>5__8; private bool[] <validPath>5__9; private PathfindingCalculator <calculator>5__10; private IVisibleThreat <threatImportEnemyList>5__11; private IVisibleThreat <threatImportClosestEnemy>5__12; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FindClosestEnemy>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>s__3 = default(List<EnemyAI>.Enumerator); <enemy>5__4 = null; <distance>5__7 = null; <validPath>5__9 = null; <calculator>5__10 = null; <threatImportEnemyList>5__11 = null; <threatImportClosestEnemy>5__12 = null; <>1__state = -2; } private bool MoveNext() { //IL_064c: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0693; } <>1__state = -1; <>8__1 = new <>c__DisplayClass15_0(); <>8__1.__instance = __instance; <>s__3 = importEnemyList.GetEnumerator(); try { while (<>s__3.MoveNext()) { <enemy>5__4 = <>s__3.Current; if (debugLibrary) { LibraryLogger.LogInfo((object)$"{DebugStringHead(<>8__1.__instance)}/FindClosestEnemyCoroutine/ item {DebugStringHead(<enemy>5__4)} inside importEnemyList. IsEnemyDead: {<enemy>5__4.isEnemyDead}"); } <enemy>5__4 = null; } } finally { ((IDisposable)<>s__3).Dispose(); } <>s__3 = default(List<EnemyAI>.Enumerator); if (debugLibrary && (Object)(object)importClosestEnemy != (Object)null) { LibraryLogger.LogInfo((object)$"{DebugStringHead(<>8__1.__instance)}/FindClosestEnemyCoroutine/ {DebugStringHead(importClosestEnemy)} inside importClosestEnemy. IsEnemyDead: {importClosestEnemy.isEnemyDead}"); } if (importEnemyList.Count < 1) { if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(<>8__1.__instance) + "importEnemyList is empty!")); } if ((Object)(object)importClosestEnemy != (Object)null && importClosestEnemy.isEnemyDead) { if (!includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogError((object)(DebugStringHead(<>8__1.__instance) + " " + DebugStringHead(importClosestEnemy) + " is dead and importEnemyList is empty! Setting importClosestEnemy to null...")); } ReturnOwnerResultPairDelegate?.Invoke(null); return false; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(<>8__1.__instance) + " " + DebugStringHead(importClosestEnemy) + " is dead and importEnemyList is empty!")); } ReturnOwnerResultPairDelegate?.Invoke(importClosestEnemy); return false; } } importEnemyList.OrderBy((EnemyAI x) => Vector3.Distance(((Component)<>8__1.__instance).transform.position, ((Component)x).transform.position)); <iterations>5__2 = importEnemyList.Count; if (<iterations>5__2 > maxIterations) { <iterations>5__2 = maxIterations; } <i>5__5 = 0; goto IL_0989; IL_0693: if (!<calculator>5__10.CalculationnStatus(0, out <distance>5__7[0], out <validPath>5__9[0]) && !<calculator>5__10.CalculationnStatus(1, out <distance>5__7[1], out <validPath>5__9[1])) { <>2__current = null; <>1__state = 1; return true; } if (<validPath>5__9[0] == <validPath>5__9[1] && <distance>5__7[0] == -1f) { <noValidPaths>5__6 = true; } if (debugLibrary) { LibraryLogger.LogMessage((object)$"(E) Distance[0] = {<distance>5__7[0]}, Distance[1] = {<distance>5__7[1]}"); } <validPath>5__9 = null; <calculator>5__10 = null; goto IL_0767; IL_0977: <i>5__5++; goto IL_0989; IL_0989: if (<i>5__5 < <iterations>5__2) { if ((Object)(object)importClosestEnemy == (Object)null) { if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(<>8__1.__instance) + " No enemy assigned. Assigning new closestEnemy...")); } <j>5__8 = <i>5__5; while (<j>5__8 < importEnemyList.Count) { if (importEnemyList[<j>5__8].isEnemyDead && !includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(<>8__1.__instance) + " Found dead enemy. Skipping...")); } <j>5__8++; continue; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(<>8__1.__instance) + " New closestEnemy found!")); } importClosestEnemy = importEnemyList[<j>5__8]; break; } } else { if (importClosestEnemy.isEnemyDead) { if (!includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogError((object)(DebugStringHead(<>8__1.__instance) + ", " + DebugStringHead(importClosestEnemy) + " is dead! Assigning new tempClosestEnemy from importEnemyList...")); } importClosestEnemy = importEnemyList[<i>5__5]; goto IL_0977; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(<>8__1.__instance) + " " + DebugStringHead(importClosestEnemy) + " is dead! The dead enemy will be included. ")); } } if ((Object)(object)importClosestEnemy == (Object)(object)importEnemyList[<i>5__5]) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(<>8__1.__instance) + " " + DebugStringHead(importEnemyList[<i>5__5]) + " is already assigned as closestEnemy")); } } else { if (!((Object)(object)importEnemyList[<i>5__5] == (Object)null)) { <noValidPaths>5__6 = false; <distance>5__7 = new float[2]; if ((<>8__1.__instance != null) & usePathLengthAsDistance) { <validPath>5__9 = new bool[2]; <calculator>5__10 = PathfindingCalculator.Create(<>8__1.__instance, new List<Vector3>(2) { ((Component)importEnemyList[<i>5__5]).transform.position, ((Component)importClosestEnemy).transform.position }); goto IL_0693; } goto IL_0767; } if (debugLibrary) { LibraryLogger.LogError((object)(DebugStringHead(<>8__1.__instance) + " Enemy not found! Skipping...")); } } } goto IL_0977; } if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(<>8__1.__instance) + " FindClosestEnemyCoroutine returning " + DebugStringHead(importClosestEnemy))); } ReturnOwnerResultPairDelegate?.Invoke(importClosestEnemy); return false; IL_0767: if (!((Object)(object)importClosestEnemy == (Object)null) && !((Object)(object)importEnemyList[<i>5__5] == (Object)null)) { if (<noValidPaths>5__6 || !usePathLengthAsDistance) { <distance>5__7[0] = Vector3.Distance(((Component)<>8__1.__instance).transform.position, ((Component)importEnemyList[<i>5__5]).transform.position); <distance>5__7[1] = Vector3.Distance(((Component)<>8__1.__instance).transform.position, ((Component)importClosestEnemy).transform.position); } if (useThreatVisibility) { ((Component)importEnemyList[<i>5__5]).TryGetComponent<IVisibleThreat>(ref <threatImportEnemyList>5__11); ((Component)importClosestEnemy).TryGetComponent<IVisibleThreat>(ref <threatImportClosestEnemy>5__12); if (<threatImportEnemyList>5__11 != null) { <distance>5__7[0] *= <threatImportEnemyList>5__11.GetVisibility(); } if (<threatImportClosestEnemy>5__12 != null) { <distance>5__7[1] *= <threatImportClosestEnemy>5__12.GetVisibility(); } <threatImportEnemyList>5__11 = null; <threatImportClosestEnemy>5__12 = null; } if (<distance>5__7[0] < <distance>5__7[1]) { importClosestEnemy = importEnemyList[<i>5__5]; if (debugLibrary) { LibraryLogger.LogInfo((object)(DebugStringHead(<>8__1.__instance) + " Assigned " + DebugStringHead(importEnemyList[<i>5__5]) + " as new closestEnemy. Distance: " + <distance>5__7[0])); } } <distance>5__7 = null; } goto IL_0977; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool debugLibrary = false; public static bool debugSpam = false; public static bool usePathfindingLib = false; public static ManualLogSource LibraryLogger = new ManualLogSource("NaturalSelectionLib"); public static string DebugStringHead(object? source, bool shortFormat = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_0206: Unknown result type (might be due to invalid IL or missing references) string result = ""; if (source != null) { string text = ""; if (source is EnemyAI) { EnemyAI val = (EnemyAI)source; text = $"{val.enemyType.enemyName}|ID: {((NetworkBehaviour)val).NetworkObjectId}|ThisEnemyIndex: {val.thisEnemyIndex}"; if (shortFormat) { text = $"{val?.enemyType.enemyName}|ID: {((val != null) ? new ulong?(((NetworkBehaviour)val).NetworkObjectId) : null)}"; } } else if (source is SandSpiderWebTrap) { SandSpiderWebTrap val2 = (SandSpiderWebTrap)source; text = $"Spider web {val2.trapID}"; if (!shortFormat) { text = $"Spider web {val2.trapID}, Owner {DebugStringHead(val2.mainScript)}"; } } else if (source is GrabbableObject) { GrabbableObject val3 = (GrabbableObject)source; text = $"{val3.itemProperties.itemName}, ID: {((NetworkBehaviour)val3).NetworkObjectId}"; if (!shortFormat) { text = $"{val3.itemProperties.itemName}|ID: {((NetworkBehaviour)val3).NetworkObjectId}|ItemID: {val3.itemProperties.itemId}"; } } else if (!(source is GameObject)) { text = ((source is Item) ? $"{((Item)source).itemName}, ID: {((Item)source).itemId}" : ((!(source is string)) ? "Unknown source" : ((string)source))); } else { EnemyAI source2 = default(EnemyAI); if (((GameObject)source).TryGetComponent<EnemyAI>(ref source2)) { return DebugStringHead(source2, shortFormat); } SandSpiderWebTrap source3 = default(SandSpiderWebTrap); if (((GameObject)source).TryGetComponent<SandSpiderWebTrap>(ref source3)) { return DebugStringHead(source3, shortFormat); } GrabbableObject source4 = default(GrabbableObject); if (((GameObject)source).TryGetComponent<GrabbableObject>(ref source4)) { return DebugStringHead(source4, shortFormat); } text = ((Object)(GameObject)source).name; } result = "(" + text + ")"; } return result; } public static List<EnemyAI> GetCompleteList(EnemyAI instance, bool filterThemselves = true, int includeOrReturnTheDead = 0) { List<EnemyAI> list = new List<EnemyAI>(RoundManager.Instance.SpawnedEnemies); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] == (Object)(object)instance) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found itself in the list. Removing...")); } list.Remove(list[i]); } else if (((object)list[i]).GetType() == ((object)instance).GetType() && filterThemselves) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found its type in the list. Removing...")); } list.Remove(list[i]); } else { if (!list[i].isEnemyDead) { continue; } switch (includeOrReturnTheDead) { case 0: if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(instance) + " Found dead enemy in the list. Removing...")); } list.Remove(list[i]); break; case 1: if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(instance) + " Found dead enemy in the list. Proceeding...")); } break; case 2: if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(instance) + " Found living enemy in the list. Removing..")); } list.Remove(list[i]); break; } } } return list; } public static List<EnemyAI> GetNearbyEnemies(EnemyAI instance, float radius = 0f, Vector3? importEyePosition = null, int includeOrReturnTheDead = 0) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) List<EnemyAI> list = new List<EnemyAI>(); Vector3 val = instance.eye.position; if (importEyePosition.HasValue) { val = importEyePosition.Value; } int mask = LayerMask.GetMask(new string[1] { "Enemies" }); int num = Physics.OverlapSphereNonAlloc(val, radius, RoundManager.Instance.tempColliderResults, mask, (QueryTriggerInteraction)2); EnemyAICollisionDetect val2 = default(EnemyAICollisionDetect); for (int i = 0; i < num; i++) { if (!((Component)RoundManager.Instance.tempColliderResults[i]).gameObject.TryGetComponent<EnemyAICollisionDetect>(ref val2)) { continue; } EnemyAI mainScript = val2.mainScript; if ((Object)(object)mainScript == (Object)(object)instance || list.Contains(mainScript)) { continue; } if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " /GetEnemiesInLOS/: Enemy not found in imported enemy list! Skipping...")); } switch (includeOrReturnTheDead) { case 0: if (!mainScript.isEnemyDead) { list.Add(mainScript); } break; case 1: list.Add(mainScript); break; case 2: if (mainScript.isEnemyDead) { list.Add(mainScript); } break; } } return list; } public static bool GetPathLength(NavMeshAgent agent, Vector3 targetDestination, out float PathLength, out bool validPathOut) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) NavMeshPath val = new NavMeshPath(); bool flag = false; bool flag2 = false; Vector3[] array = Array.Empty<Vector3>(); PathLength = -1f; validPathOut = false; if (!((Behaviour)agent).enabled || !((Behaviour)agent).isActiveAndEnabled) { LibraryLogger.LogWarning((object)"Agent is disabled!"); PathLength = -1f; return false; } flag2 = (validPathOut = agent.CalculatePath(targetDestination, val) && (int)val.status == 0); array = val.corners; if (flag2) { float num = 0f; for (int i = 1; i < array.Length; i++) { float num2 = Vector3.Distance(array[i - 1], array[i]); num += num2; } PathLength = num; if (debugLibrary) { LibraryLogger.LogMessage((object)$"Found path length: {PathLength}"); } return true; } return false; } public static void GetInsideOrOutsideEnemyList(ref List<EnemyAI> importEnemyList, EnemyAI instance) { foreach (EnemyAI item in importEnemyList.ToList()) { if ((Object)(object)item == (Object)(object)instance || item.isOutside != instance.isOutside) { importEnemyList.Remove(item); if (debugLibrary && debugSpam) { LibraryLogger.LogDebug((object)(DebugStringHead(instance) + "/GetInsideOrOutsideEnemyList/ removed " + DebugStringHead(item))); } } } } public static EnemyAI? FindClosestEnemy(ref List<EnemyAI> importEnemyList, EnemyAI? importClosestEnemy, EnemyAI __instance, int maxIterations = 6, bool useThreatVisibility = true, bool usePathLengthAsDistance = false, bool includeTheDead = false) { //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) EnemyAI __instance2 = __instance; foreach (EnemyAI importEnemy in importEnemyList) { if (debugLibrary) { LibraryLogger.LogInfo((object)$"{DebugStringHead(__instance2)}/FindClosestEnemy/ item {DebugStringHead(importEnemy)} inside importEnemyList. IsEnemyDead: {importEnemy.isEnemyDead}"); } } if (debugLibrary && (Object)(object)importClosestEnemy != (Object)null) { LibraryLogger.LogInfo((object)$"{DebugStringHead(__instance2)}/FindClosestEnemy/ {DebugStringHead(importClosestEnemy)} inside importClosestEnemy. IsEnemyDead: {importClosestEnemy.isEnemyDead}"); } if (importEnemyList.Count < 1) { if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(__instance2) + "importEnemyList is empty!")); } if ((Object)(object)importClosestEnemy != (Object)null && importClosestEnemy.isEnemyDead) { if (!includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogError((object)(DebugStringHead(__instance2) + " " + DebugStringHead(importClosestEnemy) + " is dead and importEnemyList is empty! Setting importClosestEnemy to null...")); } return null; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(__instance2) + " " + DebugStringHead(importClosestEnemy) + " is dead and importEnemyList is empty!")); } return importClosestEnemy; } } importEnemyList.OrderBy((EnemyAI x) => Vector3.Distance(((Component)__instance2).transform.position, ((Component)x).transform.position)); int num = importEnemyList.Count; if (num > maxIterations) { num = maxIterations; } IVisibleThreat val = default(IVisibleThreat); IVisibleThreat val2 = default(IVisibleThreat); for (int i = 0; i < num; i++) { if ((Object)(object)importClosestEnemy == (Object)null) { if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(__instance2) + " No enemy assigned. Assigning new closestEnemy...")); } for (int j = i; j < importEnemyList.Count; j++) { if (importEnemyList[j].isEnemyDead && !includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(__instance2) + " Found dead enemy. Skipping...")); } continue; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(__instance2) + " New closestEnemy found!")); } importClosestEnemy = importEnemyList[j]; break; } continue; } if (importClosestEnemy.isEnemyDead) { if (!includeTheDead) { if (debugLibrary && debugSpam) { LibraryLogger.LogError((object)(DebugStringHead(__instance2) + ", " + DebugStringHead(importClosestEnemy) + " is dead! Assigning new tempClosestEnemy from importEnemyList...")); } importClosestEnemy = importEnemyList[i]; continue; } if (debugLibrary && debugSpam) { LibraryLogger.LogInfo((object)(DebugStringHead(__instance2) + " " + DebugStringHead(importClosestEnemy) + " is dead! The dead enemy will be included. ")); } } if ((Object)(object)importClosestEnemy == (Object)(object)importEnemyList[i]) { if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(__instance2) + " " + DebugStringHead(importEnemyList[i]) + " is already assigned as closestEnemy")); } continue; } if ((Object)(object)importEnemyList[i] == (Object)null) { if (debugLibrary) { LibraryLogger.LogError((object)(DebugStringHead(__instance2) + " Enemy not found! Skipping...")); } continue; } bool flag = false; float[] array = new float[2]; if (usePathLengthAsDistance && ((Behaviour)__instance2.agent).isActiveAndEnabled && GetPathLength(__instance2.agent, ((Component)importEnemyList[i]).transform.position, out array[0], out var _) && GetPathLength(__instance2.agent, ((Component)importClosestEnemy).transform.position, out array[1], out var _)) { if (array[0] == array[1] && array[0] == -777.77f) { flag = true; } if (debugLibrary) { LibraryLogger.LogMessage((object)$"Distance[0] = {array[0]}, Distance[1] = {array[1]}"); } } if (flag || !usePathLengthAsDistance) { array[0] = Vector3.Distance(((Component)__instance2).transform.position, ((Component)importEnemyList[i]).transform.position); array[1] = Vector3.Distance(((Component)__instance2).transform.position, ((Component)importClosestEnemy).transform.position); } if (useThreatVisibility) { ((Component)importEnemyList[i]).TryGetComponent<IVisibleThreat>(ref val); ((Component)importClosestEnemy).TryGetComponent<IVisibleThreat>(ref val2); if (val != null) { array[0] *= val.GetVisibility(); } if (val2 != null) { array[1] *= val2.GetVisibility(); } } if (array[0] < array[1]) { importClosestEnemy = importEnemyList[i]; if (debugLibrary) { LibraryLogger.LogInfo((object)(DebugStringHead(__instance2) + " Assigned " + DebugStringHead(importEnemyList[i]) + " as new closestEnemy. Distance: " + array[0])); } } } if (debugLibrary && debugSpam) { LibraryLogger.LogWarning((object)(DebugStringHead(__instance2) + " findClosestEnemy returning " + DebugStringHead(importClosestEnemy))); } return importClosestEnemy; } public static void FilterEnemyList(ref List<EnemyAI> importEnemyList, List<string>? blacklist, EnemyAI instance, bool filterOutImmortal = true, bool filterTheSameType = true) { List<EnemyAI> list = new List<EnemyAI>(importEnemyList); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] == (Object)(object)instance) { if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found itself in importEnemyList! Skipping...")); } importEnemyList.Remove(list[i]); continue; } if (filterTheSameType && ((object)list[i]).GetType() == ((object)instance).GetType()) { if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found its own type in importEnemyList! Skipping...")); } importEnemyList.Remove(list[i]); continue; } try { if (blacklist != null && (Object)(object)list[i] != (Object)null && (blacklist.Contains(list[i].enemyType.enemyName) || blacklist.Contains(((Object)list[i].enemyType).name) || ((Object)(object)((Component)list[i]).GetComponentInChildren<ScanNodeProperties>() != (Object)null && blacklist.Contains(((Component)list[i]).GetComponentInChildren<ScanNodeProperties>().headerText)))) { if (debugLibrary && blacklist.Contains(list[i].enemyType.enemyName)) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found blacklisted enemy in importEnemyList by EnemyType enemyName! Skipping...")); } if (debugLibrary && blacklist.Contains(((Object)list[i].enemyType).name)) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found blacklisted enemy in importEnemyList by EnemyType name! Skipping...")); } if (debugLibrary && blacklist.Contains(((Component)list[i]).GetComponentInChildren<ScanNodeProperties>().headerText)) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " Found blacklisted enemy in importEnemyList by scan node headertext! Skipping...")); } importEnemyList.Remove(list[i]); continue; } } catch (Exception ex) { LibraryLogger.LogError((object)(DebugStringHead(instance) + " Something went wrong.")); LibraryLogger.LogError((object)blacklist); LibraryLogger.LogError((object)list[i]); LibraryLogger.LogError((object)list[i].enemyType.enemyName.ToUpper()); LibraryLogger.LogError((object)((Component)list[i]).GetComponentInChildren<ScanNodeProperties>().headerText.ToUpper()); LibraryLogger.LogError((object)ex.ToString()); } if (filterOutImmortal && !list[i].enemyType.canDie) { if (debugLibrary) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} Caught and filtered out immortal Enemy of type {((object)list[i]).GetType()}"); } importEnemyList.Remove(list[i]); } } } public static void FilterEnemySizes(ref List<EnemyAI> importEnemyList, EnemySize[] enemySizes, EnemyAI instance, bool inverseToggle = false) { //IL_0028: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) List<EnemyAI> list = new List<EnemyAI>(importEnemyList); for (int i = 0; i < list.Count; i++) { if (enemySizes != null && enemySizes.Length != 0 && ((!inverseToggle && enemySizes.Contains(list[i].enemyType.EnemySize)) || (inverseToggle && !enemySizes.Contains(list[i].enemyType.EnemySize)))) { if (debugLibrary) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} Enemy of size {list[i].enemyType.EnemySize} passed the filter. inverseToggle: {inverseToggle}"); } } else if (enemySizes != null && enemySizes.Length != 0) { if (debugLibrary) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} Caught and filtered out Enemy of size {list[i].enemyType.EnemySize}"); } importEnemyList.Remove(list[i]); continue; } if (enemySizes == null || enemySizes.Length < 1) { if (debugLibrary && enemySizes != null && enemySizes.Length < 1) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} enemySizes is empty. Adding enemy of size {list[i].enemyType.EnemySize} by default"); } if (debugLibrary && enemySizes == null) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} enemySizes is NULL. Adding enemy of size {list[i].enemyType.EnemySize} by default"); } } } } public static void FilterEnemySizes(ref Dictionary<EnemyAI, int> importEnemySizeDict, int[] enemySizes, EnemyAI instance, bool inverseToggle = false) { Dictionary<EnemyAI, int> dictionary = new Dictionary<EnemyAI, int>(importEnemySizeDict); foreach (KeyValuePair<EnemyAI, int> item in dictionary) { if (enemySizes != null && enemySizes.Length != 0 && ((!inverseToggle && enemySizes.Contains(item.Value)) || (inverseToggle && !enemySizes.Contains(item.Value)))) { if (debugLibrary) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} Enemy of size {item.Value} passed the filter. inverseToggle: {inverseToggle}"); } } else if (enemySizes != null && enemySizes.Length != 0) { if (debugLibrary) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} Caught and filtered out Enemy of size {item.Value}"); } importEnemySizeDict.Remove(item.Key); continue; } if (enemySizes == null || enemySizes.Length < 1) { if (debugLibrary && enemySizes != null && enemySizes.Length < 1) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} enemySizes is empty. Adding enemy of size {item.Value} by default"); } if (debugLibrary && enemySizes == null) { LibraryLogger.LogInfo((object)$"{DebugStringHead(instance)} enemySizes is NULL. Adding enemy of size {item.Value} by default"); } } } } public static Dictionary<EnemyAI, float> GetEnemiesInLOS(EnemyAI instance, ref List<EnemyAI> importEnemyList, float width = 45f, float importRange = 0f, float proximityAwareness = -1f, float importRadius = 0f, Vector3? importEyePosition = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01e2: Unknown result type (might be due to invalid IL or missing references) Dictionary<EnemyAI, float> tempDictionary = new Dictionary<EnemyAI, float>(); float num = importRange; float num2 = importRadius; Vector3 val = instance.eye.position; if (importEyePosition.HasValue) { val = importEyePosition.Value; } int mask = LayerMask.GetMask(new string[1] { "Enemies" }); if (instance.isOutside && !instance.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3) { num = Mathf.Clamp(importRange, 0f, 30f); } if (num2 <= 0f) { num2 = num * 2f; } int num3 = Physics.OverlapSphereNonAlloc(val, num2, RoundManager.Instance.tempColliderResults, mask, (QueryTriggerInteraction)2); EnemyAICollisionDetect val2 = default(EnemyAICollisionDetect); for (int i = 0; i < num3; i++) { if (!((Component)RoundManager.Instance.tempColliderResults[i]).gameObject.TryGetComponent<EnemyAICollisionDetect>(ref val2)) { continue; } EnemyAI mainScript = val2.mainScript; if ((Object)(object)mainScript == (Object)(object)instance) { continue; } if (!importEnemyList.Contains(mainScript)) { if (debugLibrary) { LibraryLogger.LogWarning((object)(DebugStringHead(instance) + " /GetEnemiesInLOS/: Enemy not found in imported enemy list! Skipping...")); } continue; } Vector3 position = ((Component)mainScript).transform.position; if (!(Vector3.Distance(position, instance.eye.position) < num) || Physics.Linecast(instance.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !instance.CheckLineOfSightForPosition(position, width, (int)num, proximityAwareness, instance.eye)) { continue; } if (!tempDictionary.ContainsKey(mainScript)) { tempDictionary.Add(mainScript, Vector3.Distance(((Component)instance).transform.position, position)); if (debugLibrary && debugSpam) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: Added {mainScript} to tempDictionary"); } } if (tempDictionary.ContainsKey(mainScript) && debugLibrary && debugSpam && debugLibrary) { LibraryLogger.LogWarning((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: {mainScript} is already in tempDictionary"); } } if (tempDictionary.Count > 1) { tempDictionary.OrderBy<KeyValuePair<EnemyAI, float>, Dictionary<EnemyAI, float>.ValueCollection>((KeyValuePair<EnemyAI, float> value) => tempDictionary.Values).Reverse(); if (debugLibrary) { foreach (KeyValuePair<EnemyAI, float> item in tempDictionary) { if (debugLibrary && debugSpam) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: Final list: {item.Key}, range: {item.Value}"); } } } } return tempDictionary; } public static Dictionary<EnemyAI, float> GetEnemiesInLOS(EnemyAI instance, float width = 45f, float importRange = 0f, float proximityAwareness = -1f, float importRadius = 0f, Vector3? importEyePosition = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) Dictionary<EnemyAI, float> tempDictionary = new Dictionary<EnemyAI, float>(); float num = importRange; float num2 = importRadius; Vector3 val = instance.eye.position; if (importEyePosition.HasValue) { val = importEyePosition.Value; } int mask = LayerMask.GetMask(new string[1] { "Enemies" }); if (instance.isOutside && !instance.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3) { num = Mathf.Clamp(importRange, 0f, 30f); } if (num2 <= 0f) { num2 = num * 2f; } int num3 = Physics.OverlapSphereNonAlloc(val, num2, RoundManager.Instance.tempColliderResults, mask, (QueryTriggerInteraction)2); EnemyAICollisionDetect val2 = default(EnemyAICollisionDetect); for (int i = 0; i < num3; i++) { if (!((Component)RoundManager.Instance.tempColliderResults[i]).gameObject.TryGetComponent<EnemyAICollisionDetect>(ref val2)) { continue; } EnemyAI mainScript = val2.mainScript; if ((Object)(object)mainScript == (Object)(object)instance) { continue; } Vector3 position = ((Component)mainScript).transform.position; if (!(Vector3.Distance(position, instance.eye.position) < num) || Physics.Linecast(instance.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !instance.CheckLineOfSightForPosition(position, width, (int)num, proximityAwareness, instance.eye)) { continue; } if (!tempDictionary.ContainsKey(mainScript)) { tempDictionary.Add(mainScript, Vector3.Distance(((Component)instance).transform.position, position)); if (debugLibrary && debugSpam) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: Added {mainScript} to tempDictionary"); } } if (tempDictionary.ContainsKey(mainScript) && debugLibrary && debugSpam && debugLibrary) { LibraryLogger.LogWarning((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: {mainScript} is already in tempDictionary"); } } if (tempDictionary.Count > 1) { tempDictionary.OrderBy<KeyValuePair<EnemyAI, float>, Dictionary<EnemyAI, float>.ValueCollection>((KeyValuePair<EnemyAI, float> value) => tempDictionary.Values).Reverse(); if (debugLibrary) { foreach (KeyValuePair<EnemyAI, float> item in tempDictionary) { if (debugLibrary && debugSpam) { LibraryLogger.LogDebug((object)$"{DebugStringHead(instance)} /GetEnemiesInLOS/: Final list: {item.Key}, range: {item.Value}"); } } } } return tempDictionary; } [IteratorStateMachine(typeof(<FindClosestEnemy>d__15))] public static IEnumerator FindClosestEnemy(Action<EnemyAI?>? ReturnOwnerResultPairDelegate, List<EnemyAI> importEnemyList, EnemyAI? importClosestEnemy, EnemyAI __instance, int maxIterations = 6, bool useThreatVisibility = true, bool usePathLengthAsDistance = false, bool includeTheDead = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FindClosestEnemy>d__15(0) { ReturnOwnerResultPairDelegate = ReturnOwnerResultPairDelegate, importEnemyList = importEnemyList, importClosestEnemy = importClosestEnemy, __instance = __instance, maxIterations = maxIterations, useThreatVisibility = useThreatVisibility, usePathLengthAsDistance = usePathLengthAsDistance, includeTheDead = includeTheDead }; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "fandovec03.NaturalSelectionLib"; public const string PLUGIN_NAME = "NaturalSelectionLib"; public const string PLUGIN_VERSION = "0.8.2"; } } namespace NaturalSelectionLib.Comp { internal static class PathfindingLibHelper { public static PathfindingCalculatorAsyncPathfindingLib ReturnPathfindingLibalculator(EnemyAI instance, List<Vector3> destinations) { return new PathfindingCalculatorAsyncPathfindingLib(instance, destinations); } } internal class PathfindingCalculatorAsyncPathfindingLib : PathfindingCalculator { private SmartPathTask pathfindingTask = new SmartPathTask(); internal PathfindingCalculatorAsyncPathfindingLib(EnemyAI instance, List<Vector3> destinations) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) pathfindingTask.StartPathTask(instance.agent, AgentExtensions.GetPathOrigin(instance.agent), destinations, (SmartPathfindingLinkFlags)0); } public override bool CalculationnStatus(int index, out float pathLengthResult, out bool validPath) { pathLengthResult = -1f; validPath = false; if (!pathfindingTask.IsResultReady(index)) { return true; } if (pathfindingTask.PathSucceeded(index)) { pathLengthResult = pathfindingTask.GetPathLength(index); validPath = pathfindingTask.PathSucceeded(index); return true; } return true; } public override void Dispose() { base.Dispose(); pathfindingTask.Dispose(); } } } namespace NaturalSelectionLib.Tools { internal abstract class PathfindingCalculator : IDisposable { internal static PathfindingCalculator Create(EnemyAI instance, List<Vector3> destinations) { if (Chainloader.PluginInfos.ContainsKey("Zaggy1024.PathfindingLib") && !Library.usePathfindingLib) { return PathfindingLibHelper.ReturnPathfindingLibalculator(instance, destinations); } return new PathfindingCalculatorAsync(instance, destinations); } public abstract bool CalculationnStatus(int index, out float pathLengthResult, out bool validPath); public virtual void Dispose() { } } internal class PathfindingCalculatorAsync : PathfindingCalculator { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private EnemyAI <instance>P; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private List<Vector3> <destinations>P; private NavMeshPath path; public PathfindingCalculatorAsync(EnemyAI instance, List<Vector3> destinations) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown <instance>P = instance; <destinations>P = destinations; path = new NavMeshPath(); base..ctor(); } public override bool CalculationnStatus(int index, out float pathLengthResult, out bool validPath) { //IL_001d: 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_003a: Invalid comparison between Unknown and I4 //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) pathLengthResult = -1f; validPath = false; <instance>P.agent.CalculatePath(<destinations>P[index], path); if ((int)path.status > 0) { return true; } pathLengthResult = 0f; for (int i = 1; i < path.corners.Length; i++) { validPath = true; pathLengthResult += Vector3.Distance(path.corners[i - 1], path.corners[i]); } return true; } } }