The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of HardcoreParkour v0.2.1
plugins/com.github.chrispavs.HardcoreParkour.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Unity.Mathematics; using UnityEngine; using Zorro.Core.Serizalization; [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: AssemblyCompany("com.github.chrispavs.HardcoreParkour")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1+96c0475e3d0f5dd684cec638584380ddd0478108")] [assembly: AssemblyProduct("com.github.chrispavs.HardcoreParkour")] [assembly: AssemblyTitle("HardcoreParkour")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace HardcoreParkour { public class ExtraCharacterSyncData { public List<quaternion>? TargetRotations; } [HarmonyPatch] internal class FlipSyncPatch { private static readonly ConditionalWeakTable<CharacterSyncer, ExtraCharacterSyncData> syncData = new ConditionalWeakTable<CharacterSyncer, ExtraCharacterSyncData>(); private static Character? characterToWrite; private static List<quaternion>? receivedRotations; [HarmonyPrefix] [HarmonyPatch(typeof(CharacterSyncer), "GetDataToWrite")] private static void Prefix_GetDataToWrite(CharacterSyncer __instance) { if (((PhotonBinaryStreamSerializer<CharacterSyncData>)(object)__instance).photonView.IsMine) { characterToWrite = ((Component)__instance).GetComponent<Character>(); } } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterSyncData), "Serialize")] private static void Postfix_Serialize(BinarySerializer serializer) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)characterToWrite != (Object)null) { List<Rigidbody> rigidbodies = characterToWrite.refs.ragdoll.rigidbodies; int count = rigidbodies.Count; if (count > 0 && count <= 50) { serializer.WriteInt(count); foreach (Rigidbody item in rigidbodies) { serializer.WriteQuaternion(item.rotation); } } else { if (Plugin.debuggingLogsConfig.Value) { Plugin.Log.LogWarning((object)$"Invalid rigidbody count: {count}, writing 0"); } serializer.WriteInt(0); } characterToWrite = null; } else { serializer.WriteInt(0); } } catch (Exception ex) { if (Plugin.debuggingLogsConfig.Value) { Plugin.Log.LogError((object)("Error in serialization: " + ex.Message)); } serializer.WriteInt(0); } } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterSyncData), "Deserialize")] private static void Postfix_Deserialize(BinaryDeserializer deserializer) { //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) try { int num = deserializer.ReadInt(); if (num > 0 && num <= 50) { List<quaternion> list = new List<quaternion>(num); for (int i = 0; i < num; i++) { list.Add(quaternion.op_Implicit(deserializer.ReadQuaternion())); } receivedRotations = list; } else { if (num != 0 && Plugin.debuggingLogsConfig.Value) { Plugin.Log.LogWarning((object)$"Invalid rotation count received: {num}, treating as 0"); } receivedRotations = null; } } catch (Exception ex) { if (Plugin.debuggingLogsConfig.Value) { Plugin.Log.LogError((object)("Error in deserialization: " + ex.Message)); } receivedRotations = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterSyncer), "OnDataReceived")] private static void Postfix_OnDataReceived(CharacterSyncer __instance) { try { if (receivedRotations != null) { ExtraCharacterSyncData orCreateValue = syncData.GetOrCreateValue(__instance); orCreateValue.TargetRotations = receivedRotations; receivedRotations = null; } } catch (Exception ex) { if (Plugin.debuggingLogsConfig.Value) { Plugin.Log.LogError((object)("Error in OnDataReceived: " + ex.Message)); } receivedRotations = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(CharacterSyncer), "Update")] private static void Postfix_Update(CharacterSyncer __instance) { //IL_0064: 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_0085: Unknown result type (might be due to invalid IL or missing references) try { if (((PhotonBinaryStreamSerializer<CharacterSyncData>)(object)__instance).photonView.IsMine || !syncData.TryGetValue(__instance, out ExtraCharacterSyncData value) || value.TargetRotations == null) { return; } Character component = ((Component)__instance).GetComponent<Character>(); List<Rigidbody> rigidbodies = component.refs.ragdoll.rigidbodies; if (rigidbodies.Count == value.TargetRotations.Count) { for (int i = 0; i < rigidbodies.Count; i++) { rigidbodies[i].rotation = Quaternion.Slerp(rigidbodies[i].rotation, quaternion.op_Implicit(value.TargetRotations[i]), Time.deltaTime * 15f); } } } catch (Exception ex) { Plugin.Log.LogError((object)("Error in Update: " + ex.Message)); } } } [BepInPlugin("com.github.chrispavs.HardcoreParkour", "HardcoreParkour", "0.2.1")] public class Plugin : BaseUnityPlugin { internal static ConfigEntry<KeyCode>? keyboardKeybindConfig; internal static ConfigEntry<KeyCode>? controllerKeybindConfig; internal static ConfigEntry<bool>? debuggingLogsConfig; internal static float3 lastSyncedRotation = float3.zero; private const float launchForceForward = 200f; private const float launchForceUp = 200f; private const float initialTorque = 50f; private const float continuousTorque = 20f; private const float continuousForceUp = 1.75f; private const float flipLandedVerticalDotThreshold = 0.6f; private const float flipDirectionScalingMin = 0.8f; private const float flipHeightScalingMax = 1.5f; private const float jumpMaxHeightTime = 0.3f; private bool groundedSinceLastFlip = true; private float flipStartTime; private float lastGroundedTime; private Vector3 flipStartYawForward = Vector3.zero; private Vector3 flipStartYawRight = Vector3.zero; private Transform? yawReferenceTransform; public const string Id = "com.github.chrispavs.HardcoreParkour"; internal static ManualLogSource Log { get; private set; } = null; public static string Name => "HardcoreParkour"; public static string Version => "0.2.1"; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)("Plugin " + Name + " is loaded!")); Harmony.CreateAndPatchAll(typeof(FlipSyncPatch), (string)null); GameObject val = new GameObject("HardcoreParkour_YawReference"); yawReferenceTransform = val.transform; Object.DontDestroyOnLoad((Object)(object)val); keyboardKeybindConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "Keyboard Keybind", (KeyCode)102, "Keyboard key used to trigger flips. Defaults to F."); controllerKeybindConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "Controller Keybind", (KeyCode)335, "Controller button used to trigger flips. Defaults to JoystickButton5 (RB)."); debuggingLogsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Debugging", "Enable Logs", false, "Enable logs for debugging."); } private void RotateRagdoll(CharacterRagdoll ragdoll, Vector3 movementDirection, float torque, ForceMode forceMode = 1) { //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_0021: 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_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_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) foreach (Rigidbody rigidbody in ragdoll.rigidbodies) { Vector3 val = Vector3.Cross(movementDirection, Vector3.up); Vector3 val2 = -((Vector3)(ref val)).normalized; rigidbody.AddTorque(val2 * torque, forceMode); } } private void UpdateYawReference() { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MainCamera.instance != (Object)null && (Object)(object)yawReferenceTransform != (Object)null) { Vector3 eulerAngles = ((Component)MainCamera.instance).transform.eulerAngles; yawReferenceTransform.rotation = Quaternion.Euler(0f, eulerAngles.y, 0f); } } private Vector3 GetFlipDirection() { //IL_001d: 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_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_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_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_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_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_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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e1: 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) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)yawReferenceTransform == (Object)null) { return Vector3.zero; } Vector3 val = flipStartYawForward; Vector3 val2 = flipStartYawRight; Vector3 val3 = Vector3.zero; if (Input.GetKey((KeyCode)119)) { val3 += val; } if (Input.GetKey((KeyCode)115)) { val3 -= val; } if (Input.GetKey((KeyCode)100)) { val3 += val2; } if (Input.GetKey((KeyCode)97)) { val3 -= val2; } if (Input.GetAxis("Horizontal") != 0f) { val3 += val2 * Input.GetAxis("Horizontal"); } if (Input.GetAxis("Vertical") != 0f) { val3 += val * Input.GetAxis("Vertical"); } if (!(((Vector3)(ref val3)).sqrMagnitude > 0f)) { return Vector3.zero; } return ((Vector3)(ref val3)).normalized; } private void Update() { //IL_0233: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: 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_02c0: 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_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_035d: 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_043c: 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_017c: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || !Application.isFocused || (Object)(object)yawReferenceTransform == (Object)null) { return; } if (localCharacter.data.isGrounded) { lastGroundedTime = Time.time; if (!groundedSinceLastFlip && Time.time - flipStartTime > 0.5f) { Transform transform = ((Component)localCharacter.GetBodypart((BodypartType)13).rig).transform; Transform transform2 = ((Component)localCharacter.GetBodypart((BodypartType)16).rig).transform; float num = 0f - Vector3.Dot(transform.up, Vector3.up); float num2 = 0f - Vector3.Dot(transform2.up, Vector3.up); if (debuggingLogsConfig.Value) { Log.LogInfo((object)$"Upright dots: {num}, {num2}"); } if (num > 0.6f || num2 > 0.6f) { if (debuggingLogsConfig.Value) { Log.LogInfo((object)"Landed the flip!"); } localCharacter.data.fallSeconds = 0f; localCharacter.data.currentRagdollControll = Mathf.MoveTowards(localCharacter.data.currentRagdollControll, 1f, Time.fixedDeltaTime * 100f); foreach (Bodypart part in localCharacter.refs.ragdoll.partList) { Rigidbody rig = part.rig; rig.linearVelocity *= 0.5f; part.rig.angularVelocity = Vector3.zero; part.rig.MoveRotation(Quaternion.LookRotation(part.rig.rotation * Vector3.forward, part.targetUp)); } Character.GainFullStamina(); } } groundedSinceLastFlip = true; flipStartTime = 0f; } UpdateYawReference(); float num3 = Mathf.Lerp(0f, 1f, (Time.time - lastGroundedTime) / 0.3f); float num4 = Mathf.Lerp(1f, 1.5f, num3); if ((Input.GetKeyDown(keyboardKeybindConfig.Value) || Input.GetKeyDown(controllerKeybindConfig.Value)) && !localCharacter.data.isGrounded && groundedSinceLastFlip) { flipStartTime = Time.time; ((MonoBehaviourPun)localCharacter).photonView.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { 0.5f }); flipStartYawForward = yawReferenceTransform.forward; flipStartYawRight = yawReferenceTransform.right; Vector3 flipDirection = GetFlipDirection(); float num5 = Vector3.Dot(((Vector3)(ref flipDirection)).normalized, ((Vector3)(ref flipStartYawForward)).normalized); float num6 = Mathf.InverseLerp(-1f, 1f, num5); float num7 = Mathf.Lerp(0.8f, 1f, Mathf.Max(0f, num5)); float num8 = 200f * num7; localCharacter.AddForce(flipDirection * num4 * num8, 1f, 1f); if (num3 > 0.6f) { if (debuggingLogsConfig.Value) { Log.LogInfo((object)"Jumped high enough for the helper force."); } localCharacter.AddForce(Vector3.up * 200f, 1f, 1f); } float num9 = Mathf.Lerp(0.3f, 1f, num6); float num10 = Mathf.Lerp(0.1f, 4f, num3); float num11 = num10 * num9; if (debuggingLogsConfig.Value) { Log.LogInfo((object)$"forwardDotRemapped: {num6} Jump height scale: {num4} jumpPeakAmount: {num3} backwardScale: {num9} earlyJumpScale: {num10}"); } float num12 = 50f * num4 * num11; if (debuggingLogsConfig.Value) { Log.LogInfo((object)$"Final initial torque: {num12}"); } RotateRagdoll(localCharacter.refs.ragdoll, flipDirection, num12, (ForceMode)1); groundedSinceLastFlip = false; } else if (flipStartTime > 0f && !groundedSinceLastFlip) { Vector3 flipDirection2 = GetFlipDirection(); if (flipDirection2 != Vector3.zero) { float num13 = Mathf.Lerp(0.5f, 1f, num3); float torque = 20f * num13; RotateRagdoll(localCharacter.refs.ragdoll, flipDirection2, torque, (ForceMode)5); localCharacter.AddForce(Vector3.up * 1.75f, 1f, 1f); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }