Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MantlingCompany v1.1.0
BepInEx/plugins/CoddingCat.MantlingCompany/CoddingCat.MantlingCompany.dll
Decompiled 14 minutes agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Animations.Rigging; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 CoddingCat.MantlingCompany { [HarmonyPatch] internal class Patches { [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] private static void AddPlayerMantle(PlayerControllerB __instance) { ((Component)__instance).gameObject.AddComponent<PlayerMantle>(); } [HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")] [HarmonyPrefix] private static bool MantleInsteadOfJump(PlayerControllerB __instance) { PlayerMantle component = ((Component)__instance).GetComponent<PlayerMantle>(); if (!((Object)(object)component == (Object)null)) { return !component.TryMantle(); } return true; } [HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")] [HarmonyPrefix] private static void StopMantleOnTeleport(PlayerControllerB __instance) { StopMantle(((Component)__instance).transform); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPrefix] private static void StopMantleOnDeath(PlayerControllerB __instance) { StopMantle(((Component)__instance).transform); } [HarmonyPatch(typeof(InteractTrigger), "Interact")] [HarmonyPrefix] private static bool BlockInteractWhileMantling(Transform playerTransform) { PlayerMantle component = ((Component)playerTransform).GetComponent<PlayerMantle>(); if (!((Object)(object)component == (Object)null)) { return !component.isMantling; } return true; } private static void StopMantle(Transform player) { PlayerMantle component = ((Component)player).GetComponent<PlayerMantle>(); if ((Object)(object)component != (Object)null) { component.StopMantle(); } } } public class PlayerMantle : MonoBehaviour { public bool isMantling; private PlayerControllerB player; private int mantleMask; private float timeAtLastMantle; private Collider[] overlapColliders = (Collider[])(object)new Collider[16]; private RaycastHit[] castHits = (RaycastHit[])(object)new RaycastHit[16]; private Coroutine mantleCoroutine; private Transform ledge; private Vector3 startPosition; private Vector3 wallPosition; private Vector3 climbPosition; private Vector3 standPosition; private Vector3 leftGripPosition; private Vector3 rightGripPosition; private float mantleTime; private bool crouchOnLedge; private bool standUpAfterMantle; private Transform cameraOffset; private Vector3 cameraBasePosition; private TwoBoneIKConstraint leftArmIK; private TwoBoneIKConstraint rightArmIK; private void Awake() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) player = ((Component)this).GetComponent<PlayerControllerB>(); mantleMask = StartOfRound.Instance.collidersAndRoomMaskAndDefault | LayerMask.GetMask(new string[2] { "MiscLevelGeometry", "PlaceableShipObjects" }); cameraOffset = new GameObject("MantleCameraOffset").transform; cameraOffset.SetParent(((Component)this).transform, false); Transform armsRig = ((Component)player.thisPlayerModelArms).transform.parent.Find("metarig/spine.003/RigArms"); leftArmIK = CreateArmIK(armsRig, "L"); rightArmIK = CreateArmIK(armsRig, "R"); ((Component)player.playerBodyAnimator).GetComponent<RigBuilder>().Build(); } private TwoBoneIKConstraint CreateArmIK(Transform armsRig, string side) { //IL_000b: 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_00fb: Unknown result type (might be due to invalid IL or missing references) TwoBoneIKConstraint val = new GameObject("MantleArm." + side).AddComponent<TwoBoneIKConstraint>(); ((Component)val).transform.SetParent(armsRig, false); ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).weight = 0f; ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).root = armsRig.parent.Find("shoulder." + side + "/arm." + side + "_upper"); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).mid = ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).root.Find("arm." + side + "_lower"); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).tip = ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).mid.Find("hand." + side); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).target = new GameObject("MantleArm." + side + "_target").transform; ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).hint = new GameObject("MantleArm." + side + "_hint").transform; ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).target.SetParent(((Component)this).transform); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).hint.SetParent(((Component)this).transform); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).targetPositionWeight = 1f; ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)val).data)).hintWeight = 1f; return val; } private void Update() { if (standUpAfterMantle && !isMantling) { player.Crouch(false); standUpAfterMantle = player.isCrouching; } if (Plugin.autoMantleInAir.Value && !player.thisController.isGrounded && player.moveInputVector.y > -0.3f && InputSystem.actions.FindAction("Jump", false).IsPressed()) { TryMantle(); } } public bool TryMantle() { if (!player.isPlayerControlled || player.inSpecialInteractAnimation || player.quickMenuManager.isMenuOpen || player.isTypingChat || player.isCrouching || player.isExhausted || player.jetpackControls || player.isSinking || (player.isMovementHindered > 0 && !player.isUnderwater)) { return false; } if (Time.realtimeSinceStartup - timeAtLastMantle < 0.3f || player.sprintMeter < Plugin.staminaCost.Value || (Plugin.maxCarryWeight.Value > 0f && (player.carryWeight - 1f) * 105f > Plugin.maxCarryWeight.Value) || !FindLedge()) { return false; } if (mantleCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(mantleCoroutine); } mantleCoroutine = ((MonoBehaviour)this).StartCoroutine(mantleAnimation()); return true; } private bool FindLedge() { //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a6: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0111: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) bool flag = !player.thisController.isGrounded && !player.IsPlayerNearGround(); float radius = player.thisController.radius; float num = (flag ? 0.15f : Mathf.Max(0.65f, player.thisController.stepOffset + 0.1f)); float value = Plugin.maxLedgeHeight.Value; Vector3 position = ((Component)this).transform.position; Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; for (float num2 = radius + 0.2f; num2 <= radius + 1.3f; num2 += 0.25f) { Vector3 origin = position + normalized * num2 + Vector3.up * (value + 0.4f); float num3 = value + 0.4f - num; RaycastHit hit; while (num3 > 0f && Cast(origin, Vector3.down, num3, out hit)) { if (((RaycastHit)(ref hit)).point.y - position.y <= value && Vector3.Angle(((RaycastHit)(ref hit)).normal, Vector3.up) < 35f && CheckLedge(hit, position, normalized, num2, flag)) { return true; } origin = ((RaycastHit)(ref hit)).point + Vector3.down * 0.05f; num3 -= ((RaycastHit)(ref hit)).distance + 0.05f; } } return false; } private bool CheckLedge(RaycastHit top, Vector3 feet, Vector3 forward, float distance, bool airborne) { //IL_0002: 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_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) //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_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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_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_004a: 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_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_00dc: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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_0228: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_0295: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: 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_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: 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) //IL_034b: 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_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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) float y = ((RaycastHit)(ref top)).point.y; float radius = player.thisController.radius; if (!Cast(new Vector3(feet.x, y - 0.05f, feet.z), forward, distance + 0.05f, out var hit) && !Cast(new Vector3(feet.x, y - 0.2f, feet.z), forward, distance + 0.05f, out hit)) { return false; } Vector3 val = Vector3.Cross(Vector3.up, forward); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((RaycastHit)(ref hit)).point.x, y, ((RaycastHit)(ref hit)).point.z); Vector3 val3 = val2 + forward * (radius + 0.15f); if (Vector3.Angle(forward, -Vector3.ProjectOnPlane(((RaycastHit)(ref hit)).normal, Vector3.up)) > 70f || !HasFooting(val3, y, out var height) || !HasFooting(val3 + val * 0.3f, y, out var height2) || !HasFooting(val3 - val * 0.3f, y, out var height3)) { return false; } Vector3 val4 = val2 - forward * 0.12f + Vector3.up * 0.2f - ((Component)player.gameplayCamera).transform.position; if (Cast(((Component)player.gameplayCamera).transform.position, ((Vector3)(ref val4)).normalized, ((Vector3)(ref val4)).magnitude, out var _)) { return false; } float bottom = (airborne ? 0.05f : 0.22f); float bodyTravel = GetBodyTravel(feet, forward, Mathf.Max(0f, ((RaycastHit)(ref hit)).distance - radius - 0.06f), bottom); if (((RaycastHit)(ref hit)).distance - bodyTravel - radius > 1.3f) { return false; } Vector3 val5 = feet + forward * bodyTravel; val3.y = Mathf.Max(new float[3] { height, height2, height3 }); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(val5.x, val3.y + 0.07f, val5.z); crouchOnLedge = !BodyFits(val5, val6, val3, 2.5f, bottom); if (crouchOnLedge && !BodyFits(val5, val6, val3, 1.5f, bottom)) { return false; } ledge = ((RaycastHit)(ref top)).transform; startPosition = ledge.InverseTransformPoint(feet); wallPosition = ledge.InverseTransformPoint(val5); climbPosition = ledge.InverseTransformPoint(val6); standPosition = ledge.InverseTransformPoint(val3); leftGripPosition = ledge.InverseTransformPoint(val2 - val * 0.3f - forward * 0.04f + Vector3.up * 0.05f); rightGripPosition = ledge.InverseTransformPoint(val2 + val * 0.3f - forward * 0.04f + Vector3.up * 0.05f); mantleTime = Mathf.Clamp(0.42f + 0.2f * (val6.y - feet.y) + 0.22f * bodyTravel, 0.42f, 1.4f); mantleTime *= (1f + Plugin.weightSlowdown.Value * (player.carryWeight - 1f) * 105f / 100f) * (player.isSprinting ? 0.88f : 1f) / Plugin.mantleSpeed.Value; return true; } private bool HasFooting(Vector3 position, float topY, out float height) { //IL_0004: 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_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_004f: 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) height = topY; if (!Cast(new Vector3(position.x, topY + 0.45f, position.z), Vector3.down, 0.7f, out var hit)) { return false; } height = ((RaycastHit)(ref hit)).point.y; if (((RaycastHit)(ref hit)).distance > 0.01f && Mathf.Abs(((RaycastHit)(ref hit)).point.y - topY) < 0.22f) { return Vector3.Angle(((RaycastHit)(ref hit)).normal, Vector3.up) < 35f; } return false; } private bool Cast(Vector3 origin, Vector3 direction, float distance, out RaycastHit hit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) hit = default(RaycastHit); bool flag = false; int num = Physics.RaycastNonAlloc(origin, direction, castHits, distance, mantleMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if ((!flag || ((RaycastHit)(ref castHits[i])).distance < ((RaycastHit)(ref hit)).distance) && !((Component)((RaycastHit)(ref castHits[i])).collider).transform.IsChildOf(((Component)this).transform)) { hit = castHits[i]; flag = true; } } return flag; } private float GetBodyTravel(Vector3 feet, Vector3 direction, float distance, float bottom) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: Unknown result type (might be due to invalid IL or missing references) float num = player.thisController.radius * 0.92f; int num2 = Physics.CapsuleCastNonAlloc(feet + Vector3.up * (num + bottom), feet + Vector3.up * (2.5f - num), num, direction, castHits, distance, mantleMask, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { if (!((Component)((RaycastHit)(ref castHits[i])).collider).transform.IsChildOf(((Component)this).transform)) { distance = Mathf.Min(distance, ((RaycastHit)(ref castHits[i])).distance - 0.03f); } } return Mathf.Max(0f, distance); } private bool BodyFits(Vector3 wall, Vector3 climb, Vector3 stand, float height, float bottom) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) float num = player.thisController.radius * 0.92f; if (!IsBlocked(wall + Vector3.up * (num + bottom), climb + Vector3.up * (height - num), num)) { return !IsBlocked(stand + Vector3.up * (num + 0.05f), stand + Vector3.up * (height - num), num); } return false; } private bool IsBlocked(Vector3 bottom, Vector3 top, 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) int num = Physics.OverlapCapsuleNonAlloc(bottom, top, radius, overlapColliders, mantleMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if (!((Component)overlapColliders[i]).transform.IsChildOf(((Component)this).transform)) { return true; } } return false; } private IEnumerator mantleAnimation() { isMantling = true; if (player.jumpCoroutine != null) { ((MonoBehaviour)player).StopCoroutine(player.jumpCoroutine); player.jumpCoroutine = null; } player.isJumping = false; player.isFallingFromJump = false; player.isFallingNoJump = false; player.inSpecialInteractAnimation = true; player.sprintMeter = Mathf.Clamp(player.sprintMeter - Plugin.staminaCost.Value, 0f, 1f); player.playerBodyAnimator.SetBool("Jumping", true); player.PlayJumpAudio(); if (StartOfRound.Instance.connectedPlayersAmount != 0) { player.PlayerJumpedServerRpc(); } bool leanRight = Random.Range(0, 2) == 0; AnimationClip cameraClip = (leanRight ? Plugin.mantleCameraRight : Plugin.mantleCameraLeft); cameraBasePosition = ((Component)player.gameplayCamera).transform.localPosition; bool grabbedLedge = false; float timer = 0f; while (timer < mantleTime) { yield return null; timer += Time.deltaTime; if ((Object)(object)ledge == (Object)null || (Object)(object)player.inAnimationWithEnemy != (Object)null) { StopMantle(); yield break; } float num = timer / mantleTime; Vector3 val = Vector3.Lerp(startPosition, wallPosition, Mathf.SmoothStep(0f, 1f, num / 0.35f)); val.y = Mathf.SmoothStep(startPosition.y, climbPosition.y, num / 0.6f); player.thisPlayerBody.position = ledge.TransformPoint(Vector3.Lerp(val, standPosition, Mathf.SmoothStep(0f, 1f, (num - 0.5f) / 0.5f))); player.ResetFallGravity(); player.externalForces = Vector3.zero; if (!grabbedLedge && num > 0.16f) { grabbedLedge = true; player.PlayFootstepSound(); } if (crouchOnLedge && !player.isCrouching && num > 0.4f) { player.Crouch(true); } SetCameraPose(cameraClip, num); MoveArm(leftArmIK, leftGripPosition, -1f, !player.twoHanded && num > (leanRight ? 0.05f : 0f) && num < 0.75f); MoveArm(rightArmIK, rightGripPosition, 1f, !player.twoHanded && !player.isHoldingObject && num > (leanRight ? 0f : 0.05f) && num < 0.75f); } player.thisPlayerBody.position = ledge.TransformPoint(standPosition) + Vector3.up * 0.02f; EndMantle(); if (crouchOnLedge) { standUpAfterMantle = true; player.thisController.height = 1.5f; player.thisController.center = new Vector3(player.thisController.center.x, 0.72f, player.thisController.center.z); } player.PlayFootstepSound(); RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 13f, 0.45f, 0, player.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed, 6); for (float landTimer = 1f; landTimer < cameraClip.length; landTimer += Time.deltaTime) { SetCameraPose(cameraClip, landTimer); yield return null; } ResetCamera(); mantleCoroutine = null; } private void SetCameraPose(AnimationClip clip, float time) { //IL_0023: 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_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_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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) clip.SampleAnimation(((Component)cameraOffset).gameObject, time); ((Component)player.gameplayCamera).transform.localPosition = cameraBasePosition + cameraOffset.localPosition * Plugin.cameraIntensity.Value; ((Component)player.gameplayCamera).transform.localRotation = Quaternion.Euler(player.cameraUp, 0f, 0f) * Quaternion.SlerpUnclamped(Quaternion.identity, cameraOffset.localRotation, Plugin.cameraIntensity.Value); } private void MoveArm(TwoBoneIKConstraint armIK, Vector3 gripPosition, float side, bool gripping) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)armIK).data)).target.position = ledge.TransformPoint(gripPosition); ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)armIK).data)).hint.position = ((TwoBoneIKConstraintData)(ref ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)armIK).data)).root.position + ((Component)this).transform.right * side + Vector3.down * 0.7f - ((Component)this).transform.forward * 0.35f; ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)armIK).weight = Mathf.Lerp(((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)armIK).weight, gripping ? 1f : 0f, 15f * Time.deltaTime); } public void StopMantle() { if (mantleCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(mantleCoroutine); mantleCoroutine = null; if (isMantling) { EndMantle(); } ResetCamera(); } } private void EndMantle() { isMantling = false; timeAtLastMantle = Time.realtimeSinceStartup; if ((Object)(object)player.inAnimationWithEnemy == (Object)null) { player.inSpecialInteractAnimation = false; } player.ResetFallGravity(); player.playerBodyAnimator.SetBool("Jumping", false); ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)leftArmIK).weight = 0f; ((RigConstraint<TwoBoneIKConstraintJob, TwoBoneIKConstraintData, TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>>)(object)rightArmIK).weight = 0f; Physics.SyncTransforms(); } private void ResetCamera() { //IL_0011: 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) ((Component)player.gameplayCamera).transform.localPosition = cameraBasePosition; ((Component)player.gameplayCamera).transform.localRotation = Quaternion.Euler(player.cameraUp, 0f, 0f); } } [BepInPlugin("CoddingCat.MantlingCompany", "Mantling Company", "1.5.0")] public class Plugin : BaseUnityPlugin { public static ConfigEntry<bool> autoMantleInAir; public static ConfigEntry<float> maxLedgeHeight; public static ConfigEntry<float> staminaCost; public static ConfigEntry<float> maxCarryWeight; public static ConfigEntry<float> cameraIntensity; public static ConfigEntry<float> mantleSpeed; public static ConfigEntry<float> weightSlowdown; public static AnimationClip mantleCameraLeft; public static AnimationClip mantleCameraRight; private void Awake() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) autoMantleInAir = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoMantleInAir", true, "Hold jump in the air to grab the next ledge you reach."); maxLedgeHeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxLedgeHeight", 1.3f, "Highest ledge above your feet you can grab."); staminaCost = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StaminaCost", 0.1f, "Sprint meter used per mantle. A jump uses 0.08."); maxCarryWeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxCarryWeight", 100f, "Heaviest load in pounds you can mantle with. 0 means no limit."); cameraIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CameraIntensity", 1f, "Strength of the camera motion while mantling. 0 turns it off."); mantleSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MantleSpeed", 1f, new ConfigDescription("How fast you mantle. 2 is twice as fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>())); weightSlowdown = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WeightSlowdown", 0.33f, new ConfigDescription("How much slower you mantle per 100 lb carried. 0.33 is a third slower at 100 lb, 0 turns it off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "mantlingcompany")); mantleCameraLeft = obj.LoadAsset<AnimationClip>("MantleCameraLeft"); mantleCameraRight = obj.LoadAsset<AnimationClip>("MantleCameraRight"); new Harmony("CoddingCat.MantlingCompany").PatchAll(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }