Decompiled source of PingDrivenRobots v1.3.9
PingDrivenRobots.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.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.9.0")] [assembly: AssemblyInformationalVersion("1.3.9")] [assembly: AssemblyProduct("PingDrivenRobots")] [assembly: AssemblyTitle("PingDrivenRobots")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.9.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 RouteFailureReason Reason = RouteFailureReason.Unknown; public Vector3 Position = Vector3.zero; public Vector3 Direction = Vector3.zero; public float Until; } private sealed class GroundCorridorCacheEntry { public bool Found; public GroundCorridorStats Stats; public float CreatedAt; } private struct GroundCorridorStats { public Vector3 EndPoint; public float PathLength; public float TotalRise; public float TotalDrop; public float MaxStepRise; public float MaxStepDrop; public bool HasSlope; public bool NeedsSmallHops; } private sealed class SpatialRouteNode { public Vector3 Position; public readonly List<PathPlan> Segments = new List<PathPlan>(); public float Cost; public float Score; public float DistanceToGoal; public float RemainingStamina; public int Depth; } private readonly struct SpatialRouteStateKey : IEquatable<SpatialRouteStateKey> { 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 BackpackPickupFlatDistance = 1.35f; private const float BackpackPickupVerticalDistance = 1.6f; private const float BackpackPickupReachWindup = 0.65f; private const float BackpackPickupReachHold = 0.9f; private const float BackpackPickupAttachAfterReachStopDelay = 0.3f; private const float BackpackPickupRetargetInterval = 0.15f; private const float BackpackPickupTimeout = 20f; private Backpack? _backpackTarget; private bool _backpackCommandActive; private bool _backpackPickupReachStarted; private bool _backpackPickupInteractionSent; private bool _backpackPickupReachStopped; private float _backpackNextGoalRefreshTime; private float _backpackReachStartTime; private float _backpackReachStopTime; private float _backpackAttachTime; private float _backpackCommandStartTime; 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<FailedSegmentMemory> _failedSegments = new List<FailedSegmentMemory>(); public static readonly List<NetworkRobotAgent> All = new List<NetworkRobotAgent>(); private static readonly Dictionary<int, NetworkRobotAgent> AgentByZombieInstanceId = new Dictionary<int, NetworkRobotAgent>(); private static readonly Dictionary<int, float> MissingAgentRetryByZombieInstanceId = new Dictionary<int, float>(); 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<PathPlan> _segmentQueue = new Queue<PathPlan>(); 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 = 8.75f; private const float DropEdgeArrivalDistance = 1.15f; private const float DropLandingGoalWeight = 1.75f; private const float DropSearchTargetDirectionBonus = 1.2f; private const float StableRestSlopeAngle = 42f; private const float SlopeSettleNormalAngle = 48f; private const float SlopeSettleAssistDistance = 2.35f; private const float SlopeSettleExtraForward = 1.25f; private const float SlopeSettleClimbProbe = 0.85f; 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 Vector3 _timeCriticalEdgeProbeTarget = Vector3.zero; private float _timeCriticalEdgeProbeTime; private bool _timeCriticalEdgeProbeResult; private float _lastAutoJumpTime; private PathPlan _plan = new PathPlan(); private readonly List<BlockedMemory> _blockedMemory = new List<BlockedMemory>(); private readonly List<RouteChoiceMemory> _recentRouteChoices = new List<RouteChoiceMemory>(); private readonly Dictionary<RouteCandidateCacheKey, RouteCandidateCacheEntry> _guideCandidateCache = new Dictionary<RouteCandidateCacheKey, RouteCandidateCacheEntry>(); private readonly Dictionary<RouteCandidateCacheKey, RouteCandidateCacheEntry> _spatialCandidateCache = new Dictionary<RouteCandidateCacheKey, RouteCandidateCacheEntry>(); private readonly Dictionary<RoutePathCacheKey, RoutePathCacheEntry> _guidePathCache = new Dictionary<RoutePathCacheKey, RoutePathCacheEntry>(); private readonly Dictionary<RoutePathCacheKey, GroundCorridorCacheEntry> _groundCorridorCache = new Dictionary<RoutePathCacheKey, GroundCorridorCacheEntry>(); private readonly Dictionary<Collider, bool> _routeStandableColliderCache = new Dictionary<Collider, bool>(); private readonly List<RouteCandidateCacheKey> _candidateCacheRemovalScratch = new List<RouteCandidateCacheKey>(64); private readonly List<RoutePathCacheKey> _pathCacheRemovalScratch = new List<RoutePathCacheKey>(64); private static readonly Dictionary<RoutePathCacheKey, RoutePathCacheEntry> SharedGuidePathCache = new Dictionary<RoutePathCacheKey, RoutePathCacheEntry>(); private static readonly Dictionary<PhysicsProbeCacheKey, GroundProbeCacheEntry> SharedGroundProbeCache = new Dictionary<PhysicsProbeCacheKey, GroundProbeCacheEntry>(); private static readonly Dictionary<PhysicsProbeCacheKey, LineProbeCacheEntry> SharedLineProbeCache = new Dictionary<PhysicsProbeCacheKey, LineProbeCacheEntry>(); private static readonly List<RoutePathCacheKey> SharedRoutePathRemovalScratch = new List<RoutePathCacheKey>(96); private static readonly List<PhysicsProbeCacheKey> SharedPhysicsProbeRemovalScratch = new List<PhysicsProbeCacheKey>(128); private static float SharedNextGuideCachePruneTime; private static float SharedNextPhysicsProbePruneTime; private static int SharedPlannerBudgetFrame = -1; private static int SharedPlannerBudgetUsed; private const int SharedMaxGuidedRoutePlansPerFrameDefault = 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.18f; private const float SharedPhysicsProbePruneInterval = 0.25f; private const float SharedPhysicsProbeCell = 0.55f; private const float GroundCorridorCacheLifetime = 0.35f; private const int GroundCorridorMaxCacheEntries = 160; private const float GroundCorridorCacheCell = 0.85f; private bool _initialized; private float _nextPersistentRefreshTime; private State _lastVisualZombieState = (State)(-1); private bool _lastVisualBiteColliderEnabled; private bool _lastVisualSprintState; private bool _hasVisualStateSnapshot; private float _nextRemoteMouthRefreshTime; 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 TimeCriticalJumpGrabMinStamina = 0.24f; private const float TimeCriticalClimbMinStamina = 0.28f; private const float TimeCriticalCarryMinStamina = 0.38f; private const float TimeCriticalShortClimbMaxHeight = 2.05f; private const float TimeCriticalTraversalMaxHeight = 3.35f; private const float TimeCriticalJumpGrabMinHorizontal = 0.72f; private const float TimeCriticalEdgeProbeForward = 0.82f; private const float TimeCriticalEdgeSafeDrop = 1.55f; private const float TimeCriticalEdgeProbeUp = 0.35f; private const float TimeCriticalEdgeProbeDown = 3.65f; 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 float[] JumpGrabAngleSamples = new float[11] { 0f, 15f, -15f, 30f, -30f, 45f, -45f, 60f, -60f, 90f, -90f }; private static readonly float[] JumpGrabLaunchSamples = new float[5] { 0.55f, 0.85f, 1.2f, 1.6f, 2f }; private static readonly float[] JumpGrabWallSamples = new float[7] { 1.25f, 1.65f, 2.2f, 2.8f, 3.4f, 4f, 4.6f }; private static readonly float[] ClimbProbeForwardSamples = new float[7] { 0.55f, 0.8f, 1.05f, 1.3f, 1.6f, 1.95f, 2.2f }; private static readonly float[] DropSearchAngles = new float[12] { 0f, 30f, -30f, 60f, -60f, 90f, -90f, 120f, -120f, 150f, -150f, 180f }; private static readonly float[] DropAnchorSamples = new float[9] { 0.8f, 1.15f, 1.55f, 2.05f, 2.7f, 3.45f, 4.35f, 5.35f, 6.5f }; private static readonly float[] DropLandingExtraSamples = new float[6] { 0.55f, 0.9f, 1.35f, 1.9f, 2.55f, 3.35f }; private static readonly float[] NonStandableGoalAccessRadii = new float[6] { 0.55f, 1.1f, 1.8f, 2.7f, 3.8f, 5.2f }; private static readonly float[] NonStandableGoalAccessAngles = new float[8] { 0f, 45f, -45f, 90f, -90f, 135f, -135f, 180f }; private static readonly float[] ObstacleLandingOffsets = new float[4] { 0.95f, 1.25f, 1.6f, 1.95f }; private static readonly float[] WallContinuationDistances = new float[4] { 0.65f, 1.1f, 1.65f, 2.25f }; private static readonly float[] RecoverySearchAngles = new float[8] { 0f, 35f, -35f, 70f, -70f, 115f, -115f, 180f }; private static readonly float[] RecoverySearchDistances = new float[4] { 1.15f, 1.75f, 2.45f, 3.15f }; private static readonly float[] ReverseAccessRadii = new float[5] { 0.65f, 1.1f, 1.7f, 2.4f, 3.2f }; private static readonly float[] ReverseAccessAngles = new float[10] { 180f, 145f, -145f, 110f, -110f, 70f, -70f, 35f, -35f, 0f }; private static readonly float[] ObstacleBypassAngles = new float[9] { 0f, 18f, -18f, 35f, -35f, 55f, -55f, 75f, -75f }; private static readonly float[] WallTraverseLateralDistances = new float[5] { 0.95f, 1.45f, 2.1f, 2.85f, 3.6f }; private static readonly Vector3[] StandSupportDirections = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.back, Vector3.left, Vector3.right }; private static readonly Vector3[] GoalStandOffsets = (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) }; 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 const float BlockedMemoryDefaultLifetime = 6f; private const float BlockedMemoryMaxRadius = 5f; private const float BlockedMemoryMinRadius = 1.25f; private const float BlockedMemoryBasePenalty = 1f; private const float BlockedMemoryMaxPenalty = 4f; private const float ValidatedGroundSampleSpacing = 0.72f; private const float ValidatedGroundMaxStepUp = 0.95f; private const float ValidatedGroundMaxStepDown = 1.2f; private const float ValidatedGroundMaxSegmentFlat = 7.25f; private const float ValidatedGroundFullGoalMaxFlat = 14f; private const float GroundPlanMinimumProgress = 0.45f; private const float GroundPlanMaxUsefulRise = 5f; private static readonly float[] SlopeStableExtraDistances = new float[5] { 0.75f, 1.2f, 1.75f, 2.35f, 3.1f }; private const float FootholdScanHeightTrigger = 0.85f; private const float FootholdScanMaxFlat = 15.5f; private const float FootholdScanMaxRayHeight = 7.5f; private const float FootholdScanRayDepth = 18f; private const float FootholdSameLevelIgnoreHeight = 0.38f; private static readonly float[] FootholdForwardSamples = new float[8] { 1.25f, 2.15f, 3.25f, 4.55f, 6.15f, 8.2f, 10.6f, 13.4f }; private static readonly float[] FootholdLateralSamples = new float[7] { 0f, -0.8f, 0.8f, -1.65f, 1.65f, -2.75f, 2.75f }; private RobotBrainState _lastLoggedBrainState = (RobotBrainState)(-1); private const int SpatialPlannerMaxDepthDefault = 4; private const int SpatialPlannerBeamWidthDefault = 8; private const int SpatialPlannerMaxCandidatesPerNodeDefault = 18; private const float SpatialPlannerCacheLifetime = 2.2f; private const float SpatialCandidateCacheLifetime = 0.55f; 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 const float SpatialRouteAssistSearchRadius = 7.5f; private const float SpatialRouteAssistTopProbeHeight = 9.5f; private const int SpatialRouteAssistMaxColliders = 48; private static readonly Collider[] SharedRouteAssistColliderBuffer = (Collider[])(object)new Collider[48]; 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 IsAdvancedRoutingEnabled() { return (Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.AdvancedRoutingEnabled; } private bool IsSpatialRoutingEnabled() { return IsAdvancedRoutingEnabled() && ((Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.SpatialRoutingEnabled); } private bool IsReverseRouteSearchEnabled() { return IsSpatialRoutingEnabled() && ((Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.ReverseRouteSearchEnabled); } private bool IsExplicitStaminaWaitEnabled() { return IsAdvancedRoutingEnabled() && ((Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.ExplicitStaminaWaitEnabled); } private bool IsFailureMemoryEnabled() { return IsAdvancedRoutingEnabled() && ((Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.FailureMemoryEnabled); } private bool IsRouteAssistAwarenessEnabled() { return IsAdvancedRoutingEnabled() && ((Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.RouteAssistAwarenessEnabled); } private bool IsAdvancedRoutingDebugEnabled() { return (Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.DebugRoutingLogs; } private bool IsAdvancedRoutingDrawEnabled() { return (Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.DebugDrawRouting; } private int GetConfiguredSpatialPlannerMaxDepth() { return ((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.SpatialPlannerMaxDepth : 4; } private int GetConfiguredSpatialPlannerBeamWidth() { return ((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.SpatialPlannerBeamWidth : 8; } private int GetConfiguredSpatialPlannerMaxCandidatesPerNode() { return ((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.SpatialPlannerMaxCandidatesPerNode : 18; } private int GetConfiguredSharedPlannerPlansPerFrame() { return (!((Object)(object)Plugin.Instance != (Object)null)) ? 1 : Plugin.Instance.SharedPlannerPlansPerFrame; } private float GetConfiguredStaminaSafetyRatio() { return ((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.StaminaSafetyRatio : 0.22f; } private void DebugAdvancedRouting(string message) { if (IsAdvancedRoutingDebugEnabled()) { Plugin.Log.LogDebug((object)("[AdvancedRouting] " + message)); } } private void DebugDrawRouteSegments(List<PathPlan> segments, string source) { //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_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_0048: 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_006b: 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_0072: 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_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_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_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_00a1: 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_018f: 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_00c2: 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_00cd: 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_00d9: 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_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_00f2: 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_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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0138: 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_014f: 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_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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if (!IsAdvancedRoutingDrawEnabled() || (Object)(object)_character == (Object)null || segments.Count == 0) { return; } Vector3 val = _character.Center; Vector3 val2 = Vector3.up * 0.18f; for (int i = 0; i < segments.Count; i++) { PathPlan pathPlan = segments[i]; Vector3 planProjectedEndPoint = GetPlanProjectedEndPoint(pathPlan); Color debugColorForAction = GetDebugColorForAction(pathPlan.Action); Debug.DrawLine(val + val2, planProjectedEndPoint + val2, debugColorForAction, 2.25f); if (pathPlan.Anchor != Vector3.zero && Vector3.Distance(val, pathPlan.Anchor) > 0.35f) { Debug.DrawLine(val + Vector3.up * 0.32f, pathPlan.Anchor + Vector3.up * 0.32f, Color.gray, 2.25f); Debug.DrawLine(pathPlan.Anchor + Vector3.left * 0.18f, pathPlan.Anchor + Vector3.right * 0.18f, Color.white, 2.25f); Debug.DrawLine(pathPlan.Anchor + Vector3.forward * 0.18f, pathPlan.Anchor + Vector3.back * 0.18f, Color.white, 2.25f); } val = planProjectedEndPoint; } DebugAdvancedRouting($"debug drew {segments.Count} route segment(s) from {source}"); } private static Color GetDebugColorForAction(PathActionType action) { //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_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_006b: 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_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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_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_00a9: 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_0082: 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_00b9: Unknown result type (might be due to invalid IL or missing references) switch (action) { case PathActionType.Direct: return Color.green; case PathActionType.SlopeWalk: return Color.cyan; case PathActionType.Detour: return Color.yellow; case PathActionType.JumpGrab: case PathActionType.GapJump: return Color.magenta; case PathActionType.Climb: case PathActionType.WallTraverse: case PathActionType.CornerClimb: case PathActionType.Mantle: return Color.blue; case PathActionType.RopeClimb: case PathActionType.AnchorAssist: return new Color(0.35f, 0.85f, 1f); case PathActionType.DropDown: return Color.red; case PathActionType.WaitForStamina: return Color.white; case PathActionType.Recover: return new Color(1f, 0.55f, 0f); default: return Color.gray; } } private bool IsLimitedStaminaAction(PathPlan plan) { return IsClimbPlan(plan) || plan.Action == PathActionType.GapJump || plan.Action == PathActionType.RopeClimb || plan.Action == PathActionType.AnchorAssist || (plan.Action == PathActionType.DropDown && plan.UsesJumpDropImmunity); } private float GetRouteStaminaBudgetWithSafety(PathPlan plan) { float configuredStaminaSafetyRatio = GetConfiguredStaminaSafetyRatio(); float num = Mathf.Max(EstimatePlanStaminaCost(plan), plan.RequiredStamina); if (IsClimbPlan(plan)) { float num2 = (IsMetadataTimeCriticalClimbPlan(plan) ? GetTimeCriticalClimbStartThreshold(plan) : GetFullStaminaClimbStartThreshold(plan)); num = Mathf.Max(num, num2); } else if (plan.Action == PathActionType.GapJump) { num = Mathf.Max(num, 0.18f + configuredStaminaSafetyRatio * 0.65f); } else if (plan.Action == PathActionType.RopeClimb || plan.Action == PathActionType.AnchorAssist) { num = Mathf.Max(num, 0.3f + configuredStaminaSafetyRatio * 0.8f); } else if (plan.Action == PathActionType.DropDown && plan.UsesJumpDropImmunity) { num = Mathf.Max(num, 0.1f + configuredStaminaSafetyRatio * 0.35f); } return Mathf.Clamp(num + configuredStaminaSafetyRatio * 0.3f, 0.05f, 0.98f); } private List<PathPlan> NormalizeSegmentsForStaminaBudget(List<PathPlan> source) { //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_0083: 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_00db: 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_0167: 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_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) if (source.Count == 0 || (Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null) { return source; } bool flag = IsExplicitStaminaWaitEnabled(); List<PathPlan> list = new List<PathPlan>(source.Count + 1); float num = GetStamina01(); float recoverableStaminaCeiling = GetRecoverableStaminaCeiling(); Vector3 val = _character.Center; for (int i = 0; i < source.Count; i++) { PathPlan pathPlan = ClonePlan(source[i]); if (!IsPlanStartTransitionReachable(val, pathPlan, out var reason)) { if (IsAdvancedRoutingDebugEnabled()) { DebugAdvancedRouting($"normalized route rejected unreachable segment: action={pathPlan.Action}, reason={reason}, from={val}, goal={pathPlan.Goal}, anchor={pathPlan.Anchor}"); } if (list.Count == 0) { RegisterFailedSegment(pathPlan, reason); } continue; } if (flag && IsLimitedStaminaAction(pathPlan)) { float routeStaminaBudgetWithSafety = GetRouteStaminaBudgetWithSafety(pathPlan); bool flag2 = list.Count == 0; bool flag3 = IsSafeStandingNow(); bool flag4 = !IsClimbPlan(pathPlan) || Vector3.Distance(_character.Center, pathPlan.Anchor) <= 1.6f; if (flag2 && flag3 && flag4 && num + 0.01f < routeStaminaBudgetWithSafety) { list.Add(BuildWaitForStaminaSegment(pathPlan, routeStaminaBudgetWithSafety)); num = recoverableStaminaCeiling; } num = Mathf.Clamp(num - EstimatePlanStaminaCost(pathPlan), 0f, recoverableStaminaCeiling); } else if (pathPlan.Action == PathActionType.Direct || pathPlan.Action == PathActionType.SlopeWalk || pathPlan.Action == PathActionType.Detour || pathPlan.Action == PathActionType.AnchorAssist || (pathPlan.Action == PathActionType.DropDown && !pathPlan.UsesJumpDropImmunity)) { num = recoverableStaminaCeiling; } list.Add(pathPlan); if (pathPlan.Action != PathActionType.WaitForStamina && pathPlan.Action != PathActionType.Hold) { val = GetPlanProjectedEndPoint(pathPlan); } } return list; } private PathPlan BuildWaitForStaminaSegment(PathPlan nextSegment, float requiredStamina) { //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_001c: 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_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_004d: 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_0052: 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_0088: 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) Vector3 val = ((nextSegment.Anchor != Vector3.zero) ? nextSegment.Anchor : nextSegment.Goal); return new PathPlan { Action = PathActionType.WaitForStamina, Goal = val, Anchor = (((Object)(object)_character != (Object)null) ? _character.Center : val), RequiredStamina = Mathf.Clamp(requiredStamina, 0.05f, 0.98f), TargetAbove = nextSegment.TargetAbove, ProjectedEndPoint = (((Object)(object)_character != (Object)null) ? _character.Center : val), HasProjectedEndPoint = true, EndNodeType = RouteNodeType.Rest, StaminaSafetyReserve = GetConfiguredStaminaSafetyRatio() }; } private bool HasCapsuleClearanceAt(Vector3 groundPoint) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = groundPoint + Vector3.up * 0.52f; Vector3 val2 = groundPoint + Vector3.up * 1.72f; return !Physics.CheckCapsule(val, val2, 0.34f, TerrainMask, (QueryTriggerInteraction)1); } private int CountStandSupportPoints(Vector3 point) { //IL_0011: 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_001e: 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_0029: 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_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_003e: 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_0068: 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) int num = 0; Vector3[] standSupportDirections = StandSupportDirections; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < standSupportDirections.Length; i++) { Vector3 val = point + standSupportDirections[i] * 0.45f; if (Physics.Raycast(val + Vector3.up * 0.65f, Vector3.down, ref val2, 2.05f, TerrainMask, (QueryTriggerInteraction)1)) { float num2 = Mathf.Abs(((RaycastHit)(ref val2)).point.y - point.y); if (num2 <= 1.05f && IsRoughStandableNormal(((RaycastHit)(ref val2)).normal)) { num++; } } } return num; } private bool IsSafeStandableRoutePoint(Vector3 point, Vector3 normal, bool requireSupport) { //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_002b: Unknown result type (might be due to invalid IL or missing references) if (!IsRoughStandableNormal(normal)) { return false; } if (!HasCapsuleClearanceAt(point)) { return false; } return !requireSupport || CountStandSupportPoints(point) >= 1; } private bool IsClimbableWallNormal(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; } float num = Vector3.Angle(normal, Vector3.up); return num >= 38f && num <= 145f; } private bool HasMantleSpaceAt(Vector3 topPoint) { //IL_0002: 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) if (!TryFindGround(topPoint, out var hit)) { return false; } return IsSafeStandableRoutePoint(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, requireSupport: false); } private bool TryFindWallContinuationPoint(PathPlan climbPlan, float sign, 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_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_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //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_00a9: 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_00b9: 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_00c2: 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_00e9: 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_0102: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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) point = Vector3.zero; if (climbPlan.ClimbSurfaceNormal == Vector3.zero) { return false; } Vector3 normalized = ((Vector3)(ref climbPlan.ClimbSurfaceNormal)).normalized; Vector3 val = Vector3.Cross(Vector3.up, normalized); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); float[] wallContinuationDistances = WallContinuationDistances; RaycastHit val4 = default(RaycastHit); for (int i = 0; i < wallContinuationDistances.Length; i++) { Vector3 val2 = _character.Center + val * (sign * wallContinuationDistances[i]) + Vector3.up * 0.2f; Vector3 val3 = val2 + normalized * 0.85f; if (Physics.SphereCast(val3, 0.16f, -normalized, ref val4, 1.35f, TerrainMask, (QueryTriggerInteraction)1) && IsClimbableWallNormal(((RaycastHit)(ref val4)).normal)) { float num = Vector3.Angle(normalized, ((RaycastHit)(ref val4)).normal); if (!(num > 115f)) { point = ((RaycastHit)(ref val4)).point + Vector3.up * 0.35f; return true; } } } return false; } private bool TryFindCornerAwareTraversePoint(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_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_003c: 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_0078: 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_008d: 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_010c: 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_014d: 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) point = Vector3.zero; if (climbPlan.ClimbSurfaceNormal == Vector3.zero || (Object)(object)_character == (Object)null) { return false; } Vector3 val = Vector3.Cross(Vector3.up, ((Vector3)(ref climbPlan.ClimbSurfaceNormal)).normalized); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = GetGoalLookPoint() - _character.Center; val2.y = 0f; float num = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? Mathf.Sign(Vector3.Dot(((Vector3)(ref val2)).normalized, val)) : 1f); if (Mathf.Approximately(num, 0f)) { num = 1f; } bool flag = false; float num2 = float.NegativeInfinity; for (int i = 0; i < 2; i++) { float sign = ((i == 0) ? num : (0f - num)); if (TryFindWallContinuationPoint(climbPlan, sign, out var point2)) { float num3 = 0f - Vector3.Distance(point2, GetGoalLookPoint()); if (i == 0) { num3 += 0.45f; } if (!flag || num3 > num2) { flag = true; num2 = num3; point = point2; } } } return flag; } private RouteFailureReason DetermineRouteFailureReason(PathPlan segment, RouteFailureReason fallback) { //IL_028a: 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_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_02a4: 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_0103: 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_02a9: 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_02ab: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: 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_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: 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_01f1: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: 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_022f: 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_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_0247: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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 fallback; } if (GetStamina01() <= 0.08f && IsLimitedStaminaAction(segment)) { return RouteFailureReason.StaminaTooLow; } if ((segment.Action == PathActionType.RopeClimb || segment.Action == PathActionType.AnchorAssist || segment.UsesRouteAssist) && Time.time - _segmentStartTime >= 3f && !_character.data.isClimbing && !_character.data.isRopeClimbing && !_character.data.isVineClimbing) { return RouteFailureReason.RouteAssistFailed; } if (IsClimbPlan(segment)) { float num = ((segment.Anchor != Vector3.zero) ? Vector3.Distance(_character.Center, segment.Anchor) : 999f); bool flag = num <= 1.9000001f; bool flag2 = _character.data.isClimbing || _character.data.isRopeClimbing || _character.data.isVineClimbing; if (!flag2 && flag && Time.time - _segmentStartTime >= 1.15f) { if (segment.Action == PathActionType.Mantle) { return RouteFailureReason.MantleFailed; } if (segment.Action == PathActionType.JumpGrab || segment.NeedsJumpStart) { return RouteFailureReason.JumpGrabFailed; } if (segment.Action == PathActionType.RopeClimb || segment.UsesRouteAssist) { return RouteFailureReason.RouteAssistFailed; } return RouteFailureReason.WallLost; } if (flag2 && segment.ClimbSurfaceNormal != Vector3.zero) { Vector3 normalized = ((Vector3)(ref segment.ClimbSurfaceNormal)).normalized; Vector3 val = _character.Center + Vector3.up * 0.25f + normalized * 0.75f; RaycastHit val2 = default(RaycastHit); if (!Physics.SphereCast(val, 0.16f, -normalized, ref val2, 1.25f, TerrainMask, (QueryTriggerInteraction)1) || !IsClimbableWallNormal(((RaycastHit)(ref val2)).normal)) { return RouteFailureReason.WallLost; } } } Vector3 val3 = ((segment.Anchor != Vector3.zero) ? segment.Anchor : segment.Goal); if (val3 != Vector3.zero && IsRoughTerrainLineBlocked(_character.Center + Vector3.up * 0.1f, val3 + Vector3.up * 0.1f)) { return RouteFailureReason.PathBlocked; } return fallback; } private bool TryBuildRecoveryPlan(out PathPlan plan) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0072: 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_00bf: 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_009a: 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_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_00d9: 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_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_02c8: 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_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_00f5: 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_00fd: 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_011f: 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_0145: 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_0156: 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_0186: 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_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_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_01c6: 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_0233: 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) plan = new PathPlan(); if ((Object)(object)_character == (Object)null) { return false; } Vector3 center = _character.Center; Vector3 val = center - GetGoalCenter(); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = -((Component)_character).transform.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.back; } ((Vector3)(ref val)).Normalize(); float[] recoverySearchAngles = RecoverySearchAngles; float[] recoverySearchDistances = RecoverySearchDistances; bool flag = false; float num = float.NegativeInfinity; Vector3 val2 = Vector3.zero; for (int i = 0; i < recoverySearchAngles.Length; i++) { Vector3 val3 = Quaternion.AngleAxis(recoverySearchAngles[i], Vector3.up) * val; for (int j = 0; j < recoverySearchDistances.Length; j++) { Vector3 point = center + val3 * recoverySearchDistances[j]; if (!TryFindGround(point, out var hit) || !IsSafeStandableRoutePoint(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, requireSupport: false)) { continue; } float num2 = ((RaycastHit)(ref hit)).point.y - center.y; float num3 = center.y - ((RaycastHit)(ref hit)).point.y; if (!(num2 > 0.85f) && !(num3 > 10f) && !IsRoughTerrainLineBlocked(center + Vector3.up * 0.1f, ((RaycastHit)(ref hit)).point + Vector3.up * 0.1f)) { float blockedPenalty = GetBlockedPenalty(((RaycastHit)(ref hit)).point); float num4 = recoverySearchDistances[j] * 0.45f - Mathf.Abs(recoverySearchAngles[i]) * 0.006f - blockedPenalty; if (CountStandSupportPoints(((RaycastHit)(ref hit)).point) >= 2) { num4 += 0.55f; } if (!flag || num4 > num) { flag = true; num = num4; val2 = ((RaycastHit)(ref hit)).point; } } } } if (!flag) { return false; } plan = new PathPlan { Action = PathActionType.Recover, Goal = val2 + Vector3.up * 0.15f, Anchor = val2, RequiredStamina = 0f, TargetAbove = false, ReachableWithinRecoverableBudget = true, ProjectedEndPoint = val2, HasProjectedEndPoint = true, StartNodeType = RouteNodeType.Hazard, EndNodeType = RouteNodeType.Rest, Score = num }; return true; } private bool TryBuildReverseAccessPath(Vector3 start, Vector3 goal, out List<PathPlan> segments) { //IL_0020: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0067: 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_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_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_00bb: 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_00ec: 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_00fc: 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_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_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_013d: 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_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_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_0176: 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_0184: 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_01a4: 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_01b8: 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_01e5: 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_020d: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: 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_02d0: 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) //IL_02d7: 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_02e0: 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_0287: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0367: 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_0470: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: 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_03d2: 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_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) segments = new List<PathPlan>(); if (!IsReverseRouteSearchEnabled()) { return false; } float num = goal.y - start.y; if (num < 1.8499999f) { return false; } Vector3 val = goal - start; val.y = 0f; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); float[] reverseAccessRadii = ReverseAccessRadii; float[] reverseAccessAngles = ReverseAccessAngles; bool flag = false; float num2 = float.NegativeInfinity; List<PathPlan> list = new List<PathPlan>(); RaycastHit val5 = default(RaycastHit); RaycastHit val7 = default(RaycastHit); RaycastHit val10 = default(RaycastHit); for (int i = 0; i < reverseAccessRadii.Length; i++) { for (int j = 0; j < reverseAccessAngles.Length; j++) { Vector3 val3 = Quaternion.AngleAxis(reverseAccessAngles[j], Vector3.up) * val2; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { continue; } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = goal + val3 * reverseAccessRadii[i]; if (!Physics.Raycast(val4 + Vector3.up * 2.4f, Vector3.down, ref val5, 5.5f, TerrainMask, (QueryTriggerInteraction)1) || !IsSafeStandableRoutePoint(((RaycastHit)(ref val5)).point, ((RaycastHit)(ref val5)).normal, requireSupport: false)) { continue; } Vector3 val6 = ((RaycastHit)(ref val5)).point + val3 * 1.15f; float num3 = Mathf.Clamp(((RaycastHit)(ref val5)).point.y - start.y + 3.5f, 4f, 12f); if (!Physics.Raycast(val6 + Vector3.up * 1.2f, Vector3.down, ref val7, num3, TerrainMask, (QueryTriggerInteraction)1) || !IsSafeStandableRoutePoint(((RaycastHit)(ref val7)).point, ((RaycastHit)(ref val7)).normal, requireSupport: false)) { continue; } float num4 = ((RaycastHit)(ref val5)).point.y - ((RaycastHit)(ref val7)).point.y; if (num4 < 0.75f || num4 > EstimateMaxReachableClimbHeight(targetAbove: true, num4 >= 1f) + 0.25f) { continue; } Vector3 val8 = ((RaycastHit)(ref val5)).point - ((RaycastHit)(ref val7)).point; val8.y = 0f; if (((Vector3)(ref val8)).sqrMagnitude < 0.01f) { val8 = -val3; } ((Vector3)(ref val8)).Normalize(); Vector3 val9 = ((RaycastHit)(ref val7)).point + Vector3.up * Mathf.Clamp(num4 * 0.45f, 0.9f, 2.4f) + val8 * 0.75f; if (!Physics.SphereCast(val9, 0.18f, -val8, ref val10, 1.45f, TerrainMask, (QueryTriggerInteraction)1) || !IsClimbableWallNormal(((RaycastHit)(ref val10)).normal) || !HasMantleSpaceAt(((RaycastHit)(ref val5)).point)) { continue; } List<PathPlan> list2 = new List<PathPlan>(); if (Vector3.Distance(start, ((RaycastHit)(ref val7)).point) > 1.25f) { if (TryCreateSpatialGroundMovePlan(start, ((RaycastHit)(ref val7)).point, targetAbove: true, out PathPlan plan)) { plan.WasBuiltByReverseSearch = true; plan.WasBuiltBySpatialPlanner = true; plan.EndNodeType = RouteNodeType.Stand; list2.Add(plan); } else { if (IsRoughTerrainLineBlocked(start, ((RaycastHit)(ref val7)).point)) { continue; } PathPlan item = new PathPlan { Action = PathActionType.Direct, Goal = ((RaycastHit)(ref val7)).point + Vector3.up * 0.15f, Anchor = ((RaycastHit)(ref val7)).point, TargetAbove = true, RequiredStamina = EstimateGroundChaseCost(Vector3.Distance(start, ((RaycastHit)(ref val7)).point)), ReachableWithinRecoverableBudget = true, ProjectedEndPoint = ((RaycastHit)(ref val7)).point, HasProjectedEndPoint = true, WasBuiltByReverseSearch = true, WasBuiltBySpatialPlanner = true, EndNodeType = RouteNodeType.Stand }; list2.Add(item); } } bool flag2 = num4 >= 1f || HelperFunctions.FlatDistance(((RaycastHit)(ref val7)).point, ((RaycastHit)(ref val5)).point) > 1.25f; float num5 = EstimateRequiredClimbStamina(num4, targetAbove: true, num4 >= 2.15f); if (num5 > GetRecoverableStaminaCeiling() + 0.02f) { continue; } PathPlan obj = new PathPlan { Action = (flag2 ? PathActionType.JumpGrab : PathActionType.Climb), Goal = ((RaycastHit)(ref val5)).point + Vector3.up * 0.2f, Anchor = ((RaycastHit)(ref val7)).point, TargetAbove = true, EstimatedClimbHeight = num4, IsTallWall = (num4 >= 2.15f), RequiredStamina = num5, ReachableWithinRecoverableBudget = true, NeedsJumpStart = flag2, ClimbTopPoint = ((RaycastHit)(ref val5)).point }; Vector3 normal = ((RaycastHit)(ref val10)).normal; obj.ClimbSurfaceNormal = ((Vector3)(ref normal)).normalized; obj.ProjectedEndPoint = ((RaycastHit)(ref val5)).point; obj.HasProjectedEndPoint = true; obj.JumpGrabAimPoint = ((RaycastHit)(ref val5)).point + Vector3.up * 0.15f; obj.JumpGrabHorizontalDistance = HelperFunctions.FlatDistance(((RaycastHit)(ref val7)).point, ((RaycastHit)(ref val5)).point); obj.WasBuiltBySpatialPlanner = true; obj.WasBuiltByReverseSearch = true; obj.StartNodeType = RouteNodeType.Wall; obj.EndNodeType = RouteNodeType.Ledge; obj.StaminaSafetyReserve = GetConfiguredStaminaSafetyRatio(); PathPlan pathPlan = obj; if (IsSpatialClimbPlanViable(pathPlan)) { list2.Add(pathPlan); float num6 = 0f; num6 -= Vector3.Distance(start, ((RaycastHit)(ref val7)).point) * 0.45f; num6 -= Vector3.Distance(((RaycastHit)(ref val5)).point, goal) * 1.35f; num6 += num4 * 0.65f; num6 -= GetFailedSegmentPenalty(pathPlan); num6 -= GetBlockedPenalty(((RaycastHit)(ref val7)).point); if (!flag || num6 > num2) { flag = true; num2 = num6; list = list2; } } } } if (!flag || list.Count == 0) { return false; } int num7 = Mathf.Min(3, list.Count); for (int k = 0; k < num7; k++) { segments.Add(ClonePlan(list[k])); } if (IsAdvancedRoutingDebugEnabled()) { DebugAdvancedRouting($"reverse access selected {segments.Count} segment(s), score={num2:0.00}"); } return true; } public bool ToggleBackpackCommand(float searchRadius, out string message) { //IL_00c7: 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_0150: 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) 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 use backpacks."; return false; } if ((Object)(object)_character.data == (Object)null || _character.data.dead) { message = "Controlled robot is dead."; return false; } RobotBackpackAttachment robotBackpackAttachment = RobotBackpackAttachment.FindAttachedTo(_character); if ((Object)(object)robotBackpackAttachment != (Object)null) { CancelBackpackCommand(stopReach: true); robotBackpackAttachment.DetachNetworked(GetBackpackDropPosition(_character)); message = "Controlled robot dropped its backpack."; return true; } if (_backpackCommandActive) { CancelBackpackCommand(stopReach: true); message = "Controlled robot backpack pickup cancelled."; return true; } Backpack val = FindNearestGroundBackpack(_character.Center, searchRadius, _character); if ((Object)(object)val == (Object)null) { message = $"No wearable backpack found within {searchRadius:0.#}m of the nearest controlled robot."; return false; } StartBackpackPickup(val); message = $"Controlled robot is walking to a backpack ({Vector3.Distance(_character.Center, ((Item)val).Center()):0.#}m)."; return true; } private void UpdateBackpackCommandGoal() { //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_0128: Unknown result type (might be due to invalid IL or missing references) if (!_backpackCommandActive) { return; } if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null || _character.data.dead) { CancelBackpackCommand(stopReach: true); return; } if ((Object)(object)RobotBackpackAttachment.FindAttachedTo(_character) != (Object)null) { CancelBackpackCommand(stopReach: true); return; } Backpack backpackTarget = _backpackTarget; if (!IsUsableGroundBackpack(backpackTarget, _character)) { CancelBackpackCommand(stopReach: true); return; } if (Time.time - _backpackCommandStartTime > 20f) { CancelBackpackCommand(stopReach: true); return; } Character backpackCommandTarget = GetBackpackCommandTarget(); if ((Object)(object)backpackCommandTarget == (Object)null) { CancelBackpackCommand(stopReach: true); return; } Vector3 backpackApproachPoint = GetBackpackApproachPoint(backpackTarget, _character); if (Time.time >= _backpackNextGoalRefreshTime) { _backpackNextGoalRefreshTime = Time.time + 0.15f; SetCommandGoal(backpackCommandTarget, backpackApproachPoint); _brainState = RobotBrainState.Chase; } if (CanReachBackpack(backpackTarget, _character)) { TickBackpackPickupReach(backpackTarget); } } private void StartBackpackPickup(Backpack backpack) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) _backpackTarget = backpack; _backpackCommandActive = true; _backpackPickupReachStarted = false; _backpackPickupInteractionSent = false; _backpackPickupReachStopped = false; _backpackNextGoalRefreshTime = 0f; _backpackReachStartTime = 0f; _backpackReachStopTime = 0f; _backpackAttachTime = 0f; _backpackCommandStartTime = Time.time; _manualBiteActive = false; _manualBiteTarget = null; _vanillaBiteControlActive = false; _vanillaBiteTarget = null; _carryAssistEnabled = false; _carryTarget = null; _nextCarryRetargetTime = 0f; StopClimb(); ClearGoalParking(); ClearLockedClimbPlan(); _segmentQueue.Clear(); ClearActiveSegment(); ClearGuidePlannerCaches(); ResetInput(); ResetRouteForNewGoal(GetBackpackApproachPoint(backpack, _character)); } private void TickBackpackPickupReach(Backpack backpack) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) StopClimb(); ResetInput(); SetSprint(sprinting: false); LookAt(((Item)backpack).Center()); if (!_backpackPickupReachStarted) { _backpackPickupReachStarted = true; _backpackPickupReachStopped = false; _backpackReachStartTime = Time.time; _backpackReachStopTime = Time.time + 0.9f; _backpackAttachTime = 0f; StartReachAnimation(); } else if (!_backpackPickupReachStopped) { HoldReachInput(); if (!(Time.time - _backpackReachStartTime < 0.65f) && !(Time.time < _backpackReachStopTime)) { _backpackPickupReachStopped = true; _backpackAttachTime = Time.time + 0.3f; StopReachAnimation(); } } else { ClearReachInput(); if (!_backpackPickupInteractionSent && Time.time >= _backpackAttachTime) { _backpackPickupInteractionSent = true; PickupBackpack(backpack); } } } private void PickupBackpack(Backpack backpack) { try { if (IsUsableGroundBackpack(backpack, _character) && (Object)(object)RobotBackpackAttachment.FindAttachedTo(_character) == (Object)null) { RobotBackpackAttachment.Ensure(backpack).AttachNetworked(_character); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"PickupBackpack failed: {arg}"); } finally { CancelBackpackCommand(stopReach: true); } } private void CancelBackpackCommand(bool stopReach) { _backpackTarget = null; _backpackCommandActive = false; _backpackPickupReachStarted = false; _backpackPickupInteractionSent = false; _backpackPickupReachStopped = false; _backpackNextGoalRefreshTime = 0f; _backpackReachStartTime = 0f; _backpackReachStopTime = 0f; _backpackAttachTime = 0f; if (stopReach) { StopReachAnimation(); } } private bool ShouldHoldBackpackCommandTarget() { return _backpackCommandActive; } private static Backpack? FindNearestGroundBackpack(Vector3 origin, float radius, Character robot) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Backpack result = null; float num = radius * radius; Backpack[] array = Object.FindObjectsByType<Backpack>((FindObjectsInactive)0, (FindObjectsSortMode)1); foreach (Backpack val in array) { if (IsUsableGroundBackpack(val, robot)) { Vector3 val2 = ((Item)val).Center() - origin; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude > num)) { num = sqrMagnitude; result = val; } } } return result; } private static bool IsUsableGroundBackpack(Backpack? backpack, Character robot) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)backpack == (Object)null || (Object)(object)robot == (Object)null || !((Behaviour)backpack).isActiveAndEnabled) { return false; } if (RobotBackpackAttachment.IsAttached(backpack)) { return false; } return (int)((Item)backpack).itemState == 0 && ((Item)backpack).IsInteractible(robot); } private static Vector3 GetBackpackApproachPoint(Backpack backpack, Character robot) { //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_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_0014: 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_006c: 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_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_0083: 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_0087: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Item)backpack).Center(); Vector3 val2 = robot.Center - val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = -((Component)backpack).transform.forward; val2.y = 0f; } if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } return val + ((Vector3)(ref val2)).normalized * 0.55f; } private static bool CanReachBackpack(Backpack backpack, Character robot) { //IL_0002: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) float num = HelperFunctions.FlatDistance(robot.Center, ((Item)backpack).Center()); float num2 = Mathf.Abs(((Item)backpack).Center().y - robot.Center.y); if (num > 1.35f || num2 > 1.6f) { return false; } RaycastHit val = HelperFunctions.LineCheck(robot.Head, ((Item)backpack).Center(), (LayerType)1, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref val)).transform == (Object)null; } private Character? GetBackpackCommandTarget() { Character localCharacter = Character.localCharacter; if (IsValidBackpackCommandTarget(localCharacter)) { return localCharacter; } foreach (Character allCharacter in Character.AllCharacters) { if (IsValidBackpackCommandTarget(allCharacter)) { return allCharacter; } } return null; } private static bool IsValidBackpackCommandTarget(Character? candidate) { return (Object)(object)candidate != (Object)null && (Object)(object)candidate.data != (Object)null && !candidate.isBot && !candidate.data.dead && !candidate.data.fullyPassedOut; } private void HoldReachInput() { try { if (!((Object)(object)_character == (Object)null) && !((Object)(object)_character.input == (Object)null) && !((Object)(object)_character.data == (Object)null)) { _character.input.useSecondaryIsPressed = true; _character.input.useSecondaryWasPressed = true; _character.input.useSecondaryWasReleased = false; _character.data.sincePressReach = 0f; } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"HoldReachInput failed: {arg}"); } } private void ClearReachInput() { try { if (!((Object)(object)_character == (Object)null) && !((Object)(object)_character.input == (Object)null)) { _character.input.useSecondaryIsPressed = false; _character.input.useSecondaryWasPressed = false; _character.input.useSecondaryWasReleased = true; if ((Object)(object)_character.data != (Object)null) { _character.data.sincePressReach = 10f; } } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"ClearReachInput failed: {arg}"); } } private void StartReachAnimation() { HoldReachInput(); try { if ((Object)(object)_character != (Object)null && _character.refs != null && (Object)(object)_character.refs.view != (Object)null) { _character.refs.view.RPC("RPCA_StartReaching", (RpcTarget)0, Array.Empty<object>()); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"StartReachAnimation failed: {arg}"); } } private void StopReachAnimation() { ClearReachInput(); try { if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { _character.data.isReaching = false; } if ((Object)(object)_character != (Object)null && _character.refs != null && (Object)(object)_character.refs.view != (Object)null) { _character.refs.view.RPC("RPCA_StopReaching", (RpcTarget)0, Array.Empty<object>()); } } catch (Exception arg) { Plugin.Log.LogDebug((object)$"StopReachAnimation failed: {arg}"); } } private static Vector3 GetBackpackDropPosition(Character character) { //IL_00bb: 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_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_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_00ea: 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_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_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_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_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_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_0044: 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_007a: 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_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_0095: 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_00a9: 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) try { Bodypart bodypart = character.GetBodypart((BodypartType)0); if ((Object)(object)bodypart != (Object)null) { Vector3 val = ((Component)bodypart).transform.forward; if (Vector3.Dot(val, Vector3.up) < 0f) { val = -val; } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = ((Component)character).transform.forward; } return ((Component)bodypart).transform.position + ((Vector3)(ref val)).normalized * 0.75f + Vector3.up * 0.2f; } } catch { } Vector3 forward = ((Component)character).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } return character.Center + ((Vector3)(ref forward)).normalized * 0.75f + Vector3.up * 0.2f; } 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_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_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_00b4: Unknow