Decompiled source of LoxCarts v0.12.0

BepInEx/plugins/LoxCarts.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("benjamin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.12.0.0")]
[assembly: AssemblyInformationalVersion("0.12.0+39be9ebaecc9c51e1a1d7ea1d808b1ecaf02bafc")]
[assembly: AssemblyProduct("LoxCarts")]
[assembly: AssemblyTitle("LoxCarts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.12.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_008f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: 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)
				ArticulatedChassis component = ((Component)__instance).GetComponent<ArticulatedChassis>();
				if (!((Object)component == (Object)null))
				{
					object value = AttachField.GetValue(__instance);
					ConfigurableJoint val = (ConfigurableJoint)((value is ConfigurableJoint) ? value : null);
					if (!((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 val3 = (val.yMotion = val2);
						ConfigurableJointMotion xMotion = val3;
						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[] array = 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;
						array[7] = ((SoftJointLimitSpring)(ref linearLimitSpring)).spring.ToString();
						array[8] = " damper=";
						linearLimitSpring = val.linearLimitSpring;
						array[9] = ((SoftJointLimitSpring)(ref linearLimitSpring)).damper.ToString();
						array[10] = " breakForce=";
						array[11] = ((Joint)val).breakForce.ToString();
						log.LogDebug((object)string.Concat(array));
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
		private static class IgnorePlacementPreview
		{
			private static void Postfix(Player __instance)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Expected O, but got Unknown
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Expected O, but got Unknown
				object value = AccessTools.Field(typeof(Player), "m_placementGhost").GetValue(__instance);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if ((Object)val == (Object)null)
				{
					return;
				}
				ArticulatedChassis component = val.GetComponent<ArticulatedChassis>();
				if (!((Object)component == (Object)null))
				{
					component.Preview = true;
					((Behaviour)component).enabled = false;
					Vagon component2 = val.GetComponent<Vagon>();
					if ((Object)component2 != (Object)null)
					{
						((MonoBehaviour)component2).CancelInvoke();
						((Behaviour)component2).enabled = false;
					}
					LoxWagonController component3 = val.GetComponent<LoxWagonController>();
					if ((Object)component3 != (Object)null)
					{
						((Behaviour)component3).enabled = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Vagon), "SetMass")]
		private static class PreserveMassRatios
		{
			private static bool Prefix(Vagon __instance, float __0)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Expected O, but got Unknown
				ArticulatedChassis component = ((Component)__instance).GetComponent<ArticulatedChassis>();
				if ((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
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				if (!((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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Expected O, but got Unknown
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Expected O, but got Unknown
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Expected O, but got Unknown
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Expected O, but got Unknown
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: 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_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Expected O, but got Unknown
			//IL_053f: Expected O, but got Unknown
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: 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)
			VisualWheelRotation component = wagon.GetComponent<VisualWheelRotation>();
			if ((Object)component == (Object)null || (Object)component.Shafts == (Object)null || (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)ram != (Object)null) ? ram.GetComponent<Vagon>() : null);
			Rigidbody val2 = (((Object)val != (Object)null && val.m_wheels.Length != 0) ? val.m_wheels[0] : null);
			MeshCollider val3 = (((Object)val2 != (Object)null) ? ((Component)val2).GetComponent<MeshCollider>() : null);
			if ((Object)val3 == (Object)null || (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 val4 = default(Vector3);
			for (int i = 0; i < 4; i++)
			{
				bool flag = i < 2;
				Rigidbody val5 = (flag ? articulatedChassis.Carrier : articulatedChassis.body);
				((Vector3)(ref val4))..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)val5).transform, ((Component)val5).transform.InverseTransformPoint(wagon.transform.TransformPoint(val4)), 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, val5, 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)val5).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)component2.m_lineAttachPoints0 != (Object)null)
			{
				component2.m_lineAttachPoints0.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			if ((Object)component2.m_lineAttachPoints1 != (Object)null)
			{
				component2.m_lineAttachPoints1.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			Transform val8 = wagon.transform.Find("LoxHitch");
			if ((Object)val8 != (Object)null)
			{
				val8.SetParent(((Component)articulatedChassis.Carrier).transform, true);
			}
			Rigidbody[] wheels = component2.m_wheels;
			foreach (Rigidbody val9 in wheels)
			{
				if ((Object)val9 != (Object)null)
				{
					Object.DestroyImmediate((Object)((Component)val9).gameObject);
				}
			}
			Collider[] componentsInChildren = wagon.GetComponentsInChildren<Collider>(true);
			foreach (Collider val10 in componentsInChildren)
			{
				if (!val10.isTrigger && (Object)((Component)val10).GetComponentInParent<Rigidbody>(true) == (Object)articulatedChassis.body)
				{
					Object.DestroyImmediate((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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			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 val2 = (obj.yMotion = val);
			ConfigurableJointMotion xMotion = val2;
			obj.xMotion = xMotion;
			val = (ConfigurableJointMotion)0;
			obj.angularZMotion = (ConfigurableJointMotion)0;
			val2 = (obj.angularYMotion = val);
			xMotion = val2;
			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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_009f: 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()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)body != (Object)null && (Object)Turntable != (Object)null && (Object)Carrier != (Object)null && Wheels != null && Wheels.Length == 4)
			{
				return Wheels.All((Rigidbody w) => (Object)w != (Object)null);
			}
			return false;
		}

		internal void SetMass(float total)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			if (Preview || faulted)
			{
				return;
			}
			if ((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 j = 0; j < wheels.Length; j++)
				{
					wheels[j].ResetInertiaTensor();
				}
			}
		}

		private string MissingBodies()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			List<string> list = new List<string>();
			if ((Object)body == (Object)null)
			{
				list.Add("WagonBody");
			}
			if ((Object)Turntable == (Object)null)
			{
				list.Add("FrontTurntable");
			}
			if ((Object)Carrier == (Object)null)
			{
				list.Add("FrontAxleCarrier");
			}
			for (int i = 0; i < 4; i++)
			{
				if (Wheels == null || Wheels.Length <= i || (Object)Wheels[i] == (Object)null)
				{
					list.Add("Wheel" + i);
				}
			}
			return string.Join(",", list.ToArray());
		}

		private void Fail(string reason)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			if (faulted)
			{
				return;
			}
			faulted = true;
			ready = false;
			HaldorWagonPlugin.Log.LogError((object)("Chassis disabled wagon=" + Identity + " reason=" + reason));
			if ((Object)cart != (Object)null && (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)val != (Object)null)
					{
						val.collisionDetectionMode = (CollisionDetectionMode)3;
						val.isKinematic = true;
					}
				}
			}
			((Behaviour)this).enabled = false;
		}

		private void Start()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_02f6: Expected O, but got Unknown
			body = ((Component)this).GetComponent<Rigidbody>();
			net = ((Component)this).GetComponent<ZNetView>();
			cart = ((Component)this).GetComponent<Vagon>();
			if (Preview || (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)components[num2]);
				}
				if ((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)array2[num4].attachedRigidbody == (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[] array3 = new string[10] { "Chassis initialized wagon=", Identity, " bodies=7 joints=6 yawRest=", null, null, null, null, null, null, null };
			Quaternion val2 = yawRest;
			array3[3] = ((object)val2).ToString();
			array3[4] = " pitchRest=";
			val2 = pitchRest;
			array3[5] = ((object)val2).ToString();
			array3[6] = " yawAnchorError=";
			array3[7] = AnchorError(yawJoint).ToString("F4");
			array3[8] = " pitchAnchorError=";
			array3[9] = AnchorError(pitchJoint).ToString("F4");
			log.LogDebug((object)string.Concat(array3));
			FixedUpdate();
		}

		internal void JointBroken(string source, float force)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			lastBreakAt = Time.time;
			lastBreakBody = source;
			object obj = (((Object)(object)cart != (Object)null) ? AttachField.GetValue(cart) : null);
			ConfigurableJoint val = (ConfigurableJoint)((obj is ConfigurableJoint) ? obj : null);
			HaldorWagonPlugin.Log.LogWarning((object)("Chassis joint break wagon=" + Identity + " source=" + source + " force=" + force + " hitchPresent=" + ((Object)val != (Object)null) + " yawPresent=" + ((Object)yawJoint != (Object)null) + " pitchPresent=" + ((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_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)j == (Object)null || (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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005f: 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_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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a4: 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 = default(Quaternion);
			((Quaternion)(ref val4))..ctor(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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)settlingHitch == (Object)null) && !((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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: 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_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: 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_04a4: Expected O, but got Unknown
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Expected O, but got Unknown
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: 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_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Expected O, but got Unknown
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Expected O, but got Unknown
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: 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)yawJoint == (Object)null || (Object)pitchJoint == (Object)null)
			{
				Fail("structural joint missing" + LossContext());
				return;
			}
			bool flag = (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)val4 != (Object)null && (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[] array2 = 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)val4 != (Object)null).ToString(),
						" settling=",
						((Object)settlingHitch != (Object)null).ToString(),
						" hitchGap=",
						num.ToString("F3"),
						" speed=",
						null
					};
					val3 = body.linearVelocity;
					array2[21] = ((Vector3)(ref val3)).magnitude.ToString("F2");
					log.LogDebug((object)string.Concat(array2));
				}
			}
			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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0071: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			if (PhysicsReady && !((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()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			foreach (CollisionPair item in ignored)
			{
				if ((Object)item.A != (Object)null && (Object)item.B != (Object)null)
				{
					Physics.IgnoreCollision(item.A, item.B, item.Previous);
				}
			}
		}

		internal static ConfigurableJoint MakeHitch(GameObject wagon)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			ArticulatedChassis component = wagon.GetComponent<ArticulatedChassis>();
			if ((Object)component != (Object)null && (!component.ready || component.faulted || !component.BodiesValid()))
			{
				throw new InvalidOperationException("Articulated chassis is not ready for hitching.");
			}
			return (((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_0018: 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_004c: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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_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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0142: Expected O, but got Unknown
			if (recoveryShapes == null)
			{
				return false;
			}
			Physics.SyncTransforms();
			RecoveryShape[] array = recoveryShapes;
			Vector3 val = default(Vector3);
			float num = 0f;
			Collider[] array2;
			for (int i = 0; i < array.Length; i++)
			{
				RecoveryShape recoveryShape = array[i];
				Collider collider = recoveryShape.Collider;
				if ((Object)collider == (Object)null || !collider.enabled || !((Component)collider).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val2 = position + rotation * recoveryShape.Position;
				Quaternion val3 = rotation * recoveryShape.Rotation;
				Bounds bounds = collider.bounds;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				float magnitude = ((Vector3)(ref extents)).magnitude;
				bounds = collider.bounds;
				float num2 = magnitude + Vector3.Distance(((Bounds)(ref bounds)).center, ((Component)collider).transform.position) + 0.05f;
				array2 = Physics.OverlapSphere(val2, num2, -1, (QueryTriggerInteraction)1);
				Collider[] array3 = array2;
				foreach (Collider val4 in array3)
				{
					if (!((Component)val4).transform.IsChildOf(((Component)this).transform) && Physics.ComputePenetration(collider, val2, val3, val4, ((Component)val4).transform.position, ((Component)val4).transform.rotation, ref val, ref num) && num > (((Object)val4.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 k = 0; k < array2.Length; k++)
			{
				if (!((Component)array2[k]).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_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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			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 val = (body.angularVelocity = Vector3.zero);
			Vector3 linearVelocity = val;
			obj.linearVelocity = linearVelocity;
			for (int i = 0; i < moving.Length; i++)
			{
				Vector3 val2 = position + rotation * recoveryPositions[i];
				Quaternion val3 = rotation * recoveryRotations[i];
				((Component)moving[i]).transform.SetPositionAndRotation(val2, val3);
				moving[i].position = val2;
				moving[i].rotation = val3;
				Rigidbody obj2 = moving[i];
				val = (moving[i].angularVelocity = Vector3.zero);
				linearVelocity = val;
				obj2.linearVelocity = linearVelocity;
				moving[i].WakeUp();
			}
			settlingHitch = null;
			lastRoot = position;
			body.WakeUp();
			Physics.SyncTransforms();
			net.GetZDO().SetPosition(position);
			net.GetZDO().SetRotation(rotation);
			PublishForHandoff();
		}
	}
	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_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_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: 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_0320: 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_033b: 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_0356: 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_0371: 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_038c: 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_03a7: 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_03c2: 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_03de: 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_03fa: 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_0416: 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_0432: 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_044e: 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_046a: 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_0486: 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_04a2: 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_04be: 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_04da: 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_04f6: 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_0512: 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_052e: 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_054a: 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_0566: 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_0582: 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_059e: 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_05ba: 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_05d6: 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_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_070e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0713: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0783: Unknown result type (might be due to invalid IL or missing references)
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_080f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_082b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_0847: Unknown result type (might be due to invalid IL or missing references)
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_087a: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0896: Unknown result type (might be due to invalid IL or missing references)
			//IL_089b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0906: Unknown result type (might be due to invalid IL or missing references)
			//IL_090b: Unknown result type (might be due to invalid IL or missing references)
			//IL_094f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_096a: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0985: Unknown result type (might be due to invalid IL or missing references)
			//IL_098a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ded: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e25: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0edb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0feb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1002: Unknown result type (might be due to invalid IL or missing references)
			//IL_1007: Unknown result type (might be due to invalid IL or missing references)
			//IL_101e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1023: Unknown result type (might be due to invalid IL or missing references)
			//IL_103a: Unknown result type (might be due to invalid IL or missing references)
			//IL_103f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1056: Unknown result type (might be due to invalid IL or missing references)
			//IL_105b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1072: Unknown result type (might be due to invalid IL or missing references)
			//IL_1077: Unknown result type (might be due to invalid IL or missing references)
			//IL_108e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1093: Unknown result type (might be due to invalid IL or missing references)
			//IL_10aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_10af: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1103: Unknown result type (might be due to invalid IL or missing references)
			//IL_111a: Unknown result type (might be due to invalid IL or missing references)
			//IL_111f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1136: Unknown result type (might be due to invalid IL or missing references)
			//IL_113b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1152: Unknown result type (might be due to invalid IL or missing references)
			//IL_1157: Unknown result type (might be due to invalid IL or missing references)
			//IL_116e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1173: Unknown result type (might be due to invalid IL or missing references)
			//IL_118a: Unknown result type (might be due to invalid IL or missing references)
			//IL_118f: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1209: Unknown result type (might be due to invalid IL or missing references)
			//IL_120e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1224: Unknown result type (might be due to invalid IL or missing references)
			//IL_1229: Unknown result type (might be due to invalid IL or missing references)
			//IL_123f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1244: Unknown result type (might be due to invalid IL or missing references)
			//IL_125a: Unknown result type (might be due to invalid IL or missing references)
			//IL_125f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1275: Unknown result type (might be due to invalid IL or missing references)
			//IL_127a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1290: Unknown result type (might be due to invalid IL or missing references)
			//IL_1295: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_12cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_1304: Unknown result type (might be due to invalid IL or missing references)
			//IL_131b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1320: Unknown result type (might be due to invalid IL or missing references)
			//IL_1337: Unknown result type (might be due to invalid IL or missing references)
			//IL_133c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1353: Unknown result type (might be due to invalid IL or missing references)
			//IL_1358: Unknown result type (might be due to invalid IL or missing references)
			//IL_136f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1374: Unknown result type (might be due to invalid IL or missing references)
			//IL_138b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1390: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_13df: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_13fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1400: Unknown result type (might be due to invalid IL or missing references)
			//IL_1441: Unknown result type (might be due to invalid IL or missing references)
			//IL_1446: Unknown result type (might be due to invalid IL or missing references)
			//IL_145c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1461: Unknown result type (might be due to invalid IL or missing references)
			//IL_1477: Unknown result type (might be due to invalid IL or missing references)
			//IL_147c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1492: Unknown result type (might be due to invalid IL or missing references)
			//IL_1497: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_14b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_14cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_14fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1503: Unknown result type (might be due to invalid IL or missing references)
			//IL_1519: Unknown result type (might be due to invalid IL or missing references)
			//IL_151e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1535: Unknown result type (might be due to invalid IL or missing references)
			//IL_153a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1551: Unknown result type (might be due to invalid IL or missing references)
			//IL_1556: Unknown result type (might be due to invalid IL or missing references)
			//IL_156d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1572: Unknown result type (might be due to invalid IL or missing references)
			//IL_1589: Unknown result type (might be due to invalid IL or missing references)
			//IL_158e: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_15aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_15dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_15e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_15fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1615: Unknown result type (might be due to invalid IL or missing references)
			//IL_161a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1631: Unknown result type (might be due to invalid IL or missing references)
			//IL_1636: Unknown result type (might be due to invalid IL or missing references)
			//IL_164d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1652: Unknown result type (might be due to invalid IL or missing references)
			//IL_1669: Unknown result type (might be due to invalid IL or missing references)
			//IL_166e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1685: Unknown result type (might be due to invalid IL or missing references)
			//IL_168a: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_16bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_16c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_16d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_16de: Unknown result type (might be due to invalid IL or missing references)
			//IL_16f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_16fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1711: Unknown result type (might be due to invalid IL or missing references)
			//IL_1716: Unknown result type (might be due to invalid IL or missing references)
			//IL_172d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1732: Unknown result type (might be due to invalid IL or missing references)
			//IL_1776: Unknown result type (might be due to invalid IL or missing references)
			//IL_177b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1791: Unknown result type (might be due to invalid IL or missing references)
			//IL_1796: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_17c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_17cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_17e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_17e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_17fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1802: Unknown result type (might be due to invalid IL or missing references)
			//IL_1818: Unknown result type (might be due to invalid IL or missing references)
			//IL_181d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1833: Unknown result type (might be due to invalid IL or missing references)
			//IL_1838: Unknown result type (might be due to invalid IL or missing references)
			//IL_184e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1853: Unknown result type (might be due to invalid IL or missing references)
			//IL_186a: Unknown result type (might be due to invalid IL or missing references)
			//IL_186f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1886: Unknown result type (might be due to invalid IL or missing references)
			//IL_188b: Unknown result type (might be due to invalid IL or missing references)
			//IL_18a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_18a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_18be: Unknown result type (might be due to invalid IL or missing references)
			//IL_18c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_18da: Unknown result type (might be due to invalid IL or missing references)
			//IL_18df: Unknown result type (might be due to invalid IL or missing references)
			//IL_18f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_18fb: Unknown result type (might be due to