using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Interaction; using LabFusion.Utilities; using MelonLoader; using MelonLoader.Preferences; using TelekinesisModNS; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(TelekinesisModClass), "TelekinesisMod", "7.0.0", "Dave", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: AssemblyTitle("telekinies")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("telekinies")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1f8a7dcf-881a-400c-8ddd-929adb6f8d50")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace TelekinesisModNS; public class TelekinesisModClass : MelonMod { internal static bool Enabled = false; internal static float HoldStiffness = 15f; internal static float DistanceScrollSpeed = 8f; internal static float FlingBoost = 1.3f; internal static bool ShowBeam = true; internal static bool ShowSphere = true; internal static float SphereRadius = 0.3f; internal static float SphereOffset = 0.5f; internal static float GrabThreshold = 0.6f; internal static float ReleaseThreshold = 0.3f; private static MelonPreferences_Category _prefCat; private static MelonPreferences_Entry _prefEnabled; private static MelonPreferences_Entry _prefStiffness; private static MelonPreferences_Entry _prefScrollSpeed; private static MelonPreferences_Entry _prefFlingBoost; private static MelonPreferences_Entry _prefShowBeam; private static MelonPreferences_Entry _prefShowSphere; private static MelonPreferences_Entry _prefSphereRadius; private static MelonPreferences_Entry _prefSphereOffset; internal static TKState RightTK = new TKState(); internal static TKState LeftTK = new TKState(); private static bool _ownershipChecked = false; private static bool _ownershipReady = false; private static object _marrowCache = null; private static MethodInfo _cacheTryGet = null; private static MethodInfo _takeOwnershipMethod = null; private static PropertyInfo _hasServerProp = null; public override void OnInitializeMelon() { SetupPrefs(); SetupBoneMenu(); MelonLogger.Msg("[TK] Force Grab v7 loaded"); } private void SetupPrefs() { _prefCat = MelonPreferences.CreateCategory("TelekinesisMod"); _prefEnabled = _prefCat.CreateEntry("Enabled", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefStiffness = _prefCat.CreateEntry("Stiffness", 15f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefScrollSpeed = _prefCat.CreateEntry("ScrollSpeed", 8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefFlingBoost = _prefCat.CreateEntry("FlingBoost", 1.3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefShowBeam = _prefCat.CreateEntry("ShowBeam", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefShowSphere = _prefCat.CreateEntry("ShowSphere", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefSphereRadius = _prefCat.CreateEntry("SphereRadius", 0.3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _prefSphereOffset = _prefCat.CreateEntry("SphereOffset", 0.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); Enabled = _prefEnabled.Value; HoldStiffness = _prefStiffness.Value; DistanceScrollSpeed = _prefScrollSpeed.Value; FlingBoost = _prefFlingBoost.Value; ShowBeam = _prefShowBeam.Value; ShowSphere = _prefShowSphere.Value; SphereRadius = _prefSphereRadius.Value; SphereOffset = _prefSphereOffset.Value; } private static void SavePrefs() { _prefEnabled.Value = Enabled; _prefStiffness.Value = HoldStiffness; _prefScrollSpeed.Value = DistanceScrollSpeed; _prefFlingBoost.Value = FlingBoost; _prefShowBeam.Value = ShowBeam; _prefShowSphere.Value = ShowSphere; _prefSphereRadius.Value = SphereRadius; _prefSphereOffset.Value = SphereOffset; _prefCat.SaveToFile(false); } private void SetupBoneMenu() { //IL_000a: 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_0051: 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_00d9: 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_0161: 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_01d9: Unknown result type (might be due to invalid IL or missing references) Page obj = Page.Root.CreatePage("Telekinesis", Color.magenta, 0, true); obj.CreateBool("Enabled", Color.green, Enabled, (Action)delegate(bool v) { Enabled = v; if (!v) { RightTK.Drop(0f); RightTK.DestroySphere(); LeftTK.Drop(0f); LeftTK.DestroySphere(); } SavePrefs(); }); obj.CreateFloat("Stiffness", Color.cyan, HoldStiffness, 1f, 1f, 30f, (Action)delegate(float v) { HoldStiffness = v; SavePrefs(); }); obj.CreateFloat("Scroll Speed", Color.cyan, DistanceScrollSpeed, 1f, 1f, 20f, (Action)delegate(float v) { DistanceScrollSpeed = v; SavePrefs(); }); obj.CreateFloat("Fling Boost", Color.yellow, FlingBoost, 0.1f, 0.5f, 5f, (Action)delegate(float v) { FlingBoost = v; SavePrefs(); }); obj.CreateFloat("Sphere Size", Color.white, SphereRadius, 0.05f, 0.05f, 2f, (Action)delegate(float v) { SphereRadius = v; RightTK.UpdateSphereSize(v); LeftTK.UpdateSphereSize(v); SavePrefs(); }); obj.CreateFloat("Sphere Offset", Color.white, SphereOffset, 0.1f, 0.2f, 2f, (Action)delegate(float v) { SphereOffset = v; SavePrefs(); }); obj.CreateBool("Show Sphere", Color.white, ShowSphere, (Action)delegate(bool v) { ShowSphere = v; if (!v) { RightTK.DestroySphere(); LeftTK.DestroySphere(); } SavePrefs(); }); obj.CreateBool("Show Beam", Color.white, ShowBeam, (Action)delegate(bool v) { ShowBeam = v; SavePrefs(); }); } public override void OnUpdate() { if (Enabled) { RigManager rigManager = Player.RigManager; if (!((Object)(object)rigManager == (Object)null)) { UpdateHand(RightTK, rigManager.physicsRig.rightHand); UpdateHand(LeftTK, rigManager.physicsRig.leftHand); } } } private void UpdateHand(TKState tk, Hand hand) { //IL_0023: 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_0033: 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_01f3: 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_024a: 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_025a: 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_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_0287: 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_0293: 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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: 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_008f: 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_00a3: 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_0316: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null) { return; } BaseController controller = hand.Controller; if ((Object)(object)controller == (Object)null) { return; } Transform transform = ((Component)hand).transform; Vector3 position = transform.position + transform.forward * SphereOffset; if (ShowSphere && Enabled) { if ((Object)(object)tk.Sphere == (Object)null) { tk.CreateSphere(SphereRadius); } if ((Object)(object)tk.Sphere != (Object)null) { tk.Sphere.transform.position = position; tk.Sphere.transform.localScale = Vector3.one * SphereRadius * 2f; } } else { tk.DestroySphere(); } float primaryAxis = controller._primaryAxis; if (!tk.IsActive) { if (primaryAxis >= GrabThreshold && (Object)(object)hand.m_CurrentAttachedGO == (Object)null) { if (!tk.InputWasDown) { tk.InputWasDown = true; TryForceGrab(tk, hand); } } else if (primaryAxis < ReleaseThreshold) { tk.InputWasDown = false; } return; } if (primaryAxis < ReleaseThreshold) { tk.InputWasDown = false; tk.Drop(FlingBoost); return; } if ((Object)(object)hand.m_CurrentAttachedGO != (Object)null) { tk.Drop(0f); return; } if ((Object)(object)tk.RB == (Object)null) { tk.Drop(0f); return; } try { if ((Object)(object)((Component)tk.RB).gameObject == (Object)null || !((Component)tk.RB).gameObject.activeInHierarchy) { tk.Drop(0f); return; } } catch { tk.Drop(0f); return; } tk.OwnershipTimer -= Time.deltaTime; if (tk.OwnershipTimer <= 0f) { tk.OwnershipTimer = 0.15f; try { TakeNetworkOwnership(((Component)tk.RB).gameObject); } catch { } if (tk.RB.isKinematic) { tk.RB.isKinematic = false; } } float y = controller._thumbstickAxis.y; if (Mathf.Abs(y) > 0.15f) { tk.Distance += y * DistanceScrollSpeed * Time.deltaTime; tk.Distance = Mathf.Clamp(tk.Distance, 0.5f, 100f); } Vector3 val = (transform.position + transform.forward * tk.Distance - tk.RB.position) * HoldStiffness; tk.RB.velocity = Vector3.Lerp(tk.RB.velocity, val, 0.5f); tk.RB.AddForce(-Physics.gravity, (ForceMode)5); Rigidbody rB = tk.RB; rB.angularVelocity *= 0.9f; if (ShowBeam) { if ((Object)(object)tk.Beam == (Object)null) { tk.CreateBeam(); } if ((Object)(object)tk.Beam != (Object)null) { tk.Beam.SetPosition(0, transform.position); tk.Beam.SetPosition(1, tk.RB.position); } } else { tk.DestroyBeam(); } } private void TryForceGrab(TKState tk, Hand hand) { //IL_0008: 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_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_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_00e3: 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_008e: 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) Transform transform = ((Component)hand).transform; Vector3 val = transform.position + transform.forward * SphereOffset; Collider[] array = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)Physics.OverlapSphere(val, SphereRadius, -1, (QueryTriggerInteraction)1)); if (array == null || array.Length == 0) { return; } Rigidbody val2 = null; float num = float.MaxValue; Collider[] array2 = array; foreach (Collider val3 in array2) { if (val3.isTrigger) { continue; } Rigidbody componentInParent = ((Component)val3).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { continue; } RigManager componentInParent2 = ((Component)componentInParent).GetComponentInParent(); if (!((Object)(object)componentInParent2 != (Object)null) || !FusionPlayer.IsLocalPlayer(componentInParent2)) { float num2 = Vector3.Distance(val, componentInParent.position); if (num2 < num) { num = num2; val2 = componentInParent; } } } if (!((Object)(object)val2 == (Object)null)) { try { TakeNetworkOwnership(((Component)val2).gameObject); } catch { } if (val2.isKinematic) { val2.isKinematic = false; } float num3 = Vector3.Distance(transform.position, val2.position); if (num3 < 0.5f) { num3 = 0.5f; } tk.Activate(val2, num3); MelonLogger.Msg($"[TK] Force grabbed: {((Object)((Component)val2).gameObject).name} at {num3:F1}m"); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void CacheOwnershipReflection() { if (_ownershipChecked) { return; } _ownershipChecked = true; try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (assembly2.GetName().Name == "LabFusion") { assembly = assembly2; break; } } if (assembly == null) { MelonLogger.Msg("[TK] Fusion not found — ownership takeover disabled"); return; } _marrowCache = (assembly.GetType("LabFusion.Entities.IMarrowEntityExtender")?.GetField("Cache", BindingFlags.Static | BindingFlags.Public))?.GetValue(null); if (_marrowCache != null) { _cacheTryGet = _marrowCache.GetType().GetMethod("TryGet"); } _takeOwnershipMethod = assembly.GetType("LabFusion.Entities.NetworkEntityManager")?.GetMethod("TakeOwnership", BindingFlags.Static | BindingFlags.Public); _hasServerProp = assembly.GetType("LabFusion.Network.NetworkInfo")?.GetProperty("HasServer", BindingFlags.Static | BindingFlags.Public); _ownershipReady = _marrowCache != null && _cacheTryGet != null && _takeOwnershipMethod != null; MelonLogger.Msg(_ownershipReady ? "[TK] Ownership takeover ready — can grab held objects" : "[TK] Ownership takeover unavailable"); } catch (Exception ex) { MelonLogger.Warning("[TK] Ownership reflection: " + ex.Message); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void TakeNetworkOwnership(GameObject go) { CacheOwnershipReflection(); if (!_ownershipReady) { return; } try { if (_hasServerProp != null && !(bool)_hasServerProp.GetValue(null)) { return; } } catch { return; } MarrowEntity componentInParent = go.GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { object[] array = new object[2] { componentInParent, null }; if ((bool)_cacheTryGet.Invoke(_marrowCache, array) && array[1] != null) { object obj2 = array[1]; _takeOwnershipMethod.Invoke(null, new object[1] { obj2 }); MelonLogger.Msg("[TK] Took network ownership of grabbed object"); } } } public override void OnDeinitializeMelon() { RightTK.Drop(0f); RightTK.DestroySphere(); LeftTK.Drop(0f); LeftTK.DestroySphere(); SavePrefs(); } } public class TKState { public bool IsActive; public Rigidbody RB; public float Distance = 5f; public bool InputWasDown; public LineRenderer Beam; public GameObject Sphere; public float OwnershipTimer; private float _origDrag; private float _origAngDrag = 0.05f; private bool _origGravity = true; public void Activate(Rigidbody rb, float dist) { _origDrag = rb.drag; _origAngDrag = rb.angularDrag; _origGravity = rb.useGravity; rb.useGravity = false; rb.drag = 0f; rb.angularDrag = 2f; RB = rb; Distance = dist; IsActive = true; } public void Drop(float flingBoost) { //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) if ((Object)(object)RB != (Object)null) { try { RB.useGravity = _origGravity; RB.drag = _origDrag; RB.angularDrag = _origAngDrag; if (flingBoost > 0f && flingBoost != 1f) { Rigidbody rB = RB; rB.velocity *= flingBoost; } } catch { } } RB = null; IsActive = false; DestroyBeam(); } public void CreateBeam() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_007d: 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) try { GameObject val = new GameObject("TK_Beam"); Object.DontDestroyOnLoad((Object)(object)val); Beam = val.AddComponent(); Beam.positionCount = 2; Beam.startWidth = 0.005f; Beam.endWidth = 0.005f; ((Renderer)Beam).material = new Material(Shader.Find("Sprites/Default")); Beam.startColor = new Color(0.6f, 0.2f, 1f, 0.7f); Beam.endColor = new Color(1f, 0.4f, 1f, 0.3f); } catch { Beam = null; } } public void DestroyBeam() { if ((Object)(object)Beam != (Object)null) { try { Object.Destroy((Object)(object)((Component)Beam).gameObject); } catch { } Beam = null; } } public void CreateSphere(float radius) { //IL_0032: 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_0042: 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_008c: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) try { Sphere = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)Sphere).name = "TK_DetectionSphere"; Object.DontDestroyOnLoad((Object)(object)Sphere); Sphere.transform.localScale = Vector3.one * radius * 2f; Collider component = Sphere.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = Sphere.GetComponent(); if ((Object)(object)component2 != (Object)null) { Material val = new Material(Shader.Find("Sprites/Default")); val.color = new Color(0.6f, 0.2f, 1f, 0.15f); ((Renderer)component2).material = val; } } catch { Sphere = null; } } public void DestroySphere() { if ((Object)(object)Sphere != (Object)null) { try { Object.Destroy((Object)(object)Sphere); } catch { } Sphere = null; } } public void UpdateSphereSize(float radius) { //IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Sphere != (Object)null) { Sphere.transform.localScale = Vector3.one * radius * 2f; } } }