Decompiled source of ComfortGlide CG350 Elite v1.1.0

plugins/ValheimScooter/ValheimScooter.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MagicaCloth2;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ValheimScooter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("ValheimScooter")]
[assembly: AssemblyTitle("ValheimScooter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 ValheimScooter
{
	internal enum Slot
	{
		Side,
		Front
	}
	internal sealed class Accessory
	{
		public readonly string Id;

		public readonly Slot Slot;

		public readonly int Value;

		public readonly string ItemName;

		public readonly string ModelRoot;

		public readonly string[] KitParts;

		public int ChopTier;

		public int PickTier;

		internal Func<ScooterController, Humanoid, bool> CanRemove = (ScooterController c, Humanoid u) => true;

		internal Action<ScooterController> OnRemoved = delegate
		{
		};

		public static readonly Accessory Sidecar = new Accessory("sidecar", Slot.Side, 1, "CG350_Sidecar", "SidecarRoot", "EjectoPod");

		public static readonly Accessory Row1 = new Accessory("row1", Slot.Front, 1, "CG350_ROW1", "BullBarRoot")
		{
			ChopTier = 2,
			PickTier = 1
		};

		public static readonly Accessory[] All = new Accessory[2] { Sidecar, Row1 };

		public string SharedName => "$cg350_" + Id;

		private Accessory(string id, Slot slot, int value, string itemName, string modelRoot, params string[] kitParts)
		{
			Id = id;
			Slot = slot;
			Value = value;
			ItemName = itemName;
			ModelRoot = modelRoot;
			KitParts = kitParts;
		}

		public static Accessory ByItem(ItemData item)
		{
			if (item?.m_shared != null)
			{
				return All.FirstOrDefault((Accessory a) => a.SharedName == item.m_shared.m_name);
			}
			return null;
		}

		public static Accessory In(Slot slot, int value)
		{
			if (value != 0)
			{
				return All.FirstOrDefault((Accessory a) => a.Slot == slot && a.Value == value);
			}
			return null;
		}

		public static void StripAll(GameObject go)
		{
			HashSet<string> hashSet = new HashSet<string>(All.SelectMany((Accessory a) => a.KitParts.Prepend(a.ModelRoot)));
			Transform[] componentsInChildren = go.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && hashSet.Contains(((Object)val).name))
				{
					Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
				}
			}
			CleanLods(go);
		}

		public static void CleanLods(GameObject go)
		{
			LODGroup[] componentsInChildren = go.GetComponentsInChildren<LODGroup>(true);
			foreach (LODGroup val in componentsInChildren)
			{
				LOD[] lODs = val.GetLODs();
				for (int j = 0; j < lODs.Length; j++)
				{
					lODs[j].renderers = lODs[j].renderers.Where((Renderer r) => (Object)(object)r != (Object)null).ToArray();
				}
				val.SetLODs(lODs);
				val.RecalculateBounds();
			}
		}

		public static void RegisterItem(Accessory a, ItemConfig cfg, Quaternion iconRotation, Action<SharedData> tweak = null)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			CustomItem val = new CustomItem(a.ItemName, "SaddleLox", cfg);
			GameObject itemPrefab = val.ItemPrefab;
			BuildVisual(a, itemPrefab);
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			shared.m_teleportable = true;
			shared.m_maxStackSize = 1;
			tweak?.Invoke(shared);
			ItemManager.Instance.AddItem(val);
			shared.m_icons = (Sprite[])(object)new Sprite[1] { RenderManager.Instance.Render(new RenderRequest(itemPrefab)
			{
				Rotation = iconRotation,
				Width = 128,
				Height = 128
			}) };
		}

		private static void BuildVisual(Accessory a, GameObject root)
		{
			//IL_009f: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			for (int num = root.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)root.transform.GetChild(num)).gameObject);
			}
			Collider[] components = root.GetComponents<Collider>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			GameObject val = Assets.Prefab("CG350");
			GameObject val2 = Object.Instantiate<GameObject>(val, root.transform, false);
			((Object)val2).name = a.Id + "Visual";
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = val.transform.localRotation;
			val2.transform.localScale = Vector3.one * 1.2f;
			Transform val3 = ((IEnumerable<Transform>)val2.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == a.ModelRoot));
			if ((Object)(object)val3 == (Object)null)
			{
				throw new Exception("no " + a.ModelRoot + " in the model");
			}
			Transform val4 = val3;
			while ((Object)(object)val4 != (Object)null && (Object)(object)val4 != (Object)(object)val2.transform)
			{
				Transform parent = val4.parent;
				for (int num2 = parent.childCount - 1; num2 >= 0; num2--)
				{
					Transform child = parent.GetChild(num2);
					if ((Object)(object)child != (Object)(object)val4)
					{
						Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
					}
				}
				val4 = val4.parent;
			}
			((Component)val3).gameObject.SetActive(true);
			CleanLods(val2);
			components = val2.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Bounds val5 = MeshBounds(val2.transform, root.transform);
			val2.transform.localPosition = -((Bounds)(ref val5)).center;
			BoxCollider obj = root.AddComponent<BoxCollider>();
			obj.center = Vector3.zero;
			obj.size = ((Bounds)(ref val5)).size * 0.95f;
		}

		internal static Bounds MeshBounds(Transform of, Transform space, Func<Bounds, bool> keep = null)
		{
			//IL_0004: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds result = default(Bounds);
			MeshFilter[] componentsInChildren = ((Component)of).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = val.sharedMesh.bounds;
				Bounds val2 = default(Bounds);
				for (int j = 0; j < 8; j++)
				{
					Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))));
					Vector3 val4 = space.InverseTransformPoint(((Component)val).transform.TransformPoint(val3));
					if (j == 0)
					{
						((Bounds)(ref val2))..ctor(val4, Vector3.zero);
					}
					else
					{
						((Bounds)(ref val2)).Encapsulate(val4);
					}
				}
				if (keep == null || keep(val2))
				{
					if (!flag)
					{
						result = val2;
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val2);
					}
				}
			}
			return result;
		}
	}
	public class ScooterController : MonoBehaviour
	{
		private class PassengerBones
		{
			public Transform hips;

			public Transform spine;

			public Transform chest;

			public Transform upperChest;

			public Transform neck;

			public Transform head;

			public Transform lThigh;

			public Transform lShin;

			public Transform lFoot;

			public Transform lToes;

			public Transform rThigh;

			public Transform rShin;

			public Transform rFoot;

			public Transform rToes;

			public Transform lClav;

			public Transform lArm;

			public Transform lFore;

			public Transform lHand;

			public Transform lPalm;

			public Transform lMiddle;

			public Transform rClav;

			public Transform rArm;

			public Transform rFore;

			public Transform rHand;

			public Transform rPalm;

			public Transform rMiddle;

			public bool ok;

			private Transform[] _posed;

			private Quaternion[] _lastAnim;

			private Quaternion[] _lastSet;

			private bool _primed;

			private Transform[] Posed
			{
				get
				{
					Transform[] array = _posed;
					if (array == null)
					{
						Transform[] obj = new Transform[19]
						{
							spine, chest, upperChest, neck, head, lThigh, lShin, lFoot, rThigh, rShin,
							rFoot, lClav, lArm, lFore, lHand, rClav, rArm, rFore, rHand
						};
						Transform[] array2 = (Transform[])(object)obj;
						_posed = (Transform[])(object)obj;
						array = array2;
					}
					return array;
				}
			}

			public void Begin()
			{
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				Transform[] posed = Posed;
				if (_lastAnim == null)
				{
					_lastAnim = (Quaternion[])(object)new Quaternion[posed.Length];
					_lastSet = (Quaternion[])(object)new Quaternion[posed.Length];
				}
				for (int i = 0; i < posed.Length; i++)
				{
					if (!((Object)(object)posed[i] == (Object)null))
					{
						if (_primed && posed[i].localRotation == _lastSet[i])
						{
							posed[i].localRotation = _lastAnim[i];
						}
						else
						{
							_lastAnim[i] = posed[i].localRotation;
						}
					}
				}
			}

			public void End()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				Transform[] posed = Posed;
				for (int i = 0; i < posed.Length; i++)
				{
					if ((Object)(object)posed[i] != (Object)null)
					{
						_lastSet[i] = posed[i].localRotation;
					}
				}
				_primed = true;
			}
		}

		private class RiderBones
		{
			public Transform spine;

			public Transform lArm;

			public Transform lFore;

			public Transform lHand;

			public Transform lPalm;

			public Transform lMiddle;

			public Transform rArm;

			public Transform rFore;

			public Transform rHand;

			public Transform rPalm;

			public Transform rMiddle;

			public bool ok;

			public Quaternion[] lastAnim = (Quaternion[])(object)new Quaternion[7];

			public Quaternion[] lastSet = (Quaternion[])(object)new Quaternion[7];

			public bool primed;

			private Transform[] _posed;

			public Transform[] Posed
			{
				get
				{
					Transform[] array = _posed;
					if (array == null)
					{
						Transform[] obj = new Transform[7] { spine, lArm, lFore, lHand, rArm, rFore, rHand };
						Transform[] array2 = (Transform[])(object)obj;
						_posed = (Transform[])(object)obj;
						array = array2;
					}
					return array;
				}
			}

			public void Begin()
			{
				//IL_0059: 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_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				Transform[] posed = Posed;
				for (int i = 0; i < posed.Length; i++)
				{
					if (!((Object)(object)posed[i] == (Object)null))
					{
						if (primed && posed[i].localRotation == lastSet[i])
						{
							posed[i].localRotation = lastAnim[i];
						}
						else
						{
							lastAnim[i] = posed[i].localRotation;
						}
					}
				}
			}

			public void End()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				Transform[] posed = Posed;
				for (int i = 0; i < posed.Length; i++)
				{
					if ((Object)(object)posed[i] != (Object)null)
					{
						lastSet[i] = posed[i].localRotation;
					}
				}
				primed = true;
			}
		}

		private static readonly int[] s_slotHash = new int[2]
		{
			StringExtensionMethods.GetStableHashCode("cg350_slot_side"),
			StringExtensionMethods.GetStableHashCode("cg350_slot_front")
		};

		private readonly Dictionary<Accessory, List<Transform>> _accParts = new Dictionary<Accessory, List<Transform>>();

		private readonly Dictionary<Accessory, Bounds> _accBounds = new Dictionary<Accessory, Bounds>();

		private readonly Dictionary<Player, MagicaCloth[]> _pinnedCapes = new Dictionary<Player, MagicaCloth[]>();

		private static readonly List<Player> _drop = new List<Player>();

		private float _nextCapeScan;

		private CapsuleCollider _barBody;

		private int _barBodyState = -1;

		private int _reachState = -1;

		private bool _trampleSearched;

		private const float MaxTiltDeg = 35f;

		private const float MaxHeave = 0.2f;

		private const float RayLift = 0.5f;

		private const float TiltRate = 12f;

		private const float MaxTiltSpeed = 110f;

		private const float HeaveSmooth = 0.09f;

		private const float HeaveMaxSpeed = 1.5f;

		private const float HangMaxSpeed = 1f;

		private const float HangDelay = 0.3f;

		private const float HangCooldown = 1.5f;

		private float _hangCooldownUntil;

		internal float _lastDriveInput = -10f;

		private static int s_groundMask;

		private Transform _tiltPivot;

		private bool _groundInit;

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

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

		private readonly List<float> _wheelSign = new List<float>();

		private readonly List<bool> _wheelFront = new List<bool>();

		private float _wheelRadius;

		private float _travel;

		private Quaternion _tiltCur = Quaternion.identity;

		private float _heaveCur;

		internal int GroundSupports;

		private Transform _scWheel;

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

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

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

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

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

		private Vector3 _scWheelCenter;

		private Vector3 _scPivot;

		private Vector3 _scPivotAxis;

		private Vector3 _scSpinAxis;

		private float _scDegPerMeter;

		private const int Contacts = 5;

		internal Vector3 HangDir;

		private float _hangTime;

		private float _heaveVel;

		private const float HangSlide = 2.2f;

		private const float ScTravel = 2f;

		private const float PassLeanDeg = 16f;

		private Transform _passHips;

		private Transform _passFootL;

		private Transform _passFootR;

		private Transform _passHandL;

		private Transform _passHandR;

		private bool _passSearched;

		private readonly Dictionary<Player, PassengerBones> _passBones = new Dictionary<Player, PassengerBones>();

		private static bool s_portalAllowAll;

		private const float ReseatWait = 30f;

		private const float ReseatReach = 12f;

		private const int HEADLIGHT = 1;

		private const int LEFT = 2;

		private const int RIGHT = 4;

		private const int HAZARD = 8;

		private const int BRAKE = 16;

		private const int HEADLIGHT_MANUAL = 32;

		private const int HORN = 128;

		private static readonly int s_lightsHash = StringExtensionMethods.GetStableHashCode("cg350_lights");

		private const float BlinkHz = 1.4f;

		private const float TailLightDim = 0.45f;

		private const float TailLightBrake = 1f;

		private ZNetView _nview;

		private Character _character;

		private Sadle _sadle;

		private Transform _model;

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

		private Transform _tiller;

		private Transform _needle;

		private readonly List<Renderer> _amberL = new List<Renderer>();

		private readonly List<Renderer> _amberR = new List<Renderer>();

		private readonly List<Renderer> _tail = new List<Renderer>();

		private Renderer _headLens;

		private Renderer _scNoseLens;

		private Renderer _scPlateLamp;

		private Light _scNoseLight;

		private Light _scPlateLight;

		private readonly List<Light> _lightsL = new List<Light>();

		private readonly List<Light> _lightsR = new List<Light>();

		private readonly List<Light> _lightsTail = new List<Light>();

		private Light _headLight;

		private GameObject _demister;

		private Material _amberOff;

		private Material _amberOn;

		private Material _redOff;

		private Material _redOn;

		private Material _redTail;

		private Material _clearOff;

		private Material _clearOn;

		private AudioSource _sfx;

		private AudioSource _motor;

		private AudioClip _horn;

		private AudioClip _tickOn;

		private AudioClip _tickOff;

		private float _wheelAngle;

		private float _prevYaw;

		private float _steer;

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

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

		private Quaternion _tillerRest;

		private Quaternion _needleRest;

		private Vector3 _tillerAxis;

		private Vector3 _needleAxis;

		private bool _blinkPhase;

		private int _lastMask = -1;

		private const float BeamHalfAngleDeg = 20f;

		private const float BeamNearRadius = 3.5f;

		private const float MinHonk = 0.1f;

		private float _hornHeldUntil = -1f;

		private AudioSource _hornSrc;

		private AudioClip _hornLoop;

		private bool _hornWas;

		private float _hornOnAt;

		private const float SteerLock = 35f;

		private const float ReverseFactor = 0.55f;

		private const float InputTimeout = 1f;

		private const int REVERSE = 64;

		private Vector3 _driveInput;

		private float _driveSkill;

		private float _driveInputTime;

		private Vector3 _lastSent;

		private float _lastSentTime;

		private bool _driving;

		private AudioClip _beep;

		private float _lastBeep;

		private bool _jumpQueued;

		private AudioClip _keyOn;

		private AudioClip _land;

		private AudioClip _bump;

		private Cloth _flag;

		private bool _flagSearched;

		private bool _flagWoken;

		private readonly Dictionary<Player, RiderBones> _riderBones = new Dictionary<Player, RiderBones>();

		private Renderer _gripL;

		private Renderer _gripR;

		private bool _gripsSearched;

		private const float SpineLeanDeg = 3f;

		private const float TrampleSpeed = 7f;

		private GameObject _trample;

		private bool _trampleLooked;

		private bool _hareThrottle;

		private float _nextBonePrune;

		private static readonly List<Player> s_gone = new List<Player>();

		private bool _wasOccupied;

		private bool _wasGrounded = true;

		private float _airTime;

		private float _prevSpeed;

		private float _lastBump;

		private Rigidbody _body;

		private bool _inPortal;

		private bool _carried;

		private static readonly FieldRef<Character, float> s_maxAirAltitude = AccessTools.FieldRefAccess<Character, float>("m_maxAirAltitude");

		internal Transform SidecarRoot;

		internal Transform SidecarAttach;

		private Transform _trunk;

		private AudioSource _nopeSrc;

		private Transform _ejectoPod;

		private Transform _ejectoButton;

		private Renderer _ejectoButtonR;

		private Material _ejectoOff;

		private AudioClip _ejectoLaunch;

		private AudioClip _ejectoNope;

		private Vector3 _ejectoRest;

		private Vector3 _ejectoPush;

		private float _ejectoPressUntil = -1f;

		private bool _ejectoLit;

		private const float EjectoTravel = 0.0055f;

		private const float EjectoPressTime = 0.22f;

		private static EffectList s_launchFx;

		private static GameObject s_sparks;

		private const float SparkRate = 120f;

		private const float SparkSeconds = 2.2f;

		private const float EjectUpSpeed = 40f;

		private const float EjectFuse = 0.65f;

		private const float EjectoVolume = 0.9f;

		private const float EjectoNopeVolume = 0.7f;

		private BoxCollider _scBody;

		private BoxCollider _trampleBox;

		private Vector3 _trampleCenter;

		private Vector3 _trampleSize;

		private Bounds _scBounds;

		private int _scBodyState = -1;

		private static int s_scBodyHits;

		private static int s_pieceMask;

		private static readonly Collider[] s_nearPieces = (Collider[])(object)new Collider[48];

		private float _portalScanAt;

		private Container _storage;

		private ScooterCompartments _compartments;

		private float _lastStackAt;

		private float DropMin => 0.6f;

		public Sadle Saddle => _sadle;

		internal int Mask
		{
			get
			{
				if (!((Object)(object)_nview != (Object)null) || !_nview.IsValid())
				{
					return 0;
				}
				return _nview.GetZDO().GetInt(s_lightsHash, 0);
			}
			set
			{
				if ((Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.IsOwner())
				{
					_nview.GetZDO().Set(s_lightsHash, value, false);
				}
			}
		}

		public bool Driving => _driving;

		private Rigidbody Body
		{
			get
			{
				if ((Object)(object)_body == (Object)null)
				{
					_body = ((Component)this).GetComponent<Rigidbody>();
				}
				return _body;
			}
		}

		internal bool SidecarFitted => IsFitted(Accessory.Sidecar);

		private Container Storage
		{
			get
			{
				if ((Object)(object)_storage == (Object)null)
				{
					Container[] componentsInChildren = ((Component)this).GetComponentsInChildren<Container>(true);
					foreach (Container val in componentsInChildren)
					{
						if (((Object)val).name == "BasketStorage")
						{
							_storage = val;
							break;
						}
					}
				}
				if ((Object)(object)_storage != (Object)null && (Object)(object)_compartments == (Object)null)
				{
					_compartments = ((Component)_storage).GetComponent<ScooterCompartments>();
				}
				return _storage;
			}
		}

		internal int SlotValue(Slot s)
		{
			if (!((Object)(object)_nview != (Object)null) || !_nview.IsValid())
			{
				return 0;
			}
			return _nview.GetZDO().GetInt(s_slotHash[(int)s], 0);
		}

		internal bool IsFitted(Accessory a)
		{
			return SlotValue(a.Slot) == a.Value;
		}

		internal Accessory FittedIn(Slot s)
		{
			return Accessory.In(s, SlotValue(s));
		}

		private void RegisterAccessoryRpc()
		{
			if (!((Object)(object)_nview == (Object)null) && _nview.IsValid())
			{
				_nview.Register<int, int, bool>("CG350_Slot", (Action<long, int, int, bool>)RPC_Slot);
				if ((Object)(object)_character != (Object)null)
				{
					Character character = _character;
					character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, new Action(OnScooterDestroyed));
				}
			}
		}

		private void InitAccessories()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_model == (Object)null)
			{
				return;
			}
			Accessory[] all = Accessory.All;
			foreach (Accessory accessory in all)
			{
				string[] names = accessory.KitParts.Prepend(accessory.ModelRoot).ToArray();
				_accParts[accessory] = (from t in ((Component)_model).GetComponentsInChildren<Transform>(true)
					where names.Contains(((Object)t).name)
					select t).ToList();
				Transform val = AccessoryRoot(accessory);
				if ((Object)(object)val != (Object)null)
				{
					_accBounds[accessory] = Accessory.MeshBounds(val, ((Component)this).transform);
				}
			}
			InitFrontBody();
			UpdateAccessories();
		}

		private void UpdateAccessories()
		{
			foreach (KeyValuePair<Accessory, List<Transform>> accPart in _accParts)
			{
				bool flag = IsFitted(accPart.Key);
				foreach (Transform item in accPart.Value)
				{
					if ((Object)(object)item != (Object)null && ((Component)item).gameObject.activeSelf != flag)
					{
						((Component)item).gameObject.SetActive(flag);
					}
				}
			}
			UpdateFrontBody();
		}

		internal bool AccessoryBounds(Accessory a, out Bounds b)
		{
			return _accBounds.TryGetValue(a, out b);
		}

		internal Transform AccessoryRoot(Accessory a)
		{
			if (!_accParts.TryGetValue(a, out var value))
			{
				return null;
			}
			return ((IEnumerable<Transform>)value).FirstOrDefault((Func<Transform, bool>)((Transform t) => (Object)(object)t != (Object)null && ((Object)t).name == a.ModelRoot));
		}

		internal bool TryFit(Accessory a, Humanoid user, ItemData item)
		{
			if ((Object)(object)user == (Object)null || item == null || (Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				return false;
			}
			if (!WardAllows(user))
			{
				return true;
			}
			Accessory accessory = FittedIn(a.Slot);
			if (accessory == a)
			{
				((Character)user).Message((MessageType)2, "$cg350_already_fitted", 0, (Sprite)null, false);
				return true;
			}
			if (accessory != null && !accessory.CanRemove(this, user))
			{
				return true;
			}
			user.GetInventory().RemoveOneItem(item);
			if (accessory != null)
			{
				GiveOrDrop(user, accessory);
			}
			_nview.InvokeRPC("CG350_Slot", new object[3]
			{
				(int)a.Slot,
				a.Value,
				false
			});
			((Character)user).Message((MessageType)2, a.SharedName + "_fitted", 0, (Sprite)null, false);
			return true;
		}

		internal void RequestRemove(Accessory a, Humanoid user = null)
		{
			if (IsFitted(a) && a.CanRemove(this, user) && WardAllows(user))
			{
				_nview.InvokeRPC("CG350_Slot", new object[3]
				{
					(int)a.Slot,
					0,
					true
				});
			}
		}

		private bool WardAllows(Humanoid user)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Player val = (Player)(object)((user is Player) ? user : null);
			if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
			{
				return PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false);
			}
			return true;
		}

		private static void GiveOrDrop(Humanoid user, Accessory a)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(a.ItemName) : null);
			if (!((Object)(object)val == (Object)null) && !user.GetInventory().AddItem(val, 1))
			{
				Object.Instantiate<GameObject>(val, ((Component)user).transform.position + ((Component)user).transform.forward * 0.6f + Vector3.up * 0.5f, ((Component)user).transform.rotation);
			}
		}

		private void RPC_Slot(long sender, int slot, int value, bool dropOld)
		{
			if (!_nview.IsOwner() || slot < 0 || slot >= s_slotHash.Length)
			{
				return;
			}
			int num = SlotValue((Slot)slot);
			if (num == value)
			{
				return;
			}
			_nview.GetZDO().Set(s_slotHash[slot], value, false);
			Accessory accessory = Accessory.In((Slot)slot, num);
			if (accessory != null)
			{
				accessory.OnRemoved(this);
				if (dropOld)
				{
					SpawnAccessoryItem(accessory);
				}
			}
		}

		private void OnScooterDestroyed()
		{
			//IL_004f: 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_0054: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner())
			{
				return;
			}
			Vector3 at = (((Object)(object)Storage != (Object)null) ? ((Component)_storage).transform.position : ((Component)this).transform.position);
			DropCompartment(Compartment.Basket, at);
			DropCompartment(Compartment.Trunk, ((Object)(object)_trunk != (Object)null) ? _trunk.position : ((Component)this).transform.position);
			Accessory[] all = Accessory.All;
			foreach (Accessory accessory in all)
			{
				if (IsFitted(accessory))
				{
					accessory.OnRemoved(this);
					SpawnAccessoryItem(accessory);
				}
			}
			DropSalvage();
			DyingMeep.Play(((Component)this).transform.position, _horn, ((Object)(object)_sfx != (Object)null) ? _sfx.outputAudioMixerGroup : null);
		}

		private void DropSalvage()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			object obj;
			if (!((Object)(object)ZNetScene.instance != (Object)null))
			{
				obj = null;
			}
			else
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CG350_Piece");
				obj = ((prefab != null) ? prefab.GetComponent<Piece>() : null);
			}
			Piece val = (Piece)obj;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Requirement[] resources = val.m_resources;
			foreach (Requirement val2 in resources)
			{
				if (!((Object)(object)val2?.m_resItem == (Object)null) && !(((Object)val2.m_resItem).name == "Coins"))
				{
					int num = (val2.m_amount + 1) / 2;
					if (num > 0)
					{
						ItemData obj2 = val2.m_resItem.m_itemData.Clone();
						obj2.m_stack = num;
						obj2.m_dropPrefab = ((Component)val2.m_resItem).gameObject;
						ItemDrop.DropItem(obj2, 0, ((Component)this).transform.position + Vector3.up * 0.6f + Random.insideUnitSphere * 0.4f, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f));
					}
				}
			}
		}

		private void SpawnAccessoryItem(Accessory a)
		{
			//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_005b: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00b7: 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_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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(a.ItemName) : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)("CG-350: no " + a.Id + " item prefab to drop"));
				return;
			}
			Bounds b;
			Vector3 val2 = (AccessoryBounds(a, out b) ? ((Component)this).transform.TransformPoint(((Bounds)(ref b)).center) : ((Component)this).transform.position);
			Vector3 val3 = val2 - ((Component)this).transform.position;
			val3.y = 0f;
			val3 = ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val3)).normalized : ((Component)this).transform.forward);
			Rigidbody component = Object.Instantiate<GameObject>(val, val2 + Vector3.up * 0.6f, ((Component)this).transform.rotation).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.linearVelocity = val3 * 1.5f + Vector3.up * 1.5f;
			}
		}

		private bool SeatedHere(Player p)
		{
			if (!((Object)(object)_sadle != (Object)null) || !SeatedOn(p, _sadle.m_attachPoint))
			{
				if (SidecarFitted)
				{
					return SeatedOn(p, SidecarAttach);
				}
				return false;
			}
			return true;
		}

		private void UpdateCapePins()
		{
			bool flag = Time.time >= _nextCapeScan;
			if (flag)
			{
				_nextCapeScan = Time.time + 0.5f;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!SeatedHere(allPlayer) || (!flag && _pinnedCapes.ContainsKey(allPlayer)))
				{
					continue;
				}
				MagicaCloth[] componentsInChildren = ((Component)allPlayer).GetComponentsInChildren<MagicaCloth>(false);
				if (!_pinnedCapes.TryGetValue(allPlayer, out var value) || !SameSet(value, componentsInChildren))
				{
					if (value != null)
					{
						SetWeight(value, 1f, reset: false);
					}
					SetWeight(componentsInChildren, 0f, reset: false);
					_pinnedCapes[allPlayer] = componentsInChildren;
				}
			}
			_drop.Clear();
			foreach (KeyValuePair<Player, MagicaCloth[]> pinnedCape in _pinnedCapes)
			{
				Player key = pinnedCape.Key;
				if (!((Object)(object)key != (Object)null) || !SeatedHere(key))
				{
					_drop.Add(key);
				}
			}
			foreach (Player item in _drop)
			{
				SetWeight(_pinnedCapes[item], 1f, reset: true);
				_pinnedCapes.Remove(item);
			}
		}

		private void OnDestroy()
		{
			ReleaseAllCapes();
		}

		private void ReleaseAllCapes()
		{
			foreach (KeyValuePair<Player, MagicaCloth[]> pinnedCape in _pinnedCapes)
			{
				SetWeight(pinnedCape.Value, 1f, reset: true);
			}
			_pinnedCapes.Clear();
		}

		private static bool SameSet(MagicaCloth[] a, MagicaCloth[] b)
		{
			if (a.Length != b.Length)
			{
				return false;
			}
			for (int i = 0; i < a.Length; i++)
			{
				if ((Object)(object)a[i] != (Object)(object)b[i])
				{
					return false;
				}
			}
			return true;
		}

		private static void SetWeight(MagicaCloth[] cloths, float w, bool reset)
		{
			foreach (MagicaCloth val in cloths)
			{
				if (!((Object)(object)val == (Object)null))
				{
					val.SerializeData.blendWeight = w;
					val.SetParameterChange();
					if (reset)
					{
						val.ResetCloth(true);
					}
				}
			}
		}

		private void InitFrontBody()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00e0: 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_00e5: 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_0139: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			Transform val = AccessoryRoot(Accessory.Row1);
			Transform val2 = (((Object)(object)val != (Object)null) ? ((IEnumerable<Transform>)((Component)val).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "BB_Hoop")) : null);
			if (!((Object)(object)val2 == (Object)null))
			{
				Bounds val3 = Accessory.MeshBounds(val2, ((Component)this).transform);
				float num = Mathf.Max(((Bounds)(ref val3)).min.y, 0.2f);
				float num2 = (((Bounds)(ref val3)).max.y - num) / 2f;
				GameObject val4 = new GameObject("BarBody");
				int num3 = LayerMask.NameToLayer("Ignore Raycast");
				val4.layer = ((num3 >= 0) ? num3 : 2);
				val4.transform.SetParent(((Component)this).transform, false);
				Rigidbody body = Body;
				Vector3 centerOfMass = (((Object)(object)body != (Object)null) ? body.centerOfMass : Vector3.zero);
				_barBody = val4.AddComponent<CapsuleCollider>();
				_barBody.direction = 0;
				_barBody.radius = num2;
				_barBody.height = Mathf.Max(((Bounds)(ref val3)).size.x, 2f * num2);
				_barBody.center = new Vector3(((Bounds)(ref val3)).center.x, num + num2, ((Bounds)(ref val3)).max.z - num2);
				if ((Object)(object)body != (Object)null)
				{
					body.centerOfMass = centerOfMass;
				}
				SetBodyLayers((Collider)(object)_barBody, on: false);
				_barBodyState = 0;
			}
		}

		private void UpdateFrontBody()
		{
			int num = (IsFitted(Accessory.Row1) ? 1 : 0);
			if (!((Object)(object)_barBody == (Object)null) && num != _barBodyState)
			{
				_barBodyState = num;
				SetBodyLayers((Collider)(object)_barBody, num == 1);
			}
		}

		private void UpdateTrampleReach()
		{
			//IL_00a0: 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_00c1: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_01ac: 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)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_011e: 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_0138: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			if (!_trampleSearched)
			{
				_trampleSearched = true;
				BoxCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren<BoxCollider>(true);
				foreach (BoxCollider val in componentsInChildren)
				{
					if (((Object)val).name == "TrampleBox")
					{
						_trampleBox = val;
						_trampleCenter = val.center;
						_trampleSize = val.size;
						break;
					}
				}
			}
			if ((Object)(object)_trampleBox == (Object)null)
			{
				return;
			}
			int num = (SidecarFitted ? 1 : 0) | (SlotValue(Slot.Front) << 1);
			if (num != _reachState)
			{
				_reachState = num;
				Bounds val2 = default(Bounds);
				((Bounds)(ref val2))..ctor(_trampleCenter, _trampleSize);
				if (SidecarFitted && ((Bounds)(ref _scBounds)).size != Vector3.zero)
				{
					Bounds scBounds = _scBounds;
					((Bounds)(ref scBounds)).Expand(new Vector3(0.3f, 0f, 0.3f));
					((Bounds)(ref val2)).Encapsulate(new Vector3(((Bounds)(ref scBounds)).max.x, ((Bounds)(ref val2)).center.y, ((Bounds)(ref scBounds)).max.z));
					((Bounds)(ref val2)).Encapsulate(new Vector3(((Bounds)(ref scBounds)).max.x, ((Bounds)(ref val2)).center.y, ((Bounds)(ref scBounds)).min.z));
				}
				Accessory accessory = FittedIn(Slot.Front);
				if (accessory != null && AccessoryBounds(accessory, out var b))
				{
					((Bounds)(ref val2)).Encapsulate(new Vector3(((Bounds)(ref val2)).center.x, ((Bounds)(ref val2)).center.y, ((Bounds)(ref b)).max.z + 0.15f));
				}
				_trampleBox.center = ((Bounds)(ref val2)).center;
				_trampleBox.size = ((Bounds)(ref val2)).size;
			}
		}

		private void FixedUpdate()
		{
			//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_0053: 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_0062: 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_0071: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!(HangDir == Vector3.zero) && !((Object)(object)_nview == (Object)null) && _nview.IsValid() && _nview.IsOwner())
			{
				Rigidbody body = Body;
				if (!((Object)(object)body == (Object)null))
				{
					Vector3 val = ((Component)this).transform.TransformDirection(HangDir) * 2.2f * Time.fixedDeltaTime;
					val.y = 0f;
					body.MovePosition(body.position + val);
				}
			}
		}

		private static double Det3(double[,] m)
		{
			return m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) - m[0, 1] * (m[1, 0] * m[2, 2] - m[1, 2] * m[2, 0]) + m[0, 2] * (m[1, 0] * m[2, 1] - m[1, 1] * m[2, 0]);
		}

		private static double[,] Col(double[,] m, int col, double[] r)
		{
			double[,] array = (double[,])m.Clone();
			for (int i = 0; i < 3; i++)
			{
				array[i, col] = r[i];
			}
			return array;
		}

		private void InitGroundFollow()
		{
			//IL_007f: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0134: 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)
			_groundInit = true;
			if ((Object)(object)_model == (Object)null || (Object)(object)_sadle == (Object)null || _wheels.Count != 4)
			{
				return;
			}
			if (s_groundMask == 0)
			{
				s_groundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			}
			_tiltPivot = new GameObject("GroundTilt").transform;
			_tiltPivot.SetParent(((Component)this).transform, false);
			_model.SetParent(_tiltPivot, true);
			((Component)_sadle).transform.SetParent(_tiltPivot, true);
			float num = 1.2f;
			_wheelRadius = 0.127f * num;
			_travel = 0.04f * num;
			foreach (Transform wheel in _wheels)
			{
				Vector3 val = ((Component)this).transform.InverseTransformPoint(wheel.position);
				_wheelCenter.Add(val);
				_wheelRestPos.Add(wheel.localPosition);
				_wheelSign.Add(Mathf.Sign(val.x));
				_wheelFront.Add(val.z > 0f);
			}
			InitSidecarWheel();
		}

		private void InitSidecarWheel()
		{
			//IL_00d6: 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_0174: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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)
			if ((Object)(object)SidecarRoot == (Object)null)
			{
				return;
			}
			Transform val = null;
			Transform[] componentsInChildren = ((Component)SidecarRoot).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if (!((Object)val2).name.Contains("_LOD"))
				{
					if (((Object)val2).name == "SC_Wheel")
					{
						_scWheel = val2;
					}
					else if (((Object)val2).name == "SC_SwingArmPivot")
					{
						val = val2;
					}
					else if (((Object)val2).name == "SC_SwingArm" || ((Object)val2).name == "SC_AxleStub")
					{
						_scSwingParts.Add(val2);
					}
					else if (((Object)val2).name.StartsWith("SC_Fender"))
					{
						_scRideParts.Add(val2);
						_scRideRestPos.Add(val2.localPosition);
					}
				}
			}
			MeshFilter val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null);
			if ((Object)(object)_scWheel == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val3.sharedMesh == (Object)null)
			{
				_scWheel = null;
				return;
			}
			_scSwingParts.Add(_scWheel);
			foreach (Transform scSwingPart in _scSwingParts)
			{
				_scSwingRestPos.Add(scSwingPart.localPosition);
				_scSwingRestRot.Add(scSwingPart.localRotation);
			}
			_scWheelCenter = ((Component)this).transform.InverseTransformPoint(_scWheel.position);
			Transform obj = val;
			Bounds bounds = val3.sharedMesh.bounds;
			Vector3 val4 = obj.TransformPoint(((Bounds)(ref bounds)).center);
			_scPivot = SidecarRoot.InverseTransformPoint(val4);
			Vector3 val5 = SidecarRoot.InverseTransformDirection(((Component)this).transform.right);
			_scPivotAxis = ((Vector3)(ref val5)).normalized;
			val5 = _scWheel.InverseTransformDirection(((Component)this).transform.right);
			_scSpinAxis = ((Vector3)(ref val5)).normalized;
			Vector3 val6 = _scWheel.position - val4;
			float num = Vector3.Dot(Quaternion.AngleAxis(1f, ((Component)this).transform.right) * val6 - val6, ((Component)this).transform.up);
			_scDegPerMeter = ((Mathf.Abs(num) > 1E-05f) ? (1f / num) : 0f);
		}

		private void PlaceSidecarWheel(float rise)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00f2: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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)
			Vector3 val = SidecarRoot.TransformPoint(_scPivot);
			Vector3 val2 = SidecarRoot.TransformDirection(_scPivotAxis);
			float num = rise * _scDegPerMeter;
			for (int i = 0; i < _scSwingParts.Count; i++)
			{
				Transform obj = _scSwingParts[i];
				obj.localPosition = _scSwingRestPos[i];
				obj.localRotation = _scSwingRestRot[i];
				obj.RotateAround(val, val2, num);
			}
			Vector3 val3 = _scWheel.position - _scWheel.parent.TransformPoint(_scSwingRestPos[_scSwingParts.Count - 1]);
			for (int j = 0; j < _scRideParts.Count; j++)
			{
				_scRideParts[j].localPosition = _scRideRestPos[j];
				Transform obj2 = _scRideParts[j];
				obj2.position += val3;
			}
			Transform scWheel = _scWheel;
			scWheel.localRotation *= Quaternion.AngleAxis(_wheelAngle, _scSpinAxis);
		}

		private void UpdateGroundFollow()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: 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_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: 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_0796: Unknown result type (might be due to invalid IL or missing references)
			//IL_079b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0816: Unknown result type (might be due to invalid IL or missing references)
			//IL_081b: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0824: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: 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_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: 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_07e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_063e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0737: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0718: 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)
			if (!_groundInit)
			{
				InitGroundFollow();
			}
			if ((Object)(object)_tiltPivot == (Object)null)
			{
				return;
			}
			Camera mainCamera = Utils.GetMainCamera();
			Vector3 val;
			int num;
			if (!((Object)(object)mainCamera == (Object)null))
			{
				val = ((Component)mainCamera).transform.position - ((Component)this).transform.position;
				num = ((((Vector3)(ref val)).sqrMagnitude < 6400f) ? 1 : 0);
			}
			else
			{
				num = 1;
			}
			bool flag = (byte)num != 0;
			bool flag2 = (Object)(object)_scWheel != (Object)null && SidecarFitted && ((Component)_scWheel).gameObject.activeInHierarchy;
			int num2 = (flag2 ? 5 : 4);
			float[] d = new float[5];
			bool[] array = new bool[5];
			float[] array2 = new float[5];
			float num3 = Mathf.Tan(0.61086524f);
			for (int i = 0; i < num2; i++)
			{
				int num4 = i;
				Vector2 val2 = new Vector2(Contact(i).x, Contact(i).z);
				array2[num4] = ((Vector2)(ref val2)).magnitude * num3 + _travel + 0.02f;
			}
			if (flag)
			{
				RaycastHit val4 = default(RaycastHit);
				for (int j = 0; j < num2; j++)
				{
					Vector3 val3 = Contact(j);
					float num5 = ((j < 4) ? 0.5f : Mathf.Max(0.5f, array2[j] + 0.1f));
					float num6 = ((j < 4) ? 0.6f : Mathf.Max(0.6f, array2[j] + 0.2f));
					if (Physics.Raycast(((Component)this).transform.TransformPoint(new Vector3(val3.x, val3.y + num5, val3.z)), -((Component)this).transform.up, ref val4, num5 + _wheelRadius + num6, s_groundMask, (QueryTriggerInteraction)1))
					{
						float y = ((Component)this).transform.InverseTransformPoint(((RaycastHit)(ref val4)).point).y;
						d[j] = y - (val3.y - _wheelRadius);
						array[j] = true;
					}
				}
			}
			bool[] sup = new bool[5];
			bool[] array3 = new bool[5];
			GroundSupports = 0;
			int num7 = 0;
			for (int k = 0; k < num2; k++)
			{
				float num8 = ((k < 4) ? DropMin : Mathf.Max(DropMin, array2[k] + 0.1f));
				if (!array[k] || d[k] < 0f - num8)
				{
					array3[k] = true;
				}
				else if (d[k] <= array2[k] + 0.15f)
				{
					sup[k] = true;
					num7++;
					if (k < 4)
					{
						GroundSupports++;
					}
				}
			}
			Vector3 val5 = Vector3.zero;
			if (flag && GroundSupports >= 1 && GroundSupports < 4)
			{
				for (int l = 0; l < 4; l++)
				{
					if (array3[l])
					{
						val5 += new Vector3(_wheelCenter[l].x, 0f, _wheelCenter[l].z);
					}
				}
			}
			Vector3 val6 = (((Object)(object)_character != (Object)null) ? _character.GetVelocity() : Vector3.zero);
			val6.y = 0f;
			bool flag3 = (Object)(object)_sadle != (Object)null && _sadle.HaveValidUser() && Time.time - _lastDriveInput < 0.6f;
			bool flag4 = ((Vector3)(ref val5)).sqrMagnitude > 1E-06f && ((Vector3)(ref val6)).magnitude < 1f && Time.time >= _hangCooldownUntil && !flag3;
			_hangTime = (flag4 ? (_hangTime + Time.deltaTime) : 0f);
			Vector3 hangDir = HangDir;
			HangDir = ((flag4 && _hangTime >= 0.3f) ? ((Vector3)(ref val5)).normalized : Vector3.zero);
			if (hangDir != Vector3.zero && HangDir == Vector3.zero)
			{
				_hangCooldownUntil = Time.time + 1.5f;
			}
			float num9 = 0f;
			float num10 = 0f;
			float num11 = 0f;
			Quaternion val7 = Quaternion.identity;
			float num12 = 0f;
			if (num7 >= 2)
			{
				double num13 = 1.0;
				double num14 = 0.0;
				double num15 = 0.0;
				double num16 = 0.0;
				double num17 = 0.0;
				double num18 = 0.0;
				double num19 = 0.0;
				double num20 = 0.0;
				double num21 = 0.0;
				for (int m = 0; m < num2; m++)
				{
					if (sup[m])
					{
						double num22 = Contact(m).x;
						double num23 = Contact(m).z;
						double num24 = d[m];
						num13 += 1.0;
						num14 += num22;
						num15 += num23;
						num16 += num22 * num22;
						num17 += num23 * num23;
						num18 += num22 * num23;
						num19 += num24;
						num20 += num22 * num24;
						num21 += num23 * num24;
					}
				}
				double[,] m2 = new double[3, 3]
				{
					{ num13, num14, num15 },
					{ num14, num16, num18 },
					{ num15, num18, num17 }
				};
				double[] r = new double[3] { num19, num20, num21 };
				double num25 = Det3(m2);
				if (Math.Abs(num25) > 1E-09)
				{
					num9 = (float)(Det3(Col(m2, 0, r)) / num25);
					num10 = (float)(Det3(Col(m2, 1, r)) / num25);
					num11 = (float)(Det3(Col(m2, 2, r)) / num25);
				}
				else
				{
					Vector2 val8 = Vector2.zero;
					Vector2 val9 = default(Vector2);
					for (int n = 0; n < num2; n++)
					{
						if (sup[n])
						{
							((Vector2)(ref val9))..ctor(Contact(n).x, Contact(n).z);
							val8 = ((Vector2)(ref val9)).normalized;
							break;
						}
					}
					double num26 = 0.0;
					double num27 = 0.0;
					for (int num28 = 0; num28 < num2; num28++)
					{
						if (sup[num28])
						{
							double num29 = Contact(num28).x * val8.x + Contact(num28).z * val8.y;
							num26 += num29 * num29;
							num27 += num29 * (double)d[num28];
						}
					}
					if (num26 > 1E-09)
					{
						float num30 = (float)(num27 / num26);
						num10 = num30 * val8.x;
						num11 = num30 * val8.y;
					}
				}
				val = new Vector3(0f - num10, 1f, 0f - num11);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				val7 = Quaternion.FromToRotation(Vector3.up, normalized);
				float num31 = Quaternion.Angle(Quaternion.identity, val7);
				if (num31 > 35f)
				{
					val7 = Quaternion.Slerp(Quaternion.identity, val7, 35f / num31);
				}
				num12 = Mathf.Clamp(num9, -0.2f, 0.2f);
			}
			if (HangDir != Vector3.zero)
			{
				float num32 = Mathf.Lerp(6f, 22f, Mathf.Clamp01((_hangTime - 0.3f) / 0.35f));
				Vector3 val10 = Vector3.Cross(Vector3.up, HangDir);
				val7 = Quaternion.AngleAxis(num32, val10) * val7;
			}
			float num33 = Mathf.Max(Time.deltaTime, 0.0001f);
			float num34 = 1f - Mathf.Exp(-12f * num33);
			Quaternion val11 = Quaternion.Slerp(_tiltCur, val7, num34);
			_tiltCur = Quaternion.RotateTowards(_tiltCur, val11, 110f * num33);
			_heaveCur = Mathf.SmoothDamp(_heaveCur, num12, ref _heaveVel, 0.09f, 1.5f, num33);
			_tiltPivot.localRotation = _tiltCur;
			_tiltPivot.localPosition = new Vector3(0f, _heaveCur, 0f);
			for (int num35 = 0; num35 < 4; num35++)
			{
				Transform obj = _wheels[num35];
				Vector3 val12 = obj.parent.InverseTransformVector(_tiltPivot.up * Travel(num35, _travel));
				obj.localPosition = _wheelRestPos[num35] + val12;
			}
			if (flag2)
			{
				float rise = Travel(4, 2f * _travel);
				PlaceSidecarWheel(rise);
			}
			float Travel(int num36, float travel)
			{
				//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_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: 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_0050: Unknown result type (might be due to invalid IL or missing references)
				if (!sup[num36])
				{
					return 0f - travel;
				}
				Vector3 val13 = Contact(num36);
				Vector3 val14 = _tiltCur * Vector3.up;
				float num37 = _heaveCur + (0f - val14.x) / val14.y * val13.x + (0f - val14.z) / val14.y * val13.z;
				return Mathf.Clamp(d[num36] - num37, 0f - travel, travel);
			}
		}

		private Vector3 Contact(int i)
		{
			//IL_0012: 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)
			if (i >= 4)
			{
				return _scWheelCenter;
			}
			return _wheelCenter[i];
		}

		private PassengerBones PassBones(Player p)
		{
			if (_passBones.TryGetValue(p, out var value))
			{
				return value;
			}
			Animator an = ((Character)p).m_animator;
			value = new PassengerBones
			{
				hips = B((HumanBodyBones)0),
				spine = B((HumanBodyBones)7),
				chest = B((HumanBodyBones)8),
				upperChest = B((HumanBodyBones)54),
				neck = B((HumanBodyBones)9),
				head = B((HumanBodyBones)10),
				lThigh = B((HumanBodyBones)1),
				lShin = B((HumanBodyBones)3),
				lFoot = B((HumanBodyBones)5),
				lToes = B((HumanBodyBones)19),
				rThigh = B((HumanBodyBones)2),
				rShin = B((HumanBodyBones)4),
				rFoot = B((HumanBodyBones)6),
				rToes = B((HumanBodyBones)20),
				lClav = B((HumanBodyBones)11),
				lArm = B((HumanBodyBones)13),
				lFore = B((HumanBodyBones)15),
				lHand = B((HumanBodyBones)17),
				rClav = B((HumanBodyBones)12),
				rArm = B((HumanBodyBones)14),
				rFore = B((HumanBodyBones)16),
				rHand = B((HumanBodyBones)18),
				lMiddle = B((HumanBodyBones)30),
				rMiddle = B((HumanBodyBones)45),
				lPalm = FindBone(((Component)p).transform, "LeftHand_Attach"),
				rPalm = FindBone(((Component)p).transform, "RightHand_Attach")
			};
			if ((Object)(object)value.lPalm == (Object)null)
			{
				value.lPalm = value.lHand;
			}
			if ((Object)(object)value.rPalm == (Object)null)
			{
				value.rPalm = value.rHand;
			}
			value.ok = Object.op_Implicit((Object)(object)value.hips) && Object.op_Implicit((Object)(object)value.lThigh) && Object.op_Implicit((Object)(object)value.lShin) && Object.op_Implicit((Object)(object)value.lFoot) && Object.op_Implicit((Object)(object)value.rThigh) && Object.op_Implicit((Object)(object)value.rShin) && Object.op_Implicit((Object)(object)value.rFoot) && Object.op_Implicit((Object)(object)value.lArm) && Object.op_Implicit((Object)(object)value.lFore) && Object.op_Implicit((Object)(object)value.lHand) && Object.op_Implicit((Object)(object)value.rArm) && Object.op_Implicit((Object)(object)value.rFore) && Object.op_Implicit((Object)(object)value.rHand);
			_passBones[p] = value;
			return value;
			Transform B(HumanBodyBones h)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)an != (Object)null))
				{
					return null;
				}
				return an.GetBoneTransform(h);
			}
		}

		private static bool SeatedOn(Player p, Transform attach)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)p == (Object)null) && !((Object)(object)attach == (Object)null))
			{
				Vector3 val = ((Component)p).transform.position - attach.position;
				if (!(((Vector3)(ref val)).sqrMagnitude > 0.04f))
				{
					if (!((Object)(object)p != (Object)(object)Player.m_localPlayer))
					{
						if (((Character)p).IsAttached())
						{
							return (Object)(object)p.GetAttachPoint() == (Object)(object)attach;
						}
						return false;
					}
					return true;
				}
			}
			return false;
		}

		private void FindPassengerAnchors()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			_passSearched = true;
			if ((Object)(object)SidecarRoot == (Object)null)
			{
				return;
			}
			Transform[] componentsInChildren = ((Component)SidecarRoot).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				switch (((Object)val).name)
				{
				case "SC_PassHips":
					_passHips = val;
					break;
				case "SC_PassFoot_L":
					_passFootL = val;
					break;
				case "SC_PassFoot_R":
					_passFootR = val;
					break;
				case "SC_PassHand_L":
					_passHandL = val;
					break;
				case "SC_PassHand_R":
					_passHandR = val;
					break;
				}
			}
			if ((Object)(object)_passFootL != (Object)null && (Object)(object)_passFootR != (Object)null && Vector3.Dot(_passFootL.position - _passFootR.position, ((Component)this).transform.right) > 0f)
			{
				Transform passFootR = _passFootR;
				Transform passFootL = _passFootL;
				_passFootL = passFootR;
				_passFootR = passFootL;
			}
			if ((Object)(object)_passHandL != (Object)null && (Object)(object)_passHandR != (Object)null && Vector3.Dot(_passHandL.position - _passHandR.position, ((Component)this).transform.right) > 0f)
			{
				Transform passFootL = _passHandR;
				Transform passFootR = _passHandL;
				_passHandL = passFootL;
				_passHandR = passFootR;
			}
		}

		private void PosePassengers()
		{
			if ((Object)(object)SidecarAttach == (Object)null || !SidecarFitted)
			{
				return;
			}
			if (!_passSearched)
			{
				FindPassengerAnchors();
			}
			if ((Object)(object)_passHips == (Object)null || (Object)(object)_passFootL == (Object)null || (Object)(object)_passFootR == (Object)null || (Object)(object)_passHandL == (Object)null || (Object)(object)_passHandR == (Object)null)
			{
				return;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (SeatedOn(allPlayer, SidecarAttach))
				{
					PosePassenger(allPlayer);
				}
			}
		}

		private void PosePassenger(Player p)
		{
			//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_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_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_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)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_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_00b8: 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_00c3: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: 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_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: 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_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: 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_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			PassengerBones passengerBones = PassBones(p);
			if (passengerBones.ok)
			{
				Vector3 right = SidecarAttach.right;
				Vector3 up = SidecarAttach.up;
				Vector3 forward = SidecarAttach.forward;
				Vector3 position = _passHips.position;
				Vector3 position2 = _passFootL.position;
				Vector3 position3 = _passFootR.position;
				Vector3 val = up * 0.025f - forward * 0.012f;
				float num = 16f;
				passengerBones.Begin();
				passengerBones.hips.position = position;
				SolveLimb(passengerBones.lThigh, passengerBones.lShin, passengerBones.lFoot, position2, up + forward * 0.5f - right * 0.2f);
				SolveLimb(passengerBones.rThigh, passengerBones.rShin, passengerBones.rFoot, position3, up + forward * 0.5f + right * 0.2f);
				Transform lFoot = passengerBones.lFoot;
				Transform lToes = passengerBones.lToes;
				Vector3 val2 = forward - up * 0.04f;
				OrientHand(lFoot, lToes, ((Vector3)(ref val2)).normalized);
				Transform rFoot = passengerBones.rFoot;
				Transform rToes = passengerBones.rToes;
				val2 = forward - up * 0.04f;
				OrientHand(rFoot, rToes, ((Vector3)(ref val2)).normalized);
				if ((Object)(object)passengerBones.upperChest != (Object)null && (Object)(object)passengerBones.chest != (Object)null && (Object)(object)passengerBones.spine != (Object)null)
				{
					Lean(passengerBones.spine, num * 0.4f, right);
					Lean(passengerBones.chest, num * 0.35f, right);
					Lean(passengerBones.upperChest, num * 0.25f, right);
				}
				else if ((Object)(object)passengerBones.chest != (Object)null && (Object)(object)passengerBones.spine != (Object)null)
				{
					Lean(passengerBones.spine, num * 0.55f, right);
					Lean(passengerBones.chest, num * 0.45f, right);
				}
				else if ((Object)(object)passengerBones.spine != (Object)null)
				{
					Lean(passengerBones.spine, num, right);
				}
				if ((Object)(object)passengerBones.neck != (Object)null)
				{
					Lean(passengerBones.neck, (0f - num) * 0.35f, right);
				}
				if ((Object)(object)passengerBones.head != (Object)null)
				{
					Lean(passengerBones.head, (0f - num) * 0.35f, right);
				}
				Vector3 target = _passHandL.position + val;
				Vector3 target2 = _passHandR.position + val;
				Reach(passengerBones.lClav, passengerBones.lArm, target, 0.45f);
				Reach(passengerBones.rClav, passengerBones.rArm, target2, 0.45f);
				val2 = forward * 0.55f - up * 0.8f + right * 0.1f;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				val2 = forward * 0.55f - up * 0.8f - right * 0.1f;
				Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
				for (int i = 0; i < 3; i++)
				{
					SolveArm(passengerBones.lArm, passengerBones.lFore, passengerBones.lPalm, target, -right, up);
					SolveArm(passengerBones.rArm, passengerBones.rFore, passengerBones.rPalm, target2, right, up);
					OrientHand(passengerBones.lHand, passengerBones.lMiddle, normalized);
					OrientHand(passengerBones.rHand, passengerBones.rMiddle, normalized2);
				}
				passengerBones.End();
			}
		}

		private static void Lean(Transform t, float deg, Vector3 axis)
		{
			//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_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)
			t.rotation = Quaternion.AngleAxis(deg, axis) * t.rotation;
		}

		private static void Reach(Transform clav, Transform arm, Vector3 target, float amount)
		{
			//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_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)clav == (Object)null) && !((Object)(object)arm == (Object)null))
			{
				Quaternion val = Quaternion.FromToRotation(arm.position - clav.position, target - clav.position);
				clav.rotation = Quaternion.Slerp(Quaternion.identity, val, amount) * clav.rotation;
			}
		}

		private static void SolveLimb(Transform upper, Transform lower, Transform effector, Vector3 target, Vector3 pole)
		{
			//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_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)
			//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_0015: 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_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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_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_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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0136: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 position = upper.position;
			Vector3 position2 = lower.position;
			Vector3 position3 = effector.position;
			Vector3 val = position2 - position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			val = position3 - position2;
			float magnitude2 = ((Vector3)(ref val)).magnitude;
			if (!(magnitude < 0.0001f) && !(magnitude2 < 0.0001f))
			{
				Vector3 val2 = target - position;
				float num = Mathf.Clamp(((Vector3)(ref val2)).magnitude, 0.02f, magnitude + magnitude2 - 0.005f);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num2 = Mathf.Clamp((magnitude * magnitude + num * num - magnitude2 * magnitude2) / (2f * magnitude * num), -1f, 1f);
				float num3 = Mathf.Sqrt(Mathf.Max(0f, 1f - num2 * num2));
				Vector3 val3 = Vector3.ProjectOnPlane(pole, normalized);
				if (!(((Vector3)(ref val3)).sqrMagnitude < 1E-06f))
				{
					((Vector3)(ref val3)).Normalize();
					Vector3 val4 = position + normalized * (magnitude * num2) + val3 * (magnitude * num3);
					upper.rotation = Quaternion.FromToRotation(position2 - position, val4 - position) * upper.rotation;
					position2 = lower.position;
					position3 = effector.position;
					lower.rotation = Quaternion.FromToRotation(position3 - position2, target - position2) * lower.rotation;
				}
			}
		}

		private void RegisterPortalRpc()
		{
			if (!((Object)(object)_nview == (Object)null) && _nview.IsValid())
			{
				_nview.Register<Vector3, Quaternion, bool>("CG350_PassengerPortal", (Action<long, Vector3, Quaternion, bool>)RPC_PassengerPortal);
			}
		}

		internal static void NotePortal(TeleportWorld portal)
		{
			s_portalAllowAll = (Object)(object)portal != (Object)null && portal.m_allowAllItems;
		}

		private void SendPassengerAlong(Player rider, Vector3 seatPos, Quaternion seatRot)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			Player val = Passenger();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)rider) && !((Object)(object)SidecarAttach == (Object)null))
			{
				var (val2, val3) = PassengerTarget(seatPos, seatRot);
				_nview.InvokeRPC(ZNetView.Everybody, "CG350_PassengerPortal", new object[3] { val2, val3, s_portalAllowAll });
			}
		}

		internal (Vector3, Quaternion) PassengerTarget(Vector3 seatPos, Quaternion seatRot)
		{
			//IL_0012: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_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_0039: 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_0068: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: