Decompiled source of LoxWagon v0.11.3

LoxWagon.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[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 HaldorWagonMod
{
	public sealed class ArticulatedChassis : MonoBehaviour
	{
		private struct CollisionPair
		{
			public Collider A;

			public Collider B;

			public bool Previous;
		}

		[HarmonyPatch(typeof(Vagon), "AttachTo")]
		private static class RouteHitch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				bool patched = false;
				foreach (CodeInstruction instruction in instructions)
				{
					MethodInfo methodInfo = instruction.operand as MethodInfo;
					if (methodInfo != null && methodInfo.Name == "AddComponent" && methodInfo.IsGenericMethod && methodInfo.GetGenericArguments()[0] == typeof(ConfigurableJoint))
					{
						instruction.opcode = OpCodes.Call;
						instruction.operand = AccessTools.Method(typeof(ArticulatedChassis), "MakeHitch", (Type[])null, (Type[])null);
						patched = true;
					}
					yield return instruction;
				}
				if (!patched)
				{
					throw new Exception("Cannot route vanilla hitch joint to articulated carrier.");
				}
			}

			private static void Postfix(Vagon __instance)
			{
				//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_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				ArticulatedChassis component = ((Component)__instance).GetComponent<ArticulatedChassis>();
				if (!((Object)(object)component == (Object)null))
				{
					object? value = AttachField.GetValue(__instance);
					ConfigurableJoint val = (ConfigurableJoint)((value is ConfigurableJoint) ? value : null);
					if (!((Object)(object)val == (Object)null))
					{
						((Joint)val).anchor = ((Component)val).transform.InverseTransformPoint(__instance.m_attachPoint.position);
						((Joint)val).enableCollision = false;
						component.desiredHitchAnchor = __instance.m_attachOffset;
						float num = AnchorError(val);
						((Joint)val).connectedAnchor = ((Component)((Joint)val).connectedBody).transform.InverseTransformPoint(__instance.m_attachPoint.position);
						ConfigurableJointMotion val2 = (ConfigurableJointMotion)1;
						val.zMotion = (ConfigurableJointMotion)1;
						ConfigurableJointMotion xMotion = (val.yMotion = val2);
						val.xMotion = xMotion;
						SoftJointLimit linearLimit = default(SoftJointLimit);
						((SoftJointLimit)(ref linearLimit)).limit = 0.08f;
						((SoftJointLimit)(ref linearLimit)).bounciness = 0f;
						((SoftJointLimit)(ref linearLimit)).contactDistance = 0.01f;
						val.linearLimit = linearLimit;
						component.settlingHitch = val;
						ManualLogSource log = HaldorWagonPlugin.Log;
						string[] obj = new string[12]
						{
							"Hitch settling wagon=",
							component.Identity,
							" initialNominalGap=",
							num.ToString("F3"),
							" actualGap=",
							AnchorError(val).ToString("F3"),
							" spring=",
							null,
							null,
							null,
							null,
							null
						};
						SoftJointLimitSpring linearLimitSpring = val.linearLimitSpring;
						obj[7] = ((SoftJointLimitSpring)(ref linearLimitSpring)).spring.ToString();
						obj[8] = " damper=";
						linearLimitSpring = val.linearLimitSpring;
						obj[9] = ((SoftJointLimitSpring)(ref linearLimitSpring)).damper.ToString();
						obj[10] = " breakForce=";
						obj[11] = ((Joint)val).breakForce.ToString();
						log.LogDebug((object)string.Concat(obj));
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
		private static class IgnorePlacementPreview
		{
			private static void Postfix(Player __instance)
			{
				object? value = AccessTools.Field(typeof(Player), "m_placementGhost").GetValue(__instance);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				ArticulatedChassis component = val.GetComponent<ArticulatedChassis>();
				if (!((Object)(object)component == (Object)null))
				{
					component.Preview = true;
					((Behaviour)component).enabled = false;
					Vagon component2 = val.GetComponent<Vagon>();
					if ((Object)(object)component2 != (Object)null)
					{
						((MonoBehaviour)component2).CancelInvoke();
						((Behaviour)component2).enabled = false;
					}
					LoxWagonController component3 = val.GetComponent<LoxWagonController>();
					if ((Object)(object)component3 != (Object)null)
					{
						((Behaviour)component3).enabled = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Vagon), "SetMass")]
		private static class PreserveMassRatios
		{
			private static bool Prefix(Vagon __instance, float __0)
			{
				ArticulatedChassis component = ((Component)__instance).GetComponent<ArticulatedChassis>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				if (!component.Preview)
				{
					component.SetMass(__0);
				}
				return false;
			}
		}

		private struct RecoveryShape
		{
			internal Collider Collider;

			internal Vector3 Position;

			internal Quaternion Rotation;
		}

		public Rigidbody Turntable;

		public Rigidbody Carrier;

		public Rigidbody[] Wheels;

		private Rigidbody body;

		private ZNetView net;

		private Vagon cart;

		private Rigidbody[] moving;

		private Vector3[] restPositions;

		private Quaternion[] restRotations;

		private bool owner;

		private bool initialized;

		private bool ready;

		private bool faulted;

		public bool Preview;

		private ConfigurableJoint yawJoint;

		private ConfigurableJoint pitchJoint;

		private ConfigurableJoint settlingHitch;

		private Quaternion yawRest;

		private Quaternion pitchRest;

		private Vector3 desiredHitchAnchor;

		private float lastBreakAt = -100f;

		private string lastBreakBody = "none";

		private static readonly MethodInfo Detach = AccessTools.Method(typeof(Vagon), "Detach", (Type[])null, (Type[])null);

		private float nextPublish;

		private float nextLog;

		private Vector3 lastRoot;

		private readonly List<CollisionPair> ignored = new List<CollisionPair>();

		private static readonly FieldInfo AttachField = AccessTools.Field(typeof(Vagon), "m_attachJoin");

		private RecoveryShape[] recoveryShapes;

		private Vector3[] recoveryPositions;

		private Quaternion[] recoveryRotations;

		internal bool PhysicsReady
		{
			get
			{
				if (ready && owner && !faulted)
				{
					return !Preview;
				}
				return false;
			}
		}

		internal string Identity
		{
			get
			{
				if (!((Object)(object)net != (Object)null) || !net.IsValid())
				{
					return ((Object)((Component)this).gameObject).GetInstanceID().ToString();
				}
				return ((object)Unsafe.As<ZDOID, ZDOID>(ref net.GetZDO().m_uid)/*cast due to .constrained prefix*/).ToString();
			}
		}

		internal static void Build(GameObject wagon, GameObject ram)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			VisualWheelRotation component = wagon.GetComponent<VisualWheelRotation>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.Shafts == (Object)null || (Object)(object)component.FrontAxle == (Object)null || component.Wheels.Length != 4)
			{
				throw new Exception("Articulated chassis requires separated wheels, shafts and front axle.");
			}
			Vagon component2 = wagon.GetComponent<Vagon>();
			Vagon val = (((Object)(object)ram != (Object)null) ? ram.GetComponent<Vagon>() : null);
			Rigidbody val2 = (((Object)(object)val != (Object)null && val.m_wheels.Length != 0) ? val.m_wheels[0] : null);
			MeshCollider val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<MeshCollider>() : null);
			if ((Object)(object)val3 == (Object)null || (Object)(object)val3.sharedMesh == (Object)null)
			{
				throw new Exception("BatteringRam wheel collider unavailable; chassis cannot be built.");
			}
			ArticulatedChassis articulatedChassis = wagon.AddComponent<ArticulatedChassis>();
			articulatedChassis.body = wagon.GetComponent<Rigidbody>();
			articulatedChassis.Turntable = NewBody("FrontTurntable", wagon.transform, new Vector3(0f, 1.25f, -2f), 3f);
			LimitedJoint(articulatedChassis.Turntable, articulatedChassis.body, Vector3.up, Vector3.forward, 32f, 1.5f);
			articulatedChassis.Carrier = NewBody("FrontAxleCarrier", ((Component)articulatedChassis.Turntable).transform, new Vector3(0f, 0f, 0.55f), 3.6f);
			LimitedJoint(articulatedChassis.Carrier, articulatedChassis.Turntable, Vector3.right, Vector3.up, 18f, 0.8f);
			articulatedChassis.Wheels = (Rigidbody[])(object)new Rigidbody[4];
			Vector3 val5 = default(Vector3);
			for (int i = 0; i < 4; i++)
			{
				bool flag = i < 2;
				Rigidbody val4 = (flag ? articulatedChassis.Carrier : articulatedChassis.body);
				((Vector3)(ref val5))..ctor((float)((i % 2 != 0) ? 1 : (-1)) * 1.44284f, 1f, (float)(flag ? (-2) : 2));
				Rigidbody val6 = NewBody((flag ? "Front" : "Rear") + ((i % 2 == 0) ? "Left" : "Right") + "Wheel", ((Component)val4).transform, ((Component)val4).transform.InverseTransformPoint(wagon.transform.TransformPoint(val5)), 2.1f);
				((Component)val6).transform.rotation = wagon.transform.rotation;
				GameObject val7 = new GameObject("WheelContact");
				val7.layer = ((Component)val3).gameObject.layer;
				val7.transform.SetParent(((Component)val6).transform, false);
				Bounds bounds = val3.sharedMesh.bounds;
				val7.transform.localScale = new Vector3(0.14f / ((Bounds)(ref bounds)).size.x, 1.96f / ((Bounds)(ref bounds)).size.y, 1.96f / ((Bounds)(ref bounds)).size.z);
				val7.transform.localPosition = -Vector3.Scale(((Bounds)(ref bounds)).center, val7.transform.localScale);
				MeshCollider obj = val7.AddComponent<MeshCollider>();
				obj.sharedMesh = val3.sharedMesh;
				obj.convex = true;
				((Collider)obj).sharedMaterial = ((Collider)val3).sharedMaterial;
				ConfigurableJoint obj2 = LockedJoint(val6, val4, Vector3.right, Vector3.up);
				obj2.angularXMotion = (ConfigurableJointMotion)2;
				obj2.projectionMode = (JointProjectionMode)0;
				articulatedChassis.Wheels[i] = val6;
				Transform transform = new GameObject("VisualWheelMount" + i).transform;
				transform.SetParent(((Component)val4).transform, false);
				transform.position = component.Wheels[i].position;
				transform.rotation = wagon.transform.rotation;
				component.Wheels[i].SetParent(transform, true);
			}
			component.Shafts.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			component.FrontAxle.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			component2.m_attachPoint.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			if ((Object)(object)component2.m_lineAttachPoints0 != (Object)null)
			{
				component2.m_lineAttachPoints0.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			if ((Object)(object)component2.m_lineAttachPoints1 != (Object)null)
			{
				component2.m_lineAttachPoints1.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			Transform val8 = wagon.transform.Find("LoxHitch");
			if ((Object)(object)val8 != (Object)null)
			{
				val8.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			Rigidbody[] wheels = component2.m_wheels;
			foreach (Rigidbody val9 in wheels)
			{
				if ((Object)(object)val9 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)val9).gameObject);
				}
			}
			Collider[] componentsInChildren = wagon.GetComponentsInChildren<Collider>(true);
			foreach (Collider val10 in componentsInChildren)
			{
				if (!val10.isTrigger && (Object)(object)((Component)val10).GetComponentInParent<Rigidbody>(true) == (Object)(object)articulatedChassis.body)
				{
					Object.DestroyImmediate((Object)(object)val10);
				}
			}
			BoxCollider obj3 = wagon.AddComponent<BoxCollider>();
			obj3.center = new Vector3(0f, 2.08f, 0.6f);
			obj3.size = new Vector3(1.85f, 0.36f, 5.25f);
			component2.m_slipperyCollider = null;
			WagonCollision.BuildBed(wagon);
			component2.m_wheels = articulatedChassis.Wheels;
			articulatedChassis.body.solverIterations = 20;
			articulatedChassis.body.solverVelocityIterations = 8;
			articulatedChassis.body.maxDepenetrationVelocity = 2f;
			articulatedChassis.body.centerOfMass = new Vector3(0f, 1.65f, 0.35f);
			articulatedChassis.SetMass(component2.m_baseMass);
			HaldorWagonPlugin.Log.LogDebug((object)"Articulated chassis built: BatteringRam wheel contacts; yaw +/-32, offset pitch +/-18; shafts AND actual hitch on carrier; four physical wheels; roll locked.");
		}

		private static Rigidbody NewBody(string name, Transform parent, Vector3 pos, float mass)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			Rigidbody obj = val.AddComponent<Rigidbody>();
			obj.mass = mass;
			obj.linearDamping = 0f;
			obj.angularDamping = 0.1f;
			obj.solverIterations = 20;
			obj.solverVelocityIterations = 8;
			obj.maxDepenetrationVelocity = 2f;
			obj.collisionDetectionMode = (CollisionDetectionMode)2;
			obj.interpolation = (RigidbodyInterpolation)1;
			obj.maxAngularVelocity = 15f;
			obj.inertiaTensor = Vector3.one * 0.8f;
			obj.inertiaTensorRotation = Quaternion.identity;
			return obj;
		}

		private static ConfigurableJoint LockedJoint(Rigidbody child, Rigidbody parent, Vector3 axis, Vector3 secondary)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0061: 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_0072: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			ConfigurableJoint obj = ((Component)child).gameObject.AddComponent<ConfigurableJoint>();
			((Joint)obj).autoConfigureConnectedAnchor = false;
			((Joint)obj).connectedBody = parent;
			((Joint)obj).anchor = Vector3.zero;
			((Joint)obj).connectedAnchor = ((Component)parent).transform.InverseTransformPoint(((Component)child).transform.position);
			((Joint)obj).axis = axis;
			obj.secondaryAxis = secondary;
			ConfigurableJointMotion val = (ConfigurableJointMotion)0;
			obj.zMotion = (ConfigurableJointMotion)0;
			ConfigurableJointMotion xMotion = (obj.yMotion = val);
			obj.xMotion = xMotion;
			val = (ConfigurableJointMotion)0;
			obj.angularZMotion = (ConfigurableJointMotion)0;
			xMotion = (obj.angularYMotion = val);
			obj.angularXMotion = xMotion;
			((Joint)obj).enableCollision = false;
			((Joint)obj).enablePreprocessing = true;
			obj.projectionMode = (JointProjectionMode)1;
			obj.projectionDistance = 0.05f;
			obj.projectionAngle = 3f;
			return obj;
		}

		private static void LimitedJoint(Rigidbody child, Rigidbody parent, Vector3 axis, Vector3 secondary, float limit, float damping)
		{
			//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_0013: 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_0044: 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_0073: 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)
			ConfigurableJoint obj = LockedJoint(child, parent, axis, secondary);
			obj.angularXMotion = (ConfigurableJointMotion)1;
			SoftJointLimit val = default(SoftJointLimit);
			((SoftJointLimit)(ref val)).limit = 0f - limit;
			((SoftJointLimit)(ref val)).bounciness = 0f;
			((SoftJointLimit)(ref val)).contactDistance = 2f;
			obj.lowAngularXLimit = val;
			val = default(SoftJointLimit);
			((SoftJointLimit)(ref val)).limit = limit;
			((SoftJointLimit)(ref val)).bounciness = 0f;
			((SoftJointLimit)(ref val)).contactDistance = 2f;
			obj.highAngularXLimit = val;
			JointDrive angularXDrive = default(JointDrive);
			((JointDrive)(ref angularXDrive)).positionSpring = 0f;
			((JointDrive)(ref angularXDrive)).positionDamper = damping;
			((JointDrive)(ref angularXDrive)).maximumForce = 30f;
			obj.angularXDrive = angularXDrive;
		}

		private bool BodiesValid()
		{
			if ((Object)(object)body != (Object)null && (Object)(object)Turntable != (Object)null && (Object)(object)Carrier != (Object)null && Wheels != null && Wheels.Length == 4)
			{
				return Wheels.All((Rigidbody w) => (Object)(object)w != (Object)null);
			}
			return false;
		}

		internal void SetMass(float total)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (Preview || faulted)
			{
				return;
			}
			if ((Object)(object)body == (Object)null)
			{
				body = ((Component)this).GetComponent<Rigidbody>();
			}
			if (BodiesValid())
			{
				body.mass = total * 0.5f;
				Turntable.mass = total * 0.1f;
				Carrier.mass = total * 0.12f;
				Rigidbody[] wheels = Wheels;
				for (int i = 0; i < wheels.Length; i++)
				{
					wheels[i].mass = total * 0.07f;
				}
				Turntable.inertiaTensor = Vector3.one * Turntable.mass * 0.8f;
				Carrier.inertiaTensor = new Vector3(3f, 3f, 0.5f) * Carrier.mass;
				wheels = Wheels;
				for (int i = 0; i < wheels.Length; i++)
				{
					wheels[i].ResetInertiaTensor();
				}
			}
		}

		private string MissingBodies()
		{
			List<string> list = new List<string>();
			if ((Object)(object)body == (Object)null)
			{
				list.Add("WagonBody");
			}
			if ((Object)(object)Turntable == (Object)null)
			{
				list.Add("FrontTurntable");
			}
			if ((Object)(object)Carrier == (Object)null)
			{
				list.Add("FrontAxleCarrier");
			}
			for (int i = 0; i < 4; i++)
			{
				if (Wheels == null || Wheels.Length <= i || (Object)(object)Wheels[i] == (Object)null)
				{
					list.Add("Wheel" + i);
				}
			}
			return string.Join(",", list.ToArray());
		}

		private void Fail(string reason)
		{
			if (faulted)
			{
				return;
			}
			faulted = true;
			ready = false;
			HaldorWagonPlugin.Log.LogError((object)("Chassis disabled wagon=" + Identity + " reason=" + reason));
			if ((Object)(object)cart != (Object)null && (Object)(object)net != (Object)null && net.IsValid() && net.IsOwner())
			{
				Detach.Invoke(cart, null);
			}
			if (moving != null)
			{
				Rigidbody[] array = moving;
				foreach (Rigidbody val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.collisionDetectionMode = (CollisionDetectionMode)3;
						val.isKinematic = true;
					}
				}
			}
			((Behaviour)this).enabled = false;
		}

		private unsafe void Start()
		{
			//IL_0112: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: 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_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			body = ((Component)this).GetComponent<Rigidbody>();
			net = ((Component)this).GetComponent<ZNetView>();
			cart = ((Component)this).GetComponent<Vagon>();
			if (Preview || (Object)(object)net == (Object)null || !net.IsValid())
			{
				((Behaviour)this).enabled = false;
				return;
			}
			if (!BodiesValid())
			{
				Fail("missing bodies: " + MissingBodies());
				return;
			}
			Physics.SyncTransforms();
			moving = ((IEnumerable<Rigidbody>)(object)new Rigidbody[2] { Turntable, Carrier }).Concat(Wheels).ToArray();
			restPositions = moving.Select((Rigidbody r) => ((Component)r).transform.localPosition).ToArray();
			restRotations = moving.Select((Rigidbody r) => ((Component)r).transform.localRotation).ToArray();
			lastRoot = ((Component)this).transform.position;
			Rigidbody[] array = moving;
			foreach (Rigidbody val in array)
			{
				ConfigurableJoint[] components = ((Component)val).GetComponents<ConfigurableJoint>();
				for (int num2 = 0; num2 < components.Length; num2++)
				{
					Object.DestroyImmediate((Object)(object)components[num2]);
				}
				if ((Object)(object)((Component)val).GetComponent<ChassisJointEvents>() == (Object)null)
				{
					((Component)val).gameObject.AddComponent<ChassisJointEvents>();
				}
			}
			LimitedJoint(Turntable, body, Vector3.up, Vector3.forward, 32f, 3f);
			LimitedJoint(Carrier, Turntable, Vector3.right, Vector3.up, 18f, 2f);
			yawJoint = ((Component)Turntable).GetComponent<ConfigurableJoint>();
			pitchJoint = ((Component)Carrier).GetComponent<ConfigurableJoint>();
			yawRest = Quaternion.Inverse(body.rotation) * Turntable.rotation;
			pitchRest = Quaternion.Inverse(Turntable.rotation) * Carrier.rotation;
			for (int num3 = 0; num3 < 4; num3++)
			{
				ConfigurableJoint obj = LockedJoint(Wheels[num3], (num3 < 2) ? Carrier : body, Vector3.right, Vector3.up);
				obj.angularXMotion = (ConfigurableJointMotion)2;
				obj.projectionMode = (JointProjectionMode)0;
			}
			Collider[] array2 = (from c in ((Component)this).GetComponentsInChildren<Collider>(true)
				where !c.isTrigger
				select c).ToArray();
			for (int num4 = 0; num4 < array2.Length; num4++)
			{
				for (int num5 = num4 + 1; num5 < array2.Length; num5++)
				{
					if (!((Object)(object)array2[num4].attachedRigidbody == (Object)(object)array2[num5].attachedRigidbody))
					{
						ignored.Add(new CollisionPair
						{
							A = array2[num4],
							B = array2[num5],
							Previous = Physics.GetIgnoreCollision(array2[num4], array2[num5])
						});
						Physics.IgnoreCollision(array2[num4], array2[num5], true);
					}
				}
			}
			SetMass(cart.m_baseMass + cart.m_container.GetInventory().GetTotalWeight() * cart.m_itemWeightMassFactor);
			CaptureRecoveryPose();
			ready = true;
			ManualLogSource log = HaldorWagonPlugin.Log;
			string[] obj2 = new string[10] { "Chassis initialized wagon=", Identity, " bodies=7 joints=6 yawRest=", null, null, null, null, null, null, null };
			Quaternion val2 = yawRest;
			obj2[3] = ((object)(*(Quaternion*)(&val2))/*cast due to .constrained prefix*/).ToString();
			obj2[4] = " pitchRest=";
			val2 = pitchRest;
			obj2[5] = ((object)(*(Quaternion*)(&val2))/*cast due to .constrained prefix*/).ToString();
			obj2[6] = " yawAnchorError=";
			obj2[7] = AnchorError(yawJoint).ToString("F4");
			obj2[8] = " pitchAnchorError=";
			obj2[9] = AnchorError(pitchJoint).ToString("F4");
			log.LogDebug((object)string.Concat(obj2));
			FixedUpdate();
		}

		internal void JointBroken(string source, float force)
		{
			lastBreakAt = Time.time;
			lastBreakBody = source;
			ConfigurableJoint val = (ConfigurableJoint)(((Object)(object)cart != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			HaldorWagonPlugin.Log.LogWarning((object)("Chassis joint break wagon=" + Identity + " source=" + source + " force=" + force + " hitchPresent=" + ((Object)(object)val != (Object)null) + " yawPresent=" + ((Object)(object)yawJoint != (Object)null) + " pitchPresent=" + ((Object)(object)pitchJoint != (Object)null)));
		}

		internal string LossContext()
		{
			return " wagon=" + Identity + " lastBreakBody=" + lastBreakBody + " secondsSinceBreak=" + (Time.time - lastBreakAt).ToString("F2");
		}

		private static float AnchorError(ConfigurableJoint j)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)j == (Object)null || (Object)(object)((Joint)j).connectedBody == (Object)null)
			{
				return -1f;
			}
			return Vector3.Distance(((Component)j).transform.TransformPoint(((Joint)j).anchor), ((Component)((Joint)j).connectedBody).transform.TransformPoint(((Joint)j).connectedAnchor));
		}

		private static float Twist(Rigidbody child, Rigidbody parent, Quaternion rest, Vector3 axis, out float swing)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0043: 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_0049: 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_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Inverse(rest) * (Quaternion.Inverse(parent.rotation) * child.rotation);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.x, val.y, val.z);
			Vector3 val3 = axis * Vector3.Dot(val2, axis);
			Quaternion val4 = new Quaternion(val3.x, val3.y, val3.z, val.w);
			Quaternion normalized = ((Quaternion)(ref val4)).normalized;
			swing = Quaternion.Angle(Quaternion.identity, val * Quaternion.Inverse(normalized));
			return Mathf.DeltaAngle(0f, 2f * Mathf.Atan2(Vector3.Dot(val3, axis), val.w) * 57.29578f);
		}

		private void SettleHitch()
		{
			//IL_0066: 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_0076: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)settlingHitch == (Object)null) && !((Object)(object)((Joint)settlingHitch).connectedBody == (Object)null))
			{
				if (AnchorError(settlingHitch) < 0.3f)
				{
					((Joint)settlingHitch).connectedAnchor = Vector3.MoveTowards(((Joint)settlingHitch).connectedAnchor, desiredHitchAnchor, 0.75f * Time.fixedDeltaTime);
				}
				Vector3 val = ((Joint)settlingHitch).connectedAnchor - desiredHitchAnchor;
				if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
				{
					HaldorWagonPlugin.Log.LogDebug((object)("Hitch settled wagon=" + Identity));
					settlingHitch = null;
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: 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_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01dc: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: 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_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			if (!ready || Preview || faulted)
			{
				return;
			}
			if (!BodiesValid())
			{
				Fail("runtime missing bodies: " + MissingBodies());
				return;
			}
			if ((Object)(object)yawJoint == (Object)null || (Object)(object)pitchJoint == (Object)null)
			{
				Fail("structural joint missing" + LossContext());
				return;
			}
			bool flag = (Object)(object)net != (Object)null && net.IsValid();
			bool flag2 = flag && net.IsOwner();
			if (!initialized || flag2 != owner)
			{
				if (initialized && owner && !flag2)
				{
					((Component)this).GetComponent<LoxWagonController>().ReleaseLocalHitch();
				}
				Rigidbody[] array = moving;
				foreach (Rigidbody val in array)
				{
					if (!flag2)
					{
						val.collisionDetectionMode = (CollisionDetectionMode)3;
					}
					val.isKinematic = !flag2;
					if (flag2)
					{
						val.collisionDetectionMode = (CollisionDetectionMode)2;
					}
				}
				if (flag2)
				{
					for (int j = 0; j < moving.Length; j++)
					{
						Rigidbody val2 = moving[j];
						((Component)val2).transform.localPosition = net.GetZDO().GetVec3("lw_chassis_p" + j, ((Component)val2).transform.localPosition);
						((Component)val2).transform.localRotation = net.GetZDO().GetQuaternion("lw_chassis_q" + j, ((Component)val2).transform.localRotation);
						val2.position = ((Component)val2).transform.position;
						val2.rotation = ((Component)val2).transform.rotation;
						val2.linearVelocity = net.GetZDO().GetVec3("lw_chassis_v" + j, body.linearVelocity);
						val2.angularVelocity = net.GetZDO().GetVec3("lw_chassis_w" + j, body.angularVelocity);
					}
				}
				owner = flag2;
				initialized = true;
				HaldorWagonPlugin.Log.LogDebug((object)("Articulated chassis physics owner=" + owner));
			}
			if (!flag)
			{
				return;
			}
			if (owner)
			{
				SettleHitch();
				Vector3 val3 = ((Component)this).transform.position - lastRoot;
				if (((Vector3)(ref val3)).sqrMagnitude > 100f)
				{
					for (int k = 0; k < moving.Length; k++)
					{
						Transform transform = ((Component)moving[k]).transform;
						transform.localPosition = restPositions[k];
						transform.localRotation = restRotations[k];
						moving[k].position = transform.position;
						moving[k].rotation = transform.rotation;
						moving[k].linearVelocity = body.linearVelocity;
						moving[k].angularVelocity = Vector3.zero;
					}
				}
				if (Time.time >= nextPublish)
				{
					nextPublish = Time.time + 0.1f;
					for (int l = 0; l < moving.Length; l++)
					{
						net.GetZDO().Set("lw_chassis_p" + l, ((Component)moving[l]).transform.localPosition);
						net.GetZDO().Set("lw_chassis_q" + l, ((Component)moving[l]).transform.localRotation);
						net.GetZDO().Set("lw_chassis_v" + l, moving[l].linearVelocity);
						net.GetZDO().Set("lw_chassis_w" + l, moving[l].angularVelocity);
					}
				}
				if (Time.time >= nextLog)
				{
					nextLog = Time.time + 10f;
					object? value = AttachField.GetValue(cart);
					ConfigurableJoint val4 = (ConfigurableJoint)((value is ConfigurableJoint) ? value : null);
					float num = (((Object)(object)val4 != (Object)null && (Object)(object)((Joint)val4).connectedBody != (Object)null) ? Vector3.Distance(((Component)val4).transform.TransformPoint(((Joint)val4).anchor), ((Component)((Joint)val4).connectedBody).transform.TransformPoint(((Joint)val4).connectedAnchor)) : 0f);
					float swing;
					float num2 = Twist(Turntable, body, yawRest, Vector3.up, out swing);
					float swing2;
					float num3 = Twist(Carrier, Turntable, pitchRest, Vector3.right, out swing2);
					ManualLogSource log = HaldorWagonPlugin.Log;
					string[] obj = new string[22]
					{
						"Chassis state wagon=",
						Identity,
						" yawTwist=",
						num2.ToString("F1"),
						" pitchTwist=",
						num3.ToString("F1"),
						" yawSwing=",
						swing.ToString("F1"),
						" pitchSwing=",
						swing2.ToString("F1"),
						" yawAnchorError=",
						AnchorError(yawJoint).ToString("F3"),
						" pitchAnchorError=",
						AnchorError(pitchJoint).ToString("F3"),
						" attached=",
						((Object)(object)val4 != (Object)null).ToString(),
						" settling=",
						((Object)(object)settlingHitch != (Object)null).ToString(),
						" hitchGap=",
						num.ToString("F3"),
						" speed=",
						null
					};
					val3 = body.linearVelocity;
					obj[21] = ((Vector3)(ref val3)).magnitude.ToString("F2");
					log.LogDebug((object)string.Concat(obj));
				}
			}
			else
			{
				for (int m = 0; m < moving.Length; m++)
				{
					Transform transform2 = ((Component)moving[m]).transform;
					transform2.localPosition = net.GetZDO().GetVec3("lw_chassis_p" + m, restPositions[m]);
					transform2.localRotation = net.GetZDO().GetQuaternion("lw_chassis_q" + m, restRotations[m]);
				}
			}
			lastRoot = ((Component)this).transform.position;
		}

		internal void PublishForHandoff()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (PhysicsReady && !((Object)(object)net == (Object)null) && net.IsValid() && net.IsOwner())
			{
				for (int i = 0; i < moving.Length; i++)
				{
					net.GetZDO().Set("lw_chassis_p" + i, ((Component)moving[i]).transform.localPosition);
					net.GetZDO().Set("lw_chassis_q" + i, ((Component)moving[i]).transform.localRotation);
					net.GetZDO().Set("lw_chassis_v" + i, moving[i].linearVelocity);
					net.GetZDO().Set("lw_chassis_w" + i, moving[i].angularVelocity);
				}
			}
		}

		private void OnDestroy()
		{
			foreach (CollisionPair item in ignored)
			{
				if ((Object)(object)item.A != (Object)null && (Object)(object)item.B != (Object)null)
				{
					Physics.IgnoreCollision(item.A, item.B, item.Previous);
				}
			}
		}

		internal static ConfigurableJoint MakeHitch(GameObject wagon)
		{
			ArticulatedChassis component = wagon.GetComponent<ArticulatedChassis>();
			if ((Object)(object)component != (Object)null && (!component.ready || component.faulted || !component.BodiesValid()))
			{
				throw new InvalidOperationException("Articulated chassis is not ready for hitching.");
			}
			return (((Object)(object)component != (Object)null) ? ((Component)component.Carrier).gameObject : wagon).AddComponent<ConfigurableJoint>();
		}

		private void CaptureRecoveryPose()
		{
			recoveryPositions = moving.Select((Rigidbody r) => ((Component)this).transform.InverseTransformPoint(r.position)).ToArray();
			recoveryRotations = moving.Select((Rigidbody r) => Quaternion.Inverse(((Component)this).transform.rotation) * r.rotation).ToArray();
			recoveryShapes = (from c in ((Component)this).GetComponentsInChildren<Collider>(true)
				where !c.isTrigger
				select new RecoveryShape
				{
					Collider = c,
					Position = ((Component)this).transform.InverseTransformPoint(((Component)c).transform.position),
					Rotation = Quaternion.Inverse(((Component)this).transform.rotation) * ((Component)c).transform.rotation
				}).ToArray();
		}

		internal bool RecoveryClear(Vector3 position, Quaternion rotation)
		{
			//IL_0148: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (recoveryShapes == null)
			{
				return false;
			}
			Physics.SyncTransforms();
			RecoveryShape[] array = recoveryShapes;
			Vector3 val4 = default(Vector3);
			float num2 = default(float);
			Collider[] array2;
			for (int i = 0; i < array.Length; i++)
			{
				RecoveryShape recoveryShape = array[i];
				Collider collider = recoveryShape.Collider;
				if ((Object)(object)collider == (Object)null || !collider.enabled || !((Component)collider).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val = position + rotation * recoveryShape.Position;
				Quaternion val2 = rotation * recoveryShape.Rotation;
				Bounds bounds = collider.bounds;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				float magnitude = ((Vector3)(ref extents)).magnitude;
				bounds = collider.bounds;
				float num = magnitude + Vector3.Distance(((Bounds)(ref bounds)).center, ((Component)collider).transform.position) + 0.05f;
				array2 = Physics.OverlapSphere(val, num, -1, (QueryTriggerInteraction)1);
				foreach (Collider val3 in array2)
				{
					if (!((Component)val3).transform.IsChildOf(((Component)this).transform) && Physics.ComputePenetration(collider, val, val2, val3, ((Component)val3).transform.position, ((Component)val3).transform.rotation, ref val4, ref num2) && num2 > (((Object)(object)val3.attachedRigidbody != (Object)null) ? 0.002f : 0.012f))
					{
						return false;
					}
				}
			}
			array2 = Physics.OverlapBox(position + rotation * new Vector3(0f, 1.65f, -4.5f), new Vector3(1.8f, 0.5f, 2.1f), rotation, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array2.Length; i++)
			{
				if (!((Component)array2[i]).transform.IsChildOf(((Component)this).transform))
				{
					return false;
				}
			}
			return true;
		}

		internal void RecoverUpright(Vector3 position, Quaternion rotation)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0052: 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_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00d7: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!PhysicsReady || recoveryPositions == null)
			{
				throw new InvalidOperationException("Recovery requires initialized owner physics");
			}
			body.position = position;
			body.rotation = rotation;
			((Component)this).transform.SetPositionAndRotation(position, rotation);
			Rigidbody obj = body;
			Vector3 linearVelocity = (body.angularVelocity = Vector3.zero);
			obj.linearVelocity = linearVelocity;
			for (int i = 0; i < moving.Length; i++)
			{
				Vector3 val = position + rotation * recoveryPositions[i];
				Quaternion val2 = rotation * recoveryRotations[i];
				((Component)moving[i]).transform.SetPositionAndRotation(val, val2);
				moving[i].position = val;
				moving[i].rotation = val2;
				Rigidbody obj2 = moving[i];
				linearVelocity = (moving[i].angularVelocity = Vector3.zero);
				obj2.linearVelocity = linearVelocity;
				moving[i].WakeUp();
			}
			settlingHitch = null;
			lastRoot = position;
			body.WakeUp();
			Physics.SyncTransforms();
			net.GetZDO().SetPosition(position);
			net.GetZDO().SetRotation(rotation);
			PublishForHandoff();
		}
	}
	public sealed class ChassisJointEvents : MonoBehaviour
	{
		private void OnJointBreak(float force)
		{
			ArticulatedChassis componentInParent = ((Component)this).GetComponentInParent<ArticulatedChassis>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				componentInParent.JointBroken(((Object)((Component)this).gameObject).name, force);
			}
		}
	}
	internal static class CargoCollisionData
	{
		internal static void Build(Transform[] stages)
		{
			//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_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_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: 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_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_0709: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_0725: 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_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0774: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: 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_07e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0800: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Unknown result type (might be due to invalid IL or missing references)
			//IL_081c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Unknown result type (might be due to invalid IL or missing references)
			//IL_0838: Unknown result type (might be due to invalid IL or missing references)
			//IL_083d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_0859: Unknown result type (might be due to invalid IL or missing references)
			//IL_0870: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0891: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e0: 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_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0901: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_0945: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0960: Unknown result type (might be due to invalid IL or missing references)
			//IL_0976: Unknown result type (might be due to invalid IL or missing references)
			//IL_097b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0991: Unknown result type (might be due to invalid IL or missing references)
			//IL_0996: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0edd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fee: Unknown result type (might be due to invalid IL or missing references)
			//IL_1005: Unknown result type (might be due to invalid IL or missing references)
			//IL_100a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1021: Unknown result type (might be due to invalid IL or missing references)
			//IL_1026: Unknown result type (might be due to invalid IL or missing references)
			//IL_103d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1042: Unknown result type (might be due to invalid IL or missing references)
			//IL_1059: Unknown result type (might be due to invalid IL or missing references)
			//IL_105e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1075: Unknown result type (might be due to invalid IL or missing references)
			//IL_107a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1091: Unknown result type (might be due to invalid IL or missing references)
			//IL_1096: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_1101: Unknown result type (might be due to invalid IL or missing references)
			//IL_1106: Unknown result type (might be due to invalid IL or missing references)
			//IL_111d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1122: Unknown result type (might be due to invalid IL or missing references)
			//IL_1139: Unknown result type (might be due to invalid IL or missing references)
			//IL_113e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1155: Unknown result type (might be due to invalid IL or missing references)
			//IL_115a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1171: Unknown result type (might be due to invalid IL or missing references)
			//IL_1176: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_11eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1206: Unknown result type (might be due to invalid IL or missing references)
			//IL_120b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1221: Unknown result type (might be due to invalid IL or missing references)
			//IL_1226: Unknown result type (might be due to invalid IL or missing references)
			//IL_123c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1241: Unknown result type (might be due to invalid IL or missing references)
			//IL_1257: Unknown result type (might be due to invalid IL or missing references)
			//IL_125c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1272: Unknown result type (might be due to invalid IL or missing references)
			//IL_1277: Unknown result type (might be due to invalid IL or missing references)
			//IL_128d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1292: Unknown result type (might be due to invalid IL or missing references)
			//IL_12a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_12fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1302: Unknown result type (might be due to invalid IL or missing references)
			//IL_1319: Unknown result type (might be due to invalid IL or missing references)
			//IL_131e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1335: Unknown result type (might be due to invalid IL or missing references)
			//IL_133a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1351: Unknown result type (might be due to invalid IL or missing references)
			//IL_1356: Unknown result type (might be due to invalid IL or missing references)
			//IL_136d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1372: Unknown result type (might be due to invalid IL or missing references)
			//IL_1389: Unknown result type (might be due to invalid IL or missing references)
			//IL_138e: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_13aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_13dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_141e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1423: Unknown result type (might be due to invalid IL or missing references)
			//IL_1439: Unknown result type (might be due to invalid IL or missing references)
			//IL_143e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1454: Unknown result type (might be due to invalid IL or missing references)
			//IL_1459: Unknown result type (might be due to invalid IL or missing references)
			//IL_146f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1474: Unknown result type (might be due to invalid IL or missing references)
			//IL_148a: Unknown result type (might be due to invalid IL or missing references)
			//IL_148f: Unknown result type (might be due to invalid IL or missing references)
			//IL_14a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_14aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_14db: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_14f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_14fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1512: Unknown result type (might be due to invalid IL or missing references)
			//IL_1517: Unknown result type (might be due to invalid IL or missing references)
			//IL_152e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1533: Unknown result type (might be due to invalid IL or missing references)
			//IL_154a: Unknown result type (might be due to invalid IL or missing references)
			//IL_154f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1566: Unknown result type (might be due to invalid IL or missing references)
			//IL_156b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1582: Unknown result type (might be due to invalid IL or missing references)
			//IL_1587: Unknown result type (might be due to invalid IL or missing references)
			//IL_159e: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_15ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_15bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_15d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_15db: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_160e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1613: Unknown result type (might be due to invalid IL or missing references)
			//IL_162a: Unknown result type (might be due to invalid IL or missing references)
			//IL_162f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1646: Unknown result type (might be due to invalid IL or missing references)
			//IL_164b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1662: Unknown result type (might be due to invalid IL or missing references)
			//IL_1667: Unknown result type (might be due to invalid IL or missing references)
			//IL_167e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1683: Unknown result type (might be due to invalid IL or missing references)
			//IL_169a: Unknown result type (might be due to invalid IL or missing references)
			//IL_169f: Unknown result type (might be due to invalid IL or missing references)
			//IL_16b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_16bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_16d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_16d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_16f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_170a: Unknown result type (might be due to invalid IL or missing references)
			//IL_170f: Unknown result type (might be due to invalid IL or missing references)
			//IL_174e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1753: Unknown result type (might be due to invalid IL or missing references)
			//IL_1769: Unknown result type (might be due to invalid IL or missing references)
			//IL_176e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1784: Unknown result type (might be due to invalid IL or missing references)
			//IL_1789: Unknown result type (might be due to invalid IL or missing references)
			//IL_179f: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_17bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_17d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_17da: Unknown result type (might be due to invalid IL or missing references)
			//IL_17f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_17f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_180b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1810: Unknown result type (might be due to invalid IL or missing references)
			//IL_1826: Unknown result type (might be due to invalid IL or missing references)
			//IL_182b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1842: Unknown result type (might be due to invalid IL or missing references)
			//IL_1847: Unknown result type (might be due to invalid IL or missing references)
			//IL_185e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1863: Unknown result type (might be due to invalid IL or missing references)
			//IL_187a: Unknown result type (might be due to invalid IL or missing references)
			//IL_187f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1896: Unknown result type (might be due to invalid IL or missing references)
			//IL_189b: Unknown result type (might be due to invalid IL or missing references)
			//IL_18b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_18b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_18ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_18d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_18ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_18ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_1906: Unknown result type (might be due to invalid IL or missing references)
			//IL_190b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1922: Unknown result type (might be due to invalid IL or missing references)
			//IL_1927: Unknown result type (might be due to invalid IL or missing references)
			//IL_193e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1943: Unknown result type (might be due to invalid IL or missing references)
			//IL_195a: Unknown result type (might be due to invalid IL or missing references)
			//IL_195f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1976: Unknown result type (might be due to invalid IL or missing references)
			//IL_197b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1992: Unknown result type (might be due to invalid IL or missing references)
			//IL_1997: Unknown result type (might be due to invalid IL or missing references)
			//IL_19ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_19b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_19ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_19cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_19e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_19eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a45: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a65: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a7b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a80: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a96: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ab1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ab6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1acc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1aec: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b02: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b23: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b56: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b72: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b93: Unknown result type (might be due to invalid IL or missing references)
			//IL_1baa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bc6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1be2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bfe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c03: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c1a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c36: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c52: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c73: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ca6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cab: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cde: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ce3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cff: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d16: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d32: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d37: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d53: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d86: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1da2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1da7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dda: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ddf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1df6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dfb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e12: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e17: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e33: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e93: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ea9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1eae: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ec4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ec9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1edf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ee4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1efa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1eff: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f15: Unknown result type (might be due to invalid I