Decompiled source of CoopBot v1.0.5
CoopBot.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using Dungeonator; using HarmonyLib; using InControl; using Pathfinding; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace CoopBot; public enum PartnerKind { Player, Enemy } public static class AllyPartner { public static AIActor Actor; public const float DamageMultiplier = 2.5f; private const float PreferredMin = 5f; private const float PreferredMax = 8.5f; private static float m_nextPath; private static float m_nextAggro; private static float m_nextCover; private static float m_lastHp = -1f; private static float m_lastHurt = -10f; private static float m_roomMismatchSince = -1f; private static bool m_pendingRespawn; private static float m_nextRespawn; private static float m_lastSummonAt; public static readonly Color BulletColor = new Color(0.35f, 0.65f, 1f, 1f); private static float m_dodgeUntil; private static Vector2 m_dodgeDir; private static float m_strafeSign = 1f; private static float m_nextStrafe; private static bool m_hasCover; private static Vector2 m_coverSpot; private static List<EnemyDatabaseEntry> s_choices; private static readonly HashSet<AIActor> s_steered = new HashSet<AIActor>(); private static int s_tintedTotal; private static float m_nextStatus; private static readonly HashSet<Projectile> s_blue = new HashSet<Projectile>(); public static bool Active => (Object)(object)Actor != (Object)null; public static List<EnemyDatabaseEntry> Choices() { if (s_choices != null) { return s_choices; } s_choices = new List<EnemyDatabaseEntry>(); if (!EnemyDatabase.HasInstance) { return s_choices; } foreach (EnemyDatabaseEntry entry in ((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries) { if (entry != null && !entry.isInBossTab && !string.IsNullOrEmpty(((AssetBundleDatabaseEntry)entry).name)) { s_choices.Add(entry); } } s_choices.Sort((EnemyDatabaseEntry a, EnemyDatabaseEntry b) => string.CompareOrdinal(((AssetBundleDatabaseEntry)a).name, ((AssetBundleDatabaseEntry)b).name)); return s_choices; } public static void Summon(string guid) { //IL_0044: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Invalid comparison between Unknown and I4 //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer; if ((Object)(object)primaryPlayer == (Object)null || primaryPlayer.CurrentRoom == null) { CoopBotPlugin.Say("Ally: no room to summon into."); return; } AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(guid); if ((Object)(object)orLoadByGuid == (Object)null) { CoopBotPlugin.Say("Ally: can't load that enemy."); return; } AIActor val = AIActor.Spawn(orLoadByGuid, ((GameActor)primaryPlayer).CenterPosition + new Vector2(1.5f, 0f), primaryPlayer.CurrentRoom, true, (AwakenAnimationType)0, true); if ((Object)(object)val == (Object)null) { CoopBotPlugin.Say("Ally: that enemy can't be summoned here."); return; } val.CompanionOwner = primaryPlayer; val.IsNormalEnemy = false; val.CanTargetPlayers = false; val.CanTargetEnemies = true; CompanionController val2 = ((Component)val).GetComponent<CompanionController>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).gameObject.AddComponent<CompanionController>(); } val2.Initialize(primaryPlayer); val.IgnoreForRoomClear = true; SpeculativeRigidbody specRigidbody = ((BraveBehaviour)val).specRigidbody; specRigidbody.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)0)); foreach (PixelCollider pixelCollider in specRigidbody.PixelColliders) { if ((int)pixelCollider.CollisionLayer == 2) { pixelCollider.CollisionLayer = (CollisionLayer)0; pixelCollider.IsTrigger = false; pixelCollider.CollisionLayerIgnoreOverride &= ~CollisionMask.LayerToMask((CollisionLayer)4, (CollisionLayer)0); } } specRigidbody.Reinitialize(); Action<Projectile> b = delegate(Projectile p) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (!((Object)(object)p == (Object)null) && p.baseData != null) { p.baseData = new ProjectileData(p.baseData); ProjectileData baseData = p.baseData; baseData.damage *= 2.5f; } }; AIShooter component = ((Component)val).GetComponent<AIShooter>(); if ((Object)(object)((BraveBehaviour)val).bulletBank != (Object)null) { AIBulletBank bulletBank = ((BraveBehaviour)val).bulletBank; bulletBank.OnProjectileCreated = (Action<Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, b); } else if ((Object)(object)component != (Object)null) { component.PostProcessProjectile = (Action<Projectile>)Delegate.Combine(component.PostProcessProjectile, b); } val.SetOutlines(true); val.SetOverrideOutlineColor(BulletColor); Actor = val; m_lastSummonAt = Time.time; m_lastHp = -1f; m_hasCover = false; CoopBotPlugin.Say("Ally online: " + val.GetActorName() + ". Shift+H dismisses it."); } public static void Tick() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) RecolorBullets(); if ((Object)(object)Actor == (Object)null) { TryRespawn(); return; } PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer; if ((Object)(object)primaryPlayer == (Object)null || ((BraveBehaviour)primaryPlayer).healthHaver.IsDead || primaryPlayer.IsGhost || GameManager.Instance.IsFoyer) { Dismiss(announce: false); return; } if ((Object)(object)((BraveBehaviour)Actor).healthHaver == (Object)null || ((BraveBehaviour)Actor).healthHaver.IsDead) { CoopBotPlugin.Say("Ally fell."); CoopBotPlugin.Log("Ally diag: fell " + (Time.time - m_lastSummonAt).ToString("0.0") + "s after summon, hp=" + ((BraveBehaviour)Actor).healthHaver.GetCurrentHealth()); Dismiss(announce: false); m_pendingRespawn = true; return; } Vector2 unitCenter = ((BraveBehaviour)Actor).specRigidbody.UnitCenter; Vector2 unitCenter2 = ((BraveBehaviour)primaryPlayer).specRigidbody.UnitCenter; float num = Vector2.Distance(unitCenter, unitCenter2); if (primaryPlayer.CurrentRoom != null && Actor.ParentRoom != primaryPlayer.CurrentRoom) { if (m_roomMismatchSince < 0f) { m_roomMismatchSince = Time.time; } if (Time.time - m_roomMismatchSince > 0.5f) { m_roomMismatchSince = -1f; PlaceNearPlayer(primaryPlayer); } return; } m_roomMismatchSince = -1f; if (num > 30f) { PlaceNearPlayer(primaryPlayer); return; } float currentHealth = ((BraveBehaviour)Actor).healthHaver.GetCurrentHealth(); if (m_lastHp >= 0f && currentHealth < m_lastHp) { m_lastHurt = Time.time; } m_lastHp = currentHealth; RoomHandler room = Actor.ParentRoom ?? primaryPlayer.CurrentRoom; List<AIActor> list = Foes(room); if (list.Count == 0) { m_hasCover = false; Actor.OverrideTarget = null; Actor.BehaviorOverridesVelocity = false; if (num > 4f && Time.time >= m_nextPath) { m_nextPath = Time.time + 0.5f; Actor.PathfindToPosition(unitCenter2, (Vector2?)null, true, (CellValidator)null, (ExtraWeightingFunction)null, (CellTypes?)null, false); } else if (num < 2.5f) { Actor.ClearPath(); } } else { if (Time.time >= m_nextAggro) { m_nextAggro = Time.time + 0.25f; ShareAggro(list, unitCenter, unitCenter2, primaryPlayer); } CombatMove(room, list, unitCenter, unitCenter2, num); } } private static List<AIActor> Foes(RoomHandler room) { List<AIActor> list = new List<AIActor>(); if (room == null) { return list; } List<AIActor> activeEnemies = room.GetActiveEnemies((ActiveEnemyType)0); if (activeEnemies == null) { return list; } for (int i = 0; i < activeEnemies.Count; i++) { AIActor val = activeEnemies[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Actor) && !((Object)(object)((BraveBehaviour)val).healthHaver == (Object)null) && !((BraveBehaviour)val).healthHaver.IsDead && !val.IsHarmlessEnemy && !((Object)(object)val.CompanionOwner != (Object)null) && !((Object)(object)((BraveBehaviour)val).specRigidbody == (Object)null) && ((Behaviour)val).isActiveAndEnabled) { list.Add(val); } } return list; } private static void ShareAggro(List<AIActor> foes, Vector2 apos, Vector2 ppos, PlayerController prim) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) for (int i = 0; i < foes.Count; i++) { AIActor val = foes[i]; if ((Object)(object)val == (Object)null || (Object)(object)((BraveBehaviour)val).specRigidbody == (Object)null) { continue; } Vector2 unitCenter = ((BraveBehaviour)val).specRigidbody.UnitCenter; float num = Vector2.Distance(unitCenter, apos); float num2 = Vector2.Distance(unitCenter, ppos); if (Mathf.Min(num, num2) > 14f) { if (s_steered.Remove(val)) { val.OverrideTarget = null; } } else { bool flag = ((Mathf.Abs(num - num2) < 2f) ? ((((Object)val).GetInstanceID() & 1) == 0) : (num < num2)); val.OverrideTarget = (flag ? ((BraveBehaviour)Actor).specRigidbody : ((BraveBehaviour)prim).specRigidbody); s_steered.Add(val); } } } private static void CombatMove(RoomHandler room, List<AIActor> foes, Vector2 apos, Vector2 ppos, float distToPlayer) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) AIActor val = null; float num = float.MaxValue; for (int i = 0; i < foes.Count; i++) { float num2 = Vector2.Distance(((BraveBehaviour)foes[i]).specRigidbody.UnitCenter, apos); if (num2 < num) { num = num2; val = foes[i]; } } Vector2 unitCenter = ((BraveBehaviour)val).specRigidbody.UnitCenter; Actor.OverrideTarget = ((BraveBehaviour)val).specRigidbody; float num3 = Mathf.Max(3.5f, Actor.MovementSpeed); Vector2 move = Vector2.zero; if (Time.time < m_dodgeUntil) { move = m_dodgeDir * num3 * 2.5f; } else if (BulletWillHit(apos, out m_dodgeDir)) { m_dodgeUntil = Time.time + 0.3f; move = m_dodgeDir * num3 * 2.5f; } else { Vector2 val2; if (Time.time - m_lastHurt < 2.5f || BulletsNear(apos)) { if (!m_hasCover || (Time.time >= m_nextCover && !CoopBotBrain.CoverBlocks(m_coverSpot, unitCenter))) { m_nextCover = Time.time + 0.8f; m_hasCover = FindCover(room, apos, foes, out m_coverSpot); } if (m_hasCover) { if (Vector2.Distance(apos, m_coverSpot) > 0.45f) { val2 = m_coverSpot - apos; move = ((Vector2)(ref val2)).normalized * num3; } else { move = Vector2.zero; } SetVelocity(move, num3); return; } } else { m_hasCover = false; } val2 = unitCenter - apos; Vector2 normalized = ((Vector2)(ref val2)).normalized; if (num < 5f) { move = -normalized; } else if (num > 8.5f) { move = normalized; } else { if (Time.time > m_nextStrafe) { m_strafeSign = ((Random.value < 0.5f) ? (-1f) : 1f); m_nextStrafe = Time.time + Random.Range(1.2f, 2.8f); } move = CoopBotBrain.Perp(normalized) * m_strafeSign * 0.7f; } if (((Vector2)(ref move)).sqrMagnitude > 0.01f && (CoopBotBrain.MoveBlocked(apos, apos + ((Vector2)(ref move)).normalized * 1.2f) || CoopBotBrain.Pit(apos + ((Vector2)(ref move)).normalized * 1f))) { m_strafeSign = 0f - m_strafeSign; move = CoopBotBrain.Perp(((Vector2)(ref move)).normalized) * m_strafeSign; } } SetVelocity(move, num3); } private static void SetVelocity(Vector2 move, float speed) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Actor.BehaviorOverridesVelocity = true; Actor.BehaviorVelocity = ((((Vector2)(ref move)).sqrMagnitude > 0.01f) ? (((Vector2)(ref move)).normalized * speed) : Vector2.zero); } private static bool BulletsNear(Vector2 apos) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) ReadOnlyCollection<Projectile> allProjectiles = StaticReferenceManager.AllProjectiles; for (int i = 0; i < allProjectiles.Count; i++) { Projectile val = allProjectiles[i]; if (IsThreat(val)) { Vector2 val2 = ((BraveBehaviour)val).specRigidbody.UnitCenter - apos; if (((Vector2)(ref val2)).sqrMagnitude < 100f) { return true; } } } return false; } private static bool BulletWillHit(Vector2 apos, out Vector2 dir) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0055: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) dir = Vector2.zero; ReadOnlyCollection<Projectile> allProjectiles = StaticReferenceManager.AllProjectiles; for (int i = 0; i < allProjectiles.Count; i++) { Projectile val = allProjectiles[i]; if (!IsThreat(val)) { continue; } Vector2 velocity = ((BraveBehaviour)val).specRigidbody.Velocity; if (((Vector2)(ref velocity)).sqrMagnitude < 0.25f) { continue; } Vector2 unitCenter = ((BraveBehaviour)val).specRigidbody.UnitCenter; Vector2 val2 = apos - unitCenter; float num = Mathf.Clamp(Vector2.Dot(val2, velocity) / ((Vector2)(ref velocity)).sqrMagnitude, 0f, 0.6f); if (!(Vector2.Dot(val2, velocity) < 0f)) { Vector2 val3 = val2 - velocity * num; if (!(((Vector2)(ref val3)).magnitude >= 1.2f)) { Vector2 val4 = CoopBotBrain.Perp(((Vector2)(ref velocity)).normalized); dir = ((!CoopBotBrain.MoveBlocked(apos, apos + val4 * 1.2f) && !CoopBotBrain.Pit(apos + val4)) ? val4 : (-val4)); return true; } } } return false; } private static bool IsThreat(Projectile p) { if ((Object)(object)p == (Object)null || (Object)(object)((BraveBehaviour)p).specRigidbody == (Object)null || !p.collidesWithPlayer) { return false; } if (p.Owner is PlayerController) { return false; } if (p.Owner is AIActor && (Object)(object)((AIActor)/*isinst with value type is only supported in some contexts*/).CompanionOwner != (Object)null) { return false; } return true; } private static bool FindCover(RoomHandler room, Vector2 apos, List<AIActor> foes, out Vector2 spot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) spot = apos; List<KeyValuePair<float, Vector2>> list = new List<KeyValuePair<float, Vector2>>(); for (int i = 0; i < 3; i++) { float num = 2f + (float)i * 1.5f; for (int j = 0; j < 16; j++) { Vector2 val = apos + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, (float)j * 22.5f) * Vector3.right) * num; if (CoopBotBrain.Pit(val) || CoopBotBrain.MoveBlocked(apos, val) || !CoopBotBrain.HasRoom(val)) { continue; } int num2 = 0; for (int k = 0; k < foes.Count; k++) { if (CoopBotBrain.CoverBlocks(val, ((BraveBehaviour)foes[k]).specRigidbody.UnitCenter)) { num2++; } } if (num2 >= foes.Count) { list.Add(new KeyValuePair<float, Vector2>(num + Random.value * 0.4f, val)); } } } list.Sort((KeyValuePair<float, Vector2> a, KeyValuePair<float, Vector2> b) => a.Key.CompareTo(b.Key)); for (int num3 = 0; num3 < list.Count && num3 < 4; num3++) { if (CoopBotBrain.CanReach(apos, list[num3].Value)) { spot = list[num3].Value; return true; } } return false; } private static void TryRespawn() { if (!m_pendingRespawn || Time.time < m_nextRespawn) { return; } GameManager instance = GameManager.Instance; PlayerController primaryPlayer = instance.PrimaryPlayer; if ((Object)(object)primaryPlayer == (Object)null || ((BraveBehaviour)primaryPlayer).healthHaver.IsDead || primaryPlayer.IsGhost || instance.IsFoyer || instance.IsLoadingLevel) { return; } if (CoopBotPlugin.PartnerMode.Value != PartnerKind.Enemy || string.IsNullOrEmpty(CoopBotPlugin.AllyGuid.Value)) { m_pendingRespawn = false; return; } RoomHandler currentRoom = primaryPlayer.CurrentRoom; if (currentRoom != null && !currentRoom.HasActiveEnemies((ActiveEnemyType)1)) { m_pendingRespawn = false; m_nextRespawn = Time.time + 3f; Summon(CoopBotPlugin.AllyGuid.Value); } } private static bool OpenFloor(DungeonData data, int x, int y) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if (!data.CheckInBoundsAndValid(x, y) || data.isTopWall(x, y)) { return false; } CellData val = data[x, y]; if (val != null && (int)val.type == 2) { return val.isGridConnected; } return false; } private static void PlaceNearPlayer(PlayerController prim) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_0064: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) Dungeon dungeon = GameManager.Instance.Dungeon; if ((Object)(object)dungeon == (Object)null || dungeon.data == null || prim.CurrentRoom == null) { return; } DungeonData data = dungeon.data; Vector2 unitCenter = ((BraveBehaviour)prim).specRigidbody.UnitCenter; IntVector2? val = null; for (int i = 2; i <= 5; i++) { if (val.HasValue) { break; } for (int j = 0; j < 16; j++) { if (val.HasValue) { break; } Vector2 val2 = unitCenter + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, (float)j * 22.5f) * Vector3.right) * (float)i; IntVector2 val3 = Vector2Extensions.ToIntVector2(val2, (VectorConversions)0); if (OpenFloor(data, val3.x, val3.y) && !CoopBotBrain.Pit(val2) && OpenFloor(data, val3.x + 1, val3.y) && OpenFloor(data, val3.x - 1, val3.y) && OpenFloor(data, val3.x, val3.y + 1) && OpenFloor(data, val3.x, val3.y - 1) && data.GetAbsoluteRoomFromPosition(val3) == prim.CurrentRoom) { val = val3; } } } if (!val.HasValue) { return; } IntVector2 value = val.Value; ((BraveBehaviour)Actor).specRigidbody.Initialize(); Vector2 val4 = ((BraveBehaviour)Actor).specRigidbody.UnitCenter - Vector3Extensions.XY(((BraveBehaviour)Actor).transform.position); Vector2 val5 = Pathfinder.GetClearanceOffset(value, Actor.Clearance) - val4; ((BraveBehaviour)Actor).transform.position = Vector2.op_Implicit(BraveUtility.QuantizeVector(val5)); ((BraveBehaviour)Actor).specRigidbody.Reinitialize(); RoomHandler parentRoom = Actor.ParentRoom; if (parentRoom != prim.CurrentRoom) { if (parentRoom != null) { parentRoom.DeregisterEnemy(Actor, true); } Actor.ParentRoom = prim.CurrentRoom; prim.CurrentRoom.RegisterEnemy(Actor); } } private static void DiagnoseAlly() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Actor == (Object)null) && !(Time.time < m_nextStatus)) { m_nextStatus = Time.time + 3f; CoopBotPlugin.Log("Ally diag: state=" + ((object)Actor.State/*cast due to .constrained prefix*/).ToString() + " hp=" + ((BraveBehaviour)Actor).healthHaver.GetCurrentHealth() + " allyBulletsTinted=" + s_tintedTotal); } } private static void TintBullet(Projectile p) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) tk2dBaseSprite[] componentsInChildren = ((Component)p).gameObject.GetComponentsInChildren<tk2dBaseSprite>(true); foreach (tk2dBaseSprite val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)((BraveBehaviour)val).renderer == (Object)null) { continue; } val.OverrideMaterialMode = (SpriteMaterialOverrideMode)1; Material material = ((BraveBehaviour)val).renderer.material; bool flag = material.HasProperty("_EmissivePower"); Shader val2 = (flag ? ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive") : ShaderCache.Acquire("tk2d/CutoutVertexColorTintableTilted")); if ((Object)(object)material.shader != (Object)(object)val2) { float num = (flag ? material.GetFloat("_EmissivePower") : 0f); float num2 = (flag ? material.GetFloat("_EmissiveColorPower") : 0f); material.shader = val2; material.EnableKeyword("BRIGHTNESS_CLAMP_ON"); if (flag) { material.SetFloat("_EmissivePower", num); material.SetFloat("_EmissiveColorPower", num2); } } material.SetColor("_OverrideColor", BulletColor); } } private static void ResetBullet(Projectile p) { //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_0076: Unknown result type (might be due to invalid IL or missing references) tk2dBaseSprite[] componentsInChildren = ((Component)p).gameObject.GetComponentsInChildren<tk2dBaseSprite>(true); foreach (tk2dBaseSprite val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((BraveBehaviour)val).renderer == (Object)null)) { Material material = ((BraveBehaviour)val).renderer.material; if (material.HasProperty("_OverrideColor") && material.GetColor("_OverrideColor") == BulletColor) { material.SetColor("_OverrideColor", new Color(0f, 0f, 0f, 0f)); } } } } private static void RecolorBullets() { DiagnoseAlly(); } public static void OnBulletOwner(Projectile p, GameActor owner) { if ((Object)(object)p == (Object)null) { return; } try { AIActor val = (AIActor)(object)((owner is AIActor) ? owner : null); if ((Object)(object)val != (Object)null && (Object)(object)val.CompanionOwner != (Object)null) { TintBullet(p); s_blue.Add(p); s_tintedTotal++; } else if (s_blue.Remove(p)) { ResetBullet(p); } } catch (Exception ex) { CoopBotPlugin.Log("Ally tint failed: " + ex.Message); } } public static void Dismiss(bool announce) { m_pendingRespawn = false; foreach (AIActor item in s_steered) { if ((Object)(object)item != (Object)null) { item.OverrideTarget = null; } } s_steered.Clear(); if ((Object)(object)Actor != (Object)null) { Object.Destroy((Object)(object)((Component)Actor).gameObject); } Actor = null; m_hasCover = false; if (announce) { CoopBotPlugin.Say("Ally dismissed."); } } } [HarmonyPatch(typeof(Projectile), "set_Owner")] public static class AllyBulletOwnerPatch { public static void Postfix(Projectile __instance, GameActor value) { AllyPartner.OnBulletOwner(__instance, value); } } public class CoopBotBrain : MonoBehaviour { private enum OrderKind { None, Interact, Break, Regroup } private struct Bullet { public Vector2 pos; public Vector2 vel; } private struct Zone { public Vector2 c; public float r; } public PlayerController Bot; public BotCharacter Character; public Vector2 Move; public bool Shoot; private bool m_dodge; private bool m_reload; private int m_interactTicks; private int m_itemTicks; private float m_nextItemTime; private int m_swapTicks; private float m_nextSwapTime; private OrderKind m_order; private Component m_orderTarget; private IPlayerInteractable m_orderInteractable; private Vector2 m_orderCenter; private float m_orderExpires; private float m_lastInteractTime = -10f; private int m_interactAttempts; private int m_dropState; private Vector2 m_dropSpot; private float m_dropDeadline; private List<Vector2> m_waypoints = new List<Vector2>(); private Vector2 m_pathGoal = new Vector2(-999f, -999f); private float m_nextPathTime; private float m_strafeSign = 1f; private float m_nextStrafeFlip; private float m_dodgeReadyTime; private float m_stuckTimer; private Vector2 m_lastPos; private float m_farTimer; private Vector2 m_facing = Vector2.right; private const float FollowStart = 4.5f; private const float FollowStop = 2.5f; private const float Leash = 16f; private const float EngageRange = 18f; private ElevatorDepartureController m_elevator; private float m_nextElevatorScan; private int m_ghostFrame; private AIActor m_lockedEnemy; private Vector2 m_coverSpot; private bool m_hasCover; private float m_nextCoverSearch; private readonly HashSet<FlippableCover> m_triedTables = new HashSet<FlippableCover>(); private FlippableCover m_table; private float m_tableDeadline; private float m_coverBestDist = float.MaxValue; private float m_coverProgressTime; private readonly List<Vector2> m_badCover = new List<Vector2>(); private float m_badCoverUntil; private float m_coverCooldownUntil; private float m_lastFiredAt = -10f; private bool m_peeking; private float m_phaseEnd; private bool m_coverHolding; private Vector2 m_tableCoverSpot; private float m_tableCoverUntil; private bool m_thin; private float m_thinUntil; private int m_unstickStage; private float m_nextBlankTime; public bool WantBlank; private readonly List<Bullet> m_bullets = new List<Bullet>(); private Vector2 m_evadeDir; private float m_evadeUntil; private float m_weaveSign = 1f; private const float BulletR = 1.1f; private readonly Dictionary<Projectile, float> m_reactAt = new Dictionary<Projectile, float>(); private float m_nextReactCleanup; private Vector2 m_aimErr; private float m_aimErrUntil; private float m_chargeStart = -1f; private float m_releaseUntil; private readonly List<Zone> m_zones = new List<Zone>(); private float m_nextZoneScan; private static readonly FieldInfo RocketPos = typeof(SkyRocket).GetField("m_targetLandPosition", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo RocketState = typeof(SkyRocket).GetField("m_state", BindingFlags.Instance | BindingFlags.NonPublic); private const float TradeRange = 3.5f; private bool BulletsIncoming => m_bullets.Count > 0; private float MoveSpeed => Mathf.Max(4f, Bot.stats.GetStatValue((StatType)0)); public bool ConsumeUseItem() { if (m_itemTicks <= 0) { return false; } m_itemTicks--; return true; } public bool ConsumeSwapGun() { if (m_swapTicks <= 0) { return false; } m_swapTicks--; return m_swapTicks > 0; } public bool ConsumeDodge() { bool dodge = m_dodge; m_dodge = false; return dodge; } public bool ConsumeReload() { bool reload = m_reload; m_reload = false; return reload; } public bool ConsumeInteract() { if (m_interactTicks <= 0) { return false; } m_interactTicks--; return true; } private static int TileMask() { return CollisionMask.LayerToMask((CollisionLayer)6, (CollisionLayer)8); } private static bool TilesBlock(Vector2 from, Vector2 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector2 val = to - from; float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < 0.01f) { return false; } RaycastResult val2 = default(RaycastResult); bool num = PhysicsEngine.Instance.Raycast(from, val, magnitude, ref val2, true, false, TileMask(), (CollisionLayer?)null, false, (Func<SpeculativeRigidbody, bool>)null, (SpeculativeRigidbody)null); if (num) { RaycastResult.Pool.Free(ref val2); } return num; } internal static bool MoveBlocked(Vector2 from, Vector2 to, float width = 0.32f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) Vector2 val = to - from; float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < 0.01f) { return false; } Vector2 val2 = new Vector2(0f - val.y, val.x); Vector2 val3 = ((Vector2)(ref val2)).normalized * width; int num = CollisionMask.LayerToMask((CollisionLayer)6, (CollisionLayer)5, (CollisionLayer)8); SpeculativeRigidbody val4 = (((Object)(object)CoopBotPlugin.Brain != (Object)null && (Object)(object)CoopBotPlugin.Brain.Bot != (Object)null) ? ((BraveBehaviour)CoopBotPlugin.Brain.Bot).specRigidbody : null); RaycastResult val5 = default(RaycastResult); for (int i = -1; i <= 1; i++) { if (PhysicsEngine.Instance.Raycast(from + val3 * (float)i, val, magnitude, ref val5, true, true, num, (CollisionLayer?)null, false, (Func<SpeculativeRigidbody, bool>)null, val4)) { RaycastResult.Pool.Free(ref val5); return true; } } return false; } private void Update() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: 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_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: 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_020a: 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_0456: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) Move = Vector2.zero; Shoot = false; m_coverHolding = false; GameManager instance = GameManager.Instance; PlayerController primaryPlayer = instance.PrimaryPlayer; if ((Object)(object)Bot == (Object)null || (Object)(object)primaryPlayer == (Object)null || instance.IsLoadingLevel || instance.IsPaused) { return; } if (Bot.IsGhost || ((BraveBehaviour)Bot).healthHaver.IsDead) { GhostUpdate(primaryPlayer); } else { if ((int)Bot.CurrentInputState != 0) { return; } Vector2 unitCenter = ((BraveBehaviour)Bot).specRigidbody.UnitCenter; Vector2 unitCenter2 = ((BraveBehaviour)primaryPlayer).specRigidbody.UnitCenter; RoomHandler currentRoom = Bot.CurrentRoom; if (Time.time > m_orderExpires && m_order != OrderKind.None) { EndOrder("Order timed out."); } float num = Vector2.Distance(unitCenter, unitCenter2); bool flag = currentRoom != null && currentRoom == primaryPlayer.CurrentRoom; bool flag2 = Bot.IsInCombat && currentRoom != null && currentRoom.HasActiveEnemies((ActiveEnemyType)0); if (num > 40f || (!flag && !flag2 && !primaryPlayer.IsInCombat && num > 22f)) { m_farTimer += Time.deltaTime; if (m_farTimer > 2.5f) { Bot.ReuniteWithOtherPlayer(primaryPlayer, true); m_farTimer = 0f; return; } } else { m_farTimer = 0f; } AIActor val = PickEnemy(currentRoom, unitCenter); Vector2? aim = null; if ((Object)(object)val == (Object)null && ElevatorNearPlayer(unitCenter2)) { if (m_order != OrderKind.None) { EndOrder("Bot: heading to the elevator."); } if (num > 0.35f) { MoveToward(unitCenter, unitCenter2, 0.3f); if (((Vector2)(ref Move)).sqrMagnitude < 0.01f) { Vector2 val2 = unitCenter2 - unitCenter; Move = ((Vector2)(ref val2)).normalized; } if (num < 1.5f) { Move *= Mathf.Clamp(num, 0.3f, 1f); } } if (num > 8f) { m_farTimer += Time.deltaTime; if (m_farTimer > 2f) { Bot.ReuniteWithOtherPlayer(primaryPlayer, true); m_farTimer = 0f; } } Bot.forceAimPoint = unitCenter + m_facing * 5f; if (((Vector2)(ref Move)).sqrMagnitude > 0.01f) { m_facing = ((Vector2)(ref Move)).normalized; } UnstickCheck(unitCenter); return; } if (m_order == OrderKind.Interact) { RunInteractOrder(unitCenter, ref aim); } else if (m_order == OrderKind.Break) { RunBreakOrder(unitCenter, ref aim); } else if (m_order == OrderKind.Regroup) { if (num < 3f) { EndOrder("Regrouped."); } else { MoveToward(unitCenter, unitCenter2, 1.5f); } } bool flag3 = m_order != OrderKind.None; AutoUseItem(currentRoom, unitCenter, val); if ((Object)(object)val != (Object)null) { Vector2 unitCenter3 = ((BraveBehaviour)val).specRigidbody.UnitCenter; float num2 = Vector2.Distance(unitCenter, unitCenter3); bool flag4 = !TilesBlock(unitCenter, unitCenter3); if (num2 < 18f && flag4) { Vector2 val3 = ((BraveBehaviour)val).specRigidbody.Velocity * Mathf.Clamp(num2 / 18f, 0f, 0.6f); aim = unitCenter3 + val3 + AimError(num2); Shoot = true; } if (!flag3 && !CoverMove(currentRoom, unitCenter, unitCenter3, num2, flag4)) { CombatMove(unitCenter, unitCenter3, num2, flag4, unitCenter2, num); } if (m_coverHolding) { Shoot = false; } } else if (!flag3) { FollowMove(unitCenter, unitCenter2, num); } AvoidProjectiles(unitCenter); PitGuard(unitCenter); HazardGuard(unitCenter); DangerZoneGuard(unitCenter); ContactGuard(currentRoom, unitCenter); if (((Vector2)(ref Move)).sqrMagnitude > 0.01f) { m_facing = ((Vector2)(ref Move)).normalized; } Bot.forceAimPoint = (Vector2)(((??)aim) ?? (unitCenter + m_facing * 5f)); HandleReloadAndAmmo((Object)(object)val != (Object)null); ChargeCycle(); UnstickCheck(unitCenter); } } private bool ElevatorNearPlayer(Vector2 primPos) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (Time.time > m_nextElevatorScan) { m_nextElevatorScan = Time.time + 1.5f; m_elevator = Object.FindObjectOfType<ElevatorDepartureController>(); } if ((Object)(object)m_elevator == (Object)null || !((Component)m_elevator).gameObject.activeInHierarchy) { return false; } return Vector2.Distance(Vector3Extensions.XY(((BraveBehaviour)m_elevator).transform.position), primPos) < 9f; } private void GhostUpdate(PlayerController prim) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Bot == (Object)null || (Object)(object)((BraveBehaviour)Bot).specRigidbody == (Object)null) { return; } Vector2 unitCenter = ((BraveBehaviour)Bot).specRigidbody.UnitCenter; Vector2 unitCenter2 = ((BraveBehaviour)prim).specRigidbody.UnitCenter; float num = Vector2.Distance(unitCenter, unitCenter2); Vector2 val; if (num > 2.5f) { val = unitCenter2 - unitCenter; Move = ((Vector2)(ref val)).normalized * Mathf.Min(1f, (num - 2f) / 2f); } if (num > 30f) { Bot.ReuniteWithOtherPlayer(prim, true); } bool flag = false; ReadOnlyCollection<Projectile> allProjectiles = StaticReferenceManager.AllProjectiles; for (int i = 0; i < allProjectiles.Count; i++) { if (flag) { break; } Projectile val2 = allProjectiles[i]; if ((Object)(object)val2 == (Object)null || (Object)(object)((BraveBehaviour)val2).specRigidbody == (Object)null || !val2.collidesWithPlayer || val2.Owner is PlayerController) { continue; } Vector2 unitCenter3 = ((BraveBehaviour)val2).specRigidbody.UnitCenter; Vector2 velocity = ((BraveBehaviour)val2).specRigidbody.Velocity; if (!(((Vector2)(ref velocity)).sqrMagnitude < 0.25f)) { Vector2 val3 = unitCenter2 - unitCenter3; float num2 = Mathf.Clamp(Vector2.Dot(val3, velocity) / ((Vector2)(ref velocity)).sqrMagnitude, 0f, 0.8f); val = val3 - velocity * num2; if (((Vector2)(ref val)).magnitude < 1.4f) { flag = true; } } } m_ghostFrame++; Shoot = flag && m_ghostFrame % 2 == 0; Bot.forceAimPoint = unitCenter + Vector2.right; } private void HandleReloadAndAmmo(bool hasEnemy) { Gun currentGun = ((GameActor)Bot).CurrentGun; if ((Object)(object)currentGun == (Object)null || currentGun.IsReloading || Bot.IsDodgeRolling) { return; } if (currentGun.InfiniteAmmo || currentGun.CurrentAmmo > 0) { int clipCapacity = currentGun.ClipCapacity; int clipShotsRemaining = currentGun.ClipShotsRemaining; if (clipCapacity > 0 && clipCapacity <= 200 && (currentGun.InfiniteAmmo || currentGun.CurrentAmmo > clipShotsRemaining) && (clipShotsRemaining <= 0 || (!Shoot && (float)clipShotsRemaining < (float)clipCapacity * 0.6f) || (!hasEnemy && clipShotsRemaining < clipCapacity))) { m_reload = true; } } else { if (!(Time.time > m_nextSwapTime) || Bot.inventory == null || Bot.inventory.AllGuns.Count <= 1) { return; } m_nextSwapTime = Time.time + 1f; Gun val = LoadedGun(currentGun); if ((Object)(object)val != (Object)null) { SelectGun(val, announce: false); return; } if (CanDropHeld()) { try { Bot.ForceDropGun(currentGun); return; } catch (Exception) { return; } } m_swapTicks = 3; } } private AIActor PickEnemy(RoomHandler room, Vector2 pos) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_lockedEnemy != (Object)null) { AIActor lockedEnemy = m_lockedEnemy; if (!((Object)(object)((BraveBehaviour)lockedEnemy).healthHaver == (Object)null) && !((BraveBehaviour)lockedEnemy).healthHaver.IsDead && ((Behaviour)lockedEnemy).isActiveAndEnabled && !((Object)(object)((BraveBehaviour)lockedEnemy).specRigidbody == (Object)null)) { return lockedEnemy; } m_lockedEnemy = null; } if (room == null) { return null; } List<AIActor> activeEnemies = room.GetActiveEnemies((ActiveEnemyType)0); if (activeEnemies == null) { return null; } AIActor result = null; float num = float.MaxValue; for (int i = 0; i < activeEnemies.Count; i++) { AIActor val = activeEnemies[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)((BraveBehaviour)val).healthHaver == (Object)null) && !((BraveBehaviour)val).healthHaver.IsDead && !val.IsHarmlessEnemy && !((Object)(object)val.CompanionOwner != (Object)null) && ((Behaviour)val).isActiveAndEnabled && !((Object)(object)((BraveBehaviour)val).specRigidbody == (Object)null)) { Vector2 unitCenter = ((BraveBehaviour)val).specRigidbody.UnitCenter; float num2 = Vector2.Distance(pos, unitCenter) + (TilesBlock(pos, unitCenter) ? 12f : 0f); if (num2 < num) { num = num2; result = val; } } } return result; } public void DropItemNow() { if ((Object)(object)Bot == (Object)null || ((BraveBehaviour)Bot).healthHaver.IsDead || Bot.IsGhost) { return; } PlayerItem currentItem = Bot.CurrentItem; if ((Object)(object)currentItem == (Object)null) { CoopBotPlugin.Say("Bot: no active item."); return; } try { Bot.DropActiveItem(currentItem, 4f, false); CoopBotPlugin.Say("Bot: dropped its item."); } catch (Exception) { } } public void UseItemNow() { if (!((Object)(object)Bot == (Object)null) && !((BraveBehaviour)Bot).healthHaver.IsDead && !Bot.IsGhost) { PlayerItem currentItem = Bot.CurrentItem; if ((Object)(object)currentItem == (Object)null) { CoopBotPlugin.Say("Bot: no active item."); return; } if (currentItem.IsOnCooldown || !currentItem.CanBeUsed(Bot)) { CoopBotPlugin.Say("Bot: item not ready."); return; } m_itemTicks = 2; CoopBotPlugin.Say("Bot: using its item."); } } private void AutoUseItem(RoomHandler room, Vector2 pos, AIActor enemy) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy == (Object)null || Time.time < m_nextItemTime || m_itemTicks > 0 || Bot.IsDodgeRolling) { return; } PlayerItem currentItem = Bot.CurrentItem; if ((Object)(object)currentItem == (Object)null || currentItem.IsCurrentlyActive || currentItem.IsOnCooldown || !currentItem.CanBeUsed(Bot)) { return; } int num = 0; List<AIActor> list = ((room != null) ? room.GetActiveEnemies((ActiveEnemyType)0) : null); if (list != null) { for (int i = 0; i < list.Count; i++) { AIActor val = list[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)((BraveBehaviour)val).healthHaver == (Object)null) && !((BraveBehaviour)val).healthHaver.IsDead && !((Object)(object)((BraveBehaviour)val).specRigidbody == (Object)null) && Vector2.Distance(pos, ((BraveBehaviour)val).specRigidbody.UnitCenter) < 12f) { num++; } } } float currentHealthPercentage = ((BraveBehaviour)Bot).healthHaver.GetCurrentHealthPercentage(); bool isBoss = ((BraveBehaviour)enemy).healthHaver.IsBoss; if (num >= 3 || isBoss || (num >= 2 && currentHealthPercentage < 0.7f) || currentHealthPercentage < 0.4f) { m_itemTicks = 2; m_nextItemTime = Time.time + 2f; } } internal static bool CoverBlocks(Vector2 from, Vector2 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector2 val = to - from; float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < 0.01f) { return false; } int num = CollisionMask.LayerToMask((CollisionLayer)6, (CollisionLayer)5, (CollisionLayer)8); RaycastResult val2 = default(RaycastResult); bool num2 = PhysicsEngine.Instance.Raycast(from, val, magnitude, ref val2, true, true, num, (CollisionLayer?)null, false, (Func<SpeculativeRigidbody, bool>)null, (SpeculativeRigidbody)null); if (num2) { RaycastResult.Pool.Free(ref val2); } return num2; } private bool WantsCover() { if (Time.time < m_coverCooldownUntil) { return false; } float num = Mathf.Clamp01(CoopBotPlugin.CoverPreference.Value); if (num < 0.05f) { return false; } if (Time.time - m_lastFiredAt < 1.5f) { return true; } Gun currentGun = ((GameActor)Bot).CurrentGun; if ((Object)(object)currentGun != (Object)null && currentGun.IsReloading) { return true; } if (((BraveBehaviour)Bot).healthHaver.GetCurrentHealthPercentage() < Mathf.Lerp(0.5f, 0.95f, num)) { return true; } return Time.time % 6f / 6f < num * 0.6f; } private void UpdateCoverPhase() { if (!(Time.time < m_phaseEnd)) { m_peeking = !m_peeking; float num = Mathf.Clamp01(CoopBotPlugin.CoverPreference.Value); float num2 = (m_peeking ? Mathf.Lerp(1f, 0.6f, num) : Mathf.Lerp(0.8f, 2f, num)); m_phaseEnd = Time.time + num2 * Random.Range(0.8f, 1.2f); } } private bool FindPeekStep(Vector2 pos, Vector2 ep, out Vector2 step) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ep - pos; Vector2 val2 = Perp(((Vector2)(ref val)).normalized); for (int i = -1; i <= 1; i += 2) { Vector2 val3 = pos + val2 * (float)i * 0.8f; if (!Pit(val3) && !MoveBlocked(pos, val3, 0.2f) && !CoverBlocks(val3, ep)) { step = val3; return true; } } step = pos; return false; } private bool CoverMove(RoomHandler room, Vector2 pos, Vector2 ep, float d, bool los) { //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: 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_0178: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0465: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: 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_0479: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: 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_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) if (room == null) { return false; } bool flag = WantsCover(); if ((Object)(object)m_table == (Object)null && d > 2.5f && CoopBotPlugin.CoverPreference.Value > 0.05f && Time.time > m_nextCoverSearch) { m_nextCoverSearch = Time.time + 0.5f; ReadOnlyCollection<IPlayerInteractable> roomInteractables = room.GetRoomInteractables(); float num = 9f; for (int i = 0; i < roomInteractables.Count; i++) { IPlayerInteractable obj = roomInteractables[i]; FlippableCover val = (FlippableCover)(object)((obj is FlippableCover) ? obj : null); if (!((Object)(object)val == (Object)null) && !val.IsFlipped && !val.IsBroken && !m_triedTables.Contains(val)) { float num2 = Vector2.Distance(pos, ((BraveBehaviour)val).specRigidbody.UnitCenter); if (num2 < num) { num = num2; m_table = val; m_tableDeadline = Time.time + 6f; } } } } Vector2 val2; if ((Object)(object)m_table != (Object)null) { if (m_table.IsFlipped || m_table.IsBroken || Time.time > m_tableDeadline) { m_triedTables.Add(m_table); m_table = null; } else { Vector2 unitCenter = ((BraveBehaviour)m_table).specRigidbody.UnitCenter; val2 = unitCenter - ep; Vector2 val3; if (!(((Vector2)(ref val2)).sqrMagnitude > 0.01f)) { val3 = Vector2.up; } else { val2 = unitCenter - ep; val3 = ((Vector2)(ref val2)).normalized; } Vector2 val4 = val3; Vector2 val5 = unitCenter - val4 * 1.1f; if (!(m_table.GetDistanceToPoint(((GameActor)Bot).CenterPosition) < 0.85f)) { if (Vector2.Distance(pos, val5) > 0.5f && m_table.GetDistanceToPoint(((GameActor)Bot).CenterPosition) > 1.6f) { MoveToward(pos, val5, 0.3f); return true; } MoveToward(pos, unitCenter, 0.2f); if (((Vector2)(ref Move)).sqrMagnitude < 0.01f) { val2 = unitCenter - pos; Move = ((Vector2)(ref val2)).normalized; } return true; } m_interactTicks = 3; m_triedTables.Add(m_table); m_table = null; m_tableCoverSpot = pos; m_tableCoverUntil = Time.time + 2f; } } if ((Object)(object)m_table == (Object)null && !m_hasCover && Time.time < m_tableCoverUntil) { m_coverSpot = m_tableCoverSpot; m_hasCover = true; m_tableCoverUntil = 0f; m_peeking = false; m_phaseEnd = Time.time + 0.6f; m_coverBestDist = float.MaxValue; m_coverProgressTime = Time.time; } if (!flag) { m_hasCover = false; return false; } if (!m_hasCover || (Time.time > m_nextCoverSearch && !CoverBlocks(m_coverSpot, ep))) { m_nextCoverSearch = Time.time + 0.6f; Vector2 coverSpot = m_coverSpot; bool hasCover = m_hasCover; m_hasCover = FindCover(room, pos, out m_coverSpot); if (m_hasCover && (!hasCover || coverSpot != m_coverSpot)) { m_coverBestDist = float.MaxValue; m_coverProgressTime = Time.time; m_peeking = false; m_phaseEnd = Time.time + 0.6f; } } if (!m_hasCover) { return false; } if (!CoverBlocks(m_coverSpot, ep) && !los) { AbandonCover(0.5f); return false; } float num3 = Vector2.Distance(pos, m_coverSpot); if (!m_peeking && num3 > 0.45f) { if (num3 < m_coverBestDist - 0.25f) { m_coverBestDist = num3; m_coverProgressTime = Time.time; } if (Time.time - m_coverProgressTime > 1.2f) { AbandonCover(2f); return false; } MoveToward(pos, m_coverSpot, 0.3f); if (((Vector2)(ref Move)).sqrMagnitude < 0.01f) { val2 = m_coverSpot - pos; Move = ((Vector2)(ref val2)).normalized; } return true; } UpdateCoverPhase(); if (m_peeking) { if (!CoverBlocks(pos, ep)) { m_coverHolding = false; return true; } if (FindPeekStep(pos, ep, out var step)) { val2 = step - pos; Move = ((Vector2)(ref val2)).normalized; m_coverHolding = false; return true; } } m_coverHolding = true; if (num3 > 0.45f) { MoveToward(pos, m_coverSpot, 0.3f); if (((Vector2)(ref Move)).sqrMagnitude < 0.01f) { val2 = m_coverSpot - pos; Move = ((Vector2)(ref val2)).normalized; } } return true; } private bool FindCover(RoomHandler room, Vector2 pos, out Vector2 spot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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) spot = pos; List<AIActor> activeEnemies = room.GetActiveEnemies((ActiveEnemyType)0); if (activeEnemies == null) { return false; } List<Vector2> list = new List<Vector2>(); for (int i = 0; i < activeEnemies.Count; i++) { if (list.Count >= 6) { break; } AIActor val = activeEnemies[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)((BraveBehaviour)val).healthHaver == (Object)null) && !((BraveBehaviour)val).healthHaver.IsDead && !((Object)(object)((BraveBehaviour)val).specRigidbody == (Object)null) && !val.IsHarmlessEnemy) { Vector2 unitCenter = ((BraveBehaviour)val).specRigidbody.UnitCenter; if (Vector2.Distance(unitCenter, pos) < 20f) { list.Add(unitCenter); } } } if (list.Count == 0) { return false; } Vector2 unitCenter2 = ((BraveBehaviour)GameManager.Instance.PrimaryPlayer).specRigidbody.UnitCenter; List<KeyValuePair<float, Vector2>> list2 = new List<KeyValuePair<float, Vector2>>(); for (int j = 0; j < 3; j++) { float num = 2f + (float)j * 2.2f; for (int k = 0; k < 16; k++) { Vector2 val2 = pos + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, (float)k * 22.5f) * Vector3.right) * num; if (Pit(val2) || MoveBlocked(pos, val2) || IsBadCover(val2) || !HasRoom(val2)) { continue; } int num2 = 0; float num3 = float.MaxValue; for (int l = 0; l < list.Count; l++) { num3 = Mathf.Min(num3, Vector2.Distance(val2, list[l])); if (CoverBlocks(val2, list[l])) { num2++; } } if (num2 >= list.Count && !(num3 < 3.5f)) { float key = num + Vector2.Distance(val2, unitCenter2) * 0.25f + Random.value * 0.5f; list2.Add(new KeyValuePair<float, Vector2>(key, val2)); } } } list2.Sort((KeyValuePair<float, Vector2> a, KeyValuePair<float, Vector2> b) => a.Key.CompareTo(b.Key)); for (int num4 = 0; num4 < list2.Count && num4 < 4; num4++) { if (CanReach(pos, list2[num4].Value)) { spot = list2[num4].Value; return true; } } return false; } internal static bool HasRoom(Vector2 c) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 0; i < 8; i++) { Vector2 val = Vector2.op_Implicit(Quaternion.Euler(0f, 0f, (float)i * 45f) * Vector3.right); if (!Pit(c + val * 0.7f) && !MoveBlocked(c, c + val * 0.7f, 0.2f)) { num++; } } return num >= 5; } internal static bool CanReach(Vector2 from, Vector2 to) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) if (!Pathfinder.HasInstance) { return true; } IntVector2 val = Vector2Extensions.ToIntVector2(from, (VectorConversions)0); IntVector2 val2 = Vector2Extensions.ToIntVector2(to, (VectorConversions)0); Path val3 = default(Path); return Pathfinder.Instance.GetPath(val, val2, ref val3, (IntVector2?)IntVector2.One, (CellTypes)2, (CellValidator)null, (ExtraWeightingFunction)null, false); } private bool IsBadCover(Vector2 c) { //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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (Time.time > m_badCoverUntil) { m_badCover.Clear(); } for (int i = 0; i < m_badCover.Count; i++) { Vector2 val = m_badCover[i] - c; if (((Vector2)(ref val)).sqrMagnitude < 0.81f) { return true; } } return false; } private void AbandonCover(float cooldown) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (m_hasCover) { if (Time.time > m_badCoverUntil) { m_badCover.Clear(); } m_badCover.Add(m_coverSpot); m_badCoverUntil = Time.time + 15f; } if ((Object)(object)m_table != (Object)null) { m_triedTables.Add(m_table); m_table = null; } m_hasCover = false; m_peeking = false; m_coverCooldownUntil = Mathf.Max(m_coverCooldownUntil, Time.time + cooldown); } private void FollowMove(Vector2 pos, Vector2 primPos, float distToPrim) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (distToPrim > 4.5f || (distToPrim > 2.5f && m_waypoints.Count > 0 && ((Vector2)(ref Move)).sqrMagnitude > 0f)) { MoveToward(pos, primPos, 2.5f); } else if (distToPrim < 1.2f) { Vector2 val = pos - primPos; if (((Vector2)(ref val)).sqrMagnitude < 0.01f) { val = Vector2.right; } Move = ((Vector2)(ref val)).normalized * 0.7f; } } private void CombatMove(Vector2 pos, Vector2 ep, float d, bool los, Vector2 primPos, float distToPrim) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (distToPrim > 16f) { MoveToward(pos, primPos, 2.5f); return; } if (!los || d > 11f) { MoveToward(pos, ep, 8f); return; } Vector2 val = ep - pos; Vector2 normalized = ((Vector2)(ref val)).normalized; if (d < 4.5f) { Vector2 val2 = -normalized; if (MoveBlocked(pos, pos + val2 * 1.5f)) { val2 = Perp(normalized) * m_strafeSign; } Move = val2; return; } if (Time.time > m_nextStrafeFlip) { m_strafeSign = ((Random.value < 0.5f) ? (-1f) : 1f); m_nextStrafeFlip = Time.time + Random.Range(1.2f, 2.8f); } Vector2 val3 = Perp(normalized) * m_strafeSign; if (MoveBlocked(pos, pos + val3 * 1.5f)) { m_strafeSign = 0f - m_strafeSign; val3 = -val3; } Move = val3 * 0.8f; } internal static Vector2 Perp(Vector2 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return new Vector2(0f - v.y, v.x); } private void MoveToward(Vector2 pos, Vector2 goal, float stopDistance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (Vector2.Distance(pos, goal) <= stopDistance) { m_waypoints.Clear(); return; } Vector2 val; if (!MoveBlocked(pos, goal, 0.45f) && Vector2.Distance(pos, goal) < 6f) { m_waypoints.Clear(); val = goal - pos; Move = ((Vector2)(ref val)).normalized; return; } if (!(Time.time > m_nextPathTime)) { val = goal - m_pathGoal; if (!(((Vector2)(ref val)).sqrMagnitude > 4f) && m_waypoints.Count != 0) { goto IL_00a3; } } RecomputePath(pos, goal); goto IL_00a3; IL_00a3: while (m_waypoints.Count > 0 && Vector2.Distance(pos, m_waypoints[0]) < (m_thin ? 0.3f : 0.45f)) { m_waypoints.RemoveAt(0); } if (m_waypoints.Count > 0) { if (!m_thin && m_waypoints.Count > 1 && Vector2.Distance(pos, m_waypoints[1]) < 2.2f && !MoveBlocked(pos, m_waypoints[1], 0.5f)) { m_waypoints.RemoveAt(0); } val = m_waypoints[0] - pos; Move = ((Vector2)(ref val)).normalized; } else { val = goal - pos; Move = ((Vector2)(ref val)).normalized; } } private void RecomputePath(Vector2 pos, Vector2 goal) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) m_nextPathTime = Time.time + 0.5f; m_pathGoal = goal; m_waypoints.Clear(); if (!Pathfinder.HasInstance) { return; } IntVector2 val = Vector2Extensions.ToIntVector2(pos, (VectorConversions)0); IntVector2 val2 = Vector2Extensions.ToIntVector2(goal, (VectorConversions)0); bool flag = false; Path val3 = null; if (!m_thin) { flag = Pathfinder.Instance.GetPath(val, val2, ref val3, (IntVector2?)new IntVector2(2, 2), (CellTypes)2, (CellValidator)null, (ExtraWeightingFunction)null, false); } if (!flag) { flag = Pathfinder.Instance.GetPath(val, val2, ref val3, (IntVector2?)IntVector2.One, (CellTypes)2, (CellValidator)null, (ExtraWeightingFunction)null, false); } if (!flag) { for (int i = 1; i <= 2; i++) { if (flag) { break; } for (int j = -i; j <= i; j++) { if (flag) { break; } for (int k = -i; k <= i; k++) { if (flag) { break; } if (Mathf.Max(Mathf.Abs(j), Mathf.Abs(k)) == i) { flag = Pathfinder.Instance.GetPath(val, new IntVector2(val2.x + j, val2.y + k), ref val3, (IntVector2?)IntVector2.One, (CellTypes)2, (CellValidator)null, (ExtraWeightingFunction)null, false); } } } } } if (!flag || val3 == null || val3.Positions == null) { return; } foreach (IntVector2 position in val3.Positions) { m_waypoints.Add(Pathfinder.GetClearanceOffset(position, val3.Clearance)); } } private void Unstic