using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Combat; using LabFusion.Data; using LabFusion.Player; using LabFusion.Utilities; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using RagdollArmDisable; using RagdollPlayer; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "RagdollUtility", "1.0.0", "notnotnotswipez", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("RagdollUtility")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RagdollUtility")] [assembly: AssemblyTitle("RagdollUtility")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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 RagdollArmDisable { public class Core : MelonMod { public static bool dropHeldItemsWhenRagdolled = true; public static bool ignoreAutoRise = true; public static bool _passThroughPatch = false; public static bool overrideStiffStatCalc = false; public static float upperStiffness = 10f; public static float lowerStiffness = 10f; public static float lastAttackTime = 0f; private int timesShortAttacked = 0; public static MelonPreferences_Category mainCategory = MelonPreferences.CreateCategory("RagdollUtility"); public static MelonPreferences_Entry dropHeldItemsEntry = mainCategory.CreateEntry("DropHeldItems", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public static MelonPreferences_Entry ignoreAutoRiseEntry = mainCategory.CreateEntry("IgnoreAutoRise", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public static MelonPreferences_Entry fastExitVehiclesEntry = mainCategory.CreateEntry("FastExitVehicles", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public static MelonPreferences_Entry twoTapDamageRagdollEntry = mainCategory.CreateEntry("TwoTapDamage", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public static MelonPreferences_Entry upperStiffnessEntry = mainCategory.CreateEntry("UpperStiffNess", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public static MelonPreferences_Entry lowerStiffnessEntry = mainCategory.CreateEntry("LowerStiffNess", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); public override void OnInitializeMelon() { //IL_000b: 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_0071: 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_00e0: Unknown result type (might be due to invalid IL or missing references) Page val = Page.Root.CreatePage("Ragdoll Utility", Color.yellow, 0, true); dropHeldItemsWhenRagdolled = dropHeldItemsEntry.Value; ignoreAutoRise = ignoreAutoRiseEntry.Value; val.CreateBool("Drop Held Items", Color.green, dropHeldItemsWhenRagdolled, (Action)delegate(bool b) { dropHeldItemsWhenRagdolled = b; dropHeldItemsEntry.Value = b; mainCategory.SaveToFile(false); }); val.CreateBool("Ignore Auto Knockout Rise", Color.green, ignoreAutoRise, (Action)delegate(bool b) { ignoreAutoRise = b; ignoreAutoRiseEntry.Value = b; mainCategory.SaveToFile(false); }); val.CreateBool("Fast Exit Vehicles", Color.green, fastExitVehiclesEntry.Value, (Action)delegate(bool b) { fastExitVehiclesEntry.Value = b; mainCategory.SaveToFile(false); }); val.CreateBool("Two Tap Damage", Color.green, twoTapDamageRagdollEntry.Value, (Action)delegate(bool b) { twoTapDamageRagdollEntry.Value = b; mainCategory.SaveToFile(false); }); LocalHealth.OnAttackedByPlayer += onAttackedByPlayer; ((MelonBase)this).LoggerInstance.Msg("Initialized."); } private void onAttackedByPlayer(Attack attack, BodyPart part, PlayerID iD) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (twoTapDamageRagdollEntry.Value && (int)attack.attackType == 1 && (int)Player.RigManager.health.healthMode == 0) { float time = Time.time; if (time - lastAttackTime < 5f) { timesShortAttacked++; } else { timesShortAttacked = 1; } lastAttackTime = time; if (timesShortAttacked >= 2) { MelonCoroutines.Start(RagdollPatch.KnockoutCoroutine(Player.RigManager, 2f, blind: false, useRagdollType: true)); } } } public override void OnUpdate() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 if (Player.ControllersExist && Player.LeftController.GetThumbStickDown()) { if (Object.op_Implicit((Object)(object)Player.RigManager.activeSeat) && fastExitVehiclesEntry.Value) { Player.RigManager.activeSeat.EgressRig(true); RagdollPlayerMod.RagdollRig(Player.RigManager); } else if (!Player.PhysicsRig.ballLocoEnabled && (int)RagdollPlayerMod.Mode == 1) { Player.PhysicsRig.ShutdownRig(); Player.PhysicsRig.RagdollRig(); } } } public static void OnLocalPlayerRagdolledForAnyReason() { if (dropHeldItemsWhenRagdolled) { LocalPlayer.ReleaseGrips(); } } public static void OnLocalPlayerUnRagdolledForAnyReason() { } } [HarmonyPatch(typeof(RagdollPlayerMod), "RagdollRig")] public static class RagdollPlayerPatch { public static bool Prefix() { if (!Core._passThroughPatch) { Core.OnLocalPlayerRagdolledForAnyReason(); } return true; } } [HarmonyPatch(typeof(RagdollPlayerMod), "UnragdollRig")] public static class UnRagdollPlayerPatch { public static void Prefix() { Core.OnLocalPlayerUnRagdolledForAnyReason(); } } [HarmonyPatch(typeof(LocalRagdoll), "ToggleRagdoll")] public static class LocalRagdollPlayerPatch { public static bool Prefix(bool ragdolled) { if (ragdolled) { Core.OnLocalPlayerRagdolledForAnyReason(); } else { Core.OnLocalPlayerUnRagdolledForAnyReason(); } return true; } } [HarmonyPatch(typeof(LocalRagdoll), "Knockout", new Type[] { typeof(float), typeof(bool) })] public static class RagdollPatch { public static bool Prefix(float length, bool blind) { if (!Core.ignoreAutoRise) { return true; } if (!RigData.HasPlayer) { return false; } if (LocalRagdoll.KnockedOut) { return false; } MelonCoroutines.Start(KnockoutCoroutine(RigData.Refs.RigManager, length, blind, useRagdollType: false)); return false; } public static IEnumerator KnockoutCoroutine(RigManager rigManager, float length, bool blind, bool useRagdollType) { LocalPlayer.ReleaseGrips(); if (useRagdollType) { RagdollPlayerMod.RagdollRig(rigManager); } else { LocalRagdoll.ToggleRagdoll(true); } LocalVision.Blind = blind; LocalVision.BlindColor = Color.black; typeof(LocalRagdoll).GetField("_knockedOut", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, true); float elapsed = 0f; float eyeLength = Mathf.Min(10f, length); while (elapsed <= length) { elapsed += TimeReferences.DeltaTime; float eyeStart = Mathf.Max(length - eyeLength, 0f); float eyeProgress = Mathf.Max(elapsed - eyeStart, 0f) / eyeLength; LocalVision.BlindColor = Color.Lerp(Color.black, Color.clear, Mathf.Pow(eyeProgress, 3f)); yield return null; } typeof(LocalRagdoll).GetField("_knockedOut", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, false); LocalVision.Blind = false; LocalVision.BlindColor = Color.black; if (!((Object)(object)rigManager == (Object)null)) { rigManager.health.SetFullHealth(); } } } }