Decompiled source of HandStabilizer v1.0.0

BepInEx\plugins\invent60-HandStabilizer\HandStabilizer.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite;
using Sodalite.Api;
using UnityEngine;
using UnityEngine.Rendering;
using Valve.VR;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("HandStabilizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HandStabilizer")]
[assembly: AssemblyTitle("HandStabilizer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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 HandStabilizer
{
	[BepInPlugin("h3vr.invent60.handstabilizer", "HandStabilizer", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HandStabilizerPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> CfgEnabled;

		internal static ConfigEntry<int> CfgMode;

		internal static ConfigEntry<float> CfgSmoothness;

		internal static ConfigEntry<float> CfgPosThreshold;

		internal static ConfigEntry<float> CfgAngThreshold;

		internal static ConfigEntry<float> CfgAttack;

		internal static ConfigEntry<float> CfgRelease;

		internal static ConfigEntry<bool> CfgDebug;

		private void Awake()
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master on/off. Toggle in wrist menu: Wrist > Hand Stabilizer section.\nPRESETS: Smoothness | Mode\n  1000m:    75 | 2\n  500m:     45 | 2\n  Action:   20 | 1 (PosThresh=0.08)");
			CfgMode = ((BaseUnityPlugin)this).Config.Bind<int>("Smoothing", "Mode", 2, "1=Classic 2=Adaptive");
			CfgSmoothness = ((BaseUnityPlugin)this).Config.Bind<float>("Smoothing", "Smoothness", 35f, "0=off, no cap. TC=(S/100)^2*0.5s. At 75: ~0.28s. At 100: 0.5s. At 200: 2s.");
			CfgPosThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Smoothing", "PositionThreshold", 0.08f, "Both modes: minimum linear velocity threshold (m/s).\nClassic: gate velocity. Adaptive: floor for self-calibrated bubble (0=pure self-calibrate).");
			CfgAngThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Smoothing", "AngularThreshold", 0.08f, "Both modes: minimum angular velocity threshold (rad/s).\nClassic: gate velocity. Adaptive: floor for self-calibrated angular bubble.");
			CfgAttack = ((BaseUnityPlugin)this).Config.Bind<float>("Classic", "AttackSeconds", 0.25f, "Classic + Adaptive: seconds to fade BACK INTO smoothing after hand stops.\nSet 0 for instant snap-on (useful for seeing exact smoothing boundary).");
			CfgRelease = ((BaseUnityPlugin)this).Config.Bind<float>("Classic", "ReleaseSeconds", 0.04f, "Classic + Adaptive: seconds to DROP smoothing when hand moves.\nSet 0 for instant snap-off.");
			CfgDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "AdaptiveOverlay", false, "Show raw/smooth/bubble debug spheres above each hand.\nWhite dot=raw. Blue dot=smoothed (hidden when smoothing off). Bubble=measured tremor sigma.");
			new Harmony("h3vr.invent60.handstabilizer").PatchAll(typeof(Patches));
			HSWristMenu.Init();
			Log.LogInfo((object)"[HandStabilizer] Loaded.");
		}
	}
	internal static class HSWristMenu
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ButtonClickEvent <>9__21_0;

			public static ButtonClickEvent <>9__21_1;

			public static ButtonClickEvent <>9__21_2;

			public static ButtonClickEvent <>9__21_3;

			public static ButtonClickEvent <>9__21_4;

			public static ButtonClickEvent <>9__21_5;

			public static ButtonClickEvent <>9__21_6;

			public static ButtonClickEvent <>9__21_7;

			public static ButtonClickEvent <>9__21_8;

			public static ButtonClickEvent <>9__21_9;

			public static ButtonClickEvent <>9__21_10;

			public static ButtonClickEvent <>9__21_11;

			public static ButtonClickEvent <>9__21_12;

			public static ButtonClickEvent <>9__21_13;

			internal void <Init>b__21_0(object s, ButtonClickEventArgs e)
			{
				HandStabilizerPlugin.CfgEnabled.Value = !HandStabilizerPlugin.CfgEnabled.Value;
				_enabledBtn.Text = EnabledLabel();
			}

			internal void <Init>b__21_1(object s, ButtonClickEventArgs e)
			{
				HandStabilizerPlugin.CfgDebug.Value = !HandStabilizerPlugin.CfgDebug.Value;
				_overlayBtn.Text = OverlayLabel();
			}

			internal void <Init>b__21_2(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgSmoothness, -25f, 0f, 9999f);
				RefreshAll();
			}

			internal void <Init>b__21_3(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgSmoothness, -5f, 0f, 9999f);
				RefreshAll();
			}

			internal void <Init>b__21_4(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgSmoothness, 5f, 0f, 9999f);
				RefreshAll();
			}

			internal void <Init>b__21_5(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgSmoothness, 25f, 0f, 9999f);
				RefreshAll();
			}

			internal void <Init>b__21_6(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgPosThreshold, -0.02f, 0f, 5f);
				RefreshAll();
			}

			internal void <Init>b__21_7(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgPosThreshold, 0.02f, 0f, 5f);
				RefreshAll();
			}

			internal void <Init>b__21_8(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgAngThreshold, -0.02f, 0f, 5f);
				RefreshAll();
			}

			internal void <Init>b__21_9(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgAngThreshold, 0.02f, 0f, 5f);
				RefreshAll();
			}

			internal void <Init>b__21_10(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgAttack, -0.1f, 0f, 2f);
				RefreshAll();
			}

			internal void <Init>b__21_11(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgAttack, 0.1f, 0f, 2f);
				RefreshAll();
			}

			internal void <Init>b__21_12(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgRelease, -0.01f, 0f, 0.2f);
				RefreshAll();
			}

			internal void <Init>b__21_13(object s, ButtonClickEventArgs e)
			{
				AdjF(HandStabilizerPlugin.CfgRelease, 0.01f, 0f, 0.2f);
				RefreshAll();
			}
		}

		private static readonly string[] ModeNames = new string[2] { "Classic", "Adaptive" };

		private static WristMenuButton[] _modeBtns = (WristMenuButton[])(object)new WristMenuButton[2];

		private static WristMenuButton _smoothLbl;

		private static WristMenuButton _smoothM5;

		private static WristMenuButton _smoothM1;

		private static WristMenuButton _smoothP1;

		private static WristMenuButton _smoothP5;

		private static WristMenuButton _posLbl;

		private static WristMenuButton _posM;

		private static WristMenuButton _posP;

		private static WristMenuButton _angLbl;

		private static WristMenuButton _angM;

		private static WristMenuButton _angP;

		private static WristMenuButton _atkLbl;

		private static WristMenuButton _atkM;

		private static WristMenuButton _atkP;

		private static WristMenuButton _relLbl;

		private static WristMenuButton _relM;

		private static WristMenuButton _relP;

		private static WristMenuButton _enabledBtn;

		private static WristMenuButton _overlayBtn;

		public static void Init()
		{
			//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_002f: Expected O, but got Unknown
			//IL_0062: 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_006d: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00fb: 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_0106: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0157: 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_0162: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			//IL_0241: 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_024c: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Expected O, but got Unknown
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			WristMenuSectionProxy val = WristMenuAPI.CreateSection("Hand Stabilizer");
			string text = EnabledLabel();
			object obj = <>c.<>9__21_0;
			if (obj == null)
			{
				ButtonClickEvent val2 = delegate
				{
					HandStabilizerPlugin.CfgEnabled.Value = !HandStabilizerPlugin.CfgEnabled.Value;
					_enabledBtn.Text = EnabledLabel();
				};
				<>c.<>9__21_0 = val2;
				obj = (object)val2;
			}
			_enabledBtn = Btn(text, (ButtonClickEvent)obj);
			val.Buttons.Add(_enabledBtn);
			string text2 = OverlayLabel();
			object obj2 = <>c.<>9__21_1;
			if (obj2 == null)
			{
				ButtonClickEvent val3 = delegate
				{
					HandStabilizerPlugin.CfgDebug.Value = !HandStabilizerPlugin.CfgDebug.Value;
					_overlayBtn.Text = OverlayLabel();
				};
				<>c.<>9__21_1 = val3;
				obj2 = (object)val3;
			}
			_overlayBtn = Btn(text2, (ButtonClickEvent)obj2);
			val.Buttons.Add(_overlayBtn);
			for (int i = 0; i < 2; i++)
			{
				int mi = i;
				_modeBtns[i] = Btn(ModeLabel(i + 1), (ButtonClickEvent)delegate
				{
					HandStabilizerPlugin.CfgMode.Value = mi + 1;
					RefreshAll();
				});
				val.Buttons.Add(_modeBtns[i]);
			}
			_smoothLbl = Btn(SmoothLabel());
			object obj3 = <>c.<>9__21_2;
			if (obj3 == null)
			{
				ButtonClickEvent val4 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgSmoothness, -25f, 0f, 9999f);
					RefreshAll();
				};
				<>c.<>9__21_2 = val4;
				obj3 = (object)val4;
			}
			_smoothM5 = Btn("Smooth -25", (ButtonClickEvent)obj3);
			object obj4 = <>c.<>9__21_3;
			if (obj4 == null)
			{
				ButtonClickEvent val5 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgSmoothness, -5f, 0f, 9999f);
					RefreshAll();
				};
				<>c.<>9__21_3 = val5;
				obj4 = (object)val5;
			}
			_smoothM1 = Btn("Smooth -5", (ButtonClickEvent)obj4);
			object obj5 = <>c.<>9__21_4;
			if (obj5 == null)
			{
				ButtonClickEvent val6 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgSmoothness, 5f, 0f, 9999f);
					RefreshAll();
				};
				<>c.<>9__21_4 = val6;
				obj5 = (object)val6;
			}
			_smoothP1 = Btn("Smooth +5", (ButtonClickEvent)obj5);
			object obj6 = <>c.<>9__21_5;
			if (obj6 == null)
			{
				ButtonClickEvent val7 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgSmoothness, 25f, 0f, 9999f);
					RefreshAll();
				};
				<>c.<>9__21_5 = val7;
				obj6 = (object)val7;
			}
			_smoothP5 = Btn("Smooth +25", (ButtonClickEvent)obj6);
			val.Buttons.Add(_smoothLbl);
			val.Buttons.Add(_smoothM5);
			val.Buttons.Add(_smoothM1);
			val.Buttons.Add(_smoothP1);
			val.Buttons.Add(_smoothP5);
			_posLbl = Btn(PosLabel());
			object obj7 = <>c.<>9__21_6;
			if (obj7 == null)
			{
				ButtonClickEvent val8 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgPosThreshold, -0.02f, 0f, 5f);
					RefreshAll();
				};
				<>c.<>9__21_6 = val8;
				obj7 = (object)val8;
			}
			_posM = Btn("PosThresh -", (ButtonClickEvent)obj7);
			object obj8 = <>c.<>9__21_7;
			if (obj8 == null)
			{
				ButtonClickEvent val9 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgPosThreshold, 0.02f, 0f, 5f);
					RefreshAll();
				};
				<>c.<>9__21_7 = val9;
				obj8 = (object)val9;
			}
			_posP = Btn("PosThresh +", (ButtonClickEvent)obj8);
			val.Buttons.Add(_posLbl);
			val.Buttons.Add(_posM);
			val.Buttons.Add(_posP);
			_angLbl = Btn(AngLabel());
			object obj9 = <>c.<>9__21_8;
			if (obj9 == null)
			{
				ButtonClickEvent val10 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgAngThreshold, -0.02f, 0f, 5f);
					RefreshAll();
				};
				<>c.<>9__21_8 = val10;
				obj9 = (object)val10;
			}
			_angM = Btn("AngThresh -", (ButtonClickEvent)obj9);
			object obj10 = <>c.<>9__21_9;
			if (obj10 == null)
			{
				ButtonClickEvent val11 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgAngThreshold, 0.02f, 0f, 5f);
					RefreshAll();
				};
				<>c.<>9__21_9 = val11;
				obj10 = (object)val11;
			}
			_angP = Btn("AngThresh +", (ButtonClickEvent)obj10);
			val.Buttons.Add(_angLbl);
			val.Buttons.Add(_angM);
			val.Buttons.Add(_angP);
			_atkLbl = Btn(AtkLabel());
			object obj11 = <>c.<>9__21_10;
			if (obj11 == null)
			{
				ButtonClickEvent val12 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgAttack, -0.1f, 0f, 2f);
					RefreshAll();
				};
				<>c.<>9__21_10 = val12;
				obj11 = (object)val12;
			}
			_atkM = Btn("Attack -", (ButtonClickEvent)obj11);
			object obj12 = <>c.<>9__21_11;
			if (obj12 == null)
			{
				ButtonClickEvent val13 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgAttack, 0.1f, 0f, 2f);
					RefreshAll();
				};
				<>c.<>9__21_11 = val13;
				obj12 = (object)val13;
			}
			_atkP = Btn("Attack +", (ButtonClickEvent)obj12);
			val.Buttons.Add(_atkLbl);
			val.Buttons.Add(_atkM);
			val.Buttons.Add(_atkP);
			_relLbl = Btn(RelLabel());
			object obj13 = <>c.<>9__21_12;
			if (obj13 == null)
			{
				ButtonClickEvent val14 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgRelease, -0.01f, 0f, 0.2f);
					RefreshAll();
				};
				<>c.<>9__21_12 = val14;
				obj13 = (object)val14;
			}
			_relM = Btn("Release -", (ButtonClickEvent)obj13);
			object obj14 = <>c.<>9__21_13;
			if (obj14 == null)
			{
				ButtonClickEvent val15 = delegate
				{
					AdjF(HandStabilizerPlugin.CfgRelease, 0.01f, 0f, 0.2f);
					RefreshAll();
				};
				<>c.<>9__21_13 = val15;
				obj14 = (object)val15;
			}
			_relP = Btn("Release +", (ButtonClickEvent)obj14);
			val.Buttons.Add(_relLbl);
			val.Buttons.Add(_relM);
			val.Buttons.Add(_relP);
		}

		private static void RefreshAll()
		{
			for (int i = 0; i < 2; i++)
			{
				_modeBtns[i].Text = ModeLabel(i + 1);
			}
			_smoothLbl.Text = SmoothLabel();
			_posLbl.Text = PosLabel();
			_angLbl.Text = AngLabel();
			_atkLbl.Text = AtkLabel();
			_relLbl.Text = RelLabel();
		}

		private static string EnabledLabel()
		{
			return "HS: " + (HandStabilizerPlugin.CfgEnabled.Value ? "ON" : "OFF");
		}

		private static string OverlayLabel()
		{
			return "Overlay: " + (HandStabilizerPlugin.CfgDebug.Value ? "ON" : "OFF");
		}

		private static string ModeLabel(int m)
		{
			string text = ((HandStabilizerPlugin.CfgMode.Value == m) ? " [●]" : "");
			return m + ": " + ModeNames[m - 1] + text;
		}

		private static string SmoothLabel()
		{
			return "Smoothness: " + HandStabilizerPlugin.CfgSmoothness.Value.ToString("F0");
		}

		private static string PosLabel()
		{
			return "PosThresh: " + HandStabilizerPlugin.CfgPosThreshold.Value.ToString("F2");
		}

		private static string AngLabel()
		{
			return "AngThresh: " + HandStabilizerPlugin.CfgAngThreshold.Value.ToString("F2");
		}

		private static string AtkLabel()
		{
			return "Attack: " + HandStabilizerPlugin.CfgAttack.Value.ToString("F2");
		}

		private static string RelLabel()
		{
			return "Release: " + HandStabilizerPlugin.CfgRelease.Value.ToString("F3");
		}

		private static WristMenuButton Btn(string text, ButtonClickEvent clickAction = null)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			return new WristMenuButton(text, clickAction);
		}

		private static void AdjF(ConfigEntry<float> cfg, float delta, float min, float max)
		{
			cfg.Value = Mathf.Clamp(cfg.Value + delta, min, max);
		}
	}
	internal struct DebugData
	{
		public Vector3 rawPos;

		public Quaternion rawRot;

		public Vector3 vel;

		public float angVel;

		public Vector3 smoothPos;

		public float velThreshold;

		public float angThreshold;

		public float smoothAmt;

		public bool valid;
	}
	internal static class Patches
	{
		private sealed class S
		{
			public Vector3 pos;

			public Quaternion rot = Quaternion.identity;

			public Vector3 prevRaw;

			public Quaternion prevRawRot = Quaternion.identity;

			public bool init;

			public bool ff = true;

			public int mode = -1;

			public int frame = -1;

			public float pe;

			public float re;

			public float aE;

			public float aERot;

			public Vector3 aFast;

			public float aV;

			public Vector3 aFastAng;

			public float aVAng;
		}

		internal static readonly Dictionary<int, DebugData> _dbg = new Dictionary<int, DebugData>();

		private static readonly Dictionary<int, FVRViveHand> _h = new Dictionary<int, FVRViveHand>();

		private static readonly Dictionary<int, S> _s = new Dictionary<int, S>();

		[HarmonyPatch(typeof(SteamVR_Behaviour_Pose), "UpdateTransform")]
		[HarmonyPostfix]
		public static void Run(SteamVR_Behaviour_Pose __instance)
		{
			//IL_0070: 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_007d: 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_00c0: 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_00c8: 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_00a9: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_01b2: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			if (!HandStabilizerPlugin.CfgEnabled.Value)
			{
				return;
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			if (unscaledDeltaTime <= 0f)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!_h.TryGetValue(instanceID, out var value))
			{
				value = ((Component)__instance).GetComponent<FVRViveHand>();
				_h[instanceID] = value;
			}
			if (value == null)
			{
				return;
			}
			if (!_s.TryGetValue(instanceID, out var value2))
			{
				value2 = new S();
				_s[instanceID] = value2;
			}
			Vector3 position = ((Component)__instance).transform.position;
			Quaternion rotation = ((Component)__instance).transform.rotation;
			if (value2.frame == Time.frameCount)
			{
				((Component)__instance).transform.position = value2.pos;
				((Component)__instance).transform.rotation = value2.rot;
				return;
			}
			value2.frame = Time.frameCount;
			Vector3 prevRaw = value2.prevRaw;
			_ = value2.prevRawRot;
			int num;
			if (value2.init)
			{
				Vector3 val = position - prevRaw;
				num = ((((Vector3)(ref val)).sqrMagnitude > 0.25f) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			value2.prevRaw = position;
			value2.prevRawRot = rotation;
			int num2 = Mathf.Clamp(HandStabilizerPlugin.CfgMode.Value, 1, 2);
			if (num2 != value2.mode || !value2.init || flag)
			{
				value2.mode = num2;
				value2.pos = position;
				value2.rot = rotation;
				value2.pe = (value2.re = 0f);
				value2.aFast = Vector3.zero;
				value2.aV = 0f;
				value2.aFastAng = Vector3.zero;
				value2.aVAng = 0f;
				value2.aE = 0f;
				value2.aERot = 0f;
				value2.init = true;
				((Component)__instance).transform.position = position;
				((Component)__instance).transform.rotation = rotation;
				return;
			}
			float num3 = Mathf.Max(HandStabilizerPlugin.CfgSmoothness.Value, 0f) / 100f;
			float num4 = num3 * num3 * 0.5f;
			if (num4 < 0.001f)
			{
				value2.pos = position;
				value2.rot = rotation;
				((Component)__instance).transform.position = position;
				((Component)__instance).transform.rotation = rotation;
				return;
			}
			if (num2 == 2)
			{
				Adaptive(value2, position, rotation, unscaledDeltaTime, num4, value);
			}
			else
			{
				Classic(value2, position, rotation, unscaledDeltaTime, num4, value);
			}
			((Component)__instance).transform.position = value2.pos;
			((Component)__instance).transform.rotation = value2.rot;
			if (value2.ff)
			{
				value2.ff = false;
				HandStabilizerPlugin.Log.LogInfo((object)$"[HandStabilizer] Active mode={num2} maxTC={num4:F3}s");
			}
			if (HandStabilizerPlugin.CfgDebug.Value)
			{
				Vector3 velLinearWorld = value.Input.VelLinearWorld;
				float velThreshold;
				float smoothAmt;
				if (num2 == 2)
				{
					float num5 = HandStabilizerPlugin.CfgPosThreshold.Value / 2.5f;
					velThreshold = Mathf.Max(Mathf.Sqrt(Mathf.Max(value2.aV, 0f)), Mathf.Max(num5, 0.001f)) * 2.5f;
					smoothAmt = 1f - value2.aE;
				}
				else
				{
					velThreshold = Mathf.Max(HandStabilizerPlugin.CfgPosThreshold.Value, 0.001f);
					smoothAmt = value2.pe;
				}
				float magnitude = ((Vector3)(ref value.Input.VelAngularWorld)).magnitude;
				float angThreshold;
				if (num2 == 2)
				{
					float num6 = HandStabilizerPlugin.CfgAngThreshold.Value / 2.5f;
					angThreshold = Mathf.Max(Mathf.Sqrt(Mathf.Max(value2.aVAng, 0f)), Mathf.Max(num6, 0.001f)) * 2.5f;
				}
				else
				{
					angThreshold = Mathf.Max(HandStabilizerPlugin.CfgAngThreshold.Value, 0.001f);
				}
				_dbg[instanceID] = new DebugData
				{
					rawPos = position,
					rawRot = rotation,
					vel = velLinearWorld,
					angVel = magnitude,
					smoothPos = value2.pos,
					velThreshold = velThreshold,
					angThreshold = angThreshold,
					smoothAmt = smoothAmt,
					valid = true
				};
				if ((Object)(object)((Component)value).GetComponent<DebugOverlay>() == (Object)null)
				{
					((Component)value).gameObject.AddComponent<DebugOverlay>().Init(instanceID);
				}
			}
		}

		private static void Classic(S s, Vector3 rp, Quaternion rr, float dt, float maxTC, FVRViveHand h)
		{
			//IL_012d: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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)
			float magnitude = ((Vector3)(ref h.Input.VelLinearWorld)).magnitude;
			float magnitude2 = ((Vector3)(ref h.Input.VelAngularWorld)).magnitude;
			float num = Mathf.Max(HandStabilizerPlugin.CfgPosThreshold.Value, 0.0001f);
			float num2 = Mathf.Max(HandStabilizerPlugin.CfgAngThreshold.Value, 0.0001f);
			float num3 = Mathf.Clamp01(magnitude / num);
			num3 = num3 * num3 * (3f - 2f * num3);
			float num4 = Mathf.Clamp01(magnitude2 / num2);
			num4 = num4 * num4 * (3f - 2f * num4);
			float num5 = 1f - Mathf.Exp((0f - dt) / Mathf.Max(HandStabilizerPlugin.CfgAttack.Value, 0.001f));
			float num6 = 1f - Mathf.Exp((0f - dt) / Mathf.Max(HandStabilizerPlugin.CfgRelease.Value, 0.001f));
			s.pe = Mathf.Lerp(s.pe, 1f - num3, (1f - num3 > s.pe) ? num5 : num6);
			s.re = Mathf.Lerp(s.re, 1f - num4, (1f - num4 > s.re) ? num5 : num6);
			s.pos = Vector3.Lerp(s.pos, rp, 1f - Mathf.Exp((0f - dt) / Mathf.Max(s.pe * maxTC, 0.001f)));
			s.rot = SR(s.rot, rr, dt, Mathf.Max(s.re * maxTC, 0.001f));
		}

		private static void Adaptive(S s, Vector3 rp, Quaternion rr, float dt, float maxTC, FVRViveHand h)
		{
			//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_003e: 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_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_0050: 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_005f: 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_0066: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0100: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 velLinearWorld = h.Input.VelLinearWorld;
			float magnitude = ((Vector3)(ref velLinearWorld)).magnitude;
			float num = 1f - Mathf.Exp((0f - dt) / 0.05f);
			float num2 = 1f - Mathf.Exp((0f - dt) / 0.2f);
			s.aFast += num * (velLinearWorld - s.aFast);
			Vector3 val = velLinearWorld - s.aFast;
			s.aV = (1f - num2) * s.aV + num2 * ((Vector3)(ref val)).sqrMagnitude;
			float num3 = HandStabilizerPlugin.CfgPosThreshold.Value / 2.5f;
			float num4 = Mathf.Max(Mathf.Sqrt(s.aV), Mathf.Max(num3, 0.001f));
			float num5 = Mathf.Clamp01(magnitude / (num4 * 2.5f));
			num5 = num5 * num5 * (3f - 2f * num5);
			Vector3 velAngularWorld = h.Input.VelAngularWorld;
			float magnitude2 = ((Vector3)(ref velAngularWorld)).magnitude;
			s.aFastAng += num * (velAngularWorld - s.aFastAng);
			Vector3 val2 = velAngularWorld - s.aFastAng;
			s.aVAng = (1f - num2) * s.aVAng + num2 * ((Vector3)(ref val2)).sqrMagnitude;
			float num6 = HandStabilizerPlugin.CfgAngThreshold.Value / 2.5f;
			float num7 = Mathf.Max(Mathf.Sqrt(s.aVAng), Mathf.Max(num6, 0.001f));
			float num8 = Mathf.Clamp01(magnitude2 / (num7 * 2.5f));
			num8 = num8 * num8 * (3f - 2f * num8);
			float value = HandStabilizerPlugin.CfgRelease.Value;
			float value2 = HandStabilizerPlugin.CfgAttack.Value;
			if (num5 > s.aE)
			{
				s.aE = ((value < 0.0001f) ? num5 : Mathf.Lerp(s.aE, num5, 1f - Mathf.Exp((0f - dt) / value)));
			}
			else
			{
				s.aE = ((value2 < 0.0001f) ? num5 : Mathf.Lerp(s.aE, num5, 1f - Mathf.Exp((0f - dt) / value2)));
			}
			if (num8 > s.aERot)
			{
				s.aERot = ((value < 0.0001f) ? num8 : Mathf.Lerp(s.aERot, num8, 1f - Mathf.Exp((0f - dt) / value)));
			}
			else
			{
				s.aERot = ((value2 < 0.0001f) ? num8 : Mathf.Lerp(s.aERot, num8, 1f - Mathf.Exp((0f - dt) / value2)));
			}
			float num9 = Mathf.Lerp(maxTC, 0.002f, s.aE);
			float tc = Mathf.Lerp(maxTC, 0.002f, s.aERot);
			s.pos = Vector3.Lerp(s.pos, rp, 1f - Mathf.Exp((0f - dt) / num9));
			s.rot = SR(s.rot, rr, dt, tc);
		}

		private static Quaternion SR(Quaternion f, Quaternion t, float dt, float tc)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			return Quaternion.Slerp(f, t, 1f - Mathf.Exp((0f - dt) / Mathf.Max(tc, 0.001f)));
		}
	}
	internal class DebugOverlay : MonoBehaviour
	{
		private const float Y_OFF = 0.13f;

		private const float VEL_SCALE = 0.15f;

		private const float ANG_SCALE = 0.013f;

		private const float MAX_BUBBLE_R = 0.1f;

		private const float TIP_SZ = 0.005f;

		private const float SHAFT_W = 0.0015f;

		private const float DOT_SZ = 0.005f;

		private const float BUBBLE_HOLD_S = 0.5f;

		private int _id;

		private GameObject _velShaft;

		private GameObject _velTip;

		private GameObject _velBubble;

		private GameObject _angShaft;

		private GameObject _angTip;

		private GameObject _angBubble;

		private GameObject _smoothDot;

		private TrailRenderer _trail;

		private Material _velBubbleMat;

		private Material _angBubbleMat;

		private float _peakVelR;

		private float _peakAngR;

		private float _peakVelTime;

		private float _peakAngTime;

		public void Init(int id)
		{
			_id = id;
		}

		private void Start()
		{
			//IL_002e: 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_0052: 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_007f: 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_009e: 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_00c7: 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_0132: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			Color c = default(Color);
			((Color)(ref c))..ctor(0.2f, 0.5f, 1f);
			Color c2 = default(Color);
			((Color)(ref c2))..ctor(1f, 0.25f, 0.2f);
			_velShaft = MakeSolid((PrimitiveType)2, c, "HS_vShaft");
			_velTip = MakeSolid((PrimitiveType)0, c, "HS_vTip");
			_angShaft = MakeSolid((PrimitiveType)2, c2, "HS_aShaft");
			_angTip = MakeSolid((PrimitiveType)0, c2, "HS_aTip");
			_velTip.transform.localScale = Vector3.one * 0.005f;
			_angTip.transform.localScale = Vector3.one * 0.005f;
			_velBubble = MakeBubble(new Color(0.2f, 0.5f, 1f, 0.11f), "HS_vBubble");
			_angBubble = MakeBubble(new Color(1f, 0.25f, 0.2f, 0.11f), "HS_aBubble");
			_velBubbleMat = ((Renderer)_velBubble.GetComponent<MeshRenderer>()).material;
			_angBubbleMat = ((Renderer)_angBubble.GetComponent<MeshRenderer>()).material;
			_smoothDot = MakeSolid((PrimitiveType)0, Color.white, "HS_smooth");
			_smoothDot.transform.localScale = Vector3.one * 0.005f;
			_trail = _smoothDot.AddComponent<TrailRenderer>();
			_trail.time = 0.15f;
			_trail.startWidth = 0.0034999999f;
			_trail.endWidth = 0f;
			((Renderer)_trail).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)_trail).receiveShadows = false;
			Material val = new Material(Shader.Find("Sprites/Default"));
			val.color = new Color(1f, 1f, 1f, 0.35f);
			((Renderer)_trail).material = val;
		}

		private void LateUpdate()
		{
			//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)
			//IL_00d4: 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_00db: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_025d: 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_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: 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)
			DebugData value = default(DebugData);
			bool flag = HandStabilizerPlugin.CfgEnabled.Value && HandStabilizerPlugin.CfgDebug.Value && Patches._dbg.TryGetValue(_id, out value) && value.valid;
			_velBubble.SetActive(flag);
			_velTip.SetActive(flag);
			_angBubble.SetActive(flag);
			_angTip.SetActive(flag);
			bool flag2 = flag && value.smoothAmt > 0.05f;
			if (!flag2 && _smoothDot.activeSelf)
			{
				_trail.Clear();
			}
			_smoothDot.SetActive(flag2);
			if (!flag)
			{
				_velShaft.SetActive(false);
				_angShaft.SetActive(false);
				return;
			}
			Vector3 val = Vector3.up * 0.13f;
			Vector3 val2 = value.rawPos + val;
			_smoothDot.transform.position = value.smoothPos + val;
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			float num = Mathf.Min(value.velThreshold * 0.15f, 0.1f);
			if (num >= _peakVelR)
			{
				_peakVelR = num;
				_peakVelTime = realtimeSinceStartup;
			}
			else if (realtimeSinceStartup - _peakVelTime >= 0.5f)
			{
				_peakVelR = num;
			}
			float peakVelR = _peakVelR;
			_velBubble.transform.position = val2;
			_velBubble.transform.localScale = Vector3.one * peakVelR * 2f;
			float magnitude = ((Vector3)(ref value.vel)).magnitude;
			Vector3 dir = ((magnitude > 0.001f) ? (value.vel / magnitude) : Vector3.up);
			DrawArrow(_velShaft, _velTip, val2, dir, magnitude * 0.15f);
			float num2 = Mathf.Min(APow(value.angThreshold), 0.1f);
			if (num2 >= _peakAngR)
			{
				_peakAngR = num2;
				_peakAngTime = realtimeSinceStartup;
			}
			else if (realtimeSinceStartup - _peakAngTime >= 0.5f)
			{
				_peakAngR = num2;
			}
			float peakAngR = _peakAngR;
			_angBubble.transform.position = val2;
			_angBubble.transform.localScale = Vector3.one * peakAngR * 2f;
			Vector3 dir2 = value.rawRot * Vector3.forward;
			DrawArrow(_angShaft, _angTip, val2, dir2, APow(value.angVel));
			SetAlpha(_velBubbleMat, (peakVelR >= peakAngR) ? 0.04f : 0.1f);
			SetAlpha(_angBubbleMat, (peakAngR > peakVelR) ? 0.04f : 0.1f);
		}

		private static float APow(float x)
		{
			return Mathf.Max(x, 0f) * 0.013f;
		}

		private static void SetAlpha(Material mat, float a)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			Color color = mat.color;
			color.a = a;
			mat.color = color;
		}

		private static void DrawArrow(GameObject shaft, GameObject tip, Vector3 base_, Vector3 dir, float len)
		{
			//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_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_0041: 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_004a: 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_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)
			tip.transform.position = base_ + dir * len;
			float num = Mathf.Max(len - 0.0025f, 0f);
			if (num > 0.001f)
			{
				shaft.SetActive(true);
				shaft.transform.position = base_ + dir * (num * 0.5f);
				shaft.transform.up = dir;
				shaft.transform.localScale = new Vector3(0.0015f, num * 0.5f, 0.0015f);
			}
			else
			{
				shaft.SetActive(false);
			}
		}

		private static GameObject MakeSolid(PrimitiveType type, Color c, string name)
		{
			//IL_0000: 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_002f: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(type);
			((Object)obj).name = name;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.layer = 2;
			Material val = new Material(Shader.Find("Unlit/Color"));
			val.color = c;
			((Renderer)obj.GetComponent<MeshRenderer>()).material = val;
			obj.SetActive(false);
			return obj;
		}

		private static GameObject MakeBubble(Color c, string name)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)obj).name = name;
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.layer = 2;
			Material val = new Material(Shader.Find("Standard"));
			val.color = c;
			val.SetFloat("_Mode", 3f);
			val.SetInt("_SrcBlend", 5);
			val.SetInt("_DstBlend", 10);
			val.SetInt("_ZWrite", 0);
			val.EnableKeyword("_ALPHABLEND_ON");
			val.renderQueue = 3000;
			((Renderer)obj.GetComponent<MeshRenderer>()).material = val;
			obj.SetActive(false);
			return obj;
		}
	}
}