using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GangBeastsMouseGrabber;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MouseDragMod), "MouseDragMod", "1.0.0", "Zooks", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MouseDragMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MouseDragMod")]
[assembly: AssemblyTitle("MouseDragMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GangBeastsMouseGrabber;
public class MouseDragMod : MelonMod
{
private struct FrozenData
{
public bool IsKinematic;
public float Drag;
public float AngularDrag;
}
private bool _isUnlocked;
private Camera _mainCam;
private Rigidbody _grabbedRb;
private SpringJoint _spring;
private float _depth;
private float _originalDrag;
private float _originalAngularDrag;
private List<GameObject> _outlineShells = new List<GameObject>();
private Material _outlineMat;
private Dictionary<Rigidbody, FrozenData> _frozenBodies = new Dictionary<Rigidbody, FrozenData>();
private LineRenderer _laserCore;
private LineRenderer _laserMid;
private LineRenderer _laserOuter;
private float _buzzTimer;
private Material _laserMat;
private const float CoreStartW = 0.03f;
private const float CoreEndW = 0.005f;
private const float MidStartW = 0.1f;
private const float MidEndW = 0.02f;
private const float OuterStartW = 0.3f;
private const float OuterEndW = 0.05f;
private Transform _localPlayerRoot;
private Transform _localPlayerHead;
private float _nextHeadSearchTime;
private float _springForce = 5000f;
private float _springDamper = 100f;
private const int LaserSegments = 12;
private const float BuzzSpeed = 80f;
private Rect _uiRect = new Rect(30f, 30f, 300f, 460f);
private bool _isDragging = false;
private Vector2 _dragOffset;
private bool _stylesInitialized = false;
private GUIStyle _titleStyle;
private GUIStyle _labelStyle;
private GUIStyle _headerLabelStyle;
private GUIStyle _buttonStyle;
private GUIStyle _sliderBgStyle;
private GUIStyle _sliderThumbStyle;
private GUIStyle _boxStyle;
private GUIStyle _headerBoxStyle;
private Texture2D _bgTex;
private Texture2D _headerTex;
private Texture2D _btnNormalTex;
private Texture2D _btnHoverTex;
private Texture2D _btnActiveTex;
private Texture2D _sliderBgTex;
private Texture2D _sliderThumbTex;
public override void OnUpdate()
{
try
{
CacheCamera();
HandleInput();
if (_isUnlocked && (Object)(object)_grabbedRb != (Object)null && (Object)(object)_spring != (Object)null)
{
UpdateGrabbedObject();
UpdateLaserBuzz();
}
}
catch (Exception ex)
{
MelonLogger.Error("Update failed: " + ex.Message);
ReleaseGrab();
}
}
public override void OnLateUpdate()
{
if (_isUnlocked)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
else
{
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
}
public override void OnGUI()
{
if (_isUnlocked)
{
if ((Object)(object)_bgTex == (Object)null)
{
_stylesInitialized = false;
}
GUI.depth = -1000;
InitializeUIStyles();
DrawUI();
}
}
private void HandleInput()
{
//IL_0082: 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_008b: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
if (Keyboard.current == null || Mouse.current == null)
{
return;
}
if (((ButtonControl)Keyboard.current.tabKey).wasPressedThisFrame)
{
ToggleModState();
}
if (!_isUnlocked)
{
return;
}
if (((ButtonControl)Keyboard.current.mKey).wasPressedThisFrame)
{
ToggleFreeze();
}
if (Mouse.current.leftButton.wasPressedThisFrame)
{
Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(val.x, (float)Screen.height - val.y);
if (!((Rect)(ref _uiRect)).Contains(val2))
{
TryGrab(val);
}
}
if (Mouse.current.leftButton.wasReleasedThisFrame)
{
ReleaseGrab();
}
}
private void ToggleModState()
{
_isUnlocked = !_isUnlocked;
PlayerInput[] array = Il2CppArrayBase<PlayerInput>.op_Implicit(Object.FindObjectsOfType<PlayerInput>());
PlayerInput[] array2 = array;
foreach (PlayerInput val in array2)
{
if ((Object)(object)val != (Object)null)
{
((Behaviour)val).enabled = !_isUnlocked;
}
}
if (_isUnlocked)
{
_localPlayerRoot = null;
_localPlayerHead = null;
FindLocalPlayerHead();
MelonLogger.Msg("Mod Unlocked.");
}
else
{
ReleaseGrab();
MelonLogger.Msg("Mod Locked.");
}
}
private void ToggleFreeze()
{
if ((Object)(object)_grabbedRb != (Object)null)
{
if (_frozenBodies.ContainsKey(_grabbedRb))
{
UnfreezeObject(_grabbedRb);
_grabbedRb.drag = 10f;
_grabbedRb.angularDrag = 10f;
}
else
{
FreezeObject(_grabbedRb);
ReleaseGrab(keepFrozen: true);
}
}
}
private void TryGrab(Vector2 mousePos)
{
//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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: 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)
if ((Object)(object)_mainCam == (Object)null)
{
return;
}
Ray val = _mainCam.ScreenPointToRay(Vector2.op_Implicit(mousePos));
RaycastHit[] array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val, 150f, -1, (QueryTriggerInteraction)1));
Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
RaycastHit[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
RaycastHit val2 = array2[i];
Rigidbody attachedRigidbody = ((RaycastHit)(ref val2)).collider.attachedRigidbody;
if (!((Object)(object)attachedRigidbody == (Object)null))
{
if (_frozenBodies.ContainsKey(attachedRigidbody))
{
UnfreezeObject(attachedRigidbody);
}
_grabbedRb = attachedRigidbody;
_depth = ((RaycastHit)(ref val2)).distance;
_originalDrag = attachedRigidbody.drag;
_originalAngularDrag = attachedRigidbody.angularDrag;
attachedRigidbody.isKinematic = false;
attachedRigidbody.drag = 10f;
attachedRigidbody.angularDrag = 10f;
_spring = ((Component)attachedRigidbody).gameObject.AddComponent<SpringJoint>();
((Joint)_spring).autoConfigureConnectedAnchor = false;
((Joint)_spring).anchor = ((Component)attachedRigidbody).transform.InverseTransformPoint(((RaycastHit)(ref val2)).point);
((Joint)_spring).connectedAnchor = ((RaycastHit)(ref val2)).point;
_spring.spring = _springForce * attachedRigidbody.mass;
_spring.damper = _springDamper * attachedRigidbody.mass;
_spring.maxDistance = 0f;
CreateLaser();
CreateOutline(attachedRigidbody);
break;
}
}
}
private void UpdateGrabbedObject()
{
//IL_0054: 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_00c6: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_grabbedRb == (Object)null || (Object)(object)_spring == (Object)null || (Object)(object)_mainCam == (Object)null || Mouse.current == null)
{
ReleaseGrab();
return;
}
float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
if (y > 0f)
{
_depth += 1.5f;
}
else if (y < 0f)
{
_depth -= 1.5f;
}
_depth = Mathf.Max(_depth, 2f);
Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
Ray val2 = _mainCam.ScreenPointToRay(Vector2.op_Implicit(val));
Vector3 point = ((Ray)(ref val2)).GetPoint(_depth);
_spring.spring = _springForce * _grabbedRb.mass;
_spring.damper = _springDamper * _grabbedRb.mass;
((Joint)_spring).connectedAnchor = point;
_grabbedRb.WakeUp();
}
private void ReleaseGrab(bool keepFrozen = false)
{
if ((Object)(object)_spring != (Object)null)
{
Object.Destroy((Object)(object)_spring);
}
DestroyLaser();
DestroyOutline();
if ((Object)(object)_grabbedRb != (Object)null && !keepFrozen)
{
try
{
_grabbedRb.drag = _originalDrag;
_grabbedRb.angularDrag = _originalAngularDrag;
}
catch
{
}
}
_spring = null;
_grabbedRb = null;
}
private void FreezeObject(Rigidbody rb)
{
//IL_005d: 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)
if (!((Object)(object)rb == (Object)null) && !_frozenBodies.ContainsKey(rb))
{
_frozenBodies[rb] = new FrozenData
{
IsKinematic = rb.isKinematic,
Drag = rb.drag,
AngularDrag = rb.angularDrag
};
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.isKinematic = true;
}
}
private void UnfreezeObject(Rigidbody rb)
{
if ((Object)(object)rb != (Object)null && _frozenBodies.TryGetValue(rb, out var value))
{
try
{
rb.isKinematic = value.IsKinematic;
rb.drag = value.Drag;
rb.angularDrag = value.AngularDrag;
}
catch
{
}
_frozenBodies.Remove(rb);
}
}
private void UnfreezeAll()
{
List<Rigidbody> list = new List<Rigidbody>(_frozenBodies.Keys);
foreach (Rigidbody item in list)
{
if ((Object)(object)item != (Object)null)
{
FrozenData frozenData = _frozenBodies[item];
try
{
item.isKinematic = frozenData.IsKinematic;
item.drag = frozenData.Drag;
item.angularDrag = frozenData.AngularDrag;
}
catch
{
}
}
}
_frozenBodies.Clear();
}
private void CreateOutline(Rigidbody rb)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
DestroyOutline();
Shader val = Shader.Find("Particles/Additive") ?? Shader.Find("Sprites/Default");
if ((Object)(object)val == (Object)null)
{
return;
}
_outlineMat = new Material(val);
_outlineMat.color = new Color(0.1f, 0.5f, 1f, 1f);
_outlineMat.renderQueue = 3000;
Renderer[] array = Il2CppArrayBase<Renderer>.op_Implicit(((Component)rb).GetComponentsInChildren<Renderer>(true));
Renderer[] array2 = array;
foreach (Renderer val2 in array2)
{
SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null);
if (val3 != null)
{
if (!((Object)(object)val3.sharedMesh == (Object)null))
{
CreateShell(((Component)val3).transform, val3.sharedMesh, Il2CppArrayBase<Transform>.op_Implicit((Il2CppArrayBase<Transform>)(object)val3.bones), val3.rootBone);
}
continue;
}
MeshRenderer val4 = (MeshRenderer)(object)((val2 is MeshRenderer) ? val2 : null);
if (val4 != null)
{
MeshFilter component = ((Component)val4).GetComponent<MeshFilter>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null))
{
CreateShell(((Component)val4).transform, component.sharedMesh, null, null);
}
}
}
}
private void CreateShell(Transform parent, Mesh mesh, Transform[] bones, Transform rootBone)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0020: 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_0051: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("OutlineShell");
val.transform.SetParent(parent, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = new Vector3(1.06f, 1.06f, 1.06f);
if (bones != null && bones.Length != 0)
{
SkinnedMeshRenderer val2 = val.AddComponent<SkinnedMeshRenderer>();
val2.sharedMesh = mesh;
val2.bones = Il2CppReferenceArray<Transform>.op_Implicit(bones);
val2.rootBone = rootBone;
((Renderer)val2).material = _outlineMat;
val2.updateWhenOffscreen = true;
((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val2).receiveShadows = false;
}
else
{
MeshFilter val3 = val.AddComponent<MeshFilter>();
val3.sharedMesh = mesh;
MeshRenderer val4 = val.AddComponent<MeshRenderer>();
((Renderer)val4).material = _outlineMat;
((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val4).receiveShadows = false;
}
_outlineShells.Add(val);
}
private void DestroyOutline()
{
foreach (GameObject outlineShell in _outlineShells)
{
if ((Object)(object)outlineShell != (Object)null)
{
Object.Destroy((Object)(object)outlineShell);
}
}
_outlineShells.Clear();
if ((Object)(object)_outlineMat != (Object)null)
{
Object.Destroy((Object)(object)_outlineMat);
_outlineMat = null;
}
}
private void CreateLaser()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
try
{
Shader val = Shader.Find("Particles/Additive") ?? Shader.Find("Sprites/Default");
if (!((Object)(object)val == (Object)null))
{
_laserMat = new Material(val);
_laserOuter = CreateLaserLayer("GlowO", 0.3f, 0.05f, new Color(0f, 0.2f, 1f, 0.15f));
_laserMid = CreateLaserLayer("GlowM", 0.1f, 0.02f, new Color(0.1f, 0.5f, 1f, 0.6f));
_laserCore = CreateLaserLayer("Core", 0.03f, 0.005f, new Color(0.8f, 1f, 1f, 1f));
_buzzTimer = 0f;
}
}
catch (Exception ex)
{
MelonLogger.Error("Laser failed: " + ex.Message);
}
}
private LineRenderer CreateLaserLayer(string name, float startW, float endW, Color color)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_001d: 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)
GameObject val = new GameObject(name);
LineRenderer val2 = val.AddComponent<LineRenderer>();
((Renderer)val2).material = _laserMat;
val2.startColor = color;
val2.endColor = color;
val2.startWidth = startW;
val2.endWidth = endW;
val2.positionCount = 12;
val2.useWorldSpace = true;
val2.numCornerVertices = 1;
val2.numCapVertices = 1;
return val2;
}
private void UpdateLaserBuzz()
{
//IL_005e: 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_0063: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_00bc: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_007d: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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)
if ((Object)(object)_laserCore == (Object)null || (Object)(object)_grabbedRb == (Object)null || (Object)(object)_spring == (Object)null)
{
return;
}
ResolvePlayerHead();
Vector3 val = (((Object)(object)_mainCam != (Object)null) ? ((Component)_mainCam).transform.position : Vector3.zero);
if ((Object)(object)_localPlayerHead != (Object)null)
{
val = _localPlayerHead.position + _localPlayerHead.up * 0.06f;
}
Vector3 val2 = ((Component)_grabbedRb).transform.TransformPoint(((Joint)_spring).anchor);
Vector3 val3 = val2 - val;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
Vector3 val4 = val + normalized * 0.12f;
Vector3 val5 = val2 - val4;
float magnitude = ((Vector3)(ref val5)).magnitude;
if (!(magnitude < 0.001f))
{
((Vector3)(ref val5)).Normalize();
_buzzTimer += Time.deltaTime * 80f;
Vector3 val6 = Vector3.Cross(val5, Vector3.up);
if (((Vector3)(ref val6)).sqrMagnitude < 0.001f)
{
val6 = Vector3.Cross(val5, Vector3.right);
}
((Vector3)(ref val6)).Normalize();
val3 = Vector3.Cross(val5, val6);
Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
float pulse = 0.9f + 0.1f * Mathf.Sin(_buzzTimer * 3f);
ApplyBuzz(_laserOuter, val4, val2, val6, normalized2, magnitude, 0.025f, pulse, 0.3f, 0.05f);
ApplyBuzz(_laserMid, val4, val2, val6, normalized2, magnitude, 0.015f, pulse, 0.1f, 0.02f);
ApplyBuzz(_laserCore, val4, val2, val6, normalized2, magnitude, 0.005f, pulse, 0.03f, 0.005f);
}
}
private void ApplyBuzz(LineRenderer line, Vector3 start, Vector3 end, Vector3 p1, Vector3 p2, float dist, float jitter, float pulse, float baseStartW, float baseEndW)
{
//IL_0003: 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_0025: 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_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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
line.SetPosition(0, start);
line.SetPosition(11, end);
for (int i = 1; i < 11; i++)
{
float num = (float)i / 11f;
Vector3 val = Vector3.Lerp(start, end, num);
float num2 = Mathf.Sin(num * (float)Math.PI);
float num3 = num2 * Mathf.Max(0.005f, dist * jitter);
float num4 = Mathf.Sin(_buzzTimer * 1.1f + (float)i * 5.3f) * 0.7f + Mathf.Sin(_buzzTimer * 3.1f + (float)i * 2.1f) * 0.3f;
float num5 = Mathf.Cos(_buzzTimer * 0.9f + (float)i * 4.7f) * 0.7f + Mathf.Cos(_buzzTimer * 2.7f + (float)i * 3.3f) * 0.3f;
line.SetPosition(i, val + (p1 * num4 + p2 * num5) * num3);
}
line.startWidth = baseStartW * pulse;
line.endWidth = baseEndW * pulse;
}
private void DestroyLaser()
{
DestroyLaserLayer(ref _laserOuter);
DestroyLaserLayer(ref _laserMid);
DestroyLaserLayer(ref _laserCore);
if ((Object)(object)_laserMat != (Object)null)
{
Object.Destroy((Object)(object)_laserMat);
_laserMat = null;
}
}
private void DestroyLaserLayer(ref LineRenderer lr)
{
if ((Object)(object)lr != (Object)null)
{
Object.Destroy((Object)(object)((Component)lr).gameObject);
}
lr = null;
}
private void CacheCamera()
{
if ((Object)(object)_mainCam == (Object)null || !((Behaviour)_mainCam).isActiveAndEnabled)
{
_mainCam = Camera.main;
}
}
private void ResolvePlayerHead()
{
if ((!((Object)(object)_localPlayerHead != (Object)null) || !((Component)_localPlayerHead).gameObject.activeInHierarchy) && Time.time > _nextHeadSearchTime)
{
FindLocalPlayerHead();
_nextHeadSearchTime = Time.time + 2f;
}
}
private void FindLocalPlayerHead()
{
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_mainCam == (Object)null)
{
return;
}
Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(Object.FindObjectsOfType<Rigidbody>());
if (array.Length == 0)
{
return;
}
Dictionary<Transform, List<Rigidbody>> dictionary = new Dictionary<Transform, List<Rigidbody>>();
Rigidbody[] array2 = array;
foreach (Rigidbody val in array2)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform == (Object)null) && !((Object)(object)((Component)val).transform.root == (Object)null) && !val.isKinematic)
{
Transform root = ((Component)val).transform.root;
if (!dictionary.ContainsKey(root))
{
dictionary[root] = new List<Rigidbody>();
}
dictionary[root].Add(val);
}
}
Transform val2 = null;
float num = float.MaxValue;
foreach (KeyValuePair<Transform, List<Rigidbody>> item in dictionary)
{
if (item.Value.Count >= 5)
{
Transform key = item.Key;
float num2 = Vector3.Distance(key.position, ((Component)_mainCam).transform.position);
if (num2 < num)
{
num = num2;
val2 = key;
}
}
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
_localPlayerRoot = val2;
_localPlayerHead = null;
string[] names = new string[11]
{
"Head", "head", "HEAD", "Head_", "head_", "HeadBone", "headBone", "Cranium", "Skull", "Helmet",
"Mask"
};
FindChildRecursiveName(val2, names, ref _localPlayerHead);
if (!((Object)(object)_localPlayerHead == (Object)null))
{
return;
}
float num3 = float.MinValue;
foreach (Rigidbody item2 in dictionary[val2])
{
float y = val2.InverseTransformPoint(((Component)item2).transform.position).y;
if (y > num3)
{
num3 = y;
_localPlayerHead = ((Component)item2).transform;
}
}
}
private void FindChildRecursiveName(Transform parent, string[] names, ref Transform found)
{
if ((Object)(object)found != (Object)null)
{
return;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
foreach (string value in names)
{
if (((Object)child).name.Contains(value))
{
found = child;
return;
}
}
FindChildRecursiveName(child, names, ref found);
if ((Object)(object)found != (Object)null)
{
break;
}
}
}
private void DrawUI()
{
//IL_0002: 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_0057: 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_00af: 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)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
GUI.Box(_uiRect, GUIContent.none, _boxStyle);
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref _uiRect)).x, ((Rect)(ref _uiRect)).y, ((Rect)(ref _uiRect)).width, 35f);
GUI.Box(val, GUIContent.none, _headerBoxStyle);
GUI.Label(val, "MouseDragMod v1.0.0", _titleStyle);
HandleWindowDrag(val);
float num = ((Rect)(ref _uiRect)).x + 20f;
float num2 = ((Rect)(ref _uiRect)).y + 50f;
float num3 = ((Rect)(ref _uiRect)).width - 40f;
GUI.Label(new Rect(num, num2, num3, 20f), "CONTROLS", _headerLabelStyle);
num2 += 22f;
GUI.Label(new Rect(num, num2, num3, 20f), "TAB : Toggle Menu", _labelStyle);
num2 += 18f;
GUI.Label(new Rect(num, num2, num3, 20f), "LMB : Grab / Release", _labelStyle);
num2 += 18f;
GUI.Label(new Rect(num, num2, num3, 20f), "Scroll : Push / Pull", _labelStyle);
num2 += 18f;
GUI.Label(new Rect(num, num2, num3, 20f), "M : Freeze/Unfreeze (Gmod)", _labelStyle);
num2 += 30f;
GUI.Label(new Rect(num, num2, num3, 20f), "STATUS", _headerLabelStyle);
num2 += 22f;
string text = (((Object)(object)_grabbedRb != (Object)null) ? ((Object)_grabbedRb).name : "None");
GUI.Label(new Rect(num, num2, num3, 20f), "Target: <color=#33A5FF>" + text + "</color>", _labelStyle);
num2 += 20f;
GUI.Label(new Rect(num, num2, num3, 20f), $"Frozen Objects: <color=#80CCFF>{_frozenBodies.Count}</color>", _labelStyle);
num2 += 20f;
GUI.Label(new Rect(num, num2, num3, 20f), "Tracking: <color=#00FF66>Player Eyes</color>", _labelStyle);
num2 += 35f;
GUI.Label(new Rect(num, num2, num3, 20f), $"Pull Strength: {Mathf.Round(_springForce)}", _labelStyle);
num2 += 22f;
_springForce = GUI.HorizontalSlider(new Rect(num, num2, num3, 10f), _springForce, 100f, 20000f, _sliderBgStyle, _sliderThumbStyle);
num2 += 30f;
GUI.Label(new Rect(num, num2, num3, 20f), $"Smoothing: {Mathf.Round(_springDamper)}", _labelStyle);
num2 += 22f;
_springDamper = GUI.HorizontalSlider(new Rect(num, num2, num3, 10f), _springDamper, 10f, 500f, _sliderBgStyle, _sliderThumbStyle);
num2 += 40f;
if (GUI.Button(new Rect(num, num2, num3, 32f), "Reset Settings", _buttonStyle))
{
_springForce = 5000f;
_springDamper = 100f;
}
num2 += 40f;
if (GUI.Button(new Rect(num, num2, num3, 32f), "Unfreeze All", _buttonStyle))
{
UnfreezeAll();
}
}
private void HandleWindowDrag(Rect titleBar)
{
//IL_0008: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
//IL_0090: 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)
Event current = Event.current;
if ((int)current.type == 0 && ((Rect)(ref titleBar)).Contains(current.mousePosition))
{
_isDragging = true;
_dragOffset = current.mousePosition - new Vector2(((Rect)(ref _uiRect)).x, ((Rect)(ref _uiRect)).y);
}
else if ((int)current.type == 1)
{
_isDragging = false;
}
if (_isDragging && (int)current.type == 3)
{
((Rect)(ref _uiRect)).x = current.mousePosition.x - _dragOffset.x;
((Rect)(ref _uiRect)).y = current.mousePosition.y - _dragOffset.y;
}
}
private void InitializeUIStyles()
{
//IL_0028: 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_0076: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: 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)
//IL_014e: Expected O, but got Unknown
//IL_014f: 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_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Expected O, but got Unknown
//IL_0251: 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)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: 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_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Expected O, but got Unknown
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Expected O, but got Unknown
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Expected O, but got Unknown
if (!_stylesInitialized)
{
_bgTex = MakeTex(1, 1, new Color(0.12f, 0.12f, 0.14f, 0.95f));
_headerTex = MakeTex(1, 1, new Color(0.15f, 0.45f, 0.9f, 1f));
_btnNormalTex = MakeTex(1, 1, new Color(0.2f, 0.2f, 0.22f, 1f));
_btnHoverTex = MakeTex(1, 1, new Color(0.28f, 0.28f, 0.32f, 1f));
_btnActiveTex = MakeTex(1, 1, new Color(0.15f, 0.15f, 0.17f, 1f));
_sliderBgTex = MakeTex(1, 1, new Color(0.05f, 0.05f, 0.05f, 1f));
_sliderThumbTex = MakeTex(1, 1, new Color(0.9f, 0.9f, 0.9f, 1f));
GUIStyle val = new GUIStyle();
val.normal.background = _bgTex;
val.stretchWidth = true;
val.stretchHeight = true;
_boxStyle = val;
GUIStyle val2 = new GUIStyle();
val2.normal.background = _headerTex;
val2.stretchWidth = true;
val2.stretchHeight = true;
_headerBoxStyle = val2;
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = 15,
fontStyle = (FontStyle)1
};
val3.normal.textColor = Color.white;
_titleStyle = val3;
GUIStyle val4 = new GUIStyle(GUI.skin.label)
{
fontSize = 13,
fontStyle = (FontStyle)1
};
val4.normal.textColor = new Color(0.4f, 0.7f, 1f);
_headerLabelStyle = val4;
GUIStyle val5 = new GUIStyle(GUI.skin.label)
{
fontSize = 13,
richText = true
};
val5.normal.textColor = new Color(0.85f, 0.85f, 0.85f);
_labelStyle = val5;
GUIStyle val6 = new GUIStyle(GUI.skin.button);
val6.normal.background = _btnNormalTex;
val6.normal.textColor = Color.white;
val6.hover.background = _btnHoverTex;
val6.hover.textColor = Color.white;
val6.active.background = _btnActiveTex;
val6.active.textColor = new Color(0.7f, 0.7f, 0.7f);
val6.fontSize = 14;
val6.fontStyle = (FontStyle)1;
val6.alignment = (TextAnchor)4;
val6.stretchWidth = true;
val6.stretchHeight = true;
_buttonStyle = val6;
GUIStyle val7 = new GUIStyle(GUI.skin.horizontalSlider);
val7.normal.background = _sliderBgTex;
val7.fixedHeight = 6f;
_sliderBgStyle = val7;
GUIStyle val8 = new GUIStyle(GUI.skin.horizontalSliderThumb);
val8.normal.background = _sliderThumbTex;
val8.fixedWidth = 14f;
val8.fixedHeight = 14f;
_sliderThumbStyle = val8;
_stylesInitialized = true;
}
}
private Texture2D MakeTex(int w, int h, Color col)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_001a: 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)
Texture2D val = new Texture2D(w, h, (TextureFormat)4, false);
Color[] array = (Color[])(object)new Color[w * h];
for (int i = 0; i < array.Length; i++)
{
array[i] = col;
}
val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
val.Apply();
return val;
}
}