using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using Zorro.Core; using Zorro.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("MMHOOK_Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PingDrivenRobots")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: AssemblyInformationalVersion("1.3.3")] [assembly: AssemblyProduct("PingDrivenRobots")] [assembly: AssemblyTitle("PingDrivenRobots")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PingDrivenRobots { internal sealed class NetworkRobotAgent : MonoBehaviour { internal sealed class FailedSegmentMemory { public PathActionType Action = PathActionType.None; public Vector3 Position = Vector3.zero; public Vector3 Direction = Vector3.zero; public float Until; } private sealed class SpatialRouteNode { public Vector3 Position; public readonly List Segments = new List(); public float Cost; public float Score; public float DistanceToGoal; public float RemainingStamina; public int Depth; } private readonly struct SpatialRouteStateKey : IEquatable { private readonly int _x; private readonly int _y; private readonly int _z; private readonly int _depth; private readonly int _stamina; public SpatialRouteStateKey(int x, int y, int z, int depth, int stamina) { _x = x; _y = y; _z = z; _depth = depth; _stamina = stamina; } public bool Equals(SpatialRouteStateKey other) { return _x == other._x && _y == other._y && _z == other._z && _depth == other._depth && _stamina == other._stamina; } public override bool Equals(object? obj) { return obj is SpatialRouteStateKey other && Equals(other); } public override int GetHashCode() { int x = _x; x = (x * 397) ^ _y; x = (x * 397) ^ _z; x = (x * 397) ^ _depth; return (x * 397) ^ _stamina; } } private const float ManualBiteAcquireRadius = 10f; private const float ManualBiteMinStamina = 0.05f; private const float CarryAssistAcquireRadius = 80f; private const float CarryAssistStartFlatDistance = 1.75f; private const float CarryAssistStartVerticalDistance = 2.25f; private const float CarryAssistRetargetInterval = 0.75f; private Character? _manualBiteTarget; private bool _manualBiteActive; private Character? _vanillaBiteTarget; private bool _vanillaBiteControlActive; private bool _carryAssistEnabled; private Character? _carryTarget; private float _nextCarryRetargetTime; private readonly List _failedSegments = new List(); public static readonly List All = new List(); private static readonly Dictionary AgentByZombieInstanceId = new Dictionary(); private static readonly Dictionary MissingAgentRetryByZombieInstanceId = new Dictionary(); private const float MissingZombieAgentRetrySeconds = 0.25f; private int _spawnOwnerActorNumber; private string _spawnOwnerUserId = string.Empty; private bool _rawGoalIsStandable; private const float ImmediateDirectClimbFlatDistance = 2.35f; private const float ImmediateDirectClimbVerticalSlack = 0.55f; private const float SmallObstacleHopCooldown = 0.12f; private const float SmallObstacleHopMinStamina = 0.16f; private const float HeavyActionLowStaminaThreshold = 0.08f; private const float SprintMinStamina = 0.12f; private const float FlatTravelHopVerticalTolerance = 0.45f; private const float FlatTravelHopMinDistance = 2f; private const float GoalExactStandFlatRadius = 1.05f; private const float GoalExactStandVerticalTolerance = 1.2f; private const float GoalStableStandSeconds = 1f; private const float GoalSettleFlatRadius = 1.55f; private const float GoalSettleVerticalTolerance = 1.25f; private const float GoalParkHysteresisFlat = 2.45f; private const float GoalParkHysteresisVertical = 2.25f; private const float GoalArrivalSettleFlatRadius = 2.05f; private const float GoalArrivalSettleVerticalTolerance = 1.6f; private const float RoughWalkableSlopeAngle = 68f; private const float RoughClimbTopSlopeAngle = 72f; private const float RoughSupportHeightTolerance = 1.05f; private const float ObstacleBypassJumpMinHeight = 0.28f; private const float ObstacleBypassJumpMaxHeight = 1.55f; private const float ObstacleBypassJumpMaxLandingDelta = 0.9f; private const float TerrainFallbackMaxRise = 2.15f; private const float TerrainFallbackMaxDrop = 6.5f; private const float TerrainFallbackMinProgress = -0.25f; public bool canBeCarriedAsRobot; public bool suppressRobotAI; public float zombieInteractionLock; public float lastRobotFedTime; private const float EdgeGoalSupportProbeRadius = 0.45f; private const float EdgeGoalSupportProbeHeight = 0.65f; private const float EdgeGoalSupportDropTolerance = 1.4f; private const float EdgeGoalResolvedReuseDistance = 0.9f; private const float EdgeGoalRawOffsetThreshold = 0.55f; private const float EdgeGoalArriveFlat = 1.85f; private const float EdgeGoalArriveVertical = 2.6f; private const float EdgeGoalNearPlanDistance = 2.2f; private PathPlan _lockedClimbPlan = new PathPlan(); private bool _hasLockedClimbPlan; private readonly Queue _segmentQueue = new Queue(); private PathPlan _activeSegment = new PathPlan(); private bool _hasActiveSegment; private float _routeWindowStartTime; private float _routeWindowStartGoalDistance; private Vector3 _segmentStartPos; private float _segmentStartTime; private float _segmentStartGoalDistance; private Vector3 _lastAcceptedGoalPoint = Vector3.zero; private bool _hadAcceptedGoalPoint; private float _nextReplanTime; private const float ImmediateJumpGrabMaxFlatDistance = 3.2f; private const float ImmediateJumpGrabMinHeightDelta = 1f; private const float ImmediateJumpGrabMaxHeightDelta = 4.8f; private const float ImmediateJumpGrabAnchorRadius = 1.6f; private const float SegmentMinProgressTime = 1.2f; private const float SegmentProgressTimeout = 3f; private const float SegmentMinGoalProgress = 1f; private const float SegmentArriveDistance = 1.25f; private const float SegmentArriveVertical = 1.75f; private const float RouteNetProgressWindow = 2.5f; private const float RouteNetProgressMin = 0.9f; private const float ReplanCooldown = 0.42f; private const int MaxPlannedSegments = 3; private const int GuidePlannerMaxDepth = 2; private const int GuidePlannerBeamWidth = 3; private const int GuidePlannerMaxCandidatesPerNode = 10; private const float GuidePlannerMinUsefulProgress = -1.75f; private const float GuidePlannerCloseEnoughFlat = 2.15f; private const float GuidePlannerCloseEnoughVertical = 2.35f; private const float GuidePlannerRepeatPenaltyDistance = 2.4f; private const float GuidePlannerMemoryLifetime = 5.5f; private const float GuidePlannerCacheLifetime = 1.1f; private const int GuidePlannerMaxCandidateCacheEntries = 128; private const int GuidePlannerMaxPathCacheEntries = 32; private const float GuidePlannerPositionCell = 1.4f; private const float GuidePlannerGoalCell = 1.25f; private const float GuidePlannerDpCell = 1.75f; private const float GuidePlannerDpScoreEpsilon = 0.08f; private const float VerticalDropFlatEpsilon = 0.35f; private const float LowerGoalThreshold = -1.25f; private const float DropSearchMaxAnchorDistance = 7f; private const float DropEdgeArrivalDistance = 1.15f; private const float DropLandingGoalWeight = 1.45f; private const float ClimbProbeMinStamina = 0.1f; private const float ActiveClimbExhaustedStaminaThreshold = 0.018f; private const float ClimbContinueMinStamina = 0.018f; private const float ClimbNearTopContinueMinStamina = 0.018f; private float _repositionUntil; private const float ClimbStartGraceTime = 0.45f; private const float RepositionMinDuration = 1.1f; private const float DirectBlockedPenaltyThreshold = 1.1f; private const float ClimbLastStaminaBurstThreshold = 0.18f; private MushroomZombie _zombie = null; private Character _character = null; private PhotonView _view = null; private RobotBrainState _brainState = RobotBrainState.Idle; private Character? _ownerCharacter; private Character? _target; private Vector3 _goalPoint; private bool _hasGoalPoint; private Vector3 _resolvedGoalPoint; private bool _hasResolvedGoalPoint; private bool _resolvedGoalIsStandable; private float _nextResolvedGoalRefreshTime; private Vector3 _lastResolvedRawGoal; private bool _hasLastResolvedRawGoal; private float _goalStableTimer; private bool _goalParked; private Vector3 _parkedGoalPoint; private int _goalInstructionSerial; private int _parkedGoalInstructionSerial; private int _lastAcceptedPingSequence; private bool _allowGoalParking; private float _nextTargetRefreshTime; private float _lastSeenTargetTime; private float _timeInChase; private float _timeInLunge; private float _stuckTimer; private Vector3 _stuckAnchor; private int _stuckCount; private float _climbTimer; private float _climbStartHeight; private int _failedClimbCount; private bool _activeClimbStartedAtRetryFullStamina; private bool _awaitingFullStaminaClimbRetry; private bool _fullStaminaClimbRetryConsumed; private Vector3 _fullStaminaClimbRetryAnchor; private int _fullStaminaClimbRetryGoalSerial; private float _lastAutoJumpTime; private PathPlan _plan = new PathPlan(); private readonly List _blockedMemory = new List(); private readonly List _recentRouteChoices = new List(); private readonly Dictionary _guideCandidateCache = new Dictionary(); private readonly Dictionary _guidePathCache = new Dictionary(); private static readonly Dictionary SharedGuidePathCache = new Dictionary(); private static readonly Dictionary SharedGroundProbeCache = new Dictionary(); private static readonly Dictionary SharedLineProbeCache = new Dictionary(); private static int SharedPlannerBudgetFrame = -1; private static int SharedPlannerBudgetUsed; private const int SharedMaxGuidedRoutePlansPerFrame = 1; private const int SharedGuidePlannerMaxPathCacheEntries = 128; private const int SharedMaxGroundProbeCacheEntries = 512; private const int SharedMaxLineProbeCacheEntries = 512; private const float SharedGuidePlannerPathCacheLifetime = 2.5f; private const float SharedPhysicsProbeCacheLifetime = 0.08f; private const float SharedPhysicsProbeCell = 0.55f; private bool _initialized; private float _nextPersistentRefreshTime; private State _lastVisualZombieState = (State)(-1); private bool _lastVisualBiteColliderEnabled; private bool _lastVisualSprintState; private bool _hasVisualStateSnapshot; private const float ProbeDistance = 2.2f; private const float GroundProbeHeight = 2.2f; private const float GroundProbeDepth = 16f; private const float ObstacleProbeRadius = 0.38f; private const float MaxSafeWalkDrop = 10f; private const float MaxSafeJumpDrop = 20f; private const float GapJumpNear = 1.8f; private const float GapJumpFar = 4.8f; private const float MaxClimbHeight = 4.2f; private const float TargetAboveThreshold = 1.4f; private const float OverheadSearchRadius = 3.5f; private const float TravelHopInterval = 0.2f; private const float ChainJumpStaminaThreshold = 0.35f; private const float StickyClimbMinTime = 0.8f; private const float StickyClimbTopReleaseFlat = 1.8f; private const float StickyClimbTopReleaseVertical = -1f; private const float TallWallHeightThreshold = 2.15f; private const float SmallWallFastClimbThreshold = 1.2f; private const float ClimbBurstStartProgress = 0.55f; private const float ClimbBurstMinStamina = 0.12f; private const float ClosePressureFlat = 1.65f; private const float ClosePressureVertical = 1.15f; private const float CloseStopFlat = 0.55f; private const float JumpGrabMinVertical = 1f; private const float JumpGrabMaxVertical = 4.6f; private const float JumpGrabPressInterval = 0.2f; private const float JumpGrabMinStamina = 0.18f; private const float ClimbTraverseStrongX = 0.95f; private const float ClimbTraverseWeakX = 0.6f; private const float ClimbDiagonalUp = 0.95f; private const float ClimbVerticalUp = 1f; private const float ClimbBurstSprintXBoost = 1.15f; private const float ClimbBurstSprintYBoost = 1.12f; private const float ClimbTopAssistDistance = 1.25f; private const float GoalArriveFlatDistance = 1.35f; private const float GoalArriveVerticalDistance = 2.25f; private const float ClimbWaitAnchorDistance = 1.35f; private const float ClimbResumeHysteresis = 0.02f; private const float FullStaminaRetryReadyEpsilon = 0.02f; private const float FullStaminaRetrySameSiteDistance = 2.75f; private const float GoalStandSearchRadius = 1.2f; private const float GoalStandPreferRadius = 0.95f; private const float NonStandableGoalAccessSearchRadius = 5.2f; private const float NonStandableGoalAccessProbeHeight = 7f; private const float NonStandableGoalAccessProbeDepth = 13.5f; private const float ResolvedGoalRefreshInterval = 1.5f; private const float SmallObstacleHeightMax = 1.1f; private const float SmallObstacleForwardCheck = 1f; private static readonly float[] SearchAngles = new float[11] { 0f, 20f, -20f, 40f, -40f, 60f, -60f, 90f, -90f, 120f, -120f }; private static readonly float[] OverheadAngles = new float[14] { 0f, 20f, -20f, 40f, -40f, 60f, -60f, 90f, -90f, 120f, -120f, 150f, -150f, 180f }; private static readonly float[] GuideSearchAngles = new float[7] { 0f, 25f, -25f, 55f, -55f, 90f, -90f }; private static readonly float[] GuideSearchDistances = new float[2] { 2f, 4.2f }; private static readonly float[] TerrainFallbackDistances = new float[5] { 1.4f, 2.4f, 3.8f, 5.6f, 7.5f }; private static readonly float[] LateralTraverseSamples = new float[4] { 0.7f, 1.1f, 1.5f, 2f }; private static readonly int TerrainMask = LayerMask.GetMask(new string[2] { "Terrain", "Map" }); private static readonly MethodInfo? PushStateMethod = AccessTools.Method(typeof(MushroomZombie), "PushState", (Type[])null, (Type[])null); private static readonly FieldInfo? ZombieTimeSpentChasingField = AccessTools.Field(typeof(MushroomZombie), "timeSpentChasing"); private static readonly FieldInfo? ZombieCurrentTargetField = AccessTools.Field(typeof(MushroomZombie), "_currentTarget"); private static readonly FieldInfo? ZombieTargetForcedUntilField = AccessTools.Field(typeof(MushroomZombie), "targetForcedUntil"); private RobotBrainState _lastLoggedBrainState = (RobotBrainState)(-1); private const int SpatialPlannerMaxDepth = 4; private const int SpatialPlannerBeamWidth = 8; private const int SpatialPlannerMaxCandidatesPerNode = 18; private const float SpatialPlannerCacheLifetime = 2.2f; private const float SpatialPlannerCell = 1.65f; private const float SpatialPlannerCloseFlat = 2.05f; private const float SpatialPlannerCloseVertical = 1.65f; private const float SpatialWalkStepMaxRise = 0.78f; private const float SpatialWalkStepMaxDrop = 1.05f; private const float SpatialRampTotalRiseLimit = 2.25f; private const float SpatialRampTotalDropLimit = 3.25f; private const float SpatialCandidateMaxRise = 5.25f; private const float SpatialCandidateMaxDrop = 9.5f; private const float SpatialMinUseful3DProgress = -1.25f; private static readonly float[] SpatialAngles = new float[12] { 0f, 20f, -20f, 45f, -45f, 70f, -70f, 105f, -105f, 145f, -145f, 180f }; private static readonly float[] SpatialDistances = new float[5] { 1.25f, 2.35f, 3.75f, 5.6f, 7.75f }; private static readonly float[] SpatialVerticalProbeOffsets = new float[4] { 2.4f, 4.4f, 6.8f, 9.2f }; public Character? Character => _character; public PhotonView? View => _view; public int SpawnOwnerActorNumber => _spawnOwnerActorNumber; public bool IsOwnedByLocalPlayer { get { if (!_initialized || (Object)(object)_view == (Object)null) { return false; } if (_view.IsMine) { return true; } return IsSpawnedByLocalPlayer; } } public bool IsSpawnedByLocalPlayer => PhotonNetwork.LocalPlayer != null && _spawnOwnerActorNumber > 0 && PhotonNetwork.LocalPlayer.ActorNumber == _spawnOwnerActorNumber; private bool TryBuildJumpGrabPlanFrom(Vector3 startPos, Vector3 toTargetDir, bool targetAbove, out PathPlan plan) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0174: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!HasActiveGoal()) { return false; } Vector3 goalCenter = GetGoalCenter(); float num = HelperFunctions.FlatDistance(startPos, goalCenter); float num2 = goalCenter.y - startPos.y; if (num2 < 0.45f && num < 2.2f) { return false; } float[] array = new float[11] { 0f, 15f, -15f, 30f, -30f, 45f, -45f, 60f, -60f, 90f, -90f }; float[] array2 = new float[5] { 0.55f, 0.85f, 1.2f, 1.6f, 2f }; float[] array3 = new float[7] { 1.25f, 1.65f, 2.2f, 2.8f, 3.4f, 4f, 4.6f }; bool flag = false; float num3 = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); RaycastHit val2 = default(RaycastHit); RaycastHit val5 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { Vector3 val = Quaternion.AngleAxis(array[i], Vector3.up) * toTargetDir; foreach (float num4 in array2) { Vector3 point = startPos + val * num4; if (!TryFindGround(point, out var hit)) { continue; } float num5 = Mathf.Abs(((RaycastHit)(ref hit)).point.y - startPos.y); if (num5 > 1.15f) { continue; } foreach (float num6 in array3) { if (num6 < num4 + 0.25f || !Physics.SphereCast(startPos + Vector3.up * 1.15f, 0.2f, val, ref val2, num6, TerrainMask, (QueryTriggerInteraction)1)) { continue; } Vector3 val3 = startPos + val * num6; Vector3 val4 = val3 + Vector3.up * 5.8f; if (!Physics.Raycast(val4, Vector3.down, ref val5, 6.8f, TerrainMask, (QueryTriggerInteraction)1)) { continue; } float num7 = ((RaycastHit)(ref val5)).point.y - startPos.y; if (num7 < 0.75f || num7 > 4.6f || !IsRoughClimbTopNormal(((RaycastHit)(ref val5)).normal)) { continue; } Vector3 point2 = startPos + val * Mathf.Lerp(num4, num6, 0.35f); Vector3 point3 = startPos + val * Mathf.Lerp(num4, num6, 0.6f); bool flag2 = false; if (!TryFindGround(point2, out var hit2)) { flag2 = true; } else { float num8 = startPos.y - ((RaycastHit)(ref hit2)).point.y; if (num8 > 10f) { flag2 = true; } } if (!flag2) { if (!TryFindGround(point3, out var hit3)) { flag2 = true; } else { float num9 = startPos.y - ((RaycastHit)(ref hit3)).point.y; if (num9 > 10f) { flag2 = true; } } } float num10 = HelperFunctions.FlatDistance(((RaycastHit)(ref val5)).point, goalCenter); float num11 = HelperFunctions.FlatDistance(startPos, goalCenter) - num10; float num12 = Mathf.Abs(((RaycastHit)(ref val5)).point.y - goalCenter.y); bool flag3 = num10 <= 1.45f && num12 <= 1.9f; if ((flag3 || !(num11 < 0.55f)) && (flag2 || targetAbove || flag3)) { PathPlan obj = new PathPlan { Action = PathActionType.JumpGrab, Anchor = ((RaycastHit)(ref hit)).point, Goal = goalCenter + Vector3.up * 0.15f, JumpGrabAimPoint = ((RaycastHit)(ref val2)).point + Vector3.up * 0.25f, JumpGrabHorizontalDistance = num6, TargetAbove = true, EstimatedClimbHeight = num7, IsTallWall = (num7 >= 2.15f), RequiredStamina = EstimateRequiredClimbStamina(num7, targetAbove: true, num7 >= 2.15f), ReachableWithinRecoverableBudget = (EstimateRequiredClimbStamina(num7, targetAbove: true, num7 >= 2.15f) <= GetRecoverableStaminaCeiling()), NeedsJumpStart = true, ProjectedEndPoint = ((RaycastHit)(ref val5)).point, HasProjectedEndPoint = true, ClimbTopPoint = ((RaycastHit)(ref val5)).point }; Vector3 normal = ((RaycastHit)(ref val2)).normal; Vector3 climbSurfaceNormal; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.01f)) { climbSurfaceNormal = -val; } else { normal = ((RaycastHit)(ref val2)).normal; climbSurfaceNormal = ((Vector3)(ref normal)).normalized; } obj.ClimbSurfaceNormal = climbSurfaceNormal; PathPlan pathPlan2 = obj; float num13 = (pathPlan2.Score = num11 * 2.4f + (flag3 ? 3.2f : 0f) + (flag2 ? 1.2f : 0f) - Mathf.Abs(array[i]) * 0.025f - num6 * 0.06f - GetBlockedPenalty(((RaycastHit)(ref hit)).point) - GetFailedSegmentPenalty(pathPlan2)); if (!flag || num13 > num3) { flag = true; num3 = num13; pathPlan = pathPlan2; } } } } } if (flag) { plan = pathPlan; return true; } return false; } private bool IsNearClimbAnchor(PathPlan plan) { //IL_001a: 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) if (!IsClimbPlan(plan)) { return false; } return Vector3.Distance(_character.Center, plan.Anchor) <= 1.35f; } public void Tick() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Invalid comparison between Unknown and I4 if (!_initialized || (Object)(object)_zombie == (Object)null || (Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null || (Object)(object)_view == (Object)null) { return; } UpdateInteractionState(); if (!_view.IsMine) { TickRemoteVisualOnly(); return; } KeepRobotPersistent(); if (_brainState == RobotBrainState.Dead || (int)_zombie.currentState == 6) { _brainState = RobotBrainState.Dead; _zombie.currentState = (State)6; return; } if (suppressRobotAI) { TickSuppressedByInteraction(); SyncVisualState(); return; } ResetInput(); UpdateCommandStateBeforePlanning(); if (!ShouldHoldCommandTarget()) { RefreshTargetIfNeeded(); } RefreshResolvedGoalIfNeeded(); ValidateTarget(); DecayBlockedMemory(); UpdateStuckDetection(); UpdateClimbFailureDetection(); if (TryUpdateGoalParkingAndMaybeHold()) { LogBrainStateIfChanged(); SyncVisualState(); return; } if (!HasActiveGoal()) { _brainState = RobotBrainState.Idle; } else if (!IsFollowingRoute() && HasArrivedAtGoal()) { _brainState = RobotBrainState.Idle; } switch (_brainState) { case RobotBrainState.Idle: TickIdle(); break; case RobotBrainState.Parked: TickParkedAtGoal(); break; case RobotBrainState.Chase: TickChase(); break; case RobotBrainState.PrepareTallClimb: TickPrepareTallClimb(); break; case RobotBrainState.Reposition: TickReposition(); break; case RobotBrainState.Lunge: TickLunge(); break; case RobotBrainState.LungeRecovery: TickLungeRecovery(); break; case RobotBrainState.Dead: _zombie.currentState = (State)6; break; } LogBrainStateIfChanged(); SyncVisualState(); } private void TickRemoteVisualOnly() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 UpdateInteractionState(); if (suppressRobotAI) { _zombie.currentState = (State)2; _character.data.passedOut = false; } if ((int)_zombie.currentState == 6 || (int)_zombie.currentState == 0) { _character.data.passedOut = true; } _zombie.SetBiteColliderProxy((int)_zombie.currentState == 4); _zombie.UpdateMouthProxy(); } private void KeepRobotPersistent() { if (Time.time >= _nextPersistentRefreshTime) { _nextPersistentRefreshTime = Time.time + 1f; _zombie.isNPCZombie = false; _zombie.spawner = null; _zombie.lifetime = 999999f; if ((Object)(object)ZombieManager.Instance != (Object)null) { ZombieManager.Instance.DeRegisterZombie(_zombie); } } if ((Object)(object)_character != (Object)null) { _character.isZombie = true; _character.isBot = true; _character.data.dead = false; _character.data.passedOut = false; _character.data.fullyPassedOut = false; } } private void TickIdle() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) _zombie.currentState = (State)2; _character.data.passedOut = false; SetSprint(sprinting: false); if (HasActiveGoal()) { if (HasArrivedAtGoal()) { _character.input.movementInput = Vector2.zero; LookAt(GetGoalLookPoint()); } else { LookAt(GetCurrentDrivePoint()); _brainState = RobotBrainState.Chase; _timeInChase = 0f; } } } private void TickChase() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { ClearLockedClimbPlan(); _segmentQueue.Clear(); ClearActiveSegment(); _brainState = RobotBrainState.Idle; _zombie.currentState = (State)2; return; } _zombie.currentState = (State)3; _character.data.passedOut = false; _timeInChase += Time.deltaTime; if (CanSeeGoal()) { _lastSeenTargetTime = Time.time; } if (!IsFollowingRoute() && HasArrivedAtGoal()) { _zombie.currentState = (State)2; _character.data.passedOut = false; SetSprint(sprinting: false); _character.input.movementInput = Vector2.zero; if (_resolvedGoalIsStandable && _character.data.isClimbing) { StopClimb(); } ClearLockedClimbPlan(); _brainState = RobotBrainState.Idle; return; } if (_character.data.isClimbing) { if (!_hasLockedClimbPlan) { if (_hasActiveSegment && IsClimbPlan(_activeSegment)) { LockCurrentClimbPlan(_activeSegment); } else if (IsClimbPlan(_plan)) { LockCurrentClimbPlan(_plan); } } TickActiveClimb(); return; } if (!_hasActiveSegment && _segmentQueue.Count == 0) { ReplanRoute(); } AdvanceSegmentIfNeeded(); if (!_hasActiveSegment && _segmentQueue.Count == 0) { ReplanRoute(); } if (_hasActiveSegment) { ExecuteActiveSegment(); return; } ClearLockedClimbPlan(); PathPlan pathPlan = (_plan = BuildPathPlanFrom(_character.Center)); if (IsClimbPlan(pathPlan) && !HasEnoughStaminaToStartClimb(pathPlan)) { if (!IsNearClimbAnchor(pathPlan)) { LookAt(pathPlan.Anchor); WalkTowards(pathPlan.Anchor, 0.8f, tryClimb: false, tryJump: false, sprintRequested: false); } else { EnterPrepareTallClimb(); } } else if (_stuckCount >= 2 || _failedClimbCount >= 3) { RegisterBlockedPoint(_character.Center, 3.2f); EnterReposition(); } else { ExecuteGroundPlan(pathPlan); } } private void TickPrepareTallClimb() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) _zombie.currentState = (State)2; _character.data.passedOut = false; SetSprint(sprinting: false); if (!HasActiveGoal()) { _brainState = RobotBrainState.Idle; return; } PathPlan pathPlan = (_plan = BuildPathPlanFrom(_character.Center)); if (!IsClimbPlan(pathPlan)) { _brainState = RobotBrainState.Chase; return; } float num = Vector3.Distance(_character.Center, pathPlan.Anchor); bool flag = IsWaitingForFullStaminaClimbRetry(pathPlan); bool flag2 = (flag ? HasRecoveredFullStaminaForRetry() : HasEnoughStaminaToResumeClimb(pathPlan)); bool flag3 = num <= 1.35f; LookAt(flag3 ? pathPlan.Goal : pathPlan.Anchor); if (!flag3) { WalkTowards(pathPlan.Anchor, 0.7f, tryClimb: false, tryJump: false, sprintRequested: false); return; } if (!flag2) { _character.input.movementInput = Vector2.zero; SetSprint(sprinting: false); return; } if (flag) { MarkFullStaminaClimbRetryAttemptStarted(pathPlan); } WalkTowards(pathPlan.Goal, 0.95f, tryClimb: true, tryJump: false, sprintRequested: false); TryForceJumpGrab(pathPlan, closeToAnchor: true); _brainState = RobotBrainState.Chase; } private void TickReposition() { //IL_0040: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0133: Unknown result type (might be due to invalid IL or missing references) _zombie.currentState = (State)2; _character.data.passedOut = false; if (!HasActiveGoal()) { _brainState = RobotBrainState.Idle; return; } PathPlan pathPlan = (_plan = BuildPathPlanFrom(_character.Center)); bool flag = Time.time < _repositionUntil; if (pathPlan.Action == PathActionType.Detour) { LookAt(pathPlan.Goal); WalkTowards(pathPlan.Goal, 1f, tryClimb: false, tryJump: false, sprintRequested: false); TryTravelHop(); if (!flag && Vector3.Distance(_character.Center, pathPlan.Goal) < 1.2f) { _stuckCount = 0; _failedClimbCount = 0; _brainState = RobotBrainState.Chase; } } else if (!flag && (pathPlan.Action == PathActionType.Direct || IsClimbPlan(pathPlan) || pathPlan.Action == PathActionType.GapJump || pathPlan.Action == PathActionType.DropDown)) { _stuckCount = 0; _failedClimbCount = 0; _brainState = RobotBrainState.Chase; } else { LookAt(GetCurrentMoveTarget()); WalkTowards(GetGoalLookPoint(), 0.7f, tryClimb: false, tryJump: false, sprintRequested: false); } } private void TickLunge() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) _zombie.currentState = (State)4; _character.data.passedOut = false; _timeInLunge += Time.deltaTime; if (_manualBiteActive && IsValidManualBiteTarget(_manualBiteTarget)) { SetCommandGoal(_manualBiteTarget, _manualBiteTarget.Head); } if (HasActiveGoal()) { Vector3 targetPos = _character.Center + (GetGoalLookPoint() - _character.Center) * 100f; WalkTowards(targetPos, 1.2f, tryClimb: false, tryJump: false, sprintRequested: true); } if (_timeInLunge >= _zombie.lungeTime || _character.OutOfStamina()) { _timeInLunge = 0f; ClearManualBite(); _brainState = RobotBrainState.LungeRecovery; _zombie.currentState = (State)5; _character.Fall(3f, 0f); ForcePushState(); } } private void TickLungeRecovery() { _zombie.currentState = (State)5; _character.data.passedOut = false; if (!(_character.data.fallSeconds > 0f) && !_character.data.passedOut && !_character.data.fullyPassedOut) { _timeInLunge += Time.deltaTime; if (_timeInLunge >= _zombie.lungeRecoveryTime) { _timeInLunge = 0f; _brainState = (HasActiveGoal() ? RobotBrainState.Chase : RobotBrainState.Idle); } } } private void TickActiveClimb() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: 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_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { StopClimb(); ClearLockedClimbPlan(); _brainState = RobotBrainState.Idle; return; } PathPlan activeClimbPlan = GetActiveClimbPlan(); if (IsExhaustedForActiveClimb()) { TryArmFullStaminaClimbRetry(activeClimbPlan); StopClimb(); ClearLockedClimbPlan(); SetSprint(sprinting: false); _character.input.movementInput = Vector2.zero; EnterPrepareTallClimb(); return; } if (_climbTimer > 0.45f && !CanContinueClimb(activeClimbPlan)) { StopClimb(); if (activeClimbPlan.Action == PathActionType.Climb || activeClimbPlan.Action == PathActionType.JumpGrab) { EnterPrepareTallClimb(); return; } RegisterBlockedPoint(_character.Center, 2.6f); EnterReposition(); return; } if (_resolvedGoalIsStandable) { float num = HelperFunctions.FlatDistance(_character.Center, _resolvedGoalPoint); float num2 = _resolvedGoalPoint.y - _character.Center.y; if (_climbTimer > 0.8f && num <= 1.4f && num2 <= 0.9f) { StopClimb(); ClearLockedClimbPlan(); LookAt(_resolvedGoalPoint); _character.input.movementInput = new Vector2(0f, 1f); SetSprint(sprinting: false); return; } } Vector3 val = ((activeClimbPlan.ClimbTopPoint != Vector3.zero) ? activeClimbPlan.ClimbTopPoint : GetGoalLookPoint()); Vector2 val2 = ComputeStrategicClimbInput(val, activeClimbPlan); float num3 = Mathf.Max(activeClimbPlan.EstimatedClimbHeight, 0.1f); float num4 = Mathf.Clamp01((_character.Center.y - _climbStartHeight) / num3); float stamina = GetStamina01(); bool flag = activeClimbPlan.ClimbTopPoint != Vector3.zero && Vector3.Distance(_character.Center, activeClimbPlan.ClimbTopPoint) < 1.25f; if (ShouldAbortClimbForStamina(activeClimbPlan, stamina, flag, num4)) { StopClimb(); if (TryArmFullStaminaClimbRetry(activeClimbPlan)) { ClearLockedClimbPlan(); EnterPrepareTallClimb(); return; } RegisterFailedSegment(activeClimbPlan); RegisterBlockedPoint(_character.Center, 3f); ClearLockedClimbPlan(); EnterReposition(); return; } bool flag2 = stamina <= 0.18f && stamina >= 0.12f && num4 >= 0.35f; bool flag3 = flag || num4 >= 0.55f; bool flag4 = (activeClimbPlan.Action == PathActionType.Climb || activeClimbPlan.Action == PathActionType.JumpGrab) && (flag3 || flag2) && stamina >= 0.12f; LookAt(val); SetSprint(sprinting: false); _character.input.movementInput = val2; if (flag4) { _character.input.sprintIsPressed = true; _character.input.movementInput = new Vector2(Mathf.Clamp(val2.x * 1.15f, -1f, 1f), Mathf.Clamp(val2.y * 1.12f, 0.82f, 1f)); } if (GetGoalCenter().y < _character.Center.y) { bool flag5 = !IsRoughTerrainLineBlocked(_character.Center, GetGoalCenter()); float num5 = HelperFunctions.FlatDistance(_character.Center, GetGoalCenter()); bool flag6 = _climbTimer > 0.8f; if (flag5 && flag6 && num5 < 1.8f && GetGoalCenter().y - _character.Center.y < -1f) { StopClimb(); ClearLockedClimbPlan(); SetSprint(sprinting: false); } } } public bool RequestManualBite(Character? preferredTarget, out string message) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Invalid comparison between Unknown and I4 message = string.Empty; if (!_initialized || (Object)(object)_character == (Object)null || (Object)(object)_zombie == (Object)null || (Object)(object)_view == (Object)null) { message = "Controlled robot is not ready."; return false; } if (!_view.IsMine) { message = "Nearest controlled robot is not owned by this client, so it cannot be commanded to bite."; return false; } if (_vanillaBiteControlActive) { DisableVanillaBiteControl(); message = "Controlled robot returned to ping-driven AI control."; return true; } if ((Object)(object)_character.data == (Object)null || _character.data.dead || (int)_zombie.currentState == 6) { message = "Controlled robot is dead."; return false; } if (_character.data.isCarried || (Object)(object)_character.data.carrier != (Object)null || (Object)(object)_character.data.grabbingPlayer != (Object)null) { message = "Controlled robot cannot bite while it is being carried or grabbed."; return false; } if ((Object)(object)_character.data.carriedPlayer != (Object)null) { message = "Controlled robot is carrying a player. Drop the player before biting."; return false; } Character val = null; if (IsValidManualBiteTarget(preferredTarget)) { val = preferredTarget; } if (val == null) { val = FindNearestManualBiteTarget(); } if ((Object)(object)val == (Object)null) { message = "No valid player found for vanilla zombie bite control."; return false; } EnableVanillaBiteControl(val); message = "Controlled robot is now using the original zombie chase/bite AI against " + val.characterName + ". Press B again to restore ping-driven control."; return true; } public bool ShouldUseVanillaBiteControl(MushroomZombie zombie) { if (!_vanillaBiteControlActive) { return false; } if (!_initialized || (Object)(object)zombie != (Object)(object)_zombie || (Object)(object)_character == (Object)null || (Object)(object)_zombie == (Object)null) { _vanillaBiteControlActive = false; return false; } if (!_view.IsMine) { return true; } if (!IsValidManualBiteTarget(_vanillaBiteTarget)) { DisableVanillaBiteControl(); return false; } PrepareOriginalZombieBiteTick(_vanillaBiteTarget); return true; } private void EnableVanillaBiteControl(Character target) { _vanillaBiteTarget = target; _vanillaBiteControlActive = true; _manualBiteActive = false; _manualBiteTarget = null; _carryAssistEnabled = false; _carryTarget = null; StopClimb(); ClearGoalParking(); ClearLockedClimbPlan(); _segmentQueue.Clear(); ClearActiveSegment(); ClearGuidePlannerCaches(); ResetInput(); PrepareOriginalZombieBiteTick(target); ForcePushState(); } private void DisableVanillaBiteControl() { _vanillaBiteControlActive = false; _vanillaBiteTarget = null; _manualBiteActive = false; _manualBiteTarget = null; ResetInput(); SetSprint(sprinting: false); ClearLockedClimbPlan(); ClearActiveSegment(); _segmentQueue.Clear(); ClearGuidePlannerCaches(); try { ZombieTargetForcedUntilField?.SetValue(_zombie, 0f); ZombieCurrentTargetField?.SetValue(_zombie, null); } catch { _zombie.currentTarget = null; } _brainState = (HasActiveGoal() ? RobotBrainState.Chase : RobotBrainState.Idle); _zombie.currentState = (State)((_brainState == RobotBrainState.Chase) ? 3 : 2); _nextReplanTime = 0f; ForcePushState(); } private void PrepareOriginalZombieBiteTick(Character target) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Invalid comparison between Unknown and I4 if ((Object)(object)_character.data == (Object)null) { return; } _character.isZombie = true; _character.isBot = true; _character.data.dead = false; _character.data.passedOut = false; _character.data.fullyPassedOut = false; _zombie.isNPCZombie = false; _zombie.spawner = null; _zombie.lifetime = 999999f; try { ZombieTargetForcedUntilField?.SetValue(_zombie, 0f); ZombieCurrentTargetField?.SetValue(_zombie, target); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"PrepareOriginalZombieBiteTick target set failed: {arg}"); _zombie.currentTarget = target; } if ((int)_zombie.currentState != 4 && (int)_zombie.currentState != 5 && (int)_zombie.currentState != 6) { _zombie.currentState = (State)3; } try { float num = Mathf.Max(_zombie.chaseTimeBeforeSprint + 0.25f, 0.25f); ZombieTimeSpentChasingField?.SetValue(_zombie, num); } catch (Exception arg2) { Plugin.Log.LogDebug((object)$"PrepareOriginalZombieBiteTick timeSpentChasing failed: {arg2}"); } } public bool ToggleCarryAssist(out string message) { //IL_0162: 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) message = string.Empty; if (!_initialized || (Object)(object)_character == (Object)null || (Object)(object)_view == (Object)null) { message = "Controlled robot is not ready."; return false; } if (!_view.IsMine) { message = "Nearest controlled robot is not owned by this client, so it cannot be commanded to carry players."; return false; } if ((Object)(object)_character.data == (Object)null || _character.data.dead) { message = "Controlled robot is dead."; return false; } if ((Object)(object)_character.data.carriedPlayer != (Object)null) { Character carriedPlayer = _character.data.carriedPlayer; DropCarriedPlayer(carriedPlayer); DisableCarryAssist(); message = "Controlled robot dropped " + carriedPlayer.characterName + " and disabled carry-assist."; return true; } if (_carryAssistEnabled) { DisableCarryAssist(); message = "Controlled robot carry-assist disabled."; return true; } Character val = FindNearestCarryCandidate(80f); if ((Object)(object)val == (Object)null) { message = "No living player found for carry-assist."; return false; } _carryAssistEnabled = true; _carryTarget = val; _nextCarryRetargetTime = Time.time + 0.75f; ResetRouteForNewGoal(val.Center); SetCommandGoal(val, val.Center); _brainState = RobotBrainState.Chase; message = "Controlled robot carry-assist enabled for " + val.characterName + "."; return true; } public void NotifyStartedCarryingPlayer(Character target) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return; } _carryAssistEnabled = false; _carryTarget = null; _nextCarryRetargetTime = 0f; _stuckCount = 0; _failedClimbCount = 0; ClearActiveSegment(); _segmentQueue.Clear(); ClearLockedClimbPlan(); ResetRouteProgressWindow(); if (PingTargetTracker.TryGetBestPingDataForRobot(_character, _spawnOwnerActorNumber, _character.Center, out var data)) { SetCommandGoal(data.OwnerCharacter, data.Point, allowGoalParking: true, data.Sequence); _lastAcceptedPingSequence = data.Sequence; _brainState = RobotBrainState.Chase; } else { _ownerCharacter = null; _target = null; _goalPoint = Vector3.zero; _hasGoalPoint = false; _hasResolvedGoalPoint = false; _zombie.currentTarget = null; _brainState = RobotBrainState.Idle; } try { _character.refs.afflictions.UpdateWeight(); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"NotifyStartedCarryingPlayer UpdateWeight failed: {arg}"); } } public void NotifyStoppedCarryingPlayer(Character target) { if ((Object)(object)target == (Object)null) { return; } if ((Object)(object)_carryTarget == (Object)(object)target) { DisableCarryAssist(); } try { _character.refs.afflictions.UpdateWeight(); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"NotifyStoppedCarryingPlayer UpdateWeight failed: {arg}"); } } private bool ShouldHoldCommandTarget() { if (_manualBiteActive || _brainState == RobotBrainState.Lunge || _brainState == RobotBrainState.LungeRecovery) { return true; } return _carryAssistEnabled && (Object)(object)_carryTarget != (Object)null && (Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer == (Object)null; } private void UpdateCommandStateBeforePlanning() { UpdateManualBiteGoal(); UpdateCarryAssistGoal(); } private void UpdateManualBiteGoal() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_manualBiteActive) { if (!IsValidManualBiteTarget(_manualBiteTarget)) { ClearManualBite(); return; } Vector3 head = _manualBiteTarget.Head; SetCommandGoal(_manualBiteTarget, head); } } private void StartManualBite(Character target) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) _manualBiteTarget = target; _manualBiteActive = true; _timeInLunge = 0f; StopClimb(); ClearLockedClimbPlan(); _segmentQueue.Clear(); ClearActiveSegment(); SetCommandGoal(target, target.Head); LookAt(target.Head); _character.input.jumpWasPressed = true; _brainState = RobotBrainState.Lunge; _zombie.currentState = (State)4; ForcePushState(); } private void ClearManualBite() { _manualBiteTarget = null; _manualBiteActive = false; } private Character? FindNearestManualBiteTarget() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = 100f; foreach (Character allCharacter in Character.AllCharacters) { if (IsValidManualBiteTarget(allCharacter)) { Vector3 val = allCharacter.Center - _character.Center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; result = allCharacter; } } } return result; } private bool IsManualBiteTargetInRange(Character target) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return false; } float num = Mathf.Min(10f, Mathf.Max(3.5f, _zombie.zombieLungeDistance)); Vector3 val = target.Center - _character.Center; if (((Vector3)(ref val)).sqrMagnitude > num * num) { return false; } RaycastHit val2 = HelperFunctions.LineCheck(_character.Head, target.Center, (LayerType)1, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref val2)).transform == (Object)null; } private bool IsValidManualBiteTarget(Character? candidate) { if ((Object)(object)candidate == (Object)null || (Object)(object)candidate.data == (Object)null || (Object)(object)candidate == (Object)(object)_character) { return false; } if ((Object)(object)RobotInteractionUtil.GetAgent(candidate) != (Object)null) { return false; } if (candidate.isBot || candidate.data.dead || candidate.data.fullyPassedOut) { return false; } if (candidate.data.isCarried || (Object)(object)candidate.data.carrier != (Object)null) { return false; } return true; } private void UpdateCarryAssistGoal() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!_carryAssistEnabled) { return; } if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { DisableCarryAssist(); return; } if ((Object)(object)_character.data.carriedPlayer != (Object)null) { _carryAssistEnabled = false; _carryTarget = null; return; } if ((Object)(object)_carryTarget == (Object)null || !IsValidCarryCandidate(_carryTarget)) { if (Time.time < _nextCarryRetargetTime) { return; } _carryTarget = FindNearestCarryCandidate(80f); _nextCarryRetargetTime = Time.time + 0.75f; if ((Object)(object)_carryTarget == (Object)null) { DisableCarryAssist(); return; } ResetRouteForNewGoal(_carryTarget.Center); } Vector3 center = _carryTarget.Center; SetCommandGoal(_carryTarget, center); _brainState = RobotBrainState.Chase; if (CanStartCarrying(_carryTarget)) { StartCarryingTarget(_carryTarget); } } private Character? FindNearestCarryCandidate(float radius) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = radius * radius; foreach (Character allCharacter in Character.AllCharacters) { if (IsValidCarryCandidate(allCharacter)) { Vector3 val = allCharacter.Center - _character.Center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; result = allCharacter; } } } return result; } private bool IsValidCarryCandidate(Character? candidate) { if ((Object)(object)candidate == (Object)null || (Object)(object)candidate.data == (Object)null || (Object)(object)candidate == (Object)(object)_character) { return false; } if ((Object)(object)RobotInteractionUtil.GetAgent(candidate) != (Object)null) { return false; } if (candidate.isBot || candidate.data.dead) { return false; } if ((Object)(object)candidate.data.carrier != (Object)null || candidate.data.isCarried) { return false; } return true; } private bool CanStartCarrying(Character target) { //IL_0037: 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_0049: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null || (Object)(object)target.data == (Object)null || !IsValidCarryCandidate(target)) { return false; } float num = HelperFunctions.FlatDistance(_character.Center, target.Center); float num2 = Mathf.Abs(target.Center.y - _character.Center.y); if (num > 1.75f || num2 > 2.25f) { return false; } RaycastHit val = HelperFunctions.LineCheck(_character.Head, target.Center, (LayerType)1, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref val)).transform == (Object)null; } private void StartCarryingTarget(Character target) { if ((Object)(object)target == (Object)null || (Object)(object)((MonoBehaviourPun)target).photonView == (Object)null) { return; } StopClimb(); ResetInput(); SetSprint(sprinting: false); try { ((MonoBehaviourPun)_character).photonView.RPC("RPCA_StartCarry", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)target).photonView }); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"StartCarryingTarget failed: {arg}"); } } private void DropCarriedPlayer(Character target) { try { if (!((Object)(object)target == (Object)null) && !((Object)(object)((MonoBehaviourPun)target).photonView == (Object)null) && !((Object)(object)_character == (Object)null) && !((Object)(object)((MonoBehaviourPun)_character).photonView == (Object)null)) { ((MonoBehaviourPun)_character).photonView.RPC("RPCA_Drop", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)target).photonView }); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"DropCarriedPlayer failed: {arg}"); } } private void DisableCarryAssist() { _carryAssistEnabled = false; _carryTarget = null; _nextCarryRetargetTime = 0f; } private bool IsCarryAssistTarget(Character? target) { return _carryAssistEnabled && (Object)(object)target != (Object)null && (Object)(object)target == (Object)(object)_carryTarget; } private void SetCommandGoal(Character target, Vector3 point, bool allowGoalParking = false, int instructionSerial = 0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) bool flag = HasGoalPointChanged(point) || (instructionSerial > 0 && instructionSerial != _goalInstructionSerial); _ownerCharacter = target; _target = target; _goalPoint = point; _hasGoalPoint = true; _allowGoalParking = allowGoalParking; _zombie.currentTarget = target; if (flag) { ResetRouteForNewGoal(point, instructionSerial, allowGoalParking); } } public static bool TryGetForZombie(MushroomZombie? zombie, out NetworkRobotAgent? agent) { agent = null; if ((Object)(object)zombie == (Object)null) { return false; } int instanceID = ((Object)zombie).GetInstanceID(); if (AgentByZombieInstanceId.TryGetValue(instanceID, out NetworkRobotAgent value)) { if ((Object)(object)value != (Object)null && value._initialized && (Object)(object)value._zombie == (Object)(object)zombie) { agent = value; return true; } AgentByZombieInstanceId.Remove(instanceID); } float unscaledTime = Time.unscaledTime; if (MissingAgentRetryByZombieInstanceId.TryGetValue(instanceID, out var value2) && unscaledTime < value2) { return false; } try { agent = ((Component)zombie).GetComponent(); } catch { agent = null; } if ((Object)(object)agent != (Object)null) { AgentByZombieInstanceId[instanceID] = agent; MissingAgentRetryByZombieInstanceId.Remove(instanceID); return true; } MissingAgentRetryByZombieInstanceId[instanceID] = unscaledTime + 0.25f; return false; } public static NetworkRobotAgent? FindNearest(Vector3 point) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) NetworkRobotAgent result = null; float num = float.PositiveInfinity; for (int num2 = All.Count - 1; num2 >= 0; num2--) { NetworkRobotAgent networkRobotAgent = All[num2]; if ((Object)(object)networkRobotAgent == (Object)null || !networkRobotAgent._initialized || (Object)(object)networkRobotAgent._character == (Object)null) { All.RemoveAt(num2); } else { Vector3 val = point - networkRobotAgent._character.Center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = networkRobotAgent; } } } return result; } public static NetworkRobotAgent? FindNearestOwnedByLocal(Vector3 point) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkRobotAgent result = null; float num = float.PositiveInfinity; for (int num2 = All.Count - 1; num2 >= 0; num2--) { NetworkRobotAgent networkRobotAgent = All[num2]; if ((Object)(object)networkRobotAgent == (Object)null || !networkRobotAgent._initialized || (Object)(object)networkRobotAgent._character == (Object)null) { All.RemoveAt(num2); } else if (networkRobotAgent.IsOwnedByLocalPlayer) { Vector3 val = point - networkRobotAgent._character.Center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = networkRobotAgent; } } } return result; } private void ReadSpawnOwnershipMetadata(PhotonView photonView) { _spawnOwnerActorNumber = (((Object)(object)photonView != (Object)null) ? photonView.OwnerActorNr : 0); _spawnOwnerUserId = (((Object)(object)photonView != (Object)null && photonView.Owner != null) ? (photonView.Owner.UserId ?? string.Empty) : string.Empty); try { object[] array = (((Object)(object)photonView != (Object)null) ? photonView.InstantiationData : null); if (array != null && array.Length != 0) { if (array.Length != 0 && array[0] is int num && num > 0) { _spawnOwnerActorNumber = num; } if (array.Length > 1 && array[1] is string spawnOwnerUserId) { _spawnOwnerUserId = spawnOwnerUserId; } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"ReadSpawnOwnershipMetadata failed: {arg}"); } } private void ClearPingGoalState() { //IL_0010: 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) _ownerCharacter = null; _target = null; _goalPoint = Vector3.zero; _hasGoalPoint = false; _hasResolvedGoalPoint = false; _resolvedGoalIsStandable = false; _rawGoalIsStandable = false; _hasLastResolvedRawGoal = false; if ((Object)(object)_zombie != (Object)null) { _zombie.currentTarget = null; } _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); ResetFullStaminaClimbRetry(); ClearGuidePlannerCaches(); ClearGoalParking(); _goalInstructionSerial = 0; _lastAcceptedPingSequence = 0; _allowGoalParking = true; _hadAcceptedGoalPoint = false; } public void Initialize(MushroomZombie zombie) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zombie == (Object)null || (Object)(object)zombie.character == (Object)null || (Object)(object)zombie.character.data == (Object)null) { Plugin.Log.LogError((object)"NetworkRobotAgent.Initialize failed: invalid zombie or character data."); ((Behaviour)this).enabled = false; return; } _lockedClimbPlan = new PathPlan(); _hasLockedClimbPlan = false; _repositionUntil = 0f; PhotonView component = ((Component)zombie).GetComponent(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogError((object)"NetworkRobotAgent requires PhotonView on MushroomZombie object."); ((Behaviour)this).enabled = false; return; } _zombie = zombie; _character = zombie.character; _view = component; ReadSpawnOwnershipMetadata(component); _ownerCharacter = Character.localCharacter; _target = _ownerCharacter; _goalPoint = Vector3.zero; _hasGoalPoint = false; _resolvedGoalPoint = Vector3.zero; _hasResolvedGoalPoint = false; _resolvedGoalIsStandable = false; _hasLastResolvedRawGoal = false; _nextResolvedGoalRefreshTime = 0f; ClearGoalParking(); _goalInstructionSerial = 0; _lastAcceptedPingSequence = 0; _allowGoalParking = true; _brainState = RobotBrainState.Idle; _nextTargetRefreshTime = 0f; _lastSeenTargetTime = Time.time; _timeInChase = 0f; _timeInLunge = 0f; _stuckTimer = 0f; _stuckAnchor = _character.Center; _stuckCount = 0; _climbTimer = 0f; _climbStartHeight = 0f; _failedClimbCount = 0; _activeClimbStartedAtRetryFullStamina = false; _awaitingFullStaminaClimbRetry = false; _fullStaminaClimbRetryConsumed = false; _fullStaminaClimbRetryAnchor = Vector3.zero; _fullStaminaClimbRetryGoalSerial = 0; _lastAutoJumpTime = -999f; _plan = new PathPlan(); _blockedMemory.Clear(); _failedSegments.Clear(); _recentRouteChoices.Clear(); ClearGuidePlannerCaches(); _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); _lastVisualZombieState = (State)(-1); _lastVisualBiteColliderEnabled = false; _lastVisualSprintState = false; _hasVisualStateSnapshot = false; canBeCarriedAsRobot = true; suppressRobotAI = false; zombieInteractionLock = 0f; lastRobotFedTime = -999f; _initialized = true; _nextPersistentRefreshTime = 0f; AgentByZombieInstanceId[((Object)_zombie).GetInstanceID()] = this; MissingAgentRetryByZombieInstanceId.Remove(((Object)_zombie).GetInstanceID()); RobotInteractionUtil.RegisterAgent(_character, this); if (!All.Contains(this)) { All.Add(this); } } private void OnDestroy() { All.Remove(this); if ((Object)(object)_zombie != (Object)null) { AgentByZombieInstanceId.Remove(((Object)_zombie).GetInstanceID()); MissingAgentRetryByZombieInstanceId.Remove(((Object)_zombie).GetInstanceID()); } RobotInteractionUtil.UnregisterAgent(_character, this); } public void DeleteRobotNetworked() { try { PrepareForDelete(); if ((Object)(object)_view != (Object)null && PhotonNetwork.InRoom) { if (!_view.IsMine && !PhotonNetwork.IsMasterClient) { try { _view.RequestOwnership(); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"DeleteRobotNetworked RequestOwnership failed: {arg}"); } } PhotonNetwork.Destroy(((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } catch (Exception arg2) { Plugin.Log.LogDebug((object)$"DeleteRobotNetworked failed: {arg2}"); try { Object.Destroy((Object)(object)((Component)this).gameObject); } catch { } } } private void PrepareForDelete() { _initialized = false; suppressRobotAI = true; All.Remove(this); if ((Object)(object)_zombie != (Object)null) { AgentByZombieInstanceId.Remove(((Object)_zombie).GetInstanceID()); MissingAgentRetryByZombieInstanceId.Remove(((Object)_zombie).GetInstanceID()); } RobotInteractionUtil.UnregisterAgent(_character, this); try { ResetInput(); } catch { } try { if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { if ((Object)(object)_character.data.carriedPlayer != (Object)null && (Object)(object)((MonoBehaviourPun)_character).photonView != (Object)null) { ((MonoBehaviourPun)_character).photonView.RPC("RPCA_Drop", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)_character.data.carriedPlayer).photonView }); } _character.data.grabbingPlayer = null; _character.data.grabbedPlayer = null; _character.data.carriedPlayer = null; _character.data.carrier = null; _character.data.isCarried = false; _character.data.currentItem = null; } } catch { } } private void UpdateInteractionState() { if (zombieInteractionLock > 0f) { zombieInteractionLock -= Time.deltaTime; if (zombieInteractionLock < 0f) { zombieInteractionLock = 0f; } } if (!((Object)(object)_character == (Object)null)) { bool flag = (Object)(object)_character.data.grabbingPlayer != (Object)null; if (_character.data.isCarried || (Object)(object)_character.data.carrier != (Object)null) { suppressRobotAI = true; canBeCarriedAsRobot = true; zombieInteractionLock = Mathf.Max(zombieInteractionLock, 0.5f); } else if (flag) { suppressRobotAI = true; canBeCarriedAsRobot = true; zombieInteractionLock = Mathf.Max(zombieInteractionLock, 0.5f); } else if (zombieInteractionLock <= 0f) { suppressRobotAI = false; canBeCarriedAsRobot = true; } } } public void NotifyGrabbedByPlayer(Character player) { suppressRobotAI = true; canBeCarriedAsRobot = true; zombieInteractionLock = Mathf.Max(zombieInteractionLock, 2f); } public void NotifyReleasedByPlayer(Character player) { zombieInteractionLock = Mathf.Max(zombieInteractionLock, 1.25f); if (!_character.data.isCarried) { suppressRobotAI = false; } } public void NotifyCarriedByPlayer(Character player) { suppressRobotAI = true; canBeCarriedAsRobot = true; zombieInteractionLock = 999f; } public void NotifyDroppedByPlayer(Character player) { zombieInteractionLock = 1.5f; suppressRobotAI = false; canBeCarriedAsRobot = true; } [PunRPC] public void RPC_AssistDrag(Vector3 helperCenter, float force) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)_character == (Object)null) && !((Object)(object)_character.data == (Object)null) && (!((Object)(object)_view != (Object)null) || _view.IsMine || PhotonNetwork.IsMasterClient)) { _character.DragTowards(helperCenter, force); _character.LimitFalling(); if (_character.data.isClimbing) { _character.data.sinceGrounded = 0f; } suppressRobotAI = true; canBeCarriedAsRobot = true; zombieInteractionLock = Mathf.Max(zombieInteractionLock, 0.35f); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"RPC_AssistDrag failed: {arg}"); } } public void NotifyFedByPlayer(Character player, Item item) { lastRobotFedTime = Time.time; canBeCarriedAsRobot = true; suppressRobotAI = true; zombieInteractionLock = Mathf.Max(zombieInteractionLock, 8f); } public bool CanBeHelpedByPlayer() { if ((Object)(object)_character == (Object)null) { return false; } if (_character.data.dead) { return false; } if (_character.IsStuck() || _character.data.sinceUnstuck < 1f) { return true; } if ((Object)(object)_character.refs.afflictions != (Object)null && _character.refs.afflictions.isWebbed) { return true; } if (_character.data.isClimbing || _character.data.isRopeClimbing || _character.data.isVineClimbing) { return true; } if (zombieInteractionLock > 0f) { return true; } return false; } private void TickSuppressedByInteraction() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) _zombie.currentState = (State)2; _character.data.passedOut = false; ResetInput(); SetSprint(sprinting: false); if (_character.data.isClimbing) { StopClimb(); } if ((Object)(object)_character.data.currentClimbHandle != (Object)null) { _character.refs.climbing.CancelHandle(false); } _character.input.movementInput = Vector2.zero; Vector3 lookAtPos = _character.Head + _character.data.lookDirection_Flat * 2f; LookAt(lookAtPos); } private void BeginSegment(PathPlan segment) { //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_0046: 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) _activeSegment = ClonePlan(segment); _hasActiveSegment = true; _segmentStartPos = _character.Center; _segmentStartTime = Time.time; _segmentStartGoalDistance = (HasActiveGoal() ? Vector3.Distance(_character.Center, GetGoalCenter()) : 999f); } private void ClearActiveSegment() { _activeSegment = new PathPlan(); _hasActiveSegment = false; } private bool IsSegmentFinished(PathPlan segment) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) float num = HelperFunctions.FlatDistance(_character.Center, segment.Goal); float num2 = Mathf.Abs(segment.Goal.y - _character.Center.y); switch (segment.Action) { case PathActionType.Direct: case PathActionType.Detour: return num <= 1.25f && num2 <= 1.75f; case PathActionType.Climb: case PathActionType.JumpGrab: if (!_character.data.isClimbing) { float num3 = HelperFunctions.FlatDistance(_character.Center, GetGoalCenter()); return num3 <= 2f || num <= 1.8f; } return false; case PathActionType.GapJump: case PathActionType.DropDown: return num <= 1.8f && num2 <= 2f; case PathActionType.Hold: return true; default: return false; } } private bool IsSegmentFailed(PathPlan segment) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) float num = Time.time - _segmentStartTime; if (num < 1.2f) { return false; } float num2 = Vector3.Distance(_character.Center, _segmentStartPos); if (IsClimbPlan(segment)) { float num3 = _character.Center.y - _segmentStartPos.y; if (num >= 3f && num3 < 0.35f && num2 < 0.8f) { return true; } return false; } float num4 = (HasActiveGoal() ? Vector3.Distance(_character.Center, GetGoalCenter()) : 999f); float num5 = _segmentStartGoalDistance - num4; if (num >= 3f && num2 < 1f && num5 < 1f) { return true; } return false; } private List BuildPathSegments() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_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) List list = new List(); if (!HasActiveGoal()) { return list; } Vector3 startPos = _character.Center; PathPlan a = new PathPlan(); bool flag = false; for (int i = 0; i < 3; i++) { PathPlan pathPlan = BuildPathPlanFrom(startPos); if (i == 0 && pathPlan.Action == PathActionType.None) { pathPlan = BuildPathPlanFrom(_character.Center); } if (pathPlan.Action == PathActionType.None || pathPlan.Action == PathActionType.Hold || (flag && !IsMeaningfullyDifferentSegment(a, pathPlan))) { break; } float failedSegmentPenalty = GetFailedSegmentPenalty(pathPlan); if (failedSegmentPenalty >= 3f && list.Count > 0) { break; } list.Add(pathPlan); if (pathPlan.Action == PathActionType.GapJump) { Vector3 goal = pathPlan.Goal; Vector3 goalCenter = GetGoalCenter(); if (goalCenter.y - goal.y > 1f) { PathPlan pathPlan2 = BuildPathPlanFrom(goal); if ((IsClimbPlan(pathPlan2) || pathPlan2.Action == PathActionType.Detour || pathPlan2.Action == PathActionType.Direct) && list.Count < 3) { list.Add(pathPlan2); } } break; } if (pathPlan.Action == PathActionType.Detour) { float num = GetGoalCenter().y - pathPlan.Goal.y; if (num < -1.5f) { break; } } if (IsSegmentCloseToFinalGoal(pathPlan)) { break; } startPos = pathPlan.Goal; a = pathPlan; flag = true; } if (list.Count == 0 && ShouldEscalateToGuidedPlanner()) { List list2 = BuildGuidedPathSegments(); if (list2.Count > 0) { return list2; } } return list; } private bool ShouldEscalateToGuidedPlanner() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return false; } if (_stuckCount > 0 || _failedClimbCount > 0 || _failedSegments.Count > 0) { return true; } float num = HelperFunctions.FlatDistance(_character.Center, GetGoalCenter()); float num2 = Mathf.Abs(GetGoalCenter().y - _character.Center.y); return num <= 1.2f && GetGoalCenter().y - _character.Center.y < -2f && num2 > 2f; } public bool Controls(MushroomZombie zombie) { return _initialized && (Object)(object)zombie == (Object)(object)_zombie; } private bool HasActiveGoal() { return (Object)(object)_target != (Object)null && _hasGoalPoint; } private Vector3 GetRawGoalCenter() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return _goalPoint; } private Vector3 GetGoalCenter() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return _hasResolvedGoalPoint ? _resolvedGoalPoint : _goalPoint; } private Vector3 GetCurrentMoveTarget() { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (_hasActiveSegment) { return _activeSegment.Goal; } return GetGoalLookPoint(); } private bool IsMeaningfullyDifferentSegment(PathPlan a, PathPlan b) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (a.Action != b.Action) { return true; } float num = Vector3.Distance(a.Goal, b.Goal); float num2 = Vector3.Distance(a.Anchor, b.Anchor); if (num > 1.25f) { return true; } if (num2 > 1f) { return true; } return false; } private bool IsSegmentCloseToFinalGoal(PathPlan segment) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return true; } float num = HelperFunctions.FlatDistance(segment.Goal, GetGoalCenter()); float num2 = Mathf.Abs(segment.Goal.y - GetGoalCenter().y); return num <= 1.875f && num2 <= 2.625f; } private void ResetRouteProgressWindow() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) _routeWindowStartTime = Time.time; _routeWindowStartGoalDistance = (HasActiveGoal() ? Vector3.Distance(_character.Center, GetGoalCenter()) : 999f); } private bool IsRouteMakingNetProgress() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return true; } float num = Time.time - _routeWindowStartTime; if (num < 2.5f) { return true; } float num2 = Vector3.Distance(_character.Center, GetGoalCenter()); float num3 = _routeWindowStartGoalDistance - num2; return num3 >= 0.9f; } private Vector3 GetGoalLookPoint() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) return GetGoalCenter() + Vector3.up * 0.15f; } private float GetGoalFlatDistance() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return 999f; } return HelperFunctions.FlatDistance(_character.Center, GetGoalCenter()); } private static PathPlan ClonePlan(PathPlan src) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) return new PathPlan { Action = src.Action, Goal = src.Goal, Anchor = src.Anchor, RequiredStamina = src.RequiredStamina, TargetAbove = src.TargetAbove, EstimatedClimbHeight = src.EstimatedClimbHeight, IsTallWall = src.IsTallWall, ExpectedDropHeight = src.ExpectedDropHeight, UsesJumpDropImmunity = src.UsesJumpDropImmunity, ReachableWithinRecoverableBudget = src.ReachableWithinRecoverableBudget, Score = src.Score, NeedsJumpStart = src.NeedsJumpStart, ProjectedEndPoint = src.ProjectedEndPoint, HasProjectedEndPoint = src.HasProjectedEndPoint, ProjectedRemainingStamina = src.ProjectedRemainingStamina, PlanningDepth = src.PlanningDepth, ClimbTopPoint = src.ClimbTopPoint, ClimbSurfaceNormal = src.ClimbSurfaceNormal, JumpGrabAimPoint = src.JumpGrabAimPoint, JumpGrabHorizontalDistance = src.JumpGrabHorizontalDistance }; } private PathPlan BuildHoldPlan(Vector3 goalLook, bool targetAbove) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new PathPlan { Action = PathActionType.Hold, Goal = goalLook, Anchor = goalLook, TargetAbove = targetAbove, ProjectedEndPoint = goalLook, HasProjectedEndPoint = true }; } private bool TryCreateImmediateDropPlan(Vector3 startPos, Vector3 dir, float flatDist, RouteProbe probe, out PathPlan plan) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); Vector3 anchor = startPos + dir * Mathf.Min(1f, flatDist); if (probe.SafeWalkDrop) { plan.Action = PathActionType.DropDown; plan.Goal = probe.DropLandingPoint; plan.Anchor = anchor; plan.TargetAbove = false; plan.RequiredStamina = 0.02f; plan.ExpectedDropHeight = probe.DropHeight; plan.UsesJumpDropImmunity = false; plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = probe.DropLandingPoint; plan.HasProjectedEndPoint = true; plan.Score = 3f - probe.DropHeight * 0.04f; return true; } if (probe.SafeJumpDrop) { plan.Action = PathActionType.DropDown; plan.Goal = probe.DropLandingPoint; plan.Anchor = anchor; plan.TargetAbove = false; plan.RequiredStamina = 0.08f; plan.ExpectedDropHeight = probe.DropHeight; plan.UsesJumpDropImmunity = true; plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = probe.DropLandingPoint; plan.HasProjectedEndPoint = true; plan.Score = 2.6f - probe.DropHeight * 0.03f; return true; } return false; } private void LockCurrentClimbPlan(PathPlan plan) { _lockedClimbPlan = ClonePlan(plan); _hasLockedClimbPlan = true; } private void ClearLockedClimbPlan() { _lockedClimbPlan = new PathPlan(); _hasLockedClimbPlan = false; } private PathPlan GetActiveClimbPlan() { if (_hasLockedClimbPlan) { return _lockedClimbPlan; } if (_hasActiveSegment) { return _activeSegment; } return _plan; } private float GetGoalVerticalDistance() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return 999f; } return Mathf.Abs(GetGoalCenter().y - _character.Center.y); } private bool HasArrivedAtGoal() { if (_goalParked) { return true; } return IsWithinGoalArrivalZone(1.55f, 1.25f, requireSafeStanding: false); } private void ClearGoalParking() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) _goalStableTimer = 0f; _goalParked = false; _parkedGoalPoint = Vector3.zero; _parkedGoalInstructionSerial = 0; } private bool TryUpdateGoalParkingAndMaybeHold() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { ClearGoalParking(); return false; } if (!_allowGoalParking || ShouldHoldCommandTarget() || _vanillaBiteControlActive) { ClearGoalParking(); return false; } if (_goalParked) { if (_parkedGoalInstructionSerial == _goalInstructionSerial) { TickParkedAtGoal(); return true; } ClearGoalParking(); return false; } if (!IsWithinGoalArrivalZone(2.05f, 1.6f, requireSafeStanding: false)) { _goalStableTimer = 0f; return false; } if (!IsSafeStandingNow()) { _goalStableTimer = 0f; TickGoalArrivalSettle(); return true; } _goalStableTimer += Time.deltaTime; TickGoalArrivalSettle(); if (_goalStableTimer >= 1f) { _goalParked = true; _parkedGoalPoint = GetGoalCenter(); _parkedGoalInstructionSerial = _goalInstructionSerial; _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); ClearGuidePlannerCaches(); _stuckCount = 0; _failedClimbCount = 0; TickParkedAtGoal(); } return true; } private void TickGoalArrivalSettle() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) _brainState = RobotBrainState.Idle; _zombie.currentState = (State)2; _character.data.passedOut = false; ResetInput(); SetSprint(sprinting: false); if (_character.data.isClimbing && _hasResolvedGoalPoint) { float num = HelperFunctions.FlatDistance(_character.Center, _resolvedGoalPoint); float num2 = _resolvedGoalPoint.y - _character.Center.y; if (num <= 1.6f && num2 <= 1.1f) { StopClimb(); } } _character.input.movementInput = Vector2.zero; } private void TickParkedAtGoal() { //IL_005d: 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) _brainState = RobotBrainState.Parked; _zombie.currentState = (State)2; _character.data.passedOut = false; ResetInput(); SetSprint(sprinting: false); if (_character.data.isClimbing) { StopClimb(); } _character.input.movementInput = Vector2.zero; } private bool IsWithinGoalArrivalZone(float flatRadius, float verticalTolerance, bool requireSafeStanding) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00ef: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal() || (Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return false; } if (requireSafeStanding && !IsSafeStandingNow()) { return false; } Vector3 val = _character.Center; if (TryFindGround(_character.Center, out var hit)) { val = ((RaycastHit)(ref hit)).point; } Vector3 val2 = (_hasResolvedGoalPoint ? _resolvedGoalPoint : _goalPoint); float num = HelperFunctions.FlatDistance(val, val2); float num2 = Mathf.Abs(val.y - val2.y); if (num <= flatRadius && num2 <= verticalTolerance) { return true; } if (_rawGoalIsStandable) { num = HelperFunctions.FlatDistance(val, _goalPoint); num2 = Mathf.Abs(val.y - _goalPoint.y); return num <= Mathf.Max(flatRadius, 1.05f) && num2 <= Mathf.Max(verticalTolerance, 1.2f); } return false; } private bool IsSafeStandingNow() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return false; } if (_character.data.isClimbing || _character.data.isRopeClimbing || _character.data.isVineClimbing) { return false; } if (_character.data.fallSeconds > 0f || _character.data.passedOut || _character.data.fullyPassedOut) { return false; } if (!_character.data.isGrounded) { return false; } RaycastHit hit; return TryFindGround(_character.Center, out hit) && IsRoughStandableNormal(((RaycastHit)(ref hit)).normal); } private bool IsRoughStandableNormal(Vector3 normal) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { return false; } return Vector3.Angle(normal, Vector3.up) <= 68f; } private bool IsRoughClimbTopNormal(Vector3 normal) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { return false; } return Vector3.Angle(normal, Vector3.up) <= 72f; } private bool IsRoughTerrainLineBlocked(Vector3 from, Vector3 to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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) PhysicsProbeCacheKey key = MakePhysicsProbeCacheKey(from, to, 2); if (SharedLineProbeCache.TryGetValue(key, out LineProbeCacheEntry value) && Time.time - value.CreatedAt <= 0.08f) { return value.Blocked; } RaycastHit val = HelperFunctions.LineCheck(from + Vector3.up * 0.65f, to + Vector3.up * 0.65f, (LayerType)1, 0f, (QueryTriggerInteraction)1); bool flag = (Object)(object)((RaycastHit)(ref val)).transform != (Object)null; bool flag2 = false; if (flag) { val = HelperFunctions.LineCheck(from + Vector3.up * 1.25f, to + Vector3.up * 1.25f, (LayerType)1, 0f, (QueryTriggerInteraction)1); bool flag3 = (Object)(object)((RaycastHit)(ref val)).transform != (Object)null; flag2 = flag3; } SharedLineProbeCache[key] = new LineProbeCacheEntry { Blocked = flag2, CreatedAt = Time.time }; PruneSharedPhysicsProbeCaches(); return flag2; } private static PhysicsProbeCacheKey MakePhysicsProbeCacheKey(Vector3 a, Vector3 b, int kind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) return new PhysicsProbeCacheKey(QuantizeSharedProbe(a.x), QuantizeSharedProbe(a.y), QuantizeSharedProbe(a.z), QuantizeSharedProbe(b.x), QuantizeSharedProbe(b.y), QuantizeSharedProbe(b.z), kind); } private static int QuantizeSharedProbe(float value) { return Mathf.RoundToInt(value / 0.55f); } private static void PruneSharedPhysicsProbeCaches() { if (SharedGroundProbeCache.Count > 512) { List> list = new List>(SharedGroundProbeCache); list.Sort((KeyValuePair a, KeyValuePair b) => a.Value.CreatedAt.CompareTo(b.Value.CreatedAt)); for (int i = 0; i < list.Count; i++) { if (SharedGroundProbeCache.Count <= 512) { break; } SharedGroundProbeCache.Remove(list[i].Key); } } if (SharedLineProbeCache.Count <= 512) { return; } List> list2 = new List>(SharedLineProbeCache); list2.Sort((KeyValuePair a, KeyValuePair b) => a.Value.CreatedAt.CompareTo(b.Value.CreatedAt)); for (int j = 0; j < list2.Count; j++) { if (SharedLineProbeCache.Count <= 512) { break; } SharedLineProbeCache.Remove(list2[j].Key); } } private bool IsLowStaminaForHeavyAction() { if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return true; } return _character.OutOfStamina() || GetStamina01() <= 0.08f; } private bool IsExhaustedForActiveClimb() { if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return true; } return _character.OutOfStamina() || GetStamina01() <= 0.018f; } private bool HasStaminaForSprint() { if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return false; } return !_character.OutOfStamina() && GetStamina01() >= 0.12f && _character.CheckSprint(); } private bool IsFlatTravelHopAllowed(Vector3 targetPos) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null || !_character.data.isGrounded) { return false; } if (Vector3.Distance(_character.Center, targetPos) < 2f) { return false; } if (!TryFindGround(_character.Center, out var hit) || !TryFindGround(targetPos, out var hit2)) { return false; } if (Mathf.Abs(((RaycastHit)(ref hit2)).point.y - ((RaycastHit)(ref hit)).point.y) > 0.45f) { return false; } Vector3 val = targetPos - _character.Center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); return !IsRoughTerrainLineBlocked(_character.Center, _character.Center + val * 1.5f); } private void HoldForStamina(Vector3 lookAtPoint) { //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_0048: Unknown result type (might be due to invalid IL or missing references) StopClimb(); SetSprint(sprinting: false); _character.input.movementInput = Vector2.zero; _character.input.jumpWasPressed = false; _character.input.jumpIsPressed = false; LookAt(lookAtPoint); } private float GetStamina01() { return Mathf.Clamp01(_character.GetTotalStamina()); } private float GetRecoverableStaminaCeiling() { return Mathf.Clamp(_character.GetMaxStamina() + _character.data.extraStamina, 0.05f, 1f); } private float EstimateGroundChaseCost(float distance) { return Mathf.Clamp(0.03f + distance * 0.01f, 0.03f, 0.25f); } private float GetClimbStartThreshold(PathPlan plan) { float num = ((plan.EstimatedClimbHeight <= 1.2f) ? 0.4f : ((!plan.IsTallWall) ? 0.85f : 0.92f)); if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer != (Object)null) { num += (plan.IsTallWall ? 0.05f : 0.08f); } return Mathf.Clamp(num, 0.05f, 0.98f); } private bool IsClimbPlan(PathPlan plan) { return plan.Action == PathActionType.Climb || plan.Action == PathActionType.JumpGrab; } private bool HasEnoughStaminaToStartClimb(PathPlan plan) { if (!IsClimbPlan(plan)) { return true; } if (plan.Action == PathActionType.JumpGrab) { float num = (((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer != (Object)null) ? 0.96f : 0.92f); return GetStamina01() >= num; } return GetStamina01() >= GetClimbStartThreshold(plan); } private bool HasEnoughStaminaToResumeClimb(PathPlan plan) { if (!IsClimbPlan(plan)) { return true; } return GetStamina01() >= GetClimbStartThreshold(plan) + 0.02f; } private List BuildGuidedPathSegments() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01ba: 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_01fb: 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_0132: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) List result = new List(); if (!HasActiveGoal()) { return result; } Vector3 center = _character.Center; Vector3 goalCenter = GetGoalCenter(); float num = HelperFunctions.FlatDistance(center, goalCenter); float num2 = Mathf.Abs(goalCenter.y - center.y); bool flag = goalCenter.y - center.y < -1.25f; if (!flag && num < 4f && num2 < 1.35f && _stuckCount <= 0 && _failedClimbCount <= 0) { return result; } Vector3 val = goalCenter - center; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); Vector3 originalBaseDir; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { if (!flag) { return result; } originalBaseDir = _character.data.lookDirection_Flat; originalBaseDir.y = 0f; if (((Vector3)(ref originalBaseDir)).sqrMagnitude < 0.01f) { originalBaseDir = ((Component)_character).transform.forward; originalBaseDir.y = 0f; } if (((Vector3)(ref originalBaseDir)).sqrMagnitude < 0.01f) { originalBaseDir = Vector3.forward; } ((Vector3)(ref originalBaseDir)).Normalize(); } else { originalBaseDir = ((Vector3)(ref val2)).normalized; } RoutePathCacheKey key = MakeRoutePathCacheKey(center, goalCenter, flag); if (TryGetCachedGuidedPath(key, out List segments)) { return segments; } float recoverableStaminaCeiling = GetRecoverableStaminaCeiling(); RouteSearchNode item = new RouteSearchNode { Position = center, Score = 0f, DistanceToGoal = Vector3.Distance(center, goalCenter), RemainingStamina = recoverableStaminaCeiling, Depth = 0 }; List list = new List { item }; RouteSearchNode routeSearchNode = null; float num3 = float.NegativeInfinity; Dictionary dictionary = new Dictionary(); dictionary[MakeRoutePlannerStateKey(center, 0, recoverableStaminaCeiling)] = 0f; for (int i = 0; i < 2; i++) { List list2 = new List(); for (int j = 0; j < list.Count; j++) { RouteSearchNode routeSearchNode2 = list[j]; List list3 = BuildGuideCandidatesFromCached(routeSearchNode2, originalBaseDir); for (int k = 0; k < list3.Count; k++) { PathPlan pathPlan = list3[k]; Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(pathPlan); float num4 = Vector3.Distance(planProjectedEndPoint, goalCenter); float num5 = HelperFunctions.FlatDistance(planProjectedEndPoint, goalCenter); float num6 = Mathf.Abs(goalCenter.y - planProjectedEndPoint.y); float num7 = routeSearchNode2.DistanceToGoal - num4; if (num7 < -1.75f && pathPlan.Action == PathActionType.Detour) { continue; } float num8 = EstimatePlanStaminaCost(pathPlan); if ((IsClimbPlan(pathPlan) || pathPlan.Action == PathActionType.GapJump || (pathPlan.Action == PathActionType.DropDown && pathPlan.UsesJumpDropImmunity)) && num8 > routeSearchNode2.RemainingStamina + 0.03f) { continue; } float num9 = Mathf.Clamp(routeSearchNode2.RemainingStamina - num8, 0f, recoverableStaminaCeiling); if (pathPlan.Action == PathActionType.Detour || pathPlan.Action == PathActionType.Direct || (pathPlan.Action == PathActionType.DropDown && !pathPlan.UsesJumpDropImmunity)) { num9 = recoverableStaminaCeiling; } float num10 = routeSearchNode2.Score + ScoreGuideCandidate(pathPlan, routeSearchNode2.Position, routeSearchNode2.DistanceToGoal, i, k); num10 += Mathf.Clamp(num7, -2f, 4f) * 1.75f; num10 += Mathf.Max(0f, 2.15f - num5) * 0.15f; RoutePlannerStateKey key2 = MakeRoutePlannerStateKey(planProjectedEndPoint, i + 1, num9); if (!dictionary.TryGetValue(key2, out var value) || !(num10 <= value + 0.08f)) { dictionary[key2] = num10; RouteSearchNode routeSearchNode3 = new RouteSearchNode { Position = planProjectedEndPoint, Score = num10, DistanceToGoal = num4, RemainingStamina = num9, Depth = i + 1 }; for (int l = 0; l < routeSearchNode2.Segments.Count; l++) { routeSearchNode3.Segments.Add(ClonePlan(routeSearchNode2.Segments[l])); } PathPlan pathPlan2 = ClonePlan(pathPlan); pathPlan2.ProjectedRemainingStamina = num9; pathPlan2.PlanningDepth = i; routeSearchNode3.Segments.Add(pathPlan2); bool flag2 = num5 <= 2.15f && num6 <= 2.35f; if (flag && pathPlan.Action == PathActionType.DropDown) { flag2 = flag2 || num6 <= 3.4499998f; } float num11 = num10 - num4 * 0.65f - num6 * 0.35f; if (flag2) { num11 += 8f; } if (routeSearchNode == null || num11 > num3) { routeSearchNode = routeSearchNode3; num3 = num11; } list2.Add(routeSearchNode3); } } } if (list2.Count == 0) { break; } list2.Sort((RouteSearchNode a, RouteSearchNode b) => b.Score.CompareTo(a.Score)); if (list2.Count > 3) { list2.RemoveRange(3, list2.Count - 3); } list = list2; } if (routeSearchNode == null || routeSearchNode.Segments.Count == 0) { return result; } List list4 = new List(); int num12 = Mathf.Min(routeSearchNode.Segments.Count, 3); for (int m = 0; m < num12; m++) { PathPlan pathPlan3 = ClonePlan(routeSearchNode.Segments[m]); list4.Add(pathPlan3); RememberRouteChoice(pathPlan3); } StoreGuidedPathCache(key, list4); return list4; } private List BuildGuideCandidatesFrom(RouteSearchNode node, Vector3 originalBaseDir) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) List list = new List(10); Vector3 goalCenter = GetGoalCenter(); Vector3 val = goalCenter - node.Position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : originalBaseDir); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } float num = HelperFunctions.FlatDistance(node.Position, goalCenter); float num2 = goalCenter.y - node.Position.y; bool flag = num2 > 1.4f; bool flag2 = num2 < -1.25f; PathPlan candidate = BuildPathPlanFrom(node.Position); AddGuideCandidate(list, candidate, node.Position); if (flag && TryBuildJumpGrabPlanFrom(node.Position, val3, targetAbove: true, out PathPlan plan) && IsViableClimbPlan(plan)) { AddGuideCandidate(list, plan, node.Position); } if (flag2 && TryBuildDropDownPlanFrom(node.Position, val3, num, num2, out PathPlan plan2)) { AddGuideCandidate(list, plan2, node.Position); } if (flag2 && TryBuildVerticalDropPlanFrom(node.Position, num2, out PathPlan plan3)) { AddGuideCandidate(list, plan3, node.Position); } if (TryBuildTerrainFallbackPlanFrom(node.Position, val3, num, flag, out PathPlan plan4)) { AddGuideCandidate(list, plan4, node.Position); } for (int i = 0; i < GuideSearchAngles.Length; i++) { float num3 = GuideSearchAngles[i]; Vector3 dir = Quaternion.AngleAxis(num3, Vector3.up) * val3; for (int j = 0; j < GuideSearchDistances.Length; j++) { float num4 = GuideSearchDistances[j]; if (!TryProbeRouteFrom(node.Position, dir, num4, out var probe)) { continue; } if (probe.GapJumpable && TryCreateGuideGapPlan(node.Position, dir, probe, flag, out PathPlan plan5)) { AddGuideCandidate(list, plan5, node.Position); } if (flag2 && TryCreateImmediateDropPlan(node.Position, dir, num, probe, out PathPlan plan6)) { AddGuideCandidate(list, plan6, node.Position); } if (probe.ClimbableAhead && !probe.UnsafeDropAhead) { PathPlan plan7 = new PathPlan(); FillClimbPlan(ref plan7, probe.ClimbBasePoint, probe.ClimbHeightDelta, flag, probe.NeedsJumpStart, probe.ClimbTopPoint, probe.ClimbSurfaceNormal); if (probe.ClimbTopPoint != Vector3.zero) { plan7.Goal = probe.ClimbTopPoint + Vector3.up * 0.12f; plan7.ProjectedEndPoint = probe.ClimbTopPoint; plan7.HasProjectedEndPoint = true; } if (IsViableClimbPlan(plan7)) { AddGuideCandidate(list, plan7, node.Position); } } if (TryCreateGuideGroundPlan(node.Position, dir, num4, probe, flag, out PathPlan plan8)) { AddGuideCandidate(list, plan8, node.Position); } } } list.Sort((PathPlan a, PathPlan b) => b.Score.CompareTo(a.Score)); if (list.Count > 10) { list.RemoveRange(10, list.Count - 10); } return list; } private bool TryCreateGuideGroundPlan(Vector3 startPos, Vector3 dir, float distance, RouteProbe probe, bool targetAbove, out PathPlan plan) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); Vector3 point = startPos + dir * distance; if (!TryFindGround(point, out var hit)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { return false; } float num = startPos.y - ((RaycastHit)(ref hit)).point.y; if (num > 10f) { return false; } float num2 = ((RaycastHit)(ref hit)).point.y - startPos.y; if (num2 > 2.25f && !probe.ClimbableAhead) { return false; } bool flag = IsRoughTerrainLineBlocked(startPos, ((RaycastHit)(ref hit)).point); if (flag && !probe.ObstacleAhead) { return false; } plan.Action = ((!flag) ? PathActionType.Direct : PathActionType.Detour); plan.Goal = ((RaycastHit)(ref hit)).point; plan.Anchor = ((RaycastHit)(ref hit)).point; plan.TargetAbove = targetAbove; plan.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)); plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = ((RaycastHit)(ref hit)).point; plan.HasProjectedEndPoint = true; float num3 = HelperFunctions.FlatDistance(startPos, GetGoalCenter()) - HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); plan.Score = num3 * 1.25f - Mathf.Abs(num) * 0.05f - GetBlockedPenalty(((RaycastHit)(ref hit)).point); if (!flag) { plan.Score += 0.35f; } if (probe.ObstacleAhead && !probe.ClimbableAhead) { plan.Score += 0.55f; } return true; } private bool TryCreateGuideGapPlan(Vector3 startPos, Vector3 dir, RouteProbe probe, bool targetAbove, out PathPlan plan) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!probe.GapJumpable) { return false; } float num = Mathf.Clamp(0.16f + probe.GapLandingDrop * 0.035f, 0.16f, 0.52f); if (num > GetRecoverableStaminaCeiling() + 0.02f) { return false; } float num2 = (probe.ObstacleAhead ? Mathf.Clamp(probe.ObstacleDistance - 0.25f, 0.75f, 1.55f) : 1.15f); plan.Action = PathActionType.GapJump; plan.Goal = probe.GapLandingPoint; plan.Anchor = startPos + dir * num2; plan.TargetAbove = targetAbove; plan.RequiredStamina = num; plan.ExpectedDropHeight = probe.GapLandingDrop; plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = probe.GapLandingPoint; plan.HasProjectedEndPoint = true; float num3 = HelperFunctions.FlatDistance(startPos, GetGoalCenter()) - HelperFunctions.FlatDistance(probe.GapLandingPoint, GetGoalCenter()); plan.Score = num3 * 1.6f + 0.9f - Mathf.Max(0f, probe.GapLandingDrop) * 0.035f; return true; } private void AddGuideCandidate(List candidates, PathPlan candidate, Vector3 startPos) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if (candidate.Action == PathActionType.None || candidate.Action == PathActionType.Hold || (IsClimbPlan(candidate) && !IsViableClimbPlan(candidate)) || ((candidate.Action == PathActionType.GapJump || IsClimbPlan(candidate)) && candidate.RequiredStamina > GetRecoverableStaminaCeiling() + 0.02f)) { return; } Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(candidate); Vector3 val = planProjectedEndPoint - startPos; if (((Vector3)(ref val)).sqrMagnitude < 0.20249999f || (candidate.Action == PathActionType.Direct && !IsGuideDirectSegmentSafe(startPos, planProjectedEndPoint))) { return; } candidate.Score += ScoreGuideCandidate(candidate, startPos, Vector3.Distance(startPos, GetGoalCenter()), candidate.PlanningDepth, candidates.Count); for (int i = 0; i < candidates.Count; i++) { Vector3 planProjectedEndPoint2 = GetPlanProjectedEndPoint(candidates[i]); if (candidates[i].Action == candidate.Action && Vector3.Distance(planProjectedEndPoint2, planProjectedEndPoint) < 0.9f) { if (candidate.Score > candidates[i].Score) { candidates[i] = ClonePlan(candidate); } return; } } candidates.Add(ClonePlan(candidate)); } private float ScoreGuideCandidate(PathPlan candidate, Vector3 startPos, float currentDistanceToGoal, int depth, int candidateIndex) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(candidate); Vector3 goalCenter = GetGoalCenter(); float num = Vector3.Distance(planProjectedEndPoint, goalCenter); float num2 = currentDistanceToGoal - num; float num3 = goalCenter.y - startPos.y; float num4 = Mathf.Abs(num3) - Mathf.Abs(goalCenter.y - planProjectedEndPoint.y); float num5 = 0f; num5 += num2 * 2.35f; num5 += num4 * 0.7f; num5 -= Mathf.Abs(planProjectedEndPoint.y - startPos.y) * 0.06f; num5 -= EstimatePlanStaminaCost(candidate) * 1.85f; num5 -= GetFailedSegmentPenalty(candidate); num5 -= GetBlockedPenalty(planProjectedEndPoint); num5 -= GetRecentRouteChoicePenalty(candidate, startPos); num5 -= (float)depth * 0.12f; num5 -= (float)candidateIndex * 0.01f; switch (candidate.Action) { case PathActionType.Climb: case PathActionType.JumpGrab: num5 += ((num3 > 0.75f) ? 1.1f : (-0.35f)); if (candidate.RequiredStamina > 0.92f) { num5 -= (candidate.RequiredStamina - 0.92f) * 4f; } break; case PathActionType.GapJump: num5 += 0.85f; break; case PathActionType.DropDown: num5 += ((num3 < -0.75f) ? 1.15f : 0.15f); break; case PathActionType.Detour: num5 += 0.35f; break; case PathActionType.Direct: num5 += 0.2f; break; } if (num2 < -0.25f) { num5 += Mathf.Max(num2, -3f) * 0.85f; } return num5; } private bool IsGuideDirectSegmentSafe(Vector3 startPos, Vector3 endPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) Vector3 val = endPos - startPos; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 8f) { return false; } if (magnitude < 0.25f) { return true; } Vector3 normalized = ((Vector3)(ref val)).normalized; int num = Mathf.Clamp(Mathf.CeilToInt(magnitude / 1.75f), 1, 5); Vector3 val2 = startPos; if (TryFindGround(startPos, out var hit)) { val2 = ((RaycastHit)(ref hit)).point; } for (int i = 1; i <= num; i++) { float num2 = (float)i / (float)num; Vector3 point = startPos + normalized * (magnitude * num2); if (!TryFindGround(point, out var hit2)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal)) { return false; } float num3 = val2.y - ((RaycastHit)(ref hit2)).point.y; float num4 = ((RaycastHit)(ref hit2)).point.y - val2.y; if (num3 > 10f || num4 > 1.85f) { return false; } if (IsRoughTerrainLineBlocked(val2, ((RaycastHit)(ref hit2)).point)) { return false; } val2 = ((RaycastHit)(ref hit2)).point; } return true; } private Vector3 GetPlanProjectedEndPoint(PathPlan plan) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_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) if (plan.HasProjectedEndPoint) { return plan.ProjectedEndPoint; } if (IsClimbPlan(plan) && plan.ClimbTopPoint != Vector3.zero) { return plan.ClimbTopPoint; } return plan.Goal; } private float EstimatePlanStaminaCost(PathPlan plan) { //IL_0076: 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) switch (plan.Action) { case PathActionType.Climb: case PathActionType.JumpGrab: return (plan.RequiredStamina > 0f) ? plan.RequiredStamina : EstimateRequiredClimbStamina(plan.EstimatedClimbHeight, plan.TargetAbove, plan.IsTallWall); case PathActionType.GapJump: return Mathf.Max(0.12f, plan.RequiredStamina); case PathActionType.Direct: case PathActionType.Detour: return EstimateGroundChaseCost(Vector3.Distance(_character.Center, plan.Goal)); case PathActionType.DropDown: return plan.UsesJumpDropImmunity ? 0.08f : 0.02f; default: return 0f; } } private void RememberRouteChoice(PathPlan plan) { //IL_0003: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Vector3 direction = GetPlanProjectedEndPoint(plan) - _character.Center; direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude > 0.01f) { ((Vector3)(ref direction)).Normalize(); } _recentRouteChoices.Add(new RouteChoiceMemory { Action = plan.Action, Position = GetPlanProjectedEndPoint(plan), Direction = direction, Until = Time.time + 5.5f }); if (_recentRouteChoices.Count > 24) { _recentRouteChoices.RemoveAt(0); } } private float GetRecentRouteChoicePenalty(PathPlan plan, Vector3 startPos) { //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(plan); Vector3 val = planProjectedEndPoint - startPos; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Vector3)(ref val)).Normalize(); } for (int num2 = _recentRouteChoices.Count - 1; num2 >= 0; num2--) { RouteChoiceMemory routeChoiceMemory = _recentRouteChoices[num2]; if (Time.time >= routeChoiceMemory.Until) { _recentRouteChoices.RemoveAt(num2); } else if (routeChoiceMemory.Action == plan.Action) { float num3 = Vector3.Distance(planProjectedEndPoint, routeChoiceMemory.Position); float num4 = ((val == Vector3.zero || routeChoiceMemory.Direction == Vector3.zero) ? 0f : Vector3.Dot(val, routeChoiceMemory.Direction)); if (num3 <= 2.4f && num4 > 0.65f) { num += Mathf.InverseLerp(2.4f, 0.35f, num3) * 0.75f; } } } return num; } private List BuildGuideCandidatesFromCached(RouteSearchNode node, Vector3 originalBaseDir) { //IL_0003: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) RouteCandidateCacheKey key = MakeRouteCandidateCacheKey(node.Position, GetGoalCenter(), originalBaseDir); if (_guideCandidateCache.TryGetValue(key, out RouteCandidateCacheEntry value) && Time.time - value.CreatedAt <= 1.1f) { return ClonePlanList(value.Candidates); } List list = BuildGuideCandidatesFrom(node, originalBaseDir); RouteCandidateCacheEntry routeCandidateCacheEntry = new RouteCandidateCacheEntry { CreatedAt = Time.time }; for (int i = 0; i < list.Count; i++) { routeCandidateCacheEntry.Candidates.Add(ClonePlan(list[i])); } _guideCandidateCache[key] = routeCandidateCacheEntry; PruneGuidePlannerCaches(); return ClonePlanList(list); } private bool TryGetCachedGuidedPath(RoutePathCacheKey key, out List segments) { segments = new List(); if (_guidePathCache.TryGetValue(key, out RoutePathCacheEntry value)) { if (Time.time - value.CreatedAt <= 1.1f) { segments = ClonePlanList(value.Segments); return segments.Count > 0; } _guidePathCache.Remove(key); } if (SharedGuidePathCache.TryGetValue(key, out RoutePathCacheEntry value2)) { if (Time.time - value2.CreatedAt <= 2.5f) { segments = ClonePlanList(value2.Segments); return segments.Count > 0; } SharedGuidePathCache.Remove(key); } return false; } private void StoreGuidedPathCache(RoutePathCacheKey key, List segments) { RoutePathCacheEntry routePathCacheEntry = new RoutePathCacheEntry { CreatedAt = Time.time }; for (int i = 0; i < segments.Count; i++) { routePathCacheEntry.Segments.Add(ClonePlan(segments[i])); } _guidePathCache[key] = routePathCacheEntry; RoutePathCacheEntry routePathCacheEntry2 = new RoutePathCacheEntry { CreatedAt = Time.time }; for (int j = 0; j < segments.Count; j++) { routePathCacheEntry2.Segments.Add(ClonePlan(segments[j])); } SharedGuidePathCache[key] = routePathCacheEntry2; PruneGuidePlannerCaches(); } private List ClonePlanList(List source) { List list = new List(source.Count); for (int i = 0; i < source.Count; i++) { list.Add(ClonePlan(source[i])); } return list; } private RouteCandidateCacheKey MakeRouteCandidateCacheKey(Vector3 position, Vector3 goal, Vector3 dir) { //IL_0002: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) return new RouteCandidateCacheKey(QuantizePlanner(position.x, 1.4f), QuantizePlanner(position.y, 1.4f), QuantizePlanner(position.z, 1.4f), QuantizePlanner(goal.x, 1.25f), QuantizePlanner(goal.y, 1.25f), QuantizePlanner(goal.z, 1.25f), QuantizeDirection(dir)); } private RoutePathCacheKey MakeRoutePathCacheKey(Vector3 start, Vector3 goal, bool lowerGoal) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) int num = (lowerGoal ? 1 : 0); num = num * 10 + Mathf.Clamp(_stuckCount, 0, 3); num = num * 10 + Mathf.Clamp(_failedClimbCount, 0, 3); return new RoutePathCacheKey(QuantizePlanner(start.x, 1.4f), QuantizePlanner(start.y, 1.4f), QuantizePlanner(start.z, 1.4f), QuantizePlanner(goal.x, 1.25f), QuantizePlanner(goal.y, 1.25f), QuantizePlanner(goal.z, 1.25f), QuantizeStamina(GetStamina01()), num); } private RoutePlannerStateKey MakeRoutePlannerStateKey(Vector3 position, int depth, float stamina) { //IL_0002: 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_0024: Unknown result type (might be due to invalid IL or missing references) return new RoutePlannerStateKey(QuantizePlanner(position.x, 1.75f), QuantizePlanner(position.y, 1.75f), QuantizePlanner(position.z, 1.75f), depth, QuantizeStamina(stamina)); } private int QuantizePlanner(float value, float cell) { return Mathf.RoundToInt(value / Mathf.Max(0.01f, cell)); } private int QuantizeStamina(float stamina) { return Mathf.Clamp(Mathf.RoundToInt(stamina * 10f), 0, 14); } private int QuantizeDirection(Vector3 dir) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude < 0.01f) { return 0; } ((Vector3)(ref dir)).Normalize(); float num = Mathf.Atan2(dir.x, dir.z) * 57.29578f; if (num < 0f) { num += 360f; } return Mathf.RoundToInt(num / 22.5f) & 0xF; } private void ClearGuidePlannerCaches() { _guideCandidateCache.Clear(); _guidePathCache.Clear(); } private void PruneGuidePlannerCaches() { if (SharedGuidePathCache.Count > 128) { List> list = new List>(SharedGuidePathCache); list.Sort((KeyValuePair a, KeyValuePair b) => a.Value.CreatedAt.CompareTo(b.Value.CreatedAt)); for (int i = 0; i < list.Count; i++) { if (SharedGuidePathCache.Count <= 128) { break; } SharedGuidePathCache.Remove(list[i].Key); } } if (_guideCandidateCache.Count > 128) { List> list2 = new List>(_guideCandidateCache); list2.Sort((KeyValuePair a, KeyValuePair b) => a.Value.CreatedAt.CompareTo(b.Value.CreatedAt)); for (int j = 0; j < list2.Count; j++) { if (_guideCandidateCache.Count <= 128) { break; } _guideCandidateCache.Remove(list2[j].Key); } } if (_guidePathCache.Count <= 32) { return; } List> list3 = new List>(_guidePathCache); list3.Sort((KeyValuePair a, KeyValuePair b) => a.Value.CreatedAt.CompareTo(b.Value.CreatedAt)); for (int k = 0; k < list3.Count; k++) { if (_guidePathCache.Count <= 32) { break; } _guidePathCache.Remove(list3[k].Key); } } private bool IsViableClimbPlan(PathPlan plan) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if (!IsClimbPlan(plan)) { return true; } float recoverableStaminaCeiling = GetRecoverableStaminaCeiling(); float num = ((plan.RequiredStamina > 0f) ? plan.RequiredStamina : EstimateRequiredClimbStamina(plan.EstimatedClimbHeight, plan.TargetAbove, plan.IsTallWall)); if (num > recoverableStaminaCeiling + 0.02f) { return false; } float num2 = EstimateMaxReachableClimbHeight(plan.TargetAbove, plan.NeedsJumpStart); if (plan.EstimatedClimbHeight > num2 + 0.35f) { return false; } if (_resolvedGoalIsStandable && plan.ClimbTopPoint != Vector3.zero) { Vector3 from = plan.ClimbTopPoint + Vector3.up * 0.25f; Vector3 to = _resolvedGoalPoint + Vector3.up * 0.25f; if (IsRoughTerrainLineBlocked(from, to)) { return false; } } return true; } private void FillClimbPlan(ref PathPlan plan, Vector3 anchor, float climbHeight, bool targetAbove, bool needsJumpStart, Vector3 topPoint, Vector3 surfaceNormal) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (HasActiveGoal()) { plan.Action = PathActionType.Climb; plan.Goal = GetGoalLookPoint(); plan.Anchor = anchor; plan.TargetAbove = targetAbove; plan.EstimatedClimbHeight = climbHeight; plan.IsTallWall = climbHeight >= 2.15f; plan.RequiredStamina = EstimateRequiredClimbStamina(climbHeight, targetAbove, plan.IsTallWall); plan.ReachableWithinRecoverableBudget = plan.RequiredStamina <= GetRecoverableStaminaCeiling(); plan.NeedsJumpStart = needsJumpStart; plan.ClimbTopPoint = topPoint; plan.ClimbSurfaceNormal = surfaceNormal; plan.ProjectedEndPoint = ((topPoint != Vector3.zero) ? topPoint : plan.Goal); plan.HasProjectedEndPoint = true; } } private void TryForceJumpGrab(PathPlan plan, bool closeToAnchor) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (plan.NeedsJumpStart && closeToAnchor && _character.data.isGrounded && !(Time.time - _lastAutoJumpTime < 0.2f) && !(GetStamina01() < 0.18f) && HasEnoughStaminaToStartClimb(plan)) { SetSprint(HasStaminaForSprint()); LookAt(plan.Goal); _character.input.movementInput = new Vector2(0f, 1f); _character.input.jumpWasPressed = true; _character.refs.climbing.TryClimb(1.6f); _lastAutoJumpTime = Time.time; } } private RouteProbe ProbeRoute(Vector3 dir, float forwardDistance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) TryProbeRouteFrom(_character.Center, dir, forwardDistance, out var probe); return probe; } private bool TryFindGround(Vector3 point, out RaycastHit hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) PhysicsProbeCacheKey key = MakePhysicsProbeCacheKey(point, point, 1); if (SharedGroundProbeCache.TryGetValue(key, out GroundProbeCacheEntry value) && Time.time - value.CreatedAt <= 0.08f) { hit = value.Hit; return value.Found; } bool flag = Physics.Raycast(point + Vector3.up * 2.2f, Vector3.down, ref hit, 16f, TerrainMask, (QueryTriggerInteraction)1); SharedGroundProbeCache[key] = new GroundProbeCacheEntry { Found = flag, Hit = hit, CreatedAt = Time.time }; PruneSharedPhysicsProbeCaches(); return flag; } private float EstimateRequiredClimbStamina(float climbHeight, bool targetAbove, bool tallWall) { float num = Mathf.Max(0.05f, climbHeight); float num2 = ((!(num <= 1.2f)) ? (0.54f + num * 0.135f) : (0.26f + num * 0.11f)); if (targetAbove) { num2 += 0.05f; } if (tallWall) { num2 += 0.06f; } if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer != (Object)null) { num2 += 0.1f + num * 0.035f; } if (_failedClimbCount > 0) { num2 += Mathf.Min(0.04f * (float)_failedClimbCount, 0.12f); } return Mathf.Clamp(num2, 0.2f, 1.35f); } private float EstimateMaxReachableClimbHeight(bool targetAbove, bool needsJumpStart) { float recoverableStaminaCeiling = GetRecoverableStaminaCeiling(); float num = 0.54f; if (targetAbove) { num += 0.05f; } if (needsJumpStart) { num += 0.04f; } if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer != (Object)null) { num += 0.1f; } float num2 = (recoverableStaminaCeiling - num) / 0.135f; return Mathf.Clamp(num2, 1.2f, 4.6f); } private bool ShouldAbortClimbForStamina(PathPlan climbPlan, float stamina, bool nearTopPoint, float climbedRatio) { //IL_0038: 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_0066: Unknown result type (might be due to invalid IL or missing references) if (_character.OutOfStamina() || stamina <= 0.018f) { return true; } if (nearTopPoint) { return false; } if (climbPlan.ClimbTopPoint == Vector3.zero) { return false; } float num = climbPlan.ClimbTopPoint.y - _character.Center.y; if (num <= 0.55f) { return false; } float num2 = Mathf.Clamp(0.045f + num * 0.055f, 0.07f, 0.24f); if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null && (Object)(object)_character.data.carriedPlayer != (Object)null) { num2 += 0.045f; } return false; } private bool CanContinueClimb(PathPlan climbPlan) { //IL_004a: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return false; } if (_character.OutOfStamina()) { return false; } float stamina = GetStamina01(); if (stamina <= 0.018f) { return false; } if (climbPlan.ClimbTopPoint != Vector3.zero && Vector3.Distance(_character.Center, climbPlan.ClimbTopPoint) < 1.35f) { return stamina >= 0.018f; } return stamina >= 0.018f; } private float GetFullStaminaRetryThreshold() { return Mathf.Max(0.05f, GetRecoverableStaminaCeiling() - 0.02f); } private bool HasRecoveredFullStaminaForRetry() { return GetStamina01() >= GetFullStaminaRetryThreshold(); } private Vector3 GetFullStaminaRetryAnchor(PathPlan plan) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) return (plan.Anchor != Vector3.zero) ? plan.Anchor : _character.Center; } private void ResetFullStaminaClimbRetry() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) _activeClimbStartedAtRetryFullStamina = false; _awaitingFullStaminaClimbRetry = false; _fullStaminaClimbRetryConsumed = false; _fullStaminaClimbRetryAnchor = Vector3.zero; _fullStaminaClimbRetryGoalSerial = _goalInstructionSerial; } private void RefreshFullStaminaClimbRetrySite(PathPlan plan) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!(_fullStaminaClimbRetryAnchor == Vector3.zero)) { Vector3 fullStaminaRetryAnchor = GetFullStaminaRetryAnchor(plan); if (Vector3.Distance(fullStaminaRetryAnchor, _fullStaminaClimbRetryAnchor) > 2.75f) { ResetFullStaminaClimbRetry(); } } } private bool IsWaitingForFullStaminaClimbRetry(PathPlan plan) { if (!_awaitingFullStaminaClimbRetry) { return false; } if (_fullStaminaClimbRetryGoalSerial != _goalInstructionSerial) { ResetFullStaminaClimbRetry(); return false; } RefreshFullStaminaClimbRetrySite(plan); return _awaitingFullStaminaClimbRetry; } private bool TryArmFullStaminaClimbRetry(PathPlan plan) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!_activeClimbStartedAtRetryFullStamina) { return false; } RefreshFullStaminaClimbRetrySite(plan); if (_awaitingFullStaminaClimbRetry || _fullStaminaClimbRetryConsumed) { return false; } _awaitingFullStaminaClimbRetry = true; _fullStaminaClimbRetryConsumed = false; _fullStaminaClimbRetryAnchor = GetFullStaminaRetryAnchor(plan); _fullStaminaClimbRetryGoalSerial = _goalInstructionSerial; _failedClimbCount = 0; return true; } private void MarkFullStaminaClimbRetryAttemptStarted(PathPlan plan) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (IsWaitingForFullStaminaClimbRetry(plan)) { _awaitingFullStaminaClimbRetry = false; _fullStaminaClimbRetryConsumed = true; _fullStaminaClimbRetryAnchor = GetFullStaminaRetryAnchor(plan); _fullStaminaClimbRetryGoalSerial = _goalInstructionSerial; } } private void EnterPrepareTallClimb() { StopClimb(); ClearLockedClimbPlan(); SetSprint(sprinting: false); _brainState = RobotBrainState.PrepareTallClimb; } private void EnterReposition() { StopClimb(); ClearLockedClimbPlan(); SetSprint(sprinting: false); _repositionUntil = Time.time + 1.1f; _brainState = RobotBrainState.Reposition; } private bool CanSeeGoal() { //IL_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return false; } return !IsRoughTerrainLineBlocked(_character.Head, GetGoalCenter() + Random.insideUnitSphere * 0.35f); } private void RefreshTargetIfNeeded() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextTargetRefreshTime) { return; } _nextTargetRefreshTime = Time.time + 0.2f; if (PingTargetTracker.TryGetBestPingDataForRobot(_character, _spawnOwnerActorNumber, _character.Center, out var data)) { Character ownerCharacter = data.OwnerCharacter; Vector3 point = data.Point; bool flag = data.Sequence != _lastAcceptedPingSequence; bool flag2 = HasGoalPointChanged(point); _ownerCharacter = ownerCharacter; _target = ownerCharacter; _goalPoint = point; _hasGoalPoint = true; _allowGoalParking = true; _zombie.currentTarget = ownerCharacter; if (flag || flag2) { ResetRouteForNewGoal(point, data.Sequence); _lastAcceptedPingSequence = data.Sequence; _brainState = RobotBrainState.Chase; } } else { _ownerCharacter = null; _target = null; _hasGoalPoint = false; _hasResolvedGoalPoint = false; _hasLastResolvedRawGoal = false; _allowGoalParking = true; _lastAcceptedPingSequence = 0; _zombie.currentTarget = null; _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); ResetFullStaminaClimbRetry(); _hadAcceptedGoalPoint = false; } } private void RefreshResolvedGoalIfNeeded() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) if (!HasActiveGoal()) { _hasResolvedGoalPoint = false; _resolvedGoalIsStandable = false; _rawGoalIsStandable = false; _hasLastResolvedRawGoal = false; return; } Vector3 rawGoalCenter = GetRawGoalCenter(); if ((_hasLastResolvedRawGoal && _hasResolvedGoalPoint && Vector3.Distance(_lastResolvedRawGoal, rawGoalCenter) <= 0.08f) || Time.time < _nextResolvedGoalRefreshTime) { return; } _nextResolvedGoalRefreshTime = Time.time + 1.5f; _lastResolvedRawGoal = rawGoalCenter; _hasLastResolvedRawGoal = true; if (TryProbeExactStandableGoal(rawGoalCenter, out var standPoint)) { _rawGoalIsStandable = true; _resolvedGoalPoint = standPoint; _hasResolvedGoalPoint = true; _resolvedGoalIsStandable = true; return; } _rawGoalIsStandable = false; if (TryFindStandableNearGoal(rawGoalCenter, out var standPoint2) || TryFindStandableAccessNearNonStandableGoal(rawGoalCenter, out standPoint2)) { if (_hasResolvedGoalPoint && Vector3.Distance(_resolvedGoalPoint, standPoint2) <= 0.9f) { _resolvedGoalIsStandable = true; return; } _resolvedGoalPoint = standPoint2; _hasResolvedGoalPoint = true; _resolvedGoalIsStandable = true; } else { _resolvedGoalPoint = rawGoalCenter; _hasResolvedGoalPoint = true; _resolvedGoalIsStandable = false; } } private bool TryProbeExactStandableGoal(Vector3 rawGoal, out Vector3 standPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f3: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) standPoint = Vector3.zero; if (!TryFindGround(rawGoal, out var hit)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { return false; } float num = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, rawGoal); float num2 = Mathf.Abs(((RaycastHit)(ref hit)).point.y - rawGoal.y); if (num > 1.05f || num2 > 1.2f) { return false; } int num3 = 0; Vector3[] array = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.back, Vector3.left, Vector3.right }; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { Vector3 val = ((RaycastHit)(ref hit)).point + array[i] * 0.45f; if (Physics.Raycast(val + Vector3.up * 0.65f, Vector3.down, ref val2, 2.05f, TerrainMask, (QueryTriggerInteraction)1)) { float num4 = Mathf.Abs(((RaycastHit)(ref val2)).point.y - ((RaycastHit)(ref hit)).point.y); if (num4 <= 1.05f && IsRoughStandableNormal(((RaycastHit)(ref val2)).normal)) { num3++; } } } if (num3 < 2) { return false; } standPoint = ((RaycastHit)(ref hit)).point; return true; } private bool TryFindStandableNearGoal(Vector3 rawGoal, out Vector3 standPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_01c0: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02de: 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) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) standPoint = Vector3.zero; Vector3[] array = (Vector3[])(object)new Vector3[16] { new Vector3(0.95f, 0f, 0f), new Vector3(-0.95f, 0f, 0f), new Vector3(0f, 0f, 0.95f), new Vector3(0f, 0f, -0.95f), new Vector3(1.2f, 0f, 0f), new Vector3(-1.2f, 0f, 0f), new Vector3(0f, 0f, 1.2f), new Vector3(0f, 0f, -1.2f), new Vector3(0.95f, 0f, 0.95f), new Vector3(-0.95f, 0f, 0.95f), new Vector3(0.95f, 0f, -0.95f), new Vector3(-0.95f, 0f, -0.95f), new Vector3(1.2f, 0f, 1.2f), new Vector3(-1.2f, 0f, 1.2f), new Vector3(1.2f, 0f, -1.2f), new Vector3(-1.2f, 0f, -1.2f) }; bool flag = false; float num = float.NegativeInfinity; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { Vector3 point = rawGoal + array[i]; if (!TryFindGround(point, out var hit) || !IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { continue; } float num2 = Vector3.Distance(((RaycastHit)(ref hit)).point, rawGoal); if (num2 > 1.95f) { continue; } int num3 = 0; Vector3[] array2 = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.back, Vector3.left, Vector3.right }; for (int j = 0; j < array2.Length; j++) { Vector3 val = ((RaycastHit)(ref hit)).point + array2[j] * 0.45f; if (Physics.Raycast(val + Vector3.up * 0.65f, Vector3.down, ref val2, 2.05f, TerrainMask, (QueryTriggerInteraction)1)) { float num4 = Mathf.Abs(((RaycastHit)(ref val2)).point.y - ((RaycastHit)(ref hit)).point.y); if (num4 <= 1.05f && IsRoughStandableNormal(((RaycastHit)(ref val2)).normal)) { num3++; } } } if (num3 <= 0) { continue; } bool flag2 = !IsRoughTerrainLineBlocked(((RaycastHit)(ref hit)).point, rawGoal); float num5 = Vector3.Distance(_character.Center, ((RaycastHit)(ref hit)).point); float num6 = 0f; num6 -= num2 * 2.1f; num6 += (float)num3 * 1.25f; if (flag2) { num6 += 1.2f; } num6 -= num5 * 0.08f; if (_hasResolvedGoalPoint) { float num7 = Vector3.Distance(_resolvedGoalPoint, ((RaycastHit)(ref hit)).point); if (num7 <= 0.9f) { num6 += 1f; } } if (!flag || num6 > num) { flag = true; num = num6; standPoint = ((RaycastHit)(ref hit)).point; } } return flag; } private bool TryFindStandableAccessNearNonStandableGoal(Vector3 rawGoal, out Vector3 standPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) standPoint = Vector3.zero; float[] array = new float[6] { 0.55f, 1.1f, 1.8f, 2.7f, 3.8f, 5.2f }; float[] array2 = new float[8] { 0f, 45f, -45f, 90f, -90f, 135f, -135f, 180f }; bool flag = false; float num = float.NegativeInfinity; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array2.Length; j++) { Vector3 val = Quaternion.AngleAxis(array2[j], Vector3.up) * Vector3.forward * array[i]; Vector3 val2 = rawGoal + val + Vector3.up * 7f; if (!Physics.Raycast(val2, Vector3.down, ref val3, 13.5f, TerrainMask, (QueryTriggerInteraction)1) || !IsRoughStandableNormal(((RaycastHit)(ref val3)).normal)) { continue; } float num2 = HelperFunctions.FlatDistance(((RaycastHit)(ref val3)).point, rawGoal); if (!(num2 > 5.85f)) { float num3 = ((RaycastHit)(ref val3)).point.y - rawGoal.y; float num4 = ((num3 < -0.45f) ? (Mathf.Abs(num3) * 1.85f + 1.4f) : 0f); float num5 = ((num3 > 5.8f) ? ((num3 - 5.8f) * 1.2f) : 0f); bool flag2 = !IsRoughTerrainLineBlocked(((RaycastHit)(ref val3)).point + Vector3.up * 0.15f, rawGoal + Vector3.up * 0.15f); float num6 = (((Object)(object)_character != (Object)null) ? Vector3.Distance(_character.Center, ((RaycastHit)(ref val3)).point) : 0f); float num7 = 0f; num7 -= num2 * 1.35f; num7 -= Mathf.Abs(num3) * 0.75f; num7 -= num4; num7 -= num5; num7 -= num6 * 0.06f; if (num3 >= -0.35f) { num7 += 1.6f; } if (flag2) { num7 += 0.8f; } if (!flag || num7 > num) { flag = true; num = num7; standPoint = ((RaycastHit)(ref val3)).point; } } } } return flag; } private bool TryBuildObstacleBypassJumpPlanFrom(Vector3 startPos, Vector3 dir, RouteProbe directProbe, out PathPlan plan) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_015c: 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_018b: 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_019d: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!directProbe.ObstacleAhead || directProbe.ClimbableAhead) { return false; } if (directProbe.ObstacleDistance < 0.45f || directProbe.ObstacleDistance > 2.2f) { return false; } float num = -999f; Vector3 val = directProbe.ObstaclePoint + dir * 0.12f + Vector3.up * 2.35f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, 2.75f, TerrainMask, (QueryTriggerInteraction)1)) { num = ((RaycastHit)(ref val2)).point.y - startPos.y; } if (num < 0.28f || num > 1.55f) { return false; } float[] array = new float[4] { 0.95f, 1.25f, 1.6f, 1.95f }; bool flag = false; float num2 = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); for (int i = 0; i < array.Length; i++) { float num3 = directProbe.ObstacleDistance + array[i]; Vector3 point = startPos + dir * num3; if (!TryFindGround(point, out var hit) || !IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { continue; } float num4 = Mathf.Abs(((RaycastHit)(ref hit)).point.y - startPos.y); if (num4 > 0.9f) { continue; } float num5 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); float num6 = HelperFunctions.FlatDistance(startPos, GetGoalCenter()); float num7 = num6 - num5; if (num7 < 0.35f) { continue; } Vector3 from = startPos + Vector3.up * 1f; Vector3 to = ((RaycastHit)(ref hit)).point + Vector3.up * 1f; if (!IsRoughTerrainLineBlocked(from, to)) { PathPlan pathPlan2 = new PathPlan { Action = PathActionType.GapJump, Anchor = startPos + dir * Mathf.Clamp(directProbe.ObstacleDistance - 0.1f, 0.55f, 1.25f), Goal = ((RaycastHit)(ref hit)).point, TargetAbove = false, RequiredStamina = Mathf.Clamp(0.1f + num * 0.06f, 0.1f, 0.22f), ReachableWithinRecoverableBudget = true, Score = 0f }; float num8 = 0f; num8 += num7 * 1.8f; num8 -= num4 * 0.45f; num8 -= Mathf.Abs(num - 0.9f) * 0.2f; num8 -= GetBlockedPenalty(((RaycastHit)(ref hit)).point); num8 = (pathPlan2.Score = num8 - GetFailedSegmentPenalty(pathPlan2)); if (!flag || num8 > num2) { flag = true; num2 = num8; pathPlan = pathPlan2; } } } if (flag) { plan = pathPlan; return true; } return false; } private void ValidateTarget() { if ((Object)(object)_target == (Object)null) { _hasGoalPoint = false; _hasResolvedGoalPoint = false; return; } bool flag = IsCarryAssistTarget(_target); if (_target.isBot || _target.data.dead || (_target.data.fullyPassedOut && !flag)) { _target = null; _hasGoalPoint = false; _hasResolvedGoalPoint = false; _zombie.currentTarget = null; if (flag) { DisableCarryAssist(); } } } private void UpdateStuckDetection() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) if (_brainState != RobotBrainState.Chase && _brainState != RobotBrainState.Reposition && _brainState != RobotBrainState.PrepareTallClimb) { _stuckAnchor = _character.Center; _stuckTimer = 0f; return; } _stuckTimer += Time.deltaTime; if (!(_stuckTimer < 1f)) { float num = Vector3.Distance(_character.Center, _stuckAnchor); if (num < 0.7f) { _stuckCount++; } else { _stuckCount = 0; } _stuckAnchor = _character.Center; _stuckTimer = 0f; } } private void UpdateClimbFailureDetection() { //IL_0049: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c5: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (!_character.data.isClimbing) { _climbTimer = 0f; return; } if (_climbTimer <= 0f) { _climbStartHeight = _character.Center.y; _stuckAnchor = _character.Center; _activeClimbStartedAtRetryFullStamina = HasRecoveredFullStaminaForRetry(); } _climbTimer += Time.deltaTime; if (_climbTimer < 2.2f) { return; } float num = _character.Center.y - _climbStartHeight; float num2 = Vector3.Distance(_character.Center, _stuckAnchor); bool flag = _plan.ClimbTopPoint != Vector3.zero && Vector3.Distance(_character.Center, _plan.ClimbTopPoint) < 1.35f; if (!(num >= 0.18f || num2 >= 0.45f || flag)) { PathPlan activeClimbPlan = GetActiveClimbPlan(); if (TryArmFullStaminaClimbRetry(activeClimbPlan)) { EnterPrepareTallClimb(); _stuckAnchor = _character.Center; _climbStartHeight = _character.Center.y; _climbTimer = 0f; return; } _failedClimbCount++; RegisterBlockedPoint(_character.Center, 2f); if (_failedClimbCount >= 3) { StopClimb(); ClearLockedClimbPlan(); EnterReposition(); } } else { _failedClimbCount = 0; } _stuckAnchor = _character.Center; _climbStartHeight = _character.Center.y; _climbTimer = 0f; } private void RegisterBlockedPoint(Vector3 point, float seconds) { //IL_000d: 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) _blockedMemory.Add(new BlockedMemory { Point = point, Until = Time.time + seconds }); } private void DecayBlockedMemory() { for (int num = _blockedMemory.Count - 1; num >= 0; num--) { if (Time.time >= _blockedMemory[num].Until) { _blockedMemory.RemoveAt(num); } } } private float GetBlockedPenalty(Vector3 point) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) float num = 0f; for (int i = 0; i < _blockedMemory.Count; i++) { float num2 = Vector3.Distance(point, _blockedMemory[i].Point); if (num2 < 4f) { num += Mathf.InverseLerp(4f, 0.5f, num2) * 2f; } } return num; } private void ResetInput() { _character.input.ResetInput(); } private bool HasEnoughStaminaForPassiveClimbProbe() { if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return false; } if (IsLowStaminaForHeavyAction()) { return false; } return GetStamina01() >= 0.1f; } private void WalkTowards(Vector3 targetPos, float mult, bool tryClimb, bool tryJump, bool sprintRequested) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) float num = HelperFunctions.FlatDistance(_character.Center, targetPos); float num2 = Vector3.Distance(_character.Center, targetPos); if (num < 0.55f && num2 < 1.1f) { mult *= 0.35f; } else if (num < 1.2f && num2 < 2.8f) { mult *= 0.7f; } bool flag = IsLowStaminaForHeavyAction(); _character.input.movementInput = new Vector2(0f, mult); SetSprint(sprintRequested && HasStaminaForSprint()); LookAt(targetPos); if (tryClimb && HasEnoughStaminaForPassiveClimbProbe()) { _character.refs.climbing.TryClimb(1.25f); } if (!tryJump || !_character.data.isGrounded || Time.time - _lastAutoJumpTime < 0.12f) { return; } bool flag2 = flag && IsFlatTravelHopAllowed(targetPos); if (!flag2 && _character.GetTotalStamina() < 0.16f) { return; } Vector3 val = targetPos - _character.Center; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { ((Vector3)(ref val)).Normalize(); bool flag3 = !flag && ShouldHopSmallObstacleTowards(targetPos); int num3; if (!flag) { RaycastHit val2 = HelperFunctions.LineCheck(_character.Center + val * 0.65f, _character.Center + val * 0.65f + Vector3.down * 3f, (LayerType)1, 0f, (QueryTriggerInteraction)1); num3 = (((Object)(object)((RaycastHit)(ref val2)).transform == (Object)null) ? 1 : 0); } else { num3 = 0; } bool flag4 = (byte)num3 != 0; if (flag3 || flag4 || flag2) { SetSprint(!flag && HasStaminaForSprint()); _character.input.movementInput = new Vector2(0f, Mathf.Max(mult, 1f)); _character.input.jumpWasPressed = true; _lastAutoJumpTime = Time.time; } } } private Vector2 ComputeStrategicClimbInput(Vector3 targetPos, PathPlan climbPlan) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) Bodypart bodypart = _character.GetBodypart((BodypartType)2); if ((Object)(object)bodypart == (Object)null) { return new Vector2(0f, 1f); } Vector3 val = targetPos; if (climbPlan.Action == PathActionType.Climb) { if (TryFindLateralTraversePoint(climbPlan, out var point)) { val = point; } else if (_resolvedGoalIsStandable) { val = _resolvedGoalPoint + Vector3.up * 0.1f; } else if (climbPlan.ClimbTopPoint != Vector3.zero) { val = Vector3.Lerp(climbPlan.ClimbTopPoint, targetPos, 0.7f); } } Vector3 val2 = ((Component)bodypart).transform.InverseTransformPoint(val); float num = Mathf.Clamp(val2.x * 0.9f, -1f, 1f); float num2 = Mathf.Clamp(val2.y * 0.45f + 0.95f, 0.7f, 1f); float num3 = Mathf.Abs(num); if (num3 > 0.65f) { num = Mathf.Sign(num) * 0.95f; num2 = Mathf.Max(num2, 0.95f); } else if (num3 > 0.25f) { num = Mathf.Sign(num) * 0.6f; num2 = Mathf.Max(num2, 0.92f); } else { num2 = Mathf.Max(num2, 1f); } if (climbPlan.ClimbTopPoint != Vector3.zero) { float num4 = Vector3.Distance(_character.Center, climbPlan.ClimbTopPoint); if (num4 < 1.25f) { num2 = Mathf.Max(num2, 0.95f); } } return new Vector2(num, num2); } private bool TryFindLateralTraversePoint(PathPlan climbPlan, out Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0056: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; if (climbPlan.Action != PathActionType.Climb) { return false; } if (climbPlan.ClimbSurfaceNormal == Vector3.zero) { return false; } Vector3 val = Vector3.Cross(Vector3.up, climbPlan.ClimbSurfaceNormal); Vector3 normalized = ((Vector3)(ref val)).normalized; if (normalized == Vector3.zero) { return false; } Vector3 val2 = GetGoalLookPoint() - _character.Center; val2.y = 0f; float num = Mathf.Sign(Vector3.Dot(((Vector3)(ref val2)).normalized, normalized)); if (Mathf.Approximately(num, 0f)) { num = 1f; } bool flag = false; float num2 = float.NegativeInfinity; float[] array = new float[2] { num, 0f - num }; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < LateralTraverseSamples.Length; j++) { float num3 = LateralTraverseSamples[j]; Vector3 val3 = _character.Center + normalized * (array[i] * num3) + Vector3.up * 0.15f; if (!IsRoughTerrainLineBlocked(_character.Center, val3)) { bool flag2 = IsRoughTerrainLineBlocked(val3, GetGoalLookPoint()); float num4 = 0f - Vector3.Distance(val3, GetGoalLookPoint()); if (!flag2) { num4 += 2f; } if (!flag || num4 > num2) { flag = true; num2 = num4; point = val3; } } } } return flag; } private void StopClimb() { if (_character.data.isClimbing) { _character.refs.climbing.StopClimbing(); } } private void LookAt(Vector3 lookAtPos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) _character.data.lookValues = Vector2.op_Implicit(HelperFunctions.DirectionToLook(lookAtPos - _character.Head)); } private void SetSprint(bool sprinting) { bool flag = sprinting && HasStaminaForSprint(); _character.input.sprintIsPressed = flag; if (flag != _character.data.isSprinting) { _character.data.isSprinting = flag; } } private void SyncVisualState() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)_zombie.currentState == 4; bool flag2 = !_hasVisualStateSnapshot; if (!_hasVisualStateSnapshot || _lastVisualBiteColliderEnabled != flag) { _zombie.SetBiteColliderProxy(flag); _lastVisualBiteColliderEnabled = flag; flag2 = true; } if (!_hasVisualStateSnapshot || _lastVisualZombieState != _zombie.currentState) { _zombie.UpdateMouthProxy(); _lastVisualZombieState = _zombie.currentState; flag2 = true; } bool isSprinting = _character.data.isSprinting; if (!_hasVisualStateSnapshot || _lastVisualSprintState != isSprinting) { _lastVisualSprintState = isSprinting; flag2 = true; } _hasVisualStateSnapshot = true; if (flag2) { ForcePushState(); } } private void ForcePushState() { try { PushStateMethod?.Invoke(_zombie, null); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"PushState invoke failed: {arg}"); } } private bool TryProbeRouteFrom(Vector3 startPos, Vector3 dir, float forwardDistance, out RouteProbe probe) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) probe = default(RouteProbe); Bodypart bodypart = _character.GetBodypart((BodypartType)2); Vector3 val = (((Object)(object)bodypart != (Object)null) ? ((Component)bodypart).transform.position : startPos); Vector3 val2 = val - _character.Center; Vector3 val3 = startPos + val2 + Vector3.up * 0.25f; bool preferJumpGrab = HasActiveGoal() && GetGoalCenter().y - startPos.y > 0.9f; RaycastHit val4 = default(RaycastHit); if (Physics.SphereCast(val3, 0.38f, dir, ref val4, forwardDistance, TerrainMask, (QueryTriggerInteraction)1)) { bool flag = IsTrivialRoughGroundHit(startPos, dir, val4); if (!flag) { probe.ObstacleAhead = true; probe.ObstacleDistance = ((RaycastHit)(ref val4)).distance; probe.ObstaclePoint = ((RaycastHit)(ref val4)).point; } if (!flag && TryProbeClimbableFrom(startPos, dir, val4, out var climbBase, out var climbHeight, out var climbTopPoint, out var surfaceNormal)) { probe.ClimbableAhead = true; probe.ClimbBasePoint = climbBase; probe.ClimbHeightDelta = climbHeight; probe.NeedsJumpStart = climbHeight >= 1f; probe.ClimbTopPoint = climbTopPoint; probe.ClimbSurfaceNormal = surfaceNormal; } } if (!probe.ClimbableAhead && TryProbeAnyClimbableAheadFrom(startPos, dir, Mathf.Max(forwardDistance, 1.9f), preferJumpGrab, out var climbBase2, out var climbHeight2, out var needsJumpStart, out var climbTopPoint2, out var surfaceNormal2)) { probe.ClimbableAhead = true; probe.ClimbBasePoint = climbBase2; probe.ClimbHeightDelta = climbHeight2; probe.NeedsJumpStart = needsJumpStart; probe.ClimbTopPoint = climbTopPoint2; probe.ClimbSurfaceNormal = surfaceNormal2; } Vector3 point = startPos + dir * forwardDistance; if (TryFindGround(point, out var hit)) { float num = (probe.DropHeight = startPos.y - ((RaycastHit)(ref hit)).point.y); probe.DropLandingPoint = ((RaycastHit)(ref hit)).point; if (num > 0.5f && num <= 10f) { probe.SafeWalkDrop = true; } if (num > 10f) { probe.UnsafeDropAhead = true; } if (num > 0.5f && num <= 20f) { probe.SafeJumpDrop = true; } } else { probe.UnsafeDropAhead = true; probe.DropHeight = 21f; } if (probe.UnsafeDropAhead && TryProbeGapJumpFrom(startPos, dir, out var landingPoint, out var landingDrop)) { probe.GapJumpable = true; probe.GapLandingPoint = landingPoint; probe.GapLandingDrop = landingDrop; } return true; } private bool IsTrivialRoughGroundHit(Vector3 center, Vector3 dir, RaycastHit hit) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Vector3 normal = ((RaycastHit)(ref hit)).normal; if (((Vector3)(ref normal)).sqrMagnitude >= 0.01f && Vector3.Angle(((RaycastHit)(ref hit)).normal, Vector3.up) <= 68f) { return true; } Vector3 point = center + dir * Mathf.Clamp(((RaycastHit)(ref hit)).distance + 0.55f, 0.45f, 1.65f); if (!TryFindGround(point, out var hit2)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal)) { return false; } float num = ((RaycastHit)(ref hit2)).point.y - center.y; float num2 = ((RaycastHit)(ref hit)).point.y - center.y; return num >= -0.9f && num <= 0.72f && num2 <= 0.85f; } private bool TryProbeClimbableFrom(Vector3 center, Vector3 dir, RaycastHit obstacleHit, out Vector3 climbBase, out float climbHeight, out Vector3 climbTopPoint, out Vector3 surfaceNormal) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) climbBase = Vector3.zero; climbHeight = 0f; climbTopPoint = Vector3.zero; surfaceNormal = Vector3.zero; Vector3 val = ((RaycastHit)(ref obstacleHit)).point + dir * 0.45f + Vector3.up * 5.2f; RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, Vector3.down, ref val2, 6.2f, TerrainMask, (QueryTriggerInteraction)1)) { return false; } climbHeight = ((RaycastHit)(ref val2)).point.y - center.y; if (climbHeight < 0.2f || climbHeight > 4.2f) { return false; } if (!IsRoughClimbTopNormal(((RaycastHit)(ref val2)).normal)) { return false; } climbTopPoint = ((RaycastHit)(ref val2)).point; Vector3 normal = ((RaycastHit)(ref obstacleHit)).normal; Vector3 val3; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.01f)) { val3 = -dir; } else { normal = ((RaycastHit)(ref obstacleHit)).normal; val3 = ((Vector3)(ref normal)).normalized; } surfaceNormal = val3; climbBase = center + dir * Mathf.Max(0.6f, ((RaycastHit)(ref obstacleHit)).distance - 0.35f); return true; } private bool TryProbeAnyClimbableAheadFrom(Vector3 center, Vector3 dir, float forwardDistance, bool preferJumpGrab, out Vector3 climbBase, out float climbHeight, out bool needsJumpStart, out Vector3 climbTopPoint, out Vector3 surfaceNormal) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_015a: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0195: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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) climbBase = Vector3.zero; climbHeight = 0f; needsJumpStart = false; climbTopPoint = Vector3.zero; surfaceNormal = Vector3.zero; float[] array = new float[7] { 0.55f, 0.8f, 1.05f, 1.3f, 1.6f, 1.95f, 2.2f }; Vector3 val = center + Vector3.up * 1.2f; RaycastHit val3 = default(RaycastHit); RaycastHit val4 = default(RaycastHit); foreach (float num in array) { if (num > forwardDistance + 0.45f) { continue; } Vector3 val2 = center + dir * num; if (!Physics.Raycast(val2 + Vector3.up * 5.7f, Vector3.down, ref val3, 6.8f, TerrainMask, (QueryTriggerInteraction)1)) { continue; } float num2 = ((RaycastHit)(ref val3)).point.y - center.y; if (num2 < 0.25f || num2 > 4.6f || !IsRoughClimbTopNormal(((RaycastHit)(ref val3)).normal)) { continue; } bool flag = Physics.SphereCast(val, 0.18f, dir, ref val4, num + 0.4f, TerrainMask, (QueryTriggerInteraction)1); if (!flag && (!preferJumpGrab || !(num2 >= 1f))) { continue; } climbBase = center + dir * Mathf.Clamp(num - 0.18f, 0.45f, forwardDistance); climbHeight = num2; needsJumpStart = num2 >= 1f; climbTopPoint = ((RaycastHit)(ref val3)).point; Vector3 val5; if (flag) { Vector3 normal = ((RaycastHit)(ref val4)).normal; if (((Vector3)(ref normal)).sqrMagnitude > 0.01f) { normal = ((RaycastHit)(ref val4)).normal; val5 = ((Vector3)(ref normal)).normalized; goto IL_01d4; } } val5 = -dir; goto IL_01d4; IL_01d4: surfaceNormal = val5; return true; } return false; } private bool TryProbeGapJumpFrom(Vector3 center, Vector3 dir, out Vector3 landingPoint, out float landingDrop) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: 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_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) landingPoint = Vector3.zero; landingDrop = 0f; Vector3 point = center + dir * 1.8f; Vector3 point2 = center + dir * 4.8f; RaycastHit hit; bool flag = TryFindGround(point, out hit); RaycastHit hit2; bool flag2 = TryFindGround(point2, out hit2); RaycastHit val = default(RaycastHit); bool flag3 = Physics.SphereCast(center + Vector3.up * 1f, 0.22f, dir, ref val, 1.8f, TerrainMask, (QueryTriggerInteraction)1); if (!flag2) { return false; } landingDrop = center.y - ((RaycastHit)(ref hit2)).point.y; if (landingDrop > 20f) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal)) { return false; } if (flag) { float num = center.y - ((RaycastHit)(ref hit)).point.y; if (num > 10f) { landingPoint = ((RaycastHit)(ref hit2)).point; return true; } if (flag3) { Vector3 val2 = ((RaycastHit)(ref val)).point + dir * 0.15f + Vector3.up * 2.5f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, Vector3.down, ref val3, 2.9f, TerrainMask, (QueryTriggerInteraction)1)) { float num2 = ((RaycastHit)(ref val3)).point.y - center.y; if (num2 >= 0.15f && num2 <= 1.1f) { return false; } } landingPoint = ((RaycastHit)(ref hit2)).point; return true; } return false; } landingPoint = ((RaycastHit)(ref hit2)).point; return true; } private bool IsFollowingRoute() { return _hasActiveSegment || _segmentQueue.Count > 0; } private Vector3 GetCurrentDrivePoint() { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (_hasActiveSegment) { return _activeSegment.Goal; } return GetGoalLookPoint(); } private bool HasGoalPointChanged(Vector3 newGoal) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!_hadAcceptedGoalPoint) { return true; } return Vector3.Distance(_lastAcceptedGoalPoint, newGoal) > 1f; } private void ResetRouteForNewGoal(Vector3 newGoal, int instructionSerial = 0, bool allowGoalParking = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); ClearGuidePlannerCaches(); ClearGoalParking(); _resolvedGoalPoint = newGoal; _hasResolvedGoalPoint = true; _resolvedGoalIsStandable = false; _rawGoalIsStandable = false; _hasLastResolvedRawGoal = false; _nextReplanTime = 0f; _nextResolvedGoalRefreshTime = 0f; _stuckCount = 0; _failedClimbCount = 0; ResetFullStaminaClimbRetry(); _repositionUntil = 0f; _goalInstructionSerial = ((instructionSerial > 0) ? instructionSerial : (_goalInstructionSerial + 1)); _allowGoalParking = allowGoalParking; _lastAcceptedGoalPoint = newGoal; _hadAcceptedGoalPoint = true; } private bool TryBuildImmediateJumpGrabPlanFrom(Vector3 startPos, Vector3 goalCenter, out PathPlan plan) { //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) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); Vector3 val = goalCenter - startPos; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); float magnitude = ((Vector3)(ref val2)).magnitude; float num = goalCenter.y - startPos.y; if (magnitude > 3.2f) { return false; } if (num < 0.55f || num > 4.8f) { return false; } Vector3 dir = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : ((Component)_character).transform.forward); if (!TryProbeAnyClimbableAheadFrom(startPos, dir, Mathf.Max(1.6f, magnitude + 0.35f), preferJumpGrab: true, out var climbBase, out var climbHeight, out var needsJumpStart, out var climbTopPoint, out var surfaceNormal)) { return false; } if (climbHeight < 0.45f || climbHeight > 4.6f) { return false; } Vector3 val3 = ((climbTopPoint != Vector3.zero) ? climbTopPoint : climbBase); float num2 = Vector3.Distance(startPos, goalCenter) - Vector3.Distance(val3, goalCenter); if (num2 < 0.2f && num < 1.3f) { return false; } float num3 = HelperFunctions.FlatDistance(val3, goalCenter); float num4 = Mathf.Abs(val3.y - goalCenter.y); if ((!(num3 <= 1.35f) || !(num4 <= 1.75f)) && num2 < 0.55f) { return false; } Vector3 val4 = goalCenter + Vector3.up * 0.15f; plan.Action = (needsJumpStart ? PathActionType.JumpGrab : PathActionType.Climb); plan.Anchor = climbBase; plan.Goal = val4; plan.TargetAbove = true; plan.NeedsJumpStart = needsJumpStart; plan.ClimbTopPoint = climbTopPoint; plan.ClimbSurfaceNormal = surfaceNormal; plan.EstimatedClimbHeight = Mathf.Max(climbHeight, num); plan.IsTallWall = plan.EstimatedClimbHeight >= 2.15f; plan.RequiredStamina = EstimateRequiredClimbStamina(plan.EstimatedClimbHeight, targetAbove: true, plan.IsTallWall); plan.ReachableWithinRecoverableBudget = plan.RequiredStamina <= GetRecoverableStaminaCeiling(); plan.ProjectedEndPoint = ((climbTopPoint != Vector3.zero) ? climbTopPoint : val4); plan.HasProjectedEndPoint = true; plan.Score = 12f + num2 - num3 * 0.35f; if (needsJumpStart) { plan.JumpGrabAimPoint = ((climbTopPoint != Vector3.zero) ? climbTopPoint : goalCenter) + Vector3.up * 0.1f; plan.JumpGrabHorizontalDistance = magnitude; } return true; } private bool TryFindBestLocalPlanFrom(Vector3 startPos, Vector3 toTargetDir, float currentFlatDist, bool targetAbove, out PathPlan bestPlan) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_035a: 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_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: 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_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) bestPlan = new PathPlan(); if (!HasActiveGoal()) { return false; } bool flag = GetGoalCenter().y - startPos.y < -1.25f; bool flag2 = false; if (TryProbeRouteFrom(startPos, toTargetDir, 2.2f, out var probe)) { flag2 = probe.ObstacleAhead && !probe.ClimbableAhead; } bool flag3 = false; float num = float.NegativeInfinity; float[] searchAngles = SearchAngles; foreach (float num2 in searchAngles) { Vector3 val = Quaternion.AngleAxis(num2, Vector3.up) * toTargetDir; if (!TryProbeRouteFrom(startPos, val, 2.2f, out var probe2)) { continue; } Vector3 point = startPos + val * 3f; if (!TryFindGround(point, out var hit)) { continue; } float num3 = startPos.y - ((RaycastHit)(ref hit)).point.y; if (num3 > 10f) { continue; } float num4 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); float num5 = currentFlatDist - num4; float blockedPenalty = GetBlockedPenalty(((RaycastHit)(ref hit)).point); float num6 = Mathf.Abs(num2) * 0.015f; float num7 = num5 - num6 - blockedPenalty; PathPlan plan = new PathPlan(); if (flag) { if (probe2.SafeWalkDrop) { plan.Action = PathActionType.DropDown; plan.Goal = probe2.DropLandingPoint; plan.Anchor = ((RaycastHit)(ref hit)).point; plan.TargetAbove = false; plan.RequiredStamina = 0.02f; plan.ExpectedDropHeight = probe2.DropHeight; plan.UsesJumpDropImmunity = false; plan.ReachableWithinRecoverableBudget = true; num7 += 1.35f; } else if (probe2.SafeJumpDrop) { plan.Action = PathActionType.DropDown; plan.Goal = probe2.DropLandingPoint; plan.Anchor = ((RaycastHit)(ref hit)).point; plan.TargetAbove = false; plan.RequiredStamina = 0.08f; plan.ExpectedDropHeight = probe2.DropHeight; plan.UsesJumpDropImmunity = true; plan.ReachableWithinRecoverableBudget = true; num7 += 1.05f; } else { plan.Action = PathActionType.Detour; plan.Goal = ((RaycastHit)(ref hit)).point; plan.Anchor = ((RaycastHit)(ref hit)).point; plan.TargetAbove = false; plan.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)); plan.ReachableWithinRecoverableBudget = true; num7 += 0.85f; } num7 = (plan.Score = num7 - GetFailedSegmentPenalty(plan)); if (!flag3 || num7 > num) { flag3 = true; num = num7; bestPlan = plan; } continue; } if ((probe2.UnsafeDropAhead || !(num5 > 0.2f) || !(Mathf.Abs(((RaycastHit)(ref hit)).point.y - startPos.y) <= 1.8f)) && probe2.ClimbableAhead && !probe2.UnsafeDropAhead) { FillClimbPlan(ref plan, probe2.ClimbBasePoint, probe2.ClimbHeightDelta, targetAbove, probe2.NeedsJumpStart, probe2.ClimbTopPoint, probe2.ClimbSurfaceNormal); if (!IsViableClimbPlan(plan)) { plan = new PathPlan { Action = PathActionType.Detour, Goal = ((RaycastHit)(ref hit)).point, Anchor = ((RaycastHit)(ref hit)).point, TargetAbove = targetAbove, RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = ((RaycastHit)(ref hit)).point, HasProjectedEndPoint = true }; num7 += 0.5f; } else { num7 += 0.55f; } } else { plan.Action = PathActionType.Detour; plan.Goal = ((RaycastHit)(ref hit)).point; plan.Anchor = ((RaycastHit)(ref hit)).point; plan.TargetAbove = targetAbove; plan.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)); plan.ReachableWithinRecoverableBudget = true; num7 += 0.85f; if (flag2) { num7 = (probe2.ObstacleAhead ? (num7 + 0.35f) : (num7 + 1.1f)); if (num5 > 0.35f) { num7 += 0.45f; } } } num7 = (plan.Score = num7 - GetFailedSegmentPenalty(plan)); if (!flag3 || num7 > num) { flag3 = true; num = num7; bestPlan = plan; } } return flag3; } private bool TryBuildOverheadAccessPlanFrom(Vector3 startPos, Vector3 toTargetDir, float heightDelta, out PathPlan plan) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!HasActiveGoal()) { return false; } if (!TryProbeRouteFrom(startPos, toTargetDir, 2.2f, out var probe)) { return false; } float num = HelperFunctions.FlatDistance(startPos, GetGoalCenter()); if (TryFindBestLocalPlanFrom(startPos, toTargetDir, num, targetAbove: true, out PathPlan bestPlan) && bestPlan.Action == PathActionType.Detour) { float num2 = HelperFunctions.FlatDistance(bestPlan.Goal, GetGoalCenter()); if (num2 < num - 0.75f) { plan = bestPlan; return true; } } if (probe.ClimbableAhead) { FillClimbPlan(ref plan, probe.ClimbBasePoint, Mathf.Max(probe.ClimbHeightDelta, heightDelta * 0.8f), targetAbove: true, probe.NeedsJumpStart, probe.ClimbTopPoint, probe.ClimbSurfaceNormal); if (IsViableClimbPlan(plan)) { return true; } } bool flag = false; float num3 = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); float[] overheadAngles = OverheadAngles; foreach (float num4 in overheadAngles) { Vector3 val = Quaternion.AngleAxis(num4, Vector3.up) * toTargetDir; if (!TryProbeRouteFrom(startPos, val, 2.2f, out var probe2)) { continue; } Vector3 point = startPos + val * Mathf.Min(3.5f, 3f); if (!TryFindGround(point, out var hit)) { continue; } float num5 = startPos.y - ((RaycastHit)(ref hit)).point.y; if (num5 > 10f) { continue; } float num6 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); float num7 = num - num6; float num8 = Mathf.Abs(num4) * 0.02f; float blockedPenalty = GetBlockedPenalty(((RaycastHit)(ref hit)).point); PathPlan plan2 = new PathPlan(); float num9 = num7 - num8 - blockedPenalty; if (probe2.ClimbableAhead) { FillClimbPlan(ref plan2, probe2.ClimbBasePoint, Mathf.Max(probe2.ClimbHeightDelta, heightDelta * 0.8f), targetAbove: true, probe2.NeedsJumpStart, probe2.ClimbTopPoint, probe2.ClimbSurfaceNormal); if (!IsViableClimbPlan(plan2)) { continue; } num9 += 1.2f; } else if (probe2.GapJumpable) { plan2.Action = PathActionType.GapJump; plan2.Goal = probe2.GapLandingPoint; plan2.Anchor = startPos + val * 1f; plan2.TargetAbove = true; plan2.RequiredStamina = Mathf.Clamp(0.2f + probe2.GapLandingDrop * 0.05f, 0.2f, 0.55f); plan2.ReachableWithinRecoverableBudget = plan2.RequiredStamina <= GetRecoverableStaminaCeiling(); num9 += 1.05f; } else { plan2.Action = PathActionType.Detour; plan2.Goal = ((RaycastHit)(ref hit)).point; plan2.Anchor = ((RaycastHit)(ref hit)).point; plan2.TargetAbove = true; plan2.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)); plan2.ReachableWithinRecoverableBudget = true; num9 += 1f; } num9 = (plan2.Score = num9 - GetFailedSegmentPenalty(plan2)); if (!flag || num9 > num3) { flag = true; num3 = num9; pathPlan = plan2; } } if (flag) { plan = pathPlan; return true; } return false; } private bool TryBuildVerticalDropPlanFrom(Vector3 startPos, float heightDelta, out PathPlan plan) { //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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_014d: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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) plan = new PathPlan(); if (!HasActiveGoal() || heightDelta >= -1.25f) { return false; } Vector3 goalCenter = GetGoalCenter(); Vector3 val = (((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) ? _character.data.lookDirection_Flat : Vector3.zero); if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_character != (Object)null) { val = ((Component)_character).transform.forward; } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); bool flag = false; float num = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); float[] array = new float[12] { 0f, 30f, -30f, 60f, -60f, 90f, -90f, 120f, -120f, 150f, -150f, 180f }; for (int i = 0; i < array.Length; i++) { Vector3 dir = Quaternion.AngleAxis(array[i], Vector3.up) * val; if (TryFindDropLedgeInDirection(startPos, dir, out PathPlan plan2)) { Vector3 val2 = (plan2.HasProjectedEndPoint ? plan2.ProjectedEndPoint : plan2.Goal); float num2 = Vector3.Distance(val2, goalCenter); float num3 = HelperFunctions.FlatDistance(startPos, plan2.Anchor); float num4 = Mathf.Abs(val2.y - goalCenter.y); float num5 = Mathf.Abs(array[i]) * 0.006f; float score = plan2.Score; score -= num2 * 1.45f; score -= num3 * 0.1f; score -= num4 * 0.45f; score -= num5; score -= GetFailedSegmentPenalty(plan2); score -= GetBlockedPenalty(plan2.Anchor); if (HelperFunctions.FlatDistance(startPos, goalCenter) <= 0.35f) { score -= num3 * 0.35f; } plan2.Score = score; if (!flag || score > num) { flag = true; num = score; pathPlan = plan2; } } } if (!flag) { return false; } plan = pathPlan; return true; } private bool TryFindDropLedgeInDirection(Vector3 startPos, Vector3 dir, out PathPlan plan) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_0122: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_014e: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); float[] array = new float[9] { 0.8f, 1.15f, 1.55f, 2.05f, 2.7f, 3.45f, 4.35f, 5.35f, 6.5f }; float[] array2 = new float[6] { 0.55f, 0.9f, 1.35f, 1.9f, 2.55f, 3.35f }; Vector3 val = startPos; RaycastHit hit; bool flag = TryFindGround(startPos, out hit); if (flag) { val = ((RaycastHit)(ref hit)).point; } foreach (float num in array) { if (num > 7f) { break; } Vector3 point = startPos + dir * num; if (TryFindGround(point, out var hit2)) { float num2 = startPos.y - ((RaycastHit)(ref hit2)).point.y; bool flag2 = IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal); if (num2 > 0.5f && num2 <= 20f && flag2) { Vector3 anchor = (flag ? val : (startPos + dir * Mathf.Max(0.35f, num - 0.55f))); return CreateDropOrEdgePlan(startPos, anchor, ((RaycastHit)(ref hit2)).point, num2, out plan); } if (flag2 && Mathf.Abs(((RaycastHit)(ref hit2)).point.y - startPos.y) <= 1.1f) { val = ((RaycastHit)(ref hit2)).point; flag = true; continue; } } if (!flag) { continue; } for (int j = 0; j < array2.Length; j++) { float num3 = num + array2[j]; if (num3 > 10.5f) { break; } Vector3 point2 = startPos + dir * num3; if (TryFindGround(point2, out var hit3) && IsRoughStandableNormal(((RaycastHit)(ref hit3)).normal)) { float num4 = startPos.y - ((RaycastHit)(ref hit3)).point.y; if (!(num4 <= 0.5f) && !(num4 > 20f)) { return CreateDropOrEdgePlan(startPos, val, ((RaycastHit)(ref hit3)).point, num4, out plan); } } } } return false; } private bool CreateDropOrEdgePlan(Vector3 startPos, Vector3 anchor, Vector3 landing, float drop, out PathPlan plan) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); float num = HelperFunctions.FlatDistance(startPos, anchor); bool flag = num <= 1.15f; bool flag2 = drop <= 10f; if (flag) { plan.Action = PathActionType.DropDown; plan.Goal = landing; plan.Anchor = anchor; plan.TargetAbove = false; plan.RequiredStamina = (flag2 ? 0.02f : 0.08f); plan.ExpectedDropHeight = drop; plan.UsesJumpDropImmunity = !flag2; plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = landing; plan.HasProjectedEndPoint = true; plan.Score = 5f - drop * 0.025f; return true; } plan.Action = PathActionType.Detour; plan.Goal = anchor; plan.Anchor = anchor; plan.TargetAbove = false; plan.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, anchor)); plan.ExpectedDropHeight = drop; plan.UsesJumpDropImmunity = !flag2; plan.ReachableWithinRecoverableBudget = true; plan.ProjectedEndPoint = anchor; plan.HasProjectedEndPoint = true; plan.Score = 3.25f - num * 0.1f - drop * 0.015f; return true; } private bool TryBuildDropDownPlanFrom(Vector3 startPos, Vector3 toTargetDir, float currentFlatDist, float heightDelta, out PathPlan plan) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!HasActiveGoal()) { return false; } if (!TryProbeRouteFrom(startPos, toTargetDir, 2.2f, out var probe)) { return false; } if (TryCreateImmediateDropPlan(startPos, toTargetDir, currentFlatDist, probe, out plan)) { return true; } bool flag = false; float num = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); float[] overheadAngles = OverheadAngles; foreach (float num2 in overheadAngles) { Vector3 val = Quaternion.AngleAxis(num2, Vector3.up) * toTargetDir; if (!TryProbeRouteFrom(startPos, val, 2.2f, out var probe2)) { continue; } Vector3 point = startPos + val * 3.2f; if (TryFindGround(point, out var hit)) { float num3 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); float num4 = currentFlatDist - num3; float num5 = Mathf.Abs(num2) * 0.02f; float blockedPenalty = GetBlockedPenalty(((RaycastHit)(ref hit)).point); float num6 = num4 - num5 - blockedPenalty; PathPlan pathPlan2 = new PathPlan(); if (probe2.SafeWalkDrop) { pathPlan2.Action = PathActionType.DropDown; pathPlan2.Goal = probe2.DropLandingPoint; pathPlan2.Anchor = ((RaycastHit)(ref hit)).point; pathPlan2.TargetAbove = false; pathPlan2.RequiredStamina = 0.02f; pathPlan2.ExpectedDropHeight = probe2.DropHeight; pathPlan2.UsesJumpDropImmunity = false; pathPlan2.ReachableWithinRecoverableBudget = true; num6 += 1.8f; } else if (probe2.SafeJumpDrop) { pathPlan2.Action = PathActionType.DropDown; pathPlan2.Goal = probe2.DropLandingPoint; pathPlan2.Anchor = ((RaycastHit)(ref hit)).point; pathPlan2.TargetAbove = false; pathPlan2.RequiredStamina = 0.08f; pathPlan2.ExpectedDropHeight = probe2.DropHeight; pathPlan2.UsesJumpDropImmunity = true; pathPlan2.ReachableWithinRecoverableBudget = true; num6 += 1.4f; } else { pathPlan2.Action = PathActionType.Detour; pathPlan2.Goal = ((RaycastHit)(ref hit)).point; pathPlan2.Anchor = ((RaycastHit)(ref hit)).point; pathPlan2.TargetAbove = false; pathPlan2.RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)); pathPlan2.ExpectedDropHeight = 0f; pathPlan2.UsesJumpDropImmunity = false; pathPlan2.ReachableWithinRecoverableBudget = pathPlan2.RequiredStamina <= GetRecoverableStaminaCeiling(); num6 += 0.3f; } num6 = (pathPlan2.Score = num6 - GetFailedSegmentPenalty(pathPlan2)); if (!flag || num6 > num) { flag = true; num = num6; pathPlan = pathPlan2; } } } if (flag) { plan = pathPlan; return true; } return false; } private bool TryBuildObstacleBypassPlanFrom(Vector3 startPos, Vector3 toTargetDir, float currentFlatDist, bool targetAbove, out PathPlan plan) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!HasActiveGoal()) { return false; } if (!TryProbeRouteFrom(startPos, toTargetDir, 2.2f, out var probe)) { return false; } if ((!probe.ObstacleAhead || probe.ClimbableAhead) && !probe.UnsafeDropAhead) { return false; } bool flag = false; float num = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); float[] array = new float[9] { 0f, 18f, -18f, 35f, -35f, 55f, -55f, 75f, -75f }; foreach (float num2 in array) { Vector3 val = Quaternion.AngleAxis(num2, Vector3.up) * toTargetDir; if (!TryProbeRouteFrom(startPos, val, 2.2f, out var probe2)) { continue; } float blockedPenalty = GetBlockedPenalty(startPos + val * 2.2f); float num3 = Mathf.Abs(num2) * 0.018f; if (probe2.GapJumpable) { float num4 = HelperFunctions.FlatDistance(probe2.GapLandingPoint, GetGoalCenter()); float num5 = currentFlatDist - num4; if (num5 >= 0.55f) { PathPlan pathPlan2 = new PathPlan { Action = PathActionType.GapJump, Goal = probe2.GapLandingPoint, Anchor = startPos + val * Mathf.Clamp(Mathf.Max(0.9f, probe2.ObstacleAhead ? (probe2.ObstacleDistance - 0.2f) : 1f), 0.9f, 1.45f), TargetAbove = targetAbove, RequiredStamina = Mathf.Clamp(0.18f + probe2.GapLandingDrop * 0.04f, 0.18f, 0.5f), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = probe2.GapLandingPoint, HasProjectedEndPoint = true }; float num6 = num5 * 2.1f + 1.15f - num3 - blockedPenalty - GetFailedSegmentPenalty(pathPlan2); if (Mathf.Abs(num2) <= 18f) { num6 += 0.25f; } pathPlan2.Score = num6; if (!flag || num6 > num) { flag = true; num = num6; pathPlan = pathPlan2; } } } Vector3 point = startPos + val * 3f; if (!TryFindGround(point, out var hit)) { continue; } float num7 = startPos.y - ((RaycastHit)(ref hit)).point.y; if (num7 <= 10f) { float num8 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, GetGoalCenter()); float num9 = currentFlatDist - num8; bool flag2 = IsRoughTerrainLineBlocked(startPos, ((RaycastHit)(ref hit)).point); float num10 = num9 + 0.75f - num3 - blockedPenalty - (flag2 ? 0.65f : 0f); PathPlan pathPlan3 = new PathPlan { Action = PathActionType.Detour, Goal = ((RaycastHit)(ref hit)).point, Anchor = ((RaycastHit)(ref hit)).point, TargetAbove = targetAbove, RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = ((RaycastHit)(ref hit)).point, HasProjectedEndPoint = true }; num10 = (pathPlan3.Score = num10 - GetFailedSegmentPenalty(pathPlan3)); if (!flag || num10 > num) { flag = true; num = num10; pathPlan = pathPlan3; } } } if (flag) { plan = pathPlan; return true; } return false; } private bool TryBuildTerrainFallbackPlanFrom(Vector3 startPos, Vector3 preferredDir, float currentFlatDist, bool targetAbove, out PathPlan plan) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_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_0187: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!HasActiveGoal()) { return false; } Vector3 val = preferredDir; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { val = _character.data.lookDirection_Flat; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_character != (Object)null) { val = ((Component)_character).transform.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 goalCenter = GetGoalCenter(); float num = ((currentFlatDist > 0.01f) ? currentFlatDist : HelperFunctions.FlatDistance(startPos, goalCenter)); float num2 = Mathf.Abs(goalCenter.y - startPos.y); bool flag = goalCenter.y - startPos.y < -1.25f; bool flag2 = false; float num3 = float.NegativeInfinity; PathPlan pathPlan = new PathPlan(); for (int i = 0; i < OverheadAngles.Length; i++) { float num4 = OverheadAngles[i]; Vector3 val2 = Quaternion.AngleAxis(num4, Vector3.up) * val; for (int j = 0; j < TerrainFallbackDistances.Length; j++) { float num5 = TerrainFallbackDistances[j]; Vector3 point = startPos + val2 * num5; if (!TryFindGround(point, out var hit) || !IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { continue; } float num6 = ((RaycastHit)(ref hit)).point.y - startPos.y; float num7 = startPos.y - ((RaycastHit)(ref hit)).point.y; if (num6 > 2.15f || num7 > 6.5f) { continue; } float num8 = HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, goalCenter); float num9 = num - num8; float num10 = num2 - Mathf.Abs(goalCenter.y - ((RaycastHit)(ref hit)).point.y); if (!(num9 < -0.25f) || !(num10 < 0.35f) || _stuckCount > 0 || _failedClimbCount > 0) { bool flag3 = IsRoughTerrainLineBlocked(startPos, ((RaycastHit)(ref hit)).point); bool flag4 = !flag3; float num11 = 0f; num11 += num9 * 1.55f; num11 += num10 * 0.95f; num11 -= Mathf.Abs(num4) * 0.012f; num11 -= num5 * 0.035f; num11 -= Mathf.Abs(num6) * 0.07f; num11 -= Mathf.Max(0f, num7 - 1f) * 0.035f; num11 -= GetBlockedPenalty(((RaycastHit)(ref hit)).point); num11 = ((!flag4) ? (num11 - 0.45f) : (num11 + 0.65f)); if (flag && num7 > 0.35f) { num11 += Mathf.Min(num7, 4f) * 0.3f; } PathPlan pathPlan2 = new PathPlan { Action = (flag4 ? PathActionType.Direct : PathActionType.Detour), Goal = ((RaycastHit)(ref hit)).point, Anchor = ((RaycastHit)(ref hit)).point, TargetAbove = targetAbove, RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(startPos, ((RaycastHit)(ref hit)).point)), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = ((RaycastHit)(ref hit)).point, HasProjectedEndPoint = true }; num11 = (pathPlan2.Score = num11 - GetFailedSegmentPenalty(pathPlan2)); if (!flag2 || num11 > num3) { flag2 = true; num3 = num11; pathPlan = pathPlan2; } } } } if (!flag2) { return false; } plan = pathPlan; return true; } private bool TryCreateRoughWalkDirectPlan(Vector3 startPos, Vector3 dir, float flatDist, Vector3 goalLook, bool targetAbove, out PathPlan plan) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_007c: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0170: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (flatDist < 0.2f) { return false; } float num = Mathf.Min(flatDist, 4.25f); Vector3 val = startPos; if (TryFindGround(startPos, out var hit)) { val = ((RaycastHit)(ref hit)).point; } int num2 = Mathf.Clamp(Mathf.CeilToInt(num / 0.55f), 1, 8); float num3 = 0f; float num4 = 0f; for (int i = 1; i <= num2; i++) { float num5 = num * ((float)i / (float)num2); Vector3 point = startPos + dir * num5; if (!TryFindGround(point, out var hit2)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal)) { return false; } float num6 = ((RaycastHit)(ref hit2)).point.y - val.y; float num7 = val.y - ((RaycastHit)(ref hit2)).point.y; if (num6 > 0.72f || num7 > 0.9f) { return false; } if (num6 > 0f) { num4 += num6; } if (num7 > 0f) { num3 += num7; } val = ((RaycastHit)(ref hit2)).point; } RaycastHit val2 = default(RaycastHit); if (Physics.SphereCast(startPos + Vector3.up * 1.45f, 0.18f, dir, ref val2, Mathf.Min(num, 2.2f), TerrainMask, (QueryTriggerInteraction)1)) { float num8 = ((RaycastHit)(ref val2)).point.y - startPos.y; if (!(num8 <= 0.85f) && !(Vector3.Angle(((RaycastHit)(ref val2)).normal, Vector3.up) <= 68f)) { return false; } } plan = new PathPlan { Action = PathActionType.Direct, Goal = goalLook, Anchor = goalLook, TargetAbove = targetAbove, RequiredStamina = EstimateGroundChaseCost(num), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = val, HasProjectedEndPoint = true, Score = 2.2f + num3 * 0.25f - num4 * 0.1f }; return true; } private void ExecuteGroundPlan(PathPlan plan) { //IL_003a: 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_013e: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0534: 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_0060: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_0380: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) switch (plan.Action) { case PathActionType.Direct: { LookAt(plan.Goal); float num3 = (HasActiveGoal() ? HelperFunctions.FlatDistance(_character.Center, GetGoalCenter()) : 999f); float num4 = (HasActiveGoal() ? Mathf.Abs(GetGoalCenter().y - _character.Center.y) : 999f); bool flag3 = num3 <= 1.65f && num4 <= 1.15f; bool sprintRequested2 = ((!flag3) ? ShouldAggressiveSprint() : (num3 > 0.9f && GetStamina01() > 0.05f)); bool tryJump2 = !flag3 || ShouldHopSmallObstacleTowards(plan.Goal); WalkTowards(plan.Goal, flag3 ? 0.85f : 1f, tryClimb: true, tryJump2, sprintRequested2); if (!flag3) { TryTravelHop(); } break; } case PathActionType.Detour: { LookAt(plan.Goal); bool sprintRequested = Vector3.Distance(_character.Center, plan.Goal) > 4f || ShouldAggressiveSprint(); bool tryJump = ShouldHopSmallObstacleTowards(plan.Goal); WalkTowards(plan.Goal, 1f, tryClimb: false, tryJump, sprintRequested); TryTravelHop(); break; } case PathActionType.Climb: { float num2 = Vector3.Distance(_character.Center, plan.Anchor); bool flag = num2 <= 1.35f; Vector3 val2 = (flag ? plan.Goal : plan.Anchor); if (!HasEnoughStaminaToStartClimb(plan)) { LookAt(flag ? plan.Anchor : val2); if (!flag) { WalkTowards(plan.Anchor, 0.75f, tryClimb: false, tryJump: false, sprintRequested: false); break; } _character.input.movementInput = Vector2.zero; SetSprint(sprinting: false); } else { LookAt(val2); bool flag2 = !flag && num2 > 1.8f && ShouldAggressiveSprint(); WalkTowards(val2, flag ? 0.95f : 1f, tryClimb: true, tryJump: false, flag2 && !flag); TryForceJumpGrab(plan, flag); } break; } case PathActionType.JumpGrab: { float num5 = Vector3.Distance(_character.Center, plan.Anchor); bool flag4 = num5 <= 1.15f; Vector3 lookAtPos = ((plan.JumpGrabAimPoint != Vector3.zero) ? plan.JumpGrabAimPoint : plan.Goal); if (!flag4) { LookAt(plan.Anchor); bool sprintRequested3 = num5 > 2f && ShouldAggressiveSprint(); bool tryClimb = num5 <= 1.85f && HasEnoughStaminaToStartClimb(plan); WalkTowards(plan.Anchor, 1f, tryClimb, ShouldHopSmallObstacleTowards(plan.Anchor), sprintRequested3); break; } if (!HasEnoughStaminaToStartClimb(plan)) { LookAt(lookAtPos); _character.input.movementInput = Vector2.zero; SetSprint(sprinting: false); break; } LookAt(lookAtPos); _character.input.movementInput = new Vector2(0f, 1f); SetSprint(sprinting: false); _character.refs.climbing.TryClimb(1.6f); if (_character.data.isGrounded && Time.time - _lastAutoJumpTime >= 0.2f) { _character.input.jumpWasPressed = true; _lastAutoJumpTime = Time.time; } break; } case PathActionType.GapJump: { LookAt(plan.Goal); float num = Vector3.Distance(_character.Center, plan.Anchor); if (num > 1.15f) { WalkTowards(plan.Anchor, 1f, tryClimb: false, tryJump: false, HasStaminaForSprint()); break; } if (IsLowStaminaForHeavyAction()) { HoldForStamina(plan.Goal); break; } SetSprint(HasStaminaForSprint()); _character.input.movementInput = new Vector2(0f, 1f); LookAt(plan.Goal); if (_character.data.isGrounded && GetStamina01() >= plan.RequiredStamina) { _character.input.jumpWasPressed = true; _lastAutoJumpTime = Time.time; } break; } case PathActionType.DropDown: { LookAt(plan.Goal); float num6 = Vector3.Distance(_character.Center, plan.Anchor); if (num6 > 1.1f) { bool sprintRequested4 = ShouldAggressiveSprint(); WalkTowards(plan.Anchor, 1f, tryClimb: false, tryJump: false, sprintRequested4); } else if (plan.UsesJumpDropImmunity && !IsLowStaminaForHeavyAction() && GetStamina01() >= plan.RequiredStamina) { SetSprint(HasStaminaForSprint()); _character.input.jumpWasPressed = true; _lastAutoJumpTime = Time.time; } else { SetSprint(sprinting: false); _character.input.movementInput = new Vector2(0f, 1f); } break; } case PathActionType.WaitForStamina: ResetInput(); SetSprint(sprinting: false); if (_character.data.isClimbing) { StopClimb(); } _character.input.movementInput = Vector2.zero; break; default: { Vector3 val = (HasActiveGoal() ? GetGoalLookPoint() : _character.Head); LookAt(val); WalkTowards(val, 0.7f, tryClimb: false, tryJump: false, sprintRequested: false); break; } } } private bool ShouldAggressiveSprint() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return false; } if (!HasStaminaForSprint()) { return false; } float num = Vector3.Distance(_character.Center, GetGoalCenter()); if (_timeInChase > _zombie.chaseTimeBeforeSprint && num > 3f) { return true; } if (Time.time - _lastSeenTargetTime < 1f && num > 5f) { return true; } return num > 2.5f; } private void TryTravelHop() { //IL_0056: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if (_character.data.isGrounded && !(Time.time - _lastAutoJumpTime < 0.2f) && HasActiveGoal()) { float num = Vector3.Distance(_character.Center, GetGoalCenter()); if (!(num < 2f) && (GetStamina01() <= 0.35f || !HasStaminaForSprint()) && (!IsLowStaminaForHeavyAction() || IsFlatTravelHopAllowed(GetGoalCenter()))) { SetSprint(!IsLowStaminaForHeavyAction() && HasStaminaForSprint()); _character.input.movementInput = new Vector2(0f, 1f); _character.input.jumpWasPressed = true; _lastAutoJumpTime = Time.time; } } } private bool ShouldHopSmallObstacleTowards(Vector3 targetPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = targetPos - _character.Center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = _character.Head + Vector3.down * 0.45f; RaycastHit obstacleHit = default(RaycastHit); if (!Physics.Raycast(val2, val, ref obstacleHit, 1f, TerrainMask, (QueryTriggerInteraction)1)) { return false; } Vector3 point = _character.Center + val * 0.35f; if (!TryFindGround(point, out var hit)) { return false; } float num = Mathf.Abs(((RaycastHit)(ref hit)).point.y - _character.Center.y); if (num > 0.45f) { return false; } Vector3 val3 = ((RaycastHit)(ref obstacleHit)).point + val * 0.18f + Vector3.up * 1.9000001f; RaycastHit val4 = default(RaycastHit); if (!Physics.Raycast(val3, Vector3.down, ref val4, 2.3000002f, TerrainMask, (QueryTriggerInteraction)1)) { return false; } float num2 = ((RaycastHit)(ref val4)).point.y - _character.Center.y; if (num2 < 0.15f || num2 > 1.1f) { return false; } if (num2 >= 1f) { return false; } if (!IsRoughClimbTopNormal(((RaycastHit)(ref val4)).normal)) { return false; } if (TryProbeClimbableFrom(_character.Center, val, obstacleHit, out var _, out var climbHeight, out var _, out var _) && (climbHeight >= 1f || num2 > 0.95f)) { return false; } Vector3 point2 = _character.Center + val * 1.15f; if (!TryFindGround(point2, out var hit2)) { return false; } float num3 = Mathf.Abs(((RaycastHit)(ref hit2)).point.y - _character.Center.y); if (num3 > 0.85f) { return false; } return true; } private PathPlan BuildPathPlanFrom(Vector3 startPos) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return new PathPlan { Action = PathActionType.None }; } Vector3 rawGoalCenter = GetRawGoalCenter(); Vector3 val = (_hasResolvedGoalPoint ? _resolvedGoalPoint : rawGoalCenter); bool flag = false; if (_hasResolvedGoalPoint) { float num = HelperFunctions.FlatDistance(rawGoalCenter, val); float num2 = Mathf.Abs(rawGoalCenter.y - val.y); float num3 = HelperFunctions.FlatDistance(startPos, rawGoalCenter); if (_resolvedGoalIsStandable || num >= 0.55f || num2 >= 0.45f || num3 <= 2.2f) { flag = true; } } Vector3 val2 = (flag ? val : rawGoalCenter); Vector3 val3 = val2 + Vector3.up * 0.15f; Vector3 val4 = val2 - startPos; Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(val4.x, 0f, val4.z); float magnitude = ((Vector3)(ref val5)).magnitude; float num4 = val2.y - startPos.y; bool flag2 = num4 > 1.4f; bool flag3 = num4 < -1.25f; if (flag3 && magnitude <= 0.35f && TryBuildVerticalDropPlanFrom(startPos, num4, out PathPlan plan)) { return plan; } if (magnitude < 0.001f) { Vector3 preferredDir = (((Object)(object)_character != (Object)null) ? ((Component)_character).transform.forward : Vector3.forward); if (TryBuildTerrainFallbackPlanFrom(startPos, preferredDir, magnitude, flag2, out PathPlan plan2)) { return plan2; } return BuildHoldPlan(val3, flag2); } Vector3 normalized = ((Vector3)(ref val5)).normalized; if (!TryProbeRouteFrom(startPos, normalized, 2.2f, out var probe)) { return BuildHoldPlan(val3, flag2); } float blockedPenalty = GetBlockedPenalty(startPos + normalized * Mathf.Min(2f, magnitude)); bool flag4 = blockedPenalty >= 1.1f || (_brainState == RobotBrainState.Reposition && Time.time < _repositionUntil); if (TryCreateRoughWalkDirectPlan(startPos, normalized, magnitude, val3, flag2, out PathPlan plan3)) { return plan3; } if (num4 > 0.55f && magnitude <= 2.35f && TryBuildImmediateJumpGrabPlanFrom(startPos, val2, out PathPlan plan4) && IsViableClimbPlan(plan4)) { return plan4; } if (flag3) { if (TryCreateImmediateDropPlan(startPos, normalized, magnitude, probe, out PathPlan plan5)) { return plan5; } if (TryBuildDropDownPlanFrom(startPos, normalized, magnitude, num4, out PathPlan plan6)) { return plan6; } if (TryBuildVerticalDropPlanFrom(startPos, num4, out PathPlan plan7)) { return plan7; } } if (num4 > 0.45f && magnitude <= 2.6999998f && probe.ClimbableAhead) { PathPlan plan8 = new PathPlan(); FillClimbPlan(ref plan8, probe.ClimbBasePoint, Mathf.Max(probe.ClimbHeightDelta, num4), targetAbove: true, probe.NeedsJumpStart, probe.ClimbTopPoint, probe.ClimbSurfaceNormal); if (IsViableClimbPlan(plan8)) { return plan8; } } if (flag2 && (probe.UnsafeDropAhead || probe.GapJumpable) && TryBuildJumpGrabPlanFrom(startPos, normalized, targetAbove: true, out PathPlan plan9) && IsViableClimbPlan(plan9)) { return plan9; } if (flag2 && probe.ClimbableAhead && !probe.UnsafeDropAhead) { PathPlan plan10 = new PathPlan(); FillClimbPlan(ref plan10, probe.ClimbBasePoint, Mathf.Max(probe.ClimbHeightDelta, num4), targetAbove: true, probe.NeedsJumpStart, probe.ClimbTopPoint, probe.ClimbSurfaceNormal); if (IsViableClimbPlan(plan10)) { return plan10; } } if (!flag4 && !probe.ObstacleAhead && !probe.UnsafeDropAhead) { return new PathPlan { Action = PathActionType.Direct, Goal = val3, Anchor = val3, TargetAbove = flag2, ProjectedEndPoint = val3, HasProjectedEndPoint = true }; } if (flag2 && TryBuildOverheadAccessPlanFrom(startPos, normalized, num4, out PathPlan plan11) && (plan11.Action != PathActionType.Detour || !(magnitude <= 2.8f) || !(num4 > 0.55f) || (!probe.ClimbableAhead && !TryBuildImmediateJumpGrabPlanFrom(startPos, val2, out PathPlan _)))) { return plan11; } if (TryFindBestLocalPlanFrom(startPos, normalized, magnitude, flag2, out PathPlan bestPlan)) { return bestPlan; } if (!flag3 && probe.ClimbableAhead) { PathPlan plan13 = new PathPlan(); FillClimbPlan(ref plan13, probe.ClimbBasePoint, Mathf.Max(probe.ClimbHeightDelta, Mathf.Abs(num4)), flag2, probe.NeedsJumpStart, probe.ClimbTopPoint, probe.ClimbSurfaceNormal); if (IsViableClimbPlan(plan13)) { return plan13; } } if (TryBuildTerrainFallbackPlanFrom(startPos, normalized, magnitude, flag2, out PathPlan plan14)) { return plan14; } return BuildHoldPlan(val3, flag2); } private void RegisterFailedSegment(PathPlan segment) { //IL_000a: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) RememberRouteChoice(segment); Vector3 direction = segment.Goal - _character.Center; direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude > 0.01f) { ((Vector3)(ref direction)).Normalize(); } _failedSegments.Add(new FailedSegmentMemory { Action = segment.Action, Position = _character.Center, Direction = direction, Until = Time.time + 4f }); } private float GetFailedSegmentPenalty(PathPlan segment) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Vector3 val = segment.Goal - _character.Center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Vector3)(ref val)).Normalize(); } for (int num2 = _failedSegments.Count - 1; num2 >= 0; num2--) { if (Time.time >= _failedSegments[num2].Until) { _failedSegments.RemoveAt(num2); } else { FailedSegmentMemory failedSegmentMemory = _failedSegments[num2]; float num3 = Vector3.Distance(_character.Center, failedSegmentMemory.Position); float num4 = ((val == Vector3.zero || failedSegmentMemory.Direction == Vector3.zero) ? 0f : Vector3.Dot(val, failedSegmentMemory.Direction)); if (failedSegmentMemory.Action == segment.Action && num3 < 4.5f && num4 > 0.7f) { num += 3f; } } } return num; } private void ReplanRoute() { if (Time.time < _nextReplanTime) { return; } if (!TryReserveRoutePlannerBudget()) { _nextReplanTime = Time.time + GetPlannerStaggerDelay(); return; } _nextReplanTime = Time.time + 0.42f + GetPlannerStaggerDelay() * 0.35f; _segmentQueue.Clear(); ClearActiveSegment(); ClearLockedClimbPlan(); List list = BuildPathSegments(); for (int i = 0; i < list.Count; i++) { _segmentQueue.Enqueue(list[i]); } if (_segmentQueue.Count > 0) { BeginSegment(_segmentQueue.Dequeue()); ResetRouteProgressWindow(); } else { _hasActiveSegment = false; } } private bool TryReserveRoutePlannerBudget() { int frameCount = Time.frameCount; if (SharedPlannerBudgetFrame != frameCount) { SharedPlannerBudgetFrame = frameCount; SharedPlannerBudgetUsed = 0; } if (SharedPlannerBudgetUsed >= 1) { return false; } SharedPlannerBudgetUsed++; return true; } private float GetPlannerStaggerDelay() { int num = 0; if ((Object)(object)_view != (Object)null) { num = Mathf.Abs(_view.ViewID); } else if ((Object)(object)_character != (Object)null) { num = Mathf.Abs(((Object)_character).GetInstanceID()); } return 0.035f + (float)(num % 9) * 0.018f; } private void LogBrainStateIfChanged() { if (_brainState != _lastLoggedBrainState) { _lastLoggedBrainState = _brainState; Plugin.Log.LogDebug((object)$"BrainState => {_brainState}"); } } private void AdvanceSegmentIfNeeded() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) if (!_hasActiveSegment) { if (_segmentQueue.Count > 0) { BeginSegment(_segmentQueue.Dequeue()); } return; } if (IsSegmentFinished(_activeSegment)) { if (IsClimbPlan(_activeSegment)) { ClearLockedClimbPlan(); } ClearActiveSegment(); if (_segmentQueue.Count > 0) { BeginSegment(_segmentQueue.Dequeue()); } else { ResetRouteProgressWindow(); } return; } float num = Time.time - _segmentStartTime; if (_activeSegment.Action == PathActionType.Detour) { float num2 = GetGoalCenter().y - _character.Center.y; if (num2 < -1.25f) { float num3 = Vector3.Distance(_character.Center, _activeSegment.Goal); if (num3 > 1.4f && num < 4.5f) { return; } if (num3 <= 1.4f) { ClearActiveSegment(); _segmentQueue.Clear(); _nextReplanTime = 0f; ReplanRoute(); return; } } } if (IsClimbPlan(_activeSegment)) { bool flag = Vector3.Distance(_character.Center, _activeSegment.Anchor) <= 2.25f; if (_character.data.isClimbing || flag) { return; } } if (_activeSegment.Action == PathActionType.GapJump) { float num4 = Vector3.Distance(_character.Center, _activeSegment.Anchor); if (num4 <= 1.6f && num < 3.8f) { return; } } if (IsSegmentFailed(_activeSegment)) { if (IsClimbPlan(_activeSegment)) { ClearLockedClimbPlan(); } RegisterFailedSegment(_activeSegment); RegisterBlockedPoint(_character.Center, 3f); _segmentQueue.Clear(); ClearActiveSegment(); ReplanRoute(); return; } bool flag2 = false; if (_activeSegment.Action == PathActionType.Detour) { float num5 = GetGoalCenter().y - _character.Center.y; if (num5 < -1.25f) { flag2 = true; } } else if (_activeSegment.Action == PathActionType.GapJump) { flag2 = true; } if (!flag2 && !IsRouteMakingNetProgress()) { RegisterFailedSegment(_activeSegment); RegisterBlockedPoint(_character.Center, 3.5f); if (IsClimbPlan(_activeSegment)) { ClearLockedClimbPlan(); } _segmentQueue.Clear(); ClearActiveSegment(); ReplanRoute(); } } private void ExecuteActiveSegment() { if (!_hasActiveSegment) { return; } if (_character.data.isClimbing) { if (!_hasLockedClimbPlan && IsClimbPlan(_activeSegment)) { LockCurrentClimbPlan(_activeSegment); } TickActiveClimb(); } else { if (IsClimbPlan(_activeSegment) && !_hasLockedClimbPlan) { LockCurrentClimbPlan(_activeSegment); } ExecuteGroundPlan(_activeSegment); } } private List BuildThreeDimensionalPathSegments() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025a: 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) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) List result = new List(); if (!HasActiveGoal()) { return result; } Vector3 spatialStandPoint = GetSpatialStandPoint(_character.Center); Vector3 goalCenter = GetGoalCenter(); bool targetAbove = goalCenter.y - spatialStandPoint.y > 1.4f; bool targetBelow = goalCenter.y - spatialStandPoint.y < -1.25f; RoutePathCacheKey key = MakeSpatialPathCacheKey(spatialStandPoint, goalCenter, targetAbove, targetBelow); if (TryGetCachedSpatialPath(key, out List segments)) { return segments; } float num = Get3DGoalDistance(spatialStandPoint, goalCenter); SpatialRouteNode spatialRouteNode = new SpatialRouteNode { Position = spatialStandPoint, Cost = 0f, Score = 0f - num, DistanceToGoal = num, Depth = 0, RemainingStamina = GetRecoverableStaminaCeiling() }; List list = new List { spatialRouteNode }; Dictionary dictionary = new Dictionary(); dictionary[MakeSpatialStateKey(spatialStandPoint, 0, spatialRouteNode.RemainingStamina)] = 0f; SpatialRouteNode spatialRouteNode2 = null; float num2 = float.NegativeInfinity; for (int i = 0; i < 4; i++) { List list2 = new List(); for (int j = 0; j < list.Count; j++) { SpatialRouteNode spatialRouteNode3 = list[j]; List list3 = BuildSpatialCandidatesFrom(spatialRouteNode3.Position, goalCenter); for (int k = 0; k < list3.Count; k++) { PathPlan pathPlan = list3[k]; Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(pathPlan); float num3 = Get3DGoalDistance(planProjectedEndPoint, goalCenter); float num4 = spatialRouteNode3.DistanceToGoal - num3; if (num4 < -1.25f && pathPlan.Action == PathActionType.Detour) { continue; } float num5 = EstimatePlanStaminaCost(pathPlan); if ((IsClimbPlan(pathPlan) || pathPlan.Action == PathActionType.GapJump || (pathPlan.Action == PathActionType.DropDown && pathPlan.UsesJumpDropImmunity)) && num5 > spatialRouteNode3.RemainingStamina + 0.03f) { continue; } float num6 = Mathf.Clamp(spatialRouteNode3.RemainingStamina - num5, 0f, GetRecoverableStaminaCeiling()); if (pathPlan.Action == PathActionType.Direct || pathPlan.Action == PathActionType.Detour || (pathPlan.Action == PathActionType.DropDown && !pathPlan.UsesJumpDropImmunity)) { num6 = GetRecoverableStaminaCeiling(); } float spatialTransitionCost = GetSpatialTransitionCost(pathPlan, spatialRouteNode3.Position, planProjectedEndPoint, goalCenter, k); float num7 = spatialRouteNode3.Cost + spatialTransitionCost; float num8 = 0f - num7 - num3 * 1.15f - Mathf.Abs(goalCenter.y - planProjectedEndPoint.y) * 0.9f; num8 += Mathf.Clamp(num4, -2f, 5f) * 1.85f; SpatialRouteStateKey key2 = MakeSpatialStateKey(planProjectedEndPoint, i + 1, num6); if (!dictionary.TryGetValue(key2, out var value) || !(num7 >= value - 0.05f)) { dictionary[key2] = num7; SpatialRouteNode spatialRouteNode4 = new SpatialRouteNode { Position = planProjectedEndPoint, Cost = num7, Score = num8, DistanceToGoal = num3, Depth = i + 1, RemainingStamina = num6 }; for (int l = 0; l < spatialRouteNode3.Segments.Count; l++) { spatialRouteNode4.Segments.Add(ClonePlan(spatialRouteNode3.Segments[l])); } PathPlan pathPlan2 = ClonePlan(pathPlan); pathPlan2.ProjectedRemainingStamina = num6; pathPlan2.PlanningDepth = i; spatialRouteNode4.Segments.Add(pathPlan2); float num9 = HelperFunctions.FlatDistance(planProjectedEndPoint, goalCenter); float num10 = Mathf.Abs(planProjectedEndPoint.y - goalCenter.y); bool flag = num9 <= 2.05f && num10 <= 1.65f; float num11 = num8; num11 = ((!flag) ? (num11 + Mathf.Max(0f, num - num3) * 1.2f) : (num11 + 12f)); if (spatialRouteNode2 == null || num11 > num2) { spatialRouteNode2 = spatialRouteNode4; num2 = num11; } list2.Add(spatialRouteNode4); } } } if (list2.Count == 0) { break; } list2.Sort((SpatialRouteNode a, SpatialRouteNode b) => b.Score.CompareTo(a.Score)); if (list2.Count > 8) { list2.RemoveRange(8, list2.Count - 8); } list = list2; } if (spatialRouteNode2 == null || spatialRouteNode2.Segments.Count == 0) { return result; } Vector3 position = spatialRouteNode2.Position; float num12 = num - Get3DGoalDistance(position, goalCenter); float num13 = Mathf.Abs(goalCenter.y - spatialStandPoint.y) - Mathf.Abs(goalCenter.y - position.y); if (num12 < 0.35f && num13 < 0.45f && _stuckCount <= 0 && _failedClimbCount <= 0) { return result; } List list4 = new List(); int num14 = Mathf.Min(spatialRouteNode2.Segments.Count, 3); for (int m = 0; m < num14; m++) { list4.Add(ClonePlan(spatialRouteNode2.Segments[m])); } StoreSpatialPathCache(key, list4); return list4; } private List BuildSpatialCandidatesFrom(Vector3 nodePosition, Vector3 goal) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) List list = new List(18); Vector3 val = goal - nodePosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { val = _character.data.lookDirection_Flat; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)_character != (Object)null) { val = ((Component)_character).transform.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); bool flag = goal.y - nodePosition.y > 1.4f; bool flag2 = goal.y - nodePosition.y < -1.25f; float currentDistance = Get3DGoalDistance(nodePosition, goal); if (flag2 && TryBuildVerticalDropPlanFrom(nodePosition, goal.y - nodePosition.y, out PathPlan plan)) { AddSpatialCandidate(list, plan, nodePosition, goal, currentDistance); } for (int i = 0; i < SpatialAngles.Length; i++) { Vector3 val2 = Quaternion.AngleAxis(SpatialAngles[i], Vector3.up) * val; if (flag && TryCreateSpatialClimbCandidate(nodePosition, val2, goal, out PathPlan plan2)) { AddSpatialCandidate(list, plan2, nodePosition, goal, currentDistance); } if (flag2 && TryFindDropLedgeInDirection(nodePosition, val2, out PathPlan plan3)) { AddSpatialCandidate(list, plan3, nodePosition, goal, currentDistance); } for (int j = 0; j < SpatialDistances.Length; j++) { float num = SpatialDistances[j]; Vector3 sampleXZ = nodePosition + val2 * num; if (TrySample3DStandableSurface(nodePosition, sampleXZ, goal, flag, flag2, out var hit) && TryCreateSpatialTransitionPlan(nodePosition, ((RaycastHit)(ref hit)).point, val2, goal, out PathPlan plan4)) { AddSpatialCandidate(list, plan4, nodePosition, goal, currentDistance); } } } list.Sort((PathPlan a, PathPlan b) => b.Score.CompareTo(a.Score)); if (list.Count > 18) { list.RemoveRange(18, list.Count - 18); } return list; } private void AddSpatialCandidate(List candidates, PathPlan plan, Vector3 from, Vector3 goal, float currentDistance) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (plan.Action == PathActionType.None || plan.Action == PathActionType.Hold || (IsClimbPlan(plan) && !IsSpatialClimbPlanViable(plan))) { return; } Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(plan); Vector3 val = planProjectedEndPoint - from; if (((Vector3)(ref val)).sqrMagnitude < 0.20249999f) { return; } float num = Get3DGoalDistance(planProjectedEndPoint, goal); float num2 = currentDistance - num; float num3 = Mathf.Abs(goal.y - from.y) - Mathf.Abs(goal.y - planProjectedEndPoint.y); if (num2 < -1.25f && num3 < 0.25f && plan.Action != PathActionType.Climb && plan.Action != PathActionType.JumpGrab && plan.Action != PathActionType.DropDown) { return; } plan.Score += num2 * 2f; plan.Score += num3 * 1.1f; plan.Score -= EstimatePlanStaminaCost(plan) * 1.3f; plan.Score -= GetBlockedPenalty(planProjectedEndPoint); plan.Score -= GetFailedSegmentPenalty(plan); for (int i = 0; i < candidates.Count; i++) { Vector3 planProjectedEndPoint2 = GetPlanProjectedEndPoint(candidates[i]); if (Vector3.Distance(planProjectedEndPoint2, planProjectedEndPoint) <= 0.85f && candidates[i].Action == plan.Action) { if (plan.Score > candidates[i].Score) { candidates[i] = ClonePlan(plan); } return; } } candidates.Add(ClonePlan(plan)); } private bool TrySample3DStandableSurface(Vector3 nodePosition, Vector3 sampleXZ, Vector3 goal, bool targetAbove, bool targetBelow, out RaycastHit hit) { //IL_0003: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_0104: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0175: 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_0193: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); float num = Mathf.Max(nodePosition.y, goal.y); float num2 = Mathf.Min(nodePosition.y, goal.y); Vector3 val = default(Vector3); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < SpatialVerticalProbeOffsets.Length; i++) { float num3 = SpatialVerticalProbeOffsets[i]; float num4 = (targetAbove ? Mathf.Max(nodePosition.y + num3, Mathf.Min(goal.y + 2.2f, nodePosition.y + 10f)) : ((!targetBelow) ? (nodePosition.y + Mathf.Min(num3, 4.4f)) : (nodePosition.y + Mathf.Max(2.2f, num3 * 0.55f)))); ((Vector3)(ref val))..ctor(sampleXZ.x, num4, sampleXZ.z); float num5 = Mathf.Max(8f, num4 - num2 + 4f); if (Physics.Raycast(val, Vector3.down, ref val2, num5, TerrainMask, (QueryTriggerInteraction)1) && IsRoughStandableNormal(((RaycastHit)(ref val2)).normal)) { float num6 = ((RaycastHit)(ref val2)).point.y - nodePosition.y; float num7 = nodePosition.y - ((RaycastHit)(ref val2)).point.y; if (!(num6 > 5.25f) && !(num7 > 9.5f) && (!targetAbove || !(((RaycastHit)(ref val2)).point.y < nodePosition.y - 0.35f))) { hit = val2; return true; } } } return false; } private bool TryCreateSpatialTransitionPlan(Vector3 from, Vector3 to, Vector3 dir, Vector3 finalGoal, out PathPlan plan) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0036: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0130: 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) plan = new PathPlan(); float num = HelperFunctions.FlatDistance(from, to); if (num < 0.35f) { return false; } float num2 = to.y - from.y; float num3 = from.y - to.y; bool targetAbove = finalGoal.y - from.y > 1.4f; if (TryCreateSpatialGroundMovePlan(from, to, targetAbove, out plan)) { return true; } if (num2 > 0.7f && TryCreateSpatialClimbCandidate(from, dir, finalGoal, out PathPlan plan2)) { Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(plan2); float num4 = Vector3.Distance(planProjectedEndPoint, to); float num5 = Get3DGoalDistance(planProjectedEndPoint, finalGoal); float num6 = Get3DGoalDistance(from, finalGoal); if (num4 <= 2.8f || num5 < num6 - 0.45f) { plan = plan2; return true; } } if (num3 > 1.05f && TryFindDropLedgeInDirection(from, dir, out PathPlan plan3)) { Vector3 planProjectedEndPoint2 = GetPlanProjectedEndPoint(plan3); if (Vector3.Distance(planProjectedEndPoint2, to) <= 3.25f || Get3DGoalDistance(planProjectedEndPoint2, finalGoal) < Get3DGoalDistance(from, finalGoal) - 0.35f) { plan = plan3; return true; } } return false; } private bool TryCreateSpatialGroundMovePlan(Vector3 from, Vector3 to, bool targetAbove, out PathPlan plan) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!IsSpatialGroundCorridorWalkable(from, to, targetAbove, out var projectedEnd)) { return false; } bool flag = IsRoughTerrainLineBlocked(from + Vector3.up * 0.1f, to + Vector3.up * 0.1f); plan = new PathPlan { Action = ((!flag) ? PathActionType.Direct : PathActionType.Detour), Goal = to + Vector3.up * 0.15f, Anchor = to, TargetAbove = targetAbove, RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(from, to)), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = projectedEnd, HasProjectedEndPoint = true, Score = (flag ? 0.25f : 0.75f) }; return true; } private bool IsSpatialGroundCorridorWalkable(Vector3 from, Vector3 to, bool targetAbove, out Vector3 projectedEnd) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) projectedEnd = to; Vector3 val = to - from; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.25f) { return true; } Vector3 normalized = ((Vector3)(ref val)).normalized; int num = Mathf.Clamp(Mathf.CeilToInt(magnitude / 0.65f), 1, 12); Vector3 val2 = GetSpatialStandPoint(from); float num2 = 0f; float num3 = 0f; Vector3 point = default(Vector3); for (int i = 1; i <= num; i++) { float num4 = (float)i / (float)num; Vector3 val3 = Vector3.Lerp(from, to, num4); Vector3 val4 = from + normalized * (magnitude * num4); ((Vector3)(ref point))..ctor(val4.x, val3.y, val4.z); if (!TryFindGroundNearHeight(point, out var hit)) { return false; } if (!IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { return false; } float num5 = ((RaycastHit)(ref hit)).point.y - val2.y; float num6 = val2.y - ((RaycastHit)(ref hit)).point.y; if (num5 > 0.78f || num6 > 1.05f) { return false; } if (num5 > 0f) { num2 += num5; } if (num6 > 0f) { num3 += num6; } val2 = ((RaycastHit)(ref hit)).point; } if (num2 > 2.25f || num3 > 3.25f) { return false; } if (targetAbove && val2.y < from.y + Mathf.Min(0.45f, Mathf.Max(0.2f, (to.y - from.y) * 0.25f))) { return false; } projectedEnd = val2; return true; } private bool TryFindGroundNearHeight(Vector3 point, out RaycastHit hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Physics.Raycast(point + Vector3.up * 1.65f, Vector3.down, ref hit, 3.75f, TerrainMask, (QueryTriggerInteraction)1); } private bool TryCreateSpatialClimbCandidate(Vector3 from, Vector3 dir, Vector3 finalGoal, out PathPlan plan) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0147: 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_0155: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!TryProbeAnyClimbableAheadFrom(from, dir, 5.25f, preferJumpGrab: true, out var climbBase, out var climbHeight, out var needsJumpStart, out var climbTopPoint, out var surfaceNormal)) { return false; } if (climbTopPoint == Vector3.zero) { return false; } float num = Get3DGoalDistance(from, finalGoal) - Get3DGoalDistance(climbTopPoint, finalGoal); float num2 = Mathf.Abs(finalGoal.y - from.y) - Mathf.Abs(finalGoal.y - climbTopPoint.y); if (num < 0.25f && num2 < 0.35f) { return false; } float num3 = EstimateRequiredClimbStamina(climbHeight, targetAbove: true, climbHeight >= 2.15f); plan = new PathPlan { Action = (needsJumpStart ? PathActionType.JumpGrab : PathActionType.Climb), Goal = climbTopPoint + Vector3.up * 0.2f, Anchor = climbBase, TargetAbove = true, EstimatedClimbHeight = climbHeight, IsTallWall = (climbHeight >= 2.15f), RequiredStamina = num3, ReachableWithinRecoverableBudget = (num3 <= GetRecoverableStaminaCeiling()), NeedsJumpStart = needsJumpStart, ClimbTopPoint = climbTopPoint, ClimbSurfaceNormal = surfaceNormal, ProjectedEndPoint = climbTopPoint, HasProjectedEndPoint = true, JumpGrabAimPoint = climbTopPoint + Vector3.up * 0.15f, JumpGrabHorizontalDistance = HelperFunctions.FlatDistance(from, climbBase), Score = 1.25f + num * 1.1f + num2 * 0.9f }; return IsSpatialClimbPlanViable(plan); } private bool IsSpatialClimbPlanViable(PathPlan plan) { if (!IsClimbPlan(plan)) { return true; } if (plan.RequiredStamina > GetRecoverableStaminaCeiling() + 0.02f) { return false; } float num = EstimateMaxReachableClimbHeight(plan.TargetAbove, plan.NeedsJumpStart); return plan.EstimatedClimbHeight <= num + 0.35f; } private Vector3 GetSpatialStandPoint(Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (TryFindGround(point, out var hit) && IsRoughStandableNormal(((RaycastHit)(ref hit)).normal)) { return ((RaycastHit)(ref hit)).point; } return point; } private float Get3DGoalDistance(Vector3 a, Vector3 b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float num = HelperFunctions.FlatDistance(a, b); float num2 = Mathf.Abs(a.y - b.y); return num + num2 * 1.35f; } private float GetSpatialTransitionCost(PathPlan plan, Vector3 from, Vector3 end, Vector3 goal, int candidateIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(from, end) * 0.75f; num += Mathf.Abs(end.y - from.y) * 0.55f; num += (float)candidateIndex * 0.025f; switch (plan.Action) { case PathActionType.Climb: num += 1.2f + plan.RequiredStamina * 2f; break; case PathActionType.JumpGrab: num += 1.6f + plan.RequiredStamina * 2.5f; break; case PathActionType.DropDown: num += 0.85f + Mathf.Max(0f, plan.ExpectedDropHeight - 10f) * 0.08f; break; case PathActionType.GapJump: num += 1.15f + plan.RequiredStamina * 1.8f; break; case PathActionType.Detour: num += 0.45f; break; } return num; } private bool HasDirectGroundVerticalProgress(Vector3 startPos, Vector3 dir, Vector3 goal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (!TryFindGround(startPos, out var hit)) { return false; } float num = Mathf.Abs(goal.y - ((RaycastHit)(ref hit)).point.y); Vector3 point = ((RaycastHit)(ref hit)).point; float num2 = num; float num3 = Mathf.Min(5f, Mathf.Max(1.5f, HelperFunctions.FlatDistance(startPos, goal))); int num4 = Mathf.Clamp(Mathf.CeilToInt(num3 / 0.75f), 2, 8); for (int i = 1; i <= num4; i++) { Vector3 point2 = startPos + dir * (num3 * ((float)i / (float)num4)); if (TryFindGround(point2, out var hit2) && IsRoughStandableNormal(((RaycastHit)(ref hit2)).normal)) { float num5 = Mathf.Abs(goal.y - ((RaycastHit)(ref hit2)).point.y); if (num5 < num2) { num2 = num5; point = ((RaycastHit)(ref hit2)).point; } } } float num6 = num - num2; return num6 >= 0.35f || Mathf.Abs(goal.y - point.y) <= 1.2f; } private bool ShouldTryThreeDimensionalPlannerBeforeLocal() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!HasActiveGoal()) { return false; } Vector3 center = _character.Center; Vector3 goalCenter = GetGoalCenter(); float num = HelperFunctions.FlatDistance(center, goalCenter); float num2 = Mathf.Abs(goalCenter.y - center.y); if (_stuckCount > 0 || _failedClimbCount > 0 || _failedSegments.Count > 0) { return true; } if (!_rawGoalIsStandable && num2 > 1.2f) { return true; } if (num2 > 1.85f && num <= 10f) { return true; } return num2 > 3f; } private RoutePathCacheKey MakeSpatialPathCacheKey(Vector3 start, Vector3 goal, bool targetAbove, bool targetBelow) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) int num = 700; if (targetAbove) { num += 10; } if (targetBelow) { num += 20; } num += Mathf.Clamp(_stuckCount, 0, 3); num = num * 10 + Mathf.Clamp(_failedClimbCount, 0, 3); return new RoutePathCacheKey(QuantizePlanner(start.x, 1.65f), QuantizePlanner(start.y, 1.65f), QuantizePlanner(start.z, 1.65f), QuantizePlanner(goal.x, 1.65f), QuantizePlanner(goal.y, 1.65f), QuantizePlanner(goal.z, 1.65f), QuantizeStamina(GetStamina01()), num); } private bool TryGetCachedSpatialPath(RoutePathCacheKey key, out List segments) { segments = new List(); if (SharedGuidePathCache.TryGetValue(key, out RoutePathCacheEntry value) && Time.time - value.CreatedAt <= 2.2f) { segments = ClonePlanList(value.Segments); return segments.Count > 0; } if (_guidePathCache.TryGetValue(key, out RoutePathCacheEntry value2) && Time.time - value2.CreatedAt <= 2.2f) { segments = ClonePlanList(value2.Segments); return segments.Count > 0; } return false; } private void StoreSpatialPathCache(RoutePathCacheKey key, List segments) { RoutePathCacheEntry routePathCacheEntry = new RoutePathCacheEntry { CreatedAt = Time.time }; RoutePathCacheEntry routePathCacheEntry2 = new RoutePathCacheEntry { CreatedAt = Time.time }; for (int i = 0; i < segments.Count; i++) { routePathCacheEntry.Segments.Add(ClonePlan(segments[i])); routePathCacheEntry2.Segments.Add(ClonePlan(segments[i])); } _guidePathCache[key] = routePathCacheEntry; SharedGuidePathCache[key] = routePathCacheEntry2; PruneGuidePlannerCaches(); } private SpatialRouteStateKey MakeSpatialStateKey(Vector3 position, int depth, float stamina) { //IL_0002: 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_0024: Unknown result type (might be due to invalid IL or missing references) return new SpatialRouteStateKey(QuantizePlanner(position.x, 1.65f), QuantizePlanner(position.y, 1.65f), QuantizePlanner(position.z, 1.65f), depth, QuantizeStamina(stamina)); } } internal enum RobotBrainState { Idle, Parked, Chase, PrepareTallClimb, Reposition, Lunge, LungeRecovery, Dead } internal enum PathActionType { None, Direct, Detour, Climb, JumpGrab, GapJump, DropDown, WaitForStamina, Hold } internal sealed class PathPlan { public PathActionType Action = PathActionType.None; public Vector3 Goal; public Vector3 Anchor; public float RequiredStamina; public bool TargetAbove; public float EstimatedClimbHeight; public bool IsTallWall; public float ExpectedDropHeight; public bool UsesJumpDropImmunity; public bool ReachableWithinRecoverableBudget; public float Score; public bool NeedsJumpStart; public Vector3 ProjectedEndPoint; public bool HasProjectedEndPoint; public float ProjectedRemainingStamina; public int PlanningDepth; public Vector3 ClimbTopPoint; public Vector3 ClimbSurfaceNormal; public Vector3 JumpGrabAimPoint; public float JumpGrabHorizontalDistance; } internal struct RouteProbe { public bool ObstacleAhead; public float ObstacleDistance; public Vector3 ObstaclePoint; public bool ClimbableAhead; public float ClimbHeightDelta; public Vector3 ClimbBasePoint; public bool NeedsJumpStart; public Vector3 ClimbTopPoint; public Vector3 ClimbSurfaceNormal; public bool UnsafeDropAhead; public float DropHeight; public bool SafeWalkDrop; public bool SafeJumpDrop; public Vector3 DropLandingPoint; public bool GapJumpable; public Vector3 GapLandingPoint; public float GapLandingDrop; } internal sealed class BlockedMemory { public Vector3 Point = Vector3.zero; public float Until; } internal sealed class RouteSearchNode { public Vector3 Position = Vector3.zero; public readonly List Segments = new List(); public float Score; public float DistanceToGoal; public float RemainingStamina; public int Depth; } internal readonly struct RouteCandidateCacheKey : IEquatable { public readonly int X; public readonly int Y; public readonly int Z; public readonly int GoalX; public readonly int GoalY; public readonly int GoalZ; public readonly int DirBucket; public RouteCandidateCacheKey(int x, int y, int z, int goalX, int goalY, int goalZ, int dirBucket) { X = x; Y = y; Z = z; GoalX = goalX; GoalY = goalY; GoalZ = goalZ; DirBucket = dirBucket; } public bool Equals(RouteCandidateCacheKey other) { return X == other.X && Y == other.Y && Z == other.Z && GoalX == other.GoalX && GoalY == other.GoalY && GoalZ == other.GoalZ && DirBucket == other.DirBucket; } public override bool Equals(object? obj) { return obj is RouteCandidateCacheKey other && Equals(other); } public override int GetHashCode() { int x = X; x = (x * 397) ^ Y; x = (x * 397) ^ Z; x = (x * 397) ^ GoalX; x = (x * 397) ^ GoalY; x = (x * 397) ^ GoalZ; return (x * 397) ^ DirBucket; } } internal sealed class RouteCandidateCacheEntry { public readonly List Candidates = new List(); public float CreatedAt; } internal readonly struct RoutePlannerStateKey : IEquatable { public readonly int X; public readonly int Y; public readonly int Z; public readonly int Depth; public readonly int StaminaBucket; public RoutePlannerStateKey(int x, int y, int z, int depth, int staminaBucket) { X = x; Y = y; Z = z; Depth = depth; StaminaBucket = staminaBucket; } public bool Equals(RoutePlannerStateKey other) { return X == other.X && Y == other.Y && Z == other.Z && Depth == other.Depth && StaminaBucket == other.StaminaBucket; } public override bool Equals(object? obj) { return obj is RoutePlannerStateKey other && Equals(other); } public override int GetHashCode() { int x = X; x = (x * 397) ^ Y; x = (x * 397) ^ Z; x = (x * 397) ^ Depth; return (x * 397) ^ StaminaBucket; } } internal readonly struct RoutePathCacheKey : IEquatable { public readonly int StartX; public readonly int StartY; public readonly int StartZ; public readonly int GoalX; public readonly int GoalY; public readonly int GoalZ; public readonly int StaminaBucket; public readonly int ModeBucket; public RoutePathCacheKey(int startX, int startY, int startZ, int goalX, int goalY, int goalZ, int staminaBucket, int modeBucket) { StartX = startX; StartY = startY; StartZ = startZ; GoalX = goalX; GoalY = goalY; GoalZ = goalZ; StaminaBucket = staminaBucket; ModeBucket = modeBucket; } public bool Equals(RoutePathCacheKey other) { return StartX == other.StartX && StartY == other.StartY && StartZ == other.StartZ && GoalX == other.GoalX && GoalY == other.GoalY && GoalZ == other.GoalZ && StaminaBucket == other.StaminaBucket && ModeBucket == other.ModeBucket; } public override bool Equals(object? obj) { return obj is RoutePathCacheKey other && Equals(other); } public override int GetHashCode() { int startX = StartX; startX = (startX * 397) ^ StartY; startX = (startX * 397) ^ StartZ; startX = (startX * 397) ^ GoalX; startX = (startX * 397) ^ GoalY; startX = (startX * 397) ^ GoalZ; startX = (startX * 397) ^ StaminaBucket; return (startX * 397) ^ ModeBucket; } } internal sealed class RoutePathCacheEntry { public readonly List Segments = new List(); public float CreatedAt; } internal sealed class RouteChoiceMemory { public PathActionType Action = PathActionType.None; public Vector3 Position = Vector3.zero; public Vector3 Direction = Vector3.zero; public float Until; } internal struct PingTargetData { public Vector3 Point; public float Time; public int Sequence; public int OwnerActorNumber; public int OwnerViewId; public Character? OwnerCharacter; } internal readonly struct PhysicsProbeCacheKey : IEquatable { public readonly int Ax; public readonly int Ay; public readonly int Az; public readonly int Bx; public readonly int By; public readonly int Bz; public readonly int Kind; public PhysicsProbeCacheKey(int ax, int ay, int az, int bx, int by, int bz, int kind) { Ax = ax; Ay = ay; Az = az; Bx = bx; By = by; Bz = bz; Kind = kind; } public bool Equals(PhysicsProbeCacheKey other) { return Ax == other.Ax && Ay == other.Ay && Az == other.Az && Bx == other.Bx && By == other.By && Bz == other.Bz && Kind == other.Kind; } public override bool Equals(object? obj) { return obj is PhysicsProbeCacheKey other && Equals(other); } public override int GetHashCode() { int ax = Ax; ax = (ax * 397) ^ Ay; ax = (ax * 397) ^ Az; ax = (ax * 397) ^ Bx; ax = (ax * 397) ^ By; ax = (ax * 397) ^ Bz; return (ax * 397) ^ Kind; } } internal sealed class GroundProbeCacheEntry { public bool Found; public RaycastHit Hit; public float CreatedAt; } internal sealed class LineProbeCacheEntry { public bool Blocked; public float CreatedAt; } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] internal static class CharacterAfflictionsAddStatusPatch { [HarmonyPrefix] private static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, float amount, bool fromRPC, bool playEffects, bool notify, ref bool __result) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || !__instance.character.isZombie) { return true; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(__instance.character); if ((Object)(object)agent == (Object)null) { return true; } if ((int)statusType != 6 && (int)statusType != 11 && (int)statusType != 1 && (int)statusType != 0 && (int)statusType != 3 && (int)statusType != 2 && (int)statusType != 8) { __result = false; return false; } return true; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterAfflictionsAddStatusPatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterAfflictions), "SubtractStatus")] internal static class CharacterAfflictionsSubtractStatusPatch { [HarmonyPrefix] private static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, float amount, bool fromRPC, bool decreasedNaturally) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || !__instance.character.isZombie) { return true; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(__instance.character); if ((Object)(object)agent == (Object)null) { return true; } return (int)statusType == 6 || (int)statusType == 11 || (int)statusType == 1 || (int)statusType == 0 || (int)statusType == 3 || (int)statusType == 2 || (int)statusType == 8; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterAfflictionsSubtractStatusPatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterGrabbing), "Reach")] internal static class RobotReachDragPatch { [HarmonyPostfix] private static void Postfix(CharacterGrabbing __instance) { //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null) { return; } object? obj = PatchReflectionCache.CharacterGrabbingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null || val.refs == null || (Object)(object)val.refs.view == (Object)null || !val.refs.view.IsMine) { return; } for (int num = NetworkRobotAgent.All.Count - 1; num >= 0; num--) { NetworkRobotAgent networkRobotAgent = NetworkRobotAgent.All[num]; if ((Object)(object)networkRobotAgent == (Object)null || (Object)(object)networkRobotAgent.Character == (Object)null) { NetworkRobotAgent.All.RemoveAt(num); } else { Character character = networkRobotAgent.Character; if (!((Object)(object)character == (Object)(object)val) && !((Object)(object)character.data == (Object)null) && character.refs != null && !((Object)(object)character.refs.afflictions == (Object)null) && !((Object)(object)((MonoBehaviourPun)character).photonView == (Object)null) && networkRobotAgent.CanBeHelpedByPlayer()) { float num2 = Vector3.Distance(val.Center, character.Center); if (!(num2 > 4f)) { Vector3 val2 = character.Center - val.Center; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.001f) && !(Vector3.Angle(val.data.lookDirection, val2) > 60f)) { character.refs.afflictions.SubtractStatus((STATUSTYPE)11, 1f, false, false); try { if ((Object)(object)GUIManager.instance != (Object)null) { GUIManager.instance.Grasp(); } } catch { } ((MonoBehaviourPun)character).photonView.RPC("RPC_AssistDrag", (RpcTarget)0, new object[2] { val.Center, 70f }); networkRobotAgent.NotifyGrabbedByPlayer(val); } } } } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"RobotReachDragPatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterGrabbing), "RPCA_GrabAttach")] internal static class CharacterGrabbingGrabAttachPatch { [HarmonyPostfix] private static void Postfix(CharacterGrabbing __instance, PhotonView view, int bodyPartID, Vector3 relativePos) { try { if ((Object)(object)view == (Object)null) { return; } Character component = ((Component)view).GetComponent(); if ((Object)(object)component == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(component); if (!((Object)(object)agent == (Object)null)) { object? obj = PatchReflectionCache.CharacterGrabbingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if (!((Object)(object)val == (Object)null)) { agent.NotifyGrabbedByPlayer(val); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterGrabbingGrabAttachPatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterGrabbing), "RPCA_GrabUnattach")] internal static class CharacterGrabbingGrabUnattachPatch { [HarmonyPrefix] private static void Prefix(CharacterGrabbing __instance) { try { object? obj = PatchReflectionCache.CharacterGrabbingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null) { return; } Character grabbedPlayer = val.data.grabbedPlayer; if (!((Object)(object)grabbedPlayer == (Object)null)) { NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(grabbedPlayer); if (!((Object)(object)agent == (Object)null)) { agent.NotifyReleasedByPlayer(val); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterGrabbingGrabUnattachPatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterCarrying), "Update")] internal static class CharacterCarryingUpdatePatch { [HarmonyPrefix] private static bool Prefix(CharacterCarrying __instance) { try { object? obj = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null) { return true; } if (val.data.isCarried && (Object)(object)val.data.carrier != (Object)null && (Object)(object)RobotInteractionUtil.GetAgent(val.data.carrier) != (Object)null) { if (val.refs != null && (Object)(object)val.refs.view != (Object)null && val.refs.view.IsMine && (val.input.jumpWasPressed || val.input.dropWasPressed || val.input.interactWasPressed)) { ((MonoBehaviourPun)val.data.carrier).photonView.RPC("RPCA_Drop", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)val).photonView }); } return true; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(val); if ((Object)(object)agent != (Object)null) { if (val.refs == null || (Object)(object)val.refs.view == (Object)null || !val.refs.view.IsMine) { return false; } Character carriedPlayer = val.data.carriedPlayer; if ((Object)(object)carriedPlayer == (Object)null) { return false; } if ((Object)(object)carriedPlayer.data == (Object)null || carriedPlayer.data.dead || val.data.fullyPassedOut || val.data.dead || (Object)(object)carriedPlayer.data.carrier != (Object)(object)val) { ((MonoBehaviourPun)val).photonView.RPC("RPCA_Drop", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)carriedPlayer).photonView }); } return false; } if (val.refs == null || (Object)(object)val.refs.view == (Object)null || !val.refs.view.IsMine) { return true; } Character carriedPlayer2 = val.data.carriedPlayer; if ((Object)(object)carriedPlayer2 == (Object)null) { return true; } NetworkRobotAgent agent2 = RobotInteractionUtil.GetAgent(carriedPlayer2); if ((Object)(object)agent2 == (Object)null) { return true; } if (carriedPlayer2.data.dead || val.data.fullyPassedOut || val.data.dead || (Object)(object)carriedPlayer2.data.currentItem != (Object)null) { val.refs.carriying.Drop(carriedPlayer2); } return false; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterCarryingUpdatePatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterCarrying), "RPCA_StartCarry")] internal static class CharacterCarryingStartCarryPatch { [HarmonyPrefix] private static bool Prefix(CharacterCarrying __instance, PhotonView targetView) { try { object? obj = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(val); if ((Object)(object)val == (Object)null || (Object)(object)agent == (Object)null) { return true; } if ((Object)(object)targetView == (Object)null) { return false; } Character component = ((Component)targetView).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.data == (Object)null) { return false; } if ((Object)(object)val.data.carriedPlayer != (Object)null && (Object)(object)val.data.carriedPlayer != (Object)(object)component) { val.refs.carriying.RPCA_Drop(((MonoBehaviourPun)val.data.carriedPlayer).photonView); } if ((Object)(object)component.data.carrier != (Object)null && (Object)(object)component.data.carrier != (Object)(object)val) { component.data.carrier.refs.carriying.RPCA_Drop(((MonoBehaviourPun)component).photonView); } PatchReflectionCache.CharacterCarryingToggleCarryPhysicsMethod?.Invoke(component.refs.carriying, new object[1] { true }); component.data.isCarried = true; val.data.carriedPlayer = component; component.data.carrier = val; RefreshCarryWeights(val); agent.NotifyStartedCarryingPlayer(component); return false; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterCarryingStartCarryPatch Prefix failed: {arg}"); return true; } } [HarmonyPostfix] private static void Postfix(CharacterCarrying __instance, PhotonView targetView) { try { if ((Object)(object)targetView == (Object)null) { return; } Character component = ((Component)targetView).GetComponent(); if ((Object)(object)component == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(component); if ((Object)(object)agent != (Object)null) { object? obj = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val != (Object)null) { agent.NotifyCarriedByPlayer(val); } } object? obj2 = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character character = (Character)((obj2 is Character) ? obj2 : null); NetworkRobotAgent agent2 = RobotInteractionUtil.GetAgent(character); if ((Object)(object)agent2 != (Object)null && (Object)(object)component != (Object)null) { agent2.NotifyStartedCarryingPlayer(component); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterCarryingStartCarryPatch Postfix failed: {arg}"); } } internal static void RefreshCarryWeights(Character carrier) { try { List allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters(); for (int i = 0; i < allPlayerCharacters.Count; i++) { allPlayerCharacters[i].refs.afflictions.UpdateWeight(); } if ((Object)(object)carrier != (Object)null && carrier.refs != null && (Object)(object)carrier.refs.afflictions != (Object)null) { carrier.refs.afflictions.UpdateWeight(); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"RefreshCarryWeights failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterCarrying), "RPCA_Drop")] internal static class CharacterCarryingDropPatch { [HarmonyPrefix] private static void Prefix(CharacterCarrying __instance, PhotonView targetView) { try { if ((Object)(object)targetView == (Object)null) { return; } Character component = ((Component)targetView).GetComponent(); if ((Object)(object)component == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(component); if ((Object)(object)agent != (Object)null) { object? obj = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val != (Object)null) { agent.NotifyDroppedByPlayer(val); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterCarryingDropPatch Prefix failed: {arg}"); } } [HarmonyPostfix] private static void Postfix(CharacterCarrying __instance, PhotonView targetView) { try { object? obj = PatchReflectionCache.CharacterCarryingCharacterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(val); if (!((Object)(object)agent == (Object)null) && !((Object)(object)targetView == (Object)null)) { Character component = ((Component)targetView).GetComponent(); if ((Object)(object)component != (Object)null) { agent.NotifyStoppedCarryingPlayer(component); } if ((Object)(object)val != (Object)null) { CharacterCarryingStartCarryPatch.RefreshCarryWeights(val); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterCarryingDropPatch Postfix failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInteractible), "GetInteractionText")] internal static class CharacterInteractibleGetInteractionTextPatch { [HarmonyPrefix] private static bool Prefix(CharacterInteractible __instance, ref string __result) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)RobotInteractionUtil.GetAgent(__instance.character) == (Object)null) { return true; } Character character = __instance.character; if (RobotInteractionRules.IsCarriedByLocalPlayer(character)) { __result = LocalizedText.GetText("DROP", true).Replace("#", __instance.GetName()); return false; } if (RobotInteractionRules.CanLocalPlayerEatRobot(character)) { __result = LocalizedText.GetText("EAT", true); return false; } if (RobotInteractionRules.CanCarryRobot(character, Character.localCharacter)) { __result = LocalizedText.GetText("CARRY", true).Replace("#", __instance.GetName()); return false; } __result = string.Empty; return false; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleGetInteractionTextPatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterInteractible), "Interact")] internal static class CharacterInteractibleInteractPatch { [HarmonyPrefix] private static bool Prefix(CharacterInteractible __instance, Character interactor) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)RobotInteractionUtil.GetAgent(__instance.character) == (Object)null) { return true; } Character character = __instance.character; if (RobotInteractionRules.IsCarriedByLocalPlayer(character)) { interactor.refs.carriying.Drop(character); return false; } if (RobotInteractionRules.CanLocalPlayerEatRobot(character, interactor)) { return false; } if (RobotInteractionRules.CanCarryRobot(character, interactor)) { interactor.refs.carriying.StartCarry(character); return false; } return false; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleInteractPatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterInteractible), "Interact_CastFinished")] internal static class CharacterInteractibleCastFinishedPatch { [HarmonyPrefix] private static bool Prefix(CharacterInteractible __instance, Character interactor) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)RobotInteractionUtil.GetAgent(__instance.character) == (Object)null) { return true; } RobotInteractionRules.TryEatRobot(__instance.character, interactor); return false; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleCastFinishedPatch failed: {arg}"); return true; } } } [HarmonyPatch(typeof(CharacterInteractible), "IsConstantlyInteractable")] internal static class CharacterInteractibleIsConstantlyInteractablePatch { [HarmonyPostfix] private static void Postfix(CharacterInteractible __instance, Character interactor, ref bool __result) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.character == (Object)null) && !((Object)(object)RobotInteractionUtil.GetAgent(__instance.character) == (Object)null)) { __result = RobotInteractionRules.CanLocalPlayerEatRobot(__instance.character, interactor); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleIsConstantlyInteractablePatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInteractible), "IsPrimaryInteractible")] internal static class CharacterInteractibleIsPrimaryInteractiblePatch { [HarmonyPostfix] private static void Postfix(CharacterInteractible __instance, Character interactor, ref bool __result) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.character == (Object)null)) { NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(__instance.character); if (!((Object)(object)agent == (Object)null)) { Character character = __instance.character; bool flag = RobotInteractionRules.IsCarriedByLocalPlayer(character); bool flag2 = RobotInteractionRules.CanLocalPlayerEatRobot(character, interactor); bool flag3 = RobotInteractionRules.CanCarryRobot(character, interactor); __result = !character.data.dead && (flag || flag2 || flag3); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleIsPrimaryInteractiblePatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInteractible), "IsSecondaryInteractible")] internal static class CharacterInteractibleIsSecondaryInteractiblePatch { [HarmonyPostfix] private static void Postfix(CharacterInteractible __instance, Character interactor, ref bool __result) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || (Object)(object)interactor == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(__instance.character); if ((Object)(object)agent == (Object)null) { return; } if (__instance.character.data.dead) { __result = false; return; } Item currentItem = interactor.data.currentItem; if ((Object)(object)currentItem == (Object)null || !currentItem.canUseOnFriend) { __result = false; } else { __result = (Object)(object)interactor != (Object)(object)__instance.character; } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleIsSecondaryInteractiblePatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInteractible), "CanBeCarried")] internal static class CharacterInteractibleCanBeCarriedPatch { [HarmonyPostfix] private static void Postfix(CharacterInteractible __instance, ref bool __result) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.character == (Object)null) && !((Object)(object)RobotInteractionUtil.GetAgent(__instance.character) == (Object)null)) { __result = RobotInteractionRules.CanCarryRobot(__instance.character, Character.localCharacter); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleCanBeCarriedPatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInteractible), "IsInteractible")] internal static class CharacterInteractibleIsInteractiblePatch { [HarmonyPostfix] private static void Postfix(CharacterInteractible __instance, Character interactor, ref bool __result) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(__instance.character); if (!((Object)(object)agent == (Object)null)) { Character character = __instance.character; if (character.data.dead) { __result = false; return; } bool flag = RobotInteractionRules.IsCarriedByLocalPlayer(character); bool flag2 = RobotInteractionRules.CanLocalPlayerEatRobot(character, interactor); bool flag3 = RobotInteractionRules.CanCarryRobot(character, interactor); bool flag4 = (Object)(object)interactor != (Object)null && (Object)(object)interactor != (Object)(object)character && (Object)(object)interactor.data.currentItem != (Object)null && interactor.data.currentItem.canUseOnFriend; __result = flag || flag2 || flag3 || flag4; } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CharacterInteractibleIsInteractiblePatch failed: {arg}"); } } } [HarmonyPatch(typeof(CharacterInput), "Sample")] internal static class HostPlayerPilotInputPatch { private sealed class PilotState { public int LastSequence; public bool HasGoal; public Vector3 Goal; public Vector3 ResolvedGoal; public bool HasResolvedGoal; public bool Parked; public int ParkedSequence; public float StableTimer; public PathPlan ActivePlan = new PathPlan(); public bool HasActivePlan; public float NextReplanTime; public float SegmentStartTime; public Vector3 SegmentStartPosition; public float SegmentStartGoalDistance; public Vector3 LastProgressAnchor; public float LastProgressTime; } private static readonly Dictionary StatesByView = new Dictionary(); private static readonly Dictionary LastAutoJumpByView = new Dictionary(); private static readonly Dictionary CharacterByInputId = new Dictionary(); private const float ManualMoveThreshold = 0.05f; private const float ManualLookThreshold = 0.04f; private const float JumpCooldown = 0.24f; private const float ReplanCooldown = 0.5f; private const float GoalArrivalFlat = 2.05f; private const float GoalArrivalVertical = 1.6f; private const float GoalParkStableSeconds = 1f; private const float GoalParkedHysteresisFlat = 3f; private const float GoalParkedHysteresisVertical = 2.5f; private const float SegmentArriveFlat = 1.35f; private const float SegmentProgressTimeout = 3.2f; private const float SegmentMinMove = 0.65f; private const float RoughSlopeAngle = 68f; private const float ClimbTopSlopeAngle = 72f; private const float LowerGoalThreshold = -1.25f; private const float MaxSafeWalkDrop = 8f; private const float MaxSafeJumpDrop = 16f; private const float MinClimbStamina = 0.4f; private const float ActiveClimbExhaustedStaminaThreshold = 0.018f; private const float ContinueClimbStamina = 0.018f; private const float HeavyActionLowStaminaThreshold = 0.08f; private const float SprintMinStamina = 0.12f; private const float FlatTravelHopVerticalTolerance = 0.45f; private const float GroundProbeHeight = 2.2f; private const float GroundProbeDepth = 15f; private static readonly int TerrainMask = LayerMask.GetMask(new string[2] { "Terrain", "Map" }); private static readonly float[] SearchAngles = new float[7] { 0f, 25f, -25f, 55f, -55f, 90f, -90f }; private static readonly float[] SearchDistances = new float[3] { 1.2f, 2.4f, 4.2f }; [HarmonyPostfix] private static void Postfix(CharacterInput __instance, bool playerMovementActive) { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || !playerMovementActive) { return; } Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.ShouldHostPilotRun) { return; } Character characterForInput = GetCharacterForInput(__instance); if ((Object)(object)characterForInput == (Object)null || (Object)(object)characterForInput != (Object)(object)Character.localCharacter || (Object)(object)characterForInput.data == (Object)null || !characterForInput.IsLocal || characterForInput.isBot || characterForInput.data.dead || characterForInput.data.fullyPassedOut || characterForInput.data.isCarried) { return; } int viewId = (((Object)(object)((MonoBehaviourPun)characterForInput).photonView != (Object)null) ? ((MonoBehaviourPun)characterForInput).photonView.ViewID : ((Object)characterForInput).GetInstanceID()); PilotState state = GetState(viewId); if (instance.HostPilotManualOverride && HasMeaningfulManualInput(__instance)) { ReleaseParkedAndPlan(state); return; } if (!PingTargetTracker.TryGetBestPingDataForCharacter(characterForInput, instance.HostPilotAcceptOtherPlayersPingTargets, out var data)) { ResetState(state); return; } if (data.Sequence != state.LastSequence || !state.HasGoal || Vector3.Distance(state.Goal, data.Point) > 1f) { ResetForNewGoal(state, data.Point, data.Sequence, characterForInput); } Vector3 pingPoint = (state.HasResolvedGoal ? state.ResolvedGoal : data.Point); ApplyPilotInput(characterForInput, __instance, pingPoint, data.Sequence, instance, state, viewId); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"HostPlayerPilotInputPatch failed: {arg}"); } } private static Character? GetCharacterForInput(CharacterInput input) { int instanceID = ((Object)input).GetInstanceID(); if (CharacterByInputId.TryGetValue(instanceID, out Character value)) { if ((Object)(object)value != (Object)null && (Object)(object)value.input == (Object)(object)input) { return value; } CharacterByInputId.Remove(instanceID); } try { Character component = ((Component)input).GetComponent(); if ((Object)(object)component != (Object)null) { CharacterByInputId[instanceID] = component; } return component; } catch { return null; } } private static PilotState GetState(int viewId) { if (!StatesByView.TryGetValue(viewId, out PilotState value)) { value = new PilotState(); StatesByView[viewId] = value; } return value; } private static void ResetState(PilotState state) { //IL_0010: 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) state.HasGoal = false; state.HasResolvedGoal = false; state.ResolvedGoal = Vector3.zero; state.Parked = false; state.StableTimer = 0f; state.HasActivePlan = false; state.ActivePlan = new PathPlan(); state.LastSequence = 0; } private static void ResetForNewGoal(PilotState state, Vector3 goal, int sequence, Character character) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) state.HasGoal = true; state.Goal = goal; state.ResolvedGoal = ResolvePilotGoal(character, goal); state.HasResolvedGoal = true; state.LastSequence = sequence; state.Parked = false; state.ParkedSequence = 0; state.StableTimer = 0f; state.HasActivePlan = false; state.ActivePlan = new PathPlan(); state.NextReplanTime = 0f; state.SegmentStartTime = Time.time; state.SegmentStartPosition = character.Center; state.SegmentStartGoalDistance = Vector3.Distance(character.Center, state.ResolvedGoal); state.LastProgressAnchor = character.Center; state.LastProgressTime = Time.time; } private static void ReleaseParkedAndPlan(PilotState state) { state.Parked = false; state.ParkedSequence = 0; state.StableTimer = 0f; state.HasActivePlan = false; state.NextReplanTime = 0f; } private static bool HasMeaningfulManualInput(CharacterInput input) { if (((Vector2)(ref input.movementInput)).sqrMagnitude > 0.0025000002f) { return true; } if (((Vector2)(ref input.lookInput)).sqrMagnitude > 0.0016f) { return true; } return input.jumpWasPressed || input.jumpIsPressed || input.dropWasPressed || input.dropIsPressed || input.interactWasPressed || input.interactIsPressed || input.usePrimaryWasPressed || input.usePrimaryIsPressed || input.useSecondaryWasPressed || input.useSecondaryIsPressed || input.crouchWasPressed || input.crouchIsPressed; } private static void ApplyPilotInput(Character character, CharacterInput input, Vector3 pingPoint, int sequence, Plugin plugin, PilotState state, int viewId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) input.lookInput = Vector2.zero; if (character.data.isClimbing && !HasStaminaForClimb(character)) { TryStopClimb(character); HoldStillAtGoal(character, input, pingPoint); state.HasActivePlan = false; state.NextReplanTime = Time.time + 0.35f; } else { if (TickParking(character, input, pingPoint, sequence, state)) { return; } if (!state.HasActivePlan || IsPilotSegmentFinished(character, state) || IsPilotSegmentFailed(character, state, pingPoint)) { TryReplanPilot(character, state, pingPoint, viewId); } if (!state.HasActivePlan) { if (ShouldWaitForStaminaBeforePushingUp(character, pingPoint)) { HoldStillAtGoal(character, input, pingPoint); return; } LookAt(character, pingPoint); WalkTowards(character, input, pingPoint, 0.65f, sprint: false, jump: false, viewId); TryFlatTravelHop(character, input, pingPoint, viewId); } else { ExecutePilotPlan(character, input, state.ActivePlan, pingPoint, plugin, viewId); } } } private static bool TickParking(Character character, CharacterInput input, Vector3 goal, int sequence, PilotState state) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (state.Parked) { if (state.ParkedSequence == sequence && IsWithinGoalZone(character, goal, 3f, 2.5f)) { HoldStillAtGoal(character, input, goal); return true; } ReleaseParkedAndPlan(state); return false; } if (!IsWithinGoalZone(character, goal, 2.05f, 1.6f)) { state.StableTimer = 0f; return false; } if (!IsSafeStanding(character)) { state.StableTimer = 0f; HoldStillAtGoal(character, input, goal); return true; } state.StableTimer += Time.deltaTime; HoldStillAtGoal(character, input, goal); if (state.StableTimer >= 1f) { state.Parked = true; state.ParkedSequence = sequence; state.HasActivePlan = false; state.ActivePlan = new PathPlan(); } return true; } private static void HoldStillAtGoal(Character character, CharacterInput input, Vector3 goal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) input.movementInput = Vector2.zero; input.sprintIsPressed = false; input.jumpWasPressed = false; input.jumpIsPressed = false; } private static bool IsWithinGoalZone(Character character, Vector3 goal, float flat, float vertical) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) Vector3 val = character.Center; if (TryFindGround(character.Center, out var hit)) { val = ((RaycastHit)(ref hit)).point; } return HelperFunctions.FlatDistance(val, goal) <= flat && Mathf.Abs(val.y - goal.y) <= vertical; } private static bool IsSafeStanding(Character character) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character.data == (Object)null) { return false; } if (character.data.isClimbing || character.data.isRopeClimbing || character.data.isVineClimbing) { return false; } if (!character.data.isGrounded || character.data.fallSeconds > 0f || character.data.passedOut || character.data.fullyPassedOut) { return false; } RaycastHit hit; return TryFindGround(character.Center, out hit) && IsStandableNormal(((RaycastHit)(ref hit)).normal); } private static void TryReplanPilot(Character character, PilotState state, Vector3 goal, int viewId) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < state.NextReplanTime)) { state.NextReplanTime = Time.time + 0.5f + (float)(Mathf.Abs(viewId) % 7) * 0.025f; state.ActivePlan = BuildPilotPlan(character, goal); state.HasActivePlan = state.ActivePlan.Action != 0 && state.ActivePlan.Action != PathActionType.Hold; state.SegmentStartTime = Time.time; state.SegmentStartPosition = character.Center; state.SegmentStartGoalDistance = Vector3.Distance(character.Center, state.ResolvedGoal); } } private static PathPlan BuildPilotPlan(Character character, Vector3 goal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_011b: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: 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_017e: 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_019a: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) Vector3 center = character.Center; Vector3 val = goal - center; Vector3 val2 = val; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; float num = goal.y - center.y; bool flag = num < -1.25f; bool flag2 = num > 1.1f; Vector3 val3 = ((magnitude > 0.05f) ? ((Vector3)(ref val2)).normalized : ((Component)character).transform.forward); val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } ((Vector3)(ref val3)).Normalize(); if (TryCreatePilotRoughWalkPlan(character, goal, val3, magnitude, flag2, out PathPlan plan)) { return plan; } if (flag && magnitude < 0.6f && TryFindPilotDropPlan(character, goal, val3, out PathPlan plan2)) { return plan2; } if (TryProbePilotRoute(character, val3, 2.2f, out var probe)) { if (flag2 && probe.ClimbableAhead && !HasStaminaForClimb(character)) { return BuildWaitForStaminaPlan(goal, probe.ClimbBasePoint); } if (flag && TryCreatePilotDropPlan(character, goal, val3, probe, out PathPlan plan3)) { return plan3; } if (flag2 && probe.ClimbableAhead && HasStaminaForClimb(character)) { return new PathPlan { Action = PathActionType.Climb, Goal = goal + Vector3.up * 0.25f, Anchor = probe.ClimbBasePoint, TargetAbove = true, RequiredStamina = 0.4f, NeedsJumpStart = probe.NeedsJumpStart, ClimbTopPoint = probe.ClimbTopPoint, ProjectedEndPoint = probe.ClimbTopPoint, HasProjectedEndPoint = true }; } if (!probe.ObstacleAhead && !probe.UnsafeDropAhead && !IsLineBlocked(center, goal)) { return new PathPlan { Action = PathActionType.Direct, Goal = goal, Anchor = goal, TargetAbove = flag2, ProjectedEndPoint = goal, HasProjectedEndPoint = true }; } } if (flag && TryFindPilotDropPlan(character, goal, val3, out PathPlan plan4)) { return plan4; } if (TryFindPilotTerrainPlan(character, goal, val3, out PathPlan plan5)) { return plan5; } if (flag2 && !HasStaminaForClimb(character)) { return BuildWaitForStaminaPlan(goal, character.Center); } return new PathPlan { Action = PathActionType.Hold, Goal = goal, Anchor = goal, TargetAbove = flag2 }; } private static PathPlan BuildWaitForStaminaPlan(Vector3 goal, Vector3 anchor) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return new PathPlan { Action = PathActionType.WaitForStamina, Goal = goal, Anchor = anchor, TargetAbove = true, RequiredStamina = 0.4f, ReachableWithinRecoverableBudget = true }; } private static bool TryCreatePilotRoughWalkPlan(Character character, Vector3 goal, Vector3 dir, float flatDistance, bool targetAbove, out PathPlan plan) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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) plan = new PathPlan(); if (flatDistance < 0.2f) { return false; } float num = Mathf.Min(flatDistance, 4.25f); Vector3 center = character.Center; Vector3 val = center; if (TryFindGround(center, out var hit)) { val = ((RaycastHit)(ref hit)).point; } int num2 = Mathf.Clamp(Mathf.CeilToInt(num / 0.55f), 1, 8); for (int i = 1; i <= num2; i++) { float num3 = num * ((float)i / (float)num2); Vector3 point = center + dir * num3; if (!TryFindGround(point, out var hit2) || !IsStandableNormal(((RaycastHit)(ref hit2)).normal)) { return false; } float num4 = ((RaycastHit)(ref hit2)).point.y - val.y; float num5 = val.y - ((RaycastHit)(ref hit2)).point.y; if (num4 > 0.72f || num5 > 0.9f) { return false; } val = ((RaycastHit)(ref hit2)).point; } RaycastHit val2 = default(RaycastHit); if (Physics.SphereCast(center + Vector3.up * 1.45f, 0.18f, dir, ref val2, Mathf.Min(num, 2.2f), TerrainMask, (QueryTriggerInteraction)1)) { float num6 = ((RaycastHit)(ref val2)).point.y - center.y; if (!(num6 <= 0.85f) && !(Vector3.Angle(((RaycastHit)(ref val2)).normal, Vector3.up) <= 68f)) { return false; } } plan = new PathPlan { Action = PathActionType.Direct, Goal = goal, Anchor = goal, TargetAbove = targetAbove, ProjectedEndPoint = val, HasProjectedEndPoint = true, Score = 2f }; return true; } private static bool TryFindPilotTerrainPlan(Character character, Vector3 goal, Vector3 baseDir, out PathPlan plan) { //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); Vector3 center = character.Center; float num = HelperFunctions.FlatDistance(center, goal); float num2 = Mathf.Abs(goal.y - center.y); bool flag = false; float num3 = float.NegativeInfinity; for (int i = 0; i < SearchAngles.Length; i++) { Vector3 val = Quaternion.AngleAxis(SearchAngles[i], Vector3.up) * baseDir; for (int j = 0; j < SearchDistances.Length; j++) { float num4 = SearchDistances[j]; Vector3 point = center + val * num4; if (!TryFindGround(point, out var hit) || !IsStandableNormal(((RaycastHit)(ref hit)).normal)) { continue; } float num5 = ((RaycastHit)(ref hit)).point.y - center.y; float num6 = center.y - ((RaycastHit)(ref hit)).point.y; if (num5 > 2.2f || num6 > 8f) { continue; } float num7 = num - HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, goal); float num8 = num2 - Mathf.Abs(goal.y - ((RaycastHit)(ref hit)).point.y); if (!(num7 < -0.25f) || !(num8 < 0.35f)) { bool flag2 = IsLineBlocked(center, ((RaycastHit)(ref hit)).point); float num9 = num7 * 1.55f + num8 * 0.85f - Mathf.Abs(SearchAngles[i]) * 0.012f - num4 * 0.03f; num9 = (flag2 ? (num9 - 0.3f) : (num9 + 0.55f)); if (!flag || num9 > num3) { flag = true; num3 = num9; plan = new PathPlan { Action = ((!flag2) ? PathActionType.Direct : PathActionType.Detour), Goal = ((RaycastHit)(ref hit)).point, Anchor = ((RaycastHit)(ref hit)).point, TargetAbove = (goal.y - center.y > 1.1f), Score = num9, ProjectedEndPoint = ((RaycastHit)(ref hit)).point, HasProjectedEndPoint = true }; } } } } return flag; } private static bool TryFindPilotDropPlan(Character character, Vector3 goal, Vector3 baseDir, out PathPlan plan) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) plan = new PathPlan(); for (int i = 0; i < SearchAngles.Length; i++) { Vector3 dir = Quaternion.AngleAxis(SearchAngles[i], Vector3.up) * baseDir; if (TryProbePilotRoute(character, dir, 2.6f, out var probe) && TryCreatePilotDropPlan(character, goal, dir, probe, out plan)) { return true; } } return false; } private static bool TryCreatePilotDropPlan(Character character, Vector3 goal, Vector3 dir, RouteProbe probe, out PathPlan plan) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) plan = new PathPlan(); if (!probe.SafeWalkDrop && !probe.SafeJumpDrop) { return false; } Vector3 val = ((probe.DropLandingPoint != Vector3.zero) ? probe.DropLandingPoint : probe.GapLandingPoint); if (val == Vector3.zero) { return false; } float num = (probe.ObstacleAhead ? Mathf.Clamp(probe.ObstacleDistance - 0.25f, 0.75f, 1.45f) : 1.25f); plan = new PathPlan { Action = PathActionType.DropDown, Goal = val, Anchor = character.Center + dir * num, TargetAbove = false, UsesJumpDropImmunity = (probe.SafeJumpDrop && !probe.SafeWalkDrop), RequiredStamina = 0.08f, ExpectedDropHeight = probe.DropHeight, ProjectedEndPoint = val, HasProjectedEndPoint = true, Score = 0f - HelperFunctions.FlatDistance(val, goal) }; return true; } private static void ExecutePilotPlan(Character character, CharacterInput input, PathPlan plan, Vector3 finalGoal, Plugin plugin, int viewId) { //IL_006a: 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_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_0203: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) switch (plan.Action) { case PathActionType.WaitForStamina: HoldStillAtGoal(character, input, finalGoal); if (character.data.isClimbing && !HasStaminaForClimb(character)) { TryStopClimb(character); } break; case PathActionType.Direct: case PathActionType.Detour: { float num3 = HelperFunctions.FlatDistance(character.Center, plan.Goal); bool flag = HasStaminaForJumpOrClimb(character); if (!flag && IsObstacleAhead(character, plan.Goal)) { HoldStillAtGoal(character, input, finalGoal); break; } LookAt(character, plan.Goal); bool sprint = flag && num3 > plugin.HostPilotSprintDistance && HasStaminaForSprint(character); bool jump = flag && plugin.HostPilotAutoJump && ShouldAutoJump(character, plan.Goal); WalkTowards(character, input, plan.Goal, (num3 < 1.6f) ? 0.65f : 1f, sprint, jump, viewId); TryFlatTravelHop(character, input, plan.Goal, viewId); if (plugin.HostPilotAutoClimb && flag && HasStaminaForClimb(character) && IsObstacleAhead(character, plan.Goal)) { TryClimb(character, 1.15f); } break; } case PathActionType.Climb: case PathActionType.JumpGrab: { if (!HasStaminaForClimb(character)) { HoldStillAtGoal(character, input, finalGoal); TryStopClimb(character); break; } float num2 = Vector3.Distance(character.Center, plan.Anchor); if (num2 > 1.25f) { LookAt(character, plan.Anchor); WalkTowards(character, input, plan.Anchor, 1f, num2 > 2f && HasStaminaForSprint(character), jump: false, viewId); break; } LookAt(character, plan.Goal); input.movementInput = new Vector2(0f, 1f); input.sprintIsPressed = false; if (HasStaminaForClimb(character)) { TryClimb(character, 1.55f); if (plan.NeedsJumpStart && character.data.isGrounded && CanAutoJump(viewId)) { input.jumpWasPressed = true; input.jumpIsPressed = true; LastAutoJumpByView[viewId] = Time.time; } } else { input.movementInput = Vector2.zero; } break; } case PathActionType.DropDown: { float num = Vector3.Distance(character.Center, plan.Anchor); if (num > 1.1f) { LookAt(character, plan.Anchor); WalkTowards(character, input, plan.Anchor, 1f, HasStaminaForSprint(character), jump: false, viewId); break; } LookAt(character, plan.Goal); input.movementInput = new Vector2(0f, 1f); input.sprintIsPressed = plan.UsesJumpDropImmunity && HasStaminaForSprint(character); if (plan.UsesJumpDropImmunity && !IsLowStaminaForHeavyAction(character) && character.GetTotalStamina() > plan.RequiredStamina && character.data.isGrounded && CanAutoJump(viewId)) { input.jumpWasPressed = true; input.jumpIsPressed = true; LastAutoJumpByView[viewId] = Time.time; } break; } default: LookAt(character, finalGoal); WalkTowards(character, input, finalGoal, 0.65f, sprint: false, jump: false, viewId); TryFlatTravelHop(character, input, finalGoal, viewId); break; } } private static bool IsPilotSegmentFinished(Character character, PilotState state) { //IL_001f: 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_0031: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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) if (!state.HasActivePlan) { return true; } PathPlan activePlan = state.ActivePlan; float num = HelperFunctions.FlatDistance(character.Center, activePlan.Anchor); float num2 = HelperFunctions.FlatDistance(character.Center, activePlan.Goal); if (activePlan.Action == PathActionType.DropDown) { return num2 <= 1.35f || (num <= 1.05f && character.Center.y < state.SegmentStartPosition.y - 0.9f); } if (activePlan.Action == PathActionType.Climb || activePlan.Action == PathActionType.JumpGrab) { return activePlan.ClimbTopPoint != Vector3.zero && Vector3.Distance(character.Center, activePlan.ClimbTopPoint) <= 1.45f; } return num2 <= 1.35f; } private static bool IsPilotSegmentFailed(Character character, PilotState state, Vector3 finalGoal) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!state.HasActivePlan) { return true; } float num = Time.time - state.SegmentStartTime; if (num < 3.2f) { return false; } float num2 = Vector3.Distance(character.Center, state.SegmentStartPosition); float num3 = state.SegmentStartGoalDistance - Vector3.Distance(character.Center, finalGoal); if (state.ActivePlan.Action == PathActionType.Climb || state.ActivePlan.Action == PathActionType.JumpGrab) { if (character.data.isClimbing && character.GetTotalStamina() >= 0.018f) { return false; } return num2 < 0.65f && num3 < 0.55f; } return num2 < 0.65f && num3 < 0.55f; } private static void WalkTowards(Character character, CharacterInput input, Vector3 target, float intensity, bool sprint, bool jump, int viewId) { //IL_0002: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) LookAt(character, target); input.movementInput = new Vector2(0f, Mathf.Clamp01(intensity)); input.sprintIsPressed = sprint && HasStaminaForSprint(character); if (jump && character.data.isGrounded && HasStaminaForJumpOrClimb(character) && CanAutoJump(viewId)) { input.jumpWasPressed = true; input.jumpIsPressed = true; LastAutoJumpByView[viewId] = Time.time; } } private static bool ShouldWaitForStaminaBeforePushingUp(Character character, Vector3 goal) { //IL_0019: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (HasStaminaForJumpOrClimb(character)) { return false; } if (IsLowStaminaForHeavyAction(character) && !IsFlatTravelHopAllowed(character, goal)) { return true; } float num = goal.y - character.Center.y; if (num > 0.75f) { return true; } return IsObstacleAhead(character, goal); } private static Vector3 ResolvePilotGoal(Character character, Vector3 rawGoal) { //IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (TryProbePilotExactStandableGoal(rawGoal, out var standPoint)) { return standPoint; } if (TryFindPilotStandableAccessNearGoal(character, rawGoal, out var standPoint2)) { return standPoint2; } return rawGoal; } private static bool TryProbePilotExactStandableGoal(Vector3 rawGoal, out Vector3 standPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) standPoint = Vector3.zero; if (!TryFindGround(rawGoal, out var hit) || !IsStandableNormal(((RaycastHit)(ref hit)).normal)) { return false; } if (HelperFunctions.FlatDistance(((RaycastHit)(ref hit)).point, rawGoal) > 1.05f || Mathf.Abs(((RaycastHit)(ref hit)).point.y - rawGoal.y) > 1.2f) { return false; } standPoint = ((RaycastHit)(ref hit)).point; return true; } private static bool TryFindPilotStandableAccessNearGoal(Character character, Vector3 rawGoal, out Vector3 standPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) standPoint = Vector3.zero; float[] array = new float[6] { 0.55f, 1.1f, 1.8f, 2.7f, 3.8f, 5.2f }; float[] array2 = new float[8] { 0f, 45f, -45f, 90f, -90f, 135f, -135f, 180f }; bool flag = false; float num = float.NegativeInfinity; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array2.Length; j++) { Vector3 val = Quaternion.AngleAxis(array2[j], Vector3.up) * Vector3.forward * array[i]; Vector3 val2 = rawGoal + val + Vector3.up * 7f; if (!Physics.Raycast(val2, Vector3.down, ref val3, 13.5f, TerrainMask, (QueryTriggerInteraction)1) || !IsStandableNormal(((RaycastHit)(ref val3)).normal)) { continue; } float num2 = HelperFunctions.FlatDistance(((RaycastHit)(ref val3)).point, rawGoal); if (!(num2 > 5.85f)) { float num3 = ((RaycastHit)(ref val3)).point.y - rawGoal.y; float num4 = ((num3 < -0.45f) ? (Mathf.Abs(num3) * 1.85f + 1.4f) : 0f); float num5 = Vector3.Distance(character.Center, ((RaycastHit)(ref val3)).point); float num6 = 0f; num6 -= num2 * 1.35f; num6 -= Mathf.Abs(num3) * 0.75f; num6 -= num4; num6 -= num5 * 0.06f; if (num3 >= -0.35f) { num6 += 1.6f; } if (!flag || num6 > num) { flag = true; num = num6; standPoint = ((RaycastHit)(ref val3)).point; } } } } return flag; } private static bool CanAutoJump(int viewId) { float value; return !LastAutoJumpByView.TryGetValue(viewId, out value) || Time.time - value >= 0.24f; } private static void LookAt(Character character, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point; if (Mathf.Abs(point.y - character.Center.y) < 0.5f) { val.y = character.Head.y; } else { val += Vector3.up * 0.25f; } Vector3 val2 = val - character.Head; if (((Vector3)(ref val2)).sqrMagnitude > 0.001f) { character.data.lookValues = Vector2.op_Implicit(HelperFunctions.DirectionToLook(val2)); } } private static void TryClimb(Character character, float distance) { try { if (character.refs != null && (Object)(object)character.refs.climbing != (Object)null && HasStaminaForClimb(character)) { character.refs.climbing.TryClimb(distance); } } catch { } } private static void TryStopClimb(Character character) { try { if (character.refs != null && (Object)(object)character.refs.climbing != (Object)null) { character.refs.climbing.StopClimbing(); } } catch { } } private static bool IsLowStaminaForHeavyAction(Character character) { return (Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || character.OutOfStamina() || character.GetTotalStamina() <= 0.08f; } private static bool HasStaminaForSprint(Character character) { return (Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && !character.OutOfStamina() && character.GetTotalStamina() >= 0.12f && character.CheckSprint(); } private static bool HasStaminaForJumpOrClimb(Character character) { return (Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && !character.OutOfStamina() && character.GetTotalStamina() >= 0.4f; } private static bool HasStaminaForClimb(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || character.OutOfStamina()) { return false; } if (character.data.isClimbing) { return character.GetTotalStamina() >= 0.018f; } return character.GetTotalStamina() >= 0.4f; } private static bool IsFlatTravelHopAllowed(Character character, Vector3 target) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null || !character.data.isGrounded) { return false; } if (Vector3.Distance(character.Center, target) < 2f) { return false; } if (!TryFindGround(character.Center, out var hit) || !TryFindGround(target, out var hit2)) { return false; } if (Mathf.Abs(((RaycastHit)(ref hit2)).point.y - ((RaycastHit)(ref hit)).point.y) > 0.45f) { return false; } return !IsObstacleAhead(character, target); } private static void TryFlatTravelHop(Character character, CharacterInput input, Vector3 target, int viewId) { //IL_000a: 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) if (IsLowStaminaForHeavyAction(character) && IsFlatTravelHopAllowed(character, target) && CanAutoJump(viewId)) { input.sprintIsPressed = false; input.movementInput = new Vector2(0f, 1f); input.jumpWasPressed = true; input.jumpIsPressed = true; LastAutoJumpByView[viewId] = Time.time; } } private static bool ShouldAutoJump(Character character, Vector3 target) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!character.data.isGrounded || !HasStaminaForJumpOrClimb(character)) { return false; } Vector3 val = target - character.Center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = character.Head + Vector3.down * 0.45f; RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(val2, val, ref val3, 1.05f, TerrainMask, (QueryTriggerInteraction)1)) { return false; } float num = ((RaycastHit)(ref val3)).point.y - character.Center.y; return num > -0.35f && num < 1.15f; } private static bool IsObstacleAhead(Character character, Vector3 target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0058: Unknown result type (might be due to invalid IL or missing references) Vector3 val = target - character.Center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); RaycastHit val2 = default(RaycastHit); return Physics.SphereCast(character.Center + Vector3.up * 1f, 0.22f, val, ref val2, 1.25f, TerrainMask, (QueryTriggerInteraction)1); } private static bool TryProbePilotRoute(Character character, Vector3 dir, float distance, out RouteProbe probe) { //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_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_0120: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) probe = default(RouteProbe); Vector3 center = character.Center; RaycastHit val = default(RaycastHit); if (Physics.SphereCast(center + Vector3.up * 1f, 0.24f, dir, ref val, distance, TerrainMask, (QueryTriggerInteraction)1)) { bool flag = false; Vector3 point = center + dir * Mathf.Clamp(((RaycastHit)(ref val)).distance + 0.55f, 0.45f, 1.65f); if (TryFindGround(point, out var hit) && IsStandableNormal(((RaycastHit)(ref hit)).normal)) { float num = ((RaycastHit)(ref hit)).point.y - center.y; float num2 = ((RaycastHit)(ref val)).point.y - center.y; flag = num >= -0.9f && num <= 0.72f && num2 <= 0.85f; } if (!flag) { probe.ObstacleAhead = true; probe.ObstacleDistance = ((RaycastHit)(ref val)).distance; probe.ObstaclePoint = ((RaycastHit)(ref val)).point; } } Vector3 point2 = center + dir * 1.45f; Vector3 point3 = center + dir * 3.6f; RaycastHit hit2; bool flag2 = TryFindGround(point2, out hit2); RaycastHit hit3; bool flag3 = TryFindGround(point3, out hit3); if (!flag2 || center.y - ((RaycastHit)(ref hit2)).point.y > 8f) { probe.UnsafeDropAhead = true; probe.DropHeight = (flag2 ? (center.y - ((RaycastHit)(ref hit2)).point.y) : 16f); } if (flag3 && IsStandableNormal(((RaycastHit)(ref hit3)).normal)) { float num3 = center.y - ((RaycastHit)(ref hit3)).point.y; if (num3 <= 16f) { probe.GapJumpable = true; probe.SafeJumpDrop = true; probe.GapLandingPoint = ((RaycastHit)(ref hit3)).point; probe.DropLandingPoint = ((RaycastHit)(ref hit3)).point; probe.GapLandingDrop = num3; probe.DropHeight = num3; if (num3 <= 8f && (!flag2 || center.y - ((RaycastHit)(ref hit2)).point.y > 1.25f)) { probe.SafeWalkDrop = true; } } } TryProbePilotClimb(character, dir, distance + 0.8f, ref probe); return true; } private static void TryProbePilotClimb(Character character, Vector3 dir, float distance, ref RouteProbe probe) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Vector3 center = character.Center; float[] array = new float[6] { 0.55f, 0.85f, 1.2f, 1.65f, 2.1f, 2.65f }; RaycastHit val2 = default(RaycastHit); foreach (float num in array) { if (num > distance + 0.35f) { continue; } Vector3 val = center + dir * num; if (Physics.Raycast(val + Vector3.up * 5.2f, Vector3.down, ref val2, 6.3f, TerrainMask, (QueryTriggerInteraction)1)) { float num2 = ((RaycastHit)(ref val2)).point.y - center.y; if (!(num2 < 0.35f) && !(num2 > 4.7f) && IsClimbTopNormal(((RaycastHit)(ref val2)).normal)) { probe.ClimbableAhead = true; probe.ClimbHeightDelta = num2; probe.ClimbBasePoint = center + dir * Mathf.Clamp(num - 0.2f, 0.45f, distance); probe.ClimbTopPoint = ((RaycastHit)(ref val2)).point; probe.ClimbSurfaceNormal = -dir; probe.NeedsJumpStart = num2 >= 1f; break; } } } } private static bool TryFindGround(Vector3 point, out RaycastHit hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Physics.Raycast(point + Vector3.up * 2.2f, Vector3.down, ref hit, 15f, TerrainMask, (QueryTriggerInteraction)1); } private static bool IsLineBlocked(Vector3 from, Vector3 to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = HelperFunctions.LineCheck(from + Vector3.up * 0.65f, to + Vector3.up * 0.65f, (LayerType)1, 0f, (QueryTriggerInteraction)1); if (!((Object)(object)((RaycastHit)(ref val)).transform != (Object)null)) { return false; } val = HelperFunctions.LineCheck(from + Vector3.up * 1.25f, to + Vector3.up * 1.25f, (LayerType)1, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref val)).transform != (Object)null; } private static bool IsStandableNormal(Vector3 normal) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return ((Vector3)(ref normal)).sqrMagnitude >= 0.01f && Vector3.Angle(normal, Vector3.up) <= 68f; } private static bool IsClimbTopNormal(Vector3 normal) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return ((Vector3)(ref normal)).sqrMagnitude >= 0.01f && Vector3.Angle(normal, Vector3.up) <= 72f; } } internal struct RobotFeedState { public Character? feeder; public Character? target; public Optionable feederSlot; public NetworkRobotAgent? agent; } [HarmonyPatch(typeof(Item), "FinishCastSecondary")] internal static class ItemFinishCastSecondaryPatch { [HarmonyPrefix] private static void Prefix(Item __instance, ref RobotFeedState __state) { //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) __state = default(RobotFeedState); try { if ((Object)(object)__instance == (Object)null || !__instance.canUseOnFriend || (Object)(object)Interaction.instance == (Object)null || !Interaction.instance.hasValidTargetCharacter) { return; } CharacterInteractible bestCharacter = Interaction.instance.bestCharacter; if ((Object)(object)bestCharacter == (Object)null || (Object)(object)bestCharacter.character == (Object)null) { return; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(bestCharacter.character); if (!((Object)(object)agent == (Object)null)) { Character holderCharacter = __instance.holderCharacter; if (!((Object)(object)holderCharacter == (Object)null)) { __state = new RobotFeedState { feeder = holderCharacter, target = bestCharacter.character, feederSlot = holderCharacter.refs.items.currentSelectedSlot, agent = agent }; } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"ItemFinishCastSecondaryPatch Prefix failed: {arg}"); } } [HarmonyPostfix] private static void Postfix(Item __instance, RobotFeedState __state) { //IL_00b5: 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) try { if ((Object)(object)__state.agent == (Object)null || (Object)(object)__state.feeder == (Object)null || (Object)(object)__state.target == (Object)null) { return; } __state.agent.NotifyFedByPlayer(__state.feeder, __instance); if (!__instance.consuming) { return; } Character feeder = __state.feeder; if (feeder.IsLocal && !__state.feederSlot.IsNone) { byte value = __state.feederSlot.Value; feeder.data.lastConsumedItem = Time.time; feeder.player.EmptySlot(Optionable.Some(value)); feeder.refs.items.EquipSlot(Optionable.Some(value)); if (feeder.player.itemsChangedAction != null) { feeder.player.itemsChangedAction(feeder.player.itemSlots); } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"ItemFinishCastSecondaryPatch Postfix failed: {arg}"); } } } [HarmonyPatch(typeof(MushroomZombie), "Update")] internal static class MushroomRobotUpdatePatch { [HarmonyPrefix] private static bool Prefix(MushroomZombie __instance) { if (!NetworkRobotAgent.TryGetForZombie(__instance, out NetworkRobotAgent agent) || (Object)(object)agent == (Object)null) { return true; } if (!agent.Controls(__instance)) { return true; } if (agent.ShouldUseVanillaBiteControl(__instance)) { return true; } try { agent.Tick(); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"NetworkRobotAgent.Tick failed: {arg}"); } return false; } } [HarmonyPatch] internal static class PointPingerReceivePatch { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(PointPinger), "ReceivePoint_Rpc", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); } [HarmonyPostfix] private static void Postfix(PointPinger __instance, Vector3 point) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) try { PingTargetTracker.SetPing(((Object)(object)__instance != (Object)null) ? __instance.character : null, point); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"PointPingerReceivePatch failed: {arg}"); } } } internal static class PingTargetTracker { private static readonly Dictionary LastPingByActor = new Dictionary(); private static readonly Dictionary LastPingByCharacterViewId = new Dictionary(); private static readonly Dictionary CharacterByActor = new Dictionary(); private static readonly Dictionary CharacterByViewId = new Dictionary(); private static readonly List RemoveBuffer = new List(); private static int _sequence; private static float _nextCharacterCacheRefreshTime; public const float PingLifetime = 30f; private const float CharacterCacheRefreshInterval = 1f; private const float DuplicatePingWindow = 0.08f; private const float DuplicatePingDistanceSq = 0.0025000002f; private static int GetActorKey(Character? character) { if ((Object)(object)character == (Object)null || (Object)(object)((MonoBehaviourPun)character).photonView == (Object)null) { return 0; } return ((MonoBehaviourPun)character).photonView.OwnerActorNr; } private static int GetViewKey(Character? character) { if ((Object)(object)character == (Object)null || (Object)(object)((MonoBehaviourPun)character).photonView == (Object)null) { return 0; } return ((MonoBehaviourPun)character).photonView.ViewID; } public static void SetPing(Character? character, Vector3 point) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) int actorKey = GetActorKey(character); int viewKey = GetViewKey(character); if (viewKey <= 0) { viewKey = GetViewKey(character); } if (viewKey <= 0 && actorKey <= 0) { return; } bool flag = (Object)(object)RobotInteractionUtil.GetAgent(character) != (Object)null; if (actorKey > 0 && !flag && LastPingByActor.TryGetValue(actorKey, out var value) && Time.time - value.Time <= 0.08f) { Vector3 val = value.Point - point; if (((Vector3)(ref val)).sqrMagnitude <= 0.0025000002f) { value.Time = Time.time; value.OwnerCharacter = character; value.OwnerViewId = viewKey; LastPingByActor[actorKey] = value; if (viewKey > 0) { LastPingByCharacterViewId[viewKey] = value; } return; } } PingTargetData pingTargetData = default(PingTargetData); pingTargetData.Point = point; pingTargetData.Time = Time.time; pingTargetData.Sequence = ++_sequence; pingTargetData.OwnerActorNumber = actorKey; pingTargetData.OwnerViewId = viewKey; pingTargetData.OwnerCharacter = character; PingTargetData value2 = pingTargetData; if (viewKey > 0) { LastPingByCharacterViewId[viewKey] = value2; } if (actorKey > 0 && !flag) { LastPingByActor[actorKey] = value2; } } public static bool TryGetBestPingForRobot(Character? robotCharacter, int robotOwnerActorNumber, Vector3 robotPos, out Character? owner, out Vector3 point) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; return TryGetLatestActorPing(out owner, out point); } public static bool TryGetBestPingDataForRobot(Character? robotCharacter, int robotOwnerActorNumber, Vector3 robotPos, out PingTargetData data) { data = default(PingTargetData); return TryGetLatestActorPingData(out data); } public static bool TryGetBestPingForCharacter(Character character, bool acceptOtherPlayers, out Character? owner, out Vector3 point) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; if ((Object)(object)character == (Object)null) { return false; } return acceptOtherPlayers ? TryGetLatestActorPing(out owner, out point) : TryGetPing(character, out owner, out point); } public static bool TryGetBestPingDataForCharacter(Character character, bool acceptOtherPlayers, out PingTargetData data) { data = default(PingTargetData); if ((Object)(object)character == (Object)null) { return false; } return acceptOtherPlayers ? TryGetLatestActorPingData(out data) : TryGetPingData(character, out data); } public static bool TryGetLatestPingForRobot(Vector3 robotPos, out Character? owner, out Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGetBestPingForRobot(null, 0, robotPos, out owner, out point); } public static bool TryGetPing(Character character, out Vector3 point) { Character owner; return TryGetPing(character, out owner, out point); } public static bool TryGetPing(Character character, out Character? owner, out Vector3 point) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; if ((Object)(object)character == (Object)null) { return false; } int viewKey = GetViewKey(character); if (viewKey > 0 && TryGetPingByViewId(viewKey, out owner, out point)) { return true; } return TryGetPingByActor(GetActorKey(character), out owner, out point); } private static bool TryGetPingData(Character character, out PingTargetData data) { data = default(PingTargetData); if ((Object)(object)character == (Object)null) { return false; } int viewKey = GetViewKey(character); if (viewKey > 0 && TryGetPingDataByViewId(viewKey, out data)) { return true; } return TryGetPingDataByActor(GetActorKey(character), out data); } private static bool TryGetLatestActorPingData(out PingTargetData data) { data = default(PingTargetData); int num = int.MinValue; bool flag = false; RemoveBuffer.Clear(); foreach (KeyValuePair item in LastPingByActor) { PingTargetData data2 = item.Value; if (!TryResolveValidPingOwnerByActor(item.Key, ref data2, out Character owner)) { RemoveBuffer.Add(item.Key); } else if (!flag || data2.Sequence > num) { flag = true; num = data2.Sequence; data2.OwnerCharacter = owner; data = data2; } } RemoveActorBuffer(); return flag; } private static bool TryGetPingDataByActor(int actorNumber, out PingTargetData data) { data = default(PingTargetData); if (actorNumber <= 0 || !LastPingByActor.TryGetValue(actorNumber, out var data2)) { return false; } if (!TryResolveValidPingOwnerByActor(actorNumber, ref data2, out Character owner)) { LastPingByActor.Remove(actorNumber); return false; } data2.OwnerCharacter = owner; LastPingByActor[actorNumber] = data2; data = data2; return true; } private static bool TryGetPingDataByViewId(int viewId, out PingTargetData data) { data = default(PingTargetData); if (viewId <= 0 || !LastPingByCharacterViewId.TryGetValue(viewId, out var data2)) { return false; } if (!TryResolveValidPingOwnerByViewId(viewId, ref data2, out Character owner)) { LastPingByCharacterViewId.Remove(viewId); return false; } data2.OwnerCharacter = owner; LastPingByCharacterViewId[viewId] = data2; data = data2; return true; } private static bool TryGetLatestActorPing(out Character? owner, out Vector3 point) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; int num = int.MinValue; bool flag = false; RemoveBuffer.Clear(); foreach (KeyValuePair item in LastPingByActor) { PingTargetData data = item.Value; if (!TryResolveValidPingOwnerByActor(item.Key, ref data, out Character owner2)) { RemoveBuffer.Add(item.Key); } else if (!flag || data.Sequence > num) { flag = true; num = data.Sequence; owner = owner2; point = data.Point; } } RemoveActorBuffer(); return flag; } private static bool TryGetPingByActor(int actorNumber, out Character? owner, out Vector3 point) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; if (actorNumber <= 0 || !LastPingByActor.TryGetValue(actorNumber, out var data)) { return false; } if (!TryResolveValidPingOwnerByActor(actorNumber, ref data, out Character owner2)) { LastPingByActor.Remove(actorNumber); return false; } data.OwnerCharacter = owner2; LastPingByActor[actorNumber] = data; owner = owner2; point = data.Point; return true; } private static bool TryGetPingByViewId(int viewId, out Character? owner, out Vector3 point) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) owner = null; point = Vector3.zero; if (viewId <= 0 || !LastPingByCharacterViewId.TryGetValue(viewId, out var data)) { return false; } if (!TryResolveValidPingOwnerByViewId(viewId, ref data, out Character owner2)) { LastPingByCharacterViewId.Remove(viewId); return false; } data.OwnerCharacter = owner2; LastPingByCharacterViewId[viewId] = data; owner = owner2; point = data.Point; return true; } private static bool TryResolveValidPingOwnerByActor(int actorNumber, ref PingTargetData data, out Character? owner) { owner = null; if (Time.time - data.Time > 30f) { return false; } Character val = data.OwnerCharacter; if (!IsValidPlayerPingOwner(val) || GetActorKey(val) != actorNumber) { val = FindCharacterByActor(actorNumber); } if (!IsValidPlayerPingOwner(val)) { return false; } data.OwnerCharacter = val; data.OwnerActorNumber = actorNumber; data.OwnerViewId = GetViewKey(val); owner = val; return true; } private static bool TryResolveValidPingOwnerByViewId(int viewId, ref PingTargetData data, out Character? owner) { owner = null; if (Time.time - data.Time > 30f) { return false; } Character val = data.OwnerCharacter; if (!IsValidAnyPingOwner(val) || GetViewKey(val) != viewId) { val = FindCharacterByViewId(viewId); } if (!IsValidAnyPingOwner(val)) { return false; } data.OwnerCharacter = val; data.OwnerActorNumber = GetActorKey(val); data.OwnerViewId = viewId; owner = val; return true; } private static Character? FindCharacterByActor(int actorNumber) { if (actorNumber <= 0) { return null; } RefreshCharacterCacheIfNeeded(); Character value; return CharacterByActor.TryGetValue(actorNumber, out value) ? value : null; } private static Character? FindCharacterByViewId(int viewId) { if (viewId <= 0) { return null; } RefreshCharacterCacheIfNeeded(); Character value; return CharacterByViewId.TryGetValue(viewId, out value) ? value : null; } private static void RefreshCharacterCacheIfNeeded() { if (Time.time < _nextCharacterCacheRefreshTime) { return; } _nextCharacterCacheRefreshTime = Time.time + 1f; CharacterByActor.Clear(); CharacterByViewId.Clear(); foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null) && !((Object)(object)allCharacter.data == (Object)null)) { int viewID = ((MonoBehaviourPun)allCharacter).photonView.ViewID; if (viewID > 0) { CharacterByViewId[viewID] = allCharacter; } int ownerActorNr = ((MonoBehaviourPun)allCharacter).photonView.OwnerActorNr; if (ownerActorNr > 0 && (Object)(object)RobotInteractionUtil.GetAgent(allCharacter) == (Object)null && IsValidPlayerPingOwner(allCharacter)) { CharacterByActor[ownerActorNr] = allCharacter; } } } for (int num = NetworkRobotAgent.All.Count - 1; num >= 0; num--) { NetworkRobotAgent networkRobotAgent = NetworkRobotAgent.All[num]; Character val = (((Object)(object)networkRobotAgent != (Object)null) ? networkRobotAgent.Character : null); if ((Object)(object)networkRobotAgent == (Object)null || (Object)(object)val == (Object)null || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null) { if ((Object)(object)networkRobotAgent == (Object)null) { NetworkRobotAgent.All.RemoveAt(num); } } else { int viewID2 = ((MonoBehaviourPun)val).photonView.ViewID; if (viewID2 > 0) { CharacterByViewId[viewID2] = val; } } } } private static bool IsValidPlayerPingOwner(Character? character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } if ((Object)(object)RobotInteractionUtil.GetAgent(character) != (Object)null) { return false; } if (character.data.dead || character.data.fullyPassedOut) { return false; } return GetActorKey(character) > 0; } private static bool IsValidAnyPingOwner(Character? character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } if (character.data.dead || character.data.fullyPassedOut) { return false; } return GetActorKey(character) > 0 || GetViewKey(character) > 0; } private static void RemoveActorBuffer() { for (int i = 0; i < RemoveBuffer.Count; i++) { LastPingByActor.Remove(RemoveBuffer[i]); } RemoveBuffer.Clear(); } public static void ClearPing(Character character) { if (!((Object)(object)character == (Object)null)) { int actorKey = GetActorKey(character); if (actorKey > 0 && (Object)(object)RobotInteractionUtil.GetAgent(character) == (Object)null) { LastPingByActor.Remove(actorKey); } int viewKey = GetViewKey(character); if (viewKey > 0) { LastPingByCharacterViewId.Remove(viewKey); } } } } [BepInPlugin("com.elizabeth.peak.pingdrivenrobots", "PingDrivenRobots", "1.3.3")] public sealed class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__46 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Character 5__1; private Vector3 5__2; private Quaternion 5__3; private Bodypart 5__4; private GameObject 5__5; private MushroomZombie 5__6; private NetworkRobotAgent 5__7; private Vector3 5__8; private object[] 5__9; private Exception 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__46(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__4 = null; 5__5 = null; 5__6 = null; 5__7 = null; 5__9 = null; 5__10 = null; <>1__state = -2; } private bool MoveNext() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this._isSpawning = true; 5__1 = Character.localCharacter; if ((Object)(object)5__1 == (Object)null) { <>4__this._isSpawning = false; return false; } 5__2 = 5__1.Center; 5__3 = Quaternion.identity; 5__4 = 5__1.GetBodypart((BodypartType)2); if ((Object)(object)5__4 != (Object)null) { 5__2 = ((Component)5__4).transform.position; 5__3 = ((Component)5__4).transform.rotation; } if (<>4__this._spawnNearPlayer.Value) { 5__8 = 5__1.data.lookDirection; if (5__8 == Vector3.zero) { 5__8 = ((Component)5__1).transform.forward; } 5__8.y = 0f; if (((Vector3)(ref 5__8)).sqrMagnitude < 0.001f) { 5__8 = Vector3.forward; } ((Vector3)(ref 5__8)).Normalize(); 5__2 += 5__8 * <>4__this._spawnForwardOffset.Value; } try { 5__9 = new object[2] { (PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0, (PhotonNetwork.LocalPlayer != null) ? (PhotonNetwork.LocalPlayer.UserId ?? string.Empty) : string.Empty }; 5__5 = PhotonNetwork.Instantiate(<>4__this._robotPrefabName.Value, 5__2, 5__3, (byte)0, 5__9); 5__9 = null; } catch (Exception ex) { 5__10 = ex; Log.LogError((object)$"Failed to instantiate robot prefab '{<>4__this._robotPrefabName.Value}': {5__10}"); <>4__this._isSpawning = false; return false; } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if ((Object)(object)5__5 == (Object)null) { Log.LogError((object)"Robot instantiate returned null."); <>4__this._isSpawning = false; return false; } 5__6 = 5__5.GetComponent(); if ((Object)(object)5__6 == (Object)null) { Log.LogError((object)"Spawned object does not contain MushroomZombie component. Keep RobotPrefabName on a networked character prefab this mod knows how to drive."); <>4__this._isSpawning = false; return false; } 5__6.isNPCZombie = false; 5__6.spawner = null; 5__6.lifetime = 999999f; if ((Object)(object)ZombieManager.Instance != (Object)null) { ZombieManager.Instance.DeRegisterZombie(5__6); } if ((Object)(object)5__6.character == (Object)null || (Object)(object)5__6.character.data == (Object)null) { Log.LogError((object)"Spawned robot has no Character or CharacterData."); SafeDestroySpawnedObject(5__5); <>4__this._isSpawning = false; return false; } 5__6.character.isZombie = true; 5__6.character.isBot = true; 5__6.character.data.passedOut = false; 5__6.character.data.fullyPassedOut = false; 5__6.character.data.dead = false; 5__6.character.data.fallSeconds = 0f; 5__6.character.data.currentRagdollControll = 1f; 5__6.currentState = (State)2; if (!5__6.visible) { ((MonoBehaviour)5__6).StartCoroutine(5__6.RevealZombie()); } 5__7 = ((Component)5__6).gameObject.GetComponent(); if ((Object)(object)5__7 == (Object)null) { 5__7 = ((Component)5__6).gameObject.AddComponent(); } 5__7.Initialize(5__6); Log.LogInfo((object)"Spawned one controlled network robot. It follows the newest valid ping target from any real player."); <>4__this._isSpawning = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string ModGuid = "com.elizabeth.peak.pingdrivenrobots"; public const string ModName = "PingDrivenRobots"; public const string ModVersion = "1.3.3"; internal static ManualLogSource Log; internal static Plugin Instance; private Harmony _harmony = null; private ConfigEntry _spawnKey = null; private ConfigEntry _deleteKey = null; private ConfigEntry _robotPrefabName = null; private ConfigEntry _spawnForwardOffset = null; private ConfigEntry _spawnNearPlayer = null; private ConfigEntry _biteKey = null; private ConfigEntry _carryPlayerKey = null; private ConfigEntry _toggleHostPilotKey = null; private ConfigEntry _hostPilotEnabledByDefault = null; private ConfigEntry _hostPilotManualOverride = null; private ConfigEntry _hostPilotArriveDistance = null; private ConfigEntry _hostPilotSprintDistance = null; private ConfigEntry _hostPilotAutoJump = null; private ConfigEntry _hostPilotAutoClimb = null; private ConfigEntry _hostPilotAcceptOtherPlayersPingTargets = null; private const float SpawnInputDebounceSeconds = 0.2f; private bool _isSpawning; private bool _hostPilotEnabled; private float _nextSpawnAllowedTime; internal bool ShouldHostPilotRun => _hostPilotEnabled; internal bool HostPilotManualOverride => _hostPilotManualOverride != null && _hostPilotManualOverride.Value; internal float HostPilotArriveDistance => (_hostPilotArriveDistance != null) ? Mathf.Max(0.25f, _hostPilotArriveDistance.Value) : 1.25f; internal float HostPilotSprintDistance => (_hostPilotSprintDistance != null) ? Mathf.Max(0.5f, _hostPilotSprintDistance.Value) : 3f; internal bool HostPilotAutoJump => _hostPilotAutoJump != null && _hostPilotAutoJump.Value; internal bool HostPilotAutoClimb => _hostPilotAutoClimb != null && _hostPilotAutoClimb.Value; internal bool HostPilotAcceptOtherPlayersPingTargets => _hostPilotAcceptOtherPlayersPingTargets != null && _hostPilotAcceptOtherPlayersPingTargets.Value; private void Awake() { //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"PingDrivenRobots: duplicate plugin instance detected; the duplicate will be disabled to prevent duplicate input processing."); ((Behaviour)this).enabled = false; Object.Destroy((Object)(object)this); return; } Instance = this; Log = ((BaseUnityPlugin)this).Logger; _spawnKey = ((BaseUnityPlugin)this).Config.Bind("Robot", "SpawnRobotKey", (KeyCode)106, "Spawn one controlled network robot near the host player."); _deleteKey = ((BaseUnityPlugin)this).Config.Bind("Robot", "DeleteRobotKey", (KeyCode)107, "Delete the nearest controlled network robot owned by you."); _robotPrefabName = ((BaseUnityPlugin)this).Config.Bind("Robot", "RobotPrefabName", "MushroomZombie", "Photon prefab name used as the controlled robot body. Default stays MushroomZombie because this is the game's networked creature prefab."); _spawnForwardOffset = ((BaseUnityPlugin)this).Config.Bind("Robot", "SpawnForwardOffset", 2.5f, "How far in front of the host player to spawn the robot."); _spawnNearPlayer = ((BaseUnityPlugin)this).Config.Bind("Robot", "SpawnNearPlayer", true, "Spawn the robot near the host player."); _biteKey = ((BaseUnityPlugin)this).Config.Bind("RobotCommands", "BiteNearestRobotKey", (KeyCode)98, "Make the nearest owned robot perform one manual bite lunge."); _carryPlayerKey = ((BaseUnityPlugin)this).Config.Bind("RobotCommands", "CarryNearestPlayerKey", (KeyCode)110, "Toggle carry-assist on the nearest owned robot. It will seek and carry the nearest living player, including passed-out players."); _toggleHostPilotKey = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "ToggleHostPilotKey", (KeyCode)104, "Toggle AI/code control for the host's real player body."); _hostPilotEnabledByDefault = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "EnabledByDefault", false, "When true, the host player starts under ping-driven pilot control after loading in."); _hostPilotManualOverride = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "ManualOverride", true, "When true, normal player movement/look/action input temporarily wins over the host pilot."); _hostPilotArriveDistance = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "ArriveDistance", 1.25f, "Flat distance at which the host pilot stops at the ping point."); _hostPilotSprintDistance = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "SprintDistance", 3f, "Flat distance above which the host pilot requests sprint."); _hostPilotAutoJump = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "AutoJump", true, "Let the host pilot tap jump for small obstacles and upward goals."); _hostPilotAutoClimb = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "AutoClimb", true, "Let the host pilot call the game's climb helper while following pings."); _hostPilotAcceptOtherPlayersPingTargets = ((BaseUnityPlugin)this).Config.Bind("HostPilot", "AcceptOtherPlayersPingTargets", false, "When true, the host pilot follows the newest valid ping from any player. When false, it follows the host player's own ping."); _hostPilotEnabled = _hostPilotEnabledByDefault.Value; _harmony = new Harmony("com.elizabeth.peak.pingdrivenrobots"); _harmony.PatchAll(); Log.LogInfo((object)string.Format("{0} loaded. HostPilot={1}.", "PingDrivenRobots", _hostPilotEnabled)); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception arg) { if (Log != null) { Log.LogDebug((object)$"UnpatchSelf failed: {arg}"); } } } private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) try { if (Input.GetKeyDown(_toggleHostPilotKey.Value)) { _hostPilotEnabled = !_hostPilotEnabled; Log.LogInfo((object)(_hostPilotEnabled ? "Host player pilot enabled. The host remains a real player; only input is overridden when no manual input is active." : "Host player pilot disabled. Manual host control restored.")); } else if (Input.GetKeyDown(_deleteKey.Value)) { DeleteNearestRobot(); } else if (Input.GetKeyDown(_biteKey.Value)) { CommandNearestRobotBite(); } else if (Input.GetKeyDown(_carryPlayerKey.Value)) { ToggleNearestRobotCarryAssist(); } else if (Input.GetKeyDown(_spawnKey.Value) && !_isSpawning) { if (!PhotonNetwork.InRoom) { Log.LogWarning((object)"Not in a room."); } else if ((Object)(object)Character.localCharacter == (Object)null) { Log.LogWarning((object)"Local character not found."); } else if (!(Time.unscaledTime < _nextSpawnAllowedTime)) { _nextSpawnAllowedTime = Time.unscaledTime + 0.2f; ((MonoBehaviour)this).StartCoroutine(SpawnRobotRoutine()); } } } catch (Exception arg) { Log.LogDebug((object)$"Plugin.Update failed: {arg}"); } } private NetworkRobotAgent? FindNearestRobotToLocal() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.InRoom) { Log.LogWarning((object)"Not in a room."); return null; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Log.LogWarning((object)"Local character not found."); return null; } NetworkRobotAgent networkRobotAgent = NetworkRobotAgent.FindNearestOwnedByLocal(localCharacter.Center); if ((Object)(object)networkRobotAgent == (Object)null || (Object)(object)networkRobotAgent.Character == (Object)null) { Log.LogInfo((object)"No controlled robot found."); return null; } return networkRobotAgent; } private void CommandNearestRobotBite() { try { NetworkRobotAgent networkRobotAgent = FindNearestRobotToLocal(); if (!((Object)(object)networkRobotAgent == (Object)null)) { Character val = null; try { val = (((Object)(object)Interaction.instance != (Object)null && (Object)(object)Interaction.instance.bestCharacter != (Object)null) ? Interaction.instance.bestCharacter.character : null); } catch { val = null; } if (networkRobotAgent.RequestManualBite(val, out string message)) { Log.LogInfo((object)message); } else { Log.LogWarning((object)message); } } } catch (Exception arg) { Log.LogDebug((object)$"CommandNearestRobotBite failed: {arg}"); } } private void ToggleNearestRobotCarryAssist() { try { NetworkRobotAgent networkRobotAgent = FindNearestRobotToLocal(); if (!((Object)(object)networkRobotAgent == (Object)null)) { if (networkRobotAgent.ToggleCarryAssist(out string message)) { Log.LogInfo((object)message); } else { Log.LogWarning((object)message); } } } catch (Exception arg) { Log.LogDebug((object)$"ToggleNearestRobotCarryAssist failed: {arg}"); } } private void DeleteNearestRobot() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) try { if (!PhotonNetwork.InRoom) { Log.LogWarning((object)"Not in a room."); return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Log.LogWarning((object)"Local character not found."); return; } NetworkRobotAgent networkRobotAgent = NetworkRobotAgent.FindNearestOwnedByLocal(localCharacter.Center); if ((Object)(object)networkRobotAgent == (Object)null || (Object)(object)networkRobotAgent.Character == (Object)null) { Log.LogInfo((object)"No controlled robot found to delete."); return; } int num = (((Object)(object)networkRobotAgent.View != (Object)null) ? networkRobotAgent.View.ViewID : (-1)); networkRobotAgent.DeleteRobotNetworked(); Log.LogInfo((object)$"Deleted controlled robot [{num}]."); } catch (Exception arg) { Log.LogDebug((object)$"DeleteNearestRobot failed: {arg}"); } } [IteratorStateMachine(typeof(d__46))] private IEnumerator SpawnRobotRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__46(0) { <>4__this = this }; } private static void SafeDestroySpawnedObject(GameObject obj) { try { if (!((Object)(object)obj == (Object)null)) { PhotonView component = obj.GetComponent(); if ((Object)(object)component != (Object)null && PhotonNetwork.InRoom) { PhotonNetwork.Destroy(obj); } else { Object.Destroy((Object)(object)obj); } } } catch (Exception arg) { Log.LogDebug((object)$"SafeDestroySpawnedObject failed: {arg}"); try { Object.Destroy((Object)(object)obj); } catch { } } } } internal static class MushroomRobotProxyExtensions { private static readonly MethodInfo? UpdateMouthMethod = AccessTools.Method(typeof(MushroomZombie), "UpdateMouth", (Type[])null, (Type[])null); private static readonly FieldInfo? BiteColliderObjectField = AccessTools.Field(typeof(MushroomZombie), "biteColliderObject"); public static void UpdateMouthProxy(this MushroomZombie zombie) { try { UpdateMouthMethod?.Invoke(zombie, null); } catch (Exception arg) { Plugin.Log.LogDebug((object)$"UpdateMouth invoke failed: {arg}"); } } public static void SetBiteColliderProxy(this MushroomZombie zombie, bool enabled) { try { object? obj = BiteColliderObjectField?.GetValue(zombie); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null) { val.SetActive(enabled); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"SetBiteColliderProxy failed: {arg}"); } } } internal static class PatchReflectionCache { public static readonly FieldInfo? CharacterGrabbingCharacterField = AccessTools.Field(typeof(CharacterGrabbing), "character"); public static readonly FieldInfo? CharacterCarryingCharacterField = AccessTools.Field(typeof(CharacterCarrying), "character"); public static readonly MethodInfo? CharacterCarryingToggleCarryPhysicsMethod = AccessTools.Method(typeof(CharacterCarrying), "ToggleCarryPhysics", (Type[])null, (Type[])null); } internal static class RobotInteractionRules { public static bool CanLocalPlayerEatRobot(Character? target, Character? interactor = null) { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Invalid comparison between Unknown and I4 try { if ((Object)(object)target == (Object)null || (Object)(object)target.data == (Object)null || target.refs == null) { return false; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(target); if ((Object)(object)agent == (Object)null) { return false; } Character val = interactor ?? Character.localCharacter; if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null || val.refs == null || (Object)(object)val.refs.afflictions == (Object)null) { return false; } if ((Object)(object)val == (Object)(object)target || target.data.dead || (Object)(object)target.data.carrier != (Object)null) { return false; } if (!val.data.fullyConscious) { return false; } float currentStatus = val.refs.afflictions.GetCurrentStatus((STATUSTYPE)1); if (currentStatus < UIPlayerNames.CANNIBAL_HUNGER_THRESHOLD) { return false; } CannibalismSetting val2 = null; try { val2 = (((Object)(object)GameHandler.Instance != (Object)null && GameHandler.Instance.SettingsHandler != null) ? GameHandler.Instance.SettingsHandler.GetSetting() : null); } catch { val2 = null; } if (val2 != null && (int)((EnumSetting)(object)val2).Value != 1) { return false; } return target.data.cannibalismPermitted; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CanLocalPlayerEatRobot failed: {arg}"); return false; } } public static bool CanCarryRobot(Character? target, Character? interactor = null) { try { if ((Object)(object)target == (Object)null || (Object)(object)target.data == (Object)null || target.data.dead || (Object)(object)target.data.carrier != (Object)null) { return false; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(target); if ((Object)(object)agent == (Object)null || !agent.canBeCarriedAsRobot) { return false; } if (CanLocalPlayerEatRobot(target, interactor)) { return false; } return true; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"CanCarryRobot failed: {arg}"); return false; } } public static bool IsCarriedByLocalPlayer(Character? target) { try { return (Object)(object)target != (Object)null && (Object)(object)target.data != (Object)null && (Object)(object)target.data.carrier != (Object)null && (Object)(object)target.data.carrier == (Object)(object)Character.localCharacter; } catch { return false; } } public static bool TryEatRobot(Character target, Character eater) { try { if (!CanLocalPlayerEatRobot(target, eater)) { return false; } NetworkRobotAgent agent = RobotInteractionUtil.GetAgent(target); if ((Object)(object)agent == (Object)null) { return false; } if (eater.IsLocal) { eater.refs.afflictions.SubtractStatus((STATUSTYPE)1, 1f, false, false); eater.refs.afflictions.AddStatus((STATUSTYPE)5, 0.1f, false, true, true); Singleton.Instance.ThrowAchievement((ACHIEVEMENTTYPE)40); } agent.DeleteRobotNetworked(); return true; } catch (Exception arg) { Plugin.Log.LogDebug((object)$"TryEatRobot failed: {arg}"); return false; } } } internal static class RobotInteractionUtil { private const float MissingAgentRetrySeconds = 0.25f; private static readonly Dictionary AgentByCharacterId = new Dictionary(); private static readonly Dictionary MissingAgentRetryByCharacterId = new Dictionary(); public static void RegisterAgent(Character? character, NetworkRobotAgent? agent) { if (!((Object)(object)character == (Object)null) && !((Object)(object)agent == (Object)null)) { int instanceID = ((Object)character).GetInstanceID(); AgentByCharacterId[instanceID] = agent; MissingAgentRetryByCharacterId.Remove(instanceID); } } public static void UnregisterAgent(Character? character, NetworkRobotAgent? agent) { if (!((Object)(object)character == (Object)null)) { int instanceID = ((Object)character).GetInstanceID(); if (AgentByCharacterId.TryGetValue(instanceID, out NetworkRobotAgent value) && ((Object)(object)agent == (Object)null || (Object)(object)value == (Object)(object)agent)) { AgentByCharacterId.Remove(instanceID); } MissingAgentRetryByCharacterId.Remove(instanceID); } } public static NetworkRobotAgent? GetAgent(Character? character) { if ((Object)(object)character == (Object)null) { return null; } int instanceID = ((Object)character).GetInstanceID(); if (AgentByCharacterId.TryGetValue(instanceID, out NetworkRobotAgent value)) { if ((Object)(object)value != (Object)null && (Object)(object)value.Character == (Object)(object)character) { return value; } AgentByCharacterId.Remove(instanceID); } float unscaledTime = Time.unscaledTime; if (MissingAgentRetryByCharacterId.TryGetValue(instanceID, out var value2) && unscaledTime < value2) { return null; } try { NetworkRobotAgent component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null) { RegisterAgent(character, component); return component; } } catch { } MissingAgentRetryByCharacterId[instanceID] = unscaledTime + 0.25f; return null; } public static bool IsRobotCharacter(Character? character) { return (Object)(object)GetAgent(character) != (Object)null; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }