Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Black Vulture v0.9.0
BepInEx/plugins/LethalRaptor/LethalRaptor.dll
Decompiled 3 weeks 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.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalRaptor")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.0.0")] [assembly: AssemblyInformationalVersion("0.9.0")] [assembly: AssemblyProduct("LethalRaptor")] [assembly: AssemblyTitle("LethalRaptor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LethalRaptor { internal static class PluginInfo { public const string Guid = "LethalRaptor"; public const string Name = "Black Vulture"; public const string Version = "0.9.0"; } public sealed class RaptorAI : EnemyAI { private enum State { Roaming, Hunting, RageStart, Raging, ClawCombo, Regurgitating, JetpackFlight, TruckRest } private sealed class RoamCandidate { public Vector3 Position; public int NodeId; public float PathDistance; public Vector3 FirstDirection; public float Score; } private readonly struct RoamVisit { public readonly int NodeId; public readonly Vector3 Position; public readonly float Time; public RoamVisit(int nodeId, Vector3 position, float time) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) NodeId = nodeId; Position = position; Time = time; } } private readonly struct RoamFailure { public readonly int NodeId; public readonly Vector3 Position; public readonly float Time; public RoamFailure(int nodeId, Vector3 position, float time) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) NodeId = nodeId; Position = position; Time = time; } } public RaptorPosePlayer PosePlayer; public RaptorTongueAttack TongueAttack; public RaptorShotgunAttack ShotgunAttack; public RaptorMaskCorruption MaskCorruption; public RaptorCadaverContainment CadaverContainment; public RaptorStomach Stomach; public RaptorItemEating ItemEating; public RaptorCruiserCapture Cruiser; public RaptorDoorBreaker DoorBreaker; public RaptorTruckVisual TruckVisual; public RaptorSapsuckerIncubation SapsuckerIncubation; public RaptorPillTailTransfer PillTailTransfer; private bool _wasSapsuckerLaying; public RaptorZapGunShield ZapGunShield; public RaptorItemEffects ItemEffects; public RaptorJetpackFlight JetpackFlight; public RaptorSwipeAudio SwipeAudio; public RaptorEventAudio EventAudio; public RaptorCandyRush CandyRush; private bool _tzpRageQueued; private bool _tzpRageActive; private ulong _tzpQueuedItemId = ulong.MaxValue; public RaptorHumanTaste HumanTaste; public RaptorWeddingRing WeddingRing; private bool _ringFollowing; private bool _lastGoldStored; public RaptorWhoopieSounds WhoopieSounds; public RaptorCombatAudio CombatAudio; public RaptorFear Fear; public RaptorIdleAudio IdleAudio; public RaptorFlashStun FlashStun; public RaptorPupilEffect PupilEffect; public RaptorPlayerReelRagdoll ReelRagdoll; private Transform? _mouthSocket; private StartOfRound? _spawnSession; private int _spawnSessionId; private bool _removingOldSessionInstance; private readonly List<ulong> _rageAggressors = new List<ulong>(); private ulong? _rageTriggerPlayerId; private float _comboEndsAt; private float _nextClawAt; private float _localComboStarted; private float _comboAdvanceStartedAt; private float _comboAdvanceTravelled; private ulong? _meleeFocusPlayerId; private RaptorMotionGate _rageMotionGate = new RaptorMotionGate(); private Vector3 _previousWorldPosition; private float _previousWorldSampleTime; private bool _hasWorldSample; private float _remoteMotionHoldUntil; private int _previousRemoteGait = -1; private int _previousCombatState = -1; private bool _leftHit; private bool _rightHit; private Random _serverRandom; private bool _deathCollisionReleased; private bool _jetpackBlastFrozen; private bool _teleportedToShipWithoutNavMesh; private bool _outdoorNavResumePending; private float _nextOutdoorNavRecoveryAt; private float _nextOutdoorRoamRetryAt; private readonly List<RoamVisit> _recentRoamVisits = new List<RoamVisit>(); private readonly List<RoamFailure> _recentRoamFailures = new List<RoamFailure>(); private bool _hasRoamDestination; private Vector3 _roamDestination; private int _roamDestinationNodeId = -1; private Vector3 _roamLegStartPosition; private Vector3 _lastRoamDirection; private float _roamPauseUntil; private float _roamProgressCheckAt; private Vector3 _roamProgressPosition; private int _roamRepathAttempts; private float _roamWatchdogAt; private Vector3 _roamWatchdogPosition; private bool _forceEscapeNextDestination; private bool _roamFallbackSearchActive; private bool _resetHeadingWhenRoamingResumes; private ulong? _lastDetectedPlayerId; private ulong? _huntTargetId; private float _huntEndsAt; private float _pausedHuntRemaining; private bool _huntHoldingWithinReach; private float _satisfiedUntil; private float _rageEndsAt; private float _rageStartEndsAt; private float _regurgitationStartedAt; private int _regurgitationItemCount; private bool _regurgitationPlayerReleased; private bool _regurgitationItemsReleased; private bool _pickleRegurgitationQueued; private bool _chemicalRegurgitationQueued; private bool _chemicalRegurgitation; private bool _nonRageRegurgitation; private bool _regurgitationResumeHunt; private bool _rageAfterPickleRegurgitation; internal bool IsDoorBreakingRage { get { if (base.currentBehaviourStateIndex != 2 && base.currentBehaviourStateIndex != 3 && base.currentBehaviourStateIndex != 4) { if (base.currentBehaviourStateIndex == 5) { return _rageTriggerPlayerId.HasValue; } return false; } return true; } } internal bool IsTruckResting { get { if ((Object)(object)Cruiser != (Object)null) { return Cruiser.IsResting; } return false; } } internal bool IsTzpRaging => _tzpRageActive; internal bool IsHumanTasteActive { get { if ((Object)(object)HumanTaste != (Object)null) { return HumanTaste.Active; } return false; } } internal bool IsWeddingFollowing { get { if (_ringFollowing && (Object)(object)WeddingRing != (Object)null) { return WeddingRing.Active; } return false; } } internal bool IsFlashStunned { get { if ((Object)(object)FlashStun != (Object)null) { return FlashStun.Active; } return false; } } internal bool IsJetpackFlying { get { if ((Object)(object)JetpackFlight != (Object)null) { return JetpackFlight.Active; } return false; } } internal Vector3 FeedItemMouthPoint { get { //IL_004e: 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_001f: 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) //IL_0033: 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) if (!((Object)(object)_mouthSocket != (Object)null)) { return ((Component)this).transform.position + ((Component)this).transform.forward * 3f + Vector3.up * 1.25f; } return _mouthSocket.position; } } public bool IsSatisfied => Time.time < _satisfiedUntil; internal bool IsRegurgitating => base.currentBehaviourStateIndex == 5; public bool IsRaging { get { if (base.currentBehaviourStateIndex != 5 && base.currentBehaviourStateIndex != 2 && base.currentBehaviourStateIndex != 3) { return base.currentBehaviourStateIndex == 4; } return true; } } private float HuntMovementSpeed => RaptorHumanTasteRules.Speed(RushSpeed(1.2f), IsHumanTasteActive); private float MovementAnimationMultiplier => RaptorHumanTasteRules.Speed(RaptorStoredUtilityRules.GoldSpeed(((Object)(object)CandyRush != (Object)null && CandyRush.Active) ? 1.4f : 1f, (Object)(object)ItemEating != (Object)null && ItemEating.HasStoredGoldBar), IsHumanTasteActive && base.currentBehaviourStateIndex == 1); public override void Start() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_02ea: Unknown result type (might be due to invalid IL or missing references) _spawnSession = StartOfRound.Instance; _spawnSessionId = (((Object)(object)_spawnSession != (Object)null) ? ((Object)_spawnSession).GetInstanceID() : 0); if ((int)((Object)((Component)this).gameObject).hideFlags != 0) { HideFlags hideFlags = ((Object)((Component)this).gameObject).hideFlags; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)0; ManualLogSource log = RaptorPlugin.Log; string text = $"[RaptorLifecycle] live instance flags {hideFlags} -> None; "; object arg = ((NetworkBehaviour)this).NetworkObjectId; Scene scene = ((Component)this).gameObject.scene; log.LogInfo((object)(text + $"networkId={arg}; scene='{((Scene)(ref scene)).name}'")); } ((EnemyAI)this).Start(); base.enemyHP = 26; _serverRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex * 7919); _mouthSocket = FindRigNode("Mouth_Socket"); if ((Object)(object)_mouthSocket == (Object)null) { RaptorPlugin.Log.LogWarning((object)"Raptor Mouth_Socket rig node was not found; claw positioning will use the fallback root offset."); } base.currentBehaviourStateIndex = 0; ConfigureAgentFor(State.Roaming); if (((NetworkBehaviour)this).IsOwner) { ResetBaseNavigationForRoam(); BeginRoamingExploration(); } _rageMotionGate = new RaptorMotionGate(); _previousWorldPosition = ((Component)this).transform.position; _previousWorldSampleTime = Time.time; _hasWorldSample = true; ApplyAnimationForState(force: true); Stomach.Initialize(); Fear = ((Component)this).GetComponent<RaptorFear>(); if ((Object)(object)Fear != (Object)null) { Fear.AI = this; Fear.Initialize(); } else { RaptorPlugin.Log.LogError((object)$"[RaptorFear] missing on live Raptor={((NetworkBehaviour)this).NetworkObjectId}"); } TongueAttack.Initialize(); ShotgunAttack?.Initialize(); MaskCorruption?.Initialize(); CadaverContainment?.Initialize(); ItemEating.Initialize(); Cruiser?.Initialize(); DoorBreaker?.Initialize(); SapsuckerIncubation?.Initialize(); ZapGunShield?.Initialize(); ItemEffects.Initialize(); WhoopieSounds?.Initialize(); JetpackFlight.Initialize(); FlashStun.Initialize(); PupilEffect.Initialize(); CandyRush.Initialize(); HumanTaste?.Initialize(); WeddingRing?.Initialize(); bool flag = (Object)(object)((Component)this).transform.Find("PlayerBodyBlocker") != (Object)null; RaptorPlugin.Log.LogInfo((object)($"Raptor Start completed: networkId={((NetworkBehaviour)this).NetworkObjectId}; owner={((NetworkBehaviour)this).IsOwner}; " + $"position={((Component)this).transform.position}; agentOnNavMesh={base.agent.isOnNavMesh}; rigNodes={PosePlayer.RigNodes.Length}; " + $"collisionRegions={((Component)this).GetComponentsInChildren<EnemyAICollisionDetect>(true).Length}; agentRadius={base.agent.radius:0.00}; " + $"rageStopDistance={GetRageAttackStoppingDistance():0.00}; playerBlocker={flag}.")); DebugLog($"Spawned. HP={base.enemyHP}; state={State.Roaming}."); } public override void Update() { //IL_0822: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_08a3: Unknown result type (might be due to invalid IL or missing references) //IL_08c0: Unknown result type (might be due to invalid IL or missing references) if (_removingOldSessionInstance) { return; } if (_spawnSession != null && StartOfRound.Instance != _spawnSession) { StartOfRound instance = StartOfRound.Instance; NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if ((Object)(object)instance != (Object)null || (Object)(object)networkManager == (Object)null || !networkManager.IsListening) { _removingOldSessionInstance = true; RaptorPlugin.Log.LogWarning((object)("[RaptorLifecycle] removing prior-session Raptor " + $"id={((NetworkBehaviour)this).NetworkObjectId}; oldRound={_spawnSessionId}; " + "newRound=" + (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID().ToString() : "none"))); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)0; ((Component)this).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)this).gameObject); return; } } if (_jetpackBlastFrozen) { JetpackFlight?.Tick(); return; } if (((NetworkBehaviour)this).IsOwner && _teleportedToShipWithoutNavMesh) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; } Cruiser?.Tick(); ((EnemyAI)this).Update(); CombatAudio?.Tick(); Fear?.Tick(); SwipeAudio?.Tick(); EventAudio?.Tick(); IdleAudio?.Tick(); if (!IsTruckResting && base.currentBehaviourStateIndex != 7) { RaptorCruiserCapture cruiser = Cruiser; if (cruiser == null || !cruiser.IsPreparing) { RaptorCruiserCapture cruiser2 = Cruiser; if (cruiser2 == null || !cruiser2.IsReconciling) { TongueAttack?.Tick(); ShotgunAttack?.Tick(); MaskCorruption?.Tick(); CadaverContainment?.Tick(); CadaverContainment?.SpreadInfection(); Stomach?.Tick(); ItemEating?.Tick(); SapsuckerIncubation?.Tick(); PillTailTransfer?.Tick(); bool flag = (Object)(object)ItemEating != (Object)null && ItemEating.HasStoredGoldBar; if (flag != _lastGoldStored) { _lastGoldStored = flag; RefreshCandyMovement(); RaptorPlugin.Log.LogInfo((object)(string.Format("[GoldBar] Raptor={0} penalty={1}; ", ((NetworkBehaviour)this).NetworkObjectId, flag ? "20%" : "OFF") + "speed reflects current stomach roster.")); } JetpackFlight?.Tick(); FlashStun?.Tick(); if (((NetworkBehaviour)this).IsOwner && _tzpRageActive) { float num = RaptorTzpRules.PauseDelta(Time.deltaTime, _tzpRageActive, IsFlashStunned); if (num > 0f) { _rageEndsAt += num; if (base.currentBehaviourStateIndex == 2) { _rageStartEndsAt += num; } CandyRush?.HoldTzpForFlash(num); } } ItemEffects?.Tick(); WhoopieSounds?.Tick(); CandyRush?.Tick(); HumanTaste?.Tick(); WeddingRing?.Tick(); if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && base.isOutside) { MaintainOutdoorNavigation(); } if (base.isEnemyDead) { ReleaseDeadCollision(); return; } if (((Object)(object)SapsuckerIncubation != (Object)null && SapsuckerIncubation.IsLaying) || ((Object)(object)PillTailTransfer != (Object)null && PillTailTransfer.IsLaying)) { HoldForSapsuckerLaying(); ApplyAnimationForState(force: false); return; } if (_wasSapsuckerLaying) { _wasSapsuckerLaying = false; if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = false; ConfigureAgentFor((State)base.currentBehaviourStateIndex); } } if (((NetworkBehaviour)this).IsOwner && !IsFlashStunned && base.currentBehaviourStateIndex == 1 && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { PlayerControllerB val = ResolvePlayer(_huntTargetId); if (IsHumanTasteActive) { base.targetPlayer = EnsureHumanTasteTarget(); if ((Object)(object)base.targetPlayer == (Object)null) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } } } else if ((!_ringFollowing && RaptorHuntClock.HasExpired(Time.time, _huntEndsAt)) || !IsValidTargetInCurrentArea(val)) { RaptorPlugin.Log.LogInfo((object)($"[HuntExit] Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + "target=" + (_huntTargetId.HasValue ? _huntTargetId.Value.ToString() : "none") + "; " + $"inside={(Object)(object)val != (Object)null && val.isInsideFactory}; raptorOutside={base.isOutside}; " + $"expired={!_ringFollowing && RaptorHuntClock.HasExpired(Time.time, _huntEndsAt)}; " + "returning immediately to Roam with cleared chase path.")); EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } if (((NetworkBehaviour)this).IsOwner) { TickClawAdvance(); SampleActualMovement(); ApplyAnimationForState(force: false); } if (!IsJetpackFlying && !IsFlashStunned) { TickLocalClawDamage(); } if (!((NetworkBehaviour)this).IsOwner) { return; } if (_tzpRageQueued && !base.isEnemyDead && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { BeginTzpRage(); } else if (_chemicalRegurgitationQueued && !base.isEnemyDead && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { _chemicalRegurgitationQueued = false; BeginChemicalRegurgitation(); } else if (RaptorContainedItemRules.MayStartPickleReaction(_pickleRegurgitationQueued, (Object)(object)TongueAttack != (Object)null && TongueAttack.Busy, IsRaging)) { _pickleRegurgitationQueued = false; BeginPickleRegurgitation(); } else if (base.currentBehaviourStateIndex == 5) { TickRegurgitating(); } else if (base.stunNormalizedTimer > 0f || base.stunnedIndefinitely > 0 || IsFlashStunned) { if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.speed = 0f; } } else { if ((Object)(object)TongueAttack != (Object)null && TongueAttack.Busy) { return; } ApplySoftWallClearance(); if (base.currentBehaviourStateIndex == 2 && (Object)(object)base.targetPlayer != (Object)null) { FaceTargetSmoothly(((Component)base.targetPlayer).transform.position, 10f); } else if (base.currentBehaviourStateIndex == 3 || base.currentBehaviourStateIndex == 4) { PlayerControllerB val2 = ResolvePlayer(_meleeFocusPlayerId); if (IsValidTargetInCurrentArea(val2)) { FaceTargetSmoothly(((Component)val2).transform.position, 9f); } else if (base.currentBehaviourStateIndex == 3 && (Object)(object)base.targetPlayer != (Object)null && FlatDistance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) <= 5f) { FaceTargetSmoothly(((Component)base.targetPlayer).transform.position, 9f); } } } return; } } } StopForCruiserRest(); Cruiser?.PresentCaptureWindup(); Stomach?.Tick(); ItemEating?.Tick(); ItemEffects?.Tick(); WhoopieSounds?.Tick(); TruckVisual?.Tick(Cruiser?.RestElapsed ?? 0.0); } internal void MarkOutdoorAfterShipTeleport() { ((EnemyAI)this).SetEnemyOutside(true); base.isInsidePlayerShip = true; } internal void TransferToShip(Transform shipArrival) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || (Object)(object)shipArrival == (Object)null) { return; } Vector3 position = shipArrival.position; CancelRoamingExploration(); base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.targetPlayer = null; _lastDetectedPlayerId = null; MarkOutdoorAfterShipTeleport(); NavMeshHit val = default(NavMeshHit); bool num = NavMesh.SamplePosition(position, ref val, 1.5f, -1); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); base.agent.isStopped = true; } if (num && (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.Warp(((NavMeshHit)(ref val)).position) && base.agent.isOnNavMesh) { _teleportedToShipWithoutNavMesh = false; _outdoorNavResumePending = true; } else { if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } ((Component)this).transform.position = position; _teleportedToShipWithoutNavMesh = true; _outdoorNavResumePending = false; _nextOutdoorNavRecoveryAt = Time.time + 2f; } Vector3 position2 = ((Component)this).transform.position; base.serverPosition = position2 + Vector3.up * 0.08f; ((EnemyAI)this).SyncPositionToClients(); _previousWorldPosition = position2; _hasWorldSample = false; _nextOutdoorRoamRetryAt = 0f; if (!_teleportedToShipWithoutNavMesh && (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { base.agent.isStopped = false; base.agent.updateRotation = true; _outdoorNavResumePending = false; } if (base.currentBehaviourStateIndex == 0 && !_teleportedToShipWithoutNavMesh) { ResetBaseNavigationForRoam(); BeginRoamingExploration(forceInitialEscape: true); } RaptorPlugin.Log.LogInfo((object)($"[OutdoorNav] SHIP TRANSFER Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + $"outside={base.isOutside}, navmesh={(Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh}, " + $"agentStopped={(Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isStopped}, " + $"roamState={base.currentBehaviourStateIndex}, pendingResume={_outdoorNavResumePending}.")); RaptorPlugin.Log.LogInfo((object)($"[Teleporter] Raptor {((NetworkBehaviour)this).NetworkObjectId} moved onto ship at {position2}; " + $"navigationAvailable={!_teleportedToShipWithoutNavMesh}; livingCaptives={Stomach.LivingOccupants} retained.")); } private void MaintainOutdoorNavigation() { //IL_00cf: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if (_outdoorNavResumePending && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy) && (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = false; base.agent.updateRotation = true; _outdoorNavResumePending = false; RaptorPlugin.Log.LogInfo((object)$"[OutdoorNav] Raptor={((NetworkBehaviour)this).NetworkObjectId} agent RESUMED after ship transfer."); } if (!_teleportedToShipWithoutNavMesh || Time.time < _nextOutdoorNavRecoveryAt || (Object)(object)base.agent == (Object)null || base.isEnemyDead) { return; } _nextOutdoorNavRecoveryAt = Time.time + 2f; NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(((Component)this).transform.position, ref val, 1.5f, -1) || Mathf.Abs(((NavMeshHit)(ref val)).position.y - ((Component)this).transform.position.y) > 1.25f) { return; } if (!((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = true; } if (!base.agent.Warp(((NavMeshHit)(ref val)).position) || !base.agent.isOnNavMesh) { ((Behaviour)base.agent).enabled = false; return; } _teleportedToShipWithoutNavMesh = false; base.agent.isStopped = false; base.agent.updateRotation = true; _outdoorNavResumePending = false; _hasWorldSample = false; RaptorPlugin.Log.LogInfo((object)$"[OutdoorNav] Raptor={((NetworkBehaviour)this).NetworkObjectId} recovered navigable outdoor surface at {((NavMeshHit)(ref val)).position}."); if (base.currentBehaviourStateIndex == 0 || base.currentBehaviourStateIndex == 6) { BeginRoamingExploration(forceInitialEscape: true); } } private void HoldForSapsuckerLaying() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) _wasSapsuckerLaying = true; if (((NetworkBehaviour)this).IsOwner) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.ResetPath(); base.agent.velocity = Vector3.zero; base.agent.speed = 0f; } } } public override void DoAIInterval() { if (!_jetpackBlastFrozen && !IsTruckResting) { RaptorCruiserCapture cruiser = Cruiser; if (cruiser == null || !cruiser.IsPreparing) { RaptorCruiserCapture cruiser2 = Cruiser; if (cruiser2 == null || !cruiser2.IsReconciling) { RaptorCruiserCapture cruiser3 = Cruiser; if ((cruiser3 == null || !cruiser3.IsPursuing) && base.currentBehaviourStateIndex != 7) { if (((Object)(object)SapsuckerIncubation != (Object)null && SapsuckerIncubation.IsLaying) || ((Object)(object)PillTailTransfer != (Object)null && PillTailTransfer.IsLaying)) { HoldForSapsuckerLaying(); return; } if (IsFlashStunned) { if (((NetworkBehaviour)this).IsOwner && base.currentBehaviourStateIndex == 5) { TickRegurgitating(); } FreezeForFlashStun(); return; } if (!_teleportedToShipWithoutNavMesh) { ((EnemyAI)this).DoAIInterval(); } if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || StartOfRound.Instance.allPlayersDead) { return; } if (IsJetpackFlying) { if (base.currentBehaviourStateIndex == 6) { TickJetpackFlightRoam(); } } else if (base.currentBehaviourStateIndex == 5) { TickRegurgitating(); } else if (base.stunNormalizedTimer > 0f || base.stunnedIndefinitely > 0) { base.agent.speed = 0f; } else { if ((Object)(object)TongueAttack != (Object)null && TongueAttack.Busy) { return; } switch ((State)base.currentBehaviourStateIndex) { case State.Roaming: TickRoaming(); break; case State.Hunting: TickHunting(); break; case State.Regurgitating: TickRegurgitating(); break; case State.RageStart: TickRageStart(); break; case State.Raging: TickRaging(); break; case State.ClawCombo: base.agent.speed = 0f; base.movingTowardsTargetPlayer = false; if (Time.time >= _comboEndsAt) { _nextClawAt = Time.time + 0.65f; if (Time.time >= _rageEndsAt) { EndRage(); } else { SwitchState(State.Raging); } } break; default: DebugLog($"Unknown behavior state index {base.currentBehaviourStateIndex}; recovering to Roaming."); EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); break; } } return; } } } } if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead) { return; } RaptorCruiserCapture cruiser4 = Cruiser; if (cruiser4 == null || !cruiser4.IsPursuing) { RaptorCruiserCapture cruiser5 = Cruiser; if (cruiser5 == null || !cruiser5.IsPreparing) { RaptorCruiserCapture cruiser6 = Cruiser; if (cruiser6 == null || !cruiser6.IsReconciling) { RaptorCruiserCapture cruiser7 = Cruiser; if (cruiser7 == null || !cruiser7.IsResting) { return; } } } } ((EnemyAI)this).SyncPositionToClients(); } internal void EnterJetpackFlight() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && base.currentBehaviourStateIndex != 6) { WeddingRing?.Cancel("jetpack flight"); _rageAggressors.Clear(); _rageTriggerPlayerId = null; _meleeFocusPlayerId = null; _lastDetectedPlayerId = null; _pausedHuntRemaining = 0f; _huntTargetId = null; _huntEndsAt = 0f; _satisfiedUntil = 0f; base.targetPlayer = null; base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; _roamPauseUntil = 0f; SwitchState(State.JetpackFlight); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = false; } ResetBaseNavigationForRoam(); BeginRoamingExploration(forceInitialEscape: true); RaptorPlugin.Log.LogInfo((object)$"[JetpackFlight] roaming in current area outside={base.isOutside}, NavMesh={base.agent.isOnNavMesh}"); } } internal void ExitJetpackFlight() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && base.currentBehaviourStateIndex == 6) { EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } private void TickJetpackFlightRoam() { ConfigureAgentFor(State.JetpackFlight); base.movingTowardsTargetPlayer = false; base.targetPlayer = null; _roamPauseUntil = 0f; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = false; TickRoamingExploration(); } } private void TickRoaming() { ConfigureAgentFor(State.Roaming); base.movingTowardsTargetPlayer = false; TickRoamingExploration(); PlayerControllerB val = FindClosestVisiblePlayerInArea(20f); if ((Object)(object)val != (Object)null) { if (_lastDetectedPlayerId != val.playerClientId) { _lastDetectedPlayerId = val.playerClientId; DebugLog($"Detected player {val.playerClientId} in current area; outside={base.isOutside}."); } if (RaptorDevConfig.DebugHuntOnSightEnabled) { BeginHunt(val); } TongueAttack.TryBegin(val); } else { _lastDetectedPlayerId = null; } } private void TickHunting() { ConfigureAgentFor(State.Hunting); if (!IsHumanTasteActive && !_ringFollowing && RaptorHuntClock.HasExpired(Time.time, _huntEndsAt)) { DebugLog("Hunt duration expired."); EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); return; } PlayerControllerB val = (IsHumanTasteActive ? EnsureHumanTasteTarget() : ResolvePlayer(_huntTargetId)); if (!IsValidTargetInCurrentArea(val)) { if (IsHumanTasteActive) { base.targetPlayer = null; base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } } else { DebugLog("Hunt target became invalid or left the current environment."); EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } return; } base.targetPlayer = val; ApplyHuntSpacing(val); if (IsHumanTasteActive || ((Object)(object)WeddingRing != (Object)null && WeddingRing.Active)) { PlayerControllerB val2 = FindClosestVisiblePlayerInArea(20f); base.targetPlayer = val; if ((Object)(object)val2 != (Object)null) { TongueAttack.TryBegin(val2); } } else if (IsTongueTargetVisible(val)) { TongueAttack.TryBegin(val); } } private void ApplyHuntSpacing(PlayerControllerB huntTarget) { //IL_0071: 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) bool flag = CanBeginClawCombo(huntTarget); if (_huntHoldingWithinReach != flag) { RaptorPlugin.Log.LogInfo((object)("[HuntSpacing] " + (flag ? "HOLD" : "FOLLOW") + " " + $"Raptor={((NetworkBehaviour)this).NetworkObjectId}, player={huntTarget.playerClientId}, " + $"rootDistance={FlatDistance(((Component)this).transform.position, ((Component)huntTarget).transform.position):0.00}m")); } _huntHoldingWithinReach = flag; if (flag) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.agent.speed = 0f; if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && base.agent.hasPath) { base.agent.ResetPath(); } } else if (_teleportedToShipWithoutNavMesh || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.agent.speed = 0f; } else { base.agent.stoppingDistance = GetRageAttackStoppingDistance(); base.agent.speed = HuntMovementSpeed; base.agent.autoBraking = true; base.moveTowardsDestination = true; base.movingTowardsTargetPlayer = true; } } private bool IsTongueTargetVisible(PlayerControllerB player) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player.playerCollider == (Object)null) && !((Object)(object)TongueAttack == (Object)null)) { RaptorTongueAttack tongueAttack = TongueAttack; Vector3 position = base.eye.position; Bounds bounds = player.playerCollider.bounds; if (!tongueAttack.IsClosedDoorBetween(position, ((Bounds)(ref bounds)).center)) { Vector3 position2 = base.eye.position; bounds = player.playerCollider.bounds; return !Physics.Linecast(position2, ((Bounds)(ref bounds)).center, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } } return false; } internal void FaceTongueTarget(Vector3 target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FaceTargetSmoothly(target, 12f); } internal void ResumeAfterTongue() { if (base.isEnemyDead) { return; } State currentBehaviourStateIndex = (State)base.currentBehaviourStateIndex; ConfigureAgentFor(currentBehaviourStateIndex); if (currentBehaviourStateIndex == State.Hunting) { PlayerControllerB val = ResolvePlayer(_huntTargetId); if (IsValidTargetInCurrentArea(val)) { base.targetPlayer = val; ApplyHuntSpacing(val); } } } private void TickRegurgitating() { //IL_0180: 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) if (!_nonRageRegurgitation || _rageAfterPickleRegurgitation) { RefreshRageTarget(); } ConfigureAgentFor(State.Regurgitating); base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && base.agent.hasPath) { base.agent.ResetPath(); } if (!_regurgitationPlayerReleased && RaptorRegurgitationPlan.AtCue(Time.time, _regurgitationStartedAt, 2.2f)) { _regurgitationPlayerReleased = true; if (_chemicalRegurgitation) { MaskCorruption?.EjectAllMasked(); CadaverContainment?.EjectAll(); Stomach?.RegurgitateAllLiving(); } else if (!TryRegurgitateContainedMonster()) { Stomach?.RegurgitateOne(); } RaptorPlugin.Log.LogInfo((object)$"[Regurgitate] player release cue at {Time.time - _regurgitationStartedAt:0.00}s (Raptor {((NetworkBehaviour)this).NetworkObjectId})"); } if (!_regurgitationItemsReleased && RaptorRegurgitationPlan.AtCue(Time.time, _regurgitationStartedAt, 2.96f)) { _regurgitationItemsReleased = true; int num = ((!((Object)(object)ItemEating == (Object)null)) ? (_chemicalRegurgitation ? ItemEating.RegurgitateAllItems(FeedItemMouthPoint) : ItemEating.RegurgitateItems(_regurgitationItemCount, FeedItemMouthPoint)) : 0); RaptorPlugin.Log.LogInfo((object)$"[Regurgitate] end-of-animation item release={num}; remaining={ItemEating?.StoredCount ?? 0} (Raptor {((NetworkBehaviour)this).NetworkObjectId})"); } if (!RaptorRegurgitationPlan.AtCue(Time.time, _regurgitationStartedAt, 3f)) { return; } if (_chemicalRegurgitation) { _chemicalRegurgitation = false; _nonRageRegurgitation = false; _regurgitationResumeHunt = false; _rageAfterPickleRegurgitation = false; EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); FlashStun?.ChemicalDaze(); RaptorPlugin.Log.LogInfo((object)($"[ChemicalJug] REGURGITATE complete for Raptor {((NetworkBehaviour)this).NetworkObjectId}; " + "all items/players expelled; ten-second daze now active before normal roaming.")); } else if (_nonRageRegurgitation) { bool regurgitationResumeHunt = _regurgitationResumeHunt; bool rageAfterPickleRegurgitation = _rageAfterPickleRegurgitation; _nonRageRegurgitation = false; _rageAfterPickleRegurgitation = false; _regurgitationResumeHunt = false; if (rageAfterPickleRegurgitation) { _rageStartEndsAt = Time.time + 2f; SwitchState(State.RageStart); return; } PlayerControllerB val = ResolvePlayer(_huntTargetId); if (regurgitationResumeHunt && Time.time < _huntEndsAt && IsValidTargetInCurrentArea(val)) { base.targetPlayer = val; SwitchState(State.Hunting); } else { EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } RaptorPlugin.Log.LogInfo((object)"[Pickles] non-Rage regurgitation finished; returned to normal behavior."); } else { _rageStartEndsAt = Time.time + 2f; SwitchState(State.RageStart); } } internal void QueueTzpRage(ulong originalItemId) { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && originalItemId != ulong.MaxValue && !IsJetpackFlying) { _tzpRageQueued = true; _tzpQueuedItemId = originalItemId; RaptorPlugin.Log.LogInfo((object)($"[TZP] QUEUED Raptor={((NetworkBehaviour)this).NetworkObjectId}; native inhalant={originalItemId}, " + "waiting for swallowed-item recovery; NO regurgitation.")); } } private void BeginTzpRage() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && _tzpRageQueued && !IsJetpackFlying) { ulong tzpQueuedItemId = _tzpQueuedItemId; _tzpQueuedItemId = ulong.MaxValue; _tzpRageQueued = false; _tzpRageActive = true; _rageAggressors.Clear(); _rageTriggerPlayerId = null; _meleeFocusPlayerId = null; _pausedHuntRemaining = 0f; _huntEndsAt = 0f; _huntTargetId = null; _satisfiedUntil = 0f; _resetHeadingWhenRoamingResumes = true; _rageStartEndsAt = Time.time + 2f; _rageEndsAt = RaptorTzpRules.RageEnd(Time.time); _nextClawAt = 0f; base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; CancelRoamingExploration(); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } CandyRush?.BeginTzpBoost(tzpQueuedItemId); RefreshRageTarget(); SwitchState(State.RageStart); RaptorPlugin.Log.LogInfo((object)($"[TZP] RAGE START Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + $"Rage_Start={2f:0.0}s, then {60f:0}s of " + $"nearest-player claw combat, 1.40x speed; storedItems={ItemEating?.StoredCount ?? 0}, " + $"livingCaptives={Stomach?.LivingOccupants ?? 0}, regurgitation=SUPPRESSED.")); } } internal void QueueChemicalRegurgitation() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { _chemicalRegurgitationQueued = true; _pickleRegurgitationQueued = false; RaptorPlugin.Log.LogInfo((object)($"[ChemicalJug] full stomach purge queued for Raptor {((NetworkBehaviour)this).NetworkObjectId}; " + "waiting for tongue swallow/recovery to complete.")); } } private bool TryRegurgitateContainedMonster() { int num = MaskCorruption?.ReadyCount ?? 0; int num2 = CadaverContainment?.ReadyCount ?? 0; return RaptorContainedMonsterRules.Choose(num, num2, Stomach?.LivingOccupants ?? 0, Random.value, Random.Range(0, Math.Max(1, num + num2))) switch { ContainedMonsterChoice.Masked => MaskCorruption?.ReleaseOneReady(Random.Range(0, num)) ?? false, ContainedMonsterChoice.Cadaver => CadaverContainment?.ReleaseOne(Random.Range(0, num2)) ?? false, _ => false, }; } private void BeginChemicalRegurgitation() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { int num = Stomach?.LivingOccupants ?? 0; int num2 = ItemEating?.StoredCount ?? 0; _chemicalRegurgitation = true; _nonRageRegurgitation = true; _rageAfterPickleRegurgitation = false; _regurgitationResumeHunt = false; _regurgitationStartedAt = Time.time; _regurgitationPlayerReleased = num == 0 && (MaskCorruption?.ReadyCount ?? 0) + (CadaverContainment?.ReadyCount ?? 0) == 0; _regurgitationItemsReleased = num2 == 0; _regurgitationItemCount = num2; _rageAggressors.Clear(); _rageTriggerPlayerId = null; _meleeFocusPlayerId = null; _huntTargetId = null; _lastDetectedPlayerId = null; _pausedHuntRemaining = 0f; _huntEndsAt = (_rageEndsAt = (_rageStartEndsAt = (_comboEndsAt = 0f))); _satisfiedUntil = 0f; base.targetPlayer = null; base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; CancelRoamingExploration(); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } SwitchState(State.Regurgitating); RaptorPlugin.Log.LogInfo((object)($"[ChemicalJug] full REGURGITATE started Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + $"living={num}, storedItems={num2}, plannedAll={_regurgitationItemCount}; " + "post-animation stunned duration=10 seconds.")); } } internal void QueuePickleRegurgitation() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { _pickleRegurgitationQueued = true; RaptorPlugin.Log.LogInfo((object)$"[Pickles] jar eaten; non-Rage regurgitation queued for Raptor {((NetworkBehaviour)this).NetworkObjectId}."); } } private void BeginPickleRegurgitation() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !IsRaging) { int num = (((Object)(object)Stomach != (Object)null) ? Stomach.LivingOccupants : 0); int num2 = (((Object)(object)ItemEating != (Object)null) ? ItemEating.StoredCount : 0); _nonRageRegurgitation = true; _rageAfterPickleRegurgitation = false; _regurgitationResumeHunt = base.currentBehaviourStateIndex == 1; if (_regurgitationResumeHunt) { _huntEndsAt += 3f; } _regurgitationStartedAt = Time.time; _regurgitationPlayerReleased = num == 0 && (MaskCorruption?.ReadyCount ?? 0) + (CadaverContainment?.ReadyCount ?? 0) == 0; _regurgitationItemsReleased = num2 == 0; _regurgitationItemCount = RaptorRegurgitationPlan.ItemCountToRelease(num2, _serverRandom.Next(1, 4)); base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } RaptorPlugin.Log.LogInfo((object)($"[Pickles] REGURGITATE started (NO RAGE): Raptor={((NetworkBehaviour)this).NetworkObjectId}, " + $"living={num}, storedItems={num2}, willRelease={_regurgitationItemCount}")); SwitchState(State.Regurgitating); } } private void BeginRagePresentation() { if (IsRaging) { return; } _nonRageRegurgitation = false; int num = (((Object)(object)Stomach != (Object)null) ? Stomach.LivingOccupants : 0); int num2 = (((Object)(object)ItemEating != (Object)null) ? ItemEating.StoredCount : 0); if (RaptorRegurgitationPlan.ShouldAnimate(num, num2) || (MaskCorruption?.ReadyCount ?? 0) + (CadaverContainment?.ReadyCount ?? 0) > 0) { _regurgitationStartedAt = Time.time; _regurgitationPlayerReleased = num == 0 && (MaskCorruption?.ReadyCount ?? 0) + (CadaverContainment?.ReadyCount ?? 0) == 0; _regurgitationItemsReleased = num2 == 0; _regurgitationItemCount = RaptorRegurgitationPlan.ItemCountToRelease(num2, _serverRandom.Next(1, 4)); _rageEndsAt += 3f; base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } RaptorPlugin.Log.LogInfo((object)($"[Regurgitate] STARTED Raptor={((NetworkBehaviour)this).NetworkObjectId}, living={num}, " + $"stored={num2}, plannedItems={_regurgitationItemCount}; " + $"playerCue={2.2f}s, " + $"itemCue={2.96f}s, duration={3f}s")); SwitchState(State.Regurgitating); } else { _rageStartEndsAt = Time.time + 2f; SwitchState(State.RageStart); } } private void TickRageStart() { ConfigureAgentFor(State.RageStart); base.movingTowardsTargetPlayer = false; RefreshRageTarget(); if (Time.time >= _rageStartEndsAt) { SwitchState(State.Raging); } } private void TickRaging() { //IL_0167: 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) ConfigureAgentFor(State.Raging); if (Time.time >= _rageEndsAt) { EndRage(); return; } RefreshRageTarget(); if ((Object)(object)base.targetPlayer == (Object)null) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.agent.speed = 0f; _meleeFocusPlayerId = null; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } return; } PlayerControllerB val = FindReachableClawTarget(); _meleeFocusPlayerId = val?.playerClientId; if ((Object)(object)val != (Object)null) { base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; base.agent.speed = 0f; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && base.agent.hasPath) { base.agent.ResetPath(); } if (Time.time >= _nextClawAt) { _comboEndsAt = Time.time + 1.3f; SwitchState(State.ClawCombo); RaptorPlugin.Log.LogInfo((object)($"[RageMelee] combo started against player {val.playerClientId}; " + $"rootDistance={FlatDistance(((Component)this).transform.position, ((Component)val).transform.position):0.00}m; " + "target is within shared claw reach.")); } } else if (_teleportedToShipWithoutNavMesh || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.agent.speed = 0f; } else { base.agent.stoppingDistance = GetRageAttackStoppingDistance(); base.moveTowardsDestination = true; base.movingTowardsTargetPlayer = true; } } private void TickClawAdvance() { //IL_0095: 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_00bc: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0134: 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_0149: 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_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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || base.currentBehaviourStateIndex != 4 || IsFlashStunned || IsJetpackFlying || _teleportedToShipWithoutNavMesh || base.stunNormalizedTimer > 0f || base.stunnedIndefinitely > 0 || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return; } PlayerControllerB val = ResolvePlayer(_meleeFocusPlayerId); if (!IsValidTargetInCurrentArea(val) || !HasClawLineOfSight(val)) { return; } Vector3 val2 = Flatten(((Component)this).transform.forward); if (!(((Vector3)(ref val2)).sqrMagnitude < 0.001f)) { ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Flatten(((Component)val).transform.position - ((Component)this).transform.position); float forwardDistance = Vector3.Dot(val3, val2); float sidewaysDistance = Mathf.Abs(Vector3.Dot(val3, Vector3.Cross(Vector3.up, val2))); float num = RaptorClawAdvanceRules.ForwardStep(Time.time - _comboAdvanceStartedAt, Time.deltaTime, _comboAdvanceTravelled, forwardDistance, sidewaysDistance); if (!(num <= 0f)) { Vector3 nextPosition = base.agent.nextPosition; base.agent.Move(val2 * num); Vector3 val4 = Flatten(base.agent.nextPosition - nextPosition); _comboAdvanceTravelled = Mathf.Min(2.7f, _comboAdvanceTravelled + Mathf.Max(0f, Vector3.Dot(val4, val2))); } } } public void BeginHunt(PlayerControllerB player) { if (((NetworkBehaviour)this).IsOwner && IsValidTargetInCurrentArea(player) && !IsRaging) { SetHuntTargetAndDeadline(player); } } private void SetHuntTargetAndDeadline(PlayerControllerB player) { if (IsHumanTasteActive) { return; } bool flag = base.currentBehaviourStateIndex == 1; _ringFollowing = false; _huntTargetId = player.playerClientId; _huntEndsAt = RaptorHuntClock.RefreshDeadline(Time.time); base.targetPlayer = player; if (!flag) { SwitchState(State.Hunting); } else { ConfigureAgentFor(State.Hunting); if ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy) { ApplyHuntSpacing(player); } } if (!flag && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { ApplyHuntSpacing(player); } DebugLog(string.Format("{0} Hunt -> player {1}; ", flag ? "Refresh" : "Begin", player.playerClientId) + $"duration={_huntEndsAt - Time.time:0.0}s."); } internal void TryResumeWeddingFollowing(ulong playerId) { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !IsHumanTasteActive && !IsJetpackFlying && !IsFlashStunned && !IsRaging && !((Object)(object)WeddingRing == (Object)null) && WeddingRing.Protects(playerId) && base.currentBehaviourStateIndex == 0 && (!((Object)(object)TongueAttack != (Object)null) || !TongueAttack.Busy)) { PlayerControllerB val = ResolvePlayer(playerId); if (IsValidTargetInCurrentArea(val)) { _ringFollowing = true; _huntTargetId = playerId; _huntEndsAt = float.PositiveInfinity; base.targetPlayer = val; SwitchState(State.Hunting); ApplyHuntSpacing(val); RaptorPlugin.Log.LogInfo((object)($"[WeddingRing] FOLLOW Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + string.Format("player={0}; area={1}; speed=normal Hunt.", playerId, base.isOutside ? "outside" : "facility"))); } } } internal void StopWeddingFollowing() { if (((NetworkBehaviour)this).IsOwner) { bool ringFollowing = _ringFollowing; _ringFollowing = false; if (ringFollowing && base.currentBehaviourStateIndex == 1) { EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } } internal void BeginHumanTasteHunt(bool preserveLockedTarget) { if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || IsJetpackFlying) { return; } WeddingRing?.Cancel("Human Taste Hunt"); PlayerControllerB val = (preserveLockedTarget ? ResolvePlayer(_huntTargetId) : null); if (!IsEligibleHumanTasteTarget(val)) { val = FindNearestHumanTasteTarget(); } _huntTargetId = val?.playerClientId; _huntEndsAt = Time.time + 30f; _pausedHuntRemaining = 0f; _satisfiedUntil = 0f; if (!IsRaging && !IsRegurgitating) { if (base.currentBehaviourStateIndex != 1) { SwitchState(State.Hunting); } base.targetPlayer = val; if ((Object)(object)val != (Object)null && ((Object)(object)TongueAttack == (Object)null || !TongueAttack.Busy)) { ApplyHuntSpacing(val); } } RaptorPlugin.Log.LogInfo((object)($"[HumanTaste] LOCK Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + "target=" + (_huntTargetId.HasValue ? _huntTargetId.Value.ToString() : "waiting") + "; " + $"remaining={HumanTaste?.Remaining:0.0}s; outside={base.isOutside}.")); } private bool IsEligibleHumanTasteTarget(PlayerControllerB? player) { if (IsValidTargetInCurrentArea(player) && (Object)(object)player.playerCollider != (Object)null) { return player.playerCollider.enabled; } return false; } private PlayerControllerB? FindNearestHumanTasteTarget() { //IL_003b: 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_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null) { return null; } PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (IsEligibleHumanTasteTarget(val)) { Vector3 val2 = ((Component)this).transform.position - ((Component)val).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = val; } } } return result; } private PlayerControllerB? EnsureHumanTasteTarget() { PlayerControllerB val = ResolvePlayer(_huntTargetId); if (IsEligibleHumanTasteTarget(val)) { return val; } PlayerControllerB val2 = FindNearestHumanTasteTarget(); if (_huntTargetId != val2?.playerClientId) { RaptorPlugin.Log.LogInfo((object)($"[HumanTaste] RETARGET Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + "previous=" + (_huntTargetId.HasValue ? _huntTargetId.Value.ToString() : "none") + "; next=" + (((Object)(object)val2 != (Object)null) ? val2.playerClientId.ToString() : "waiting"))); } _huntTargetId = val2?.playerClientId; return val2; } internal void EndHumanTasteHunt() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { _pausedHuntRemaining = 0f; _huntEndsAt = 0f; _regurgitationResumeHunt = false; if (base.currentBehaviourStateIndex == 1 && !IsFlashStunned) { EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } } public void SetSatisfied(float seconds) { if (((NetworkBehaviour)this).IsOwner) { _satisfiedUntil = Mathf.Max(_satisfiedUntil, Time.time + Mathf.Max(0f, seconds)); DebugLog($"Satisfied for {Mathf.Max(0f, seconds):0.0}s."); } } internal bool TryStartOrRefreshHuntAfterFeeding(PlayerControllerB feeder) { if (!((NetworkBehaviour)this).IsOwner || (Object)(object)feeder == (Object)null || IsRaging || !IsValidTargetInCurrentArea(feeder)) { RaptorPlugin.Log.LogInfo((object)"[ItemFeeding] feeder Hunt not started: feeder unavailable, in a different area, or Rage active."); return false; } bool flag = base.currentBehaviourStateIndex == 1; if (!IsHumanTasteActive) { SetHuntTargetAndDeadline(feeder); } RaptorPlugin.Log.LogInfo((object)("[ItemFeeding] Hunt " + (flag ? "REFRESHED" : "STARTED") + " " + $"on item gulp: feeder={feeder.playerClientId}; duration={60f:0}s; " + $"satisfaction remaining={Mathf.Max(0f, _satisfiedUntil - Time.time):0.0}s (tongue cooldown only).")); return true; } public void SetSatisfiedRandom() { if (((NetworkBehaviour)this).IsOwner) { SetSatisfied(RandomRange(20f, 40f)); } } public override void SetEnemyStunned(bool setToStunned, float setToStunnedTime = 1f, PlayerControllerB? playerWhoStunned = null) { if (RaptorFlashStunRules.IsFlashbangRequest(setToStunned, setToStunnedTime) && !base.isEnemyDead && (Object)(object)base.enemyType != (Object)null && base.enemyType.canBeStunned) { ((EnemyAI)this).SetEnemyStunned(true, RaptorFlashStunRules.NormalizedSeconds(10f, base.enemyType.stunTimeMultiplier), playerWhoStunned); FlashStun?.NativeFlashbang(); } else { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunnedTime, playerWhoStunned); } } internal void BeginFlashStun() { if ((Object)(object)TongueAttack != (Object)null && TongueAttack.Busy) { TongueAttack.Interrupt("flash grenade", ((NetworkBehaviour)this).IsOwner); } _leftHit = true; _rightHit = true; FreezeForFlashStun(); RaptorPlugin.Log.LogInfo((object)($"[FlashStun] POSE Raptor={((NetworkBehaviour)this).NetworkObjectId}, owner={((NetworkBehaviour)this).IsOwner}, " + $"state={base.currentBehaviourStateIndex}, clip=Stunned_Loop.")); } internal void FreezeForFlashStun() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead) { return; } base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.speed = 0f; if (base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.velocity = Vector3.zero; } } } internal void EndFlashStun() { if (base.stunNormalizedTimer > 0f) { base.stunNormalizedTimer = 0f; } if ((Object)(object)PosePlayer != (Object)null) { ApplyAnimationForState(force: true); } if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || _jetpackBlastFrozen) { return; } if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = false; } if (IsJetpackFlying) { ConfigureAgentFor(State.JetpackFlight); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { BeginRoamingExploration(forceInitialEscape: true); } } else if (base.currentBehaviourStateIndex == 5) { ConfigureAgentFor(State.Regurgitating); } else if (_tzpRageActive) { State state = ((base.currentBehaviourStateIndex == 2) ? State.RageStart : State.Raging); RefreshRageTarget(); SwitchState(state); CandyRush?.SyncTzpAfterFlash(); RaptorPlugin.Log.LogInfo((object)($"[TZP] resumed Rage after flash stun Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + $"remaining={Mathf.Max(0f, _rageEndsAt - Time.time):0.0}s.")); } else { EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } public override void OnCollideWithPlayer(Collider other) { if (!((Object)(object)other != (Object)null) || !((Object)(object)JetpackFlight != (Object)null) || !JetpackFlight.TryDetonateOnContact(((Component)other).GetComponent<PlayerControllerB>() ?? ((Component)other).GetComponentInParent<PlayerControllerB>())) { ((EnemyAI)this).OnCollideWithPlayer(other); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { if (IsTruckResting || base.currentBehaviourStateIndex == 7 || ((Object)(object)ZapGunShield != (Object)null && ZapGunShield.TryBlockHit(force, playerWhoHit, hitID))) { return; } if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { WeddingRing?.Cancel("Raptor hit"); } if (((Object)(object)JetpackFlight != (Object)null && JetpackFlight.TryDetonateOnHit(playerWhoHit, force)) || _jetpackBlastFrozen) { return; } ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (base.isEnemyDead) { return; } base.enemyHP -= force; if (!((NetworkBehaviour)this).IsOwner) { return; } if (base.enemyHP <= 0) { CancelRoamingExploration(); base.movingTowardsTargetPlayer = false; base.agent.speed = 0f; DebugLog("Killed."); ((EnemyAI)this).KillEnemyOnOwnerClient(false); } else if (!IsFlashStunned) { if (IsJetpackFlying) { RaptorPlugin.Log.LogInfo((object)$"[JetpackFlight] hit during flight; no Rage: Raptor={((NetworkBehaviour)this).NetworkObjectId}, force={force}, hitID={hitID}"); } else if (!RaptorTzpRules.SuppressHitRegurgitation(_tzpRageActive || _tzpRageQueued) && (Object)(object)playerWhoHit != (Object)null) { StartOrRefreshRage(playerWhoHit, RaptorShotgunImpactRules.IsNativeShotgunPellet(force, hitID)); } } } private void StartOrRefreshRage(PlayerControllerB attacker, bool shotgunImpact) { if (_tzpRageActive || _tzpRageQueued) { return; } WeddingRing?.Cancel("Rage triggered"); if (IsJetpackFlying || _chemicalRegurgitationQueued || _chemicalRegurgitation) { return; } if (_nonRageRegurgitation && IsRegurgitating) { if (!_rageAfterPickleRegurgitation) { _rageTriggerPlayerId = attacker.playerClientId; } RegisterAggressor(attacker); _rageAfterPickleRegurgitation = true; RefreshRageTarget(); _rageEndsAt = Time.time + 35f + Mathf.Max(0f, 3f - (Time.time - _regurgitationStartedAt)); if (_regurgitationResumeHunt) { _pausedHuntRemaining = Mathf.Max(0f, _huntEndsAt - Time.time); } RaptorPlugin.Log.LogInfo((object)"[Pickles] incoming hit will start Rage AFTER the regurgitation animation."); return; } TongueAttack?.Interrupt("rage started"); if (!IsRegurgitating) { _rageTriggerPlayerId = attacker.playerClientId; } RegisterAggressor(attacker); _rageEndsAt = Time.time + 35f; if (!IsRaging) { if (base.currentBehaviourStateIndex == 1) { _pausedHuntRemaining = Mathf.Max(0f, _huntEndsAt - Time.time); } else { _pausedHuntRemaining = 0f; } _resetHeadingWhenRoamingResumes = true; CancelRoamingExploration(); RefreshRageTarget(); RaptorPlugin.Log.LogInfo((object)($"[RageTarget] Raptor={((NetworkBehaviour)this).NetworkObjectId}; triggeringPlayer={attacker.playerClientId}; " + $"lockedTarget={_rageTriggerPlayerId}; initialState={(State)base.currentBehaviourStateIndex}")); DebugLog($"Entering Rage for {35f:0}s; attacker={attacker.playerClientId}."); if (shotgunImpact) { _rageStartEndsAt = Time.time + 2f; SwitchState(State.RageStart); RaptorPlugin.Log.LogInfo((object)($"[RageTarget] shotgun impact Raptor={((NetworkBehaviour)this).NetworkObjectId}: " + "Rage_Start without regurgitation; stored items/prey retained.")); } else { BeginRagePresentation(); } } else { RefreshRageTarget(); DebugLog($"Rage refreshed; newest attacker={attacker.playerClientId}; no regurgitation."); } } private void EndRage() { if (_tzpRageActive) { _tzpRageActive = false; CandyRush?.EndTzpBoost(); RaptorPlugin.Log.LogInfo((object)($"[TZP] RAGE COMPLETE Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + $"full {60f:0}s combat finished; stomach preserved.")); } DebugLog("Rage expired."); _rageAggressors.Clear(); _rageTriggerPlayerId = null; _meleeFocusPlayerId = null; base.targetPlayer = null; base.movingTowardsTargetPlayer = false; if (IsHumanTasteActive) { _pausedHuntRemaining = 0f; base.targetPlayer = EnsureHumanTasteTarget(); SwitchState(State.Hunting); return; } PlayerControllerB val = ResolvePlayer(_huntTargetId); if (_pausedHuntRemaining > 0f && IsValidTargetInCurrentArea(val)) { _huntEndsAt = Time.time + _pausedHuntRemaining; _pausedHuntRemaining = 0f; base.targetPlayer = val; DebugLog($"Resuming paused Hunt for {_huntEndsAt - Time.time:0.0}s."); SwitchState(State.Hunting); } else { _pausedHuntRemaining = 0f; EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } } private void RegisterAggressor(PlayerControllerB player) { ulong playerClientId = player.playerClientId; _rageAggressors.Remove(playerClientId); _rageAggressors.Add(playerClientId); } private void RefreshRageTarget() { if (_tzpRageActive) { PlayerControllerB val = FindNearestValidPlayerInArea(); if ((Object)(object)base.targetPlayer != (Object)(object)val) { base.targetPlayer = val; RaptorPlugin.Log.LogInfo((object)($"[TZP] TARGET Raptor={((NetworkBehaviour)this).NetworkObjectId}; " + "nearest=" + (((Object)(object)val != (Object)null) ? val.playerClientId.ToString() : "none") + ", " + $"outside={base.isOutside}.")); } return; } PlayerControllerB val2 = ResolvePlayer(RaptorRageTargetRules.PreferAttacker(_rageTriggerPlayerId, _rageAggressors, (ulong id) => IsValidTargetInCurrentArea(ResolvePlayer(id)))); if (val2 == null) { val2 = FindNearestValidPlayerInArea(); } if ((Object)(object)base.targetPlayer != (Object)(object)val2) { base.targetPlayer = val2; if ((Object)(object)val2 != (Object)null) { DebugLog($"Rage target -> player {val2.playerClientId}."); } else { DebugLog("Rage currently has no valid target in this area."); } } } private void EnterRoaming(bool resetDirectionalBias = false, bool seedCurrentArea = false) { //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_0053: Unknown result type (might be due to invalid IL or missing references) _ringFollowing = false; _huntTargetId = null; _huntHoldingWithinReach = false; base.targetPlayer = null; bool flag = resetDirectionalBias || _resetHeadingWhenRoamingResumes; if (flag) { _lastRoamDirection = Vector3.zero; } if (seedCurrentArea || _resetHeadingWhenRoamingResumes) { RecordRoamVisit(int.MinValue, ((Component)this).transform.position); } ResetBaseNavigationForRoam(); _resetHeadingWhenRoamingResumes = false; SwitchState(State.Roaming); BeginRoamingExploration(flag || seedCurrentArea); } private void SwitchState(State state) { if ((!IsTruckResting || state == State.TruckRest) && ((NetworkBehaviour)this).IsOwner) { if (state == State.RageStart || state == State.Raging || state == State.ClawCombo) { WeddingRing?.Cancel("entered Rage"); } if (state != State.Hunting) { _huntHoldingWithinReach = false; } if (state != State.Roaming) { CancelRoamingExploration(); } ConfigureAgentFor(state); if (state == State.ClawCombo) { _comboAdvanceStartedAt = Time.time; _comboAdvanceTravelled = 0f; } if (((NetworkBehaviour)this).IsServer) { ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient((int)state); ((EnemyAI)this).SwitchToBehaviourClientRpc((int)state); } else { ((EnemyAI)this).SwitchToBehaviourState((int)state); } DebugLog($"State -> {state}."); } } internal void BeginCruiserRest() { if (!base.isEnemyDead) { TongueAttack?.Interrupt("Company Cruiser consumed"); StopForCruiserRest(); if (((NetworkBehaviour)this).IsOwner && base.currentBehaviourStateIndex != 7) { SwitchState(State.TruckRest); } else if (!((NetworkBehaviour)this).IsOwner && base.currentBehaviourStateIndex != 7) { ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(7); } TruckVisual?.Begin(); } } internal void ResumeAfterCruiserAbort() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || IsTruckResting || base.currentBehaviourStateIndex == 7 || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh || IsFlashStunned) { return; } base.agent.isStopped = false; if (base.currentBehaviourStateIndex == 1) { PlayerControllerB val = ResolvePlayer(_huntTargetId); if ((Object)(object)val != (Object)null && IsValidTargetInCurrentArea(val) && (_ringFollowing || IsHumanTasteActive || Time.time < _huntEndsAt)) { ConfigureAgentFor(State.Hunting); base.targetPlayer = val; base.movingTowardsTargetPlayer = true; base.moveTowardsDestination = false; base.agent.SetDestination(((Component)val).transform.position); return; } } EnterRoaming(resetDirectionalBias: true, seedCurrentArea: true); } internal void StopForCruiserRest() { if (!((NetworkBehaviour)this).IsOwner) { return; } CancelRoamingExploration(); base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.targetPlayer = null; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; if (base.agent.hasPath) { base.agent.ResetPath(); } base.agent.speed = 0f; } } private void ConfigureAgentFor(State state) { switch (state) { case State.JetpackFlight: base.agent.speed = RaptorStoredUtilityRules.GoldSpeed(18f, (Object)(object)ItemEating != (Object)null && ItemEating.HasStoredGoldBar); base.agent.acceleration = 32f; base.agent.angularSpeed = 520f; base.agent.stoppingDistance = 0.15f; base.agent.autoBraking = false; break; case State.Roaming: base.agent.autoBraking = true; base.agent.speed = RushSpeed(0.612f); base.agent.acceleration = 10f; base.agent.angularSpeed = 180f; base.agent.stoppingDistance = 0.35f; break; case State.Hunting: base.agent.speed = HuntMovementSpeed; base.agent.acceleration = 12f; base.agent.angularSpeed = 220f; base.agent.stoppingDistance = GetRageAttackStoppingDistance(); base.agent.autoBraking = true; break; case State.TruckRest: base.agent.speed = 0f; base.agent.autoBraking = true; break; case State.RageStart: case State.ClawCombo: case State.Regurgitating: base.agent.speed = 0f; base.agent.acceleration = 32f; base.agent.angularSpeed = 520f; base.agent.stoppingDistance = 0.35f; break; case State.Raging: base.agent.speed = RushSpeed(8.05f); base.agent.acceleration = 32f; base.agent.angularSpeed = 520f; base.agent.stoppingDistance = GetRageAttackStoppingDistance(); base.agent.autoBraking = true; break; } } private float RushSpeed(float normal) { return RaptorStoredUtilityRules.GoldSpeed(((Object)(object)CandyRush != (Object)null) ? CandyRush.Adjust(normal) : normal, (Object)(object)ItemEating != (Object)null && ItemEating.HasStoredGoldBar); } internal void RefreshCandyMovement() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !((Object)(object)base.agent == (Object)null) && ((Behaviour)base.agent).enabled && !(base.agent.speed <= 0.01f)) { switch ((State)base.currentBehaviourStateIndex) { case State.Roaming: base.agent.speed = RushSpeed(0.612f); break; case State.Hunting: base.agent.speed = HuntMovementSpeed; break; case State.Raging: base.agent.speed = RushSpeed(8.05f); break; case State.JetpackFlight: base.agent.speed = RaptorStoredUtilityRules.GoldSpeed(18f, (Object)(object)ItemEating != (Object)null && ItemEating.HasStoredGoldBar); break; case State.RageStart: case State.ClawCombo: case State.Regurgitating: break; } } } private void ApplySoftWallClearance() { //IL_00cb: 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_0071: 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_00f1: 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_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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_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_015b: 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_0166: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_017d: 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_0188: 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_0192: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01b9: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh || (Object)(object)StartOfRound.Instance == (Object)null || base.agent.speed <= 0.01f) { return; } State currentBehaviourStateIndex = (State)base.currentBehaviourStateIndex; switch (currentBehaviourStateIndex) { case State.RageStart: case State.ClawCombo: case State.Regurgitating: return; case State.Roaming: case State.JetpackFlight: if (_hasRoamDestination) { bool num = Vector3.Distance(((Component)this).transform.position, _roamDestination) <= 2f; bool flag = !base.agent.pathPending && base.agent.hasPath && base.agent.remainingDistance <= 2f; if (num || flag) { return; } } break; } Vector3 val = base.agent.desiredVelocity; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)this).transform.forward; val.y = 0f; } if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; float leftPressure = 0f; float rightPressure = 0f; Vector3 position = ((Component)this).transform.position; Vector3 origin = position + Vector3.up * 0.85f + val * 0.45f; Vector3 origin2 = position + Vector3.up * 0.85f - val * 0.6f; Vector3 origin3 = position + Vector3.up * 1.85f + val * 0.45f; Vector3 origin4 = position + Vector3.up * 1.85f - val * 0.6f; AccumulateWallPressures(origin, normalized, ref leftPressure, ref rightPressure); AccumulateWallPressures(origin2, normalized, ref leftPressure, ref rightPressure); AccumulateWallPressures(origin3, normalized, ref leftPressure, ref rightPressure); AccumulateWallPressures(origin4, normalized, ref leftPressure, ref rightPressure); float num2 = Mathf.Clamp((leftPressure - rightPressure) * 0.25f, -1f, 1f); if (!(Mathf.Abs(num2) < 0.02f)) { base.agent.Move(normalized * (num2 * RushSpeed(currentBehaviourStateIndex switch { State.Raging => 0.7f, State.Hunting => 0.45f, _ => 0.28f, }) * Time.deltaTime)); } } } private void AccumulateWallPressures(Vector3 origin, Vector3 right, ref float leftPressure, ref float rightPressure) { //IL_0006: 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_0013: 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_0015: Unknown result type (might be due to invalid IL or missing references) rightPressure += SampleWallPressure(origin, right); leftPressure += SampleWallPressure(origin, -right); } private float SampleWallPressure(Vector3 origin, Vector3 direction) { //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) RaycastHit val = default(RaycastHit); if (Physics.Raycast(origin, direction, ref val, 1.05f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { return 1f - Mathf.Clamp01(((RaycastHit)(ref val)).distance / 1.05f); } return 0f; } private void BeginRoamingExploration(bool forceInitialEscape = false) { //IL_003e: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead) { StopFallbackRoamSearch(); ClearRoamDestination(resetPath: true); _roamPauseUntil = 0f; _roamRepathAttempts = 0; _forceEscapeNextDestination = forceInitialEscape; _roamProgressPosition = ((Component)this).transform.position; _roamProgressCheckAt = Time.time + 8f; _roamWatchdogPosition = ((Component)this).transform.position; _roamWatchdogAt = Time.time + 45f; _nextOutdoorRoamRetryAt = 0f; ChooseRoamDestination(forceInitialEscape); } } private void CancelRoamingExploration() { ClearRoamDestination(resetPath: true); StopFallbackRoamSearch(); _roamPauseUntil = 0f; _roamRepathAttempts = 0; _forceEscapeNextDestination = false; } private void TickRoamingExploration() { //IL_0063: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Invalid comparison between Unknown and I4 //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Invalid comparison between Unknown and I4 //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return; } if (Time.time < _roamPauseUntil) { base.agent.speed = 0f; } else { if (_roamFallbackSearchActive) { return; } if (Time.time >= _roamWatchdogAt) { float num = Vector3.Distance(((Component)this).transform.position, _roamWatchdogPosition); if (num < 7f) { DebugLog($"Roam watchdog: only {num:0.0}m net progress in " + $"{45f:0}s; forcing a long exploratory leg."); _forceEscapeNextDestination = true; ClearRoamDestination(resetPath: true); } _roamWatchdogPosition = ((Component)this).transform.position; _roamWatchdogAt = Time.time + 45f; } if (!_hasRoamDestination) { ChooseRoamDestination(_forceEscapeNextDestination); return; } float num2 = Vector3.Distance(((Component)this).transform.position, _roamDestination); bool num3 = !base.agent.pathPending && base.agent.hasPath && (int)base.agent.pathStatus == 0 && base.agent.remainingDistance <= 1.25f; bool flag = !base.agent.pathPending && !base.agent.hasPath && num2 <= 1.25f; if (num3 || flag) { CompleteRoamLeg(); } else if (!base.agent.pathPending && ((int)base.agent.pathStatus == 2 || (int)base.agent.pathStatus == 1)) { DebugLog($"Committed roam path became {base.agent.pathStatus}; blacklisting the destination temporarily."); RecordRoamFailure(_roamDestinationNodeId, _roamDestination); ClearRoamDestination(resetPath: true); ChooseRoamDestination(forceEscape: true); } else { if (!(Time.time >= _roamProgressCheckAt)) { return; } float num4 = Vector3.Distance(((Component)this).transform.position, _roamProgressPosition); if (num4 < 0.6f) { if (_roamRepathAttempts == 0) { _roamRepathAttempts = 1; base.agent.ResetPath(); bool flag2 = ((EnemyAI)this).SetDestinationToPosition(_roamDestination, false); DebugLog($"Roam progress check: moved only {num4:0.00}m; repathing committed leg (accepted={flag2})."); } else { DebugLog("Roam progress check: still stuck after repath; blacklisting destination and forcing exploration escape."); RecordRoamFailure(_roamDestinationNodeId, _roamDestination); _forceEscapeNextDestination = true; ClearRoamDestination(resetPath: true); } } else { Vector3 val = Flatten(((Component)this).transform.position - _roamProgressPosition); if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { _lastRoamDirection = ((Vector3)(ref val)).normalized; } _roamRepathAttempts = 0; } _roamProgressPosition = ((Component)this).transform.position; _roamProgressCheckAt = Time.time + 8f; } } } private void CompleteRoamLeg() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: 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_0082: 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_0075: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)base.agent != (Object)null) ? Flatten(base.agent.velocity) : Vector3.zero); if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { _lastRoamDirection = ((Vector3)(ref val)).normalized; } else { Vector3 val2 = Flatten(((Component)this).transform.position - _roamLegStartPosition); if (((Vector3)(ref val2)).sqrMagnitude > 1f) { _lastRoamDirection = ((Vector3)(ref val2)).normalized; } } RecordRoamVisit(_roamDestinationNodeId, _roamDestination); bool flag = DetectRecentRoamOscillation(); bool flag2 = flag; DebugLog($"Completed roam leg to node {_roamDestinationNodeId}; " + $"recent destinations={_recentRoamVisits.Count}; oscillation={flag}."); ClearRoamDestination(resetPath: true); _forceEscapeNextDestination = flag2; if (flag) { DebugLog("Detected repeated A<->B/local destination oscillation; next leg will use hard escape selection."); } if (!IsJetpackFlying && _serverRandom.NextDouble() < 0.15000000596046448) { float num = RandomRange(1f, 3f); _roamPauseUntil = Time.time + num; base.agent.speed = 0f; DebugLog($"Roam pause for {num:0.0}s before continuing exploration."); } else { ChooseRoamDestination(flag2); } } private void ChooseRoamDestination(bool forceEscape) { //IL_00d3: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: 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_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: 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_0422: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_018a: 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_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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return; } GameObject[] array = (((Object)(object)RoundManager.Instance == (Object)null) ? Array.Empty<GameObject>() : (base.isOutside ? RoundManager.Instance.outsideAINodes : RoundManager.Instance.insideAINodes)); if (array == null || array.Length == 0) { if (base.isOutside) { TryChooseLocalOutdoorRoamDestination("no outside AI nodes"); return; } DebugLog("No inside AI nodes were available for exploration; falling back to vanilla search."); StartFallbackRoamSearch(); return; } PruneRoamVisits(); PruneRoamFailures(); List<RoamCandidate> list = new List<RoamCandidate>(); bool flag = false; int num = 0; int num2 = 0; NavMeshHit val2 = default(NavMeshHit); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null || !NavMesh.SamplePosition(val.transform.position, ref val2, 3f, base.agent.areaMask)) { continue; } if (Mathf.Abs(((NavMeshHit)(ref val2)).position.y - val.transform.position.y) > 1.5f) { num++; continue; } NavMeshPath val3 = new NavMeshPath(); if (!base.agent.CalculatePath(((NavMeshHit)(ref val2)).position, val3) || (int)val3.status != 0 || val3.corners.Length < 2) { num2++; continue; } float num3 = CalculatePathDistance(val3); if (!(num3 < 0.1f)) { Vector3 firstDirection = FirstFlatPathDirection(val3); int instanceID = ((Object)val).GetInstanceID(); float score = ScoreRoamCandidate(instanceID, ((NavMeshHit)(ref val2)).position, num3, firstDirection, array); if (num3 >= 20f) { flag = true; } list.Add(new RoamCandidate { Position = ((NavMeshHit)(ref val2)).position, NodeId = instanceID, PathDistance = num3, FirstDirection = firstDirection, Score = score }); } } if (list.Count == 0) { if (base.isOutside) { TryChooseLocalOutdoorRoamDestination($"outside nodes unreachable={num2}, verticalRejects={num}"); return; } DebugLog("No complete exploration path could be built to any inside AI node; " + $"verticalRejects={num}, unreachable={num2}; falling back to vanilla search."); StartFallbackRoamSearch(); return; } bool flag2 = forceEscape; int num4; RoamCandidate roamCandidate; if (flag2) { List<RoamCandidate> list2 = list.FindAll((RoamCandidate candidate) => !WasAreaRecentlyVisited(candidate.Position) && !WasDestinationRecentlyFailed(candidate.NodeId, candidate.Position)); if (flag) { List<RoamCandidate> list3 = list2.FindAll((RoamCandidate candidate) => candidate.PathDistance >= 20f); if (list3.Count > 0) { list2 = list3; } } if (list2.Count == 0) { list2 = list.FindAll((RoamCandidate candidate) => !WasDestinationRecentlyFailed(candidate.NodeId, candidate.Position)); } if (list2.Count == 0) { list2 = list; } list2.Sort(delegate(RoamCandidate a, RoamCandidate b) { int num5 = b.PathDistance.CompareTo(a.PathDistance); return (num5 == 0) ? b.Score.CompareTo(a.Score) : num5; }); num4 = Mathf.Min(3, list2.Count); roamCandidate = list2[_serverRandom.Next(num4)]; } else { list.Sort((RoamCandidate a, RoamCandidate b) => b.Score.CompareTo(a.Score)); num4 = Mathf.Min(3, list.Count); roamCandidate = list[_serverRandom.Next(num4)]; } if (!((EnemyAI)this).SetDestinationToPosition(roamCandidate.Position, false)) { RecordRoamFailure(roamCandidate.NodeId, roamCandidate.Position); DebugLog($"NavMeshAgent rejected roam destination node {roamCandidate.NodeId}; destination blacklisted, falling back to