Decompiled source of LootScooter v1.0.0

plugins/LootScooter/LootScooter.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NightShiftWorks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Loot Scooter")]
[assembly: AssemblyTitle("LootScooter")]
[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 NightShiftWorks.LootScooter
{
	internal static class Discovery
	{
		internal static IEnumerator TrySpawn(LevelGenerator level)
		{
			yield return (object)new WaitForSeconds(0.2f);
			if (!Object.op_Implicit((Object)(object)level) || (Object)(object)level != (Object)(object)LevelGenerator.Instance || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || Object.op_Implicit((Object)(object)Object.FindAnyObjectByType<ScooterRide>()))
			{
				yield break;
			}
			Plugin instance = Plugin.Instance;
			if (!ScooterBalance.ShouldSpawn(instance.SpawnChance.Value, Random.Range(0f, 100f)))
			{
				yield break;
			}
			try
			{
				if (TryFindParkingSpot(level, instance.PlacementBounds, out var position, out var rotation))
				{
					float num = Random.Range(35f, 60f);
					GameObject val = NetworkPrefabs.SpawnNetworkPrefab(instance.Scooter.prefab, position, rotation, (byte)0, new object[1] { num });
					if (Object.op_Implicit((Object)(object)val))
					{
						val.GetComponent<ScooterRide>().SetFoundCharge(num);
						instance.LogSpawn($"Loot Scooter parked in the mission with {num:F0}% charge.");
					}
				}
				else
				{
					instance.LogSpawn("Loot Scooter skipped this mission because no clear parking spot was found.");
				}
			}
			catch (Exception exception)
			{
				instance.LogSpawnFailure(exception);
			}
		}

		private static bool TryFindParkingSpot(LevelGenerator level, Bounds bounds, out Vector3 position, out Quaternion rotation)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00d0: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_017f: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			Vector3 entrance = (Object.op_Implicit((Object)(object)level.LevelPathTruck) ? ((Component)level.LevelPathTruck).transform.position : ((Component)level).transform.position);
			RaycastHit val2 = default(RaycastHit);
			foreach (LevelPoint item in (from _ in level.LevelPathPoints.Where(delegate(LevelPoint point)
				{
					//IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0040: Unknown result type (might be due to invalid IL or missing references)
					if (Object.op_Implicit((Object)(object)point) && !point.Truck && Object.op_Implicit((Object)(object)point.Room) && !point.Room.Truck)
					{
						Vector3 val5 = ((Component)point).transform.position - entrance;
						return ((Vector3)(ref val5)).sqrMagnitude >= 36f;
					}
					return false;
				})
				orderby Random.value
				select _).Take(80).ToList())
			{
				for (int num = 0; num < 3; num++)
				{
					Vector2 val = Random.insideUnitCircle * 0.8f;
					if (Physics.Raycast(((Component)item).transform.position + new Vector3(val.x, 0.9f, val.y), Vector3.down, ref val2, 2.25f, -5, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val2)).normal.y < 0.93f) && !Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider.attachedRigidbody))
					{
						rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
						position = ((RaycastHit)(ref val2)).point + Vector3.up * (0.09f - ((Bounds)(ref bounds)).min.y);
						Vector3 val3 = position + rotation * ((Bounds)(ref bounds)).center;
						Vector3 val4 = ((Bounds)(ref bounds)).extents + new Vector3(0.14f, 0.01f, 0.16f);
						if (!Physics.CheckBox(val3, val4, rotation, -5, (QueryTriggerInteraction)1))
						{
							return true;
						}
					}
				}
			}
			position = default(Vector3);
			rotation = default(Quaternion);
			return false;
		}
	}
	[BepInPlugin("NightShiftWorks.LootScooter", "Loot Scooter", "1.0.0")]
	[BepInDependency("REPOLib", "4.5.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")]
		private static class LoadItemsPatch
		{
			[HarmonyPostfix]
			private static void Postfix(StatsManager __instance)
			{
				Instance.RegisterScooter(__instance);
			}
		}

		[HarmonyPatch(typeof(StatsManager), "Start")]
		private static class StatsStartPatch
		{
			[HarmonyPostfix]
			private static void Postfix(StatsManager __instance)
			{
				if ((Object)(object)__instance == (Object)(object)StatsManager.instance)
				{
					Instance.RegisterScooter(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(LevelGenerator), "GenerateDoneApply")]
		private static class GenerationPatch
		{
			[HarmonyPostfix]
			private static void Postfix(LevelGenerator __instance)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel() && Object.op_Implicit((Object)(object)Instance.Scooter))
				{
					((MonoBehaviour)__instance).StartCoroutine(Discovery.TrySpawn(__instance));
				}
			}
		}

		internal const string Id = "NightShiftWorks.LootScooter";

		internal const string AssetName = "Item NightShiftWorks Loot Scooter";

		private const string ScoutAssetName = "Item Vehicle Semiscooter Small";

		private const string StockItemFolder = "Items/Items/";

		private bool registrationFailed;

		internal static Plugin Instance { get; private set; }

		internal ConfigEntry<int> SpawnChance { get; private set; }

		internal ConfigEntry<float> FullThrottleSeconds { get; private set; }

		internal ConfigEntry<float> EngineNoiseRadius { get; private set; }

		internal Item? Scooter { get; private set; }

		internal Bounds PlacementBounds { get; private set; }

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			SpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Salvage", "SpawnChancePercent", 75, new ConfigDescription("Chance of finding a scooter in a mission with suitable parking.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			FullThrottleSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "FullThrottleSeconds", 48f, new ConfigDescription("Seconds of continuous full input from a full battery.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 180f), Array.Empty<object>()));
			EngineNoiseRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Handling", "EngineNoiseRadius", 5f, new ConfigDescription("Range at which a hard-running motor can draw enemy attention. Set to zero to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 15f), Array.Empty<object>()));
			new Harmony("NightShiftWorks.LootScooter").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loot Scooter loaded.");
		}

		internal void RegisterScooter(StatsManager stats)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			if (registrationFailed)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)Scooter))
			{
				stats.itemDictionary.TryAdd("Item NightShiftWorks Loot Scooter", Scooter);
				return;
			}
			GameObject val = null;
			Item val2 = null;
			try
			{
				if (!stats.itemDictionary.TryGetValue("Item Vehicle Semiscooter Small", out var value))
				{
					value = Resources.Load<Item>("Items/Items/Item Vehicle Semiscooter Small");
				}
				if (Object.op_Implicit((Object)(object)value))
				{
					GameObject val3 = ((PrefabRef<GameObject>)(object)value.prefab)?.Prefab;
					if (val3 == null || !Object.op_Implicit((Object)(object)val3))
					{
						throw new InvalidOperationException("The native Scout prefab could not be loaded.");
					}
					val = new GameObject("Loot Scooter prefab holder");
					val.SetActive(false);
					Object.DontDestroyOnLoad((Object)(object)val);
					GameObject val4 = Object.Instantiate<GameObject>(val3, val.transform);
					((Object)val4).name = "Item NightShiftWorks Loot Scooter";
					val4.SetActive(true);
					ItemVehicle component = val4.GetComponent<ItemVehicle>();
					ItemAttributes component2 = val4.GetComponent<ItemAttributes>();
					ItemBattery component3 = val4.GetComponent<ItemBattery>();
					if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component3) || !Object.op_Implicit((Object)(object)component.meshTransform))
					{
						throw new InvalidOperationException("The native Scout is missing a required component.");
					}
					val2 = Object.Instantiate<Item>(value);
					((Object)val2).name = "Item NightShiftWorks Loot Scooter";
					val2.itemName = "Loot Scooter";
					val2.description = "A field scooter with a rechargeable traction battery.";
					val2.itemNameLocalized = null;
					val2.prefab = new PrefabRef();
					val2.maxAmountInShop = 0;
					component2.item = val2;
					PlacementBounds = ScooterRide.ConfigurePrefab(val4, component, component3);
					if (Items.RegisterItem(component2) == null)
					{
						throw new InvalidOperationException("REPOLib did not register the item.");
					}
					Scooter = val2;
					stats.itemDictionary.TryAdd("Item NightShiftWorks Loot Scooter", val2);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Registered Loot Scooter using " + ((Object)value).name + "."));
				}
			}
			catch (Exception arg)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)val);
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					Object.Destroy((Object)(object)val2);
				}
				registrationFailed = true;
				((BaseUnityPlugin)this).Logger.LogError((object)$"Loot Scooter registration failed. {arg}");
			}
		}

		internal void LogSpawn(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}

		internal void LogSpawnFailure(Exception exception)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Loot Scooter spawn failed. {exception}");
		}
	}
	internal static class ScooterBalance
	{
		internal const float Reserve = 5f;

		internal const float MinimumThrottle = 0.05f;

		internal static float ChargeFraction(float charge)
		{
			return Math.Clamp((charge - 5f) / 95f, 0f, 1f);
		}

		internal static float Drain(float charge, float throttle, float seconds, float fullThrottleSeconds)
		{
			float num = Math.Abs(throttle);
			if (charge <= 5f || num <= 0.05f)
			{
				return charge;
			}
			return Math.Max(5f, charge - 95f * num * seconds / fullThrottleSeconds);
		}

		internal static float LimitThrottle(float throttle, float charge, float forwardSpeed)
		{
			if (throttle * forwardSpeed < 0f && Math.Abs(forwardSpeed) > 0.45f)
			{
				return throttle;
			}
			if (charge <= 5f)
			{
				return 0f;
			}
			return throttle * (0.55f + 0.45f * Math.Clamp((charge - 5f - 1f) / 19f, 0f, 1f));
		}

		internal static bool ShouldSpawn(int chance, float roll)
		{
			if (chance < 100)
			{
				return roll < (float)chance;
			}
			return true;
		}
	}
	internal sealed class ScooterRide : MonoBehaviour, IPunInstantiateMagicCallback
	{
		[HarmonyPatch(typeof(ItemVehicle), "UpdatePhysicsState")]
		private static class ThrottlePatch
		{
			[HarmonyPostfix]
			private static void Postfix(ItemVehicle __instance, ref float ___inputY)
			{
				ScooterRide scooterRide = default(ScooterRide);
				if (((Component)__instance).TryGetComponent<ScooterRide>(ref scooterRide))
				{
					___inputY = scooterRide.ConsumeCharge(___inputY);
				}
			}
		}

		[HarmonyPatch(typeof(ItemVehicle), "UpdateLights")]
		private static class NativeLightsPatch
		{
			[HarmonyPrefix]
			private static bool Prefix(ItemVehicle __instance)
			{
				ScooterRide scooterRide = default(ScooterRide);
				return !((Component)__instance).TryGetComponent<ScooterRide>(ref scooterRide);
			}
		}

		private static readonly FieldRef<ItemAttributes, string> InstanceName = AccessTools.FieldRefAccess<ItemAttributes, string>("instanceName");

		private static readonly Func<ItemVehicle, PlayerAvatar> Driver = AccessTools.MethodDelegate<Func<ItemVehicle, PlayerAvatar>>(AccessTools.PropertyGetter(typeof(ItemVehicle), "Driver"), (object)null, true);

		private static readonly Func<ItemVehicle, bool> DriverMounted = AccessTools.MethodDelegate<Func<ItemVehicle, bool>>(AccessTools.PropertyGetter(typeof(ItemVehicle), "DriverFullyMounted"), (object)null, true);

		private static readonly FieldRef<PlayerAvatar, Vector3> InputDirection = AccessTools.FieldRefAccess<PlayerAvatar, Vector3>("InputDirectionRaw");

		private ItemVehicle vehicle;

		private ItemBattery battery;

		private ItemAttributes attributes;

		[SerializeField]
		private Transform modelRoot;

		private ScooterVisuals visuals;

		private Vector3 lastPosition;

		private float displaySpeed;

		private float previousSpeed;

		private float nextNoise;

		private int initialCharge = -1;

		private bool initialChargeSet;

		private int initialFrames;

		internal static Bounds ConfigurePrefab(GameObject prefab, ItemVehicle vehicle, ItemBattery battery)
		{
			//IL_0011: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_022f: 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_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: 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_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: 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_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: 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_0076: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(new Vector3(0f, 0.45f, 0f), new Vector3(0.56f, 1.12f, 1.33f));
			bool flag = true;
			Collider[] vehicleColliders = vehicle.vehicleColliders;
			Vector3 val5 = default(Vector3);
			foreach (Collider val in vehicleColliders)
			{
				if (!Object.op_Implicit((Object)(object)val) || val.isTrigger)
				{
					continue;
				}
				CapsuleCollider val2 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null);
				Vector3 center;
				Vector3 val3;
				if (val2 != null)
				{
					center = val2.center;
					val3 = Vector3.one * val2.radius;
					((Vector3)(ref val3))[val2.direction] = Mathf.Max(val2.radius, val2.height * 0.5f);
				}
				else
				{
					BoxCollider val4 = (BoxCollider)(object)((val is BoxCollider) ? val : null);
					if (val4 == null)
					{
						continue;
					}
					center = val4.center;
					val3 = val4.size * 0.5f;
				}
				for (int j = 0; j < 8; j++)
				{
					((Vector3)(ref val5))..ctor((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)));
					Vector3 val6 = prefab.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(center + Vector3.Scale(val3, val5)));
					if (flag)
					{
						((Bounds)(ref result))..ctor(val6, Vector3.zero);
						flag = false;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val6);
					}
				}
			}
			if (Object.op_Implicit((Object)(object)vehicle.frontLight))
			{
				((Behaviour)vehicle.frontLight).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)vehicle.backLight))
			{
				((Behaviour)vehicle.backLight).enabled = false;
			}
			vehicle.hasDrifting = false;
			vehicle.enableDriftPhysics = false;
			vehicle.maxForwardSpeed = 8.5f;
			vehicle.hyperMaxSpeed = 8.5f;
			vehicle.maxReverseSpeed = 2.8f;
			vehicle.maxSpeedKmh = 32f;
			vehicle.softMaxSpeedKmh = 30f;
			vehicle.forwardAcceleration *= 1.12f;
			vehicle.hyperAcceleration = vehicle.forwardAcceleration;
			battery.batteryDrainRate = 0f;
			GameObject val7 = new GameObject("Loot Scooter chassis");
			val7.transform.SetParent(vehicle.meshTransform, false);
			Vector3 val8 = default(Vector3);
			((Vector3)(ref val8))..ctor(((Bounds)(ref result)).center.x, ((Bounds)(ref result)).min.y, ((Bounds)(ref result)).center.z);
			val7.transform.SetPositionAndRotation(prefab.transform.TransformPoint(val8), prefab.transform.rotation);
			Vector3 lossyScale = vehicle.meshTransform.lossyScale;
			Vector3 lossyScale2 = prefab.transform.lossyScale;
			val7.transform.localScale = new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z);
			prefab.AddComponent<ScooterRide>().modelRoot = val7.transform;
			((Bounds)(ref result)).Encapsulate(val8 + new Vector3(-0.27f, 0f, -0.66f));
			((Bounds)(ref result)).Encapsulate(val8 + new Vector3(0.27f, 1.12f, 0.66f));
			return result;
		}

		private void Awake()
		{
			//IL_0065: 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)
			vehicle = ((Component)this).GetComponent<ItemVehicle>();
			battery = ((Component)this).GetComponent<ItemBattery>();
			attributes = ((Component)this).GetComponent<ItemAttributes>();
			MeshRenderer[] componentsInChildren = ((Component)vehicle.meshTransform).GetComponentsInChildren<MeshRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Renderer)componentsInChildren[i]).forceRenderingOff = true;
			}
			visuals = ScooterVisuals.Create(modelRoot);
			lastPosition = ((Component)this).transform.position;
		}

		public void OnPhotonInstantiate(PhotonMessageInfo info)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			object[] instantiationData = info.photonView.InstantiationData;
			if (instantiationData != null && instantiationData.Length == 1 && instantiationData[0] is float foundCharge)
			{
				SetFoundCharge(foundCharge);
			}
		}

		internal void SetFoundCharge(float charge)
		{
			initialCharge = Mathf.RoundToInt(Mathf.Clamp(charge, 35f, 60f));
			battery.batteryLife = initialCharge;
		}

		private void LateUpdate()
		{
			//IL_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (!initialChargeSet && initialCharge >= 0 && SemiFunc.IsMasterClientOrSingleplayer() && (!string.IsNullOrEmpty(InstanceName.Invoke(attributes)) || ++initialFrames > 60))
			{
				battery.SetBatteryLife(initialCharge);
				initialChargeSet = true;
			}
			float deltaTime = Time.deltaTime;
			if (!(deltaTime <= 0f))
			{
				Vector3 val = ((Component)this).transform.position - lastPosition;
				lastPosition = ((Component)this).transform.position;
				float num = ((((Vector3)(ref val)).sqrMagnitude < 4f) ? Vector3.Dot(val / deltaTime, ((Component)this).transform.forward) : 0f);
				displaySpeed = Mathf.Lerp(displaySpeed, Mathf.Clamp(num, -12f, 12f), 1f - Mathf.Exp(-9f * deltaTime));
				PlayerAvatar val2 = Driver(vehicle);
				bool flag = Object.op_Implicit((Object)(object)val2) && DriverMounted(vehicle);
				bool brake = flag && (InputDirection.Invoke(val2).z * displaySpeed < -0.2f || Mathf.Abs(previousSpeed) - Mathf.Abs(displaySpeed) > 2.8f * deltaTime);
				previousSpeed = displaySpeed;
				visuals.SetState(flag && battery.batteryLife > 5f, brake, ScooterBalance.ChargeFraction(battery.batteryLife), displaySpeed * deltaTime * 57.29578f / 0.125f);
			}
		}

		private float ConsumeCharge(float throttle)
		{
			//IL_0026: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			if (!DriverMounted(vehicle) || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return throttle;
			}
			float num = Vector3.Dot(vehicle.rb.linearVelocity, ((Component)this).transform.forward);
			float batteryLife = battery.batteryLife;
			if (!(throttle * num < 0f) || !(Mathf.Abs(num) > 0.45f))
			{
				Plugin instance = Plugin.Instance;
				battery.batteryLife = ScooterBalance.Drain(batteryLife, throttle, Time.fixedDeltaTime, instance.FullThrottleSeconds.Value);
				if (batteryLife > 5f && battery.batteryLife <= 5f)
				{
					battery.SetBatteryLife(5);
				}
				float value = instance.EngineNoiseRadius.Value;
				if (value > 0f && batteryLife > 5f && Mathf.Abs(throttle) > 0.55f && Mathf.Abs(num) > 3.8f && Time.time >= nextNoise && Object.op_Implicit((Object)(object)EnemyDirector.instance))
				{
					nextNoise = Time.time + 3f;
					SemiFunc.EnemyInvestigate(((Component)this).transform.position, value, false);
				}
			}
			return ScooterBalance.LimitThrottle(throttle, battery.batteryLife, num);
		}
	}
	public sealed class ScooterVisuals
	{
		private enum Finish
		{
			Frame,
			Rubber,
			Enamel,
			Steel,
			Brass,
			Black,
			HeadOff,
			HeadOn,
			TailOff,
			TailOn,
			TailBrake,
			CellOff,
			CellOn,
			CellLow
		}

		private sealed class Shape
		{
			private readonly List<Vector3> vertices = new List<Vector3>();

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

			private readonly List<int>[] triangles;

			public Shape(int finishes)
			{
				triangles = new List<int>[finishes];
				for (int i = 0; i < finishes; i++)
				{
					triangles[i] = new List<int>();
				}
			}

			public Mesh Bake(string name)
			{
				//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_001b: Expected O, but got Unknown
				Mesh val = new Mesh
				{
					name = name,
					subMeshCount = triangles.Length
				};
				val.SetVertices(vertices);
				val.SetNormals(normals);
				for (int i = 0; i < triangles.Length; i++)
				{
					val.SetTriangles(triangles[i], i, false);
				}
				val.RecalculateBounds();
				return val;
			}

			public void Beam(Finish finish, Vector3 from, Vector3 to, float width, float depth, float corner)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: 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_0016: 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_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)
				Vector3 val = to - from;
				Box(finish, (from + to) * 0.5f, new Vector3(width, ((Vector3)(ref val)).magnitude, depth), corner, Quaternion.FromToRotation(Vector3.up, val));
			}

			public void Box(Finish finish, Vector3 center, Vector3 size, float corner, Quaternion? rotation = null)
			{
				//IL_0000: 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_000b: 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_001a: 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_0052: 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_0057: 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_0059: 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_0064: 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_006c: 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_007d: 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_0086: 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_0096: 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_009f: 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_00c6: 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_00d8: 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_00f0: 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_0102: 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_011b: 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_012d: 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_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: 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_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = size * 0.5f;
				float num = Mathf.Min(corner * 0.5f, Mathf.Min(val.y, Mathf.Min(val.x, val.z)) * 0.29f);
				Quaternion orientation = (Quaternion)(((??)rotation) ?? Quaternion.identity);
				Vector3[] array = Outline(center, val, corner, 0f - val.y, num, orientation);
				Vector3[] array2 = Outline(center, val, corner, 0f - val.y + num, 0f, orientation);
				Vector3[] array3 = Outline(center, val, corner, val.y - num, 0f, orientation);
				Vector3[] array4 = Outline(center, val, corner, val.y, num, orientation);
				for (int i = 0; i < 8; i++)
				{
					int num2 = (i + 1) % 8;
					Quad(finish, array[i], array2[i], array2[num2], array[num2]);
					Quad(finish, array2[i], array3[i], array3[num2], array2[num2]);
					Quad(finish, array3[i], array4[i], array4[num2], array3[num2]);
				}
				for (int j = 1; j < 7; j++)
				{
					Triangle(finish, array[0], array[j], array[j + 1]);
					Triangle(finish, array4[0], array4[j + 1], array4[j]);
				}
			}

			private static Vector3[] Outline(Vector3 center, Vector3 half, float corner, float y, float bevel, Quaternion orientation)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_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_005c: 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_006d: 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_007e: 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_0090: 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_00a2: 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_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_00c6: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: 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_00da: Unknown result type (might be due to invalid IL or missing references)
				float num = half.x - bevel;
				float num2 = half.z - bevel;
				corner = Mathf.Min(corner, Mathf.Min(num, num2) * 0.9f);
				Vector3[] array = (Vector3[])(object)new Vector3[8]
				{
					new Vector3(0f - num + corner, y, 0f - num2),
					new Vector3(num - corner, y, 0f - num2),
					new Vector3(num, y, 0f - num2 + corner),
					new Vector3(num, y, num2 - corner),
					new Vector3(num - corner, y, num2),
					new Vector3(0f - num + corner, y, num2),
					new Vector3(0f - num, y, num2 - corner),
					new Vector3(0f - num, y, 0f - num2 + corner)
				};
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = center + orientation * array[i];
				}
				return array;
			}

			public void Tube(Finish finish, Vector3 from, Vector3 to, float startRadius, float endRadius, int sides)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: 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_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_0044: 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_005c: 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)
				Vector3 val = to - from;
				Revolve(finish, from, ((Vector3)(ref val)).normalized, sides, Vector2.zero, new Vector2(startRadius, 0f), new Vector2(endRadius, ((Vector3)(ref val)).magnitude), new Vector2(0f, ((Vector3)(ref val)).magnitude));
			}

			public void Revolve(Finish finish, Vector3 center, Vector3 axis, int sides, params Vector2[] profile)
			{
				//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_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_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_0021: 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_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_0029: 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_0043: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: 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_0090: 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_0097: 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_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: 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_00ab: 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)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: 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_00e4: 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_00eb: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: 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_010a: 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_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_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_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: 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_0131: 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_013d: 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_014f: 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_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: 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_0185: 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_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: 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_019e: 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)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01be: Unknown result type (might be due to invalid IL or missing references)
				Quaternion val = Quaternion.FromToRotation(Vector3.up, axis);
				for (int i = 1; i < profile.Length; i++)
				{
					Vector2 val2 = profile[i - 1];
					Vector2 val3 = profile[i];
					Vector2 val4 = val3 - val2;
					for (int j = 0; j < sides; j++)
					{
						float num = MathF.PI * 2f / (float)sides;
						Vector3 val5 = val * new Vector3(Mathf.Sin((float)j * num), 0f, Mathf.Cos((float)j * num));
						Vector3 val6 = val * new Vector3(Mathf.Sin((float)(j + 1) * num), 0f, Mathf.Cos((float)(j + 1) * num));
						Vector3 a = center + axis * val2.y + val5 * val2.x;
						Vector3 b = center + axis * val2.y + val6 * val2.x;
						Vector3 val7 = center + axis * val3.y + val6 * val3.x;
						Vector3 c = center + axis * val3.y + val5 * val3.x;
						Vector3 val8 = val5 * val4.y - axis * val4.x;
						Vector3 normalized = ((Vector3)(ref val8)).normalized;
						val8 = val6 * val4.y - axis * val4.x;
						Vector3 normalized2 = ((Vector3)(ref val8)).normalized;
						if (val2.x > 0f)
						{
							Triangle(finish, a, b, val7, normalized, normalized2, normalized2);
						}
						if (val3.x > 0f)
						{
							Triangle(finish, a, val7, c, normalized, normalized2, normalized);
						}
					}
				}
			}

			public void Mudguard(Finish finish, Vector3 axle, float start, float end, float width)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: 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_005e: 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_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: 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_00a2: 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_00a8: 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_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)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: 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_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_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: 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_00d7: 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_00df: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: 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_0106: 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_0115: 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_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: 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_012b: 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_013b: 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_013d: 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_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: 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_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: 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_0165: 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_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: 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_0177: 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_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				float num = ((finish == Finish.Enamel) ? 0.15f : 0.145f);
				Vector3 val = Vector3.right * (width * 0.5f);
				for (int i = 0; i < 10; i++)
				{
					Vector3 val2 = GuardPoint(axle, Mathf.Lerp(start, end, (float)i / 10f), num);
					Vector3 val3 = GuardPoint(axle, Mathf.Lerp(start, end, (float)(i + 1) / 10f), num);
					Vector3 val4 = GuardPoint(axle, Mathf.Lerp(start, end, (float)i / 10f), num - 0.013f);
					Vector3 val5 = GuardPoint(axle, Mathf.Lerp(start, end, (float)(i + 1) / 10f), num - 0.013f);
					Quad(finish, val2 - val, val2 + val, val3 + val, val3 - val);
					Quad(finish, val4 + val, val4 - val, val5 - val, val5 + val);
					Quad(finish, val2 - val, val3 - val, val5 - val, val4 - val);
					Quad(finish, val3 + val, val2 + val, val4 + val, val5 + val);
					if (i == 0)
					{
						Quad(finish, val2 + val, val2 - val, val4 - val, val4 + val);
					}
					if (i == 9)
					{
						Quad(finish, val3 - val, val3 + val, val5 + val, val5 - val);
					}
				}
			}

			private static Vector3 GuardPoint(Vector3 axle, float angle, float radius)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				float num = angle * (MathF.PI / 180f);
				return axle + new Vector3(0f, Mathf.Sin(num) * radius, Mathf.Cos(num) * radius);
			}

			private void Quad(Finish finish, Vector3 a, Vector3 b, Vector3 c, Vector3 d)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: 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_000e: 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)
				Triangle(finish, a, b, c);
				Triangle(finish, a, c, d);
			}

			private void Triangle(Finish finish, Vector3 a, Vector3 b, Vector3 c)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: 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_001c: 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_0020: 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_0023: 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)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Vector3.Cross(b - a, c - a);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Triangle(finish, a, b, c, normalized, normalized, normalized);
			}

			private void Triangle(Finish finish, Vector3 a, Vector3 b, Vector3 c, Vector3 na, Vector3 nb, Vector3 nc)
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				List<int> obj = triangles[(int)finish];
				int count = vertices.Count;
				obj.Add(count);
				obj.Add(count + 1);
				obj.Add(count + 2);
				vertices.Add(a);
				vertices.Add(b);
				vertices.Add(c);
				normals.Add(na);
				normals.Add(nb);
				normals.Add(nc);
			}
		}

		public const float WheelRadius = 0.125f;

		private const int BatterySegments = 5;

		private static readonly Vector3 FrontAxle = new Vector3(0f, 0.125f, 0.52f);

		private static readonly Vector3 RearAxle = new Vector3(0f, 0.125f, -0.52f);

		private static readonly Vector3 StemTop = new Vector3(0f, 1.053f, 0.333f);

		private static readonly Vector3 DisplayPosition = new Vector3(0f, 1.086f, 0.294f);

		private static Material[] materials = null;

		private static Mesh bodyMesh = null;

		private static Mesh wheelMesh = null;

		private static Mesh headMesh = null;

		private static Mesh tailMesh = null;

		private static Mesh cellMesh = null;

		private readonly Transform frontWheel;

		private readonly Transform rearWheel;

		private readonly Light headlight;

		private readonly Light taillight;

		private readonly MeshRenderer headLens;

		private readonly MeshRenderer tailLens;

		private readonly MeshRenderer[] cells = (MeshRenderer[])(object)new MeshRenderer[5];

		private float wheelAngle;

		public static ScooterVisuals Create(Transform parent)
		{
			PrepareMeshes();
			return new ScooterVisuals(parent);
		}

		private ScooterVisuals(Transform parent)
		{
			//IL_0018: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00eb: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			Transform parent2 = Child(parent, "Loot Scooter model", Vector3.zero);
			Render(parent2, "Chassis", bodyMesh, Vector3.zero, Finish.Frame, Finish.Rubber, Finish.Enamel, Finish.Steel, Finish.Brass, Finish.Black);
			frontWheel = ((Component)Render(parent2, "Front wheel", wheelMesh, FrontAxle, Finish.Frame, Finish.Rubber, Finish.Enamel, Finish.Steel, Finish.Brass, Finish.Black)).transform;
			rearWheel = ((Component)Render(parent2, "Rear wheel", wheelMesh, RearAxle, Finish.Frame, Finish.Rubber, Finish.Enamel, Finish.Steel, Finish.Brass, Finish.Black)).transform;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0.997f, 0.422f);
			headLens = Render(parent2, "Headlight lens", headMesh, val, Finish.HeadOff);
			headlight = ((Component)Child(parent2, "Headlight beam", val + Vector3.forward * 0.016f)).gameObject.AddComponent<Light>();
			headlight.type = (LightType)0;
			headlight.color = new Color(0.82f, 0.95f, 1f);
			headlight.range = 10f;
			headlight.intensity = 3.1f;
			headlight.spotAngle = 54f;
			headlight.innerSpotAngle = 28f;
			headlight.shadows = (LightShadows)0;
			((Component)headlight).transform.localRotation = Quaternion.Euler(9f, 0f, 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f, 0.256f, -0.594f);
			tailLens = Render(parent2, "Tail light lens", tailMesh, val2, Finish.TailOff);
			taillight = ((Component)Child(parent2, "Tail light", val2 - Vector3.forward * 0.027f)).gameObject.AddComponent<Light>();
			taillight.type = (LightType)2;
			taillight.color = new Color(1f, 0.13f, 0.075f);
			taillight.range = 1.25f;
			taillight.shadows = (LightShadows)0;
			for (int i = 0; i < cells.Length; i++)
			{
				Vector3 position = DisplayPosition + Vector3.right * ((float)(i - 2) * 0.016f);
				cells[i] = Render(parent2, "Battery segment", cellMesh, position, Finish.CellOff);
			}
			SetState(headlight: false, brake: false, 0f, 0f);
		}

		public void SetState(bool headlight, bool brake, float chargeFraction, float wheelDegreesDelta)
		{
			//IL_00e3: 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_00ed: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			bool num = chargeFraction > 0f;
			bool flag = num && headlight;
			bool flag2 = num && brake;
			((Behaviour)this.headlight).enabled = flag;
			((Behaviour)taillight).enabled = flag || flag2;
			taillight.intensity = (flag2 ? 1.8f : 0.55f);
			SetMaterial(headLens, flag ? Finish.HeadOn : Finish.HeadOff);
			SetMaterial(tailLens, flag2 ? Finish.TailBrake : (flag ? Finish.TailOn : Finish.TailOff));
			int num2 = Mathf.CeilToInt(Mathf.Clamp01(chargeFraction) * 5f);
			Finish finish = ((num2 == 1) ? Finish.CellLow : Finish.CellOn);
			for (int i = 0; i < cells.Length; i++)
			{
				SetMaterial(cells[i], (i < num2) ? finish : Finish.CellOff);
			}
			if (wheelDegreesDelta != 0f)
			{
				wheelAngle = Mathf.Repeat(wheelAngle + wheelDegreesDelta, 360f);
				Quaternion localRotation = Quaternion.AngleAxis(wheelAngle, Vector3.right);
				frontWheel.localRotation = localRotation;
				rearWheel.localRotation = localRotation;
			}
		}

		private static void SetMaterial(MeshRenderer renderer, Finish finish)
		{
			Material val = materials[(int)finish];
			if ((Object)(object)((Renderer)renderer).sharedMaterial != (Object)(object)val)
			{
				((Renderer)renderer).sharedMaterial = val;
			}
		}

		private static Transform Child(Transform parent, string name, Vector3 position)
		{
			//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_0017: 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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = position;
			return val.transform;
		}

		private static MeshRenderer Render(Transform parent, string name, Mesh mesh, Vector3 position, params Finish[] finishes)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)Child(parent, name, position)).gameObject;
			gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer val = gameObject.AddComponent<MeshRenderer>();
			if (finishes.Length == 1)
			{
				((Renderer)val).sharedMaterial = materials[(int)finishes[0]];
				((Renderer)val).shadowCastingMode = (ShadowCastingMode)0;
			}
			else
			{
				Material[] array = (Material[])(object)new Material[finishes.Length];
				for (int i = 0; i < finishes.Length; i++)
				{
					array[i] = materials[(int)finishes[i]];
				}
				((Renderer)val).sharedMaterials = array;
			}
			return val;
		}

		private static void PrepareMeshes()
		{
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)bodyMesh != (Object)null))
			{
				Shader shader = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Diffuse");
				materials = (Material[])(object)new Material[14]
				{
					Paint(shader, "Graphite housing", 44, 53, 59, 0.28f, 0.36f),
					Paint(shader, "Textured rubber", 21, 27, 28, 0f, 0.12f),
					Paint(shader, "Petrol enamel", 38, 134, 124, 0.17f, 0.39f),
					Paint(shader, "Cast alloy", 151, 164, 169, 0.49f, 0.47f),
					Paint(shader, "Ochre hardware", 218, 153, 61, 0.2f, 0.33f),
					Paint(shader, "Black anodizing", 35, 43, 45, 0.36f, 0.34f),
					Paint(shader, "Dark headlight", 139, 177, 177, 0f, 0.63f),
					Paint(shader, "Lit headlight", 177, 234, 242, 0f, 0.66f, 4f),
					Paint(shader, "Dark tail light", 92, 22, 22, 0f, 0.61f),
					Paint(shader, "Running tail light", 223, 40, 27, 0f, 0.59f, 1.5f),
					Paint(shader, "Brake light", byte.MaxValue, 82, 56, 0f, 0.59f, 3.8f),
					Paint(shader, "Blank charge segment", 38, 64, 58, 0f, 0.42f),
					Paint(shader, "Charged segment", 45, 241, 169, 0f, 0.52f, 2.4f),
					Paint(shader, "Low charge segment", 250, 162, 46, 0f, 0.52f, 2.5f)
				};
				bodyMesh = BuildBody();
				wheelMesh = BuildWheel();
				headMesh = Lens("Scooter headlight lens", new Vector3(0.071f, 0.033f, 0.015f), 0.01f);
				tailMesh = Lens("Scooter tail lens", new Vector3(0.074f, 0.02f, 0.012f), 0.006f);
				cellMesh = Lens("Scooter battery segment", new Vector3(0.011f, 0.003f, 0.016f), 0.002f);
			}
		}

		private static Material Paint(Shader shader, string name, byte red, byte green, byte blue, float metal, float gloss, float emission = 0f)
		{
			//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_0015: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			Material val = new Material(shader)
			{
				name = name,
				enableInstancing = true
			};
			Color val2 = (val.color = Color32.op_Implicit(new Color32(red, green, blue, byte.MaxValue)));
			val.SetFloat("_Metallic", metal);
			val.SetFloat("_Glossiness", gloss);
			val.SetFloat("_Smoothness", gloss);
			if (emission > 0f)
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", val2 * emission);
			}
			return val;
		}

		private static Mesh Lens(string name, Vector3 size, float corner)
		{
			//IL_0008: 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)
			Shape shape = new Shape(1);
			shape.Box(Finish.Frame, Vector3.zero, size, corner);
			return shape.Bake(name);
		}

		private static Mesh BuildBody()
		{
			//IL_0018: 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_0055: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_066b: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			//IL_082d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_0848: Unknown result type (might be due to invalid IL or missing references)
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: 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_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: 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_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: 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)
			//IL_03cc: 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_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0919: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: 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_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			Shape shape = new Shape(6);
			shape.Box(Finish.Frame, new Vector3(0f, 0.175f, -0.051f), new Vector3(0.236f, 0.088f, 0.832f), 0.053f);
			shape.Box(Finish.Enamel, new Vector3(0f, 0.19f, -0.051f), new Vector3(0.244f, 0.041f, 0.82f), 0.052f);
			shape.Box(Finish.Black, new Vector3(0f, 0.145f, -0.049f), new Vector3(0.202f, 0.038f, 0.722f), 0.042f);
			shape.Box(Finish.Rubber, new Vector3(0f, 0.219f, -0.081f), new Vector3(0.21f, 0.021f, 0.645f), 0.04f);
			for (int i = 0; i < 12; i++)
			{
				float num = -0.359f + (float)i * 0.048f;
				shape.Box(Finish.Frame, new Vector3(-0.04f, 0.231f, num), new Vector3(0.061f, 0.005f, 0.011f), 0.002f, Quaternion.Euler(0f, -19f, 0f));
				shape.Box(Finish.Frame, new Vector3(0.04f, 0.231f, num), new Vector3(0.061f, 0.005f, 0.011f), 0.002f, Quaternion.Euler(0f, 19f, 0f));
			}
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int j = -1; j <= 1; j += 2)
			{
				shape.Box(Finish.Brass, new Vector3((float)j * 0.121f, 0.195f, 0.219f), new Vector3(0.004f, 0.018f, 0.162f), 0.002f);
				shape.Box(Finish.Black, new Vector3((float)j * 0.123f, 0.193f, -0.241f), new Vector3(0.005f, 0.023f, 0.19f), 0.002f);
				for (int k = 0; k < 6; k++)
				{
					shape.Box(Finish.Steel, new Vector3((float)j * 0.126f, 0.193f, -0.305f + (float)k * 0.025f), new Vector3(0.004f, 0.012f, 0.006f), 0.001f, Quaternion.Euler(-24f, 0f, 0f));
				}
				shape.Tube(Finish.Frame, new Vector3((float)j * 0.084f, 0.175f, -0.352f), new Vector3((float)j * 0.063f, 0.132f, -0.523f), 0.024f, 0.019f, 8);
				shape.Tube(Finish.Frame, new Vector3((float)j * 0.058f, 0.134f, 0.522f), new Vector3((float)j * 0.052f, 0.333f, 0.446f), 0.024f, 0.023f, 10);
				shape.Tube(Finish.Steel, new Vector3((float)j * 0.052f, 0.302f, 0.457f), new Vector3((float)j * 0.046f, 0.407f, 0.427f), 0.014f, 0.014f, 10);
				shape.Tube(Finish.Brass, new Vector3((float)j * 0.052f, 0.302f, 0.457f), new Vector3((float)j * 0.051f, 0.323f, 0.452f), 0.022f, 0.022f, 10);
				shape.Tube(Finish.Frame, StemTop, new Vector3((float)j * 0.113f, 1.06f, 0.334f), 0.017f, 0.014f, 10);
				shape.Tube(Finish.Frame, new Vector3((float)j * 0.113f, 1.06f, 0.334f), new Vector3((float)j * 0.249f, 1.067f, 0.302f), 0.014f, 0.014f, 10);
				((Vector3)(ref val))..ctor((float)j * 0.147f, 1.061f, 0.326f);
				((Vector3)(ref val2))..ctor((float)j * 0.256f, 1.068f, 0.3f);
				Vector3 val3 = Vector3.Lerp(val, val2, 0.86f);
				shape.Tube(Finish.Rubber, val, val3, 0.0215f, 0.02f, 12);
				shape.Tube(Finish.Enamel, val3, val2, 0.0214f, 0.0214f, 12);
				for (int l = 1; l <= 4; l++)
				{
					float num2 = (float)l / 6f;
					shape.Tube(Finish.Frame, Vector3.Lerp(val, val2, num2 - 0.017f), Vector3.Lerp(val, val2, num2 + 0.017f), 0.022f, 0.022f, 12);
				}
			}
			shape.Beam(Finish.Enamel, new Vector3(0f, 0.191f, 0.28f), new Vector3(0f, 0.425f, 0.436f), 0.127f, 0.111f, 0.021f);
			shape.Beam(Finish.Frame, new Vector3(0f, 0.37f, 0.451f), StemTop, 0.068f, 0.067f, 0.013f);
			shape.Beam(Finish.Enamel, new Vector3(0f, 0.474f, 0.441f), new Vector3(0f, 0.918f, 0.364f), 0.071f, 0.052f, 0.012f);
			shape.Beam(Finish.Black, new Vector3(0f, 0.524f, 0.407f), new Vector3(0f, 0.816f, 0.355f), 0.042f, 0.016f, 0.005f);
			shape.Beam(Finish.Steel, new Vector3(0f, 0.535f, 0.403f), new Vector3(0f, 0.799f, 0.356f), 0.011f, 0.008f, 0.003f);
			shape.Beam(Finish.Brass, new Vector3(0f, 0.446f, 0.442f), new Vector3(0f, 0.473f, 0.437f), 0.07f, 0.071f, 0.013f);
			shape.Box(Finish.Frame, new Vector3(0f, 0.997f, 0.392f), new Vector3(0.096f, 0.054f, 0.052f), 0.015f);
			shape.Box(Finish.Frame, new Vector3(0f, 1.063f, 0.299f), new Vector3(0.102f, 0.036f, 0.071f), 0.012f);
			shape.Box(Finish.Black, new Vector3(0f, 1.08f, 0.293f), new Vector3(0.085f, 0.006f, 0.03f), 0.006f);
			shape.Box(Finish.Brass, new Vector3(0.123f, 1.055f, 0.301f), new Vector3(0.033f, 0.025f, 0.043f), 0.007f);
			shape.Box(Finish.Steel, new Vector3(-0.124f, 1.054f, 0.355f), new Vector3(0.048f, 0.012f, 0.049f), 0.005f);
			shape.Tube(Finish.Steel, new Vector3(-0.125f, 1.057f, 0.37f), new Vector3(-0.231f, 1.043f, 0.364f), 0.009f, 0.007f, 8);
			Vector3[] array = (Vector3[])(object)new Vector3[7]
			{
				new Vector3(-0.127f, 1.043f, 0.366f),
				new Vector3(-0.12f, 1.003f, 0.402f),
				new Vector3(-0.087f, 0.953f, 0.432f),
				new Vector3(-0.054f, 0.856f, 0.416f),
				new Vector3(-0.046f, 0.644f, 0.449f),
				new Vector3(-0.06f, 0.404f, 0.488f),
				new Vector3(-0.066f, 0.267f, 0.498f)
			};
			for (int m = 1; m < array.Length; m++)
			{
				shape.Tube(Finish.Rubber, array[m - 1], array[m], 0.0055f, 0.0055f, 7);
			}
			shape.Box(Finish.Brass, new Vector3(-0.065f, 0.194f, 0.504f), new Vector3(0.027f, 0.047f, 0.044f), 0.005f);
			shape.Mudguard(Finish.Black, RearAxle, 34f, 151f, 0.09f);
			shape.Mudguard(Finish.Enamel, RearAxle, 61f, 143f, 0.081f);
			shape.Mudguard(Finish.Black, FrontAxle, 32f, 143f, 0.08f);
			shape.Box(Finish.Frame, new Vector3(0f, 0.256f, -0.583f), new Vector3(0.089f, 0.029f, 0.024f), 0.007f);
			shape.Box(Finish.Brass, new Vector3(0f, 0.234f, -0.572f), new Vector3(0.057f, 0.008f, 0.029f), 0.004f);
			return shape.Bake("Loot Scooter chassis");
		}

		private static Mesh BuildWheel()
		{
			//IL_0009: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0054: 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_006a: 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_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_0096: 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_00ac: 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_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_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_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_0107: 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_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_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_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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_019c: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_01e6: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_0241: 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_0254: 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_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: 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_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			Shape shape = new Shape(6);
			shape.Revolve(Finish.Rubber, Vector3.zero, Vector3.right, 24, new Vector2(0.072f, -0.031f), new Vector2(0.096f, -0.037f), new Vector2(0.115f, -0.031f), new Vector2(0.123f, -0.017f), new Vector2(0.125f, 0f), new Vector2(0.123f, 0.017f), new Vector2(0.115f, 0.031f), new Vector2(0.096f, 0.037f), new Vector2(0.072f, 0.031f));
			shape.Revolve(Finish.Steel, Vector3.zero, Vector3.right, 24, new Vector2(0.061f, -0.031f), new Vector2(0.073f, -0.033f), new Vector2(0.077f, -0.025f), new Vector2(0.077f, 0.025f), new Vector2(0.073f, 0.033f), new Vector2(0.061f, 0.031f), new Vector2(0.061f, -0.031f));
			shape.Tube(Finish.Black, Vector3.left * 0.045f, Vector3.right * 0.045f, 0.025f, 0.025f, 16);
			shape.Tube(Finish.Brass, Vector3.left * 0.058f, Vector3.left * 0.044f, 0.015f, 0.019f, 8);
			shape.Tube(Finish.Brass, Vector3.right * 0.045f, Vector3.right * 0.059f, 0.019f, 0.015f, 8);
			for (int i = 0; i < 6; i++)
			{
				Quaternion val = Quaternion.AngleAxis((float)i * 60f, Vector3.right);
				shape.Box(Finish.Enamel, val * new Vector3(0f, 0.046f, 0f), new Vector3(0.035f, 0.045f, 0.018f), 0.004f, val);
			}
			shape.Revolve(Finish.Steel, new Vector3(-0.04f, 0f, 0f), Vector3.right, 24, new Vector2(0.046f, -0.003f), new Vector2(0.061f, -0.003f), new Vector2(0.061f, 0.003f), new Vector2(0.046f, 0.003f), new Vector2(0.046f, -0.003f));
			for (int j = 0; j < 20; j++)
			{
				Quaternion val2 = Quaternion.AngleAxis((float)j * 18f, Vector3.right);
				shape.Box(Finish.Rubber, val2 * new Vector3(0f, 0.124f, 0f), new Vector3(0.046f, 0.003f, 0.009f), 0.002f, val2 * Quaternion.Euler(0f, 24f, 0f));
			}
			return shape.Bake("Loot Scooter wheel");
		}
	}
}