Decompiled source of BlinkBone v1.0.0

BlinkBone/BlinkBone.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BlinkBone;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(BlinkBoneMod), "BlinkBone", "1.0.0", "Ichigo", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BlinkBone;

public enum FireButton
{
	Trigger,
	Grip,
	AButton,
	BButton,
	ThumbClick
}
public enum AimAxis
{
	Forward,
	Back,
	Up,
	Down,
	Right,
	Left
}
public class BlinkBoneMod : MelonMod
{
	private class Aim
	{
		public bool PrevFire;

		public bool Aiming;

		public Vector3 Target;

		public Vector3 RingCenter;

		public Vector3 Normal;

		public bool Standable;

		public GameObject BeamGo;

		public GameObject RingGo;

		public LineRenderer Beam;

		public LineRenderer Ring;
	}

	private MelonPreferences_Category _cat;

	private MelonPreferences_Entry<bool> _eEnabled;

	private MelonPreferences_Entry<bool> _eRightHand;

	private MelonPreferences_Entry<bool> _eLeftHand;

	private MelonPreferences_Entry<float> _eMaxRange;

	private MelonPreferences_Entry<float> _eAirDash;

	private MelonPreferences_Entry<float> _eSurfaceOffset;

	private MelonPreferences_Entry<float> _eCooldown;

	private MelonPreferences_Entry<bool> _eKillMomentum;

	private MelonPreferences_Entry<bool> _ePreview;

	private MelonPreferences_Entry<bool> _eHaptics;

	private MelonPreferences_Entry<int> _eFireButton;

	private MelonPreferences_Entry<int> _eAimAxis;

	private MelonPreferences_Entry<float> _eRingRadius;

	private MelonPreferences_Entry<float> _eGlow;

	private MelonPreferences_Entry<float> _eBeamWidth;

	private readonly Aim _right = new Aim();

	private readonly Aim _left = new Aim();

	private float _lastBlink = -999f;

	private bool _wasReady = true;

	private Shader _glowShader;

	private static readonly Color Cyan = new Color(0.2f, 0.85f, 1f, 1f);

	private static readonly Color Green = new Color(0.3f, 1f, 0.45f, 1f);

	private static readonly Color Red = new Color(1f, 0.35f, 0.3f, 1f);

	private static readonly Color White = Color.white;

	public override void OnInitializeMelon()
	{
		SetupPrefs();
		try
		{
			SetupMenu();
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Error("BoneMenu setup failed: " + ex);
		}
		((MelonBase)this).LoggerInstance.Msg("BlinkBone 1.0.0 loaded. Hold to aim, release to blink.");
	}

	public override void OnDeinitializeMelon()
	{
		DestroyMarker(_right);
		DestroyMarker(_left);
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		ResetAim(_right);
		ResetAim(_left);
		_lastBlink = -999f;
	}

