Decompiled source of ElectricScooter v1.0.0

Mods/ElectricScooter_Il2Cpp.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using ElectricScooter;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
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.0.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+6d02579b95b27e67a5127536582ba67848828bf5")]
[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;

		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 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);
		}
	}
	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.0.0 loaded");
		}

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

		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(result);
				}
			}
		}
	}
	internal static class ModInfo
	{
		public const string Name = "ElectricScooter";

		public const string Version = "1.0.0";

		public const string Author = "BbIJABNPOBATEJb";

		public const string DownloadLink = "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods";
	}
	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 SkateboardAnimation? _riddenAnimation;

		private static bool _handsFailed;

		public static void Dress(Skateboard board)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			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;
			}
			float hoverHeight = ScooterRide.HoverHeight;
			_ridden = Build(val.Board, val2.parent, val2, hoverHeight, folded: false);
			_riddenAnimation = board.Animation;
			if ((Object)(object)_ridden == (Object)null)
			{
				return;
			}
			SkateboardEffects val3 = UiKit.Get<SkateboardEffects>((Component)(object)board);
			if ((Object)(object)val3 == (Object)null || val3.Trails == null)
			{
				return;
			}
			for (int i = 0; i < ((Il2CppArrayBase<TrailRenderer>)(object)val3.Trails).Length; i++)
			{
				TrailRenderer val4 = ((Il2CppArrayBase<TrailRenderer>)(object)val3.Trails)[i];
				if (!((Object)(object)val4 == (Object)null))
				{
					float num = ((i % 2 == 0) ? (-0.02f) : 0.02f);
					((Component)val4).transform.position = _ridden.TransformPoint(new Vector3(num, Ground(hoverHeight) + 0.015f, -0.52f));
					val4.Clear();
				}
			}
		}

		public static void DressHeld(Skateboard_Equippable equippable)
		{
			Transform val = FindTruck(((Component)equippable).transform);
			if ((Object)(object)val != (Object)null)
			{
				Build(val.parent, val.parent, val, ScooterRide.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) && !((Object)(object)UiKit.Find(((Component)componentsInChild).transform, "Wheel") == (Object)null) && Owns(root, ((Component)componentsInChild).transform))
				{
					return ((Component)componentsInChild).transform;
				}
			}
			return null;
		}

		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 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00f2: 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_0112: 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_011b: 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_0127: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0244: 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_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: 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_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			if (_failed)
			{
				return null;
			}
			try
			{
				int layer = ((Component)truck).gameObject.layer;
				EnsureAssets(truck);
				Transform transform = new GameObject("ElectricScooter Parts").transform;
				transform.SetParent(parent, false);
				transform.position = frame.position;
				transform.rotation = frame.rotation;
				for (int i = 0; i < frame.childCount; i++)
				{
					Transform child = frame.GetChild(i);
					if (((Object)child).name.StartsWith("Truck", StringComparison.Ordinal))
					{
						((Component)child).gameObject.SetActive(false);
					}
				}
				float num = Radius(hoverHeight);
				float num2 = Ground(hoverHeight) + num;
				float num3 = num2 + num;
				float[] array = new float[2] { 0.52f, -0.52f };
				Vector3 val = default(Vector3);
				foreach (float num4 in array)
				{
					((Vector3)(ref val))..ctor(0f, num2, num4);
					Vector3 val2 = Vector3.right * 0.0275f;
					Rod(transform, "Tyre", val - val2, val + val2, num, _tyre, layer);
					Rod(transform, "Rim", val - val2 * 1.08f, val + val2 * 1.08f, num * 0.56f, _steel, layer);
					Rod(transform, "Hub", val - val2 * 1.3f, val + val2 * 1.3f, num * 0.17f, _gold, layer);
					float[] array2 = new float[2] { -0.042f, 0.042f };
					foreach (float num5 in array2)
					{
						Rod(transform, "Fork", new Vector3(num5, num2, num4), new Vector3(num5, num3 + 0.035f, num4 - Mathf.Sign(num4) * 0.035f), 0.011f, _dark, layer);
					}
				}
				Vector3 val3 = Crown(hoverHeight);
				Rod(transform, "Neck", new Vector3(0f, 0.004f, 0.32f), val3, 0.024f, _gold, layer);
				Rod(transform, "Crown", val3 + Vector3.left * 0.05f, val3 + Vector3.right * 0.05f, 0.016f, _dark, layer);
				Vector3 val4 = HandlebarCentre(val3, folded);
				Rod(transform, "Column", val3, val4, 0.019f, _gold, layer);
				Rod(transform, "Handlebar", val4 + Vector3.left * 0.25f, val4 + Vector3.right * 0.25f, 0.013f, _dark, layer);
				array = new float[2] { -1f, 1f };
				foreach (float num6 in array)
				{
					Rod(transform, "Grip", val4 + Vector3.right * num6 * 0.14f, val4 + Vector3.right * num6 * 0.255f, 0.019f, _tyre, layer);
				}
				if (!folded)
				{
					Vector3 val5 = Vector3.Lerp(val3, val4, 0.78f);
					Rod(transform, "Headlight", val5 + new Vector3(0f, 0f, 0.015f), val5 + new Vector3(0f, -0.004f, 0.06f), 0.026f, _dark, layer);
				}
				Vector3 val6 = default(Vector3);
				((Vector3)(ref val6))..ctor(0f, num3 + 0.035f, -0.48499998f);
				Rod(transform, "Tail", new Vector3(0f, 0.004f, -0.32f), val6, 0.02f, _gold, layer);
				Rod(transform, "Rear Crown", val6 + Vector3.left * 0.05f, val6 + Vector3.right * 0.05f, 0.016f, _dark, layer);
				Box(transform, "Fender", new Vector3(0f, num3 + 0.03f, -0.54999995f), new Vector3(0.07f, 0.01f, 0.2f), Quaternion.Euler(-14f, 0f, 0f), _dark, layer);
				Box(transform, "Battery", new Vector3(0f, -0.035f, 0f), new Vector3(0.15f, 0.045f, 0.5f), Quaternion.identity, _dark, layer);
				return transform;
			}
			catch (Exception value)
			{
				_failed = true;
				MelonLogger.Warning($"Electric Scooter model could not be built (the scooter still works): {value}");
				return null;
			}
		}

		public static void HoldHandlebar()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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)
			if (_handsFailed || (Object)(object)_ridden == (Object)null || (Object)(object)_riddenAnimation == (Object)null)
			{
				return;
			}
			try
			{
				SkateboardAnimation riddenAnimation = _riddenAnimation;
				if (!((Object)(object)riddenAnimation.HandContainer == (Object)null))
				{
					Vector3 val = HandlebarCentre(Crown(ScooterRide.HoverHeight), folded: false) + Vector3.up * 0.025f;
					Vector3 val2 = Vector3.right * 0.2f;
					Place(riddenAnimation, _ridden.TransformPoint(val - val2), riddenAnimation.LeftHandAlignment, riddenAnimation.LeftHandLoweredAlignment, riddenAnimation.LeftHandRaisedAlignment);
					Place(riddenAnimation, _ridden.TransformPoint(val + val2), riddenAnimation.RightHandAlignment, riddenAnimation.RightHandLoweredAlignment, riddenAnimation.RightHandRaisedAlignment);
				}
			}
			catch (Exception ex)
			{
				_handsFailed = true;
				MelonLogger.Warning("Electric Scooter: hands could not be put on the handlebar: " + ex.Message);
			}
		}

		private static void Place(SkateboardAnimation animation, Vector3 grip, params AlignmentSet[] sets)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = animation.HandContainer.InverseTransformPoint(grip);
			foreach (AlignmentSet val in sets)
			{
				if (val != null && !((Object)(object)val.Default == (Object)null))
				{
					val.Default.localPosition = localPosition;
					val.Animated = val.Default;
					if ((Object)(object)val.Transform != (Object)null)
					{
						val.Transform.localPosition = localPosition;
					}
				}
			}
		}

		private static void Rod(Transform parts, string name, Vector3 from, Vector3 to, float radius, Material material, int layer)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = NewPart(parts, name, _cylinder, material, layer).transform;
			transform.localPosition = (from + to) / 2f;
			Vector3 up = Vector3.up;
			Vector3 val = to - from;
			transform.localRotation = Quaternion.FromToRotation(up, ((Vector3)(ref val)).normalized);
			float num = radius * 2f;
			val = to - from;
			transform.localScale = new Vector3(num, ((Vector3)(ref val)).magnitude, radius * 2f);
		}

		private static void Box(Transform parts, string name, Vector3 centre, Vector3 size, Quaternion rotation, Material material, int layer)
		{
			//IL_0016: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = NewPart(parts, name, _box, material, layer).transform;
			transform.localPosition = centre;
			transform.localRotation = rotation;
			transform.localScale = size;
		}

		private static GameObject NewPart(Transform parts, string name, Mesh mesh, Material material, int layer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = layer
			};
			val.transform.SetParent(parts, false);
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			return val;
		}

		private static void EnsureAssets(Transform truck)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			if (_cylinder == null)
			{
				_cylinder = MakeCylinder(24);
			}
			if (_box == null)
			{
				_box = MakeBox();
			}
			if (!((Object)(object)_gold != (Object)null) || !((Object)(object)_dark != (Object)null) || !((Object)(object)_tyre != (Object)null) || !((Object)(object)_steel != (Object)null))
			{
				Material sharedMaterial = ((Renderer)UiKit.Get<MeshRenderer>((Component)(object)truck)).sharedMaterial;
				_gold = Tinted(sharedMaterial, "ElectricScooter Gold", new Color(0.96f, 0.72f, 0.14f), 0.1f, 0.55f);
				_steel = Tinted(sharedMaterial, "ElectricScooter Steel", new Color(0.66f, 0.68f, 0.72f), 0.1f, 0.5f);
				_dark = Tinted(sharedMaterial, "ElectricScooter Dark", new Color(0.13f, 0.13f, 0.15f), 0f, 0.4f);
				_tyre = Tinted(sharedMaterial, "ElectricScooter Tyre", new Color(0.05f, 0.05f, 0.055f), 0f, 0.15f);
			}
		}

		private static Material Tinted(Material source, string name, Color color, float metallic, float smoothness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(source)
			{
				name = name,
				hideFlags = (HideFlags)32
			};
			string[] array = new string[2] { "_BaseColor", "_Color" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetColor(text, color);
				}
			}
			array = new string[6] { "_BaseMap", "_MainTex", "_MetallicGlossMap", "_BumpMap", "_OcclusionMap", "_ParallaxMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			array = new string[5] { "_METALLICSPECGLOSSMAP", "_NORMALMAP", "_OCCLUSIONMAP", "_PARALLAXMAP", "_EMISSION" };
			foreach (string text3 in array)
			{
				val.DisableKeyword(text3);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			return val;
		}

		private static Mesh MakeCylinder(int segments)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<int> list3 = new List<int>();
			Vector3 val = default(Vector3);
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / (float)segments;
				((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
				list.Add(val * 0.5f + Vector3.down * 0.5f);
				list.Add(val * 0.5f + Vector3.up * 0.5f);
				list2.Add(val);
				list2.Add(val);
			}
			for (int j = 0; j < segments; j++)
			{
				int num2 = j * 2;
				list3.AddRange(new int[6]
				{
					num2,
					num2 + 1,
					num2 + 2,
					num2 + 2,
					num2 + 1,
					num2 + 3
				});
			}
			float[] array = new float[2] { -0.5f, 0.5f };
			foreach (float num3 in array)
			{
				int count = list.Count;
				Vector3 item = ((num3 > 0f) ? Vector3.up : Vector3.down);
				list.Add(new Vector3(0f, num3, 0f));
				list2.Add(item);
				for (int l = 0; l <= segments; l++)
				{
					float num4 = (float)l * (float)Math.PI * 2f / (float)segments;
					list.Add(new Vector3(Mathf.Cos(num4) * 0.5f, num3, Mathf.Sin(num4) * 0.5f));
					list2.Add(item);
				}
				for (int m = 0; m < segments; m++)
				{
					if (num3 > 0f)
					{
						list3.AddRange(new int[3]
						{
							count,
							count + 2 + m,
							count + 1 + m
						});
					}
					else
					{
						list3.AddRange(new int[3]
						{
							count,
							count + 1 + m,
							count + 2 + m
						});
					}
				}
			}
			return MakeMesh("ElectricScooter Cylinder", list, list2, list3);
		}

		private static Mesh MakeBox()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//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_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_00a2: 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_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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_00ff: 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_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_011d: 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_012e: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: 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_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_0177: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<int> list3 = new List<int>();
			Vector3[] array = (Vector3[])(object)new Vector3[3]
			{
				Vector3.right,
				Vector3.up,
				Vector3.forward
			};
			for (int i = 0; i < 3; i++)
			{
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num in array2)
				{
					Vector3 val = array[i] * num;
					Vector3 val2 = array[(i + 1) % 3];
					Vector3 val3 = array[(i + 2) % 3];
					int count = list.Count;
					list.Add(val * 0.5f - val2 * 0.5f - val3 * 0.5f);
					list.Add(val * 0.5f + val2 * 0.5f - val3 * 0.5f);
					list.Add(val * 0.5f + val2 * 0.5f + val3 * 0.5f);
					list.Add(val * 0.5f - val2 * 0.5f + val3 * 0.5f);
					for (int k = 0; k < 4; k++)
					{
						list2.Add(val);
					}
					if (num > 0f)
					{
						list3.AddRange(new int[6]
						{
							count,
							count + 1,
							count + 2,
							count,
							count + 2,
							count + 3
						});
					}
					else
					{
						list3.AddRange(new int[6]
						{
							count,
							count + 2,
							count + 1,
							count,
							count + 3,
							count + 2
						});
					}
				}
			}
			return MakeMesh("ElectricScooter Box", list, list2, list3);
		}

		private static Mesh MakeMesh(string name, List<Vector3> vertices, List<Vector3> normals, List<int> triangles)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0036: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			Mesh val = new Mesh
			{
				name = name,
				hideFlags = (HideFlags)32,
				vertices = Il2CppStructArray<Vector3>.op_Implicit(vertices.ToArray()),
				normals = Il2CppStructArray<Vector3>.op_Implicit(normals.ToArray()),
				uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])(object)new Vector2[vertices.Count]),
				triangles = Il2CppStructArray<int>.op_Implicit(triangles.ToArray())
			};
			val.RecalculateBounds();
			return val;
		}
	}
	internal static class ScooterRide
	{
		[HarmonyPatch(typeof(PlayerMovement), "ChangeStamina")]
		private static class NoStaminaDrain
		{
			private static void Prefix(ref float change)
			{
				if (change < 0f && Riding && Config.InfiniteStamina)
				{
					change = 0f;
				}
			}
		}

		private const float VanillaHoverHeight = 0.096f;

		private const float ColliderDrop = 0.04f;

		private const float MinPushStamina = 12.5f;

		private static Skateboard? _board;

		private static SkateboardSettings? _tuned;

		private static float _stamina;

		private static bool _failed;

		public static bool Riding => (Object)(object)_board != (Object)null;

		public static float HoverHeight => Config.StepHeight + 0.04f;

		public static void Tick()
		{
			if (_failed)
			{
				return;
			}
			try
			{
				Player local = Player.Local;
				Skateboard val = (((Object)(object)local != (Object)null) ? local.ActiveSkateboard : null);
				if ((Object)(object)val == (Object)null)
				{
					_board = null;
					_tuned = null;
					return;
				}
				if ((Object)(object)_board == (Object)null || ((Object)_board).GetInstanceID() != ((Object)val).GetInstanceID())
				{
					PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
					if ((Object)(object)instance == (Object)null || !ScooterItem.Is(instance.EquippedItem))
					{
						return;
					}
					Begin(val);
				}
				else if (!Same(val.CurentSettings, _tuned))
				{
					Tune(val);
				}
				KeepStamina();
				ScooterModel.HoldHandlebar();
			}
			catch (Exception value)
			{
				_failed = true;
				_board = null;
				MelonLogger.Error($"Electric Scooter ride failed: {value}");
			}
		}

		private static void Begin(Skateboard board)
		{
			//IL_0012: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			_board = board;
			Tune(board);
			Vector3 val = ((Component)board).transform.up * (HoverHeight - 0.096f);
			Transform transform = ((Component)board).transform;
			transform.position += val;
			Rigidbody rb = board.Rb;
			rb.position += val;
			PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance;
			_stamina = (((Object)(object)instance != (Object)null) ? Mathf.Max(instance.CurrentStaminaReserve, 12.5f) : 12.5f);
			ScooterModel.Dress(board);
		}

		private static void Tune(Skateboard board)
		{
			SkateboardSettings val = board.CurentSettings.Clone();
			float speed = Config.Speed;
			val.TopSpeed_Kmh *= speed;
			val.PushForceMultiplier *= speed;
			val.LongitudinalFrictionCurve = Stretched(val.LongitudinalFrictionCurve, 1f / speed);
			val.HoverHeight = HoverHeight;
			val.HoverRayLength = HoverHeight + 0.1f;
			val.Hover_P = 120f;
			val.Hover_I = 5f;
			val.Hover_D = 2f;
			board._settings = val;
			_tuned = val;
		}

		private static AnimationCurve Stretched(AnimationCurve curve, float factor)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			Il2CppStructArray<Keyframe> keys = curve.keys;
			Keyframe[] array = (Keyframe[])(object)new Keyframe[((Il2CppArrayBase<Keyframe>)(object)keys).Length];
			for (int i = 0; i < array.Length; i++)
			{
				Keyframe val = ((Il2CppArrayBase<Keyframe>)(object)keys)[i];
				((Keyframe)(ref val)).time = ((Keyframe)(ref val)).time * factor;
				((Keyframe)(ref val)).inTangent = ((Keyframe)(ref val)).inTangent / factor;
				((Keyframe)(ref val)).outTangent = ((Keyframe)(ref val)).outTangent / factor;
				array[i] = val;
			}
			return new AnimationCurve(array);
		}

		private static bool Same(SkateboardSettings? a, SkateboardSettings? b)
		{
			if (a == null || b == null)
			{
				if (a == null)
				{
					return b == null;
				}
				return false;
			}
			return ((Il2CppObjectBase)a).Pointer == ((Il2CppObjectBase)b).Pointer;
		}

		private static void KeepStamina()
		{
			if (!Config.InfiniteStamina)
			{
				return;
			}
			PlayerMovement instance = PlayerSingleton<PlayerMovement>.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				float currentStaminaReserve = instance.CurrentStaminaReserve;
				if (currentStaminaReserve < _stamina)
				{
					instance.SetStamina(_stamina, false);
				}
				else
				{
					_stamina = currentStaminaReserve;
				}
			}
		}
	}
	internal static class ScooterShop
	{
		private const float CheckInterval = 3f;

		private static float _nextCheck;

		private static bool _failed;

		public static void Tick()
		{
			if (_failed || Time.unscaledTime < _nextCheck)
			{
				return;
			}
			_nextCheck = Time.unscaledTime + 3f;
			StorableItemDefinition definition = ScooterItem.Definition;
			if ((Object)(object)definition == (Object)null || (Object)(object)Player.Local == (Object)null)
			{
				return;
			}
			try
			{
				foreach (DialogueController_SkateboardSeller item in UnityQuery.FindInScenes<DialogueController_SkateboardSeller>())
				{
					Stock(item, definition);
				}
			}
			catch (Exception value)
			{
				_failed = true;
				MelonLogger.Error($"Electric Scooter could not be added to the skate shop: {value}");
			}
		}

		private static void Stock(DialogueController_SkateboardSeller seller, StorableItemDefinition definition)
		{
			//IL_0052: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008b: Expected O, but got Unknown
			List<Option> options = seller.Options;
			for (int i = 0; i < options.Count; i++)
			{
				Option val = options[i];
				if (!((Object)(object)val.Item == (Object)null) && !(((BaseItemDefinition)val.Item).ID != "electricscooter"))
				{
					val.Price = Config.Price;
					return;
				}
			}
			options.Add(new Option
			{
				Name = "Electric Scooter",
				Price = Config.Price,
				IsAvailable = true,
				NotAvailableReason = "",
				Item = (ItemDefinition)(object)definition
			});
			MelonLogger.Msg($"Electric Scooter is now sold at the skate shop for ${Config.Price:0}");
		}
	}
}