Decompiled source of ElectricScooter v1.3.0

Mods/ElectricScooter_Il2Cpp.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using ElectricScooter;
using HarmonyLib;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRootMotion.FinalIK;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Animation;
using Il2CppScheduleOne.AvatarFramework.Equipping;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Dialogue;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.Experimental;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Skating;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1Shared;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ElectricScooterMod), "ElectricScooter", "1.3.0", "BbIJABNPOBATEJb", "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods")]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: HarmonyDontPatchAll]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ElectricScooter_Il2Cpp")]
[assembly: AssemblyConfiguration("Il2Cpp")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a2aeaf412ee33043787ba84532ee04a88246f738")]
[assembly: AssemblyProduct("ElectricScooter_Il2Cpp")]
[assembly: AssemblyTitle("ElectricScooter_Il2Cpp")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace S1Shared
{
	internal sealed class CoRunner
	{
		private sealed class Routine
		{
			public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>();

			public float WaitUntil;
		}

		private readonly List<Routine> _routines = new List<Routine>();

		private readonly Action<Exception> _onError;

		public CoRunner(Action<Exception> onError)
		{
			_onError = onError;
		}

		public void Start(IEnumerator routine)
		{
			Routine routine2 = new Routine();
			routine2.Stack.Push(routine);
			_routines.Add(routine2);
		}

		public void StopAll()
		{
			_routines.Clear();
		}

		public void Tick()
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			for (int num = _routines.Count - 1; num >= 0; num--)
			{
				Routine routine = _routines[num];
				if (!(realtimeSinceStartup < routine.WaitUntil))
				{
					try
					{
						if (!Step(routine, realtimeSinceStartup))
						{
							_routines.RemoveAt(num);
						}
					}
					catch (Exception obj)
					{
						_routines.RemoveAt(num);
						_onError(obj);
					}
				}
			}
		}

		private static bool Step(Routine r, float now)
		{
			while (r.Stack.Count > 0)
			{
				IEnumerator enumerator = r.Stack.Peek();
				if (!enumerator.MoveNext())
				{
					r.Stack.Pop();
					continue;
				}
				object current = enumerator.Current;
				if (!(current is IEnumerator item))
				{
					if (!(current is float num))
					{
						if (current is int num2)
						{
							r.WaitUntil = Time.realtimeSinceStartup + (float)num2;
							return true;
						}
						return true;
					}
					r.WaitUntil = Time.realtimeSinceStartup + num;
					return true;
				}
				r.Stack.Push(item);
			}
			return false;
		}
	}
	internal static class SafePatcher
	{
		public static int Apply(Harmony harmony, Instance log)
		{
			int num = 0;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly());
			foreach (Type type in typesFromAssembly)
			{
				if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any())
				{
					try
					{
						harmony.CreateClassProcessor(type).Patch();
					}
					catch (Exception ex)
					{
						num++;
						log.Warning("Patch " + type.FullName + " not applied: " + (ex.InnerException ?? ex).Message);
					}
				}
			}
			return num;
		}
	}
	internal static class UiKit
	{
		public static void OnClick(Button button, Action action)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			button.onClick = new ButtonClickedEvent();
			((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action));
		}

		public static void OnValueChanged(Slider slider, Action<float> action)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			slider.onValueChanged = new SliderEvent();
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<float>>((Delegate)action));
		}

		public static void AddListener(Toggle toggle, Action<bool> action)
		{
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<bool>>((Delegate)action));
		}

		public static T? Get<T>(Component c) where T : Component
		{
			Component component = c.GetComponent(Il2CppType.Of<T>());
			if (component == null)
			{
				return default(T);
			}
			return ((Il2CppObjectBase)component).TryCast<T>();
		}

		public static T? Get<T>(GameObject go) where T : Component
		{
			return Get<T>((Component)(object)go.transform);
		}

		public static T? InChildren<T>(Component c) where T : Component
		{
			return UnityQuery.GetComponentsInChildren<T>(c, includeInactive: true).FirstOrDefault();
		}

		public static Transform? Find(Transform root, string name)
		{
			for (int i = 0; i < root.childCount; i++)
			{
				Transform child = root.GetChild(i);
				if (((Object)child).name == name)
				{
					return child;
				}
				Transform val = Find(child, name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		public static List<Transform> Children(Transform t)
		{
			List<Transform> list = new List<Transform>();
			for (int i = 0; i < t.childCount; i++)
			{
				list.Add(t.GetChild(i));
			}
			return list;
		}

		public static string Namespace(Component c)
		{
			return ((Object)c).GetIl2CppType().Namespace ?? "";
		}

		public static void SetMember(object target, string name, object? value)
		{
			Type type = target.GetType();
			while (type != null)
			{
				PropertyInfo property = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && property.CanWrite)
				{
					property.SetValue(target, value);
					break;
				}
				FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					field.SetValue(target, value);
					break;
				}
				type = type.BaseType;
			}
		}
	}
	internal static class UnityQuery
	{
		public static List<T> ToManaged<T>(List<T>? list)
		{
			List<T> list2 = new List<T>();
			if (list == null)
			{
				return list2;
			}
			for (int i = 0; i < list.Count; i++)
			{
				list2.Add(list[i]);
			}
			return list2;
		}

		public static List<T> FindAllIncludingAssets<T>() where T : Object
		{
			List<T> list = new List<T>();
			foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<T>()))
			{
				T val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<T>() : default(T));
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static List<T> FindInScenes<T>() where T : Component
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			List<T> list = new List<T>();
			foreach (T item in UnityQuery.FindAllIncludingAssets<T>())
			{
				Scene scene = ((Component)item).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static T? GetComponentInParent<T>(Component component) where T : Component
		{
			Component componentInParent = component.GetComponentInParent(Il2CppType.Of<T>());
			if (componentInParent == null)
			{
				return default(T);
			}
			return ((Il2CppObjectBase)componentInParent).TryCast<T>();
		}

		public static List<T> GetComponentsInChildren<T>(Component root, bool includeInactive) where T : Component
		{
			List<T> list = new List<T>();
			foreach (Component item in (Il2CppArrayBase<Component>)(object)root.GetComponentsInChildren(Il2CppType.Of<T>(), includeInactive))
			{
				T val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<T>() : default(T));
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static bool TryCastTo<T>(Object? obj, out T result) where T : Object
		{
			result = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<T>() : default(T));
			return (Object)(object)result != (Object)null;
		}

		public static string TypeName(Object obj)
		{
			return ((MemberInfo)((Object)obj).GetIl2CppType()).Name;
		}

		public static string DumpHierarchy(Transform root, int maxDepth = 12)
		{
			StringBuilder sb = new StringBuilder();
			Walk(root, 0);
			return sb.ToString();
			void Walk(Transform t, int depth)
			{
				sb.Append(' ', depth * 2).Append(((Object)t).name).Append(((Component)t).gameObject.activeSelf ? "" : " [inactive]")
					.Append("  {");
				foreach (Component component in ((Component)t).GetComponents<Component>())
				{
					if (!((Object)(object)component == (Object)null))
					{
						sb.Append(TypeName((Object)(object)component)).Append(' ');
						if (UnityQuery.TryCastTo<TMP_Text>((Object?)(object)component, out TMP_Text result))
						{
							sb.Append("\"").Append(result.text?.Replace("\n", "\\n")).Append("\" ");
						}
					}
				}
				sb.Append("}\n");
				if (depth < maxDepth)
				{
					for (int i = 0; i < t.childCount; i++)
					{
						Walk(t.GetChild(i), depth + 1);
					}
				}
			}
		}

		public static string PathOf(Transform t)
		{
			List<string> list = new List<string>();
			Transform val = t;
			while ((Object)(object)val != (Object)null)
			{
				list.Add(((Object)val).name);
				val = val.parent;
			}
			list.Reverse();
			return string.Join("/", list);
		}
	}
}
namespace ElectricScooter
{
	internal static class Config
	{
		private static MelonPreferences_Entry<int> _price;