	private void SetupPrefs()
	{
		_cat = MelonPreferences.CreateCategory("BlinkBone");
		_eEnabled = _cat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eRightHand = _cat.CreateEntry<bool>("RightHand", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eLeftHand = _cat.CreateEntry<bool>("LeftHand", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eMaxRange = _cat.CreateEntry<float>("MaxRange", 30f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eAirDash = _cat.CreateEntry<float>("AirDashDist", 6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eSurfaceOffset = _cat.CreateEntry<float>("SurfaceOffset", 0.25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eCooldown = _cat.CreateEntry<float>("Cooldown", 0.6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eKillMomentum = _cat.CreateEntry<bool>("KillMomentum", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_ePreview = _cat.CreateEntry<bool>("ShowPreview", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eHaptics = _cat.CreateEntry<bool>("Haptics", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eFireButton = _cat.CreateEntry<int>("FireButton", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eAimAxis = _cat.CreateEntry<int>("AimAxis", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eRingRadius = _cat.CreateEntry<float>("RingRadius", 0.6f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eGlow = _cat.CreateEntry<float>("GlowIntensity", 2.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_eBeamWidth = _cat.CreateEntry<float>("BeamWidth", 0.02f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
	}

	private void SetupMenu()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0094: 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_00ee: 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_015c: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		Page obj = Page.Root.CreatePage("BlinkBone", Cyan, 0, true);
		obj.CreateBool("Enabled", Cyan, _eEnabled.Value, (Action<bool>)delegate(bool v)
		{
			_eEnabled.Value = v;
		});
		obj.CreateBool("Right Hand", Cyan, _eRightHand.Value, (Action<bool>)delegate(bool v)
		{
			_eRightHand.Value = v;
		});
		obj.CreateBool("Left Hand", Cyan, _eLeftHand.Value, (Action<bool>)delegate(bool v)
		{
			_eLeftHand.Value = v;
		});
		obj.CreateEnum("Fire Button", White, (Enum)(FireButton)_eFireButton.Value, (Action<Enum>)delegate(Enum e)
		{
			_eFireButton.Value = (int)(FireButton)(object)e;
		});
		obj.CreateEnum("Aim Axis", White, (Enum)(AimAxis)_eAimAxis.Value, (Action<Enum>)delegate(Enum e)
		{
			_eAimAxis.Value = (int)(AimAxis)(object)e;
		});
		obj.CreateFloat("Max Range", White, _eMaxRange.Value, 2f, 4f, 120f, (Action<float>)delegate(float v)
		{
			_eMaxRange.Value = v;
		});
		obj.CreateFloat("Air Dash Dist", White, _eAirDash.Value, 1f, 2f, 30f, (Action<float>)delegate(float v)
		{
			_eAirDash.Value = v;
		});
		obj.CreateFloat("Surface Offset", White, _eSurfaceOffset.Value, 0.05f, 0f, 1.5f, (Action<float>)delegate(float v)
		{
			_eSurfaceOffset.Value = v;
		});
		obj.CreateFloat("Cooldown (s)", White, _eCooldown.Value, 0.1f, 0f, 5f, (Action<float>)delegate(float v)
		{
			_eCooldown.Value = v;
		});
		obj.CreateBool("Kill Momentum", Green, _eKillMomentum.Value, (Action<bool>)delegate(bool v)
		{
			_eKillMomentum.Value = v;
		});
		obj.CreateBool("Show Preview", Green, _ePreview.Value, (Action<bool>)delegate(bool v)
		{
			_ePreview.Value = v;
		});
		obj.CreateBool("Haptics", Green, _eHaptics.Value, (Action<bool>)delegate(bool v)
		{
			_eHaptics.Value = v;
		});
		Page obj2 = obj.CreatePage("Marker", Cyan, 0, true);
		obj2.CreateFloat("Ring Radius", Cyan, _eRingRadius.Value, 0.05f, 0.1f, 3f, (Action<float>)delegate(float v)
		{
			_eRingRadius.Value = v;
		});
		obj2.CreateFloat("Glow Intensity", Cyan, _eGlow.Value, 0.5f, 1f, 8f, (Action<float>)delegate(float v)
		{
			_eGlow.Value = v;
		});
		obj2.CreateFloat("Beam Width", Cyan, _eBeamWidth.Value, 0.005f, 0.005f, 0.1f, (Action<float>)delegate(float v)
		{
			_eBeamWidth.Value = v;
		});
	}

	public override void OnUpdate()
	{
		if (_eEnabled == null || !_eEnabled.Value)
		{
			ResetAim(_right);
			ResetAim(_left);
			return;
		}
		if (!Player.HandsExist)
		{
			ResetAim(_right);
			ResetAim(_left);
			return;
		}
		bool flag = Ready();
		if (flag && !_wasReady && _eHaptics.Value)
		{
			Pulse(GetHand(right: true), 0.15f);
			Pulse(GetHand(right: false), 0.15f);
		}
		_wasReady = flag;
		if (_eRightHand.Value)
		{
			HandTick(_right, GetHand(right: true));
		}
		else
		{
			ResetAim(_right);
		}
		if (_eLeftHand.Value)
		{
			HandTick(_left, GetHand(right: false));
		}
		else
		{
			ResetAim(_left);
		}
	}

	private void HandTick(Aim aim, Hand hand)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hand == (Object)null)
		{
			ResetAim(aim);
			return;
		}
		bool flag = ReadFire(hand);
		if (flag)
		{
			aim.Aiming = true;
			ComputeTarget(hand, aim);
			if (_ePreview.Value)
			{
				DrawMarker(aim, hand);
			}
			else
			{
				HideMarker(aim);
			}
		}
		if (!flag && aim.PrevFire && aim.Aiming)
		{
			aim.Aiming = false;
			HideMarker(aim);
			if (Ready())
			{
				DoBlink(aim.Target, hand);
			}
			else if (_eHaptics.Value)
			{
				Pulse(hand, 0.4f);
			}
		}
		if (!flag)
		{
			aim.Aiming = false;
			HideMarker(aim);
		}
		aim.PrevFire = flag;
	}

	private void ComputeTarget(Hand hand, Aim aim)
	{
		//IL_0002: 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_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_0012: 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_008e: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00bf: 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_002a: 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_0041: 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_004b: 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_005a: 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_0069: 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_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)
		Vector3 origin = GetOrigin(hand);
		Vector3 aimDir = GetAimDir(hand);
		if (RaycastFiltered(origin, aimDir, _eMaxRange.Value, out var best))
		{
			aim.Target = ((RaycastHit)(ref best)).point + ((RaycastHit)(ref best)).normal * _eSurfaceOffset.Value;
			aim.RingCenter = ((RaycastHit)(ref best)).point + ((RaycastHit)(ref best)).normal * 0.02f;
			aim.Normal = ((RaycastHit)(ref best)).normal;
			aim.Standable = true;
		}
		else
		{
			Vector3 val = RootPos();
			aim.Target = val + ((Vector3)(ref aimDir)).normalized * _eAirDash.Value;
			aim.RingCenter = aim.Target;
			aim.Normal = Vector3.up;
			aim.Standable = false;
		}
	}

	private void DoBlink(Vector3 target, Hand hand)
	{
		//IL_0011: 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)
		RigManager rigManager = Player.RigManager;
		if ((Object)(object)rigManager == (Object)null)
		{
			return;
		}
		bool num = rigManager.Teleport(target, true);
		_lastBlink = Time.time;
		_wasReady = false;
		if (_eKillMomentum.Value)
		{
			Rigidbody pelvis = GetPelvis();
			if ((Object)(object)pelvis != (Object)null)
			{
				pelvis.velocity = Vector3.zero;
			}
		}
		if (_eHaptics.Value)
		{
			Pulse(hand, 0.7f);
		}
		if (!num)
		{
			((MelonBase)this).LoggerInstance.Warning("Teleport returned false (target may be invalid).");
		}
	}

	private void DrawMarker(Aim aim, Hand hand)
	{
		//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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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)
		EnsureMarker(aim);
		Color baseCol = ((!Ready()) ? Red : (aim.Standable ? Green : Cyan));
		float value = _eBeamWidth.Value;
		float value2 = _eGlow.Value;
		aim.Beam.loop = false;
		aim.Beam.startWidth = value;
		aim.Beam.endWidth = value;
		aim.Beam.positionCount = 2;
		aim.Beam.SetPosition(0, GetOrigin(hand));
		aim.Beam.SetPosition(1, aim.RingCenter);
		Tint(aim.Beam, baseCol, value2);
		((Renderer)aim.Beam).enabled = true;
		BuildRing(aim.Ring, aim.RingCenter, aim.Normal, _eRingRadius.Value, 48);
		aim.Ring.startWidth = value;
		aim.Ring.endWidth = value;
		Tint(aim.Ring, baseCol, value2);
		((Renderer)aim.Ring).enabled = true;
	}

	private void BuildRing(LineRenderer lr, Vector3 center, Vector3 normal, float radius, int segs)
	{
		//IL_0017: 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_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_001e: 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_0028: 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_004a: 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_004c: 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_0055: 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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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_0085: 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_0092: 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_009f: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((((Vector3)(ref normal)).sqrMagnitude < 1E-06f) ? Vector3.up : ((Vector3)(ref normal)).normalized);
		Vector3 val2 = Vector3.Cross(val, Vector3.forward);
		if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
		{
			val2 = Vector3.Cross(val, Vector3.right);
		}
		val2 = ((Vector3)(ref val2)).normalized;
		Vector3 val3 = Vector3.Cross(val, val2);
		Vector3 normalized = ((Vector3)(ref val3)).normalized;
		lr.loop = true;
		lr.positionCount = segs;
		for (int i = 0; i < segs; i++)
		{
			float num = (float)i / (float)segs * (float)Math.PI * 2f;
			Vector3 val4 = center + (val2 * Mathf.Cos(num) + normalized * Mathf.Sin(num)) * radius;
			lr.SetPosition(i, val4);
		}
	}

	private void Tint(LineRenderer lr, Color baseCol, float intensity)
	{
		//IL_0001: 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_0021: 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_0031: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		lr.startColor = baseCol;
		lr.endColor = baseCol;
		Material material = ((Renderer)lr).material;
		if (!((Object)(object)material == (Object)null))
		{
			Color val = default(Color);
			((Color)(ref val))..ctor(baseCol.r * intensity, baseCol.g * intensity, baseCol.b * intensity, baseCol.a);
			if (material.HasProperty("_BaseColor"))
			{
				material.SetColor("_BaseColor", val);
			}
			if (material.HasProperty("_Color"))
			{
				material.SetColor("_Color", val);
			}
			if (material.HasProperty("_TintColor"))
			{
				material.SetColor("_TintColor", val);
			}
			if (material.HasProperty("_EmissionColor"))
			{
				material.SetColor("_EmissionColor", val);
			}
		}
	}

	private Shader GlowShader()
	{
		if ((Object)(object)_glowShader != (Object)null)
		{
			return _glowShader;
		}
		string[] array = new string[6] { "Sprites/Default", "Universal Render Pipeline/Particles/Unlit", "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Universal Render Pipeline/Unlit", "Unlit/Color" };
		foreach (string text in array)
		{
			Shader val = Shader.Find(text);
			if ((Object)(object)val != (Object)null)
			{
				_glowShader = val;
				((MelonBase)this).LoggerInstance.Msg("Marker shader: " + text);
				break;
			}
		}
		if ((Object)(object)_glowShader == (Object)null)
		{
			((MelonBase)this).LoggerInstance.Warning("No marker shader found — line may be invisible.");
		}
		return _glowShader;
	}

	private LineRenderer NewLine(string name, out GameObject go)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		go = new GameObject(name);
		Object.DontDestroyOnLoad((Object)(object)go);
		LineRenderer val = go.AddComponent<LineRenderer>();
		val.useWorldSpace = true;
		val.numCapVertices = 4;
		val.numCornerVertices = 2;
		val.textureMode = (LineTextureMode)0;
		val.alignment = (LineAlignment)0;
		Shader val2 = GlowShader();
		if ((Object)(object)val2 != (Object)null)
		{
			((Renderer)val).material = new Material(val2);
		}
		return val;
	}

	private void EnsureMarker(Aim aim)
	{
		if ((Object)(object)aim.Beam == (Object)null)
		{
			aim.Beam = NewLine("BlinkBone_Beam", out aim.BeamGo);
		}
		if ((Object)(object)aim.Ring == (Object)null)
		{
			aim.Ring = NewLine("BlinkBone_Ring", out aim.RingGo);
		}
	}

	private void HideMarker(Aim aim)
	{
		if ((Object)(object)aim.Beam != (Object)null)
		{
			((Renderer)aim.Beam).enabled = false;
		}
		if ((Object)(object)aim.Ring != (Object)null)
		{
			((Renderer)aim.Ring).enabled = false;
		}
	}

	private void DestroyMarker(Aim aim)
	{
		if ((Object)(object)aim.BeamGo != (Object)null)
		{
			Object.Destroy((Object)(object)aim.BeamGo);
			aim.BeamGo = null;
			aim.Beam = null;
		}
		if ((Object)(object)aim.RingGo != (Object)null)
		{
			Object.Destroy((Object)(object)aim.RingGo);
			aim.RingGo = null;
			aim.Ring = null;
		}
	}

	private void ResetAim(Aim aim)
	{
		aim.Aiming = false;
		aim.PrevFire = false;
		HideMarker(aim);
	}

	private bool Ready()
	{
		return Time.time - _lastBlink >= _eCooldown.Value;
	}

	private Hand GetHand(bool right)
	{
		if (!right)
		{
			return Player.LeftHand;
		}
		return Player.RightHand;
	}

	private Vector3 RootPos()
	{
		//IL_0023: 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)
		RigManager rigManager = Player.RigManager;
		if (!((Object)(object)rigManager != (Object)null))
		{
			return GetOrigin(GetHand(right: true));
		}
		return ((Component)rigManager).transform.position;
	}

	private Rigidbody GetPelvis()
	{
		PhysicsRig physicsRig = Player.PhysicsRig;
		if ((Object)(object)physicsRig == (Object)null)
		{
			return null;
		}
		PhysTorso torso = physicsRig.torso;
		if ((Object)(object)torso == (Object)null)
		{
			return null;
		}
		return torso.rbPelvis;
	}

	private Vector3 GetOrigin(Hand hand)
	{
		//IL_0009: 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)
		if ((Object)(object)hand == (Object)null)
		{
			return Vector3.zero;
		}
		Transform val = hand.palmPositionTransform;
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)hand).transform;
		}
		return val.position;
	}

	private Vector3 GetAimDir(Hand hand)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_0064: 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_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)hand.palmPositionTransform != (Object)null) ? hand.palmPositionTransform : ((Component)hand).transform);
		return (Vector3)((AimAxis)_eAimAxis.Value switch
		{
			AimAxis.Forward => val.forward, 
			AimAxis.Back => -val.forward, 
			AimAxis.Up => val.up, 
			AimAxis.Down => -val.up, 
			AimAxis.Right => val.right, 
			AimAxis.Left => -val.right, 
			_ => val.forward, 
		});
	}

	private bool ReadFire(Hand hand)
	{
		switch ((FireButton)_eFireButton.Value)
		{
		case FireButton.Trigger:
			return hand.GetIndexButton();
		case FireButton.Grip:
		{
			BaseController controller4 = hand.Controller;
			if ((Object)(object)controller4 != (Object)null)
			{
				return controller4.GetSecondaryInteractionButton();
			}
			return false;
		}
		case FireButton.AButton:
		{
			BaseController controller2 = hand.Controller;
			if ((Object)(object)controller2 != (Object)null)
			{
				return controller2.GetAButton();
			}
			return false;
		}
		case FireButton.BButton:
		{
			BaseController controller3 = hand.Controller;
			if ((Object)(object)controller3 != (Object)null)
			{
				return controller3.GetBButton();
			}
			return false;
		}
		case FireButton.ThumbClick:
		{
			BaseController controller = hand.Controller;
			if ((Object)(object)controller != (Object)null)
			{
				return controller.GetThumbStick();
			}
			return false;
		}
		default:
			return hand.GetIndexButton();
		}
	}

	private void Pulse(Hand hand, float strength)
	{
		if (!((Object)(object)hand == (Object)null))
		{
			BaseController controller = hand.Controller;
			if ((Object)(object)controller != (Object)null)
			{
				controller.Haptic(strength);
			}
		}
	}

	private bool RaycastFiltered(Vector3 origin, Vector3 dir, float range, out RaycastHit best)
	{
		//IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_0069: 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)
		best = default(RaycastHit);
		Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(origin, dir, range);
		if (val == null || ((Il2CppArrayBase<RaycastHit>)(object)val).Length == 0)
		{
			return false;
		}
		float num = float.MaxValue;
		bool result = false;
		for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val).Length; i++)
		{
			RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
			Collider collider = ((RaycastHit)(ref val2)).collider;
			if (!((Object)(object)collider == (Object)null) && !IsOwnBody(((Component)collider).transform) && ((RaycastHit)(ref val2)).distance < num)
			{
				num = ((RaycastHit)(ref val2)).distance;
				best = val2;
				result = true;
			}
		}
		return result;
	}

	private bool IsOwnBody(Transform t)
	{
		if ((Object)(object)t == (Object)null)
		{
			return false;
		}
		RigManager rigManager = Player.RigManager;
		if ((Object)(object)rigManager == (Object)null)
		{
			return false;
		}
		return t.IsChildOf(((Component)rigManager).transform);
	}
}