using System; using System.Collections; using System.Collections.Generic; 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 HarmonyLib; using Il2Cpp; using Il2CppDinoFracture; using Il2CppHurricaneVR.Framework.Core; using Il2CppHurricaneVR.Framework.Core.Grabbers; using Il2CppSystem; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using RipAndTear; 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), "RipAndTear", "1.2.0", "MajedCT", null)] [assembly: MelonGame("Kubunautilus", "BrutalistickVR")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("RipAndTear")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RipAndTear")] [assembly: AssemblyTitle("RipAndTear")] [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] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 RipAndTear { public class Core : MelonMod { [HarmonyPatch(typeof(HVRGrabbable), "InternalOnGrabbed")] public static class PatchGrab { private static void Postfix(HVRGrabbable __instance) { if ((((Object)__instance).name == "Neck" && !removeNeckGib.Value) || ((Object)__instance).name == "Head" || ((Object)__instance).name == "Jaw" || ((Object)__instance).name == "UpperChest" || ((Object)__instance).name == "MiddleChest" || ((Object)__instance).name == "Knee_L" || ((Object)__instance).name == "Pelvis" || ((Object)__instance).name == "Shoulder_R" || ((Object)__instance).name == "Elbow_R" || ((Object)__instance).name == "Elbow_L" || ((Object)__instance).name == "Hip_R" || ((Object)__instance).name == "Shoulder_L" || ((Object)__instance).name == "Knee_R" || ((Object)__instance).name == "Hip_L" || ((Object)__instance).name == "Foot_R" || ((Object)__instance).name == "Foot_L") { SliceOnInputCustom component = ((Component)__instance).GetComponent(); HVRGrabbable component2 = ((Component)__instance).GetComponent(); SliceManager(component, component2, ((Object)__instance).GetInstanceID()); } } } [HarmonyPatch(typeof(HVRGrabbable), "InternalOnReleased")] public static class PatchUnGrab { private static void Postfix(HVRGrabbable __instance) { if ((((Object)__instance).name == "Neck" && !removeNeckGib.Value) || ((Object)__instance).name == "Head" || ((Object)__instance).name == "Jaw" || ((Object)__instance).name == "UpperChest" || ((Object)__instance).name == "MiddleChest" || ((Object)__instance).name == "Knee_L" || ((Object)__instance).name == "Pelvis" || ((Object)__instance).name == "Shoulder_R" || ((Object)__instance).name == "Elbow_R" || ((Object)__instance).name == "Elbow_L" || ((Object)__instance).name == "Hip_R" || ((Object)__instance).name == "Shoulder_L" || ((Object)__instance).name == "Knee_R" || ((Object)__instance).name == "Hip_L" || ((Object)__instance).name == "Foot_R" || ((Object)__instance).name == "Foot_L") { SliceOnInputCustom component = ((Component)__instance).GetComponent(); HVRGrabbable component2 = ((Component)__instance).GetComponent(); SliceManagerNullifier(component, component2, ((Object)__instance).GetInstanceID()); } } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SliceOnInputCustom original; public HVRHandGrabber hand; public Core <>4__this; private Transform 5__1; private Transform 5__2; private Transform 5__3; private HVRGrabbable 5__4; private float 5__5; private int 5__6; private Transform 5__7; private IEnumerator <>s__8; private HVRGrabbable 5__9; private Renderer 5__10; private Vector3 5__11; private float 5__12; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__7 = null; <>s__8 = null; 5__9 = null; 5__10 = null; <>1__state = -2; } private bool MoveNext() { //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_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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = null; <>1__state = 3; return true; case 3: <>1__state = -1; 5__1 = ((Component)original).transform.parent.parent; 5__2 = 5__1.Find("Chunks"); 5__3 = null; 5__6 = 0; while (5__6 < 5__2.childCount) { 5__7 = 5__2.GetChild(5__6); if (((Object)5__7).name.Contains(((Object)((Component)original).gameObject).name)) { 5__3 = 5__7; break; } 5__6++; } 5__4 = null; 5__5 = 0f; <>s__8 = ((Component)5__3).gameObject.GetComponentsInChildren(true).GetEnumerator(); try { while (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; 5__10 = ((Component)5__9).GetComponentInChildren(); if (!((Object)(object)5__10 == (Object)null)) { Bounds bounds = 5__10.bounds; 5__11 = ((Bounds)(ref bounds)).extents; 5__12 = 5__11.x * 5__11.y * 5__11.z; if (5__12 > 5__5) { 5__5 = 5__12; 5__4 = 5__9; } 5__10 = null; 5__9 = null; } } } finally { if (<>s__8 != null) { <>s__8.Dispose(); } } <>s__8 = null; if ((Object)(object)5__4 != (Object)null) { Debug.Log(Object.op_Implicit("Grabbing chunk: " + ((Object)5__4).name)); ((HVRGrabberBase)hand).ForceRelease(); ((HVRGrabberBase)hand).TryGrab(5__4, false); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static HVRHexaBodyInputs playerInputs; public static HVRHandGrabber leftHand; public static HVRHandGrabber rightHand; public static SliceOnInputCustom slice1; public static SliceOnInputCustom slice2; public static int id1; public static int id2; public static HVRGrabbable grab1; public static HVRGrabbable grab2; public static MelonPreferences_Category category; public static MelonPreferences_Entry removeNeckGib; public override void OnInitializeMelon() { ((MelonBase)this).LoggerInstance.Msg("Initialized."); category = MelonPreferences.CreateCategory("RipAndTear"); removeNeckGib = category.CreateEntry("Don't gib neck", false, "Don't gib neck", "Disable neck gibbing to work with Choke Mod", false, false, (ValueValidator)null, (string)null); category.SaveToFile(true); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName != "MainMenuScene") { playerInputs = GameObject.Find("Hexa4Rig26.10.23").GetComponentInChildren(); leftHand = GameObject.Find("Hexa4Rig26.10.23").GetComponentInChildren(); GameObject val = GameObject.Find("Hexa4Rig26.10.23"); leftHand = ((Component)val.transform.Find("Physics LeftHand")).GetComponent(); rightHand = ((Component)val.transform.Find("Physics RightHand")).GetComponent(); } } public static void SliceManager(SliceOnInputCustom slicer, HVRGrabbable grab, int id) { if ((Object)(object)grab1 == (Object)null && (Object)(object)slice1 == (Object)null && id1 == 0) { grab1 = grab; slice1 = slicer; id1 = id; } else if ((Object)(object)grab1 != (Object)null && (((Object)(object)slice1 != (Object)null) & (id1 != 0)) && (Object)(object)grab2 == (Object)null && (Object)(object)slice2 == (Object)null && id2 == 0) { grab2 = grab; slice2 = slicer; id2 = id; } } public static void SliceManagerNullifier(SliceOnInputCustom slicer, HVRGrabbable grab, int id) { if (id == id1) { grab1 = null; slice1 = null; id1 = 0; } else if (id == id2) { grab2 = null; slice2 = null; id2 = 0; } } [IteratorStateMachine(typeof(d__17))] private IEnumerator GrabAfterFracture(SliceOnInputCustom original, HVRHandGrabber hand) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this, original = original, hand = hand }; } public override void OnUpdate() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerInputs == (Object)null) { return; } if (playerInputs.LeftController.TriggerButtonState.Active) { if ((Object)(object)grab1 != (Object)null && ((Object)grab1.Grabbers[0]).name == "Physics LeftHand") { string name = ((Object)((Component)slice1).gameObject).name; if (name != "Head" && name != "Pelvis") { TransferJointsOnFractureCustom componentInParent = ((Component)slice1).GetComponentInParent(); componentInParent.DistanceTolerance = 0f; } if (removeNeckGib.Value && name == "Neck") { return; } slice1.ForceFracture(); if (name.Contains("Elbow") || name.Contains("Shoulder") || name.Contains("Knee") || name.Contains("Hip") || name.Contains("Foot") || name.Contains("Jaw")) { MelonCoroutines.Start(GrabAfterFracture(slice1, leftHand)); } else { ((HVRGrabberBase)leftHand).ForceRelease(); } SliceManagerNullifier(slice1, grab1, id1); } else if ((Object)(object)grab2 != (Object)null && ((Object)grab2.Grabbers[0]).name == "Physics LeftHand") { string name2 = ((Object)((Component)slice2).gameObject).name; if (name2 != "Head" && name2 != "Pelvis") { TransferJointsOnFractureCustom componentInParent2 = ((Component)slice2).GetComponentInParent(); componentInParent2.DistanceTolerance = 0f; } if (removeNeckGib.Value && name2 == "Neck") { return; } slice2.ForceFracture(); if (name2.Contains("Elbow") || name2.Contains("Shoulder") || name2.Contains("Knee") || name2.Contains("Hip") || name2.Contains("Foot") || name2.Contains("Jaw")) { MelonCoroutines.Start(GrabAfterFracture(slice2, leftHand)); } else { ((HVRGrabberBase)leftHand).ForceRelease(); } SliceManagerNullifier(slice2, grab2, id2); } } if (!playerInputs.RightController.TriggerButtonState.Active) { return; } if ((Object)(object)grab1 != (Object)null && ((Object)grab1.Grabbers[0]).name == "Physics RightHand") { string name3 = ((Object)((Component)slice1).gameObject).name; if (name3 != "Head" && name3 != "Pelvis") { TransferJointsOnFractureCustom componentInParent3 = ((Component)slice1).GetComponentInParent(); componentInParent3.DistanceTolerance = 0f; } if (!removeNeckGib.Value || !(name3 == "Neck")) { slice1.ForceFracture(); if (name3.Contains("Elbow") || name3.Contains("Shoulder") || name3.Contains("Knee") || name3.Contains("Hip") || name3.Contains("Foot") || name3.Contains("Jaw")) { MelonCoroutines.Start(GrabAfterFracture(slice1, rightHand)); } else { ((HVRGrabberBase)rightHand).ForceRelease(); } SliceManagerNullifier(slice1, grab1, id1); } } else { if (!((Object)(object)grab2 != (Object)null) || !(((Object)grab2.Grabbers[0]).name == "Physics RightHand")) { return; } string name4 = ((Object)((Component)slice2).gameObject).name; if (name4 != "Head" && name4 != "Pelvis") { TransferJointsOnFractureCustom componentInParent4 = ((Component)slice2).GetComponentInParent(); componentInParent4.DistanceTolerance = 0f; } if (!removeNeckGib.Value || !(name4 == "Neck")) { slice2.ForceFracture(); if (name4.Contains("Elbow") || name4.Contains("Shoulder") || name4.Contains("Knee") || name4.Contains("Hip") || name4.Contains("Foot") || name4.Contains("Jaw")) { MelonCoroutines.Start(GrabAfterFracture(slice2, rightHand)); } else { ((HVRGrabberBase)rightHand).ForceRelease(); } SliceManagerNullifier(slice2, grab2, id2); } } } } }