		private static MelonPreferences_Entry<int> _speedPercent;

		private static MelonPreferences_Entry<int> _stepHeightCm;

		private static MelonPreferences_Entry<bool> _infiniteStamina;

		private static MelonPreferences_Entry<bool> _offRoad;

		public static float Price => Mathf.Clamp(_price.Value, 0, 1000000);

		public static float Speed => (float)Mathf.Clamp(_speedPercent.Value, 50, 300) / 100f;

		public static float StepHeight => (float)Mathf.Clamp(_stepHeightCm.Value, 10, 40) / 100f;

		public static bool InfiniteStamina => _infiniteStamina.Value;

		public static bool OffRoad => _offRoad.Value;

		public static void Init()
		{
			MelonPreferences_Category obj = MelonPreferences.CreateCategory("ElectricScooter");
			_price = obj.CreateEntry<int>("Price", 5000, (string)null, "Price at the skate shop, $.", false, false, (ValueValidator)null, (string)null);
			_speedPercent = obj.CreateEntry<int>("SpeedPercent", 130, (string)null, "Top speed and acceleration compared to the Golden Skateboard, % (130 = 30% faster). 50-300.", false, false, (ValueValidator)null, (string)null);
			_stepHeightCm = obj.CreateEntry<int>("StepHeightCm", 20, (string)null, "How high a curb the scooter rolls over without stopping, cm (10-40). The wheels grow with it.", false, false, (ValueValidator)null, (string)null);
			_infiniteStamina = obj.CreateEntry<bool>("InfiniteStamina", true, (string)null, "Riding the scooter does not use stamina (it is electric, after all).", false, false, (ValueValidator)null, (string)null);
			_offRoad = obj.CreateEntry<bool>("OffRoad", false, (string)null, "Ride over grass and gravel at full speed instead of slowing down there like the skateboards.", false, false, (ValueValidator)null, (string)null);
		}
	}
	public sealed class ElectricScooterMod : MelonMod
	{
		private CoRunner _runner;

		private int _dressedHeld;

		public override void OnInitializeMelon()
		{
			SafePatcher.Apply(((MelonBase)this).HarmonyInstance, ((MelonBase)this).LoggerInstance);
			Config.Init();
			_runner = new CoRunner(delegate(Exception ex)
			{
				((MelonBase)this).LoggerInstance.Error((object)ex);
			});
			((MelonBase)this).LoggerInstance.Msg("ElectricScooter 1.3.0 loaded");
		}

		public override void OnUpdate()
		{
			_runner.Tick();
			ScooterItem.EnsureRegistered();
			ScooterShop.Tick();
			ScooterRide.Tick();
			DressHeldScooter();
			ScooterSync.Tick();
		}

		public override void OnLateUpdate()
		{
			RiderPose.LateTick();
		}

		private void DressHeldScooter()
		{
			PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Equippable equippable = instance.Equippable;
			if (!((Object)(object)equippable == (Object)null) && ((Object)equippable).GetInstanceID() != _dressedHeld && ScooterItem.Is(instance.EquippedItem))
			{
				_dressedHeld = ((Object)equippable).GetInstanceID();
				if (UnityQuery.TryCastTo<Skateboard_Equippable>((Object?)(object)equippable, out Skateboard_Equippable result) && !ScooterModel.IsDressed(((Component)result).transform))
				{
					ScooterModel.DressHeld(((Component)result).transform, ScooterRide.HoverHeight);
				}
			}
		}
	}
	internal static class ModInfo
	{
		public const string Name = "ElectricScooter";

		public const string Version = "1.3.0";

		public const string Author = "BbIJABNPOBATEJb";

		public const string DownloadLink = "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods";
	}
	internal static class RiderPose
	{
		[HarmonyPatch(typeof(BipedIK), "UpdateSolver")]
		private static class Solve
		{
			private static bool Prefix(BipedIK __instance)
			{
				return BeforeSolve(__instance);
			}

			private static void Postfix(BipedIK __instance)
			{
				AfterSolve(__instance);
			}
		}

		[HarmonyPatch(typeof(AvatarAnimation), "LateUpdate")]
		private static class Animated
		{
			private static void Postfix(AvatarAnimation __instance)
			{
				if (Riders.Count == 0)
				{
					return;
				}
				int instanceID = ((Object)__instance).GetInstanceID();
				foreach (Rider value in Riders.Values)
				{
					if (value.Animation != instanceID || !value.Snapshot.Captured)
					{
						continue;
					}
					try
					{
						if (value.Valid)
						{
							value.Snapshot.Apply();
						}
						break;
					}
					catch (Exception ex)
					{
						Warn("the rider's pose was not applied: " + ex.Message);
						break;
					}
				}
			}
		}

		private readonly struct LimbState
		{
			private readonly Transform? _target;

			private readonly Transform? _bendGoal;

			private readonly float _positionWeight;

			private readonly float _rotationWeight;

			private readonly float _maintainRotation;

			private readonly float _bendWeight;

			private readonly Vector3 _position;

			private readonly Vector3 _bendNormal;

			private readonly Quaternion _rotation;

			private readonly BendModifier _bendModifier;

			public LimbState(IKSolverLimb limb)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				_target = ((IKSolverTrigonometric)limb).target;
				_positionWeight = ((IKSolver)limb).IKPositionWeight;
				_rotationWeight = ((IKSolverTrigonometric)limb).IKRotationWeight;
				_position = ((IKSolver)limb).IKPosition;
				_rotation = ((IKSolverTrigonometric)limb).IKRotation;
				_maintainRotation = limb.maintainRotationWeight;
				_bendGoal = limb.bendGoal;
				_bendModifier = limb.bendModifier;
				_bendWeight = limb.bendModifierWeight;
				_bendNormal = ((IKSolverTrigonometric)limb).bendNormal;
			}

