Decompiled source of QuickGloves v1.0.0
Mods/QuickGloves.dll
Decompiled 6 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Utilities; using LabFusion.Entities; using LabFusion.Extensions; using LabFusion.Network; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using QuickGloves; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.XR; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(QuickGlovesMod), "QuickGloves", "1.0.0", "nontendo", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("QuickGloves")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("QuickGloves")] [assembly: AssemblyTitle("QuickGloves")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace QuickGloves { public static class GloveFusion { public static void TakeOwnership(GameObject go) { try { if (NetworkInfo.HasServer) { MarrowEntity componentInParent = go.GetComponentInParent<MarrowEntity>(); NetworkEntity val = default(NetworkEntity); if (!((Object)(object)componentInParent == (Object)null) && IMarrowEntityExtender.Cache.TryGet(componentInParent, ref val) && val != null && !val.IsOwner) { NetworkEntityManager.TakeOwnership(val); } } } catch { } } public static bool CanMove(GameObject go) { try { if (!NetworkInfo.HasServer) { return true; } MarrowEntity componentInParent = go.GetComponentInParent<MarrowEntity>(); if ((Object)(object)componentInParent == (Object)null) { return true; } NetworkEntity val = default(NetworkEntity); if (!IMarrowEntityExtender.Cache.TryGet(componentInParent, ref val) || val == null) { return true; } return val.IsOwner; } catch { return true; } } public static void Attach(Grip grip, Hand hand) { if (NetworkInfo.HasServer) { GripExtensions.TryAttach(grip, hand, true, (SimpleTransform?)null); } else { grip.OnGrabConfirm(hand, true); } } } public class GloveFx { private sealed class Piece { public GameObject Go; public MeshFilter Mf; public MeshRenderer Mr; public Transform? Src; } private const int ArcPoints = 24; private const int MaxOutline = 16; private readonly string _tag; private LineRenderer? _arc; private GameObject? _cross; private GameObject? _beam; private Material? _crossMat; private Material? _beamMat; private static Texture2D? _crossTex; private TrailRenderer? _trail; private Material? _outlineMat; private readonly List<Piece> _pieces = new List<Piece>(); private int _used; private int _outlineId; public static readonly Color Orange = new Color(1f, 0.62f, 0.12f); public GloveFx(bool isLeft) { _tag = (isLeft ? "L" : "R"); } public static Color Accent() { //IL_0000: 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_0033: Unknown result type (might be due to invalid IL or missing references) //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) try { return QuickModsTheme.ResolveAccent(Orange, modThemeToSong: false, () => (Color?)null); } catch { return Orange; } } public static Material Mat(int queue = 3000) { //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_0026: Expected O, but got Unknown Material val = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default")) { hideFlags = (HideFlags)61 }; try { val.SetInt("unity_GUIZTestMode", 4); } catch { } val.renderQueue = queue; return val; } public void Arc(bool show, Vector3 a, Vector3 b, Color c, float alpha, bool taut) { //IL_0046: 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_004e: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007d: 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_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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) if (!show || !GloveSettings.ShowArc) { if ((Object)(object)_arc != (Object)null) { ((Renderer)_arc).enabled = false; } return; } BuildArc(); if (!((Object)(object)_arc == (Object)null)) { ((Renderer)_arc).enabled = true; float num = Vector3.Distance(a, b); Vector3 val = (a + b) * 0.5f; val = ((!taut) ? (val + Vector3.up * Mathf.Min(num * 0.16f, 0.9f)) : (val + Random.insideUnitSphere * 0.012f)); for (int i = 0; i < 24; i++) { float num2 = (float)i / 23f; float num3 = 1f - num2; _arc.SetPosition(i, num3 * num3 * a + 2f * num3 * num2 * val + num2 * num2 * b); } _arc.startColor = new Color(c.r, c.g, c.b, alpha); _arc.endColor = new Color(c.r, c.g, c.b, alpha * 0.55f); } } private void BuildArc() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!((Object)(object)_arc != (Object)null)) { GameObject val = new GameObject("[QuickGloves] Arc " + _tag); Object.DontDestroyOnLoad((Object)(object)val); _arc = val.AddComponent<LineRenderer>(); _arc.positionCount = 24; _arc.useWorldSpace = true; _arc.numCapVertices = 3; _arc.startWidth = 0.007f; _arc.endWidth = 0.003f; ((Renderer)_arc).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_arc).receiveShadows = false; ((Renderer)_arc).material = Mat(); ((Renderer)_arc).enabled = false; } } public void Outline(Rigidbody? rb) { int num = 0; try { if ((Object)(object)rb != (Object)null) { num = ((Object)rb).GetInstanceID(); } } catch { } if (num == _outlineId) { return; } _outlineId = num; HidePieces(); if ((Object)(object)rb == (Object)null || !GloveSettings.ShowOutline) { return; } try { MarrowEntity componentInParent = ((Component)rb).GetComponentInParent<MarrowEntity>(); foreach (MeshFilter componentsInChild in (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)rb).gameObject).GetComponentsInChildren<MeshFilter>(false)) { if (_used >= 16) { break; } if ((Object)(object)componentsInChild == (Object)null) { continue; } Mesh sharedMesh = componentsInChild.sharedMesh; if ((Object)(object)sharedMesh == (Object)null) { continue; } MeshRenderer component = ((Component)componentsInChild).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled) { Piece piece = GetPiece(_used++); piece.Src = ((Component)componentsInChild).transform; piece.Mf.sharedMesh = sharedMesh; int num2 = Mathf.Max(1, sharedMesh.subMeshCount); Il2CppReferenceArray<Material> val = new Il2CppReferenceArray<Material>((long)num2); for (int i = 0; i < num2; i++) { ((Il2CppArrayBase<Material>)(object)val)[i] = _outlineMat; } ((Renderer)piece.Mr).sharedMaterials = val; piece.Go.SetActive(true); } } } catch { HidePieces(); } } public void OutlineTick(Color c, float alpha) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00cf: Unknown result type (might be due to invalid IL or missing references) if (_used == 0) { return; } if (!GloveSettings.ShowOutline) { HidePieces(); _outlineId = 0; return; } try { if ((Object)(object)_outlineMat != (Object)null) { _outlineMat.color = new Color(c.r, c.g, c.b, alpha); } for (int i = 0; i < _used; i++) { Piece piece = _pieces[i]; if (!((Object)(object)piece.Go == (Object)null)) { if ((Object)(object)piece.Src == (Object)null) { piece.Go.SetActive(false); continue; } piece.Go.transform.SetPositionAndRotation(piece.Src.position, piece.Src.rotation); piece.Go.transform.localScale = piece.Src.lossyScale * 1.035f; } } } catch { } } private Piece GetPiece(int i) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if ((Object)(object)_outlineMat == (Object)null) { _outlineMat = Mat(3001); } if (i < _pieces.Count && (Object)(object)_pieces[i].Go != (Object)null) { return _pieces[i]; } GameObject val = new GameObject("[QuickGloves] Outline " + _tag); Object.DontDestroyOnLoad((Object)(object)val); Piece piece = new Piece { Go = val, Mf = val.AddComponent<MeshFilter>(), Mr = val.AddComponent<MeshRenderer>() }; ((Renderer)piece.Mr).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)piece.Mr).receiveShadows = false; if (i < _pieces.Count) { _pieces[i] = piece; } else { _pieces.Add(piece); } return piece; } private void HidePieces() { for (int i = 0; i < _pieces.Count; i++) { try { if ((Object)(object)_pieces[i].Go != (Object)null) { _pieces[i].Go.SetActive(false); } } catch { } _pieces[i].Src = null; } _used = 0; } public void TrailStart(Vector3 pos, Color c) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (GloveSettings.ShowTrail) { BuildTrail(); if (!((Object)(object)_trail == (Object)null)) { ((Component)_trail).transform.position = pos; _trail.Clear(); _trail.startColor = new Color(c.r, c.g, c.b, 0.55f); _trail.endColor = new Color(c.r, c.g, c.b, 0f); _trail.emitting = true; } } } public void TrailMove(Vector3 pos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_trail != (Object)null) { ((Component)_trail).transform.position = pos; } } public void TrailStop() { if ((Object)(object)_trail != (Object)null) { _trail.emitting = false; } } private void BuildTrail() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!((Object)(object)_trail != (Object)null)) { GameObject val = new GameObject("[QuickGloves] Trail " + _tag); Object.DontDestroyOnLoad((Object)(object)val); _trail = val.AddComponent<TrailRenderer>(); _trail.time = 0.4f; _trail.startWidth = 0.035f; _trail.endWidth = 0f; _trail.minVertexDistance = 0.03f; _trail.numCapVertices = 2; ((Renderer)_trail).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_trail).receiveShadows = false; ((Renderer)_trail).material = Mat(); _trail.emitting = false; } } public void Crosshair(bool show, Vector3 pos, Vector3 eye, Color c, bool locked) { //IL_003a: 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_003c: 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_0077: 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_007f: 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) //IL_008a: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) if (!show || !GloveSettings.ShowCrosshair) { if ((Object)(object)_cross != (Object)null) { _cross.SetActive(false); } return; } BuildCross(); if ((Object)(object)_cross == (Object)null) { return; } Vector3 val = eye - pos; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.01f) { _cross.SetActive(false); return; } _cross.SetActive(true); Transform transform = _cross.transform; transform.position = pos; transform.rotation = Quaternion.LookRotation(-val / magnitude, Vector3.up) * Quaternion.Euler(0f, 0f, locked ? 45f : 0f); transform.localScale = Vector3.one * (magnitude * (locked ? 0.045f : 0.035f)); if ((Object)(object)_crossMat != (Object)null) { _crossMat.color = new Color(c.r, c.g, c.b, locked ? 1f : 0.6f); } } private void BuildCross() { //IL_0077: 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_0089: Expected O, but got Unknown if (!((Object)(object)_cross != (Object)null)) { _cross = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)_cross).name = "[QuickGloves] Crosshair " + _tag; Object.DontDestroyOnLoad((Object)(object)_cross); Collider component = _cross.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Shader val = Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default"); _crossMat = new Material(val) { hideFlags = (HideFlags)61 }; int num = 8; try { _crossMat.SetInt("unity_GUIZTestMode", num); _crossMat.SetInt("_ZTest", num); } catch { } _crossMat.renderQueue = 5000; _crossMat.mainTexture = (Texture)(object)CrossTex(); MeshRenderer component2 = _cross.GetComponent<MeshRenderer>(); ((Renderer)component2).sharedMaterial = _crossMat; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; _cross.SetActive(false); } } private static Texture2D CrossTex() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_crossTex != (Object)null) { return _crossTex; } Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; for (int i = 0; i < 96; i++) { for (int j = 0; j < 96; j++) { float num = ((float)j + 0.5f) / 96f * 2f - 1f; float num2 = ((float)i + 0.5f) / 96f * 2f - 1f; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Min(Mathf.Abs(num), Mathf.Abs(num2)); float num5 = Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2)); bool flag = num3 < 0.07f; bool flag2 = num3 > 0.56f && num3 < 0.64f && num4 > 0.16f; bool flag3 = num4 < 0.035f && num5 > 0.48f && num5 < 0.95f; val.SetPixel(j, i, new Color(1f, 1f, 1f, (flag || flag2 || flag3) ? 1f : 0f)); } } val.Apply(); _crossTex = val; return val; } public void Beam(bool show, Vector3 from, Vector3 dir, float length, float radius, Color c) { //IL_005b: 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_0065: 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_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_007b: 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_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!show || !GloveSettings.ShowBeam || length < 0.05f) { if ((Object)(object)_beam != (Object)null) { _beam.SetActive(false); } return; } BuildBeam(); if (!((Object)(object)_beam == (Object)null)) { _beam.SetActive(true); Transform transform = _beam.transform; transform.position = from + dir * (length * 0.5f); transform.rotation = Quaternion.FromToRotation(Vector3.up, dir); transform.localScale = new Vector3(radius * 2f, length * 0.5f, radius * 2f); if ((Object)(object)_beamMat != (Object)null) { _beamMat.color = new Color(c.r, c.g, c.b, 0.12f); } } } private void BuildBeam() { if (!((Object)(object)_beam != (Object)null)) { _beam = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)_beam).name = "[QuickGloves] Beam " + _tag; Object.DontDestroyOnLoad((Object)(object)_beam); Collider component = _beam.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } _beamMat = Mat(); MeshRenderer component2 = _beam.GetComponent<MeshRenderer>(); ((Renderer)component2).sharedMaterial = _beamMat; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; _beam.SetActive(false); } } public void Hide() { try { if ((Object)(object)_arc != (Object)null) { ((Renderer)_arc).enabled = false; } if ((Object)(object)_cross != (Object)null) { _cross.SetActive(false); } if ((Object)(object)_beam != (Object)null) { _beam.SetActive(false); } TrailStop(); HidePieces(); _outlineId = 0; } catch (Exception) { } } } public class GloveHand { private enum State { Idle, Targeting, Tethered, Flight } private struct Cand { public float Score; public Collider Col; public Rigidbody Rb; } private struct Checked { public Rigidbody? Main; public float Until; } private const float PressOn = 0.6f; private const float PressOff = 0.3f; private const float MinDist = 0.7f; private const float AimCone = 20f; private const float Sticky = 7f; private const float ScanEvery = 0.06f; private const float SettleTime = 0.08f; private const float StrainAccel = 18f; private const float BreakFree = 0.35f; private const int KickSteps = 4; private const int StuckSteps = 10; private const float OwnRetry = 0.3f; private const float WindMax = 0.1f; private const float HomeRadius = 1.22f; private const float HomeAccel = 60f; private const float HomeMaxTime = 6f; private readonly bool _isLeft; private readonly GloveFx _fx; public GloveHand? Other; private State _state; private Rigidbody? _rb; private int _rbId; private bool _grabLocked; private bool _held; private bool _pressed; private Vector3 _vel; private Vector3 _lastRel; private bool _haveRel; private float _scanTimer; private float _pulseTimer; private float _tetherTime; private float _ownTimer; private float _humTimer; private bool _strain; private bool _winding; private float _peak; private float _windTime; private float _power = 1f; private Vector3 _strainStart; private float _t; private float _flightT; private float _launchSpeed; private float _drag; private Vector3 _kick; private Vector3 _gravity; private Vector3 _launchFrom; private int _steps; private bool _freed; private bool _homing; private float _cruise; private readonly List<Rigidbody> _bodies = new List<Rigidbody>(); private readonly List<Cand> _cands = new List<Cand>(); private readonly HashSet<int> _seen = new HashSet<int>(); private static readonly Dictionary<int, Checked> _checked = new Dictionary<int, Checked>(); public int TargetId { get { if (_state != State.Idle) { return _rbId; } return 0; } } public GloveHand(bool isLeft) { _isLeft = isLeft; _fx = new GloveFx(isLeft); } private Hand? MyHand() { if (!_isLeft) { return Player.RightHand; } return Player.LeftHand; } public void Update() { //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_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_00a3: Unknown result type (might be due to invalid IL or missing references) Hand val = MyHand(); BaseController val2 = (_isLeft ? Player.LeftController : Player.RightController); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Cancel(null); return; } float deltaTime = Time.deltaTime; Vector3 palm = Palm(val); TrackVelocity(val2, deltaTime); ReadInput(val, val2); try { if (_state != State.Idle && !Alive()) { Cancel(val); } switch (_state) { case State.Idle: case State.Targeting: Aim(val, palm, deltaTime); break; case State.Tethered: Tether(val, palm, deltaTime); break; case State.Flight: Flight(val, palm); break; } } catch (Exception ex) { MelonLogger.Warning("[QuickGloves] " + ex.Message); Cancel(val); } } public void FixedTick() { if (_state == State.Idle || _state == State.Targeting) { return; } Hand val = MyHand(); if ((Object)(object)val == (Object)null) { return; } try { if (Alive()) { if (_state == State.Flight) { FlightTick(val, Time.fixedDeltaTime); } else if (_strain) { StrainTick(val); } } } catch { Cancel(val); } } public void Reset() { _grabLocked = false; Cancel(null); _checked.Clear(); _haveRel = false; _held = false; } public void Disable() { Cancel(MyHand()); } private void ReadInput(Hand hand, BaseController ctrl) { float num; try { num = (GloveSettings.UseTrigger ? hand.GetIndexTriggerAxis() : ctrl.GetGripForce()); } catch { num = 0f; } bool held = _held; if (!_held && num >= 0.6f) { _held = true; } else if (_held && num <= 0.3f) { _held = false; } _pressed = _held && !held; } private void TrackVelocity(BaseController ctrl, float dt) { //IL_0006: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0065: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002f: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) try { Vector3 val = ((Component)ctrl).transform.position - BodyPos(); if (_haveRel && dt > 0.0001f) { _vel = Vector3.Lerp(_vel, (val - _lastRel) / dt, 0.5f); } _lastRel = val; _haveRel = true; } catch { _vel = Vector3.zero; } } private static Vector3 BodyPos() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references) try { return Player.PhysicsRig.torso.rbPelvis.position; } catch { return Vector3.zero; } } private void Aim(Hand hand, Vector3 palm, float dt) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0049: 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_0053: 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_006a: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_014a: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0286: 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_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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 ((_state == State.Idle && _held) || !HandEmpty(hand) || NearSomething(hand)) { if (_state == State.Targeting) { Cancel(hand); } _fx.Crosshair(show: false, default(Vector3), default(Vector3), default(Color), locked: false); _fx.Beam(show: false, default(Vector3), default(Vector3), 0f, 0f, default(Color)); return; } Vector3 forward = ((Component)hand).transform.forward; _scanTimer -= dt; if (_scanTimer <= 0f) { _scanTimer = 0.06f; Rigidbody val = Scan(palm, forward); int num = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0); if (num != _rbId || (Object)(object)val == (Object)null) { _rb = val; _rbId = num; if ((Object)(object)val != (Object)null) { Rumble(0.22f, 0.02f); _pulseTimer = 0.4f; GloveSound.Play("target", _isLeft, palm, 0.25f); } } } Color c = GloveFx.Accent(); Vector3 eye = Eye(palm); float num2 = AimReach(palm, forward); if ((Object)(object)_rb == (Object)null) { if (_state == State.Targeting) { Cancel(hand); } _fx.Crosshair(show: true, palm + forward * num2, eye, c, locked: false); _fx.Beam(show: true, palm, forward, num2, GloveSettings.AimRadius, c); return; } _state = State.Targeting; Lock(hand); _pulseTimer -= dt; if (_pulseTimer <= 0f) { _pulseTimer = 0.4f; Rumble(0.08f, 0.02f); } Vector3 worldCenterOfMass = _rb.worldCenterOfMass; _fx.Crosshair(show: true, worldCenterOfMass, eye, c, locked: true); _fx.Beam(show: true, palm, forward, num2, GloveSettings.AimRadius, c); _fx.Arc(show: true, palm, worldCenterOfMass, c, 0.38f + 0.12f * Mathf.Sin(Time.time * 7f), taut: false); _fx.Outline(_rb); _fx.OutlineTick(c, 0.1f); if (!_pressed) { return; } _checked.Clear(); if ((Object)(object)Scan(palm, forward, _rbId) == (Object)null) { Cancel(hand); return; } _state = State.Tethered; _tetherTime = 0f; _strain = false; _winding = false; _power = 1f; _ownTimer = 0f; _vel = Vector3.zero; if (GloveManager.FusionAvailable) { GloveFusion.TakeOwnership(((Component)_rb).gameObject); } Rumble(0.4f, 0.03f); GloveSound.Play("lock", _isLeft, palm, 0.7f); } private static Vector3 Eye(Vector3 fallback) { //IL_0012: 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_001f: 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) try { if ((Object)(object)Player.Head != (Object)null) { return Player.Head.position; } } catch { } return fallback; } private static float AimReach(Vector3 palm, Vector3 dir) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references) float range = GloveSettings.Range; try { RaycastHit val = default(RaycastHit); if (Physics.Raycast(palm + dir * 0.15f, dir, ref val, range - 0.15f, -1, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).distance + 0.15f; } } catch { } return range; } private Rigidbody? Scan(Vector3 origin, Vector3 dir, int onlyId = 0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c9: 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_019b: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array; try { array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)Physics.SphereCastAll(origin, GloveSettings.AimRadius, dir, GloveSettings.Range, -1, (QueryTriggerInteraction)1)); } catch { return null; } _cands.Clear(); _seen.Clear(); int num = ((Other != null) ? Other.TargetId : 0); for (int i = 0; i < array.Length; i++) { Collider collider = ((RaycastHit)(ref array[i])).collider; if ((Object)(object)collider == (Object)null) { continue; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null || !_seen.Add(((Object)attachedRigidbody).GetInstanceID())) { continue; } Vector3 val = attachedRigidbody.worldCenterOfMass - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.7f) && !(magnitude > GloveSettings.Range)) { float num2 = Vector3.Angle(dir, val); if (!(num2 > 20f)) { _cands.Add(new Cand { Score = num2 + magnitude * 0.2f, Col = collider, Rb = attachedRigidbody }); } } } Rigidbody result = null; float num3 = float.MaxValue; for (int j = 0; j < _cands.Count; j++) { Cand cand = _cands[j]; Rigidbody val2 = Validate(cand.Col, cand.Rb); if ((Object)(object)val2 == (Object)null) { continue; } int instanceID = ((Object)val2).GetInstanceID(); if (instanceID != num && (onlyId == 0 || instanceID == onlyId)) { float num4 = cand.Score - ((instanceID == _rbId) ? 7f : 0f); if (!(num4 >= num3) && Visible(origin, val2)) { result = val2; num3 = num4; } } } return result; } private static Rigidbody? Validate(Collider col, Rigidbody rb) { int instanceID = ((Object)rb).GetInstanceID(); if (_checked.TryGetValue(instanceID, out var value) && value.Until > Time.time) { return value.Main; } Rigidbody val = null; try { val = ValidateNow(col, rb); } catch { val = null; } _checked[instanceID] = new Checked { Main = val, Until = Time.time + 0.75f }; return val; } private static Rigidbody? ValidateNow(Collider col, Rigidbody rb) { GameObject gameObject = ((Component)col).gameObject; if ((Object)(object)gameObject.GetComponentInParent<RigManager>() != (Object)null) { return null; } if ((Object)(object)gameObject.GetComponentInParent<AIBrain>() != (Object)null) { return null; } InteractableHost componentInParent = gameObject.GetComponentInParent<InteractableHost>(); if ((Object)(object)componentInParent == (Object)null) { if ((Object)(object)gameObject.GetComponentInParent<Grip>() == (Object)null) { return null; } } else if (componentInParent.IsStatic) { return null; } Rigidbody val = rb; GameObject gameObject2 = ((Component)rb).gameObject; MarrowEntity componentInParent2 = gameObject.GetComponentInParent<MarrowEntity>(); if ((Object)(object)componentInParent2 != (Object)null) { gameObject2 = ((Component)componentInParent2).gameObject; MarrowBody anchorBody = componentInParent2.AnchorBody; if ((Object)(object)anchorBody != (Object)null && (Object)(object)anchorBody._rigidbody != (Object)null) { val = anchorBody._rigidbody; } } if (val.isKinematic || val.mass > GloveSettings.MaxMass) { return null; } foreach (Grip componentsInChild in gameObject2.GetComponentsInChildren<Grip>(false)) { if ((Object)(object)componentsInChild != (Object)null && componentsInChild.HasAttachedHands()) { return null; } } return val; } private static bool Visible(Vector3 origin, Rigidbody rb) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_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_002a: 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_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_003b: Unknown result type (might be due to invalid IL or missing references) try { Vector3 val = rb.worldCenterOfMass - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.2f) { return true; } Vector3 val2 = val / magnitude; RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(origin + val2 * 0.12f, val2, ref val3, magnitude - 0.12f, -1, (QueryTriggerInteraction)1)) { return true; } if ((Object)(object)((RaycastHit)(ref val3)).rigidbody != (Object)null && ((Object)((RaycastHit)(ref val3)).rigidbody).GetInstanceID() == ((Object)rb).GetInstanceID()) { return true; } return ((RaycastHit)(ref val3)).distance >= magnitude - 0.6f; } catch { return false; } } private void Tether(Hand hand, Vector3 palm, float dt) { //IL_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0085: 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_0087: 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_009c: 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_00a6: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) Rigidbody rb = _rb; if (!_held) { GloveSound.Play("cancel", _isLeft, palm, 0.6f); Cancel(hand); return; } Vector3 worldCenterOfMass = rb.worldCenterOfMass; if (Vector3.Distance(palm, worldCenterOfMass) > GloveSettings.Range * 1.4f) { Cancel(hand); return; } _tetherTime += dt; Color c = GloveFx.Accent(); _fx.Arc(show: true, palm, worldCenterOfMass, c, 0.9f, _strain); _fx.Crosshair(show: true, worldCenterOfMass, Eye(palm), c, locked: true); _fx.Beam(show: false, default(Vector3), default(Vector3), 0f, 0f, c); _fx.Outline(rb); _fx.OutlineTick(c, _strain ? 0.3f : 0.22f); GloveSound.SetBeam(_isLeft, active: true, palm, _strain); if (_strain) { _humTimer -= dt; if (_humTimer <= 0f) { _humTimer = 0.05f; Rumble(0.3f + 0.12f * Mathf.Sin(Time.time * 40f), 0.06f); } if (Vector3.Distance(worldCenterOfMass, _strainStart) > 0.35f) { Launch(hand, palm); } } else { if (_tetherTime < 0.08f) { return; } if (!_winding) { if (!Flicked(palm, worldCenterOfMass)) { return; } _winding = true; _peak = 0f; _windTime = 0f; } float magnitude = ((Vector3)(ref _vel)).magnitude; _windTime += dt; if (GloveSettings.ForcePull && magnitude >= _peak && _windTime < 0.1f) { _peak = magnitude; return; } _peak = Mathf.Max(_peak, magnitude); if (GloveManager.FusionAvailable && !GloveFusion.CanMove(((Component)rb).gameObject)) { _ownTimer -= dt; if (_ownTimer <= 0f) { _ownTimer = 0.3f; GloveFusion.TakeOwnership(((Component)rb).gameObject); } } else { _power = ForceScale(_peak); Launch(hand, palm); } } } private static float ForceScale(float flick) { if (!GloveSettings.ForcePull) { return 1f; } float num = flick / Mathf.Max(0.1f, GloveSettings.FlickSpeed); return Mathf.Clamp(1f - 0.3f * GloveSettings.ForceSens * (num - 1.5f), 0.7f, 1.3f); } private bool Flicked(Vector3 palm, Vector3 at) { //IL_0017: 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_0024: Unknown result type (might be due to invalid IL or missing references) //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_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector3)(ref _vel)).magnitude; if (magnitude < GloveSettings.FlickSpeed) { return false; } Vector3 val = _vel / magnitude; Vector3 val2 = palm - at; Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Dot(val, normalized); if (!(num > 0.2f)) { if (val.y > 0.5f) { return num > -0.2f; } return false; } return true; } private static Vector3 Gravity(Rigidbody rb) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!rb.useGravity) { return Vector3.zero; } return Physics.gravity; } private static Vector3 CatchPoint(Vector3 palm) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return palm + Vector3.up * 0.06f; } private static Vector3 StepVelocity(Vector3 v, Vector3 gravity, float drag, float dt) { //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) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return (v + gravity * dt) * Mathf.Clamp01(1f - drag * dt); } private static Vector3 Solve(Vector3 from, Vector3 to, float time, Vector3 gravity, float drag) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004b: 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_0052: 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_005d: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) float fixedDeltaTime = Time.fixedDeltaTime; int num = Mathf.Max(1, Mathf.RoundToInt(time / fixedDeltaTime)); float num2 = Mathf.Clamp01(1f - drag * fixedDeltaTime); float num3 = 1f; float num4 = 0f; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; for (int i = 0; i < num; i++) { num3 *= num2; val = (val + gravity * fixedDeltaTime) * num2; num4 += num3 * fixedDeltaTime; val2 += val * fixedDeltaTime; } if (num4 < 0.01f) { num4 = 0.01f; } return (to - from - val2) / num4; } private void GatherBodies(Rigidbody rb) { _bodies.Clear(); try { MarrowEntity componentInParent = ((Component)rb).GetComponentInParent<MarrowEntity>(); if ((Object)(object)componentInParent != (Object)null) { foreach (MarrowBody item in (Il2CppArrayBase<MarrowBody>)(object)componentInParent.Bodies) { if (!((Object)(object)item == (Object)null)) { Rigidbody rigidbody = item._rigidbody; if ((Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic) { _bodies.Add(rigidbody); } } } } } catch { } if (_bodies.Count == 0) { _bodies.Add(rb); } } private void SetVelocity(Vector3 v) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _bodies.Count; i++) { try { if ((Object)(object)_bodies[i] != (Object)null) { _bodies[i].velocity = v; } } catch { } } } private void Launch(Hand hand, Vector3 palm) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00af: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e3: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) Rigidbody rb = _rb; Vector3 worldCenterOfMass = rb.worldCenterOfMass; Vector3 val = CatchPoint(palm); float num = Vector3.Distance(worldCenterOfMass, val); float num2 = Mathf.Clamp01(rb.mass / Mathf.Max(1f, GloveSettings.MaxMass)); _flightT = Mathf.Clamp(0.38f + num * 0.06f, 0.45f, 1.15f) / Mathf.Max(0.3f, GloveSettings.FlightSpeed) * (1f + 0.3f * num2) * _power; _gravity = Gravity(rb); _drag = rb.drag; _kick = Solve(worldCenterOfMass, val, _flightT, _gravity, _drag); GatherBodies(rb); rb.WakeUp(); SetVelocity(_kick); rb.angularVelocity += Random.insideUnitSphere * 2.5f; _launchFrom = worldCenterOfMass; _launchSpeed = ((Vector3)(ref _kick)).magnitude; _cruise = Mathf.Max(3f, num / _flightT); _t = 0f; _steps = 0; _freed = false; _homing = GloveSettings.GravityPull; _strain = false; _state = State.Flight; Rumble(1f, 0.04f); GloveSound.SetBeam(_isLeft, active: false, palm); GloveSound.Play("pull", _isLeft, palm); _fx.Arc(show: false, default(Vector3), default(Vector3), default(Color), 0f, taut: false); _fx.Crosshair(show: false, default(Vector3), default(Vector3), default(Color), locked: false); _fx.Outline(null); _fx.TrailStart(worldCenterOfMass, GloveFx.Accent()); } private void StrainTick(Hand hand) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0030: 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) Rigidbody rb = _rb; Vector3 val = CatchPoint(Palm(hand)) - rb.worldCenterOfMass; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { rb.AddForce(((Vector3)(ref val)).normalized * (rb.mass * 18f), (ForceMode)0); } } private void FlightTick(Hand hand, float dt) { //IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) Rigidbody rb = _rb; _t += dt; _steps++; if (_steps <= 4) { _kick = StepVelocity(_kick, _gravity, _drag, dt); SetVelocity(_kick); } else if (_freed) { Home(hand, rb, dt); } else { if (_steps < 10) { return; } if (Vector3.Distance(rb.worldCenterOfMass, _launchFrom) >= _launchSpeed * _t * 0.3f) { _freed = true; return; } _fx.TrailStop(); if (!_held) { Cancel(hand); return; } _state = State.Tethered; _strain = true; _strainStart = rb.worldCenterOfMass; _humTimer = 0f; } } private void Home(Hand hand, Rigidbody rb, float dt) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_001d: 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_0062: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (!_homing) { return; } Vector3 worldCenterOfMass = rb.worldCenterOfMass; Vector3 val = CatchPoint(Palm(hand)); if (Vector3.Distance(worldCenterOfMass, val) <= 1.22f || _t > 6f) { _homing = false; _flightT = Mathf.Max(_flightT, _t + 0.35f); return; } float time = Mathf.Max(0.05f, Vector3.Distance(worldCenterOfMass, val) / _cruise); Vector3 val2 = Vector3.ClampMagnitude(Solve(worldCenterOfMass, val, time, _gravity, _drag) - rb.velocity, 60f * dt); for (int i = 0; i < _bodies.Count; i++) { try { if ((Object)(object)_bodies[i] != (Object)null) { Rigidbody obj = _bodies[i]; obj.velocity += val2; } } catch { } } } private bool TimedOut() { if (!_homing) { return _t > _flightT + 0.45f; } return _t > 6.5f; } private void Flight(Hand hand, Vector3 palm) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) //IL_0088: 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_003d: 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) //IL_0075: 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) Rigidbody rb = _rb; _fx.TrailMove(rb.worldCenterOfMass); if (!GloveSettings.HoldToCatch) { if (!_held) { Unlock(hand); } if (!HandEmpty(hand)) { Thump(rb.mass, palm); Cancel(hand); } else if (TimedOut()) { Cancel(hand); } } else if (TimedOut() || !HandEmpty(hand)) { Cancel(hand); } else { Vector3 val; try { val = rb.ClosestPointOnBounds(palm); } catch { val = rb.worldCenterOfMass; } if (!(Vector3.Distance(palm, val) > GloveSettings.CatchRadius) && _held) { Catch(hand, palm); } } } private void Thump(float mass, Vector3 palm) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(mass / 8f); Rumble(0.5f + 0.5f * num, 0.05f + 0.1f * num); GloveSound.Play("catch", _isLeft, palm, 0.45f + 0.25f * num); } private void Catch(Hand hand, Vector3 palm) { //IL_000d: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0067: Unknown result type (might be due to invalid IL or missing references) Rigidbody? rb = _rb; float mass = rb.mass; Grip val = PickGrip(rb, palm); for (int i = 0; i < _bodies.Count; i++) { try { if (!((Object)(object)_bodies[i] == (Object)null)) { Rigidbody obj = _bodies[i]; obj.velocity *= 0.25f; Rigidbody obj2 = _bodies[i]; obj2.angularVelocity *= 0.25f; } } catch { } } Cancel(hand); if ((Object)(object)val != (Object)null) { try { if (GloveManager.FusionAvailable) { GloveFusion.Attach(val, hand); } else { val.OnGrabConfirm(hand, true); } } catch (Exception ex) { MelonLogger.Warning("[QuickGloves] catch: " + ex.Message); } } Thump(mass, palm); } private static Grip? PickGrip(Rigidbody rb, Vector3 palm) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) try { MarrowEntity componentInParent = ((Component)rb).GetComponentInParent<MarrowEntity>(); GameObject val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)rb).gameObject); Gun componentInChildren = val.GetComponentInChildren<Gun>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.triggerGrip != (Object)null) { return componentInChildren.triggerGrip; } Grip result = null; float num = float.MaxValue; foreach (Grip componentsInChild in val.GetComponentsInChildren<Grip>(false)) { if (!((Object)(object)componentsInChild == (Object)null) && !componentsInChild.IsInteractionDisabled && !componentsInChild.HasAttachedHands()) { Vector3 val2 = ((Component)componentsInChild).transform.position - palm; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = componentsInChild; } } } return result; } catch { return null; } } private bool Alive() { try { return (Object)(object)_rb != (Object)null && (Object)(object)((Component)_rb).gameObject != (Object)null && ((Component)_rb).gameObject.activeInHierarchy; } catch { return false; } } private void Cancel(Hand? hand) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) Unlock(hand); _state = State.Idle; _rb = null; _rbId = 0; _strain = false; _winding = false; _scanTimer = 0f; _bodies.Clear(); _fx.Hide(); GloveSound.SetBeam(_isLeft, active: false, Vector3.zero); } private void Lock(Hand hand) { if (_grabLocked) { return; } try { hand.GrabLock = true; _grabLocked = true; } catch { } } private void Unlock(Hand? hand) { if (!_grabLocked) { return; } _grabLocked = false; try { if ((Object)(object)hand != (Object)null) { hand.GrabLock = false; } } catch { } } private static Vector3 Palm(Hand hand) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_002a: Unknown result type (might be due to invalid IL or missing references) try { Transform palmPositionTransform = hand.palmPositionTransform; if ((Object)(object)palmPositionTransform != (Object)null) { return palmPositionTransform.position; } } catch { } return ((Component)hand).transform.position; } private static bool HandEmpty(Hand hand) { try { return (Object)(object)hand.m_CurrentAttachedGO == (Object)null; } catch { return true; } } private static bool NearSomething(Hand hand) { try { return (Object)(object)hand.HoveringReceiver != (Object)null; } catch { return false; } } private void Rumble(float amp, float dur) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!GloveSettings.Haptics) { return; } try { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)(_isLeft ? 4 : 5)); if (((InputDevice)(ref deviceAtXRNode)).isValid) { ((InputDevice)(ref deviceAtXRNode)).SendHapticImpulse(0u, Mathf.Clamp01(amp * GloveSettings.HapticPower), dur); } } catch { } } } public static class GloveManager { private static GloveHand? _left; private static GloveHand? _right; public static bool FusionAvailable; private static bool Ready { get { if (Player.ControllersExist && Player.HandsExist) { return (Object)(object)Player.PhysicsRig != (Object)null; } return false; } } public static void OnLevelLoaded() { _left?.Reset(); _right?.Reset(); } private static void Ensure() { if (_left == null) { _left = new GloveHand(isLeft: true); _right = new GloveHand(isLeft: false); _left.Other = _right; _right.Other = _left; } } public static void OnUpdate() { if (!GloveSettings.Enabled || !Ready) { _left?.Disable(); _right?.Disable(); return; } Ensure(); if (GloveSettings.RightHand) { _right.Update(); } else { _right.Disable(); } if (GloveSettings.LeftHand) { _left.Update(); } else { _left.Disable(); } } public static void OnFixedUpdate() { if (GloveSettings.Enabled && _left != null && Ready) { if (GloveSettings.RightHand) { _right.FixedTick(); } if (GloveSettings.LeftHand) { _left.FixedTick(); } } } } public static class GloveSettings { private static MelonPreferences_Category _cat; private static MelonPreferences_Entry<bool> _enabled; private static MelonPreferences_Entry<bool> _leftHand; private static MelonPreferences_Entry<bool> _rightHand; private static MelonPreferences_Entry<bool> _useTrigger; private static MelonPreferences_Entry<bool> _holdToCatch; private static MelonPreferences_Entry<float> _range; private static MelonPreferences_Entry<float> _maxMass; private static MelonPreferences_Entry<float> _flickSpeed; private static MelonPreferences_Entry<float> _flightSpeed; private static MelonPreferences_Entry<bool> _gravityPull; private static MelonPreferences_Entry<bool> _forcePull; private static MelonPreferences_Entry<float> _forceSens; private static MelonPreferences_Entry<float> _catchRadius; private static MelonPreferences_Entry<float> _aimRadius; private static MelonPreferences_Entry<bool> _showCrosshair; private static MelonPreferences_Entry<bool> _showBeam; private static MelonPreferences_Entry<bool> _haptics; private static MelonPreferences_Entry<float> _hapticPower; private static MelonPreferences_Entry<bool> _sounds; private static MelonPreferences_Entry<float> _soundVolume; private static MelonPreferences_Entry<bool> _showArc; private static MelonPreferences_Entry<bool> _showOutline; private static MelonPreferences_Entry<bool> _showTrail; public static bool Enabled { get { return _enabled.Value; } set { _enabled.Value = value; Save(); } } public static bool LeftHand { get { return _leftHand.Value; } set { _leftHand.Value = value; Save(); } } public static bool RightHand { get { return _rightHand.Value; } set { _rightHand.Value = value; Save(); } } public static bool UseTrigger { get { return _useTrigger.Value; } set { _useTrigger.Value = value; Save(); } } public static bool HoldToCatch { get { return _holdToCatch.Value; } set { _holdToCatch.Value = value; Save(); } } public static float Range { get { return _range.Value; } set { _range.Value = value; Save(); } } public static float MaxMass { get { return _maxMass.Value; } set { _maxMass.Value = value; Save(); } } public static float FlickSpeed { get { return _flickSpeed.Value; } set { _flickSpeed.Value = value; Save(); } } public static float FlightSpeed { get { return _flightSpeed.Value; } set { _flightSpeed.Value = value; Save(); } } public static bool GravityPull { get { return _gravityPull.Value; } set { _gravityPull.Value = value; Save(); } } public static bool ForcePull { get { return _forcePull.Value; } set { _forcePull.Value = value; Save(); } } public static float ForceSens { get { return _forceSens.Value; } set { _forceSens.Value = value; Save(); } } public static float CatchRadius { get { return _catchRadius.Value; } set { _catchRadius.Value = value; Save(); } } public static float AimRadius { get { return _aimRadius.Value; } set { _aimRadius.Value = value; Save(); } } public static bool ShowCrosshair { get { return _showCrosshair.Value; } set { _showCrosshair.Value = value; Save(); } } public static bool ShowBeam { get { return _showBeam.Value; } set { _showBeam.Value = value; Save(); } } public static bool Haptics { get { return _haptics.Value; } set { _haptics.Value = value; Save(); } } public static float HapticPower { get { return _hapticPower.Value; } set { _hapticPower.Value = value; Save(); } } public static bool Sounds { get { return _sounds.Value; } set { _sounds.Value = value; Save(); } } public static float SoundVolume { get { return _soundVolume.Value; } set { _soundVolume.Value = value; Save(); } } public static bool ShowArc { get { return _showArc.Value; } set { _showArc.Value = value; Save(); } } public static bool ShowOutline { get { return _showOutline.Value; } set { _showOutline.Value = value; Save(); } } public static bool ShowTrail { get { return _showTrail.Value; } set { _showTrail.Value = value; Save(); } } public static void Initialize() { _cat = MelonPreferences.CreateCategory("QuickGloves"); _enabled = _cat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _leftHand = _cat.CreateEntry<bool>("LeftHand", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _rightHand = _cat.CreateEntry<bool>("RightHand", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _useTrigger = _cat.CreateEntry<bool>("UseTrigger", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _holdToCatch = _cat.CreateEntry<bool>("HoldToCatch", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _range = _cat.CreateEntry<float>("Range", 12f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _maxMass = _cat.CreateEntry<float>("MaxMass", 25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _flickSpeed = _cat.CreateEntry<float>("FlickSpeed", 1.4f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _flightSpeed = _cat.CreateEntry<float>("FlightSpeed", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _gravityPull = _cat.CreateEntry<bool>("GravityPull", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _forcePull = _cat.CreateEntry<bool>("ForcePull", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _forceSens = _cat.CreateEntry<float>("ForceSens", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _catchRadius = _cat.CreateEntry<float>("CatchRadius", 0.22f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _aimRadius = _cat.CreateEntry<float>("AimRadius", 0.3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _showCrosshair = _cat.CreateEntry<bool>("ShowCrosshair", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _showBeam = _cat.CreateEntry<bool>("ShowBeam", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _haptics = _cat.CreateEntry<bool>("Haptics", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _hapticPower = _cat.CreateEntry<float>("HapticPower", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _sounds = _cat.CreateEntry<bool>("Sounds", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _soundVolume = _cat.CreateEntry<float>("SoundVolume", 0.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _showArc = _cat.CreateEntry<bool>("ShowArc", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _showOutline = _cat.CreateEntry<bool>("ShowOutline", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _showTrail = _cat.CreateEntry<bool>("ShowTrail", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } private static void Save() { _cat.SaveToFile(false); } } public static class GloveSound { public const string Target = "target"; public const string Lock = "lock"; public const string Pull = "pull"; public const string Catch = "catch"; public const string Cancel = "cancel"; public const string Beam = "beam"; private static readonly string[] Names = new string[6] { "target", "lock", "pull", "catch", "cancel", "beam" }; private static readonly string[] Exts = new string[3] { ".wav", ".ogg", ".mp3" }; private static string _dir = ""; private static readonly Dictionary<string, List<AudioClip>> _clips = new Dictionary<string, List<AudioClip>>(); private static bool _loaded; private static AudioSource? _shotL; private static AudioSource? _shotR; private static AudioSource? _loopL; private static AudioSource? _loopR; private static bool _apiChecked; private static MethodInfo? _loadMethod; public static void Initialize() { try { _dir = Path.Combine(MelonEnvironment.UserDataDirectory, "QuickGloves", "Sounds"); Directory.CreateDirectory(_dir); } catch (Exception ex) { MelonLogger.Warning("[QuickGloves] sound init: " + ex.Message); } } public static void Reload() { _clips.Clear(); _loaded = false; EnsureLoaded(); } public static void Play(string name, bool isLeft, Vector3 pos, float volume = 1f) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!GloveSettings.Sounds) { return; } try { EnsureBuilt(); EnsureLoaded(); AudioSource val = (isLeft ? _shotL : _shotR); if (!((Object)(object)val == (Object)null) && _clips.TryGetValue(name, out List<AudioClip> value) && value.Count != 0) { AudioClip val2 = value[Random.Range(0, value.Count)]; if (!((Object)(object)val2 == (Object)null)) { ((Component)val).transform.position = pos; val.PlayOneShot(val2, Mathf.Clamp01(GloveSettings.SoundVolume * volume)); } } } catch { } } public static void SetBeam(bool isLeft, bool active, Vector3 pos, bool strained = false) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) try { if (!GloveSettings.Sounds) { active = false; } if (!active) { AudioSource val = (isLeft ? _loopL : _loopR); if ((Object)(object)val != (Object)null && val.isPlaying) { val.Stop(); } return; } EnsureBuilt(); EnsureLoaded(); AudioSource val2 = (isLeft ? _loopL : _loopR); if (!((Object)(object)val2 == (Object)null) && _clips.TryGetValue("beam", out List<AudioClip> value) && value.Count != 0) { ((Component)val2).transform.position = pos; val2.volume = Mathf.Clamp01(GloveSettings.SoundVolume * (strained ? 0.5f : 0.3f)); val2.pitch = (strained ? 1.3f : 1f); if (!val2.isPlaying) { val2.clip = value[0]; val2.Play(); } } } catch { } } private static void EnsureBuilt() { if ((Object)(object)_shotL == (Object)null) { _shotL = MakeSource("[QuickGloves] SFX L", loop: false); } if ((Object)(object)_shotR == (Object)null) { _shotR = MakeSource("[QuickGloves] SFX R", loop: false); } if ((Object)(object)_loopL == (Object)null) { _loopL = MakeSource("[QuickGloves] Beam L", loop: true); } if ((Object)(object)_loopR == (Object)null) { _loopR = MakeSource("[QuickGloves] Beam R", loop: true); } } private static AudioSource MakeSource(string name, bool loop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject(name); Object.DontDestroyOnLoad((Object)val); AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.loop = loop; obj.spatialBlend = 1f; obj.minDistance = 1f; obj.maxDistance = 25f; return obj; } private static void EnsureLoaded() { if (_loaded) { return; } _loaded = true; int num = 0; string[] names = Names; foreach (string text in names) { List<AudioClip> list = new List<AudioClip>(); try { foreach (string item in from p in Directory.GetFiles(_dir) orderby p select p) { string text2 = Path.GetFileNameWithoutExtension(item).ToLowerInvariant(); string value = Path.GetExtension(item).ToLowerInvariant(); if (Exts.Contains(value) && (!(text2 != text) || text2.StartsWith(text + "_"))) { AudioClip val = Load(item); if (!((Object)(object)val == (Object)null)) { ((Object)val).hideFlags = (HideFlags)32; list.Add(val); } } } } catch { } _clips[text] = list; num += list.Count; } MelonLogger.Msg($"[QuickGloves] {num} sounds loaded"); } private static AudioClip? Load(string path) { try { AudioClip val = TryAudioImportLib(path); if ((Object)(object)val != (Object)null) { return val; } if (path.EndsWith(".wav", StringComparison.OrdinalIgnoreCase)) { return ParseWav(File.ReadAllBytes(path), Path.GetFileNameWithoutExtension(path)); } } catch (Exception ex) { MelonLogger.Warning("[QuickGloves] sound load: " + ex.Message); } return null; } private static AudioClip? TryAudioImportLib(string path) { try { if (!_apiChecked) { _apiChecked = true; _loadMethod = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "AudioImportLib")?.GetType("AudioImportLib.API")?.GetMethod("LoadAudioClip", BindingFlags.Static | BindingFlags.Public); } if (_loadMethod == null) { return null; } object? obj = _loadMethod.Invoke(null, new object[2] { path, true }); return (AudioClip?)((obj is AudioClip) ? obj : null); } catch { return null; } } private static AudioClip? ParseWav(byte[] data, string clipName) { if (data.Length < 12 || data[0] != 82 || data[1] != 73 || data[2] != 70 || data[3] != 70) { return null; } int num = 1; int num2 = 44100; int num3 = 16; byte[] array = null; int num4 = 12; while (num4 + 8 <= data.Length) { char c = (char)data[num4]; char c2 = (char)data[num4 + 1]; char c3 = (char)data[num4 + 2]; char c4 = (char)data[num4 + 3]; int num5 = BitConverter.ToInt32(data, num4 + 4); int num6 = num4 + 8; if (num6 + num5 > data.Length) { num5 = data.Length - num6; } if (c == 'f' && c2 == 'm' && c3 == 't' && c4 == ' ') { num = BitConverter.ToInt16(data, num6 + 2); num2 = BitConverter.ToInt32(data, num6 + 4); num3 = BitConverter.ToInt16(data, num6 + 14); } else if (c == 'd' && c2 == 'a' && c3 == 't' && c4 == 'a') { array = new byte[num5]; Array.Copy(data, num6, array, 0, num5); } num4 = num6 + num5 + num5 % 2; } if (array == null || array.Length == 0) { return null; } int num7 = Mathf.Max(1, num3 / 8); int num8 = array.Length / num7; float[] array2 = new float[num8]; switch (num3) { case 8: { for (int j = 0; j < num8; j++) { array2[j] = (float)(array[j] - 128) / 128f; } break; } case 16: { for (int k = 0; k < num8; k++) { array2[k] = (float)BitConverter.ToInt16(array, k * 2) / 32768f; } break; } case 32: { for (int i = 0; i < num8; i++) { array2[i] = (float)BitConverter.ToInt32(array, i * 4) / 2.1474836E+09f; } break; } default: return null; } AudioClip obj = AudioClip.Create(clipName, num8 / Mathf.Max(1, num), num, num2, false); obj.SetData(Il2CppStructArray<float>.op_Implicit(array2), 0); return obj; } } public class QuickGlovesMod : MelonMod { public override void OnInitializeMelon() { GloveSettings.Initialize(); QuickModsTheme.Initialize(); GloveSound.Initialize(); Hooking.OnLevelLoaded += delegate { GloveManager.OnLevelLoaded(); }; if (MelonBase.FindMelon("LabFusion", "Lakatrazz") != null) { GloveManager.FusionAvailable = true; ((MelonBase)this).LoggerInstance.Msg("QuickGloves: Fusion sync active"); } SetupMenu(); ((MelonBase)this).LoggerInstance.Msg("QuickGloves loaded!"); } private static Page GetOrCreateQuickModsPage() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) object? data = AppDomain.CurrentDomain.GetData("QuickMods.RootPage"); Page val = (Page)((data is Page) ? data : null); if (val != null) { return val; } Page val2 = Page.Root.CreatePage("Quick Mods", new Color(0.35f, 0.27f, 0.9f), 0, true); AppDomain.CurrentDomain.SetData("QuickMods.RootPage", val2); return val2; } private static void SetupMenu() { //IL_0010: 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_0057: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) Page orCreateQuickModsPage = GetOrCreateQuickModsPage(); QuickModsTheme.BuildMenu(orCreateQuickModsPage); Page obj = orCreateQuickModsPage.CreatePage("QuickGloves", GloveFx.Orange, 0, true); obj.CreateBool("enabled", Color.white, GloveSettings.Enabled, (Action<bool>)delegate(bool v) { GloveSettings.Enabled = v; }); obj.CreateBool("left glove", Color.white, GloveSettings.LeftHand, (Action<bool>)delegate(bool v) { GloveSettings.LeftHand = v; }); obj.CreateBool("right glove", Color.white, GloveSettings.RightHand, (Action<bool>)delegate(bool v) { GloveSettings.RightHand = v; }); obj.CreateBool("lock with trigger (not grip)", Color.white, GloveSettings.UseTrigger, (Action<bool>)delegate(bool v) { GloveSettings.UseTrigger = v; }); Page obj2 = obj.CreatePage("aim", new Color(1f, 0.55f, 0.2f), 0, true); obj2.CreateBool("crosshair", Color.white, GloveSettings.ShowCrosshair, (Action<bool>)delegate(bool v) { GloveSettings.ShowCrosshair = v; }); obj2.CreateFloat("aim radius", Color.white, GloveSettings.AimRadius, 0.05f, 0.05f, 1f, (Action<float>)delegate(float v) { GloveSettings.AimRadius = v; }); obj2.CreateBool("view radius beam", Color.white, GloveSettings.ShowBeam, (Action<bool>)delegate(bool v) { GloveSettings.ShowBeam = v; }); Page obj3 = obj.CreatePage("pull", new Color(1f, 0.75f, 0.3f), 0, true); obj3.CreateFloat("range", Color.white, GloveSettings.Range, 1f, 3f, 30f, (Action<float>)delegate(float v) { GloveSettings.Range = v; }); obj3.CreateFloat("max item weight", Color.white, GloveSettings.MaxMass, 5f, 5f, 150f, (Action<float>)delegate(float v) { GloveSettings.MaxMass = v; }); obj3.CreateFloat("flick needed (lower = easier)", Color.white, GloveSettings.FlickSpeed, 0.1f, 0.5f, 4f, (Action<float>)delegate(float v) { GloveSettings.FlickSpeed = v; }); obj3.CreateFloat("flight speed", Color.white, GloveSettings.FlightSpeed, 0.1f, 0.5f, 2f, (Action<float>)delegate(float v) { GloveSettings.FlightSpeed = v; }); obj3.CreateBool("gravity pull (follows your hand)", Color.white, GloveSettings.GravityPull, (Action<bool>)delegate(bool v) { GloveSettings.GravityPull = v; }); obj3.CreateFunction("(lets go 4ft from your hand)", new Color(0.6f, 0.6f, 0.6f), (Action)delegate { }); obj3.CreateBool("pull depends on force", Color.white, GloveSettings.ForcePull, (Action<bool>)delegate(bool v) { GloveSettings.ForcePull = v; }); obj3.CreateFloat("force sensitivity", Color.white, GloveSettings.ForceSens, 0.1f, 0.2f, 3f, (Action<float>)delegate(float v) { GloveSettings.ForceSens = v; }); Page obj4 = obj.CreatePage("catch", new Color(0.5f, 0.9f, 0.6f), 0, true); obj4.CreateBool("hold to catch", Color.white, GloveSettings.HoldToCatch, (Action<bool>)delegate(bool v) { GloveSettings.HoldToCatch = v; }); obj4.CreateFunction("(off = let go and grab it yourself)", new Color(0.6f, 0.6f, 0.6f), (Action)delegate { }); obj4.CreateFloat("catch reach", Color.white, GloveSettings.CatchRadius, 0.02f, 0.1f, 0.5f, (Action<float>)delegate(float v) { GloveSettings.CatchRadius = v; }); Page obj5 = obj.CreatePage("haptics", new Color(0.4f, 0.8f, 1f), 0, true); obj5.CreateBool("haptics", Color.white, GloveSettings.Haptics, (Action<bool>)delegate(bool v) { GloveSettings.Haptics = v; }); obj5.CreateFloat("strength", Color.white, GloveSettings.HapticPower, 0.1f, 0.2f, 2f, (Action<float>)delegate(float v) { GloveSettings.HapticPower = v; }); Page obj6 = obj.CreatePage("sound", new Color(0.5f, 0.9f, 0.5f), 0, true); obj6.CreateBool("sounds", Color.white, GloveSettings.Sounds, (Action<bool>)delegate(bool v) { GloveSettings.Sounds = v; }); obj6.CreateFloat("volume", Color.white, GloveSettings.SoundVolume, 0.05f, 0f, 1f, (Action<float>)delegate(float v) { GloveSettings.SoundVolume = v; }); obj6.CreateFunction("reload sounds", Color.white, (Action)GloveSound.Reload); Page obj7 = obj.CreatePage("look", new Color(0.8f, 0.7f, 0.4f), 0, true); obj7.CreateBool("aim arc", Color.white, GloveSettings.ShowArc, (Action<bool>)delegate(bool v) { GloveSettings.ShowArc = v; }); obj7.CreateBool("item outline", Color.white, GloveSettings.ShowOutline, (Action<bool>)delegate(bool v) { GloveSettings.ShowOutline = v; }); obj7.CreateBool("pull trail", Color.white, GloveSettings.ShowTrail, (Action<bool>)delegate(bool v) { GloveSettings.ShowTrail = v; }); } public override void OnUpdate() { GloveManager.OnUpdate(); } public override void OnFixedUpdate() { GloveManager.OnFixedUpdate(); } } public static class QuickModsTheme { private const string ShareKey = "QuickMods.GlobalTheme"; private const string MenuKey = "QuickMods.GlobalThemeMenuBuilt"; private static MelonPreferences_Category _cat; private static MelonPreferences_Entry<bool> _useGlobal; private static MelonPreferences_Entry<float> _hue; private static MelonPreferences_Entry<float> _sat; private static MelonPreferences_Entry<bool> _forceQB; private static MelonPreferences_Entry<bool> _rainbow; private static MelonPreferences_Entry<float> _rainbowSpeed; public static bool UseGlobalTheme { get { return _useGlobal.Value; } set { _useGlobal.Value = value; Save(); } } public static float Hue { get { return _hue.Value; } set { _hue.Value = value; Save(); } } public static float Saturation { get { return _sat.Value; } set { _sat.Value = value; Save(); } } public static bool ForceQuickBeatsSync { get { return _forceQB.Value; } set { _forceQB.Value = value; Save(); } } public static Color GlobalColor => Color.HSVToRGB(Hue / 360f, Saturation, 1f); public static bool RainbowMode { get { return _rainbow.Value; } set { _rainbow.Value = value; Save(); } } public static float RainbowSpeed { get { return _rainbowSpeed.Value; } set { _rainbowSpeed.Value = value; Save(); } } public static Color RainbowColor => Color.HSVToRGB(Time.time * RainbowSpeed % 1f, 0.85f, 1f); public static Color ResolveAccent(Color modDefault, bool modThemeToSong, Func<Color?> qbGetter) { //IL_0007: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (RainbowMode) { return RainbowColor; } if (ForceQuickBeatsSync) { Color? val = SafeGet(qbGetter); if (val.HasValue) { return val.Value; } } if (UseGlobalTheme) { return GlobalColor; } if (modThemeToSong) { Color? val2 = SafeGet(qbGetter); if (val2.HasValue) { return val2.Value; } } return modDefault; } private static Color? SafeGet(Func<Color?> getter) { try { return getter?.Invoke(); } catch { return null; } } public static void Initialize() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (AppDomain.CurrentDomain.GetData("QuickMods.GlobalTheme") is object[] array && array.Length >= 7) { try { _cat = (MelonPreferences_