using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("WhiteKnuckleRopeRewrite")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.44.0")] [assembly: AssemblyInformationalVersion("1.1.44+7bf8b6fe6565386dee9f0cdcfa455bea071aa947")] [assembly: AssemblyProduct("WhiteKnuckleRopeRewrite")] [assembly: AssemblyTitle("WhiteKnuckleRopeRewrite")] [assembly: AssemblyVersion("1.1.44.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 WhiteKnuckleRopeRewrite { [HarmonyPatch(typeof(SteamManager), "UploadGamemodeResults")] internal static class Patch_LeaderboardUpload { private static bool Prefix() { return false; } } [HarmonyPatch(typeof(OfflineLeaderboard), "SubmitOfflineScore")] internal static class Patch_OfflineLeaderboardSubmission { private static bool Prefix() { return false; } } internal static class PluginInfo { internal const string Guid = "com.wk.ropephysicsrewrite"; internal const string Name = "White Knuckle Rope Physics Rewrite"; internal const string Version = "1.1.44"; } internal static class RopeRebuild { private sealed class ReleasedCollisionState { internal Vector3[] Positions = Array.Empty(); internal Vector3 AnchorPosition; internal Vector3 EndpointPosition; internal int SettledSteps; internal int ActiveSteps; internal float NextWakeCheckAt; internal bool Sleeping; } private sealed class RopeState { internal ENV_Rope Rope; internal ENT_Player Player; internal Rigidbody? Endpoint; internal bool EndpointWasKinematic; internal RigidbodyInterpolation EndpointInterpolation; internal Vector3 LastEndpointPosition; internal Vector3 EndpointReleaseVelocity; internal bool HasEndpointPosition; internal readonly Dictionary Grabs = new Dictionary(); internal int GripIndex; internal float RopeLength; internal float ArmLength; internal float BodyLength; internal bool IsTaut; internal bool PinSlackHandsToGrip; internal bool TensionedFromSlack; internal bool DampenOnRelease; internal Vector3 SlackGripOffset; internal float SlackHandReach; internal Vector3 GroundGripVelocity; internal float LastSlackDistance; internal bool RequireSlackRadiusEntry; internal bool SlackHasEnteredRadius; internal float RetensionAllowedAt; internal Vector3 LastGripPosition; internal bool HasGripPosition; internal Vector3 GripDirection; internal bool HasGripDirection; internal Vector3 ClimbVelocity; internal bool TailNeedsReset; internal readonly List CollisionPivots = new List(); internal bool HasCollisionPivot; internal Vector3 CollisionPivot; internal Vector3 CollisionNormal; internal float CollisionPathLength; internal int CollisionPivotNodeIndex; internal float CollisionRopeRadiusOffset; internal float CollisionBodyRadiusOffset; internal Vector3[] PreviousRenderPositions = Array.Empty(); internal Vector3[] CurrentRenderPositions = Array.Empty(); internal Vector3[] InterpolatedRenderPositions = Array.Empty(); internal bool HasRenderSnapshot; } private sealed class RopeCollisionPivot { internal Vector3 Position; internal Vector3 Normal; internal Collider? Collider; internal int FramesWithoutContact; } private sealed class GrabState { internal CL_Handhold_Rope Handhold; internal Hand Hand; internal ENV_Rope_Node Node; internal int GripIndex; internal int SegmentIndex; internal float SegmentAmount; internal float OriginalHandDrag; internal Vector3 VisualAnchor; internal bool HasVisualAnchor; } private sealed class PlayerState { internal ENT_Player Player; internal readonly HashSet RopeIds = new HashSet(); internal readonly List RopeBuffer = new List(); internal readonly List ConstraintBuffer = new List(); internal Vector3 Position; internal Vector3 Velocity; internal int PumpDirection; internal float PumpPower; internal int AttachmentWarmupSteps; internal Vector3 GrabMoveAxis; internal Vector3 GrabCorrection; internal bool NativeClimbThisFrame; internal bool SwingMode; internal float SwingChargeStartedAt; internal float WalkModeStartedAt; internal bool WasSolidHandhold; internal Vector3 SolidHandholdVelocity; internal bool PendingSolidHandholdJump; internal Vector3 PendingSolidHandholdJumpVelocity; internal float NextAttachedJumpAt; internal float NativeJumpUntil; internal bool SuppressJumpRelease; internal bool AllowJumpRelease; internal bool GroundWalkMode; internal bool WasGrounded; internal float LastGroundContactAt; } private sealed class ReleaseJumpState { internal float ExpiresAt; internal bool WaitingForButtonRelease; } private sealed class HandholdTuningState { internal CL_Handhold_Rope Handhold; internal int RefCount; internal float DragMult; internal float VelocityMult; internal float ClimbMult; internal float ClimbGrav; internal float SpeedMult; internal float HangVelAdjust; internal bool Swinging; } private sealed class CollisionRecoveryState { internal ENT_Player Player; internal float ExpiresAt; } private const float MinimumLength = 0.25f; private const float MaximumSwingAngle = 2.443461f; private const float PumpAngleLimit = (float)Math.PI / 2f; private const float AttachedJumpCooldown = 0.6f; private const float ImmediateGrabJumpWindow = 0.12f; private const float ReleaseJumpWindow = 0.35f; private const float GroundPoleVaultAngle = 1.3089969f; private const float LowAngleClimbReleaseAngle = (float)Math.PI / 4f; private const float MaximumClimbReleaseRopeSpeed = 1.5f; private const float ClimbReleaseRopeMomentumRetention = 0.25f; private const float MaximumEntrySpeed = 24f; private const float MaximumReleaseSpeed = 20f; private const float PlayerVelocityScale = 175f; private const float StandardHandholdDrag = 10f; private const float PumpRampUpRate = 2.5f; private const float PumpRampDownRate = 4f; private const float GripDirectionResponse = 35f; private const float ClimbEntryVelocityTransfer = 0.65f; private const float JumpBelowGrabCooldown = 0.75f; private const float BelowGrabHorizontalRadius = 1.25f; private const float BelowGrabVerticalTolerance = 0.1f; private const float ModeInputDeadzone = 0.15f; private const float SwingMomentumThreshold = 1.25f; private const float SwingChargeDuration = 0.35f; private const float SwingModeExitDelay = 0.18f; private const float TailVelocityDamping = 4f; private const float MaximumTailRelativeSpeed = 8f; private const float EndpointVelocityResponse = 25f; private const float RopeCollisionRadius = 0.12f; private const float RopeCollisionSkin = 0.025f; private const float GroundProbeDistance = 0.2f; private const float GroundRopeProbeHeight = 1.5f; private const float GroundContactTolerance = 0.03f; private const float MinimumRopeGroundNormal = 0.5f; private const float GroundGripSmoothTime = 0.12f; private const float GroundGripMaximumSpeed = 8f; private const float HandVisualAnchorResponse = 24f; private const float HandVisualSnapDistance = 2.5f; private const float SwingGripReachScale = 0.9f; private const int SwingGripBlendNodes = 2; private const int MaximumCollisionPivots = 8; private const float CollisionPivotMinimumSpacing = 0.15f; private const int CollisionPivotReleaseFrames = 3; private const float CollisionConstraintTransitionResponse = 12f; private const float CollisionPivotRebaseDistance = 0.08f; private const int CollisionEdgeSearchSteps = 7; private const float CollisionEdgeProbeLift = 0.08f; private const int RopeCollisionIterations = 2; private const int ReleasedCollisionIterations = 6; private const float ReleasedContactDamping = 14f; private const float ReleasedContactRestingSpeed = 0.3f; private const int ReleasedCollisionSleepSteps = 30; private const int ReleasedCollisionMaximumActiveSteps = 600; private const float ReleasedCollisionSleepMovement = 0.004f; private const float ReleasedCollisionWakeMovement = 0.02f; private const float ReleasedCollisionSleepEndpointSpeed = 0.15f; private const float ReleasedCollisionWakePollInterval = 0.2f; private const int RopeCollisionHitCapacity = 64; private const float SlackRetensionDelay = 0.12f; private const float SlackTensionTolerance = 0.05f; private const float SlackOutwardSpeedThreshold = 0.1f; private const float SlackHandReachPadding = 0.2f; private const float SlackHandReleasePadding = 0.25f; private const float RecentGroundContactWindow = 0.2f; private const float SlackNodeDamping = 1.5f; private const int SlackConstraintIterations = 12; private const int AttachmentWarmupSteps = 3; private const float PlayerCollisionRecoveryDuration = 2f; private const float LifecyclePruneInterval = 1f; private const float MaximumControllerCorrection = 3f; private const float MaximumControllerMoveStep = 0.35f; private static readonly Dictionary Ropes = new Dictionary(); private static readonly Dictionary Players = new Dictionary(); private static readonly Dictionary ReleaseJumps = new Dictionary(); private static readonly Dictionary BelowGrabBlockedUntil = new Dictionary(); private static readonly Dictionary NextRopeJumpAllowedAt = new Dictionary(); private static readonly Dictionary HandholdTuning = new Dictionary(); private static readonly HashSet DisabledRopes = new HashSet(); private static readonly Dictionary ReleasedCollisionRopes = new Dictionary(); private static readonly Dictionary KnownRopes = new Dictionary(); private static readonly Dictionary KnownRopeEndpointObjects = new Dictionary(); private static readonly Dictionary> KnownRopeEndpointObjectIds = new Dictionary>(); private static readonly Dictionary PlayerCollisionRecovery = new Dictionary(); private static readonly RaycastHit[] RopeCollisionHits = (RaycastHit[])(object)new RaycastHit[64]; private static readonly Vector3[] CollisionEdgeDirections = (Vector3[])(object)new Vector3[5]; private static readonly FieldInfo? TargetRigidbodyField = AccessTools.Field(typeof(ENV_Rope), "targetRigidbody"); private static readonly FieldInfo? PlayerVelocityField = AccessTools.Field(typeof(ENT_Player), "vel"); private static readonly FieldInfo? PlayerNoclipField = AccessTools.Field(typeof(ENT_Player), "noclip"); private static readonly FieldInfo? ForceJumpField = AccessTools.Field(typeof(ENT_Player), "forceJump"); private static readonly FieldInfo? TimeSinceGroundedField = AccessTools.Field(typeof(ENT_Player), "timeSinceGrounded"); private static readonly FieldInfo? ForceAirbornTimeField = AccessTools.Field(typeof(ENT_Player), "forceAirbornTime"); private static readonly FieldInfo? CanJumpThisFrameField = AccessTools.Field(typeof(ENT_Player), "canJumpThisFrame"); private static readonly FieldInfo? HoldDistanceField = AccessTools.Field(typeof(ENT_Player), "holdDistance"); private static readonly FieldInfo? HandholdRopeField = AccessTools.Field(typeof(CL_Handhold_Rope), "rope"); private static readonly FieldInfo? HandholdSwingingField = AccessTools.Field(typeof(CL_Handhold_Rope), "swinging"); private static readonly FieldInfo? HandholdHandsField = AccessTools.Field(typeof(CL_Handhold), "hands"); private static readonly FieldInfo? LastGrabTimeField = AccessTools.Field(typeof(ENV_Rope), "lastGrabTime"); private static float NextLifecyclePruneAt; internal static void Grab(CL_Handhold_Rope handhold, ENV_Rope rope, ENV_Rope_Node node, ENT_Player player, Hand hand, Vector3 entryVelocity) { //IL_0041: 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_016f: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) if (!RopeSettings.Enabled || (Object)(object)rope == (Object)null || node == null || (Object)(object)player == (Object)null || hand == null || rope.nodes == null || rope.nodes.Count < 2) { return; } bool flag = IsPlayerGrounded(player); if (flag) { entryVelocity = Vector3.zero; } int instanceID = ((Object)rope).GetInstanceID(); RegisterRope(rope); ReleasedCollisionRopes.Remove(instanceID); WakeEndpoint(rope); LastGrabTimeField?.SetValue(rope, Time.time); if (!EnsureFiniteRopeGeometry(rope)) { throw new InvalidOperationException("The grabbed rope has an invalid anchor or node layout."); } if (!Ropes.TryGetValue(instanceID, out RopeState value)) { value = CreateRopeState(rope, player); value.TailNeedsReset = true; Ropes.Add(instanceID, value); } int key = GrabKey(handhold, hand); float num = hand.dragMult; if (value.Grabs.TryGetValue(key, out GrabState value2)) { num = value2.OriginalHandDrag; if ((Object)(object)value2.Handhold != (Object)null) { RestoreHandholdTuning(value2.Handhold); } RestoreHandDrag(value2); } GrabState grabState = new GrabState { Handhold = handhold, Hand = hand, Node = node, GripIndex = FindGripIndex(rope, node), OriginalHandDrag = num }; InitializeGrabAnchor(rope, grabState); value.Grabs[key] = grabState; ApplyStandardHandholdTuning(handhold, hand, flag ? num : 10f); ResolveGrip(value, ((Component)player).transform.position); InitializeGripDirection(value, flag); if (value.Grabs.Count == 1) { InitializeClimbMomentum(value, entryVelocity); } int instanceID2 = ((Object)player).GetInstanceID(); PlayerCollisionRecovery.Remove(instanceID2); ReleaseJumps.Remove(instanceID2); if (!Players.TryGetValue(instanceID2, out PlayerState value3)) { value3 = new PlayerState { Player = player, Position = ((Component)player).transform.position, Velocity = Vector3.ClampMagnitude(entryVelocity, 24f), SwingMode = false, SwingChargeStartedAt = float.NegativeInfinity, WalkModeStartedAt = float.NegativeInfinity, GroundWalkMode = flag, WasGrounded = flag, LastGroundContactAt = (flag ? Time.time : float.NegativeInfinity) }; Players.Add(instanceID2, value3); } value3.RopeIds.Add(instanceID); if (NextRopeJumpAllowedAt.TryGetValue(instanceID2, out var value4)) { value3.NextAttachedJumpAt = value4; } value3.NativeJumpUntil = Time.time + 0.12f; if (value.Grabs.Count == 1 && flag) { StabilizeGroundGrab(value.Rope); EnterSlack(value, player, 0f, requireRadiusEntry: false, pinHandsToGrip: true); value3.Velocity = Vector3.zero; SetPlayerVelocity(player, Vector3.zero); } value3.AttachmentWarmupSteps = (value.IsTaut ? 3 : 0); if (value3.RopeIds.Count == 1 && value.IsTaut) { InitializeEntryVelocity(value3, value); if (!value3.GroundWalkMode && player.IsSprinting() && HasSwingMomentum(player, value3)) { value3.SwingMode = true; } } SetGroundWalkGrabDrag(value3, flag); rope.SetCollision(false); StandalonePlugin.Log.LogDebug((object)$"Fresh rope solver attached at node {value.GripIndex}."); } internal static void Release(CL_Handhold_Rope handhold, ENV_Rope rope, ENT_Player player, Hand hand, bool allowReleaseJump) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rope == (Object)null || (Object)(object)player == (Object)null) { return; } int instanceID = ((Object)rope).GetInstanceID(); if (Ropes.TryGetValue(instanceID, out RopeState value)) { int key = GrabKey(handhold, hand); if (value.Grabs.TryGetValue(key, out GrabState value2) && value.Grabs.Remove(key)) { try { RestoreHandholdTuning(handhold); } catch { } try { RestoreHandDrag(value2); } catch { } } if (value.Grabs.Count == 0) { bool settleGroundDrop = !value.IsTaut && IsGroundDraggedRope(value); if (value.DampenOnRelease) { DampenClimbRelease(value); } RestoreManagedRopeState(value, restoreEndpoint: true, manageReleasedCollision: true, settleGroundDrop); Ropes.Remove(instanceID); if (Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value3)) { value3.RopeIds.Remove(instanceID); } } else { ResolveGrip(value, ((Component)player).transform.position); } } if (Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value4)) { SetReleaseVelocity(player, Vector3.ClampMagnitude(value4.Velocity, 20f)); if (value4.RopeIds.Count == 0) { if (allowReleaseJump && CanStartRopeJump(player)) { ReleaseJumps[((Object)player).GetInstanceID()] = new ReleaseJumpState { ExpiresAt = Time.time + 0.35f, WaitingForButtonRelease = InputManager.GetButton("Jump").Pressed }; } Players.Remove(((Object)player).GetInstanceID()); } } BeginPlayerCollisionRecovery(player); rope.SetCollision(false); } internal static bool IsControlled(ENV_Rope rope) { if (RopeSettings.Enabled && (Object)(object)rope != (Object)null) { return Ropes.ContainsKey(((Object)rope).GetInstanceID()); } return false; } internal static bool ShouldRunNativeRopeFixedUpdate(ENV_Rope rope) { if (IsControlled(rope)) { return false; } if ((Object)(object)rope == (Object)null || !ReleasedCollisionRopes.TryGetValue(((Object)rope).GetInstanceID(), out ReleasedCollisionState value) || !value.Sleeping) { return true; } if (Time.time < value.NextWakeCheckAt) { return false; } value.NextWakeCheckAt = Time.time + 0.2f; if (HasReleasedRopeWakeMotion(rope, value)) { WakeReleasedRope(rope); return true; } return false; } internal static void WakeReleasedRope(ENV_Rope rope) { if (!((Object)(object)rope == (Object)null)) { if (ReleasedCollisionRopes.TryGetValue(((Object)rope).GetInstanceID(), out ReleasedCollisionState value)) { value.Sleeping = false; value.SettledSteps = 0; value.ActiveSteps = 0; value.NextWakeCheckAt = 0f; } WakeEndpoint(rope); } } internal static bool CanControl(ENV_Rope rope) { if ((Object)(object)rope != (Object)null) { return !DisabledRopes.Contains(((Object)rope).GetInstanceID()); } return false; } internal static void RegisterRope(ENV_Rope rope) { if (!((Object)(object)rope == (Object)null)) { int instanceID = ((Object)rope).GetInstanceID(); KnownRopes[instanceID] = rope; RegisterRopeEndpointObjects(instanceID, rope); } } internal static void ForgetRope(ENV_Rope rope) { if ((Object)(object)rope == (Object)null) { return; } int instanceID = ((Object)rope).GetInstanceID(); if (Ropes.TryGetValue(instanceID, out RopeState value)) { try { RestoreManagedRopeState(value, restoreEndpoint: true, manageReleasedCollision: false); } catch { } } RemoveRopeFromPlayers(instanceID); ReleasedCollisionRopes.Remove(instanceID); DisabledRopes.Remove(instanceID); KnownRopes.Remove(instanceID); RemoveRopeEndpointObjects(instanceID); Ropes.Remove(instanceID); } internal static void ResetAllState() { List list = new List(Ropes.Values); for (int i = 0; i < list.Count; i++) { try { RestoreManagedRopeState(list[i], restoreEndpoint: true, manageReleasedCollision: false); } catch { } } foreach (PlayerState value in Players.Values) { if ((Object)(object)value.Player != (Object)null) { try { RestorePlayerControllerCollision(value.Player); } catch { } } } foreach (CollisionRecoveryState value2 in PlayerCollisionRecovery.Values) { if ((Object)(object)value2.Player != (Object)null) { try { RestorePlayerControllerCollision(value2.Player); } catch { } } } ForceRestoreAllHandholdTuning(); Ropes.Clear(); Players.Clear(); ReleaseJumps.Clear(); BelowGrabBlockedUntil.Clear(); NextRopeJumpAllowedAt.Clear(); DisabledRopes.Clear(); ReleasedCollisionRopes.Clear(); KnownRopes.Clear(); KnownRopeEndpointObjects.Clear(); KnownRopeEndpointObjectIds.Clear(); PlayerCollisionRecovery.Clear(); NextLifecyclePruneAt = 0f; } internal static void RegisterLoadedRopes() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) ENV_Rope[] array = Resources.FindObjectsOfTypeAll(); foreach (ENV_Rope val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { RegisterRope(val); } } } } internal static void MaintainPlayerSafety(ENT_Player player) { if ((Object)(object)player == (Object)null) { return; } PruneLifecycleState(); int instanceID = ((Object)player).GetInstanceID(); CollisionRecoveryState value; if (Players.ContainsKey(instanceID)) { RestorePlayerControllerCollision(player); } else if (PlayerCollisionRecovery.TryGetValue(instanceID, out value)) { if (Time.time > value.ExpiresAt) { PlayerCollisionRecovery.Remove(instanceID); } else { RestorePlayerControllerCollision(player); } } } private static void RestorePlayerControllerCollision(ENT_Player player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player.cCon == (Object)null)) { object obj = PlayerNoclipField?.GetValue(player); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) == 0) { player.cCon.detectCollisions = true; player.cCon.enableOverlapRecovery = true; } } } private static void BeginPlayerCollisionRecovery(ENT_Player player) { if (!((Object)(object)player == (Object)null)) { RestorePlayerControllerCollision(player); PlayerCollisionRecovery[((Object)player).GetInstanceID()] = new CollisionRecoveryState { Player = player, ExpiresAt = Time.time + 2f }; } } private static void RestoreManagedRopeState(RopeState state, bool restoreEndpoint, bool manageReleasedCollision, bool settleGroundDrop = false) { List list = new List(state.Grabs.Values); for (int i = 0; i < list.Count; i++) { GrabState grabState = list[i]; try { if ((Object)(object)grabState.Handhold != (Object)null) { RestoreHandholdTuning(grabState.Handhold); } } catch { } try { RestoreHandDrag(grabState); } catch { } } state.Grabs.Clear(); if (!restoreEndpoint || (Object)(object)state.Rope == (Object)null) { return; } try { RestoreEndpoint(state, settleGroundDrop); if (manageReleasedCollision) { BeginReleasedCollisionManagement(state.Rope); } } catch { } finally { RestoreEndpointOwnership(state); } } private static void RestoreEndpointOwnership(RopeState state) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)state.Endpoint == (Object)null) { return; } try { state.Endpoint.interpolation = state.EndpointInterpolation; } catch { } try { state.Endpoint.isKinematic = state.EndpointWasKinematic; } catch { } } private static void RemoveRopeFromPlayers(int ropeId) { List list = null; foreach (KeyValuePair player in Players) { if (player.Value.RopeIds.Remove(ropeId) && player.Value.RopeIds.Count == 0) { if ((Object)(object)player.Value.Player != (Object)null) { BeginPlayerCollisionRecovery(player.Value.Player); } if (list == null) { list = new List(); } list.Add(player.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { Players.Remove(list[i]); } } } private static void RegisterRopeEndpointObjects(int ropeId, ENV_Rope rope) { RemoveRopeEndpointObjects(ropeId); List list = new List(); RegisterRopeEndpointObject(ropeId, (Object?)(object)rope.target, list); object? obj = TargetRigidbodyField?.GetValue(rope); Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null); RegisterRopeEndpointObject(ropeId, (Object?)(object)val, list); RegisterRopeEndpointObject(ropeId, (Object?)(object)(((Object)(object)val != (Object)null) ? ((Component)val).transform : null), list); KnownRopeEndpointObjectIds[ropeId] = list; } private static void RegisterRopeEndpointObject(int ropeId, Object? endpointObject, List objectIds) { if (!(endpointObject == (Object)null)) { int instanceID = endpointObject.GetInstanceID(); KnownRopeEndpointObjects[instanceID] = ropeId; if (!objectIds.Contains(instanceID)) { objectIds.Add(instanceID); } } } private static void RemoveRopeEndpointObjects(int ropeId) { if (!KnownRopeEndpointObjectIds.TryGetValue(ropeId, out List value)) { return; } for (int i = 0; i < value.Count; i++) { int key = value[i]; if (KnownRopeEndpointObjects.TryGetValue(key, out var value2) && value2 == ropeId) { KnownRopeEndpointObjects.Remove(key); } } KnownRopeEndpointObjectIds.Remove(ropeId); } private static void PruneLifecycleState() { if (Time.time < NextLifecyclePruneAt) { return; } NextLifecyclePruneAt = Time.time + 1f; List list = null; foreach (KeyValuePair rope in Ropes) { RopeState value = rope.Value; PlayerState value2; bool flag = (Object)(object)value.Player != (Object)null && Players.TryGetValue(((Object)value.Player).GetInstanceID(), out value2) && value2.RopeIds.Contains(rope.Key); if (!((Object)(object)value.Rope != (Object)null && flag)) { if (list == null) { list = new List(); } list.Add(rope.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { int num = list[i]; if (Ropes.TryGetValue(num, out RopeState value3)) { RestoreManagedRopeState(value3, (Object)(object)value3.Rope != (Object)null, manageReleasedCollision: false); } Ropes.Remove(num); RemoveRopeFromPlayers(num); } } List list2 = null; foreach (KeyValuePair knownRope in KnownRopes) { if (!((Object)(object)knownRope.Value != (Object)null)) { if (list2 == null) { list2 = new List(); } list2.Add(knownRope.Key); } } if (list2 != null) { for (int j = 0; j < list2.Count; j++) { int num2 = list2[j]; KnownRopes.Remove(num2); ReleasedCollisionRopes.Remove(num2); DisabledRopes.Remove(num2); RemoveRopeEndpointObjects(num2); } } List list3 = null; foreach (KeyValuePair player in Players) { if (!((Object)(object)player.Value.Player != (Object)null) || player.Value.RopeIds.Count <= 0) { if ((Object)(object)player.Value.Player != (Object)null) { BeginPlayerCollisionRecovery(player.Value.Player); } if (list3 == null) { list3 = new List(); } list3.Add(player.Key); } } if (list3 != null) { for (int k = 0; k < list3.Count; k++) { Players.Remove(list3[k]); } } List list4 = null; foreach (KeyValuePair item in HandholdTuning) { if (!((Object)(object)item.Value.Handhold != (Object)null)) { if (list4 == null) { list4 = new List(); } list4.Add(item.Key); } } if (list4 != null) { for (int l = 0; l < list4.Count; l++) { HandholdTuning.Remove(list4[l]); } } PruneExpiredPlayerTimers(); } private static void PruneExpiredPlayerTimers() { float time = Time.time; List list = null; foreach (KeyValuePair item in BelowGrabBlockedUntil) { if (!(item.Value > time)) { if (list == null) { list = new List(); } list.Add(item.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { BelowGrabBlockedUntil.Remove(list[i]); } } list = null; foreach (KeyValuePair item2 in NextRopeJumpAllowedAt) { if (!(item2.Value > time)) { if (list == null) { list = new List(); } list.Add(item2.Key); } } if (list != null) { for (int j = 0; j < list.Count; j++) { NextRopeJumpAllowedAt.Remove(list[j]); } } list = null; foreach (KeyValuePair releaseJump in ReleaseJumps) { if (!(releaseJump.Value.ExpiresAt > time)) { if (list == null) { list = new List(); } list.Add(releaseJump.Key); } } if (list != null) { for (int k = 0; k < list.Count; k++) { ReleaseJumps.Remove(list[k]); } } list = null; foreach (KeyValuePair item3 in PlayerCollisionRecovery) { if (!((Object)(object)item3.Value.Player != (Object)null) || !(item3.Value.ExpiresAt > time)) { if (list == null) { list = new List(); } list.Add(item3.Key); } } if (list != null) { for (int l = 0; l < list.Count; l++) { PlayerCollisionRecovery.Remove(list[l]); } } } internal static bool IsAttached(ENT_Player player) { if (RopeSettings.Enabled && (Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return value.RopeIds.Count > 0; } return false; } internal static bool HasTautConstraint(ENT_Player player) { if (!RopeSettings.Enabled || (Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return false; } foreach (int ropeId in value.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value2) && value2.IsTaut) { return true; } } return false; } internal static bool IsGroundWalkActive(ENT_Player player) { if ((Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return IsRopeWalkMode(player, value); } return false; } internal static bool HasSolidHandholdOverride(ENT_Player player) { return HasSolidHandhold(player); } internal static bool HasSolidHandholdJumpContext(ENT_Player player) { if ((Object)(object)player != (Object)null) { if (!HasSolidHandhold(player)) { if (Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return value.WasSolidHandhold; } return false; } return true; } return false; } internal static bool BeginAttachedJump(ENT_Player player) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return false; } List playerRopes = GetPlayerRopes(value); if (playerRopes.Count == 0 || !CanStartRopeJump(player)) { return false; } SetReleaseVelocity(player, Vector3.ClampMagnitude(value.Velocity, 20f)); ForceJumpField?.SetValue(player, true); StartRopeJumpCooldown(player, value); value.SuppressJumpRelease = true; value.GroundWalkMode = false; SetGroundWalkGrabDrag(value, groundWalk: false); bool flag = player.IsGrounded(false) || Time.time - value.LastGroundContactAt <= 0.2f; foreach (RopeState item in playerRopes) { bool requireRadiusEntry = flag && GetRopeAngle(item) >= 1.3089969f && !IsActivelyPullingRope(player, value, item); EnterSlack(item, player, 0.12f, requireRadiusEntry, pinHandsToGrip: true); } value.AttachmentWarmupSteps = 0; value.PumpDirection = 0; value.PumpPower = 0f; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; StandalonePlugin.Log.LogDebug((object)"Attached jump made the held rope slack."); return true; } private static bool IsActivelyPullingRope(ENT_Player player, PlayerState state, RopeState rope) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_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) Vector3 val = Vector3.ProjectOnPlane(((Component)player).transform.position - GetConstraintAnchor(rope), Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return false; } ((Vector3)(ref val)).Normalize(); Vector2 vector = InputManager.GetVector("Move").vector; Vector3 val2 = ((Component)player).transform.forward * vector.y + ((Component)player).transform.right * vector.x; val2.y = 0f; float num = ((((Vector3)(ref val2)).sqrMagnitude >= 0.0225f) ? Vector3.Dot(((Vector3)(ref val2)).normalized, val) : 0f); float num2 = Vector3.Dot(state.Velocity, val); if (!(num > 0.25f)) { return num2 > 0.1f; } return true; } internal static bool BeginSolidHandholdJump(ENT_Player player) { //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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value) || (!HasSolidHandhold(player) && !value.WasSolidHandhold)) { return false; } StartRopeJumpCooldown(player, value); value.SuppressJumpRelease = true; value.AllowJumpRelease = false; value.GroundWalkMode = false; SetGroundWalkGrabDrag(value, groundWalk: false); value.PumpDirection = 0; value.PumpPower = 0f; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; return true; } internal static void CompleteAttachedJump(ENT_Player player) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0042: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } Vector3 val = Vector3.ClampMagnitude(GetNativeWorldVelocity(player), 24f); Vector3 val2 = Vector3.ClampMagnitude(value.Velocity, 24f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, Mathf.Max(val2.y, val.y), val2.z); val3 = Vector3.ClampMagnitude(val3, 24f); float num = Vector3.Distance(new Vector3(val.x, 0f, val.z), new Vector3(val2.x, 0f, val2.z)); value.Velocity = val3; SetReleaseVelocity(player, val3); float dt = Mathf.Max(Time.fixedDeltaTime, 0.001f); foreach (RopeState playerRope in GetPlayerRopes(value)) { if (!playerRope.IsTaut) { ResetAttachedJumpSlackRope(playerRope, val3, dt); } } StandalonePlugin.Log.LogDebug((object)("Attached jump removed " + num.ToString("F2") + " m/s of native lateral impulse.")); } internal static void CompleteSolidHandholdJump(ENT_Player player) { //IL_0042: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { if (HasSolidHandhold(player)) { value.PendingSolidHandholdJump = false; value.PendingSolidHandholdJumpVelocity = Vector3.zero; } else { value.PendingSolidHandholdJump = true; value.PendingSolidHandholdJumpVelocity = Vector3.ClampMagnitude(GetNativeWorldVelocity(player), 24f); value.NativeClimbThisFrame = false; } } } internal static void NotifyGroundContact(ENT_Player player, Vector3 normal, Vector3 moveDirection) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !(normal.y < Mathf.Cos(player.slopeLimit * ((float)Math.PI / 180f))) && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { value.LastGroundContactAt = Time.time; bool forceReset = !value.WasGrounded; value.WasGrounded = true; EnterGroundWalkMode(player, value, forceReset); } } internal static void EndAttachedJump(ENT_Player player) { if ((Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { value.SuppressJumpRelease = false; ConsumeRopeJumpGroundWindow(player); } } internal static bool ShouldPreserveJumpGrab(ENT_Player player) { if ((Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value) && !value.AllowJumpRelease) { if (!value.SuppressJumpRelease) { return Time.time < value.NextAttachedJumpAt; } return true; } return false; } internal static bool ShouldKeepRopeOnJump(ENT_Player player) { if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return false; } if (Time.time <= value.NativeJumpUntil) { return false; } return IsRopeWalkMode(player, value); } internal static bool CanStartRopeJump(ENT_Player player) { if ((Object)(object)player == (Object)null) { return false; } int instanceID = ((Object)player).GetInstanceID(); if (NextRopeJumpAllowedAt.TryGetValue(instanceID, out var value)) { return Time.time >= value; } return true; } private static void ConsumeRopeJumpGroundWindow(ENT_Player player) { TimeSinceGroundedField?.SetValue(player, Mathf.Max(player.coyoteTime, 0.05f)); float num = ((ForceAirbornTimeField?.GetValue(player) is float num2) ? num2 : 0f); ForceAirbornTimeField?.SetValue(player, Mathf.Max(num, 0.05f)); CanJumpThisFrameField?.SetValue(player, false); } internal static void BeginNativeJumpRelease(ENT_Player player) { if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } value.AllowJumpRelease = true; bool flag = !value.SwingMode; List playerRopes = GetPlayerRopes(value); for (int i = 0; i < playerRopes.Count; i++) { RopeState ropeState = playerRopes[i]; ropeState.DampenOnRelease = flag && GetRopeAngle(ropeState) <= (float)Math.PI / 4f; } if (HasTautConstraint(player) || player.hands == null) { return; } for (int j = 0; j < player.hands.Length; j++) { Hand val = player.hands[j]; if (IsControlledRopeHand(val)) { player.StopInteraction(val.id, "jump", true); } } } internal static void EndNativeJumpRelease(ENT_Player player) { if (!((Object)(object)player != (Object)null) || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } value.AllowJumpRelease = false; foreach (RopeState playerRope in GetPlayerRopes(value)) { playerRope.DampenOnRelease = false; } } internal static void BeginJumpGrabCooldown(ENT_Player player) { if ((Object)(object)player != (Object)null) { BelowGrabBlockedUntil[((Object)player).GetInstanceID()] = Time.time + 0.75f; } } private static void StartRopeJumpCooldown(ENT_Player player, PlayerState? state = null) { if (!((Object)(object)player == (Object)null)) { int instanceID = ((Object)player).GetInstanceID(); float num = Time.time + 0.6f; NextRopeJumpAllowedAt[instanceID] = num; if (state != null) { state.NextAttachedJumpAt = num; } BeginJumpGrabCooldown(player); } } internal static bool CanGrabRope(ENT_Player player, Vector3 grabPosition) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !BelowGrabBlockedUntil.TryGetValue(((Object)player).GetInstanceID(), out var value)) { return true; } if (Time.time >= value) { BelowGrabBlockedUntil.Remove(((Object)player).GetInstanceID()); return true; } Vector3 val = grabPosition - ((Component)player).transform.position; if (val.y >= -0.1f) { return true; } val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude > 1.5625f; } internal static void PreparePlayerMovement(ENT_Player player) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (IsAttached(player)) { SetPlayerVelocity(player, Vector3.zero); } } internal static void QueueReleaseJump(ENT_Player player) { if ((Object)(object)player == (Object)null || !ReleaseJumps.TryGetValue(((Object)player).GetInstanceID(), out ReleaseJumpState value)) { return; } if (Time.time > value.ExpiresAt) { ReleaseJumps.Remove(((Object)player).GetInstanceID()); return; } bool pressed = InputManager.GetButton("Jump").Pressed; if (value.WaitingForButtonRelease) { if (!pressed) { value.WaitingForButtonRelease = false; } } else if (pressed) { ForceJumpField?.SetValue(player, true); ReleaseJumps.Remove(((Object)player).GetInstanceID()); } } internal static void PrepareGroundedRopeWalk(ENT_Player player) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_010d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value) || !IsPlayerGrounded(player) || HasSolidHandhold(player)) { return; } Vector2 vector = InputManager.GetVector("Move").vector; if (((Vector2)(ref vector)).sqrMagnitude < 0.0225f) { return; } Vector3 val = ((Component)player).transform.forward * vector.y + ((Component)player).transform.right * vector.x; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref val)).Normalize(); foreach (int ropeId in value.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value2) && value2.IsTaut) { Vector3 val2 = GetConstraintAnchor(value2) - ((Component)player).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.0001f) && !(Vector3.Dot(val, ((Vector3)(ref val2)).normalized) < 0.1f)) { EnterSlack(value2, player, 0f, requireRadiusEntry: false, pinHandsToGrip: true); value.PumpDirection = 0; value.PumpPower = 0f; value.SwingMode = false; value.SwingChargeStartedAt = float.NegativeInfinity; } } } } internal static bool ShouldUseNativeClimb(ENT_Player player) { if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return false; } if (HasSolidHandhold(player)) { return true; } TransferSolidHandholdReleaseVelocity(player, value); if (!HasTautConstraint(player)) { return false; } if (IsRopeWalkMode(player, value)) { return false; } UpdateSwingMode(player, value); return !value.SwingMode; } private static void TransferSolidHandholdReleaseVelocity(ENT_Player player, PlayerState state) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!state.WasSolidHandhold) { return; } state.WasSolidHandhold = false; state.Position = ((Component)player).transform.position; state.Velocity = Vector3.ClampMagnitude(state.SolidHandholdVelocity, 24f); foreach (int ropeId in state.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value) && value.IsTaut) { InitializeEntryVelocity(state, value); break; } } if (player.IsSprinting() && ((Vector3)(ref state.Velocity)).magnitude >= 1.25f) { state.SwingMode = true; state.SwingChargeStartedAt = float.NegativeInfinity; state.WalkModeStartedAt = float.NegativeInfinity; } } private static bool HasSolidHandhold(ENT_Player player) { if (player?.hands == null) { return false; } for (int i = 0; i < player.hands.Length; i++) { Hand val = player.hands[i]; if (val != null && val.currentInteract != null) { CL_Handhold val2 = (CL_Handhold)(((object)val.handhold) ?? ((object)/*isinst with value type is only supported in some contexts*/)); if ((Object)(object)val2 != (Object)null && !(val2 is CL_Handhold_Rope)) { return true; } } } return false; } internal static bool IsControlledRopeHand(Hand hand) { if (hand != null) { CL_Handhold handhold = hand.handhold; CL_Handhold_Rope val = (CL_Handhold_Rope)(object)((handhold is CL_Handhold_Rope) ? handhold : null); if (val != null) { object? obj = HandholdRopeField?.GetValue(val); ENV_Rope val2 = (ENV_Rope)((obj is ENV_Rope) ? obj : null); if ((Object)(object)val2 != (Object)null) { return IsControlled(val2); } return false; } } return false; } internal static Vector3 GetEntryVelocity(ENT_Player player) { //IL_001f: 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 (!((Object)(object)player != (Object)null) || IsPlayerGrounded(player) || !((Object)(object)player.cCon != (Object)null)) { return Vector3.zero; } return player.cCon.velocity; } private static Vector3 GetNativeWorldVelocity(ENT_Player player) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player != (Object)null && PlayerVelocityField?.GetValue(player) is Vector3 val) { return val * 175f; } if (!((Object)(object)player?.cCon != (Object)null)) { return Vector3.zero; } return player.cCon.velocity; } private static void MovePlayerWithCollisions(ENT_Player player, Vector3 displacement) { //IL_0000: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!IsFinite(displacement)) { throw new InvalidOperationException("The rope solver produced a non-finite player correction."); } float magnitude = ((Vector3)(ref displacement)).magnitude; if (!(magnitude < 0.0001f)) { if (magnitude > 3f) { throw new InvalidOperationException("The rope solver rejected an unsafe " + magnitude.ToString("F2") + " metre player correction."); } CharacterController cCon = player.cCon; if ((Object)(object)cCon == (Object)null || !((Collider)cCon).enabled) { throw new InvalidOperationException("The player collision controller is unavailable."); } int num = Mathf.Max(1, Mathf.CeilToInt(magnitude / 0.35f)); Vector3 val = displacement / (float)num; for (int i = 0; i < num; i++) { cCon.Move(val); } } } private static bool IsFinite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static bool IsFinite(Vector3 value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFinite(value.x) && IsFinite(value.y)) { return IsFinite(value.z); } return false; } private static void ValidateManagedState(PlayerState playerState, List ropes, Vector3 playerPosition, Vector3 nativeVelocity) { //IL_0000: 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_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_0029: 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_0085: 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_00f4: Unknown result type (might be due to invalid IL or missing references) if (!IsFinite(playerPosition)) { throw new InvalidOperationException("The player position became non-finite."); } if (!IsFinite(playerState.Velocity)) { playerState.Velocity = (IsFinite(nativeVelocity) ? Vector3.ClampMagnitude(nativeVelocity, 24f) : Vector3.zero); } for (int i = 0; i < ropes.Count; i++) { RopeState ropeState = ropes[i]; if (!EnsureFiniteRopeGeometry(ropeState.Rope)) { throw new InvalidOperationException("A controlled rope has an invalid anchor."); } for (int num = ropeState.CollisionPivots.Count - 1; num >= 0; num--) { RopeCollisionPivot ropeCollisionPivot = ropeState.CollisionPivots[num]; if (!IsFinite(ropeCollisionPivot.Position) || !IsFinite(ropeCollisionPivot.Normal)) { ropeState.CollisionPivots.RemoveAt(num); } } if (!IsFinite(ropeState.RopeLength) || !IsFinite(ropeState.BodyLength) || !IsFinite(ropeState.ArmLength) || !(ropeState.RopeLength >= 0.25f) || !(ropeState.BodyLength >= 0.25f)) { ResolveGrip(ropeState, playerPosition); ropeState.HasGripDirection = false; InitializeGripDirection(ropeState, preserveCurrentGripPosition: true); } } } private static bool EnsureFiniteRopeGeometry(ENV_Rope rope) { //IL_0025: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2 || !IsFinite(((Component)rope).transform.position)) { return false; } float num = ((IsFinite(rope.nodeDistance) && rope.nodeDistance > 0.001f) ? rope.nodeDistance : 0.25f); float num2 = num * (float)rope.nodes.Count * 8f + 10f; Vector3 position = ((Component)rope).transform.position; bool flag = false; for (int i = 0; i < rope.nodes.Count; i++) { ENV_Rope_Node val = rope.nodes[i]; if (!IsFinite(val.position) || !IsFinite(val.previousPosition) || !IsFinite(val.velocity) || Vector3.Distance(position, val.position) > num2) { flag = true; break; } } if (!flag) { return true; } for (int j = 0; j < rope.nodes.Count; j++) { ENV_Rope_Node obj = rope.nodes[j]; obj.position = position + Vector3.down * (num * (float)j); obj.previousPosition = obj.position; obj.velocity = Vector3.zero; obj.locked = j == 0; obj.colliding = false; } if ((Object)(object)rope.target != (Object)null) { rope.target.position = rope.nodes[rope.nodes.Count - 1].position; } object? obj2 = TargetRigidbodyField?.GetValue(rope); Rigidbody val2 = (Rigidbody)((obj2 is Rigidbody) ? obj2 : null); if ((Object)(object)val2 != (Object)null && !val2.isKinematic) { val2.velocity = Vector3.zero; val2.angularVelocity = Vector3.zero; } StandalonePlugin.Log.LogWarning((object)"Recovered an invalid rope node layout before it could propagate into player movement."); return true; } internal static bool ShouldSuppressHandVelocity(Hand hand) { return IsControlledRopeHand(hand); } internal static void RestorePhysicsTransforms(ENT_Player player) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } foreach (int ropeId in value.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value2)) { if (!EnsureFiniteRopeGeometry(value2.Rope)) { throw new InvalidOperationException("A controlled rope has an invalid anchor."); } if ((Object)(object)value2.Endpoint != (Object)null && value2.Rope.nodes != null && value2.Rope.nodes.Count > 0) { value2.Endpoint.position = value2.Rope.nodes[value2.Rope.nodes.Count - 1].position; } RenderRope(value2.Rope); StabilizeGrabAnchors(value2); } } } internal static void RestorePhysicsTransformsSafely(ENT_Player player) { try { RestorePhysicsTransforms(player); } catch (Exception ex) { StandalonePlugin.Log.LogError((object)("Rope physics synchronization failed and was safely detached: " + ex)); DisableControlAfterRuntimeFailure(player, "physics synchronization"); } } internal static void RenderInterpolatedVisuals(ENT_Player player) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } float num = Mathf.Clamp01((Time.time - Time.fixedTime) / Mathf.Max(Time.fixedDeltaTime, 0.001f)); foreach (int ropeId in value.RopeIds) { if (!Ropes.TryGetValue(ropeId, out RopeState value2) || !value2.HasRenderSnapshot) { continue; } int num2 = value2.CurrentRenderPositions.Length; if (value2.InterpolatedRenderPositions.Length != num2) { value2.InterpolatedRenderPositions = (Vector3[])(object)new Vector3[num2]; } for (int i = 0; i < num2; i++) { value2.InterpolatedRenderPositions[i] = Vector3.Lerp(value2.PreviousRenderPositions[i], value2.CurrentRenderPositions[i], num); } RenderRope(value2.Rope, value2.InterpolatedRenderPositions); if ((Object)(object)value2.Endpoint != (Object)null && num2 > 0) { ((Component)value2.Endpoint).transform.position = value2.InterpolatedRenderPositions[num2 - 1]; } foreach (GrabState value3 in value2.Grabs.Values) { if (IsGrabActive(value3) && !((Object)(object)value3.Hand.handModel == (Object)null) && TryGetGrabAnchor(value2, value3, value2.InterpolatedRenderPositions, out var anchor)) { if (!value3.HasVisualAnchor || Vector3.Distance(value3.VisualAnchor, anchor) > 2.5f) { value3.VisualAnchor = anchor; value3.HasVisualAnchor = true; } else { float num3 = 1f - Mathf.Exp(-24f * Mathf.Max(Time.deltaTime, 0.001f)); value3.VisualAnchor = Vector3.Lerp(value3.VisualAnchor, anchor, num3); } value3.Hand.handModel.position = value3.VisualAnchor; } } } } internal static void RenderInterpolatedVisualsSafely(ENT_Player player) { try { RenderInterpolatedVisuals(player); } catch (Exception ex) { StandalonePlugin.Log.LogError((object)("Rope visual synchronization failed and was safely detached: " + ex)); DisableControlAfterRuntimeFailure(player, "visual synchronization"); } } internal static void StepPlayer(ENT_Player player, Vector3 movementStart) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //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_0112: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0592: 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_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: 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_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: 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_04e6: 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_04ee: 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_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_072f: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_07fc: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) //IL_083c: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: Unknown result type (might be due to invalid IL or missing references) //IL_08ae: Unknown result type (might be due to invalid IL or missing references) //IL_08b4: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Unknown result type (might be due to invalid IL or missing references) //IL_08c1: Unknown result type (might be due to invalid IL or missing references) //IL_08c7: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0860: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_0770: Unknown result type (might be due to invalid IL or missing references) //IL_0772: Unknown result type (might be due to invalid IL or missing references) //IL_0774: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) if (!Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } RestorePlayerControllerCollision(player); DropOverstretchedHands(player, value); if (!Players.TryGetValue(((Object)player).GetInstanceID(), out value)) { return; } RemoveInvalidRopes(value); if (value.RopeIds.Count == 0) { Players.Remove(((Object)player).GetInstanceID()); BeginPlayerCollisionRecovery(player); return; } bool flag = HasSolidHandhold(player); bool flag2 = IsPlayerGrounded(player); bool forceReset = flag2 && !value.WasGrounded; if (flag2) { value.WasGrounded = true; value.LastGroundContactAt = Time.time; if (flag) { value.GroundWalkMode = false; SetGroundWalkGrabDrag(value, groundWalk: false); } else { EnterGroundWalkMode(player, value, forceReset); } } else { if (value.GroundWalkMode) { value.GroundWalkMode = false; SetGroundWalkGrabDrag(value, groundWalk: false); } if (Time.time - value.LastGroundContactAt > 0.2f) { value.WasGrounded = false; } } float num = Mathf.Max(Time.fixedDeltaTime, 0.001f); Vector3 position = ((Component)player).transform.position; Vector3 val = (position - movementStart) / num; value.Position = position; List list = FillPlayerRopeBuffer(value); ValidateManagedState(value, list, position, val); AdvanceCollisionConstraintTransitions(list, num); UpdateCollisionPivots(list); UpdateGroundHeldGripTargets(value, list, position, num); bool flag3 = UpdateSlackTransitions(value, list, position, val); DropUnsupportedTension(player, value, list, position, val); flag = HasSolidHandhold(player); bool flag4 = value.PendingSolidHandholdJump && !flag; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0025f) ? val : value.PendingSolidHandholdJumpVelocity); if (flag4) { value.PendingSolidHandholdJump = false; value.PendingSolidHandholdJumpVelocity = Vector3.zero; value.WasSolidHandhold = false; value.SolidHandholdVelocity = Vector3.zero; value.NativeClimbThisFrame = false; } if (flag || flag4) { if (flag) { value.GroundWalkMode = false; SetGroundWalkGrabDrag(value, groundWalk: false); } ReleaseInwardSolidHandholdTension(player, list, position); } List list2 = FillTautRopeBuffer(value, list); if (list2.Count == 0) { value.PumpPower = Mathf.MoveTowards(value.PumpPower, 0f, 4f * num); value.PumpDirection = 0; value.Velocity = Vector3.ClampMagnitude(flag4 ? val2 : val, 24f); value.Position = position; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; { foreach (RopeState item in list) { UpdateSlackRope(item, position, num); } return; } } if (flag) { StepSolidHandholdTether(player, value, list, list2, movementStart, position, val, num); return; } if (flag4) { value.Velocity = Vector3.ClampMagnitude(val2, 24f); if (list2.Count == 1) { Vector3 val3 = position - GetConstraintAnchor(list2[0]); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { value.Velocity = Vector3.ProjectOnPlane(value.Velocity, ((Vector3)(ref val3)).normalized); } } value.SwingMode = ((Vector3)(ref value.Velocity)).magnitude >= 0.15f; value.SwingChargeStartedAt = float.NegativeInfinity; value.WalkModeStartedAt = float.NegativeInfinity; value.AttachmentWarmupSteps = 0; for (int i = 0; i < list2.Count; i++) { SynchronizeRopeWithPlayerMomentum(list2[i], position, value.Velocity, num); } flag3 = true; StandalonePlugin.Log.LogDebug((object)("Ledge jump transferred " + ((Vector3)(ref value.Velocity)).magnitude.ToString("F2") + " m/s into the held rope.")); } else if (flag3) { value.Velocity = Vector3.ClampMagnitude(val, 24f); if (list2.Count == 1) { InitializeEntryVelocity(value, list2[0]); } } if (flag2 && value.GroundWalkMode) { Vector3 val4 = position; Vector3 val6 = default(Vector3); for (int j = 0; j < 4; j++) { foreach (RopeState item2 in list2) { Vector3 constraintAnchor = GetConstraintAnchor(item2); Vector3 val5 = val4 - constraintAnchor; float remainingBodyLength = GetRemainingBodyLength(item2); float y = val5.y; float num2 = remainingBodyLength * remainingBodyLength - y * y; ((Vector3)(ref val6))..ctor(val5.x, 0f, val5.z); float sqrMagnitude = ((Vector3)(ref val6)).sqrMagnitude; if (num2 >= 0f && sqrMagnitude > num2 && sqrMagnitude > 0.0001f) { float y2 = val4.y; float num3 = Mathf.Sqrt(num2); val4 = constraintAnchor + ((Vector3)(ref val6)).normalized * num3; val4.y = y2; } } } MovePlayerWithCollisions(player, val4 - position); Vector3 playerPosition = (value.Position = ((Component)player).transform.position); value.Velocity = Vector3.ClampMagnitude(val, 24f); value.PumpPower = 0f; value.PumpDirection = 0; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; { foreach (RopeState item3 in list) { if (item3.IsTaut) { UpdateRope(item3, playerPosition, num, followPlayer: true); } else { UpdateSlackRope(item3, playerPosition, num); } } return; } } if (value.NativeClimbThisFrame) { SyncConstraintLengths(list2, position); Vector3 val7 = (position - movementStart) / num; if (list2.Count == 1) { Vector3 val8 = position - GetConstraintAnchor(list2[0]); if (((Vector3)(ref val8)).sqrMagnitude > 0.0001f) { val7 = Vector3.ProjectOnPlane(val7, ((Vector3)(ref val8)).normalized); } } value.PumpPower = Mathf.MoveTowards(value.PumpPower, 0f, 4f * num); value.PumpDirection = 0; value.Velocity = Vector3.ClampMagnitude(val7, 24f); value.Position = position; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; { foreach (RopeState item4 in list) { if (item4.IsTaut) { AdvanceClimbMomentum(item4, num); UpdateRope(item4, position, num, followPlayer: false); } else { UpdateSlackRope(item4, position, num); } } return; } } if (((Vector3)(ref value.GrabCorrection)).sqrMagnitude > 0.0001f) { AdjustConstraintLengthsFromHands(list2, movementStart, position); } WarmUpConstraints(value, list2, position); float num4 = Mathf.Max(0.1f, RopeSettings.Gravity); PlayerState playerState = value; playerState.Velocity += Vector3.down * num4 * num; ApplyPump(value, list2); Vector3 val9 = (flag3 ? position : (position + value.Velocity * num)); if (list2.Count == 1) { RopeState ropeState = list2[0]; val9 = ProjectToSphere(val9, GetConstraintAnchor(ropeState), GetRemainingBodyLength(ropeState)); val9 = ApplyArcLimit(val9, value, ropeState); } else { for (int k = 0; k < 8; k++) { foreach (RopeState item5 in list2) { Vector3 constraintAnchor2 = GetConstraintAnchor(item5); Vector3 val10 = val9 - constraintAnchor2; float magnitude = ((Vector3)(ref val10)).magnitude; float remainingBodyLength2 = GetRemainingBodyLength(item5); if (magnitude > remainingBodyLength2 && magnitude > 0.0001f) { val9 = constraintAnchor2 + val10 / magnitude * remainingBodyLength2; } } } } MovePlayerWithCollisions(player, val9 - position); Vector3 position2 = ((Component)player).transform.position; Vector3 val11 = (flag3 ? value.Velocity : ((position2 - position) / num)); float num5 = Mathf.Max(2f, ((Vector3)(ref value.Velocity)).magnitude + 0.75f); val11 = Vector3.ClampMagnitude(val11, num5); if (list2.Count == 1) { RopeState state = list2[0]; Vector3 val12 = position2 - GetConstraintAnchor(state); if (((Vector3)(ref val12)).sqrMagnitude > 0.0001f) { val11 = Vector3.ProjectOnPlane(val11, ((Vector3)(ref val12)).normalized); } } float num6 = Mathf.Max(0f, RopeSettings.Damping); value.Velocity = val11 * Mathf.Max(0f, 1f - num6 * num); value.Position = position2; value.GrabMoveAxis = Vector3.zero; value.GrabCorrection = Vector3.zero; value.NativeClimbThisFrame = false; SetPlayerVelocity(player, Vector3.zero); foreach (RopeState item6 in list) { if (item6.IsTaut) { UpdateRope(item6, position2, num, followPlayer: true); } else { UpdateSlackRope(item6, position2, num); } } } private static void ReleaseInwardSolidHandholdTension(ENT_Player player, List ropes, Vector3 playerPosition) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ropes.Count; i++) { RopeState ropeState = ropes[i]; if (ropeState.IsTaut && !(GetBodyPathLength(ropeState, playerPosition) >= ropeState.BodyLength - 0.05f)) { EnterSlack(ropeState, player, 0f, requireRadiusEntry: false, pinHandsToGrip: true); } } } private static void StepSolidHandholdTether(ENT_Player player, PlayerState state, List ropes, List constraints, Vector3 movementStart, Vector3 nativePosition, Vector3 nativeVelocity, float dt) { //IL_0000: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) Vector3 val = nativePosition; for (int i = 0; i < 8; i++) { for (int j = 0; j < constraints.Count; j++) { RopeState state2 = constraints[j]; Vector3 constraintAnchor = GetConstraintAnchor(state2); Vector3 val2 = val - constraintAnchor; float magnitude = ((Vector3)(ref val2)).magnitude; float remainingBodyLength = GetRemainingBodyLength(state2); if (magnitude > remainingBodyLength && magnitude > 0.0001f) { val = constraintAnchor + val2 / magnitude * remainingBodyLength; } } } MovePlayerWithCollisions(player, val - nativePosition); Vector3 val3 = (state.Position = ((Component)player).transform.position); state.WasSolidHandhold = true; state.SolidHandholdVelocity = Vector3.ClampMagnitude(nativeVelocity, 24f); state.Velocity = Vector3.ClampMagnitude((val3 - movementStart) / dt, 24f); if (((Vector3)(ref state.Velocity)).sqrMagnitude < 0.0001f) { state.Velocity = Vector3.ClampMagnitude(nativeVelocity, 24f); } state.PumpPower = 0f; state.PumpDirection = 0; state.SwingMode = false; state.SwingChargeStartedAt = float.NegativeInfinity; state.WalkModeStartedAt = float.NegativeInfinity; state.GrabMoveAxis = Vector3.zero; state.GrabCorrection = Vector3.zero; state.NativeClimbThisFrame = false; for (int k = 0; k < ropes.Count; k++) { RopeState ropeState = ropes[k]; if (ropeState.IsTaut) { UpdateRope(ropeState, val3, dt, followPlayer: true); } else { UpdateSlackRope(ropeState, val3, dt); } } } internal static void StepPlayerSafely(ENT_Player player, Vector3 movementStart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { StepPlayer(player, movementStart); } catch (Exception ex) { StandalonePlugin.Log.LogError((object)("Rope movement failed and was safely detached: " + ex)); DisableControlAfterRuntimeFailure(player, "player movement"); } } private static bool UpdateSlackTransitions(PlayerState playerState, List ropes, Vector3 playerPosition, Vector3 nativeVelocity) { //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0076: 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_007b: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b1: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) bool flag = false; bool flag2 = IsRopeWalkMode(playerState.Player, playerState); foreach (RopeState rope in ropes) { if (!rope.IsTaut) { Vector3 position = ((Component)rope.Rope).transform.position; Vector3 slackGripPosition = GetSlackGripPosition(rope, playerPosition); Vector3 val = slackGripPosition - position; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? (val / magnitude) : Vector3.down); float num = Mathf.Max(Vector3.Dot(rope.HasGripPosition ? ((slackGripPosition - rope.LastGripPosition) / Mathf.Max(Time.fixedDeltaTime, 0.001f)) : nativeVelocity, val2), Vector3.Dot(nativeVelocity, val2)); bool num2 = Vector3.Distance(playerPosition, slackGripPosition) > rope.SlackHandReach; if (magnitude < rope.RopeLength - 0.05f) { rope.SlackHasEnteredRadius = true; } bool flag3 = rope.LastSlackDistance < rope.RopeLength - 0.05f && magnitude >= rope.RopeLength - 0.05f; bool flag4 = magnitude >= rope.RopeLength - 0.05f && num > 0.1f; bool flag5 = num2 && magnitude >= rope.RopeLength - 0.05f; bool flag6 = magnitude > rope.RopeLength + 0.05f; rope.LastSlackDistance = magnitude; bool flag7 = (flag2 ? (flag4 || flag5) : ((flag3 && num > 0f) || flag4 || (flag6 && num >= 0f) || flag5)); if ((!(Time.time < rope.RetensionAllowedAt) || flag5) && (!rope.RequireSlackRadiusEntry || rope.SlackHasEnteredRadius) && flag7) { rope.IsTaut = true; rope.PinSlackHandsToGrip = false; rope.GroundGripVelocity = Vector3.zero; rope.TensionedFromSlack = true; rope.RequireSlackRadiusEntry = false; Vector3 val3 = playerPosition - position; Vector3 val4 = (rope.GripDirection = ((((Vector3)(ref val3)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val3)).normalized : val2)); rope.HasGripDirection = true; rope.BodyLength = Mathf.Max(0.25f, ((Vector3)(ref val3)).magnitude); rope.ArmLength = rope.BodyLength - rope.RopeLength; rope.ClimbVelocity = Vector3.ClampMagnitude(Vector3.ProjectOnPlane(nativeVelocity, val4), 24f); rope.LastGripPosition = position + val4 * rope.RopeLength - rope.ClimbVelocity * Mathf.Max(Time.fixedDeltaTime, 0.001f); rope.HasGripPosition = true; StandalonePlugin.Log.LogDebug((object)("Held rope regained tension at " + $"{PolarAngle(val4) * 57.29578f:F1} degrees " + $"with {((Vector3)(ref rope.ClimbVelocity)).magnitude:F2} m/s " + "tangential speed.")); flag = true; } } } if (flag) { playerState.AttachmentWarmupSteps = 0; } return flag; } private static void DropUnsupportedTension(ENT_Player player, PlayerState playerState, List ropes, Vector3 playerPosition, Vector3 nativeVelocity) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.1f, RopeSettings.Gravity); bool flag = false; foreach (RopeState rope in ropes) { if (!rope.IsTaut) { continue; } Vector3 constraintAnchor = GetConstraintAnchor(rope); Vector3 val = playerPosition - constraintAnchor; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.25f) { continue; } val /= magnitude; float num2 = PolarAngle(val); if (!(num2 <= (float)Math.PI / 2f)) { Vector3 val2 = Vector3.ProjectOnPlane(playerState.Velocity, val); float magnitude2 = ((Vector3)(ref val2)).magnitude; val2 = Vector3.ProjectOnPlane(nativeVelocity, val); float magnitude3 = ((Vector3)(ref val2)).magnitude; float num3 = Mathf.Max(magnitude2, magnitude3); if (!(num3 * num3 / magnitude + num * Mathf.Cos(num2) > 0f)) { EnterSlack(rope, player, 0.12f, requireRadiusEntry: true, pinHandsToGrip: true); flag = true; } } } if (flag && !HasTautRope(ropes)) { playerState.SwingMode = false; playerState.SwingChargeStartedAt = float.NegativeInfinity; playerState.PumpDirection = 0; playerState.PumpPower = 0f; } } private static bool HasTautRope(List ropes) { for (int i = 0; i < ropes.Count; i++) { if (ropes[i].IsTaut) { return true; } } return false; } private static List FillTautRopeBuffer(PlayerState state, List ropes) { List constraintBuffer = state.ConstraintBuffer; constraintBuffer.Clear(); for (int i = 0; i < ropes.Count; i++) { if (ropes[i].IsTaut) { constraintBuffer.Add(ropes[i]); } } return constraintBuffer; } private static void AdjustConstraintLengthsFromHands(List ropes, Vector3 previousPosition, Vector3 currentPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 val = currentPosition - previousPosition; foreach (RopeState rope in ropes) { Vector3 val2 = previousPosition - GetConstraintAnchor(rope); if (!(((Vector3)(ref val2)).sqrMagnitude < 0.0001f)) { float num = Vector3.Dot(val, ((Vector3)(ref val2)).normalized); rope.BodyLength = Mathf.Max(0.25f, rope.BodyLength + num); rope.ArmLength = rope.BodyLength - rope.RopeLength; } } } internal static bool CaptureGrabMotion(ENT_Player player, Vector3 moveAxis, Vector3 handCorrection) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_006b: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return false; } Vector2 vector = InputManager.GetVector("Move").vector; Vector3 val = ((Component)player).transform.right * (vector.x * 0.5f); Vector3 val2 = moveAxis - val; value.GrabMoveAxis = ((Mathf.Abs(vector.y) >= 0.15f) ? Vector3.ClampMagnitude(val2, 1f) : Vector3.zero); value.GrabCorrection = Vector3.ClampMagnitude(handCorrection, 1f); value.NativeClimbThisFrame = ShouldUseNativeClimb(player); return value.NativeClimbThisFrame; } private static void WarmUpConstraints(PlayerState state, List ropes, Vector3 playerPosition) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (state.AttachmentWarmupSteps <= 0) { return; } foreach (RopeState rope in ropes) { float bodyPathLength = GetBodyPathLength(rope, playerPosition); rope.BodyLength = Mathf.Max(0.25f, bodyPathLength); rope.ArmLength = rope.BodyLength - rope.RopeLength; } state.AttachmentWarmupSteps--; } private static void SyncConstraintLengths(List ropes, Vector3 playerPosition) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ropes.Count; i++) { RopeState ropeState = ropes[i]; float bodyPathLength = GetBodyPathLength(ropeState, playerPosition); ropeState.BodyLength = Mathf.Max(0.25f, bodyPathLength); ropeState.ArmLength = ropeState.BodyLength - ropeState.RopeLength; } } internal static void DisableControlAfterRuntimeFailure(ENT_Player player, string phase) { if ((Object)(object)player == (Object)null) { return; } int instanceID = ((Object)player).GetInstanceID(); AbortJumpHandling(player); if (!Players.TryGetValue(instanceID, out PlayerState value)) { return; } List list = new List(value.RopeIds); Players.Remove(instanceID); ReleaseJumps.Remove(instanceID); BeginPlayerCollisionRecovery(player); for (int i = 0; i < list.Count; i++) { int num = list[i]; DisabledRopes.Add(num); if (Ropes.TryGetValue(num, out RopeState value2)) { Ropes.Remove(num); try { RestoreManagedRopeState(value2, restoreEndpoint: true, manageReleasedCollision: false); } catch { } } } StandalonePlugin.Log.LogWarning((object)("Rope rewrite encountered an unsupported runtime method during " + phase + ". This rope was returned to the game's original physics to prevent a crash.")); } internal static void DisableRopeAfterRuntimeFailure(ENV_Rope rope, ENT_Player player, string phase) { if ((Object)(object)player != (Object)null && Players.ContainsKey(((Object)player).GetInstanceID())) { DisableControlAfterRuntimeFailure(player, phase); return; } if ((Object)(object)player != (Object)null) { AbortJumpHandling(player); BeginPlayerCollisionRecovery(player); } if ((Object)(object)rope == (Object)null) { return; } int instanceID = ((Object)rope).GetInstanceID(); DisabledRopes.Add(instanceID); ReleasedCollisionRopes.Remove(instanceID); if (Ropes.TryGetValue(instanceID, out RopeState value)) { Ropes.Remove(instanceID); try { RestoreManagedRopeState(value, restoreEndpoint: true, manageReleasedCollision: false); } catch { } } RemoveRopeFromPlayers(instanceID); StandalonePlugin.Log.LogWarning((object)("Rope rewrite control was disabled during " + phase + " and returned to the game's original physics.")); } internal static void AbortJumpHandling(ENT_Player player) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } try { ForceJumpField?.SetValue(player, false); } catch { } if (!Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { return; } value.SuppressJumpRelease = false; value.AllowJumpRelease = false; value.PendingSolidHandholdJump = false; value.PendingSolidHandholdJumpVelocity = Vector3.zero; foreach (int ropeId in value.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value2)) { value2.DampenOnRelease = false; } } } internal static Vector3 GetReleaseVelocity(ENT_Player player) { //IL_0041: 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_0031: 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_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value)) { if (!IsFinite(value.Velocity)) { return Vector3.zero; } return Vector3.ClampMagnitude(value.Velocity, 20f); } return Vector3.zero; } private static RopeState CreateRopeState(ENV_Rope rope, ENT_Player player) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) object? obj = TargetRigidbodyField?.GetValue(rope); Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null); Vector3 position = rope.nodes[rope.nodes.Count - 1].position; RopeState ropeState = new RopeState { Rope = rope, Player = player, IsTaut = true, Endpoint = val, EndpointWasKinematic = ((Object)(object)val != (Object)null && val.isKinematic), EndpointInterpolation = (RigidbodyInterpolation)(((Object)(object)val != (Object)null) ? ((int)val.interpolation) : 0), LastEndpointPosition = position, HasEndpointPosition = true, EndpointReleaseVelocity = Vector3.ClampMagnitude(rope.nodes[rope.nodes.Count - 1].velocity, 8f) }; if ((Object)(object)val != (Object)null) { try { if (!val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } val.isKinematic = true; val.interpolation = (RigidbodyInterpolation)0; } catch { try { val.isKinematic = ropeState.EndpointWasKinematic; val.interpolation = ropeState.EndpointInterpolation; } catch { } throw; } } return ropeState; } private static void ResolveGrip(RopeState state, Vector3 playerPosition) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) int num = 1; foreach (GrabState value in state.Grabs.Values) { num = Mathf.Max(num, value.GripIndex); } state.GripIndex = Mathf.Clamp(num, 1, state.Rope.nodes.Count - 1); state.RopeLength = Mathf.Max(0.25f, state.Rope.nodeDistance * (float)state.GripIndex); float bodyPathLength = GetBodyPathLength(state, playerPosition); state.BodyLength = Mathf.Max(0.25f, bodyPathLength); state.ArmLength = state.BodyLength - state.RopeLength; } private static void InitializeGripDirection(RopeState state, bool preserveCurrentGripPosition) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0083: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!state.HasGripDirection) { Vector3 position = ((Component)state.Rope).transform.position; Vector3 position2 = state.Rope.nodes[state.GripIndex].position; Vector3 val = position2 - position; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } state.GripDirection = ((Vector3)(ref val)).normalized; state.HasGripDirection = true; state.LastGripPosition = (preserveCurrentGripPosition ? position2 : (position + state.GripDirection * state.RopeLength)); state.HasGripPosition = true; } } private static void InitializeEntryVelocity(PlayerState playerState, RopeState ropeState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) Vector3 constraintAnchor = GetConstraintAnchor(ropeState); Vector3 val = playerState.Position - constraintAnchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.ProjectOnPlane(playerState.Velocity, val); float magnitude = ((Vector3)(ref val2)).magnitude; float num = PolarAngle(val); float num2 = Mathf.Max(0.1f, RopeSettings.Gravity); float num3 = Mathf.Max(0f, Mathf.Cos(num) - Mathf.Cos(2.443461f)); float num4 = Mathf.Sqrt(2f * num2 * GetRemainingBodyLength(ropeState) * num3); magnitude = Mathf.Min(magnitude, Mathf.Min(24f, num4)); if (magnitude > 0.001f) { playerState.Velocity = ((Vector3)(ref val2)).normalized * magnitude; } else { playerState.Velocity = Vector3.zero; } } private static void InitializeClimbMomentum(RopeState state, Vector3 entryVelocity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 val = state.GripDirection; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.ProjectOnPlane(entryVelocity, val) * 0.65f; if (GetRopeAngle(state) <= (float)Math.PI / 4f) { val2 = Vector3.ClampMagnitude(val2 * 0.25f, 1.5f); } state.ClimbVelocity = Vector3.ClampMagnitude(val2, 24f); } private static void AdvanceClimbMomentum(RopeState state, float dt) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cd: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (state.HasGripDirection) { Vector3 constraintAnchor = GetConstraintAnchor(state); float remainingRopeLength = GetRemainingRopeLength(state); Vector3 normalized = ((Vector3)(ref state.GripDirection)).normalized; Vector3 val = constraintAnchor + normalized * remainingRopeLength; Vector3 val2 = Vector3.ProjectOnPlane(state.ClimbVelocity, normalized); float num = Mathf.Max(0.1f, RopeSettings.Gravity); val2 += Vector3.ProjectOnPlane(Vector3.down * num, normalized) * dt; val2 = Vector3.ClampMagnitude(val2, 24f); Vector3 val3 = ProjectToSphere(val + val2 * dt, constraintAnchor, remainingRopeLength); Vector3 val4 = val3 - constraintAnchor; Vector3 normalized2 = ((Vector3)(ref val4)).normalized; Vector3 val5 = Vector3.ProjectOnPlane((val3 - val) / dt, normalized2); float num2 = Mathf.Max(0f, RopeSettings.Damping); state.GripDirection = normalized2; state.ClimbVelocity = val5 * Mathf.Max(0f, 1f - num2 * dt); } } private static void ApplyPump(PlayerState state, List ropes) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) float y = InputManager.GetVector("Move").vector.y; float num = Mathf.Clamp01(Mathf.Abs(y)); int num2 = ((num >= 0.2f) ? ((y > 0f) ? 1 : (-1)) : 0); float num3 = Mathf.Max(Time.fixedDeltaTime, 0.001f); if (num2 == 0) { state.PumpPower = Mathf.MoveTowards(state.PumpPower, 0f, 4f * num3); state.PumpDirection = 0; return; } if (state.PumpDirection != num2) { state.PumpDirection = num2; state.PumpPower = Mathf.Min(state.PumpPower, 0.5f); } state.PumpPower = Mathf.MoveTowards(state.PumpPower, 1f, 2.5f * num3); if (ropes.Count == 0) { return; } RopeState state2 = ropes[0]; Vector3 constraintAnchor = GetConstraintAnchor(state2); Vector3 val = state.Position - constraintAnchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref val)).Normalize(); float num4 = PolarAngle(val); if (num4 >= (float)Math.PI / 2f) { return; } Vector3 val2 = state.GrabMoveAxis; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = (((Object)(object)state.Player.cam != (Object)null) ? (((Component)state.Player.cam).transform.forward * (float)num2) : (((Component)state.Player).transform.forward * (float)num2)); } Vector3 val3 = Vector3.ProjectOnPlane(((Vector3)(ref val2)).normalized, val); if (!(((Vector3)(ref val3)).sqrMagnitude < 0.001f)) { ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.ProjectOnPlane(state.Velocity, val); if (!(((Vector3)(ref val4)).magnitude >= 0.15f) || !(Vector3.Dot(((Vector3)(ref val4)).normalized, val3) < 0f)) { float num5 = Mathf.Max(0.1f, RopeSettings.Gravity); float num6 = num5 * GetRemainingBodyLength(state2) * (1f - Mathf.Cos(num4)); float num7 = Mathf.Pow(Mathf.Cos(num4), 2f); float num8 = Mathf.Max(0f, RopeSettings.PumpPower) * state.PumpPower * num * num7; Vector3 val5 = val4 + val3 * num8 * num3; float magnitude = ((Vector3)(ref val5)).magnitude; float num9 = 0.5f * magnitude * magnitude + num6; float num10 = num5 * GetRemainingBodyLength(state2); float num11 = Mathf.Min(num9, num10); float num12 = Mathf.Sqrt(Mathf.Max(0f, 2f * (num11 - num6))); state.Velocity = ((((Vector3)(ref val5)).sqrMagnitude > 0.0001f) ? (((Vector3)(ref val5)).normalized * num12) : (val3 * num12)); } } } private static Vector3 ApplyArcLimit(Vector3 target, PlayerState playerState, RopeState ropeState) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0107: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Vector3 constraintAnchor = GetConstraintAnchor(ropeState); float remainingBodyLength = GetRemainingBodyLength(ropeState); Vector3 val = target - constraintAnchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return target; } ((Vector3)(ref val)).Normalize(); if (PolarAngle(val) <= 2.443461f) { return target; } Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = FallbackDirection(playerState); } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.down * Mathf.Cos(2.443461f) + val2 * Mathf.Sin(2.443461f); Vector3 val4 = -Vector3.down * Mathf.Sin(2.443461f) + val2 * Mathf.Cos(2.443461f); float num = Vector3.Dot(playerState.Velocity, val4); if (num > 0f) { playerState.Velocity = Vector3.ProjectOnPlane(playerState.Velocity, val4) - val4 * (num * 0.2f); } return constraintAnchor + val3 * remainingBodyLength; } private static Vector3 FallbackDirection(PlayerState state) { //IL_0035: 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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)state.Player.cam != (Object)null) ? ((Component)state.Player.cam).transform.forward : ((Component)state.Player).transform.forward); val = Vector3.ProjectOnPlane(val, Vector3.up); if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private static Vector3 ProjectToSphere(Vector3 position, Vector3 anchor, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position - anchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } return anchor + ((Vector3)(ref val)).normalized * radius; } private static Vector3 GetConstraintAnchor(RopeState state) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!state.HasCollisionPivot) { return ((Component)state.Rope).transform.position; } return state.CollisionPivot; } private static float GetConsumedRopeLength(RopeState state) { if (!state.HasCollisionPivot) { return 0f; } return state.CollisionPathLength; } private static float GetRemainingRopeLength(RopeState state) { return Mathf.Max(0.25f, state.RopeLength - GetConsumedRopeLength(state) + state.CollisionRopeRadiusOffset); } private static float GetRemainingBodyLength(RopeState state) { return Mathf.Max(0.25f, state.BodyLength - GetConsumedRopeLength(state) + state.CollisionBodyRadiusOffset); } private static float GetBodyPathLength(RopeState state, Vector3 playerPosition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return GetConsumedRopeLength(state) + Vector3.Distance(GetConstraintAnchor(state), playerPosition); } private static void UpdateCollisionPivots(List ropes) { for (int i = 0; i < ropes.Count; i++) { UpdateCollisionPivot(ropes[i]); } } private static void AdvanceCollisionConstraintTransitions(List ropes, float dt) { float num = 1f - Mathf.Exp(-12f * dt); for (int i = 0; i < ropes.Count; i++) { RopeState ropeState = ropes[i]; ropeState.CollisionRopeRadiusOffset = Mathf.Lerp(ropeState.CollisionRopeRadiusOffset, 0f, num); ropeState.CollisionBodyRadiusOffset = Mathf.Lerp(ropeState.CollisionBodyRadiusOffset, 0f, num); if (Mathf.Abs(ropeState.CollisionRopeRadiusOffset) < 0.001f) { ropeState.CollisionRopeRadiusOffset = 0f; } if (Mathf.Abs(ropeState.CollisionBodyRadiusOffset) < 0.001f) { ropeState.CollisionBodyRadiusOffset = 0f; } } } private static void UpdateCollisionPivot(RopeState state) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0103: 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_0133: 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_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) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0295: 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_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_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_02d1: 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_02d6: 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_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) if (!state.IsTaut || (Object)(object)state.Rope == (Object)null || state.Rope.nodes == null || state.Rope.nodes.Count < 2) { ClearCollisionPivot(state); return; } Vector3 constraintAnchor = GetConstraintAnchor(state); int count = state.CollisionPivots.Count; Vector3 position = ((Component)state.Rope).transform.position; Vector3 val = (state.HasGripPosition ? state.LastGripPosition : state.Rope.nodes[state.GripIndex].position); int num = Mathf.Min(8, Mathf.Max(0, state.GripIndex - 1)); if (state.CollisionPivots.Count > num) { state.CollisionPivots.RemoveRange(num, state.CollisionPivots.Count - num); } if (Vector3.Distance(position, val) <= 0.24f) { ClearCollisionPivot(state); Vector3 val2 = val - position; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { state.GripDirection = ((Vector3)(ref val2)).normalized; state.HasGripDirection = true; } return; } Vector3 val4; while (state.CollisionPivots.Count > 0) { int num2 = state.CollisionPivots.Count - 1; RopeCollisionPivot ropeCollisionPivot = state.CollisionPivots[num2]; Vector3 val3 = ((num2 > 0) ? state.CollisionPivots[num2 - 1].Position : position); if (TryFindPathCollision(state, val3, val, 0, out var closestHit)) { RaycastHit hit = closestHit; val4 = val - val3; Vector3 collisionPivotPosition = GetCollisionPivotPosition(hit, ((Vector3)(ref val4)).normalized); if ((Object)(object)((RaycastHit)(ref closestHit)).collider == (Object)(object)ropeCollisionPivot.Collider || Vector3.Distance(collisionPivotPosition, ropeCollisionPivot.Position) < 0.15f) { UpdateCollisionPivotContact(state, ropeCollisionPivot, val3, val, closestHit); ropeCollisionPivot.FramesWithoutContact = 0; break; } } ropeCollisionPivot.FramesWithoutContact++; if (ropeCollisionPivot.FramesWithoutContact <= 3) { break; } state.CollisionPivots.RemoveAt(num2); } for (int i = state.CollisionPivots.Count; i < num; i++) { RopeCollisionPivot ropeCollisionPivot2 = ((state.CollisionPivots.Count > 0) ? state.CollisionPivots[state.CollisionPivots.Count - 1] : null); Vector3 val5 = ropeCollisionPivot2?.Position ?? position; int ignoredNearColliderId = (((Object)(object)ropeCollisionPivot2?.Collider != (Object)null) ? ((Object)ropeCollisionPivot2.Collider).GetInstanceID() : 0); if (!TryFindPathCollision(state, val5, val, ignoredNearColliderId, out var closestHit2)) { break; } Vector3 val6 = val - val5; Vector3 val7 = GetCollisionPivotPosition(closestHit2, (((Vector3)(ref val6)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val6)).normalized : Vector3.down); val4 = ((RaycastHit)(ref closestHit2)).normal; Vector3 val8; if (!(((Vector3)(ref val4)).sqrMagnitude > 0.0001f)) { val8 = -((Vector3)(ref val6)).normalized; } else { val4 = ((RaycastHit)(ref closestHit2)).normal; val8 = ((Vector3)(ref val4)).normalized; } Vector3 val9 = val8; if (TryFindCollisionEdgePivot(state, ((RaycastHit)(ref closestHit2)).collider, ((RaycastHit)(ref closestHit2)).point, val9, val5, val, out var edgePivot)) { val7 = edgePivot; } if (Vector3.Distance(val5, val7) < 0.15f) { break; } state.CollisionPivots.Add(new RopeCollisionPivot { Position = val7, Normal = val9, Collider = ((RaycastHit)(ref closestHit2)).collider, FramesWithoutContact = 0 }); float maximumCollisionPathLength = GetMaximumCollisionPathLength(state); if (CalculateCollisionPathLength(state, position) >= maximumCollisionPathLength) { state.CollisionPivots.RemoveAt(state.CollisionPivots.Count - 1); break; } } TrimCollisionPivotsToAvailableLength(state, position); RefreshCollisionPivotState(state, position); Vector3 constraintAnchor2 = GetConstraintAnchor(state); float num3 = Vector3.Distance(constraintAnchor, constraintAnchor2); if (count != state.CollisionPivots.Count || num3 >= 0.08f) { RebaseCollisionConstraint(state, constraintAnchor, constraintAnchor2, val); } if (num3 > 0.001f) { Vector3 val10 = val - constraintAnchor2; if (((Vector3)(ref val10)).sqrMagnitude > 0.0001f) { state.GripDirection = ((Vector3)(ref val10)).normalized; state.HasGripDirection = true; } } } private static void UpdateCollisionPivotContact(RopeState state, RopeCollisionPivot pivot, Vector3 previous, Vector3 desiredGrip, RaycastHit hit) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pivot.Collider == (Object)(object)((RaycastHit)(ref hit)).collider)) { Vector3 val = desiredGrip - previous; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.down); Vector3 normal = ((RaycastHit)(ref hit)).normal; Vector3 val3; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val3 = -val2; } else { normal = ((RaycastHit)(ref hit)).normal; val3 = ((Vector3)(ref normal)).normalized; } Vector3 val4 = val3; Vector3 position = GetCollisionPivotPosition(hit, val2); if (TryFindCollisionEdgePivot(state, ((RaycastHit)(ref hit)).collider, ((RaycastHit)(ref hit)).point, val4, previous, desiredGrip, out var edgePivot)) { position = edgePivot; } Vector3 position2 = pivot.Position; Vector3 normal2 = pivot.Normal; Collider collider = pivot.Collider; pivot.Position = position; pivot.Normal = val4; pivot.Collider = ((RaycastHit)(ref hit)).collider; if (CalculateCollisionPathLength(state, ((Component)state.Rope).transform.position) > GetMaximumCollisionPathLength(state)) { pivot.Position = position2; pivot.Normal = normal2; pivot.Collider = collider; } } } private static void RebaseCollisionConstraint(RopeState state, Vector3 previousAnchor, Vector3 currentAnchor, Vector3 desiredGrip) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_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_0052: 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_006d: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ff: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.25f, state.RopeLength - state.CollisionPathLength); state.CollisionRopeRadiusOffset = Vector3.Distance(currentAnchor, desiredGrip) - num; Vector3 val = (((Object)(object)state.Player != (Object)null) ? ((Component)state.Player).transform.position : (currentAnchor + Vector3.down)); float num2 = Mathf.Max(0.25f, state.BodyLength - state.CollisionPathLength); state.CollisionBodyRadiusOffset = Vector3.Distance(currentAnchor, val) - num2; if ((Object)(object)state.Player == (Object)null || !Players.TryGetValue(((Object)state.Player).GetInstanceID(), out PlayerState value) || value.RopeIds.Count != 1 || ((Vector3)(ref value.Velocity)).sqrMagnitude < 0.0001f) { return; } Vector3 val2 = val - previousAnchor; Vector3 val3 = val - currentAnchor; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.0001f) && !(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { float magnitude = ((Vector3)(ref value.Velocity)).magnitude; Vector3 val4 = Vector3.ProjectOnPlane(value.Velocity, ((Vector3)(ref val2)).normalized); if (!(((Vector3)(ref val4)).sqrMagnitude < 0.0001f)) { Vector3 val5 = Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, ((Vector3)(ref val3)).normalized) * ((Vector3)(ref val4)).normalized; value.Velocity = val5 * magnitude; } } } private static bool TryFindCollisionEdgePivot(RopeState state, Collider collider, Vector3 contactPoint, Vector3 contactNormal, Vector3 previous, Vector3 desiredGrip, out Vector3 edgePivot) { //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_001d: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) edgePivot = Vector3.zero; if ((Object)(object)collider == (Object)null) { return false; } float num = 0.145f; Vector3 val = contactPoint + contactNormal * num; Vector3 val2 = desiredGrip - val; if (Vector3.Dot(val2, contactNormal) >= -0.025f) { return false; } Vector3 val3 = Vector3.ProjectOnPlane(val2, contactNormal); Vector3 val4 = Vector3.Cross(contactNormal, (Mathf.Abs(contactNormal.y) < 0.9f) ? Vector3.up : Vector3.right); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.forward; } ((Vector3)(ref val4)).Normalize(); Vector3 val5 = Vector3.Cross(contactNormal, val4); Vector3 normalized = ((Vector3)(ref val5)).normalized; Vector3[] collisionEdgeDirections = CollisionEdgeDirections; int num2 = 0; if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { collisionEdgeDirections[num2++] = ((Vector3)(ref val3)).normalized; } collisionEdgeDirections[num2++] = val4; collisionEdgeDirections[num2++] = -val4; collisionEdgeDirections[num2++] = normalized; collisionEdgeDirections[num2++] = -normalized; float num3 = float.PositiveInfinity; float maximumDistance = Mathf.Max(0.15f, Mathf.Min(state.RopeLength, state.BodyLength)); for (int i = 0; i < num2; i++) { Vector3 val6 = collisionEdgeDirections[i]; bool flag = false; for (int j = 0; j < i; j++) { if (Vector3.Dot(val6, collisionEdgeDirections[j]) > 0.995f) { flag = true; break; } } if (!flag && TryFindColliderFaceEdge(collider, contactPoint, contactNormal, val6, maximumDistance, out var edgeHit, out var _)) { Vector3 val7 = ((RaycastHit)(ref edgeHit)).point + contactNormal * num + val6 * num; float num4 = Vector3.Distance(previous, val7) + Vector3.Distance(val7, desiredGrip); if (!(num4 >= num3)) { num3 = num4; edgePivot = val7; } } } return !float.IsPositiveInfinity(num3); } private static bool TryFindColliderFaceEdge(Collider collider, Vector3 contactPoint, Vector3 normal, Vector3 tangent, float maximumDistance, out RaycastHit edgeHit, out float edgeDistance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_006c: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b2: 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_009e: Unknown result type (might be due to invalid IL or missing references) edgeHit = default(RaycastHit); edgeDistance = 0f; if (!TryProbeColliderFace(collider, contactPoint, normal, tangent, 0f, out var hit)) { return false; } float num = 0f; float num2 = Mathf.Min(Mathf.Max(0.15f, 0.24f), maximumDistance); RaycastHit hit2; while (num2 < maximumDistance && TryProbeColliderFace(collider, contactPoint, normal, tangent, num2, out hit2)) { num = num2; hit = hit2; num2 = Mathf.Min(maximumDistance, num2 * 2f); } if (TryProbeColliderFace(collider, contactPoint, normal, tangent, num2, out var _)) { return false; } for (int i = 0; i < 7; i++) { float num3 = (num + num2) * 0.5f; if (TryProbeColliderFace(collider, contactPoint, normal, tangent, num3, out var hit4)) { num = num3; hit = hit4; } else { num2 = num3; } } edgeHit = hit; edgeDistance = num; return edgeDistance >= 0.075f; } private static bool TryProbeColliderFace(Collider collider, Vector3 contactPoint, Vector3 normal, Vector3 tangent, float distance, out RaycastHit hit) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0034: Unknown result type (might be due to invalid IL or missing references) float num = 0.145f; Ray val = default(Ray); ((Ray)(ref val))..ctor(contactPoint + tangent * distance + normal * (num + 0.08f), -normal); return collider.Raycast(val, ref hit, num + 0.08f + 0.025f); } private static bool TryFindPathCollision(RopeState state, Vector3 start, Vector3 end, int ignoredNearColliderId, out RaycastHit closestHit) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) closestHit = default(RaycastHit); Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.24f) { return false; } Vector3 val2 = val / magnitude; float num = Mathf.Min(0.145f, magnitude * 0.2f); int num2 = Physics.SphereCastNonAlloc(start + val2 * num, 0.12f, val2, RopeCollisionHits, magnitude - num, GetRopeCollisionMask(state.Rope), (QueryTriggerInteraction)1); float num3 = float.PositiveInfinity; for (int i = 0; i < num2; i++) { RaycastHit val3 = RopeCollisionHits[i]; float num4 = ((RaycastHit)(ref val3)).distance + num; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !IsIgnoredRopeCollider(state, ((RaycastHit)(ref val3)).collider) && (ignoredNearColliderId == 0 || ((Object)((RaycastHit)(ref val3)).collider).GetInstanceID() != ignoredNearColliderId || !(num4 < 0.15f)) && !(num4 >= num3)) { closestHit = val3; num3 = num4; } } return !float.IsPositiveInfinity(num3); } private static Vector3 GetCollisionPivotPosition(RaycastHit hit, Vector3 fallbackDirection) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 normal = ((RaycastHit)(ref hit)).normal; Vector3 val; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val = -fallbackDirection; } else { normal = ((RaycastHit)(ref hit)).normal; val = ((Vector3)(ref normal)).normalized; } Vector3 val2 = val; return ((RaycastHit)(ref hit)).point + val2 * 0.145f; } private static float CalculateCollisionPathLength(RopeState state, Vector3 root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = 0f; Vector3 val = root; for (int i = 0; i < state.CollisionPivots.Count; i++) { Vector3 position = state.CollisionPivots[i].Position; num += Vector3.Distance(val, position); val = position; } return num; } private static float GetMaximumCollisionPathLength(RopeState state) { return Mathf.Max(0f, Mathf.Min(state.RopeLength, state.BodyLength) - 0.25f); } private static void TrimCollisionPivotsToAvailableLength(RopeState state, Vector3 root) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) float maximumCollisionPathLength = GetMaximumCollisionPathLength(state); while (state.CollisionPivots.Count > 0 && CalculateCollisionPathLength(state, root) > maximumCollisionPathLength) { state.CollisionPivots.RemoveAt(state.CollisionPivots.Count - 1); } } private static void RefreshCollisionPivotState(RopeState state, Vector3 root) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) state.HasCollisionPivot = state.CollisionPivots.Count > 0; if (!state.HasCollisionPivot) { state.CollisionPathLength = 0f; state.CollisionPivotNodeIndex = 0; return; } RopeCollisionPivot ropeCollisionPivot = state.CollisionPivots[state.CollisionPivots.Count - 1]; state.CollisionPivot = ropeCollisionPivot.Position; state.CollisionNormal = ropeCollisionPivot.Normal; state.CollisionPathLength = CalculateCollisionPathLength(state, root); state.CollisionPivotNodeIndex = Mathf.Clamp(Mathf.RoundToInt((float)state.GripIndex * state.CollisionPathLength / Mathf.Max(state.RopeLength, 0.25f)), 1, Mathf.Max(1, state.GripIndex - 1)); } private static void ClearCollisionPivot(RopeState state) { state.CollisionPivots.Clear(); state.HasCollisionPivot = false; state.CollisionPathLength = 0f; state.CollisionPivotNodeIndex = 0; state.CollisionRopeRadiusOffset = 0f; state.CollisionBodyRadiusOffset = 0f; } private static int GetRopeCollisionMask(ENV_Rope? rope) { return ExcludeLayer(ExcludeLayer(ExcludeLayer(IncludeLayer(IncludeLayer(IncludeLayer(IncludeLayer(IncludeLayer(IncludeLayer(((Object)(object)rope != (Object)null) ? ((LayerMask)(ref rope.layerMask)).value : 0, "Default"), "Ground"), "Environment"), "Terrain"), "Level"), "Map"), "Player"), "UI"), "Ignore Raycast"); } private static int IncludeLayer(int mask, string layerName) { int num = LayerMask.NameToLayer(layerName); if (num < 0) { return mask; } return mask | (1 << num); } private static int ExcludeLayer(int mask, string layerName) { int num = LayerMask.NameToLayer(layerName); if (num < 0) { return mask; } return mask & ~(1 << num); } private static bool IsIgnoredRopeCollider(RopeState state, Collider collider) { Transform transform = ((Component)collider).transform; if ((Object)(object)transform == (Object)null) { return true; } if ((Object)(object)state.Player != (Object)null && ((Object)(object)transform == (Object)(object)((Component)state.Player).transform || transform.IsChildOf(((Component)state.Player).transform))) { return true; } if (IsAnyRopeCollider(collider)) { return true; } if ((Object)(object)transform == (Object)(object)((Component)state.Rope).transform || transform.IsChildOf(((Component)state.Rope).transform)) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)state.Rope) { return true; } CL_Handhold_Rope componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { object? obj = HandholdRopeField?.GetValue(componentInParent); ENV_Rope val = (ENV_Rope)((obj is ENV_Rope) ? obj : null); if (val != null && (Object)(object)val == (Object)(object)state.Rope) { return true; } } if ((Object)(object)state.Endpoint != (Object)null) { if (!((Object)(object)transform == (Object)(object)((Component)state.Endpoint).transform)) { return transform.IsChildOf(((Component)state.Endpoint).transform); } return true; } return false; } private static bool IsAnyRopeCollider(Collider collider) { if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null && KnownRopeEndpointObjects.ContainsKey(((Object)attachedRigidbody).GetInstanceID())) { return true; } Transform val = ((Component)collider).transform; while ((Object)(object)val != (Object)null) { if (KnownRopeEndpointObjects.ContainsKey(((Object)val).GetInstanceID())) { return true; } val = val.parent; } return false; } private static void EnterSlack(RopeState state, ENT_Player player, float retensionDelay, bool requireRadiusEntry = false, bool pinHandsToGrip = false) { //IL_0026: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (state.HasGripPosition ? state.LastGripPosition : state.Rope.nodes[state.GripIndex].position); state.IsTaut = false; state.PinSlackHandsToGrip = pinHandsToGrip; ClearCollisionPivot(state); state.TensionedFromSlack = false; state.SlackGripOffset = val - ((Component)player).transform.position; state.SlackHandReach = Mathf.Max(0.5f, ((Vector3)(ref state.SlackGripOffset)).magnitude + 0.2f); state.LastSlackDistance = Vector3.Distance(((Component)state.Rope).transform.position, val); state.RequireSlackRadiusEntry = requireRadiusEntry; state.SlackHasEnteredRadius = state.LastSlackDistance < state.RopeLength - 0.05f; state.RetensionAllowedAt = Time.time + Mathf.Max(0f, retensionDelay); state.ClimbVelocity = Vector3.zero; state.GroundGripVelocity = Vector3.zero; state.TailNeedsReset = false; } private static void ResetAttachedJumpSlackRope(RopeState state, Vector3 gripVelocity, float dt) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_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_0089: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bb: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) ENV_Rope rope = state.Rope; if (!((Object)(object)rope == (Object)null) && rope.nodes != null && rope.nodes.Count >= 2 && EnsureFiniteRopeGeometry(rope)) { List nodes = rope.nodes; int num = Mathf.Clamp(state.GripIndex, 1, nodes.Count - 1); Vector3 position = ((Component)rope).transform.position; Vector3 slackGripPosition = GetSlackGripPosition(state, ((Component)state.Player).transform.position); for (int i = 0; i <= num; i++) { float num2 = (float)i / (float)num; Vector3 val = Vector3.Lerp(position, slackGripPosition, num2); Vector3 val2 = gripVelocity * num2; ENV_Rope_Node obj = nodes[i]; obj.position = val; obj.velocity = val2; obj.previousPosition = val - val2 * dt; obj.locked = i == 0 || i == num; obj.colliding = false; } float num3 = Mathf.Max(0.01f, rope.nodeDistance); Vector3 val3 = slackGripPosition; for (int j = num + 1; j < nodes.Count; j++) { val3 += Vector3.down * num3; ENV_Rope_Node obj2 = nodes[j]; obj2.position = val3; obj2.velocity = gripVelocity; obj2.previousPosition = val3 - gripVelocity * dt; obj2.locked = false; obj2.colliding = false; } state.LastGripPosition = slackGripPosition; state.HasGripPosition = true; state.ClimbVelocity = Vector3.zero; state.TailNeedsReset = false; state.EndpointReleaseVelocity = gripVelocity; state.LastEndpointPosition = nodes[nodes.Count - 1].position; state.HasEndpointPosition = true; if ((Object)(object)state.Endpoint != (Object)null) { state.Endpoint.position = state.LastEndpointPosition; } } } private static void UpdateGroundHeldGripTargets(PlayerState playerState, List ropes, Vector3 playerPosition, float dt) { //IL_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_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_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_024b: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) ENT_Player player = playerState.Player; if (!IsRopeWalkMode(player, playerState) || (Object)(object)player.camTransform == (Object)null) { return; } float num = player.interactDistance * 0.75f; if (HoldDistanceField?.GetValue(player) is float num2 && num2 > 0.05f) { num = num2; } Vector3 val = player.camTransform.position + player.camTransform.forward * num; for (int i = 0; i < ropes.Count; i++) { RopeState ropeState = ropes[i]; Vector3 position = ((Component)ropeState.Rope).transform.position; Vector3 val2 = val - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (ropeState.IsTaut) { if (magnitude >= ropeState.RopeLength - 0.05f) { continue; } EnterSlack(ropeState, player, 0f, requireRadiusEntry: true, pinHandsToGrip: true); } Vector3 val3 = val; if (magnitude > ropeState.RopeLength && magnitude > 0.0001f) { val3 = position + val2 / magnitude * ropeState.RopeLength; } Vector3 slackGripPosition = GetSlackGripPosition(ropeState, playerPosition); Vector3 val4 = Vector3.SmoothDamp(slackGripPosition, val3, ref ropeState.GroundGripVelocity, 0.12f, 8f, dt); Vector3 val5 = val4 - slackGripPosition; float magnitude2 = ((Vector3)(ref val5)).magnitude; Vector3 normal; if (magnitude2 > 0.0001f && TryRopeSphereCast(ropeState, slackGripPosition, val5 / magnitude2, magnitude2, out var closestHit)) { normal = ((RaycastHit)(ref closestHit)).normal; Vector3 val6; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val6 = Vector3.up; } else { normal = ((RaycastHit)(ref closestHit)).normal; val6 = ((Vector3)(ref normal)).normalized; } Vector3 val7 = val6; val4 = ((RaycastHit)(ref closestHit)).point + val7 * 0.145f; ropeState.GroundGripVelocity = Vector3.ProjectOnPlane(ropeState.GroundGripVelocity, val7); } if (TryFindGroundBelow(ropeState, val4, out var closestHit2)) { normal = ((RaycastHit)(ref closestHit2)).normal; Vector3 val8; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val8 = Vector3.up; } else { normal = ((RaycastHit)(ref closestHit2)).normal; val8 = ((Vector3)(ref normal)).normalized; } Vector3 val9 = val8; float num3 = 0.145f; float num4 = Vector3.Dot(val4 - ((RaycastHit)(ref closestHit2)).point, val9); if (num4 < num3) { val4 += val9 * (num3 - num4); ropeState.GroundGripVelocity = Vector3.ProjectOnPlane(ropeState.GroundGripVelocity, val9); } } ropeState.SlackGripOffset = val4 - playerPosition; } } private static void UpdateSlackRope(RopeState state, Vector3 playerPosition, float dt) { //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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) ENV_Rope rope = state.Rope; if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2 || !EnsureFiniteRopeGeometry(rope)) { return; } List nodes = rope.nodes; int num = Mathf.Clamp(state.GripIndex, 1, nodes.Count - 1); float num2 = Mathf.Max(0.01f, rope.nodeDistance); Vector3 position = ((Component)rope).transform.position; Vector3 slackGripPosition = GetSlackGripPosition(state, playerPosition); Vector3 val = slackGripPosition - position; Vector3 val2 = (state.HasGripPosition ? ((slackGripPosition - state.LastGripPosition) / dt) : Vector3.zero); Vector3 val3 = Vector3.down * Mathf.Max(0.1f, RopeSettings.Gravity); float num3 = Mathf.Exp(-1.5f * dt); nodes[0].position = position; nodes[0].previousPosition = position; nodes[0].velocity = Vector3.zero; nodes[0].locked = true; for (int i = 1; i < num; i++) { ENV_Rope_Node obj = nodes[i]; Vector3 val4 = obj.velocity * num3 + val3 * dt; obj.previousPosition = obj.position; obj.position += val4 * dt; obj.velocity = val4; obj.locked = false; } ENV_Rope_Node obj2 = nodes[num]; obj2.previousPosition = slackGripPosition - val2 * dt; obj2.position = slackGripPosition; obj2.velocity = val2; obj2.locked = true; for (int j = 0; j < 12; j++) { nodes[0].position = position; nodes[num].position = slackGripPosition; for (int k = 1; k <= num; k++) { ENV_Rope_Node val5 = nodes[k - 1]; ENV_Rope_Node val6 = nodes[k]; Vector3 val7 = val6.position - val5.position; float magnitude = ((Vector3)(ref val7)).magnitude; if (magnitude < 0.0001f) { continue; } Vector3 val8 = val7 * ((magnitude - num2) / magnitude); bool flag = k == 1; bool flag2 = k == num; if (!(flag && flag2)) { if (flag) { val6.position -= val8; continue; } if (flag2) { val5.position += val8; continue; } val5.position += val8 * 0.5f; val6.position -= val8 * 0.5f; } } } nodes[0].position = position; nodes[num].position = slackGripPosition; for (int l = 1; l < num; l++) { ENV_Rope_Node val9 = nodes[l]; val9.velocity = Vector3.ClampMagnitude((val9.position - val9.previousPosition) / dt, 24f); val9.previousPosition = val9.position - val9.velocity * dt; } state.LastGripPosition = slackGripPosition; state.HasGripPosition = true; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { state.GripDirection = ((Vector3)(ref val)).normalized; state.HasGripDirection = true; } SimulateTail(state, val2, dt); if (IsGroundDraggedRope(state)) { ResolveGroundDragContacts(state); } else { ResolveRopeCollisions(state, dt); } ENV_Rope_Node val10 = nodes[nodes.Count - 1]; UpdateControlledEndpoint(state, val10.position, dt); CaptureRenderSnapshot(state); RenderRope(rope, state.CurrentRenderPositions); StabilizeGrabAnchors(state); } private static bool IsGroundDraggedRope(RopeState state) { if ((Object)(object)state.Player == (Object)null || !Players.TryGetValue(((Object)state.Player).GetInstanceID(), out PlayerState value)) { return false; } return IsRopeWalkMode(state.Player, value); } private static void ResolveGroundDragContacts(RopeState state) { //IL_0066: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) ENV_Rope rope = state.Rope; if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2) { return; } int num = Mathf.Clamp(state.GripIndex, 1, rope.nodes.Count - 1); float num2 = 0.145f; for (int i = 1; i < rope.nodes.Count; i++) { if (i == num) { continue; } ENV_Rope_Node val = rope.nodes[i]; if (!TryFindGroundBelow(state, val.position, out var closestHit)) { continue; } Vector3 normal = ((RaycastHit)(ref closestHit)).normal; Vector3 val2; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val2 = Vector3.up; } else { normal = ((RaycastHit)(ref closestHit)).normal; val2 = ((Vector3)(ref normal)).normalized; } Vector3 val3 = val2; float num3 = Vector3.Dot(val.position - ((RaycastHit)(ref closestHit)).point, val3); if (!(num3 > num2 + 0.03f)) { if (num3 < num2) { val.position += val3 * (num2 - num3); } val.previousPosition = val.position; val.velocity = Vector3.zero; val.colliding = true; } } } private static bool TryFindGroundBelow(RopeState state, Vector3 position, out RaycastHit closestHit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) closestHit = default(RaycastHit); int num = Physics.RaycastNonAlloc(position + Vector3.up * 1.5f, Vector3.down, RopeCollisionHits, 3f, GetRopeCollisionMask(state.Rope), (QueryTriggerInteraction)1); float num2 = Mathf.Cos(state.Player.slopeLimit * ((float)Math.PI / 180f)); float num3 = float.PositiveInfinity; for (int i = 0; i < num; i++) { RaycastHit val = RopeCollisionHits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).normal.y < num2) && !IsIgnoredRopeCollider(state, ((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num3)) { closestHit = val; num3 = ((RaycastHit)(ref val)).distance; } } return !float.IsPositiveInfinity(num3); } private static void UpdateRope(RopeState state, Vector3 playerPosition, float dt, bool followPlayer) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0062: 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_0143: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_016f: 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_0177: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023b: 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_0295: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) ENV_Rope rope = state.Rope; if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2) { return; } Vector3 position = ((Component)rope).transform.position; Vector3 constraintAnchor = GetConstraintAnchor(state); float remainingRopeLength = GetRemainingRopeLength(state); bool tensionedFromSlack = state.TensionedFromSlack; if (tensionedFromSlack) { Vector3 val = playerPosition - constraintAnchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = state.GripDirection; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } state.GripDirection = ((Vector3)(ref val)).normalized; state.HasGripDirection = true; } else if (!state.HasGripDirection) { Vector3 val2 = rope.nodes[state.GripIndex].position - constraintAnchor; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.down; } state.GripDirection = ((Vector3)(ref val2)).normalized; state.HasGripDirection = true; } else if (followPlayer) { Vector3 val3 = playerPosition - constraintAnchor; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = state.GripDirection; } ((Vector3)(ref val3)).Normalize(); float num = 1f - Mathf.Exp(-35f * dt); Vector3 val4 = Vector3.Slerp(state.GripDirection, val3, num); state.GripDirection = ((Vector3)(ref val4)).normalized; } Vector3 val5 = constraintAnchor + state.GripDirection * remainingRopeLength; Vector3 val6; if (tensionedFromSlack) { val6 = Vector3.ClampMagnitude(Vector3.ProjectOnPlane(state.ClimbVelocity, state.GripDirection), 24f); state.LastGripPosition = val5 - val6 * dt; state.TensionedFromSlack = false; } else { val6 = (state.HasGripPosition ? ((val5 - state.LastGripPosition) / dt) : Vector3.zero); } val6 = Vector3.ClampMagnitude(val6, 24f); if (followPlayer) { state.ClimbVelocity = val6; } state.LastGripPosition = val5; state.HasGripPosition = true; List nodes = rope.nodes; int num2 = Mathf.Clamp(state.GripIndex, 1, nodes.Count - 1); for (int i = 0; i <= num2; i++) { bool collisionPivotNode; float ropeDistance; Vector3 tautRopeNodePosition = GetTautRopeNodePosition(state, position, val5, num2, i, out collisionPivotNode, out ropeDistance); float num3 = Mathf.Clamp01((ropeDistance - state.CollisionPathLength) / Mathf.Max(0.25f, remainingRopeLength)); Vector3 val7 = (collisionPivotNode ? Vector3.zero : (val6 * num3)); ENV_Rope_Node obj = nodes[i]; obj.position = tautRopeNodePosition; obj.previousPosition = tautRopeNodePosition - val7 * dt; obj.velocity = val7; obj.locked = true; } if (state.TailNeedsReset) { ResetTail(state, val6, dt); state.TailNeedsReset = false; } else { SimulateTail(state, val6, dt); } ResolveRopeCollisions(state, dt); ENV_Rope_Node val8 = nodes[nodes.Count - 1]; UpdateControlledEndpoint(state, val8.position, dt); CaptureRenderSnapshot(state); RenderRope(rope, state.CurrentRenderPositions); StabilizeGrabAnchors(state); } private static void SynchronizeRopeWithPlayerMomentum(RopeState state, Vector3 playerPosition, Vector3 playerVelocity, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) Vector3 constraintAnchor = GetConstraintAnchor(state); Vector3 val = playerPosition - constraintAnchor; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = state.GripDirection; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.ClampMagnitude(Vector3.ProjectOnPlane(playerVelocity, val), 24f); Vector3 val3 = constraintAnchor + val * GetRemainingRopeLength(state); List nodes = state.Rope.nodes; int num = Mathf.Clamp(state.GripIndex, 1, nodes.Count - 1); Vector3 val4 = val3 - nodes[num].position; state.GripDirection = val; state.HasGripDirection = true; state.LastGripPosition = val3 - val2 * dt; state.HasGripPosition = true; state.ClimbVelocity = val2; state.TailNeedsReset = false; for (int i = num + 1; i < nodes.Count; i++) { ENV_Rope_Node obj = nodes[i]; obj.position += val4; obj.velocity = val2; obj.previousPosition = obj.position - val2 * dt; obj.colliding = false; } state.EndpointReleaseVelocity = val2; } private static Vector3 GetTautRopeNodePosition(RopeState state, Vector3 root, Vector3 gripPosition, int gripIndex, int nodeIndex, out bool collisionPivotNode, out float ropeDistance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) collisionPivotNode = false; ropeDistance = 0f; if (nodeIndex <= 0) { return root; } float num = 0f; Vector3 val = root; int num2 = 0; int num3 = 1; for (int i = 0; i < state.CollisionPivots.Count; i++) { Vector3 position = state.CollisionPivots[i].Position; num += Vector3.Distance(val, position); int num4 = state.CollisionPivots.Count - i - 1; int num5 = gripIndex - num4 - 1; int num6 = Mathf.Clamp(Mathf.RoundToInt((float)gripIndex * num / Mathf.Max(state.RopeLength, 0.25f)), num3, num5); if (nodeIndex <= num6) { float num7 = Mathf.Clamp01((float)(nodeIndex - num2) / (float)Mathf.Max(1, num6 - num2)); float num8 = Vector3.Distance(val, position); ropeDistance = num - num8 + num8 * num7; collisionPivotNode = nodeIndex == num6; return Vector3.Lerp(val, position, num7); } num3 = num6 + 1; num2 = num6; val = position; } float num9 = Vector3.Distance(val, gripPosition); float num10 = Mathf.Clamp01((float)(nodeIndex - num2) / (float)Mathf.Max(1, gripIndex - num2)); ropeDistance = num + num9 * num10; if (num9 <= 0.0001f) { return gripPosition; } return Vector3.Lerp(val, gripPosition, num10); } private static void CaptureRenderSnapshot(RopeState state) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) List nodes = state.Rope.nodes; int count = nodes.Count; if (state.CurrentRenderPositions.Length != count) { state.PreviousRenderPositions = (Vector3[])(object)new Vector3[count]; state.CurrentRenderPositions = (Vector3[])(object)new Vector3[count]; state.InterpolatedRenderPositions = (Vector3[])(object)new Vector3[count]; for (int i = 0; i < count; i++) { Vector3 position = nodes[i].position; state.PreviousRenderPositions[i] = position; state.CurrentRenderPositions[i] = position; state.InterpolatedRenderPositions[i] = position; } ClampSwingGripPresentation(state, state.CurrentRenderPositions); Array.Copy(state.CurrentRenderPositions, state.PreviousRenderPositions, count); Array.Copy(state.CurrentRenderPositions, state.InterpolatedRenderPositions, count); state.HasRenderSnapshot = true; } else { Array.Copy(state.CurrentRenderPositions, state.PreviousRenderPositions, count); for (int j = 0; j < count; j++) { state.CurrentRenderPositions[j] = nodes[j].position; } ClampSwingGripPresentation(state, state.CurrentRenderPositions); state.HasRenderSnapshot = true; } } private static void ClampSwingGripPresentation(RopeState state, Vector3[] positions) { //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_0055: 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_005a: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) if (positions == null || positions.Length < 2 || !ShouldClampSwingGrip(state)) { return; } int num = Mathf.Clamp(state.GripIndex, 1, positions.Length - 1); ENT_Player player = state.Player; Vector3 val; if (!((Object)(object)player.cCon != (Object)null)) { val = ((Component)player).transform.position; } else { Bounds bounds = ((Collider)player.cCon).bounds; val = ((Bounds)(ref bounds)).center; } Vector3 val2 = val; Vector3 val3 = positions[num]; Vector3 val4 = val3 - val2; float num2 = Mathf.Max(0.75f, player.GetInteractDistance(-1) * 0.9f); if (((Vector3)(ref val4)).sqrMagnitude > num2 * num2 && ((Vector3)(ref val4)).sqrMagnitude > 0.0001f) { val3 = val2 + ((Vector3)(ref val4)).normalized * num2; } Vector3 val5 = val3 - positions[num]; if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f) { return; } int num3 = num; foreach (GrabState value in state.Grabs.Values) { num3 = Mathf.Min(num3, Mathf.Clamp(value.SegmentIndex, 1, num)); } int num4 = Mathf.Max(1, num3 - 2); int num5 = Mathf.Max(1, num3 - num4 + 1); for (int i = num4; i < positions.Length; i++) { float num6 = ((i >= num3) ? 1f : (((float)(i - num4) + 1f) / (float)num5)); ref Vector3 reference = ref positions[i]; reference += val5 * num6; } } private static bool ShouldClampSwingGrip(RopeState state) { ENT_Player player = state.Player; if (state.IsTaut && (Object)(object)player != (Object)null && Players.TryGetValue(((Object)player).GetInstanceID(), out PlayerState value) && value.SwingMode && !IsRopeWalkMode(player, value)) { return !HasSolidHandhold(player); } return false; } private static void InitializeGrabAnchor(ENV_Rope rope, GrabState grab) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(grab.GripIndex - 1, 0, rope.nodes.Count - 2); Vector3 position = rope.nodes[num].position; Vector3 val = rope.nodes[num + 1].position - position; Vector3 val2 = (grab.VisualAnchor = grab.Hand.GetHoldWorldPosition()); grab.HasVisualAnchor = true; grab.SegmentIndex = num; grab.SegmentAmount = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? Mathf.Clamp01(Vector3.Dot(val2 - position, val) / ((Vector3)(ref val)).sqrMagnitude) : 0.5f); } private static void ApplyStandardHandholdTuning(CL_Handhold_Rope handhold, Hand hand, float handDrag) { int instanceID = ((Object)handhold).GetInstanceID(); if (!HandholdTuning.TryGetValue(instanceID, out HandholdTuningState value)) { value = new HandholdTuningState { Handhold = handhold, DragMult = ((CL_Handhold)handhold).dragMult, VelocityMult = ((CL_Handhold)handhold).velocityMult, ClimbMult = ((CL_Handhold)handhold).climbMult, ClimbGrav = ((CL_Handhold)handhold).climbGrav, SpeedMult = ((CL_Handhold)handhold).speedMult, HangVelAdjust = ((CL_Handhold)handhold).hangVelAdjust, Swinging = (HandholdSwingingField?.GetValue(handhold) as bool? == true) }; HandholdTuning.Add(instanceID, value); } value.RefCount++; ((CL_Handhold)handhold).dragMult = 10f; ((CL_Handhold)handhold).velocityMult = 1f; ((CL_Handhold)handhold).climbMult = 1f; ((CL_Handhold)handhold).climbGrav = 0f; ((CL_Handhold)handhold).speedMult = 1f; ((CL_Handhold)handhold).hangVelAdjust = 1f; hand.dragMult = handDrag; HandholdSwingingField?.SetValue(handhold, false); } private static void SetGroundWalkGrabDrag(PlayerState state, bool groundWalk) { foreach (int ropeId in state.RopeIds) { if (!Ropes.TryGetValue(ropeId, out RopeState value)) { continue; } foreach (GrabState value3 in value.Grabs.Values) { if (value3.Hand != null) { value3.Hand.dragMult = (groundWalk ? value3.OriginalHandDrag : 10f); } if (!((Object)(object)value3.Handhold == (Object)null) && HandholdTuning.TryGetValue(((Object)value3.Handhold).GetInstanceID(), out HandholdTuningState value2)) { ((CL_Handhold)value3.Handhold).dragMult = (groundWalk ? value2.DragMult : 10f); } } } } private static void RestoreHandholdTuning(CL_Handhold_Rope handhold) { int instanceID = ((Object)handhold).GetInstanceID(); if (HandholdTuning.TryGetValue(instanceID, out HandholdTuningState value)) { value.RefCount--; if (value.RefCount <= 0) { ForceRestoreHandholdTuning(value); HandholdTuning.Remove(instanceID); } } } private static void ForceRestoreAllHandholdTuning() { List list = new List(HandholdTuning.Values); for (int i = 0; i < list.Count; i++) { try { ForceRestoreHandholdTuning(list[i]); } catch { } } HandholdTuning.Clear(); } private static void ForceRestoreHandholdTuning(HandholdTuningState tuning) { CL_Handhold_Rope handhold = tuning.Handhold; if (!((Object)(object)handhold == (Object)null)) { ((CL_Handhold)handhold).dragMult = tuning.DragMult; ((CL_Handhold)handhold).velocityMult = tuning.VelocityMult; ((CL_Handhold)handhold).climbMult = tuning.ClimbMult; ((CL_Handhold)handhold).climbGrav = tuning.ClimbGrav; ((CL_Handhold)handhold).speedMult = tuning.SpeedMult; ((CL_Handhold)handhold).hangVelAdjust = tuning.HangVelAdjust; HandholdSwingingField?.SetValue(handhold, tuning.Swinging); } } private static void RestoreHandDrag(GrabState grab) { if (grab.Hand != null) { grab.Hand.dragMult = grab.OriginalHandDrag; } } private static void StabilizeGrabAnchors(RopeState state) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) bool flag = ShouldClampSwingGrip(state) && state.CurrentRenderPositions.Length == state.Rope.nodes.Count; foreach (GrabState value in state.Grabs.Values) { if (IsGrabActive(value) && (flag ? TryGetGrabAnchor(state, value, state.CurrentRenderPositions, out var anchor) : TryGetGrabAnchor(state, value, out anchor))) { Vector3 holdWorldPosition = value.Hand.GetHoldWorldPosition(); Vector3 val = anchor - holdWorldPosition; value.Hand.SetWorldHoldPosition(anchor); value.Hand.OffsetLastHoldPosition(val); } } } private static bool IsGrabActive(GrabState grab) { if (grab.Hand == null || (Object)(object)grab.Handhold == (Object)null) { return false; } if (HandholdHandsField?.GetValue(grab.Handhold) is List list) { return list.Contains(grab.Hand); } if ((object)grab.Hand.currentInteract == grab.Handhold || (object)grab.Hand.handhold == grab.Handhold) { return (Object)(object)grab.Hand.holdTarget != (Object)null; } return false; } private static void DropOverstretchedHands(ENT_Player player, PlayerState state) { //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) List list = null; bool flag = !IsPlayerGrounded(player) && !HasSolidHandhold(player); foreach (int ropeId in state.RopeIds) { if (!Ropes.TryGetValue(ropeId, out RopeState value)) { continue; } bool flag2 = !value.IsTaut && value.RequireSlackRadiusEntry && !value.SlackHasEnteredRadius; foreach (GrabState value2 in value.Grabs.Values) { if (!IsGrabActive(value2) || !TryGetGrabAnchor(value, value2, out var anchor) || (value.IsTaut && flag) || (!value.IsTaut && !flag2)) { continue; } float num = (value.IsTaut ? (player.GetInteractDistance(value2.Hand.id) * 2f) : Mathf.Max(0.75f, value.SlackHandReach + 0.25f)); if (Vector3.Distance(((Component)player).transform.position, anchor) > num) { if (list == null) { list = new List(2); } if (!list.Contains(value2.Hand.id)) { list.Add(value2.Hand.id); } } } } if (list == null) { return; } foreach (int item in list) { player.StopInteraction(item, "rope-reach", true); } } private static bool TryGetGrabAnchor(RopeState state, GrabState grab, out Vector3 anchor) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) List nodes = state.Rope.nodes; if (nodes == null || nodes.Count < 2) { anchor = Vector3.zero; return false; } int num = Mathf.Clamp(grab.SegmentIndex, 0, nodes.Count - 2); anchor = Vector3.Lerp(nodes[num].position, nodes[num + 1].position, grab.SegmentAmount); return true; } private static bool TryGetGrabAnchor(RopeState state, GrabState grab, Vector3[] positions, out Vector3 anchor) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (positions == null || positions.Length < 2) { anchor = Vector3.zero; return false; } int num = Mathf.Clamp(grab.SegmentIndex, 0, positions.Length - 2); anchor = Vector3.Lerp(positions[num], positions[num + 1], grab.SegmentAmount); return true; } private static Vector3 GetSlackGripPosition(RopeState state, Vector3 playerPosition) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)state.Rope).transform.position; Vector3 val = playerPosition + state.SlackGripOffset; Vector3 val2 = val - position; float num = Mathf.Max(0.25f, state.RopeLength); if (((Vector3)(ref val2)).sqrMagnitude > num * num && ((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { val = position + ((Vector3)(ref val2)).normalized * num; } return val; } private static void SimulateTail(RopeState state, Vector3 gripVelocity, float dt) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) List nodes = state.Rope.nodes; int gripIndex = state.GripIndex; if (gripIndex >= nodes.Count - 1) { return; } float num = Mathf.Max(0.1f, RopeSettings.Gravity); float num2 = Mathf.Exp(-4f * dt); for (int i = gripIndex + 1; i < nodes.Count; i++) { ENV_Rope_Node obj = nodes[i]; Vector3 val = obj.velocity - gripVelocity; val = Vector3.ClampMagnitude(val * num2, 8f); Vector3 val2 = gripVelocity + val; val2 += Vector3.down * num * dt; obj.previousPosition = obj.position; obj.position += val2 * dt; obj.velocity = val2; obj.locked = false; } float num3 = Mathf.Max(0.01f, state.Rope.nodeDistance); for (int j = 0; j < 10; j++) { for (int k = gripIndex + 1; k < nodes.Count; k++) { ENV_Rope_Node val3 = nodes[k - 1]; ENV_Rope_Node val4 = nodes[k]; Vector3 val5 = val4.position - val3.position; float magnitude = ((Vector3)(ref val5)).magnitude; if (!(magnitude < 0.0001f)) { Vector3 val6 = val5 * ((magnitude - num3) / magnitude); if (k == gripIndex + 1) { val4.position -= val6; continue; } val3.position += val6 * 0.5f; val4.position -= val6 * 0.5f; } } } for (int l = gripIndex + 1; l < nodes.Count; l++) { ENV_Rope_Node val7 = nodes[l]; Vector3 val8 = (val7.position - val7.previousPosition) / dt - gripVelocity; val8 = Vector3.ClampMagnitude(val8, 8f); val7.velocity = gripVelocity + val8; val7.previousPosition = val7.position - val7.velocity * dt; } } private static void ResolveRopeCollisions(RopeState state, float dt) { ENV_Rope rope = state.Rope; if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2) { return; } List nodes = rope.nodes; int num = Mathf.Clamp(state.GripIndex, 1, nodes.Count - 1); for (int i = 0; i < nodes.Count; i++) { nodes[i].colliding = false; } for (int j = ((!state.IsTaut) ? 1 : (num + 1)); j < nodes.Count; j++) { if (j != num) { ResolveNodeSweep(state, nodes[j], dt); } } for (int k = 0; k < 2; k++) { for (int l = (state.IsTaut ? num : 0); l < nodes.Count - 1; l++) { ResolveSegmentCollision(state, nodes, l, num, dt); } SolveRopeCollisionConstraints(rope, pinEndpointTarget: false, (k & 1) != 0); } } private static void ResolveNodeSweep(RopeState state, ENV_Rope_Node node, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = node.position - node.previousPosition; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.0001f) && TryRopeSphereCast(state, node.previousPosition, val / magnitude, magnitude, out var closestHit)) { PinNodeAtCollision(node, closestHit, dt); } } private static void ResolveSegmentCollision(RopeState state, List nodes, int segmentIndex, int gripIndex, float dt) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00aa: Unknown result type (might be due to invalid IL or missing references) ENV_Rope_Node val = nodes[segmentIndex]; ENV_Rope_Node val2 = nodes[segmentIndex + 1]; Vector3 val3 = val2.position - val.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 0.0001f) { return; } Vector3 val4 = val3 / magnitude; float num = ((segmentIndex == 0) ? Mathf.Min(0.145f, magnitude * 0.45f) : 0f); float num2 = magnitude - num; if (num2 <= 0f || !TryRopeSphereCast(state, val.position + val4 * num, val4, num2, out var closestHit)) { return; } bool num3 = segmentIndex == 0 || segmentIndex == gripIndex; bool flag = segmentIndex + 1 == gripIndex; if (!(num3 && flag)) { if (flag) { PinNodeAtCollision(val, closestHit, dt); } else { PinNodeAtCollision(val2, closestHit, dt); } } } private static bool TryRopeSphereCast(RopeState state, Vector3 origin, Vector3 direction, float distance, out RaycastHit closestHit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) closestHit = default(RaycastHit); if (distance <= 0f || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { return false; } int num = Physics.SphereCastNonAlloc(origin, 0.12f, ((Vector3)(ref direction)).normalized, RopeCollisionHits, distance, GetRopeCollisionMask(state.Rope), (QueryTriggerInteraction)1); float num2 = float.PositiveInfinity; for (int i = 0; i < num; i++) { RaycastHit val = RopeCollisionHits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !IsIgnoredRopeCollider(state, ((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num2)) { closestHit = val; num2 = ((RaycastHit)(ref val)).distance; } } return !float.IsPositiveInfinity(num2); } private static void BeginReleasedCollisionManagement(ENV_Rope rope) { if (!((Object)(object)rope == (Object)null) && rope.nodes != null && rope.nodes.Count >= 2) { ReleasedCollisionState releasedCollisionState = new ReleasedCollisionState { NextWakeCheckAt = Time.time }; CaptureReleasedRopeState(rope, releasedCollisionState); ReleasedCollisionRopes[((Object)rope).GetInstanceID()] = releasedCollisionState; } } private static bool HasReleasedRopeWakeMotion(ENV_Rope rope, ReleasedCollisionState state) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (rope.nodes == null || state.Positions.Length != rope.nodes.Count) { return true; } float num = 0.0004f; Vector3 val = ((Component)rope).transform.position - state.AnchorPosition; if (((Vector3)(ref val)).sqrMagnitude > num) { return true; } val = (((Object)(object)rope.target != (Object)null) ? rope.target.position : rope.nodes[rope.nodes.Count - 1].position) - state.EndpointPosition; if (((Vector3)(ref val)).sqrMagnitude > num) { return true; } object? obj = TargetRigidbodyField?.GetValue(rope); Rigidbody val2 = (Rigidbody)((obj is Rigidbody) ? obj : null); if ((Object)(object)val2 != (Object)null) { val = val2.velocity; if (((Vector3)(ref val)).sqrMagnitude > 0.0225f) { return true; } } for (int i = 0; i < rope.nodes.Count; i++) { val = rope.nodes[i].position - state.Positions[i]; if (((Vector3)(ref val)).sqrMagnitude > num) { return true; } } return false; } private static void UpdateReleasedCollisionSleepState(ENV_Rope rope, ReleasedCollisionState state) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (state.Positions.Length != rope.nodes.Count) { state.SettledSteps = 0; CaptureReleasedRopeState(rope, state); return; } float num = 1.6000002E-05f; bool flag = false; for (int i = 0; i < rope.nodes.Count; i++) { Vector3 val = rope.nodes[i].position - state.Positions[i]; if (((Vector3)(ref val)).sqrMagnitude > num) { flag = true; break; } } object? obj = TargetRigidbodyField?.GetValue(rope); Rigidbody endpoint = (Rigidbody)((obj is Rigidbody) ? obj : null); state.SettledSteps = ((!flag) ? (state.SettledSteps + 1) : 0); CaptureReleasedRopeState(rope, state); if (state.SettledSteps >= 30) { PutReleasedRopeToSleep(rope, state, endpoint); } } private static void CaptureReleasedRopeState(ENV_Rope rope, ReleasedCollisionState state) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (state.Positions.Length != rope.nodes.Count) { state.Positions = (Vector3[])(object)new Vector3[rope.nodes.Count]; } for (int i = 0; i < rope.nodes.Count; i++) { state.Positions[i] = rope.nodes[i].position; } state.AnchorPosition = ((Component)rope).transform.position; state.EndpointPosition = (((Object)(object)rope.target != (Object)null) ? rope.target.position : rope.nodes[rope.nodes.Count - 1].position); } private static void PutReleasedRopeToSleep(ENV_Rope rope, ReleasedCollisionState state, Rigidbody? endpoint) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < rope.nodes.Count; i++) { ENV_Rope_Node obj = rope.nodes[i]; obj.previousPosition = obj.position; obj.velocity = Vector3.zero; obj.colliding = false; } if ((Object)(object)endpoint != (Object)null && !endpoint.isKinematic) { endpoint.velocity = Vector3.zero; endpoint.angularVelocity = Vector3.zero; endpoint.Sleep(); } state.Sleeping = true; state.SettledSteps = 30; state.ActiveSteps = 0; state.NextWakeCheckAt = Time.time + 0.2f; CaptureReleasedRopeState(rope, state); RenderRope(rope); } private static void WakeEndpoint(ENV_Rope rope) { Rigidbody val = (Rigidbody)(((Object)(object)rope == (Object)null) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val != (Object)null && !val.isKinematic) { val.WakeUp(); } } internal static void ResolveReleasedRopeCollisions(ENV_Rope rope) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) if (!RopeSettings.Enabled || (Object)(object)rope == (Object)null || IsControlled(rope) || !ReleasedCollisionRopes.TryGetValue(((Object)rope).GetInstanceID(), out ReleasedCollisionState value) || value.Sleeping || rope.nodes == null || rope.nodes.Count < 2) { return; } if (!EnsureFiniteRopeGeometry(rope)) { ReleasedCollisionRopes.Remove(((Object)rope).GetInstanceID()); return; } List nodes = rope.nodes; float num = Mathf.Max(Time.fixedDeltaTime, 0.001f); for (int i = 0; i < nodes.Count; i++) { nodes[i].colliding = false; } for (int j = 1; j < nodes.Count; j++) { ENV_Rope_Node val = nodes[j]; if (!IsReleasedNodePinned(rope, j)) { Vector3 val2 = val.position - val.previousPosition; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > 0.0001f && TryReleasedSphereCast(rope, val.previousPosition, val2 / magnitude, magnitude, out var closestHit)) { PinNodeAtCollision(val, closestHit, num); DampenReleasedContactNode(val, ((RaycastHit)(ref closestHit)).normal, num); } } } StabilizeReleasedGroundContacts(rope, num); for (int k = 0; k < 6; k++) { bool flag = (k & 1) != 0; int num2 = (flag ? (nodes.Count - 2) : 0); int num3 = (flag ? (-1) : (nodes.Count - 1)); int num4 = ((!flag) ? 1 : (-1)); for (int l = num2; l != num3; l += num4) { ResolveReleasedSegmentCollision(rope, nodes, l, num); } SolveRopeCollisionConstraints(rope, pinEndpointTarget: true, flag); StabilizeReleasedGroundContacts(rope, num); } for (int m = 1; m < nodes.Count; m++) { ENV_Rope_Node val3 = nodes[m]; if (!IsReleasedNodePinned(rope, m)) { Vector3 val4 = (val3.velocity = Vector3.ClampMagnitude(val3.velocity, 8f)); val3.previousPosition = val3.position - val4 * num; } } for (int n = 0; n < nodes.Count; n++) { nodes[n].colliding = false; } RenderRope(rope); value.ActiveSteps++; if (value.ActiveSteps >= 600) { ReleasedCollisionRopes.Remove(((Object)rope).GetInstanceID()); } else { UpdateReleasedCollisionSleepState(rope, value); } } internal static void ResolveReleasedRopeCollisionsSafely(ENV_Rope rope) { try { ResolveReleasedRopeCollisions(rope); } catch (Exception ex) { if ((Object)(object)rope != (Object)null) { ReleasedCollisionRopes.Remove(((Object)rope).GetInstanceID()); } StandalonePlugin.Log.LogError((object)("Released-rope collision management was disabled after an error: " + ex)); } } private static void DampenReleasedContactNode(ENV_Rope_Node node, Vector3 contactNormal, float dt) { //IL_0017: 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_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((((Vector3)(ref contactNormal)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref contactNormal)).normalized : Vector3.up); Vector3 val2 = Vector3.ProjectOnPlane(node.velocity, val); val2 *= Mathf.Exp(-14f * dt); if (((Vector3)(ref val2)).sqrMagnitude < 0.09f) { val2 = Vector3.zero; } node.velocity = Vector3.ClampMagnitude(val2, 8f); node.previousPosition = node.position - node.velocity * dt; node.colliding = true; } private static void StabilizeReleasedGroundContacts(ENV_Rope rope, float dt) { //IL_0028: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0067: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) float num = 0.145f; for (int i = 1; i < rope.nodes.Count; i++) { ENV_Rope_Node val = rope.nodes[i]; if (IsReleasedNodePinned(rope, i) || !TryFindReleasedGroundBelow(rope, val.position, out var closestHit)) { continue; } Vector3 normal = ((RaycastHit)(ref closestHit)).normal; Vector3 val2; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val2 = Vector3.up; } else { normal = ((RaycastHit)(ref closestHit)).normal; val2 = ((Vector3)(ref normal)).normalized; } Vector3 val3 = val2; float num2 = Vector3.Dot(val.position - ((RaycastHit)(ref closestHit)).point, val3); if (!(num2 > num + 0.03f)) { if (num2 < num) { val.position += val3 * (num - num2); } DampenReleasedContactNode(val, val3, dt); } } } private static bool TryFindReleasedGroundBelow(ENV_Rope rope, Vector3 position, out RaycastHit closestHit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) closestHit = default(RaycastHit); int num = Physics.RaycastNonAlloc(position + Vector3.up * 1.5f, Vector3.down, RopeCollisionHits, 3f, GetRopeCollisionMask(rope), (QueryTriggerInteraction)1); float num2 = float.PositiveInfinity; for (int i = 0; i < num; i++) { RaycastHit val = RopeCollisionHits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).normal.y < 0.5f) && !IsOwnedByRope(rope, ((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num2)) { closestHit = val; num2 = ((RaycastHit)(ref val)).distance; } } return !float.IsPositiveInfinity(num2); } private static void ResolveReleasedSegmentCollision(ENV_Rope rope, List nodes, int segmentIndex, float dt) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) ENV_Rope_Node val = nodes[segmentIndex]; ENV_Rope_Node val2 = nodes[segmentIndex + 1]; Vector3 val3 = val2.position - val.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 0.0001f) { return; } Vector3 val4 = val3 / magnitude; float num = ((segmentIndex == 0) ? Mathf.Min(0.145f, magnitude * 0.45f) : 0f); float num2 = magnitude - num; if (num2 <= 0f || !TryReleasedSphereCast(rope, val.position + val4 * num, val4, num2, out var closestHit)) { return; } bool flag = IsReleasedNodePinned(rope, segmentIndex); bool flag2 = IsReleasedNodePinned(rope, segmentIndex + 1); if (!(flag && flag2)) { float num3 = Mathf.Clamp01((num + ((RaycastHit)(ref closestHit)).distance) / magnitude); Vector3 normal = ((RaycastHit)(ref closestHit)).normal; Vector3 val5; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val5 = Vector3.up; } else { normal = ((RaycastHit)(ref closestHit)).normal; val5 = ((Vector3)(ref normal)).normalized; } Vector3 val6 = val5; Vector3 val7 = Vector3.Lerp(val.position, val2.position, num3); Vector3 val8 = ((RaycastHit)(ref closestHit)).point + val6 * 0.145f - val7; float maximumCorrection = Mathf.Max(0.12f, rope.nodeDistance); if (flag) { MoveReleasedContactNode(val2, val8 / Mathf.Max(num3, 0.1f), val6, maximumCorrection, dt); return; } if (flag2) { MoveReleasedContactNode(val, val8 / Mathf.Max(1f - num3, 0.1f), val6, maximumCorrection, dt); return; } float num4 = 1f - num3; float num5 = num3; float num6 = num4 * num4 + num5 * num5; MoveReleasedContactNode(val, val8 * (num4 / num6), val6, maximumCorrection, dt); MoveReleasedContactNode(val2, val8 * (num5 / num6), val6, maximumCorrection, dt); } } private static void MoveReleasedContactNode(ENV_Rope_Node node, Vector3 correction, Vector3 normal, float maximumCorrection, float dt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) correction = Vector3.ClampMagnitude(correction, maximumCorrection); node.position += correction; DampenReleasedContactNode(node, normal, dt); } private static void SolveRopeCollisionConstraints(ENV_Rope rope, bool pinEndpointTarget, bool reverse) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) List nodes = rope.nodes; float segmentLength = Mathf.Max(0.01f, rope.nodeDistance); nodes[0].position = ((Component)rope).transform.position; nodes[0].locked = true; Transform val = (pinEndpointTarget ? rope.target : null); if ((Object)(object)val != (Object)null) { nodes[nodes.Count - 1].position = val.position; } if (reverse) { for (int num = nodes.Count - 1; num >= 1; num--) { SolveRopeCollisionConstraintPair(rope, num, pinEndpointTarget, segmentLength); } } else { for (int i = 1; i < nodes.Count; i++) { SolveRopeCollisionConstraintPair(rope, i, pinEndpointTarget, segmentLength); } } if ((Object)(object)val != (Object)null) { nodes[nodes.Count - 1].position = val.position; } } private static void SolveRopeCollisionConstraintPair(ENV_Rope rope, int currentIndex, bool pinEndpointTarget, float segmentLength) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) ENV_Rope_Node val = rope.nodes[currentIndex - 1]; ENV_Rope_Node val2 = rope.nodes[currentIndex]; Vector3 val3 = val2.position - val.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 0.0001f) { return; } Vector3 val4 = val3 * ((magnitude - segmentLength) / magnitude); bool flag = IsCollisionNodePinned(rope, currentIndex - 1, pinEndpointTarget); bool flag2 = IsCollisionNodePinned(rope, currentIndex, pinEndpointTarget); if (!(flag && flag2)) { if (flag) { val2.position -= val4; return; } if (flag2) { val.position += val4; return; } val.position += val4 * 0.5f; val2.position -= val4 * 0.5f; } } private static bool IsReleasedNodePinned(ENV_Rope rope, int nodeIndex) { return IsCollisionNodePinned(rope, nodeIndex, pinEndpointTarget: true); } private static bool IsCollisionNodePinned(ENV_Rope rope, int nodeIndex, bool pinEndpointTarget) { ENV_Rope_Node val = rope.nodes[nodeIndex]; if (val.locked || val.colliding) { return true; } if (pinEndpointTarget && (Object)(object)rope.target != (Object)null) { return nodeIndex == rope.nodes.Count - 1; } return false; } private static bool TryReleasedSphereCast(ENV_Rope rope, Vector3 origin, Vector3 direction, float distance, out RaycastHit closestHit) { //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_0010: 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_003d: 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_0069: Unknown result type (might be due to invalid IL or missing references) closestHit = default(RaycastHit); int num = Physics.SphereCastNonAlloc(origin, 0.12f, ((Vector3)(ref direction)).normalized, RopeCollisionHits, distance, GetRopeCollisionMask(rope), (QueryTriggerInteraction)1); float num2 = float.PositiveInfinity; for (int i = 0; i < num; i++) { RaycastHit val = RopeCollisionHits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !IsOwnedByRope(rope, ((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num2)) { closestHit = val; num2 = ((RaycastHit)(ref val)).distance; } } return !float.IsPositiveInfinity(num2); } private static bool IsOwnedByRope(ENV_Rope rope, Collider collider) { if (IsAnyRopeCollider(collider)) { return true; } Transform transform = ((Component)collider).transform; if ((Object)(object)transform == (Object)(object)((Component)rope).transform || transform.IsChildOf(((Component)rope).transform) || (Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)rope) { return true; } CL_Handhold_Rope componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { object? obj = HandholdRopeField?.GetValue(componentInParent); ENV_Rope val = (ENV_Rope)((obj is ENV_Rope) ? obj : null); if (val != null && (Object)(object)val == (Object)(object)rope) { return true; } } object? obj2 = TargetRigidbodyField?.GetValue(rope); Rigidbody val2 = (Rigidbody)((obj2 is Rigidbody) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { if (!((Object)(object)transform == (Object)(object)((Component)val2).transform)) { return transform.IsChildOf(((Component)val2).transform); } return true; } return false; } private static void PinNodeAtCollision(ENV_Rope_Node node, RaycastHit hit, float dt, float maximumCorrection = float.PositiveInfinity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0016: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Vector3 normal = ((RaycastHit)(ref hit)).normal; Vector3 val; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.0001f)) { val = Vector3.up; } else { normal = ((RaycastHit)(ref hit)).normal; val = ((Vector3)(ref normal)).normalized; } Vector3 val2 = val; Vector3 val3 = ((RaycastHit)(ref hit)).point + val2 * 0.145f - node.position; if (!float.IsPositiveInfinity(maximumCorrection) && ((Vector3)(ref val3)).sqrMagnitude > maximumCorrection * maximumCorrection) { val3 = ((Vector3)(ref val3)).normalized * maximumCorrection; } node.position += val3; Vector3 val4 = Vector3.ProjectOnPlane(node.velocity, val2); node.velocity = Vector3.ClampMagnitude(val4, 8f); node.previousPosition = node.position - node.velocity * dt; node.colliding = true; } private static void ResetTail(RopeState state, Vector3 gripVelocity, float dt) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) List nodes = state.Rope.nodes; int gripIndex = state.GripIndex; if (gripIndex < nodes.Count - 1) { float num = Mathf.Max(0.01f, state.Rope.nodeDistance); Vector3 val = nodes[gripIndex].position; for (int i = gripIndex + 1; i < nodes.Count; i++) { val += Vector3.down * num; ENV_Rope_Node obj = nodes[i]; obj.position = val; obj.previousPosition = val - gripVelocity * dt; obj.velocity = gripVelocity; obj.locked = false; } } } private static void DampenClimbRelease(RopeState state) { //IL_002b: 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_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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(Time.fixedDeltaTime, 0.001f); foreach (ENV_Rope_Node node in state.Rope.nodes) { Vector3 val = (node.velocity = Vector3.ClampMagnitude(node.velocity * 0.25f, 1.5f)); node.previousPosition = node.position - val * num; } } private static void RenderRope(ENV_Rope rope, Vector3[]? positions = null) { //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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0080: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) List nodes = rope.nodes; bool flag = positions != null && positions.Length == nodes.Count; Vector3 up = ((Component)rope).transform.up; for (int i = 0; i < nodes.Count - 1; i++) { Transform mesh = nodes[i].mesh; if (!((Object)(object)mesh == (Object)null)) { Vector3 val = (flag ? (positions[i + 1] - positions[i]) : (nodes[i + 1].position - nodes[i].position)); float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.0001f) && !float.IsNaN(magnitude) && !float.IsInfinity(magnitude)) { mesh.position = (flag ? positions[i] : nodes[i].position); mesh.rotation = Quaternion.LookRotation(val, up); mesh.localScale = new Vector3(1f, 1f, magnitude); } } } } private static void UpdateControlledEndpoint(RopeState state, Vector3 position, float dt) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)state.Endpoint == (Object)null)) { if (state.HasEndpointPosition) { Vector3 val = (position - state.LastEndpointPosition) / Mathf.Max(dt, 0.001f); val = Vector3.ClampMagnitude(val, 8f); float num = 1f - Mathf.Exp(-25f * Mathf.Max(dt, 0.001f)); state.EndpointReleaseVelocity = Vector3.Lerp(state.EndpointReleaseVelocity, val, num); } state.LastEndpointPosition = position; state.HasEndpointPosition = true; state.Endpoint.position = position; } } private static void RestoreEndpoint(RopeState state, bool settleGroundDrop = false) { //IL_0001: 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_001f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity = (IsFinite(state.EndpointReleaseVelocity) ? Vector3.ClampMagnitude(state.EndpointReleaseVelocity, 8f) : Vector3.zero); bool flag = EnsureFiniteRopeGeometry(state.Rope); if (flag && settleGroundDrop) { ResolveGroundDragContacts(state); PrepareGroundDropForRelease(state); } else if (flag) { NormalizeRopeSegments(state); if (IsGroundDraggedRope(state)) { ResolveGroundDragContacts(state); } } ClearCollisionPivot(state); if (flag) { RenderRope(state.Rope); } if ((Object)(object)state.Endpoint == (Object)null) { return; } if (flag) { ENV_Rope_Node val = state.Rope.nodes[state.Rope.nodes.Count - 1]; state.Endpoint.position = val.position; } state.Endpoint.interpolation = state.EndpointInterpolation; state.Endpoint.isKinematic = state.EndpointWasKinematic; if (!state.EndpointWasKinematic) { state.Endpoint.velocity = velocity; if (settleGroundDrop) { state.Endpoint.angularVelocity = Vector3.zero; } } } private static void PrepareGroundDropForRelease(RopeState state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) state.GroundGripVelocity = Vector3.zero; foreach (ENV_Rope_Node node in state.Rope.nodes) { node.previousPosition = node.position; node.velocity = Vector3.zero; node.locked = false; node.colliding = false; } } private static void NormalizeRopeSegments(RopeState state) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) ENV_Rope rope = state.Rope; if ((Object)(object)rope == (Object)null || rope.nodes == null || rope.nodes.Count < 2) { return; } float num = Mathf.Max(Time.fixedDeltaTime, 0.001f); float num2 = Mathf.Max(0.01f, rope.nodeDistance); List nodes = rope.nodes; nodes[0].position = ((Component)rope).transform.position; nodes[0].previousPosition = nodes[0].position; nodes[0].velocity = Vector3.zero; nodes[0].locked = true; for (int i = 1; i < nodes.Count; i++) { ENV_Rope_Node val = nodes[i - 1]; ENV_Rope_Node obj = nodes[i]; Vector3 val2 = obj.position - val.position; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.down; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.ClampMagnitude(obj.velocity, 8f); obj.position = val.position + val2 * num2; obj.previousPosition = obj.position - val3 * num; obj.velocity = val3; obj.locked = false; obj.colliding = false; } } private static void StabilizeGroundGrab(ENV_Rope rope) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rope == (Object)null) && rope.nodes != null) { for (int i = 0; i < rope.nodes.Count; i++) { ENV_Rope_Node obj = rope.nodes[i]; obj.previousPosition = obj.position; obj.velocity = Vector3.zero; obj.colliding = false; } } } private static void RemoveInvalidRopes(PlayerState state) { List list = null; foreach (int ropeId in state.RopeIds) { if (!Ropes.TryGetValue(ropeId, out RopeState value) || (Object)(object)value.Rope == (Object)null) { if (value != null) { RestoreManagedRopeState(value, restoreEndpoint: false, manageReleasedCollision: false); Ropes.Remove(ropeId); } if (list == null) { list = new List(); } list.Add(ropeId); continue; } List list2 = null; foreach (KeyValuePair grab in value.Grabs) { if (!IsGrabActive(grab.Value)) { if (list2 == null) { list2 = new List(); } list2.Add(grab.Key); } } if (list2 != null) { for (int i = 0; i < list2.Count; i++) { int key = list2[i]; if (value.Grabs.TryGetValue(key, out GrabState value2)) { if ((Object)(object)value2.Handhold != (Object)null) { RestoreHandholdTuning(value2.Handhold); } RestoreHandDrag(value2); value.Grabs.Remove(key); } } } if (value.Grabs.Count == 0) { RestoreManagedRopeState(value, restoreEndpoint: true, manageReleasedCollision: true); Ropes.Remove(ropeId); if (list == null) { list = new List(); } list.Add(ropeId); } } if (list == null) { return; } foreach (int item in list) { state.RopeIds.Remove(item); } } private static List GetPlayerRopes(PlayerState state) { List list = new List(); foreach (int ropeId in state.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value)) { list.Add(value); } } return list; } private static List FillPlayerRopeBuffer(PlayerState state) { List ropeBuffer = state.RopeBuffer; ropeBuffer.Clear(); foreach (int ropeId in state.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value)) { ropeBuffer.Add(value); } } return ropeBuffer; } private static int FindGripIndex(ENV_Rope rope, ENV_Rope_Node node) { int num = rope.nodes.IndexOf(node); if (num < 0) { num = 0; } return Mathf.Clamp(num + 1, 1, rope.nodes.Count - 1); } private static int GrabKey(CL_Handhold_Rope handhold, Hand hand) { return (((Object)handhold).GetInstanceID() * 397) ^ hand.id; } private static float PolarAngle(Vector3 radial) { //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) return Mathf.Acos(Mathf.Clamp(Vector3.Dot(((Vector3)(ref radial)).normalized, Vector3.down), -1f, 1f)); } private static float GetRopeAngle(RopeState state) { //IL_003b: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Vector3 radial = (state.HasGripDirection ? state.GripDirection : (state.Rope.nodes[state.GripIndex].position - ((Component)state.Rope).transform.position)); if (((Vector3)(ref radial)).sqrMagnitude < 0.0001f) { radial = Vector3.down; } return PolarAngle(radial); } private static bool IsPlayerGrounded(ENT_Player player) { //IL_0041: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (player.IsGrounded(false) || ((Object)(object)player.cCon != (Object)null && player.cCon.isGrounded)) { return true; } CharacterController cCon = player.cCon; if ((Object)(object)cCon == (Object)null || !((Collider)cCon).enabled) { return false; } Bounds bounds = ((Collider)cCon).bounds; int num = Physics.RaycastNonAlloc(((Bounds)(ref bounds)).center, Vector3.down, RopeCollisionHits, ((Bounds)(ref bounds)).extents.y + 0.2f, GetRopeCollisionMask(null), (QueryTriggerInteraction)1); float num2 = Mathf.Cos(player.slopeLimit * ((float)Math.PI / 180f)); for (int i = 0; i < num; i++) { RaycastHit val = RopeCollisionHits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).normal.y < num2)) { Transform transform = ((Component)((RaycastHit)(ref val)).collider).transform; if (!((Object)(object)transform == (Object)(object)((Component)player).transform) && !transform.IsChildOf(((Component)player).transform) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null)) { return true; } } } return false; } private static bool IsRopeWalkMode(ENT_Player player, PlayerState state) { if (state.GroundWalkMode && IsPlayerGrounded(player)) { return !HasSolidHandhold(player); } return false; } private static void EnterGroundWalkMode(ENT_Player player, PlayerState state, bool forceReset = false) { if (state.GroundWalkMode && !forceReset) { return; } state.GroundWalkMode = true; SetGroundWalkGrabDrag(state, groundWalk: true); state.SwingMode = false; state.SwingChargeStartedAt = float.NegativeInfinity; state.WalkModeStartedAt = float.NegativeInfinity; state.PumpDirection = 0; state.PumpPower = 0f; foreach (int ropeId in state.RopeIds) { if (Ropes.TryGetValue(ropeId, out RopeState value) && value.IsTaut) { EnterSlack(value, player, 0.12f, requireRadiusEntry: false, pinHandsToGrip: true); } } } private static void UpdateSwingMode(ENT_Player player, PlayerState state) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Vector2 vector = InputManager.GetVector("Move").vector; if (!(((Vector2)(ref vector)).sqrMagnitude >= 0.0225f)) { state.WalkModeStartedAt = float.NegativeInfinity; return; } if (!player.IsSprinting()) { if (state.SwingMode) { if (float.IsNegativeInfinity(state.WalkModeStartedAt)) { state.WalkModeStartedAt = Time.time; return; } if (Time.time - state.WalkModeStartedAt < 0.18f) { return; } } state.SwingMode = false; state.SwingChargeStartedAt = float.NegativeInfinity; state.WalkModeStartedAt = float.NegativeInfinity; return; } state.WalkModeStartedAt = float.NegativeInfinity; if (!state.SwingMode) { if (HasSwingMomentum(player, state)) { state.SwingMode = true; state.SwingChargeStartedAt = float.NegativeInfinity; } else if (float.IsNegativeInfinity(state.SwingChargeStartedAt)) { state.SwingChargeStartedAt = Time.time; } else if (Time.time - state.SwingChargeStartedAt >= 0.35f) { state.SwingMode = true; state.SwingChargeStartedAt = float.NegativeInfinity; } } } private static bool HasSwingMomentum(ENT_Player player, PlayerState state) { //IL_0033: 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_0043: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) foreach (int ropeId in state.RopeIds) { if (!Ropes.TryGetValue(ropeId, out RopeState value) || !value.IsTaut) { continue; } Vector3 val = ((Component)player).transform.position - GetConstraintAnchor(value); if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { Vector3 val2 = Vector3.ProjectOnPlane(state.Velocity, ((Vector3)(ref val)).normalized); if (((Vector3)(ref val2)).magnitude >= 1.25f) { return true; } } } return false; } internal static void SetPlayerVelocity(ENT_Player player, Vector3 velocity) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) PlayerVelocityField?.SetValue(player, velocity); } internal static void SetReleaseVelocity(ENT_Player player, Vector3 worldVelocity) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) if (!((Object)(object)player == (Object)null) && IsFinite(worldVelocity)) { PlayerVelocityField?.SetValue(player, Vector3.ClampMagnitude(worldVelocity, 20f) / 175f); } } } internal static class RopeHandholdBase { private static readonly FieldInfo? Holding = AccessTools.Field(typeof(CL_Handhold), "holding"); private static readonly FieldInfo? InUse = AccessTools.Field(typeof(CL_Handhold), "inUse"); private static readonly FieldInfo? Player = AccessTools.Field(typeof(CL_Handhold), "player"); private static readonly FieldInfo? Hands = AccessTools.Field(typeof(CL_Handhold), "hands"); internal static void Grab(CL_Handhold handhold, InteractionInfo info) { UnityEvent activeEvent = handhold.activeEvent; if (activeEvent != null) { activeEvent.Invoke(); } Holding?.SetValue(handhold, true); Player?.SetValue(handhold, info.player); InUse?.SetValue(handhold, true); if (Hands?.GetValue(handhold) is List list && !list.Contains(info.hand)) { list.Add(info.hand); } if (handhold.modules == null) { return; } foreach (HandholdModule module in handhold.modules) { if (module != null && module.enabled) { module.OnGrab(info.player, info.hand, info); } } } internal static void Release(CL_Handhold handhold, ENT_Player player, Hand hand) { int num = 0; if (Hands?.GetValue(handhold) is List list) { list.Remove(hand); num = list.Count; } if (num == 0) { InUse?.SetValue(handhold, false); Player?.SetValue(handhold, null); Holding?.SetValue(handhold, false); UnityEvent stopEvent = handhold.stopEvent; if (stopEvent != null) { stopEvent.Invoke(); } } if (handhold.modules == null) { return; } foreach (HandholdModule module in handhold.modules) { if (module != null && module.enabled) { module.OnRelease(player, hand); } } } } [HarmonyPatch] internal static class Patch_FreshRope_CanInteract { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(CL_Handhold), "CanInteract", new Type[1] { typeof(Interaction) }, (Type[])null); } private static void Postfix(CL_Handhold __instance, Interaction info, ref bool __result) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (__result && RopeSettings.Enabled && __instance is CL_Handhold_Rope && !((Object)(object)info?.player == (Object)null)) { __result = RopeRebuild.CanGrabRope(info.player, ((Component)__instance).transform.position); } } } [HarmonyPatch] internal static class Patch_FreshRope_Interact { private static readonly FieldInfo? RopeField = AccessTools.Field(typeof(CL_Handhold_Rope), "rope"); private static readonly FieldInfo? NodeField = AccessTools.Field(typeof(CL_Handhold_Rope), "node"); private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(CL_Handhold_Rope), "Interact", new Type[1] { typeof(InteractionInfo) }, (Type[])null); } private static bool Prefix(CL_Handhold_Rope __instance, InteractionInfo info) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!RopeSettings.Enabled) { return true; } object? obj = RopeField?.GetValue(__instance); ENV_Rope val = (ENV_Rope)((obj is ENV_Rope) ? obj : null); object? obj2 = NodeField?.GetValue(__instance); ENV_Rope_Node val2 = (ENV_Rope_Node)((obj2 is ENV_Rope_Node) ? obj2 : null); object obj3 = info.player; if (obj3 == null) { Hand hand = info.hand; obj3 = ((hand != null) ? hand.GetPlayer() : null); } ENT_Player val3 = (ENT_Player)obj3; if ((Object)(object)val == (Object)null || val2 == null || (Object)(object)val3 == (Object)null || info.hand == null) { return true; } if (!RopeRebuild.CanControl(val)) { return true; } Vector3 entryVelocity = RopeRebuild.GetEntryVelocity(val3); try { RopeHandholdBase.Grab((CL_Handhold)(object)__instance, info); RopeRebuild.Grab(__instance, val, val2, val3, info.hand, entryVelocity); return false; } catch (Exception ex) { try { RopeHandholdBase.Release((CL_Handhold)(object)__instance, val3, info.hand); } catch { } RopeRebuild.DisableRopeAfterRuntimeFailure(val, val3, "rope grab"); StandalonePlugin.Log.LogError((object)("Custom rope grab failed; native handling will be used for this rope: " + ex)); return true; } } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerJump { private readonly struct SuppressedHandState { internal Hand Hand { get; } internal InteractType InteractState { get; } internal SuppressedHandState(Hand hand, InteractType interactState) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Hand = hand; InteractState = interactState; } } private readonly struct JumpState { internal bool CustomJump { get; } internal bool NativeRelease { get; } internal bool SolidHandholdJump { get; } internal List? SuppressedHands { get; } internal JumpState(bool customJump, bool nativeRelease, bool solidHandholdJump, List? suppressedHands) { CustomJump = customJump; NativeRelease = nativeRelease; SolidHandholdJump = solidHandholdJump; SuppressedHands = suppressedHands; } } private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "Jump", new Type[2] { typeof(bool), typeof(float) }, (Type[])null); } private static bool Prefix(ENT_Player __instance, out JumpState __state) { __state = default(JumpState); try { if (!RopeSettings.Enabled || !RopeRebuild.IsAttached(__instance)) { return true; } if (RopeRebuild.HasSolidHandholdJumpContext(__instance)) { bool flag = RopeRebuild.BeginSolidHandholdJump(__instance); __state = new JumpState(flag, nativeRelease: false, flag, flag ? SuppressRopeHands(__instance) : null); return true; } if (RopeRebuild.ShouldKeepRopeOnJump(__instance)) { if (!RopeRebuild.CanStartRopeJump(__instance)) { return false; } bool flag2 = RopeRebuild.BeginAttachedJump(__instance); __state = new JumpState(flag2, nativeRelease: false, solidHandholdJump: false, flag2 ? SuppressRopeHands(__instance) : null); return flag2; } RopeRebuild.BeginNativeJumpRelease(__instance); __state = new JumpState(customJump: false, nativeRelease: true, solidHandholdJump: false, null); return true; } catch (Exception ex) { RopeRebuild.AbortJumpHandling(__instance); RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "jump handling"); StandalonePlugin.Log.LogError((object)("Rope jump handling failed and reverted to native behavior: " + ex)); __state = default(JumpState); return true; } } private static List? SuppressRopeHands(ENT_Player player) { //IL_002d: 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) if (player.hands == null) { return null; } List list = null; try { for (int i = 0; i < player.hands.Length; i++) { Hand val = player.hands[i]; if (RopeRebuild.IsControlledRopeHand(val)) { if (list == null) { list = new List(); } list.Add(new SuppressedHandState(val, val.interactState)); val.interactState = (InteractType)0; } } return list; } catch { RestoreRopeHands(list); throw; } } private static void RestoreRopeHands(List? suppressedHands) { //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) if (suppressedHands == null) { return; } for (int i = 0; i < suppressedHands.Count; i++) { SuppressedHandState suppressedHandState = suppressedHands[i]; if (suppressedHandState.Hand != null) { suppressedHandState.Hand.interactState = suppressedHandState.InteractState; } } } private static void Postfix(ENT_Player __instance, JumpState __state) { RestoreRopeHands(__state.SuppressedHands); if (__state.SolidHandholdJump) { RopeRebuild.CompleteSolidHandholdJump(__instance); } else if (__state.CustomJump) { RopeRebuild.CompleteAttachedJump(__instance); } if (__state.CustomJump) { RopeRebuild.EndAttachedJump(__instance); } if (__state.NativeRelease) { RopeRebuild.EndNativeJumpRelease(__instance); } } private static Exception? Finalizer(ENT_Player __instance, Exception? __exception, JumpState __state) { RestoreRopeHands(__state.SuppressedHands); if (__exception != null) { RopeRebuild.AbortJumpHandling(__instance); if (__state.CustomJump || __state.NativeRelease || __state.SolidHandholdJump) { RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "jump finalization"); } } return __exception; } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerStopInteraction { private static readonly FieldInfo? RopeField = AccessTools.Field(typeof(CL_Handhold_Rope), "rope"); private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "StopInteraction", new Type[3] { typeof(int), typeof(string), typeof(bool) }, (Type[])null); } private static bool Prefix(ENT_Player __instance, int hand, string type) { if (!RopeSettings.Enabled || type != "jump" || __instance.hands == null || hand < 0 || hand >= __instance.hands.Length) { return true; } Clickable obj = __instance.hands[hand]?.currentInteract; CL_Handhold_Rope val = (CL_Handhold_Rope)(object)((obj is CL_Handhold_Rope) ? obj : null); if (val == null) { return true; } object? obj2 = RopeField?.GetValue(val); ENV_Rope val2 = (ENV_Rope)((obj2 is ENV_Rope) ? obj2 : null); if ((Object)(object)val2 == (Object)null || !RopeRebuild.IsControlled(val2)) { return true; } return !RopeRebuild.ShouldPreserveJumpGrab(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_StopInteract { private static readonly FieldInfo? RopeField = AccessTools.Field(typeof(CL_Handhold_Rope), "rope"); private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(CL_Handhold_Rope), "StopInteract", new Type[3] { typeof(ENT_Player), typeof(Hand), typeof(string) }, (Type[])null); } private static bool Prefix(CL_Handhold_Rope __instance, ENT_Player p, Hand dropHand, string s) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!RopeSettings.Enabled) { return true; } object? obj = RopeField?.GetValue(__instance); ENV_Rope val = (ENV_Rope)((obj is ENV_Rope) ? obj : null); if ((Object)(object)val == (Object)null || !RopeRebuild.IsControlled(val)) { return true; } if (s == "jump" && RopeRebuild.ShouldPreserveJumpGrab(p)) { return false; } Vector3 releaseVelocity = RopeRebuild.GetReleaseVelocity(p); Exception ex = null; try { RopeHandholdBase.Release((CL_Handhold)(object)__instance, p, dropHand); } catch (Exception ex2) { ex = ex2; } try { RopeRebuild.Release(__instance, val, p, dropHand, string.IsNullOrEmpty(s)); } catch (Exception ex3) { if (ex == null) { ex = ex3; } } if (ex != null) { RopeRebuild.DisableRopeAfterRuntimeFailure(val, p, "rope release"); StandalonePlugin.Log.LogError((object)("Rope release cleanup recovered from an error: " + ex)); } else { RopeRebuild.SetReleaseVelocity(p, releaseVelocity); } return false; } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerIsHanging { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "IsHanging", Type.EmptyTypes, (Type[])null); } private static void Postfix(ENT_Player __instance, ref bool __result) { if (__result && RopeRebuild.IsAttached(__instance) && !RopeRebuild.HasSolidHandholdOverride(__instance) && !RopeRebuild.HasTautConstraint(__instance)) { __result = false; } } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerGroundContact { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "OnControllerColliderHit", new Type[1] { typeof(ControllerColliderHit) }, (Type[])null); } private static void Postfix(ENT_Player __instance, ControllerColliderHit hit) { //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) RopeRebuild.NotifyGroundContact(__instance, hit.normal, hit.moveDirection); } } [HarmonyPatch] internal static class Patch_FreshRope_HandholdFixedUpdate { private static readonly FieldInfo? RopeField = AccessTools.Field(typeof(CL_Handhold_Rope), "rope"); private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(CL_Handhold_Rope), "FixedUpdate", (Type[])null, (Type[])null); } private static bool Prefix(CL_Handhold_Rope __instance) { if (!RopeSettings.Enabled) { return true; } object? obj = RopeField?.GetValue(__instance); ENV_Rope val = (ENV_Rope)((obj is ENV_Rope) ? obj : null); if (!((Object)(object)val == (Object)null)) { return !RopeRebuild.IsControlled(val); } return true; } } [HarmonyPatch] internal static class Patch_FreshRope_EnvironmentStart { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENV_Rope), "Start", (Type[])null, (Type[])null); } private static void Postfix(ENV_Rope __instance) { RopeRebuild.RegisterRope(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_EnvironmentFixedUpdate { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENV_Rope), "FixedUpdate", (Type[])null, (Type[])null); } private static bool Prefix(ENV_Rope __instance) { return RopeRebuild.ShouldRunNativeRopeFixedUpdate(__instance); } private static void Postfix(ENV_Rope __instance) { RopeRebuild.ResolveReleasedRopeCollisionsSafely(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_EnvironmentOnDestroy { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENV_Rope), "OnDestroy", (Type[])null, (Type[])null); } private static void Prefix(ENV_Rope __instance) { RopeRebuild.ForgetRope(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_AddVelocity { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENV_Rope), "AddVelocity", new Type[1] { typeof(Vector3) }, (Type[])null); } private static bool Prefix(ENV_Rope __instance) { if (RopeRebuild.IsControlled(__instance)) { return false; } RopeRebuild.WakeReleasedRope(__instance); return true; } } [HarmonyPatch] internal static class Patch_FreshRope_AddNodeVelocity { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENV_Rope), "AddVelocityToClosestNode", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); } private static bool Prefix(ENV_Rope __instance) { if (RopeRebuild.IsControlled(__instance)) { return false; } RopeRebuild.WakeReleasedRope(__instance); return true; } } [HarmonyPatch] internal static class Patch_FreshRope_HandVelocity { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(Hand), "GetVelocity", (Type[])null, (Type[])null); } private static void Postfix(Hand __instance, ref Vector3 __result) { //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) if (RopeRebuild.ShouldSuppressHandVelocity(__instance)) { __result = Vector3.zero; } } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerUpdateVisuals { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "Update", (Type[])null, (Type[])null); } [HarmonyPriority(0)] private static void Postfix(ENT_Player __instance) { RopeRebuild.RenderInterpolatedVisualsSafely(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerFixedUpdate { private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "FixedUpdate", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static void Prefix(ENT_Player __instance) { try { RopeRebuild.MaintainPlayerSafety(__instance); } catch (Exception ex) { RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "player safety maintenance"); StandalonePlugin.Log.LogError((object)("Rope player safety maintenance recovered from an error: " + ex)); } RopeRebuild.RestorePhysicsTransformsSafely(__instance); } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerHang { private struct SuppressedHandsState { internal Hand? FirstHand; internal InteractType FirstState; internal Hand? SecondHand; internal InteractType SecondState; internal void Add(Hand hand) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (FirstHand == null) { FirstHand = hand; FirstState = hand.interactState; return; } if (SecondHand != null) { throw new InvalidOperationException("More than two controlled rope hands were found."); } SecondHand = hand; SecondState = hand.interactState; } } private readonly struct HangState { internal bool Controlled { get; } internal bool Slack { get; } internal SuppressedHandsState SuppressedHands { get; } internal HangState(bool controlled, bool slack, SuppressedHandsState suppressedHands) { Controlled = controlled; Slack = slack; SuppressedHands = suppressedHands; } } private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "Hang", new Type[3] { typeof(Vector3).MakeByRefType(), typeof(float).MakeByRefType(), typeof(float).MakeByRefType() }, (Type[])null); } private static bool Prefix(ENT_Player __instance, ref Vector3 moveAxis, ref Vector3 __result, out HangState __state) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) __state = default(HangState); Vector3 val = moveAxis; try { bool flag = RopeRebuild.IsAttached(__instance); bool flag2 = flag && !RopeRebuild.HasSolidHandholdOverride(__instance) && !RopeRebuild.HasTautConstraint(__instance); bool flag3 = flag && !flag2 && RopeRebuild.ShouldUseNativeClimb(__instance); bool flag4 = flag && !flag2 && RopeRebuild.IsGroundWalkActive(__instance); bool flag5 = flag && !flag2 && !flag3 && !flag4; SuppressedHandsState suppressedHands = ((flag && (RopeRebuild.HasSolidHandholdOverride(__instance) || flag5 || flag4)) ? SuppressRopeHands(__instance) : default(SuppressedHandsState)); __state = new HangState(flag, flag2, suppressedHands); if (flag2) { __result = Vector3.zero; return false; } if (flag5) { moveAxis = Vector3.zero; RopeRebuild.SetPlayerVelocity(__instance, Vector3.zero); } return true; } catch (Exception ex) { RestoreRopeHands(__state.SuppressedHands); moveAxis = val; RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "hand movement"); StandalonePlugin.Log.LogError((object)("Rope hand movement reverted to native behavior: " + ex)); __state = default(HangState); return true; } } private static SuppressedHandsState SuppressRopeHands(ENT_Player player) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (player.hands == null) { return default(SuppressedHandsState); } SuppressedHandsState suppressedHandsState = default(SuppressedHandsState); try { for (int i = 0; i < player.hands.Length; i++) { Hand val = player.hands[i]; if (RopeRebuild.IsControlledRopeHand(val)) { suppressedHandsState.Add(val); val.interactState = (InteractType)0; } } return suppressedHandsState; } catch { RestoreRopeHands(suppressedHandsState); throw; } } private static void RestoreRopeHands(SuppressedHandsState suppressedHands) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (suppressedHands.FirstHand != null) { suppressedHands.FirstHand.interactState = suppressedHands.FirstState; } if (suppressedHands.SecondHand != null) { suppressedHands.SecondHand.interactState = suppressedHands.SecondState; } } private static void Postfix(ENT_Player __instance, ref Vector3 moveAxis, ref float curSpeed, ref float curDrag, ref Vector3 __result, HangState __state) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) RestoreRopeHands(__state.SuppressedHands); if (__state.Controlled && !__state.Slack && RopeRebuild.IsAttached(__instance) && !RopeRebuild.CaptureGrabMotion(__instance, moveAxis, __result) && !RopeRebuild.IsGroundWalkActive(__instance)) { moveAxis = Vector3.zero; curSpeed = 0f; curDrag = 0f; RopeRebuild.SetPlayerVelocity(__instance, Vector3.zero); } } private static Exception? Finalizer(ENT_Player __instance, Exception? __exception, HangState __state) { RestoreRopeHands(__state.SuppressedHands); if (__exception != null && __state.Controlled) { RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "hand movement finalization"); } return __exception; } } [HarmonyPatch] internal static class Patch_FreshRope_PlayerMovement { private readonly struct MovementState { internal bool Attached { get; } internal Vector3 Position { get; } internal MovementState(bool attached, Vector3 position) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Attached = attached; Position = position; } } private static MethodBase? TargetMethod() { return AccessTools.Method(typeof(ENT_Player), "Movement", (Type[])null, (Type[])null); } private static void Prefix(ENT_Player __instance, out MovementState __state) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) __state = default(MovementState); try { RopeRebuild.QueueReleaseJump(__instance); bool flag = RopeRebuild.IsAttached(__instance); if (flag) { RopeRebuild.PrepareGroundedRopeWalk(__instance); } int num; int num2; if (flag) { num = (RopeRebuild.HasTautConstraint(__instance) ? 1 : 0); if (num != 0) { num2 = (RopeRebuild.ShouldUseNativeClimb(__instance) ? 1 : 0); goto IL_0035; } } else { num = 0; } num2 = 0; goto IL_0035; IL_0035: bool flag2 = (byte)num2 != 0; bool flag3 = num != 0 && RopeRebuild.IsGroundWalkActive(__instance); __state = new MovementState(flag, ((Component)__instance).transform.position); if (num != 0 && !flag2 && !flag3) { RopeRebuild.PreparePlayerMovement(__instance); } } catch (Exception ex) { RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "movement preparation"); StandalonePlugin.Log.LogError((object)("Rope movement preparation reverted to native behavior: " + ex)); __state = default(MovementState); } } private static void Postfix(ENT_Player __instance, MovementState __state) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (__state.Attached && RopeRebuild.IsAttached(__instance)) { RopeRebuild.StepPlayerSafely(__instance, __state.Position); } } private static Exception? Finalizer(ENT_Player __instance, Exception? __exception, MovementState __state) { if (__exception != null && __state.Attached) { RopeRebuild.DisableControlAfterRuntimeFailure(__instance, "native movement finalization"); } return __exception; } } internal static class RopeSettings { private static ConfigEntry _enabled; private static ConfigEntry _pumpPower; private static ConfigEntry _gravity; private static ConfigEntry _damping; internal static bool Enabled => _enabled.Value; internal static float PumpPower => _pumpPower.Value; internal static float Gravity => _gravity.Value; internal static float Damping => _damping.Value; internal static void Bind(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown _enabled = config.Bind("General", "Enabled", true, "Enable the standalone rope physics rewrite."); _pumpPower = config.Bind("Swing", "PumpPower", 12f, new ConfigDescription("How strongly forward/back input builds a swing.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); _gravity = config.Bind("Swing", "Gravity", 9.81f, new ConfigDescription("Gravity used by the rope pendulum solver.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 50f), Array.Empty())); _damping = config.Bind("Swing", "Damping", 0.08f, new ConfigDescription("Energy removed from swinging each second.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); } } [BepInPlugin("com.wk.ropephysicsrewrite", "White Knuckle Rope Physics Rewrite", "1.1.44")] public sealed class StandalonePlugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony? _harmony; private bool _leaderboardsWereDisabled; private bool _ropeRewriteWasEnabled; private void Awake() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; RopeSettings.Bind(((BaseUnityPlugin)this).Config); _ropeRewriteWasEnabled = RopeSettings.Enabled; _leaderboardsWereDisabled = WK_Leaderboard_Core.disableLeaderboards; WK_Leaderboard_Core.disableLeaderboards = true; try { _harmony = new Harmony("com.wk.ropephysicsrewrite"); _harmony.PatchAll(typeof(StandalonePlugin).Assembly); SceneManager.activeSceneChanged += OnActiveSceneChanged; RopeRebuild.RegisterLoadedRopes(); } catch { SceneManager.activeSceneChanged -= OnActiveSceneChanged; Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } WK_Leaderboard_Core.disableLeaderboards = _leaderboardsWereDisabled; throw; } Log.LogInfo((object)"White Knuckle Rope Physics Rewrite v1.1.44 loaded."); Log.LogInfo((object)"Leaderboard submissions are disabled while the rope rewrite is active."); } private void Update() { bool enabled = RopeSettings.Enabled; if (enabled != _ropeRewriteWasEnabled) { _ropeRewriteWasEnabled = enabled; ResetRewriteState("configuration change"); Log.LogInfo((object)(enabled ? "Rope rewrite enabled." : "Rope rewrite disabled; active ropes were returned to native physics.")); } } private void OnDestroy() { SceneManager.activeSceneChanged -= OnActiveSceneChanged; try { RopeRebuild.ResetAllState(); } catch (Exception ex) { Log.LogError((object)("Rope cleanup encountered an error during unload: " + ex)); } finally { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } WK_Leaderboard_Core.disableLeaderboards = _leaderboardsWereDisabled; } } private static void OnActiveSceneChanged(Scene previous, Scene next) { ResetRewriteState("scene change"); } private static void ResetRewriteState(string context) { try { RopeRebuild.ResetAllState(); RopeRebuild.RegisterLoadedRopes(); } catch (Exception ex) { Log.LogError((object)("Rope lifecycle cleanup failed during " + context + ": " + ex)); } } } }