			public void Restore(IKSolverLimb limb)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				((IKSolverTrigonometric)limb).target = _target;
				((IKSolver)limb).IKPositionWeight = _positionWeight;
				((IKSolverTrigonometric)limb).IKRotationWeight = _rotationWeight;
				((IKSolver)limb).IKPosition = _position;
				((IKSolverTrigonometric)limb).IKRotation = _rotation;
				limb.maintainRotationWeight = _maintainRotation;
				limb.bendGoal = _bendGoal;
				limb.bendModifier = _bendModifier;
				limb.bendModifierWeight = _bendWeight;
				((IKSolverTrigonometric)limb).bendNormal = _bendNormal;
			}
		}

		private sealed class Rider
		{
			public readonly Player Player;

			public readonly Skateboard Board;

			public readonly Transform Parts;

			public readonly Transform LeftGrip;

			public readonly Transform RightGrip;

			public readonly BipedIK IK;

			public readonly int Animation;

			public readonly Snapshot Snapshot;

			public readonly Transform LeftHand;

			public readonly Transform RightHand;

			public readonly Transform PelvisTarget;

			public readonly Transform LeftFoot;

			public readonly Transform RightFoot;

			public readonly Transform LeftKnee;

			public readonly Transform RightKnee;

			public Quaternion LeftPalm;

			public Quaternion RightPalm;

			public Vector3 LeftContact;

			public Vector3 RightContact;

			public Vector3 PelvisForward;

			public bool EnabledIK;

			public bool Solving;

			public bool Failed;

			public bool Calibrated;

			private LimbState _leftHand;

			private LimbState _rightHand;

			private LimbState _leftFoot;

			private LimbState _rightFoot;

			private Transform? _pelvisTarget;

			private float _pelvisPositionWeight;

			private float _pelvisRotationWeight;

			private float _spineWeight;

			private Vector3 _pelvisOffset;

			public bool Valid
			{
				get
				{
					if (Failed || (Object)(object)Board == (Object)null || (Object)(object)Parts == (Object)null || (Object)(object)Player == (Object)null || (Object)(object)LeftGrip == (Object)null || (Object)(object)RightGrip == (Object)null)
					{
						return false;
					}
					Skateboard activeSkateboard = Player.ActiveSkateboard;
					Avatar avatar = Player.Avatar;
					if ((Object)(object)activeSkateboard != (Object)null && ((Object)activeSkateboard).GetInstanceID() == ((Object)Board).GetInstanceID() && (Object)(object)avatar != (Object)null)
					{
						return !avatar.Ragdolled;
					}
					return false;
				}
			}

			public Rider(Player player, Skateboard board, Transform parts, BipedIK ik, Transform leftGrip, Transform rightGrip, Transform pelvis)
			{
				Player = player;
				Board = board;
				Parts = parts;
				IK = ik;
				LeftGrip = leftGrip;
				RightGrip = rightGrip;
				AvatarAnimation animation = player.Avatar.Animation;
				Animation = (((Object)(object)animation != (Object)null) ? ((Object)animation).GetInstanceID() : 0);
				Snapshot = new Snapshot(pelvis, parts);
				LeftHand = Target("Left Hand");
				RightHand = Target("Right Hand");
				PelvisTarget = Target("Pelvis");
				LeftFoot = Target("Left Foot");
				RightFoot = Target("Right Foot");
				LeftKnee = Target("Left Knee");
				RightKnee = Target("Right Knee");
			}

			private Transform Target(string name)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Transform transform = new GameObject("Rider " + name).transform;
				transform.SetParent(Parts, false);
				return transform;
			}

			public void SaveSolver()
			{
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				BipedIKSolvers solvers = IK.solvers;
				_leftHand = new LimbState(solvers.leftHand);
				_rightHand = new LimbState(solvers.rightHand);
				_leftFoot = new LimbState(solvers.leftFoot);
				_rightFoot = new LimbState(solvers.rightFoot);
				_pelvisTarget = solvers.pelvis.target;
				_pelvisPositionWeight = solvers.pelvis.positionWeight;
				_pelvisRotationWeight = solvers.pelvis.rotationWeight;
				_pelvisOffset = solvers.pelvis.rotationOffset;
				_spineWeight = ((solvers.spine != null) ? ((IKSolver)solvers.spine).IKPositionWeight : 0f);
			}

			public void RestoreSolver()
			{
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				if (!Solving)
				{
					return;
				}
				Solving = false;
				if (!((Object)(object)IK == (Object)null) && IK.solvers != null)
				{
					BipedIKSolvers solvers = IK.solvers;
					_leftHand.Restore(solvers.leftHand);
					_rightHand.Restore(solvers.rightHand);
					_leftFoot.Restore(solvers.leftFoot);
					_rightFoot.Restore(solvers.rightFoot);
					solvers.pelvis.target = _pelvisTarget;
					solvers.pelvis.positionWeight = _pelvisPositionWeight;
					solvers.pelvis.rotationWeight = _pelvisRotationWeight;
					solvers.pelvis.rotationOffset = _pelvisOffset;
					if (solvers.spine != null)
					{
						((IKSolver)solvers.spine).IKPositionWeight = _spineWeight;
					}
				}
			}

			public void Fail(string reason)
			{
				RestoreSolver();
				Snapshot.Restore();
				Failed = true;
				Warn("the rider keeps the skateboard stance: " + reason);
			}

			public void Dispose()
			{
				RestoreSolver();
				Snapshot.Restore();
				if (EnabledIK && (Object)(object)IK != (Object)null)
				{
					((Behaviour)IK).enabled = false;
				}
				Transform[] array = (Transform[])(object)new Transform[7] { LeftHand, RightHand, PelvisTarget, LeftFoot, RightFoot, LeftKnee, RightKnee };
				foreach (Transform val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)val).gameObject);
					}
				}
			}
		}

		private sealed class Snapshot
		{
			private readonly Transform _frame;

			private readonly List<Transform> _bones = new List<Transform>();

			private readonly List<Vector3> _localPositions = new List<Vector3>();

			private readonly List<Vector3> _positions = new List<Vector3>();

			private readonly List<Quaternion> _localRotations = new List<Quaternion>();

			private readonly List<Quaternion> _rotations = new List<Quaternion>();

			public bool Captured { get; private set; }

			public Snapshot(Transform pelvis, Transform frame)
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				_frame = frame;
				List<Transform> componentsInChildren = UnityQuery.GetComponentsInChildren<Transform>((Component)(object)pelvis, includeInactive: true);
				componentsInChildren.Sort((Transform a, Transform b) => Depth(a).CompareTo(Depth(b)));
				foreach (Transform item in componentsInChildren)
				{
					_bones.Add(item);
					_localPositions.Add(item.localPosition);
					_localRotations.Add(item.localRotation);
				}
			}

			private static int Depth(Transform t)
			{
				int num = 0;
				Transform parent = t.parent;
				while ((Object)(object)parent != (Object)null)
				{
					num++;
					parent = parent.parent;
				}
				return num;
			}

			public void Capture()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_004c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				Quaternion val = Quaternion.Inverse(_frame.rotation);
				_positions.Clear();
				_rotations.Clear();
				foreach (Transform bone in _bones)
				{
					_positions.Add(((Object)(object)bone != (Object)null) ? _frame.InverseTransformPoint(bone.position) : Vector3.zero);
					_rotations.Add(((Object)(object)bone != (Object)null) ? (val * bone.rotation) : Quaternion.identity);
				}
				Captured = true;
			}

			public void Apply()
			{
				//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_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_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				if (!Captured || (Object)(object)_frame == (Object)null)
				{
					return;
				}
				Quaternion rotation = _frame.rotation;
				for (int i = 0; i < _bones.Count; i++)
				{
					Transform val = _bones[i];
					if (!((Object)(object)val == (Object)null))
					{
						val.SetPositionAndRotation(_frame.TransformPoint(_positions[i]), rotation * _rotations[i]);
					}
				}
			}

			public void Restore()
			{
				//IL_0032: 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)
				if (!Captured)
				{
					return;
				}
				Captured = false;
				for (int i = 0; i < _bones.Count; i++)
				{
					Transform val = _bones[i];
					if (!((Object)(object)val == (Object)null))
					{
						val.localPosition = _localPositions[i];
						val.localRotation = _localRotations[i];
					}
				}
			}
		}

		private static class Hand
		{
			private static readonly string[] Fingers = new string[5] { "index", "middle", "ring", "little", "thumb" };

			public static Quaternion PalmFrame(Transform hand, bool left)
			{
				//IL_0087: 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_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: 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_0240: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: 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_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e0: 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_01e9: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: 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_0226: Unknown result type (might be due to invalid IL or missing references)
				Transform val = null;
				Transform val2 = null;
				Transform val3 = null;
				Transform val4 = null;
				float num = float.MaxValue;
				float num2 = float.MaxValue;
				float num3 = float.MaxValue;
				float num4 = float.MaxValue;
				Vector3 val5;
				foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)hand, includeInactive: true))
				{
					if ((Object)(object)componentsInChild == (Object)null || ((Object)componentsInChild).GetInstanceID() == ((Object)hand).GetInstanceID())
					{
						continue;
					}
					string text = ((Object)componentsInChild).name.ToLowerInvariant();
					if (Ignored(text) || Endpoint(text))
					{
						continue;
					}
					val5 = componentsInChild.position - hand.position;
					float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
					if (!(sqrMagnitude < 1E-06f) && !(sqrMagnitude > 0.04f))
					{
						if (text.Contains("middle") && sqrMagnitude < num)
						{
							val = componentsInChild;
							num = sqrMagnitude;
						}
						if (text.Contains("index") && sqrMagnitude < num2)
						{
							val2 = componentsInChild;
							num2 = sqrMagnitude;
						}
						if ((text.Contains("little") || text.Contains("pinky")) && sqrMagnitude < num3)
						{
							val3 = componentsInChild;
							num3 = sqrMagnitude;
						}
						if (text.Contains("thumb") && sqrMagnitude < num4)
						{
							val4 = componentsInChild;
							num4 = sqrMagnitude;
						}
					}
				}
				Transform val6 = (((Object)(object)val != (Object)null) ? val : val2);
				if ((Object)(object)val6 != (Object)null && (((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) || (Object)(object)val4 != (Object)null))
				{
					val5 = val6.position - hand.position;
					Vector3 normalized = ((Vector3)(ref val5)).normalized;
					Vector3 val7 = (((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) ? (val2.position - val3.position) : (val4.position - hand.position));
					val5 = Vector3.Cross(normalized, val7);
					Vector3 val8 = ((Vector3)(ref val5)).normalized * (left ? (-1f) : 1f);
					if (((Vector3)(ref val8)).sqrMagnitude > 0.5f)
					{
						return Quaternion.Inverse(hand.rotation) * Quaternion.LookRotation(normalized, val8);
					}
				}
				return Quaternion.LookRotation(Vector3.up, left ? Vector3.back : Vector3.forward);
			}

			public static Quaternion WristRotation(Transform parts, Quaternion palmFrame, float tilt)
			{
				//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_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_002d: Unknown result type (might be due to invalid IL or missing references)
				return Quaternion.LookRotation(Quaternion.AngleAxis(tilt, parts.right) * parts.forward, -parts.up) * Quaternion.Inverse(palmFrame);
			}

			public static Vector3 ContactOffset(Transform hand, Quaternion palmFrame)
			{
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: 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_018f: 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_019e: 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_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: 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_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: 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_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: 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)
				Dictionary<string, (float, Vector3)> dictionary = new Dictionary<string, (float, Vector3)>();
				foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)hand, includeInactive: true))
				{
					if ((Object)(object)componentsInChild == (Object)null || ((Object)componentsInChild).GetInstanceID() == ((Object)hand).GetInstanceID())
					{
						continue;
					}
					string name = ((Object)componentsInChild).name.ToLowerInvariant();
					string text = Finger(name);
					if (text != null && !(text == "thumb") && !Endpoint(name))
					{
						Vector3 val = componentsInChild.position - hand.position;
						float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
						if (!(sqrMagnitude < 1E-06f) && !(sqrMagnitude > 0.04f) && (!dictionary.TryGetValue(text, out var value) || sqrMagnitude < value.Item1))
						{
							dictionary[text] = (sqrMagnitude, componentsInChild.position);
						}
					}
				}
				Vector3 val3;
				if (dictionary.Count > 0)
				{
					Vector3 val2 = Vector3.zero;
					foreach (var value2 in dictionary.Values)
					{
						val2 += value2.Item2;
					}
					val2 /= (float)dictionary.Count;
					val3 = Quaternion.Inverse(hand.rotation) * ((val2 - hand.position) * 0.6f);
				}
				else
				{
					val3 = palmFrame * Vector3.forward * 0.045f;
				}
				return val3 + palmFrame * Vector3.up * 0.008f;
			}

			public static void Curl(Transform hand, Quaternion palmFrame)
			{
				//IL_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: 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_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_00ba: 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_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: 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_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: 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_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_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				List<(Transform, Quaternion)> list = new List<(Transform, Quaternion)>();
				foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)hand, includeInactive: true))
				{
					if (!((Object)(object)componentsInChild == (Object)null) && ((Object)componentsInChild).GetInstanceID() != ((Object)hand).GetInstanceID() && Finger(((Object)componentsInChild).name.ToLowerInvariant()) != null && !Endpoint(((Object)componentsInChild).name.ToLowerInvariant()))
					{
						list.Add((componentsInChild, componentsInChild.localRotation));
					}
				}
				if (list.Count == 0)
				{
					return;
				}
				try
				{
					Vector3 val = hand.rotation * palmFrame * Vector3.up;
					Vector3 val2 = hand.rotation * palmFrame * Vector3.forward;
					string[] fingers = Fingers;
					foreach (string text in fingers)
					{
						Transform val3 = FirstJoint(list, hand, text);
						if ((Object)(object)val3 == (Object)null)
						{
							continue;
						}
						Transform val4 = NextJoint(val3, text);
						Vector3 val5;
						Vector3 val6;
						if (!((Object)(object)val4 != (Object)null))
						{
							val5 = val2;
						}
						else
						{
							val6 = val4.position - val3.position;
							val5 = ((Vector3)(ref val6)).normalized;
						}
						val6 = Vector3.Cross(val5, val);
						Vector3 normalized = ((Vector3)(ref val6)).normalized;
						if (((Vector3)(ref normalized)).sqrMagnitude < 0.5f)
						{
							continue;
						}
						Transform val7 = val3;
						for (int j = 0; j < 3; j++)
						{
							if (!((Object)(object)val7 != (Object)null))
							{
								break;
							}
							val4 = NextJoint(val7, text);
							float num = ((text == "thumb") ? (j switch
							{
								1 => 25f, 
								0 => 15f, 
								_ => 20f, 
							}) : (j switch
							{
								1 => 50f, 
								0 => 18f, 
								_ => 35f, 
							}));
							val7.rotation = Quaternion.AngleAxis(num, normalized) * val7.rotation;
							val7 = (((Object)(object)val4 != (Object)null && !Endpoint(((Object)val4).name.ToLowerInvariant())) ? val4 : null);
						}
					}
				}
				catch
				{
					foreach (var (val8, localRotation) in list)
					{
						if ((Object)(object)val8 != (Object)null)
						{
							val8.localRotation = localRotation;
						}
					}
					throw;
				}
			}

			private static Transform? FirstJoint(List<(Transform Bone, Quaternion Rotation)> joints, Transform hand, string finger)
			{
				foreach (var joint in joints)
				{
					Transform item = joint.Bone;
					if (Finger(((Object)item).name.ToLowerInvariant()) != finger)
					{
						continue;
					}
					bool flag = false;
					Transform parent = item.parent;
					while ((Object)(object)parent != (Object)null && ((Object)parent).GetInstanceID() != ((Object)hand).GetInstanceID())
					{
						string name = ((Object)parent).name.ToLowerInvariant();
						if (Finger(name) == finger && !Endpoint(name))
						{
							flag = true;
							break;
						}
						parent = parent.parent;
					}
					if (!flag)
					{
						return item;
					}
				}
				return null;
			}

			private static Transform? NextJoint(Transform joint, string finger)
			{
				for (int i = 0; i < joint.childCount; i++)
				{
					Transform child = joint.GetChild(i);
					string name = ((Object)child).name.ToLowerInvariant();
					if (Finger(name) == finger || Endpoint(name))
					{
						return child;
					}
				}
				return null;
			}

			private static string? Finger(string name)
			{
				if (Ignored(name))
				{
					return null;
				}
				if (name.Contains("index"))
				{
					return "index";
				}
				if (name.Contains("middle"))
				{
					return "middle";
				}
				if (name.Contains("ring"))
				{
					return "ring";
				}
				if (name.Contains("little") || name.Contains("pinky"))
				{
					return "little";
				}
				if (!name.Contains("thumb"))
				{
					return null;
				}
				return "thumb";
			}

			private static bool Ignored(string name)
			{
				if (!name.Contains("target"))
				{
					return name.Contains("alignment");
				}
				return true;
			}

			private static bool Endpoint(string name)
			{
				if (!name.Contains("end"))
				{
					return name.Contains("tip");
				}
				return true;
			}
		}

		private const float Lean = 2f;

		private const float GripTilt = 10f;

		private const float MinRise = 0.15f;

		private const float MaxRise = 0.4f;

		private const float Pullback = 0.02f;

		private const float AnkleX = 0.025f;

		private const float AnkleZ = 0.16f;

		private static readonly Dictionary<int, Rider> Riders = new Dictionary<int, Rider>();

		private static readonly List<int> Gone = new List<int>();

		private static bool _warned;

		public static void Track(Player player, Skateboard board, Transform parts)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Avatar avatar = player.Avatar;
				AvatarIKController val = (((Object)(object)avatar != (Object)null) ? UiKit.InChildren<AvatarIKController>((Component)(object)avatar) : null);
				BipedIK val2 = (((Object)(object)val != (Object)null) ? val.BodyIK : null);
				if ((Object)(object)avatar == (Object)null || (Object)(object)val2 == (Object)null || val2.solvers == null || val2.references == null)
				{
					return;
				}
				int instanceID = ((Object)val2).GetInstanceID();
				if (Riders.TryGetValue(instanceID, out Rider value))
				{
					if ((Object)(object)value.Board != (Object)null && ((Object)value.Board).GetInstanceID() == ((Object)board).GetInstanceID())
					{
						return;
					}
					value.Dispose();
					Riders.Remove(instanceID);
				}
				Transform val3 = null;
				Transform val4 = null;
				for (int i = 0; i < parts.childCount; i++)
				{
					Transform child = parts.GetChild(i);
					if (((Object)child).name == "Grip")
					{
						if (child.localPosition.x < 0f)
						{
							val3 = child;
						}
						else
						{
							val4 = child;
						}
					}
				}
				Transform pelvis = val2.references.pelvis;
				IKSolverLimb leftHand = val2.solvers.leftHand;
				object obj;
				if (leftHand == null)
				{
					obj = null;
				}
				else
				{
					TrigonometricBone bone = ((IKSolverTrigonometric)leftHand).bone3;
					obj = ((bone != null) ? ((Point)bone).transform : null);
				}
				Transform val5 = (Transform)obj;
				IKSolverLimb rightHand = val2.solvers.rightHand;
				object obj2;
				if (rightHand == null)
				{
					obj2 = null;
				}
				else
				{
					TrigonometricBone bone2 = ((IKSolverTrigonometric)rightHand).bone3;
					obj2 = ((bone2 != null) ? ((Point)bone2).transform : null);
				}
				Transform val6 = (Transform)obj2;
				if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null) && !((Object)(object)pelvis == (Object)null) && !((Object)(object)val5 == (Object)null) && !((Object)(object)val6 == (Object)null) && !((Object)(object)avatar.LeftShoulder == (Object)null) && !((Object)(object)avatar.RightShoulder == (Object)null) && Below(pelvis, ((Component)avatar).transform))
				{
					Rider rider = new Rider(player, board, parts, val2, val3, val4, pelvis);
					rider.LeftPalm = Hand.PalmFrame(val5, left: true);
					rider.RightPalm = Hand.PalmFrame(val6, left: false);
					rider.LeftContact = Hand.ContactOffset(val5, rider.LeftPalm);
					rider.RightContact = Hand.ContactOffset(val6, rider.RightPalm);
					if (!((Behaviour)val2).enabled)
					{
						rider.EnabledIK = true;
						((Behaviour)val2).enabled = true;
					}
					Riders.Add(instanceID, rider);
				}
			}
			catch (Exception ex)
			{
				Warn("the rider keeps the skateboard stance: " + ex.Message);
			}
		}

		private static bool Below(Transform t, Transform root)
		{
			int instanceID = ((Object)root).GetInstanceID();
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null)
			{
				if (((Object)parent).GetInstanceID() == instanceID)
				{
					return true;
				}
				parent = parent.parent;
			}
			return false;
		}

		public static bool Holds(Skateboard board)
		{
			if (Riders.Count == 0)
			{
				return false;
			}
			int instanceID = ((Object)board).GetInstanceID();
			foreach (Rider value in Riders.Values)
			{
				if (value.Snapshot.Captured && (Object)(object)value.Board != (Object)null && ((Object)value.Board).GetInstanceID() == instanceID)
				{
					return true;
				}
			}
			return false;
		}

		public static void LateTick()
		{
			if (Riders.Count == 0)
			{
				return;
			}
			Gone.Clear();
			foreach (KeyValuePair<int, Rider> rider in Riders)
			{
				Rider value = rider.Value;
				try
				{
					if (!value.Valid)
					{
						Gone.Add(rider.Key);
					}
					else if (value.Snapshot.Captured)
					{
						value.Snapshot.Apply();
					}
				}
				catch (Exception ex)
				{
					Gone.Add(rider.Key);
					Warn("the rider's pose was dropped: " + ex.Message);
				}
			}
			foreach (int item in Gone)
			{
				Riders[item].Dispose();
				Riders.Remove(item);
			}
		}

		private static bool BeforeSolve(BipedIK ik)
		{
			if (Riders.Count == 0 || !Riders.TryGetValue(((Object)ik).GetInstanceID(), out Rider value) || value.Failed)
			{
				return true;
			}
			if (value.Solving)
			{
				value.Fail("the IK solve failed");
				return true;
			}
			if (!value.Valid)
			{
				return true;
			}
			if (value.Snapshot.Captured)
			{
				value.Snapshot.Apply();
				return false;
			}
			try
			{
				value.SaveSolver();
				value.Solving = true;
				Stance(value);
				AimHands(value);
			}
			catch (Exception ex)
			{
				value.Fail(ex.Message);
			}
			return true;
		}

		private static void AfterSolve(BipedIK ik)
		{
			//IL_0105: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//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_01c6: 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_0072: 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_0083: 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)
			if (Riders.Count == 0 || !Riders.TryGetValue(((Object)ik).GetInstanceID(), out Rider value) || !value.Solving)
			{
				return;
			}
			try
			{
				BipedIKSolvers solvers = ik.solvers;
				Transform parts = value.Parts;
				StraightenLegs(value);
				Il2CppReferenceArray<Transform> spine = ik.references.spine;
				if (spine != null && ((Il2CppArrayBase<Transform>)(object)spine).Length > 0 && (Object)(object)((Il2CppArrayBase<Transform>)(object)spine)[0] != (Object)null)
				{
					((Il2CppArrayBase<Transform>)(object)spine)[0].rotation = Quaternion.AngleAxis(2f, parts.right) * ((Il2CppArrayBase<Transform>)(object)spine)[0].rotation;
				}
				SetFoot(solvers.leftFoot, value.LeftFoot);
				SetFoot(solvers.rightFoot, value.RightFoot);
				SetKnees(value);
				((IKSolver)solvers.leftFoot).Update();
				((IKSolver)solvers.rightFoot).Update();
				TwoBone(solvers.leftFoot, value.LeftFoot, value.LeftKnee);
				TwoBone(solvers.rightFoot, value.RightFoot, value.RightKnee);
				AimHands(value);
				Vector3 fit = parts.forward * 0.02f;
				float num = Mathf.Max(new float[3]
				{
					0.15f,
					BarRise(solvers.leftHand, value.LeftHand, parts.up, fit),
					BarRise(solvers.rightHand, value.RightHand, parts.up, fit)
				});
				ScooterModel.RaiseHandlebar(parts, Mathf.Min(num, 0.4f));
				AimHands(value);
				((IKSolver)solvers.leftHand).Update();
				((IKSolver)solvers.rightHand).Update();
				TwoBone(solvers.leftHand, value.LeftHand, null);
				TwoBone(solvers.rightHand, value.RightHand, null);
				try
				{
					Hand.Curl(((Point)((IKSolverTrigonometric)solvers.leftHand).bone3).transform, value.LeftPalm);
					Hand.Curl(((Point)((IKSolverTrigonometric)solvers.rightHand).bone3).transform, value.RightPalm);
				}
				catch (Exception ex)
				{
					Warn("the rider's fingers stay straight: " + ex.Message);
				}
				value.Snapshot.Capture();
			}
			catch (Exception ex2)
			{
				ScooterModel.RaiseHandlebar(value.Parts, 0f);
				value.Fail(ex2.Message);
			}
			finally
			{
				value.RestoreSolver();
			}
		}

		private static void Stance(Rider rider)
		{
			//IL_0020: 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_00d5: 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_00e5: 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_00eb: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0065: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: 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_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			BipedIKSolvers solvers = rider.IK.solvers;
			Avatar avatar = rider.Player.Avatar;
			Transform parts = rider.Parts;
			Vector3 up = parts.up;
			Transform transform = solvers.pelvis.transform;
			Transform transform2 = ((Point)((IKSolverTrigonometric)solvers.leftFoot).bone3).transform;
			Transform transform3 = ((Point)((IKSolverTrigonometric)solvers.rightFoot).bone3).transform;
			Vector3 val;
			if (!rider.Calibrated)
			{
				val = Vector3.ProjectOnPlane(avatar.RightShoulder.position - avatar.LeftShoulder.position, up);
				val = Vector3.Cross(((Vector3)(ref val)).normalized, up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				if (((Vector3)(ref normalized)).sqrMagnitude < 0.5f)
				{
					throw new InvalidOperationException("the shoulders are not level");
				}
				rider.PelvisForward = Quaternion.Inverse(transform.rotation) * normalized;
				rider.Calibrated = true;
			}
			val = Vector3.ProjectOnPlane(transform.rotation * rider.PelvisForward, up);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = Vector3.ProjectOnPlane(parts.forward, up);
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			Quaternion val2 = Quaternion.AngleAxis(Vector3.SignedAngle(normalized2, normalized3, up), up);
			if (solvers.spine != null)
			{
				((IKSolver)solvers.spine).IKPositionWeight = 0f;
			}
			float y = parts.InverseTransformPoint(transform2.position).y;
			float y2 = parts.InverseTransformPoint(transform3.position).y;
			float num = Mathf.Clamp(Mathf.Min(y, y2), 0.03f, 0.2f);
			Quaternion rotation = val2 * transform2.rotation;
			Quaternion rotation2 = val2 * transform3.rotation;
			Vector3 val3 = Toes((y <= y2) ? transform2 : transform3);
			Vector3 val4 = Toes(transform2);
			Vector3 val5 = Toes(transform3);
			if (((Vector3)(ref val3)).sqrMagnitude > 1E-06f)
			{
				if (((Vector3)(ref val4)).sqrMagnitude > 1E-06f)
				{
					rotation = val2 * Quaternion.FromToRotation(val4, val3) * transform2.rotation;
				}
				if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f)
				{
					rotation2 = val2 * Quaternion.FromToRotation(val5, val3) * transform3.rotation;
				}
			}
			rider.PelvisTarget.position = transform.position;
			rider.PelvisTarget.rotation = val2 * transform.rotation;
			solvers.pelvis.target = rider.PelvisTarget;
			solvers.pelvis.positionWeight = 0f;
			solvers.pelvis.rotationWeight = 1f;
			solvers.pelvis.rotationOffset = Vector3.zero;
			rider.LeftFoot.position = parts.TransformPoint(new Vector3(-0.025f, num, 0.16f));
			rider.RightFoot.position = parts.TransformPoint(new Vector3(0.025f, num, -0.16f));
			rider.LeftFoot.rotation = rotation;
			rider.RightFoot.rotation = rotation2;
			SetFoot(solvers.leftFoot, rider.LeftFoot);
			SetFoot(solvers.rightFoot, rider.RightFoot);
			SetKnees(rider);
		}

		private static Vector3 Toes(Transform ankle)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)ankle, includeInactive: true))
			{
				if ((Object)(object)componentsInChild != (Object)null && ((Object)componentsInChild).GetInstanceID() != ((Object)ankle).GetInstanceID() && ((Object)componentsInChild).name.IndexOf("toe", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return componentsInChild.position - ankle.position;
				}
			}
			return Vector3.zero;
		}

		private static void SetFoot(IKSolverLimb limb, Transform target)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			((IKSolverTrigonometric)limb).target = target;
			((IKSolver)limb).IKPosition = target.position;
			((IKSolverTrigonometric)limb).IKRotation = target.rotation;
			((IKSolver)limb).IKPositionWeight = 1f;
			((IKSolverTrigonometric)limb).IKRotationWeight = 1f;
			limb.maintainRotationWeight = 0f;
		}

		private static void SetKnees(Rider rider)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_002e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0068: 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_0078: 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)
			Transform parts = rider.Parts;
			rider.LeftKnee.position = rider.LeftFoot.position + parts.forward * 0.55f + parts.up * 0.45f;
			rider.RightKnee.position = rider.RightFoot.position + parts.forward * 0.55f + parts.up * 0.45f;
			(IKSolverLimb, Transform)[] array = new(IKSolverLimb, Transform)[2]
			{
				(rider.IK.solvers.leftFoot, rider.LeftKnee),
				(rider.IK.solvers.rightFoot, rider.RightKnee)
			};
			for (int i = 0; i < array.Length; i++)
			{
				var (val, bendGoal) = array[i];
				val.bendGoal = bendGoal;
				val.bendModifier = (BendModifier)4;
				val.bendModifierWeight = 1f;
			}
		}

		private static void AimHands(Rider rider)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b4: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00fb: 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_0113: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			Transform parts = rider.Parts;
			BipedIKSolvers solvers = rider.IK.solvers;
			(IKSolverLimb, Transform, Transform, Quaternion, Vector3)[] array = new(IKSolverLimb, Transform, Transform, Quaternion, Vector3)[2]
			{
				(solvers.leftHand, rider.LeftGrip, rider.LeftHand, rider.LeftPalm, rider.LeftContact),
				(solvers.rightHand, rider.RightGrip, rider.RightHand, rider.RightPalm, rider.RightContact)
			};
			for (int i = 0; i < array.Length; i++)
			{
				(IKSolverLimb, Transform, Transform, Quaternion, Vector3) tuple = array[i];
				IKSolverLimb item = tuple.Item1;
				Transform item2 = tuple.Item2;
				Transform item3 = tuple.Item3;
				Quaternion item4 = tuple.Item4;
				Vector3 item5 = tuple.Item5;
				Quaternion val = Hand.WristRotation(parts, item4, 10f);
				float num = Mathf.Max(Mathf.Abs(item2.lossyScale.x), Mathf.Abs(item2.lossyScale.z)) * 0.5f;
				Vector3 val2 = item2.position + parts.up * num - parts.forward * 0.02f;
				item3.rotation = val;
				item3.position = val2 - val * item5;
				((IKSolverTrigonometric)item).target = item3;
				((IKSolver)item).IKPosition = item3.position;
				((IKSolverTrigonometric)item).IKRotation = val;
				((IKSolver)item).IKPositionWeight = 1f;
				((IKSolverTrigonometric)item).IKRotationWeight = 1f;
				item.maintainRotationWeight = 0f;
			}
		}

		private static void StraightenLegs(Rider rider)
		{
			//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_0033: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0073: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			BipedIKSolvers solvers = rider.IK.solvers;
			Transform transform = solvers.pelvis.transform;
			Vector3 up = rider.Parts.up;
			Vector3 val = (((Point)((IKSolverTrigonometric)solvers.leftFoot).bone1).transform.position + ((Point)((IKSolverTrigonometric)solvers.rightFoot).bone1).transform.position) * 0.5f;
			Vector3 val2 = (rider.LeftFoot.position + rider.RightFoot.position) * 0.5f;
			transform.position += Vector3.ProjectOnPlane(val2 - val, up);
			float num = Reach(solvers.leftFoot, rider.LeftFoot.position, up, 0.9999f) + Vector3.Dot(rider.LeftFoot.position - ((Point)((IKSolverTrigonometric)solvers.leftFoot).bone1).transform.position, up);
			float num2 = Reach(solvers.rightFoot, rider.RightFoot.position, up, 0.9999f) + Vector3.Dot(rider.RightFoot.position - ((Point)((IKSolverTrigonometric)solvers.rightFoot).bone1).transform.position, up);
			transform.position += up * Mathf.Min(num, num2);
		}

		private static float Reach(IKSolverLimb limb, Vector3 target, Vector3 up, float stretch)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Point)((IKSolverTrigonometric)limb).bone1).transform.position;
			Vector3 position2 = ((Point)((IKSolverTrigonometric)limb).bone2).transform.position;
			Vector3 position3 = ((Point)((IKSolverTrigonometric)limb).bone3).transform.position;
			float num = (Vector3.Distance(position, position2) + Vector3.Distance(position2, position3)) * stretch;
			Vector3 val = Vector3.ProjectOnPlane(position - target, up);
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			return Mathf.Sqrt(Mathf.Max(0f, num * num - sqrMagnitude));
		}

		private static float BarRise(IKSolverLimb limb, Transform target, Vector3 up, Vector3 fit)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0056: 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_005d: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 position = ((Point)((IKSolverTrigonometric)limb).bone1).transform.position;
			Vector3 position2 = ((Point)((IKSolverTrigonometric)limb).bone2).transform.position;
			Vector3 position3 = ((Point)((IKSolverTrigonometric)limb).bone3).transform.position;
			float num = (Vector3.Distance(position, position2) + Vector3.Distance(position2, position3)) * 0.97f;
			Vector3 val = target.position + fit - position;
			Vector3 val2 = Vector3.ProjectOnPlane(val, up);
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			if (sqrMagnitude >= num * num)
			{
				return 0f;
			}
			return Mathf.Max(0f, 0f - Mathf.Sqrt(num * num - sqrMagnitude) - Vector3.Dot(val, up));
		}

		private static void TwoBone(IKSolverLimb limb, Transform target, Transform? bendGoal)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_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_00c8: 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_0142: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_023a: 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: Unknown result type (might be due to invalid IL or missing references)
			//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_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: 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_027a: Unknown result type (might be due to invalid IL or missing references)
			TrigonometricBone bone = ((IKSolverTrigonometric)limb).bone1;
			Transform val = ((bone != null) ? ((Point)bone).transform : null);
			TrigonometricBone bone2 = ((IKSolverTrigonometric)limb).bone2;
			Transform val2 = ((bone2 != null) ? ((Point)bone2).transform : null);
			TrigonometricBone bone3 = ((IKSolverTrigonometric)limb).bone3;
			Transform val3 = ((bone3 != null) ? ((Point)bone3).transform : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				throw new InvalidOperationException("the limb rig is incomplete");
			}
			Vector3 val4 = (((Object)(object)bendGoal != (Object)null) ? Vector3.Cross(bendGoal.position - val.position, target.position - val.position) : Vector3.Cross(val2.position - val.position, val3.position - val2.position));
			if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f)
			{
				val4 = ((IKSolverTrigonometric)limb).bendNormal;
			}
			float num = Vector3.Distance(val.position, val2.position);
			float num2 = Vector3.Distance(val2.position, val3.position);
			Vector3 val5 = target.position - val.position;
			if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f || num < 0.0001f || num2 < 0.0001f || ((Vector3)(ref val5)).sqrMagnitude < 1E-06f)
			{
				throw new InvalidOperationException("the limb cannot bend");
			}
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num3 = Mathf.Clamp(((Vector3)(ref val5)).magnitude, Mathf.Abs(num - num2) + 0.0001f, num + num2 - 0.0001f);
			Vector3 val6 = Vector3.Cross(normalized, val4);
			Vector3 normalized2 = ((Vector3)(ref val6)).normalized;
			if (((Vector3)(ref normalized2)).sqrMagnitude < 0.5f)
			{
				throw new InvalidOperationException("the limb has no bend direction");
			}
			float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3);
			float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4));
			Vector3 val7 = val.position + normalized * num4 + normalized2 * num5;
			Vector3 val8 = val.position + normalized * num3;
			val.rotation = Quaternion.FromToRotation(val2.position - val.position, val7 - val.position) * val.rotation;
			val2.rotation = Quaternion.FromToRotation(val3.position - val2.position, val8 - val2.position) * val2.rotation;
			val3.rotation = target.rotation;
		}

		private static void Warn(string message)
		{
			if (!_warned)
			{
				_warned = true;
				MelonLogger.Warning("Electric Scooter: " + message);
			}
		}
	}
	internal static class ScooterItem
	{
		public const string Id = "electricscooter";

		public const string DisplayName = "Electric Scooter";

		public const string Description = "Electric kick scooter with big wheels. Rolls over curbs, never wears you out and outruns any skateboard.";

		private const string SourceId = "goldenskateboard";

		private static StorableItemDefinition? _definition;

		private static bool _failed;

		public static StorableItemDefinition? Definition => _definition;

		public static bool Is(ItemInstance? item)
		{
			if (item != null)
			{
				return ((BaseItemInstance)item).ID == "electricscooter";
			}
			return false;
		}

		public static void EnsureRegistered()
		{
			if (_failed)
			{
				return;
			}
			Registry instance = Singleton<Registry>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			try
			{
				if ((!((Object)(object)_definition == (Object)null) || Create()) && !Registry.ItemExists("electricscooter"))
				{
					instance.AddToRegistry((ItemDefinition)(object)_definition);
				}
			}
			catch (Exception value)
			{
				_failed = true;
				MelonLogger.Error($"Electric Scooter item could not be registered: {value}");
			}
		}

		private static bool Create()
		{
			if (!UnityQuery.TryCastTo<StorableItemDefinition>((Object?)(object)Singleton<Registry>.Instance._GetItem("goldenskateboard", false), out StorableItemDefinition result))
			{
				return false;
			}
			StorableItemDefinition val = Object.Instantiate<StorableItemDefinition>(result);
			((Object)val).name = "ElectricScooter";
			((Object)val).hideFlags = (HideFlags)32;
			((BaseItemDefinition)val).ID = "electricscooter";
			((BaseItemDefinition)val).Name = "Electric Scooter";
			((BaseItemDefinition)val).Description = "Electric kick scooter with big wheels. Rolls over curbs, never wears you out and outruns any skateboard.";
			val.BasePurchasePrice = Config.Price;
			Sprite val2 = LoadIcon();
			if ((Object)(object)val2 != (Object)null)
			{
				((BaseItemDefinition)val).Icon = val2;
			}
			_definition = val;
			MelonLogger.Msg("Electric Scooter item created");
			return true;
		}

		private static Sprite? LoadIcon()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_004b: Expected O, but got Unknown
			//IL_007c: 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)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ElectricScooter.item-icon.png");
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = "ElectricScooter Icon",
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)32
			};
			if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(memoryStream.ToArray()), true))
			{
				return null;
			}
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)obj).name = ((Object)val).name;
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}
	}
	internal static class ScooterModel
	{
		private const string PartsName = "ElectricScooter Parts";

		private const float WheelOffset = 0.52f;

		private const float WheelWidth = 0.055f;

		private const float HandlebarHeight = 0.98f;

		private const float HandlebarWidth = 0.5f;

		private const float HandlebarRake = 0.2f;

		private static Mesh? _cylinder;

		private static Mesh? _box;

		private static Material? _gold;

		private static Material? _dark;

		private static Material? _tyre;

		private static Material? _steel;

		private static bool _failed;

		private static Transform? _ridden;

		private static Skateboard? _riddenBoard;

		private static bool _handsFailed;

		private const float FootSpread = 0.075f;

		private const float FootStagger = 0.1f;

		public static Transform? Dress(Skateboard board)
		{
			Transform? obj = (_ridden = DressBoard(board, ScooterRide.HoverHeight));
			_riddenBoard = (((Object)(object)obj != (Object)null) ? board : null);
			return obj;
		}

		public static Transform? DressRemote(Skateboard board, float hoverHeight)
		{
			return DressBoard(board, hoverHeight);
		}

		private static Transform? DressBoard(Skateboard board, float hover)
		{
			//IL_00c9: 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)
			SkateboardVisuals val = UiKit.Get<SkateboardVisuals>((Component)(object)board);
			Transform val2 = FindTruck(((Component)board).transform);
			if ((Object)(object)val == (Object)null || (Object)(object)val.Board == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return null;
			}
			Transform val3 = Build(((Component)board).transform, val.Board, val2.parent, val2, hover, folded: false);
			if ((Object)(object)val3 == (Object)null)
			{
				return null;
			}
			Pose(board, val3);
			SkateboardEffects val4 = UiKit.Get<SkateboardEffects>((Component)(object)board);
			if ((Object)(object)val4 == (Object)null || val4.Trails == null)
			{
				return val3;
			}
			for (int i = 0; i < ((Il2CppArrayBase<TrailRenderer>)(object)val4.Trails).Length; i++)
			{
				TrailRenderer val5 = ((Il2CppArrayBase<TrailRenderer>)(object)val4.Trails)[i];
				if (!((Object)(object)val5 == (Object)null))
				{
					float num = ((i % 2 == 0) ? (-0.02f) : 0.02f);
					((Component)val5).transform.position = val3.TransformPoint(new Vector3(num, Ground(hover) + 0.015f, -0.52f));
					val5.Clear();
				}
			}
			return val3;
		}

		public static void DressHeld(Transform prop, float hoverHeight)
		{
			Transform val = FindTruck(prop);
			if ((Object)(object)val != (Object)null)
			{
				Build(prop, val.parent, val.parent, val, hoverHeight, folded: true);
			}
		}

		public static bool IsDressed(Transform root)
		{
			return (Object)(object)FindParts(root) != (Object)null;
		}

		private static Transform? FindParts(Transform root)
		{
			foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)root, includeInactive: true))
			{
				if (((Object)componentsInChild).name == "ElectricScooter Parts" && Owns(root, componentsInChild))
				{
					return componentsInChild;
				}
			}
			return null;
		}

		private static bool Owns(Transform root, Transform descendant)
		{
			if (!((Object)(object)UnityQuery.GetComponentInParent<Player>((Component)(object)descendant) == (Object)null))
			{
				return (Object)(object)UnityQuery.GetComponentInParent<Player>((Component)(object)root) != (Object)null;
			}
			return true;
		}

		private static Transform? FindTruck(Transform root)
		{
			foreach (MeshRenderer componentsInChild in UnityQuery.GetComponentsInChildren<MeshRenderer>((Component)(object)root, includeInactive: false))
			{
				if (((Object)componentsInChild).name.StartsWith("Truck", StringComparison.Ordinal) && HasWheel(((Component)componentsInChild).transform) && Owns(root, ((Component)componentsInChild).transform))
				{
					return ((Component)componentsInChild).transform;
				}
			}
			return null;
		}

		private static bool HasWheel(Transform truck)
		{
			foreach (Transform componentsInChild in UnityQuery.GetComponentsInChildren<Transform>((Component)(object)truck, includeInactive: true))
			{
				if (((Object)componentsInChild).name.StartsWith("Wheel", StringComparison.Ordinal))
				{
					return true;
				}
			}
			return false;
		}

		private static void HideWheels(Transform root, Transform parts)
		{
			int instanceID = ((Object)root).GetInstanceID();
			int instanceID2 = ((Object)parts).GetInstanceID();
			foreach (MeshRenderer componentsInChild in UnityQuery.GetComponentsInChildren<MeshRenderer>((Component)(object)root, includeInactive: true))
			{
				if (!Owns(root, ((Component)componentsInChild).transform))
				{
					continue;
				}
				bool flag = false;
				Transform val = ((Component)componentsInChild).transform;
				while ((Object)(object)val != (Object)null && ((Object)val).GetInstanceID() != instanceID)
				{
					if (((Object)val).GetInstanceID() == instanceID2)
					{
						flag = false;
						break;
					}
					if (((Object)val).name.StartsWith("Wheel", StringComparison.OrdinalIgnoreCase))
					{
						flag = true;
					}
					val = val.parent;
				}
				if (flag)
				{
					((Renderer)componentsInChild).enabled = false;
				}
			}
		}

		private static float Ground(float hover)
		{
			return 0f - (hover - 0.012f);
		}

		private static float Radius(float hover)
		{
			return Mathf.Min((hover - 0.02f) / 2f, 0.16f);
		}

		private static Vector3 Crown(float hover)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(0f, Ground(hover) + Radius(hover) * 2f + 0.035f, 0.48499998f);
		}

		private static Vector3 HandlebarCentre(Vector3 crown, bool folded)
		{
			//IL_001d: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!folded)
			{
				return new Vector3(0f, 0.98f, 0.32f);
			}
			return new Vector3(0f, crown.y + 0.05f, crown.z - (0.98f - crown.y));
		}

		private static Transform? Build(Transform root, Transform parent, Transform frame, Transform truck, float hoverHeight, bool folded)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_00ea: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0175: 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_0215: 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_0231: 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_024e: Unknown