Decompiled source of Lethal Orbit v0.3.1

BepInEx/plugins/LethalOrbit/LethalOrbit.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalOrbit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1")]
[assembly: AssemblyProduct("LethalOrbit")]
[assembly: AssemblyTitle("LethalOrbit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.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 LethalOrbit
{
	public sealed class CockpitCameras : IDisposable
	{
		private readonly ShipFlightController flight;

		private readonly SceneArt art = new SceneArt();

		private readonly Camera[] cameras = (Camera[])(object)new Camera[4];

		private readonly RenderTexture[] textures = (RenderTexture[])(object)new RenderTexture[4];

		private readonly HDAdditionalCameraData[] data = (HDAdditionalCameraData[])(object)new HDAdditionalCameraData[4];

		private readonly int mask;

		private int current;

		private float nextFrame;

		public Camera[] Views => cameras;

		public RenderTexture[] Textures => textures;

		public CockpitCameras(ShipFlightController flight, Transform cockpit, Camera main)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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_029c: 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_0386: 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_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			this.flight = flight;
			mask = main.cullingMask & -33;
			string[] array = new string[4] { "LEFT", "RIGHT", "REAR", "DOWN" };
			Vector3[] array2 = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(1.5f, 2f, -1.65f),
				new Vector3(1.5f, 2f, -11.75f),
				new Vector3(-10.4f, 2f, -6.7f),
				new Vector3(1.5f, -1.3f, -6.7f)
			};
			Vector3[] array3 = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(0f, -0.18f, 1f),
				new Vector3(0f, -0.18f, -1f),
				new Vector3(-1f, -0.18f, 0f),
				Vector3.down
			};
			HDAdditionalCameraData component = ((Component)main).GetComponent<HDAdditionalCameraData>();
			for (int i = 0; i < 4; i++)
			{
				int num = ((i % 2 != 0) ? 1 : (-1));
				CockpitScreen cockpitScreen = new CockpitScreen(art, cockpit, array[i], new Vector3((float)num * 1.72f, (i < 2) ? 2.23f : 1.47f, 2.4f), new Vector2(1.03f, 0.58f), (float)(-num) * 15f);
				RenderTexture val = art.Own<RenderTexture>(new RenderTexture(480, 270, 24, (RenderTextureFormat)0)
				{
					name = "Ship " + array[i] + " camera feed",
					antiAliasing = 1
				});
				val.Create();
				textures[i] = val;
				Material val2 = art.Material(Color.white, unlit: true);
				val2.SetTexture("_UnlitColorMap", (Texture)(object)val);
				cockpitScreen.Display.sharedMaterial = val2;
				GameObject val3 = art.Own<GameObject>(new GameObject("Ship exterior camera " + array[i]));
				val3.transform.SetParent(flight.Round.elevatorTransform, false);
				val3.transform.localPosition = array2[i];
				val3.transform.localRotation = Quaternion.LookRotation(array3[i], (i == 3) ? Vector3.right : Vector3.up);
				Camera val4 = val3.AddComponent<Camera>();
				((Behaviour)val4).enabled = false;
				val4.targetTexture = val;
				val4.depth = -30 - i;
				val4.rect = new Rect(0f, 0f, 1f, 1f);
				val4.aspect = 1.7777778f;
				val4.fieldOfView = ((i == 3) ? 100 : 85);
				val4.nearClipPlane = 0.05f;
				val4.allowHDR = false;
				val4.allowMSAA = false;
				val4.useOcclusionCulling = false;
				cameras[i] = val4;
				data[i] = val3.AddComponent<HDAdditionalCameraData>();
				if ((Object)(object)component != (Object)null)
				{
					data[i].volumeLayerMask = component.volumeLayerMask;
				}
				data[i].volumeAnchorOverride = ((Component)main).transform;
				data[i].antialiasing = (AntialiasingMode)0;
				data[i].allowDynamicResolution = false;
				data[i].xrRendering = false;
				val3.transform.localPosition = array2[i];
				val3.transform.localRotation = Quaternion.LookRotation(array3[i], (i == 3) ? Vector3.right : Vector3.up);
			}
		}

		public void Update()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			Camera[] array = cameras;
			for (int i = 0; i < array.Length; i++)
			{
				((Behaviour)array[i]).enabled = false;
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !(Vector3.Distance(((Component)val).transform.position, flight.Seat.position) > 9f) && !(Time.unscaledTime < nextFrame))
			{
				nextFrame = Time.unscaledTime + 0.025f;
				current = (current + 1) % 4;
				Camera obj = cameras[current];
				obj.cullingMask = mask | int.MinValue;
				obj.farClipPlane = (flight.IsSpace ? 6500 : 1100);
				data[current].clearColorMode = (ClearColorMode)(flight.IsSpace ? 1 : 0);
				data[current].backgroundColorHDR = new Color(0.001f, 0.002f, 0.006f);
				((Behaviour)obj).enabled = true;
				obj.ResetWorldToCameraMatrix();
				obj.ResetProjectionMatrix();
				obj.ResetCullingMatrix();
			}
		}

		public void Dispose()
		{
			RenderTexture[] array = textures;
			foreach (RenderTexture val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.Release();
				}
			}
			art.Dispose();
		}
	}
	internal sealed class CockpitScreen
	{
		public readonly Transform Root;

		public readonly Renderer Display;

		public CockpitScreen(SceneArt art, Transform parent, string name, Vector3 position, Vector2 size, float yaw = 0f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_016a: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			Root = new GameObject(name + " monitor").transform;
			Root.SetParent(parent, false);
			Root.localPosition = position;
			Root.localRotation = Quaternion.Euler(0f, yaw, 0f);
			Material material = art.Material(new Color(0.22f, 0.26f, 0.28f));
			Material material2 = art.Material(new Color(0.007f, 0.017f, 0.02f), unlit: true);
			SceneArt.Part(Root, name + " housing", new Vector3(0f, 0f, 0.055f), new Vector3(size.x + 0.12f, size.y + 0.18f, 0.13f), material, (PrimitiveType)3);
			GameObject val = SceneArt.Part(Root, name + " screen", new Vector3(0f, 0f, -0.016f), new Vector3(size.x, size.y, 1f), material2, (PrimitiveType)5);
			Display = val.GetComponent<Renderer>();
			SceneArt.Label(Root, name, new Vector3(0f, size.y * 0.5f + 0.045f, -0.02f), new Vector2(size.x, 0.08f), 0.48f, new Color(0.65f, 0.76f, 0.76f));
			Material material3 = art.Material(new Color(0.08f, 0.1f, 0.11f));
			for (int i = -1; i <= 1; i += 2)
			{
				SceneArt.Part(Root, "Monitor fastener", new Vector3((float)i * (size.x * 0.5f + 0.035f), size.y * 0.5f + 0.04f, -0.025f), new Vector3(0.027f, 0.027f, 0.015f), material3, (PrimitiveType)3);
			}
		}

		public TextMeshPro Text(string value, Vector2 size, float fontSize, Color color)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return SceneArt.Label(Root, value, new Vector3(0f, 0f, -0.026f), size, fontSize, color);
		}
	}
	public sealed class DestructibleScenery : IDisposable
	{
		public sealed class Obstacle
		{
			public ulong Id;

			public Transform Root;

			public bool Metal;

			public Bounds Bounds;
		}

		private readonly ShipFlightController flight;

		private readonly Dictionary<ulong, Obstacle> objects = new Dictionary<ulong, Obstacle>();

		private readonly Dictionary<Collider, Obstacle> collisions = new Dictionary<Collider, Obstacle>();

		private readonly HashSet<ulong> destroyed = new HashSet<ulong>();

		private readonly List<(ulong id, Vector3 point, bool metal)> pending = new List<(ulong, Vector3, bool)>();

		private readonly SceneArt art = new SceneArt();

		private readonly Material wood;

		private readonly Material metal;

		public IEnumerable<Obstacle> Obstacles => objects.Values;

		public IEnumerable<ulong> Destroyed => destroyed;

		public int DestroyedCount => destroyed.Count;

		public DestructibleScenery(ShipFlightController flight)
		{
			//IL_005a: 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)
			this.flight = flight;
			wood = art.Material(new Color(0.25f, 0.15f, 0.07f));
			metal = art.Material(new Color(0.28f, 0.32f, 0.34f));
		}

		public void Rebuild()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			objects.Clear();
			collisions.Clear();
			destroyed.Clear();
			Scene sceneByName = SceneManager.GetSceneByName(flight.Round.currentLevel.sceneName);
			if (!((Scene)(ref sceneByName)).isLoaded)
			{
				return;
			}
			GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
			for (int i = 0; i < rootGameObjects.Length; i++)
			{
				Collider[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Collider>(true);
				foreach (Collider val in componentsInChildren)
				{
					if (val.isTrigger || val is TerrainCollider || (Object)(object)((Component)val).GetComponentInParent<GrabbableObject>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<EnemyAI>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<PlayerControllerB>() != (Object)null)
					{
						continue;
					}
					Transform val2 = null;
					bool flag = false;
					Bounds bounds = default(Bounds);
					Transform val3 = ((Component)val).transform;
					while ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.scene == sceneByName)
					{
						string text = ((Object)val3).name.ToLowerInvariant();
						bool flag2 = text.Contains("tree") || text.Contains("bush");
						bool flag3 = text.Contains("pole") || text.Contains("lamp") || text.Contains("streetlight");
						if (flag2 || flag3)
						{
							Renderer[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren<Renderer>(true);
							if (componentsInChildren2.Length != 0)
							{
								Bounds bounds2 = componentsInChildren2[0].bounds;
								Renderer[] array = componentsInChildren2;
								foreach (Renderer val4 in array)
								{
									((Bounds)(ref bounds2)).Encapsulate(val4.bounds);
								}
								if (!(((Bounds)(ref bounds2)).size.x > 38f) && !(((Bounds)(ref bounds2)).size.z > 38f) && !(((Bounds)(ref bounds2)).size.y > 80f))
								{
									Vector3 size = ((Bounds)(ref bounds2)).size;
									if (!(((Vector3)(ref size)).sqrMagnitude < 0.25f))
									{
										val2 = val3;
										flag = !flag2;
										bounds = bounds2;
									}
								}
							}
						}
						val3 = val3.parent;
					}
					if (!((Object)(object)val2 == (Object)null))
					{
						ulong num = Identifier(val2);
						if (!objects.TryGetValue(num, out var value))
						{
							value = new Obstacle
							{
								Id = num,
								Root = val2,
								Metal = flag,
								Bounds = bounds
							};
							objects.Add(num, value);
						}
						Collider[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren<Collider>(true);
						foreach (Collider key in componentsInChildren3)
						{
							collisions[key] = value;
						}
					}
				}
			}
			Plugin.Log.LogInfo((object)("Crushable scenery: " + objects.Count + " trees, bushes and light/utility poles."));
			(ulong id, Vector3 point, bool metal)[] array2 = pending.ToArray();
			pending.Clear();
			(ulong, Vector3, bool)[] array3 = array2;
			for (int i = 0; i < array3.Length; i++)
			{
				(ulong, Vector3, bool) tuple = array3[i];
				Apply(tuple.Item1, tuple.Item2, tuple.Item3);
			}
		}

		public bool IsBreakable(Collider collider)
		{
			if ((Object)(object)collider != (Object)null)
			{
				return collisions.ContainsKey(collider);
			}
			return false;
		}

		public bool Crush(Collider collider, Vector3 point)
		{
			//IL_003d: 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)
			if (!collisions.TryGetValue(collider, out var value))
			{
				return false;
			}
			if (destroyed.Contains(value.Id))
			{
				return true;
			}
			if (!flight.IsServer)
			{
				return true;
			}
			Apply(value.Id, point, value.Metal);
			flight.BroadcastDestruction(value.Id, point, value.Metal);
			return true;
		}

		public void Apply(ulong id, Vector3 point, bool isMetal)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if (destroyed.Contains(id))
			{
				return;
			}
			if (!objects.TryGetValue(id, out var value))
			{
				pending.Add((id, point, isMetal));
				return;
			}
			destroyed.Add(id);
			if (!((Object)(object)value.Root == (Object)null))
			{
				LODGroup[] componentsInChildren = ((Component)value.Root).GetComponentsInChildren<LODGroup>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				Renderer[] componentsInChildren2 = ((Component)value.Root).GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					componentsInChildren2[i].enabled = false;
				}
				Collider[] componentsInChildren3 = ((Component)value.Root).GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					componentsInChildren3[i].enabled = false;
				}
				Light[] componentsInChildren4 = ((Component)value.Root).GetComponentsInChildren<Light>(true);
				for (int i = 0; i < componentsInChildren4.Length; i++)
				{
					((Behaviour)componentsInChildren4[i]).enabled = false;
				}
				NavMeshObstacle[] componentsInChildren5 = ((Component)value.Root).GetComponentsInChildren<NavMeshObstacle>(true);
				for (int i = 0; i < componentsInChildren5.Length; i++)
				{
					((Behaviour)componentsInChildren5[i]).enabled = false;
				}
				Vector3 val = ((Bounds)(ref value.Bounds)).ClosestPoint(point);
				flight.Audio?.PlayImpact(val, isMetal);
				Random random = new Random((int)id);
				for (int j = 0; j < 9; j++)
				{
					float num = 0.12f + (float)random.NextDouble() * 0.28f;
					GameObject obj = SceneArt.Part(null, "Crushed scenery fragment", val + Random.insideUnitSphere * 0.4f, new Vector3(num, num * 0.4f, num * 2f), isMetal ? metal : wood, (PrimitiveType)3);
					obj.AddComponent<ImpactFragment>().Velocity = new Vector3((float)random.NextDouble() * 5f - 2.5f, 2f + (float)random.NextDouble() * 3f, (float)random.NextDouble() * 5f - 2.5f);
					Object.Destroy((Object)(object)obj, 1.6f);
				}
				Plugin.Log.LogInfo((object)("Scenery crushed: " + ((Object)value.Root).name + " [" + id + "]"));
			}
		}

		public bool TryGet(ulong id, out Obstacle obstacle)
		{
			return objects.TryGetValue(id, out obstacle);
		}

		private static ulong Identifier(Transform transform)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			Scene scene = ((Component)transform).gameObject.scene;
			string text = ((Scene)(ref scene)).name;
			Stack<string> stack = new Stack<string>();
			Transform val = transform;
			while ((Object)(object)val != (Object)null)
			{
				stack.Push(((Object)val).name);
				val = val.parent;
			}
			foreach (string item in stack)
			{
				text = text + "/" + item;
			}
			Vector3 position = transform.position;
			text = text + "@" + Mathf.RoundToInt(position.x * 20f) + "," + Mathf.RoundToInt(position.y * 20f) + "," + Mathf.RoundToInt(position.z * 20f);
			ulong num = 14695981039346656037uL;
			string text2 = text;
			foreach (char c in text2)
			{
				num ^= c;
				num *= 1099511628211L;
			}
			return num;
		}

		public void Dispose()
		{
			art.Dispose();
			objects.Clear();
			collisions.Clear();
			destroyed.Clear();
			pending.Clear();
		}
	}
	internal sealed class ImpactFragment : MonoBehaviour
	{
		public Vector3 Velocity;

		private void Update()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			Velocity += Vector3.down * 13f * Time.deltaTime;
			Transform transform = ((Component)this).transform;
			transform.position += Velocity * Time.deltaTime;
			((Component)this).transform.Rotate(190f * Time.deltaTime, 140f * Time.deltaTime, 85f * Time.deltaTime);
		}
	}
	public sealed class EvaController
	{
		private readonly ShipFlightController flight;

		private Vector3 velocity;

		private bool wasFloating;

		private Vector3 overrideInput;

		private float overrideUntil;

		public bool Floating { get; private set; }

		public Vector3 Velocity => velocity;

		public EvaController(ShipFlightController flight)
		{
			this.flight = flight;
		}

		public bool IsFloating(PlayerControllerB player)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (flight.Ready && flight.IsSpace && (Object)(object)player != (Object)null && !player.isPlayerDead && player.isPlayerControlled && (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController && !flight.IsLocalPilot && !player.isClimbingLadder && !player.inSpecialInteractAnimation)
			{
				Bounds bounds = flight.Round.shipInnerRoomBounds.bounds;
				return !((Bounds)(ref bounds)).Contains(((Component)player).transform.position + Vector3.up * 0.8f);
			}
			return false;
		}

		public void SupplyTestInput(Vector3 input)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			overrideInput = input;
			overrideUntil = Time.unscaledTime + 0.1f;
		}

		public void BeforePlayerUpdate(PlayerControllerB player)
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)player != (Object)(object)GameNetworkManager.Instance?.localPlayerController)
			{
				return;
			}
			Bounds bounds;
			if (!flight.IsLocalPilot && player.isPlayerControlled && !player.isPlayerDead && player.isInElevator)
			{
				bounds = flight.Round.shipBounds.bounds;
				if (!((Bounds)(ref bounds)).Contains(((Component)player).transform.position + Vector3.up * 0.25f))
				{
					player.isInElevator = false;
					player.isInHangarShipRoom = false;
					player.SetAllItemsInElevator(false, false);
				}
			}
			Floating = IsFloating(player);
			if (!Floating)
			{
				if (wasFloating)
				{
					player.ResetFallGravity();
					velocity = Vector3.zero;
				}
				if (flight.IsSpace)
				{
					bounds = flight.Round.shipInnerRoomBounds.bounds;
					if (((Bounds)(ref bounds)).Contains(((Component)player).transform.position + Vector3.up * 0.8f))
					{
						player.isInElevator = true;
						player.isInHangarShipRoom = true;
					}
				}
				wasFloating = false;
			}
			else
			{
				if (!wasFloating)
				{
					velocity = flight.Snapshot.Velocity;
					HUDManager.Instance.DisplayTip("Zero gravity", "WASD suit thrusters | Space/Ctrl vertical | Shift boost | X brake\nEnter the cabin to restore artificial gravity.", false, false, "LC_Tip1");
				}
				wasFloating = true;
				ResetGravity(player);
				player.isInElevator = false;
				player.isInHangarShipRoom = false;
			}
		}

		public CollisionFlags Move(CharacterController controller, Vector3 normalMotion)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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)
			PlayerControllerB component = ((Component)controller).GetComponent<PlayerControllerB>();
			if (!IsFloating(component))
			{
				return controller.Move(normalMotion);
			}
			Keyboard current = Keyboard.current;
			Vector3 zero = Vector3.zero;
			bool flag = false;
			bool flag2 = false;
			if (Time.unscaledTime < overrideUntil)
			{
				zero = overrideInput;
			}
			else if (current != null && Application.isFocused && !component.quickMenuManager.isMenuOpen && !component.isTypingChat)
			{
				((Vector3)(ref zero))..ctor((float)((((ButtonControl)current.dKey).isPressed ? 1 : 0) - (((ButtonControl)current.aKey).isPressed ? 1 : 0)), (float)((((ButtonControl)current.spaceKey).isPressed ? 1 : 0) - (((ButtonControl)current.leftCtrlKey).isPressed ? 1 : 0)), (float)((((ButtonControl)current.wKey).isPressed ? 1 : 0) - (((ButtonControl)current.sKey).isPressed ? 1 : 0)));
				flag = ((ButtonControl)current.xKey).isPressed;
				flag2 = ((ButtonControl)current.leftShiftKey).isPressed;
			}
			Transform transform = ((Component)component.gameplayCamera).transform;
			Vector3 val = Vector3.ClampMagnitude(transform.right * zero.x + transform.forward * zero.z + Vector3.up * zero.y, 1f) * (float)(flag2 ? 18 : 7);
			if (((Vector3)(ref zero)).sqrMagnitude > 0f || flag)
			{
				velocity = Vector3.MoveTowards(velocity, flag ? Vector3.zero : val, (float)(flag ? 22 : 12) * Time.deltaTime);
			}
			velocity = Vector3.ClampMagnitude(velocity, 350f);
			CollisionFlags val2 = controller.Move(velocity * Mathf.Min(Time.deltaTime, 0.05f));
			if ((int)val2 != 0)
			{
				velocity *= 0.5f;
			}
			return val2;
		}

		public static void ResetGravity(PlayerControllerB p)
		{
			p.fallValue = 0f;
			p.fallValueUncapped = 0f;
			p.takingFallDamage = false;
			p.isFallingFromJump = false;
			p.isFallingNoJump = false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal static class EvaMovementPatch
	{
		private static void Prefix(PlayerControllerB __instance)
		{
			ShipFlightController.Instance?.Eva?.BeforePlayerUpdate(__instance);
		}

		private static void Postfix(PlayerControllerB __instance)
		{
			ShipFlightController instance = ShipFlightController.Instance;
			if (instance != null && instance.Eva?.IsFloating(__instance) == true)
			{
				EvaController.ResetGravity(__instance);
			}
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo original = AccessTools.Method(typeof(CharacterController), "Move", (Type[])null, (Type[])null);
			MethodInfo replacement = AccessTools.Method(typeof(EvaMovementPatch), "Move", (Type[])null, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, original))
				{
					instruction.opcode = OpCodes.Call;
					instruction.operand = replacement;
				}
				yield return instruction;
			}
		}

		private static CollisionFlags Move(CharacterController controller, Vector3 motion)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return (ShipFlightController.Instance?.Eva)?.Move(controller, motion) ?? controller.Move(motion);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
	internal static class EvaJumpPatch
	{
		private static bool Prefix(PlayerControllerB __instance)
		{
			ShipFlightController instance = ShipFlightController.Instance;
			if (instance == null)
			{
				return true;
			}
			return instance.Eva?.IsFloating(__instance) != true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Crouch_performed")]
	internal static class EvaCrouchPatch
	{
		private static bool Prefix(PlayerControllerB __instance)
		{
			ShipFlightController instance = ShipFlightController.Instance;
			if (instance == null)
			{
				return true;
			}
			return instance.Eva?.IsFloating(__instance) != true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "TeleportPlayerInShipIfOutOfRoomBounds")]
	internal static class EvaOrbitBoundaryPatch
	{
		private static bool Prefix()
		{
			ShipFlightController instance = ShipFlightController.Instance;
			if (instance == null)
			{
				return true;
			}
			return !instance.Ready;
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ForcePlayerIntoShip")]
	internal static class EvaForcedBoardingPatch
	{
		private static bool Prefix()
		{
			ShipFlightController instance = ShipFlightController.Instance;
			if (instance == null)
			{
				return true;
			}
			return !instance.Ready;
		}
	}
	public sealed class FlightAudio : IDisposable
	{
		private readonly ShipFlightController flight;

		private readonly AudioClip woodClip;

		private readonly AudioClip metalClip;

		private readonly AudioSource engine;

		private readonly float originalVolume;

		private readonly float originalPitch;

		private readonly bool originalLoop;

		private float volume;

		private float pitch;

		public AudioSource Engine => engine;

		public int ImpactCount { get; private set; }

		public FlightAudio(ShipFlightController flight)
		{
			this.flight = flight;
			woodClip = Impact(metal: false);
			metalClip = Impact(metal: true);
			engine = flight.Round.shipMotorAudio;
			if ((Object)(object)engine != (Object)null)
			{
				originalVolume = engine.volume;
				originalPitch = engine.pitch;
				originalLoop = engine.loop;
				volume = engine.volume;
				pitch = engine.pitch;
				engine.loop = true;
				Plugin.Log.LogInfo((object)("Using vanilla ship motor audio: " + (((Object)(object)engine.clip != (Object)null) ? ((Object)engine.clip).name : "no clip assigned")));
			}
		}

		private static void Configure(AudioSource audio, float distance)
		{
			audio.playOnAwake = false;
			audio.spatialBlend = 0.9f;
			audio.spatialize = false;
			audio.dopplerLevel = 0f;
			audio.minDistance = 9f;
			audio.maxDistance = distance;
			audio.rolloffMode = (AudioRolloffMode)1;
		}

		public void Update()
		{
			if (!((Object)(object)engine == (Object)null) && !((Object)(object)engine.clip == (Object)null))
			{
				FlightSnapshot snapshot = flight.Snapshot;
				bool flag = snapshot.Phase != FlightPhase.Landed;
				float num = Mathf.Clamp01(((Vector3)(ref snapshot.Velocity)).magnitude / ((snapshot.Phase == FlightPhase.Orbit) ? 220f : 14f));
				if (snapshot.Phase == FlightPhase.Landing || snapshot.Phase == FlightPhase.EnteringAtmosphere || snapshot.Phase == FlightPhase.LeavingMoon)
				{
					num = Mathf.Max(num, 0.6f);
				}
				volume = Mathf.MoveTowards(volume, flag ? (0.15f + num * 0.4f) : 0.025f, Time.deltaTime * 0.6f);
				pitch = Mathf.MoveTowards(pitch, 0.87f + num * 0.4f, Time.deltaTime * 0.65f);
				engine.volume = volume;
				engine.pitch = pitch;
				if (!engine.isPlaying)
				{
					engine.Play();
				}
			}
		}

		public void PlayImpact(Vector3 position, bool metal)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			ImpactCount++;
			GameObject val = new GameObject(metal ? "Metal pole impact" : "Tree impact");
			val.transform.position = position;
			AudioSource obj = val.AddComponent<AudioSource>();
			Configure(obj, 100f);
			obj.outputAudioMixerGroup = (((Object)(object)engine != (Object)null) ? engine.outputAudioMixerGroup : null);
			obj.volume = 0.85f;
			obj.clip = (metal ? metalClip : woodClip);
			obj.Play();
			Object.Destroy((Object)val, 3f);
		}

		private static AudioClip Impact(bool metal)
		{
			float[] array = new float[44100];
			Random random = new Random(metal ? 819 : 444);
			float num = 0f;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = (float)i / 22050f;
				float num3 = (float)random.NextDouble() * 2f - 1f;
				num = num * 0.84f + num3 * 0.16f;
				float num4 = num3 * Mathf.Exp((0f - num2) * 22f) * 0.55f;
				float num5 = num * Mathf.Exp((0f - num2) * 5f) * 1.8f;
				float num6 = (metal ? ((0.17f * Mathf.Sin(num2 * 2f * MathF.PI * 310f) + 0.13f * Mathf.Sin(num2 * 2f * MathF.PI * 487f)) * Mathf.Exp((0f - num2) * 3f)) : (num3 * 0.18f * Mathf.Exp((0f - Mathf.Abs(num2 - 0.18f)) * 30f)));
				array[i] = Mathf.Clamp(num4 + num5 + num6, -1f, 1f);
			}
			AudioClip obj = AudioClip.Create(metal ? "Metal crushing impact" : "Wood snapping impact", array.Length, 1, 22050, false);
			obj.SetData(array, 0);
			return obj;
		}

		public void Dispose()
		{
			if ((Object)(object)engine != (Object)null)
			{
				engine.volume = originalVolume;
				engine.pitch = originalPitch;
				engine.loop = originalLoop;
			}
			Object.Destroy((Object)(object)woodClip);
			Object.Destroy((Object)(object)metalClip);
		}
	}
	public sealed class FlightCockpit : IDisposable
	{
		private readonly ShipFlightController flight;

		private readonly SceneArt art = new SceneArt();

		private readonly GameObject root;

		private readonly Camera camera;

		private readonly HDAdditionalCameraData cameraData;

		private readonly int originalMask;

		private readonly float originalFar;

		private readonly LayerMask originalVolumes;

		private readonly ClearColorMode originalClear;

		private readonly Color originalBackground;

		private readonly InteractTrigger trigger;

		private readonly HullWindow window;

		private readonly Volume spaceVolume;

		private Vector2 freeLook;

		private Vector3 walkingCameraPosition;

		private Quaternion walkingCameraRotation;

		private bool seatedView;

		private readonly Dictionary<Renderer, bool> hiddenPilotRenderers = new Dictionary<Renderer, bool>();

		private readonly CockpitCameras exteriorCameras;

		private AutoParentToShip terminalParent;

		private Vector3 originalTerminalOffset;

		private readonly List<(Transform node, Transform parent, Vector3 position, Quaternion rotation, Vector3 scale)> movedMonitors = new List<(Transform, Transform, Vector3, Quaternion, Vector3)>();

		public Transform Seat { get; }

		public Transform Exit { get; }

		public Transform Instruments => root.transform;

		public Camera ViewCamera => camera;

		public int WindowMeshCount => window.CutMeshes;

		public CockpitCameras ExteriorCameras => exteriorCameras;

		public Vector3 PilotEyePosition => Seat.position + Seat.up * 2.48f - Seat.forward * 0.12f;

		public bool FreeLooking
		{
			get
			{
				if (Mouse.current != null)
				{
					return Mouse.current.rightButton.isPressed;
				}
				return false;
			}
		}

		public FlightCockpit(ShipFlightController flight)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: 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_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: 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_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Expected O, but got Unknown
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Expected O, but got Unknown
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Expected O, but got Unknown
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Expected O, but got Unknown
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Expected O, but got Unknown
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Expected O, but got Unknown
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067c: Expected O, but got Unknown
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Expected O, but got Unknown
			//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0717: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			this.flight = flight;
			Transform elevatorTransform = flight.Round.elevatorTransform;
			MoveStockMonitors(elevatorTransform);
			window = new HullWindow(elevatorTransform);
			root = new GameObject("LethalOrbit pilot station");
			root.transform.SetParent(elevatorTransform, false);
			root.transform.localPosition = new Vector3(8.05f, 0f, -6.7f);
			root.transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
			Material material = art.Material(new Color(0.08f, 0.1f, 0.12f));
			Material material2 = art.Material(new Color(0.31f, 0.36f, 0.38f));
			Material material3 = art.Material(new Color(0.055f, 0.07f, 0.085f), unlit: true);
			Material material4 = art.Material(new Color(0.05f, 0.52f, 0.62f), unlit: true);
			SceneArt.Label(root.transform, "PILOT\n[E]", new Vector3(0f, 1.13f, -0.465f), new Vector2(0.65f, 0.4f), 0.6f, new Color(0.45f, 0.88f, 0.9f));
			SceneArt.Part(root.transform, "Seat pedestal", new Vector3(0f, 0.44f, 0f), new Vector3(0.48f, 0.88f, 0.48f), material, (PrimitiveType)3);
			SceneArt.Part(root.transform, "Pilot cushion", new Vector3(0f, 0.99f, 0f), new Vector3(0.8f, 0.16f, 0.72f), material3, (PrimitiveType)3);
			SceneArt.Part(root.transform, "Pilot seat back", new Vector3(0f, 1.48f, -0.37f), new Vector3(0.8f, 0.94f, 0.16f), material3, (PrimitiveType)3);
			SceneArt.Part(root.transform, "Pilot headrest", new Vector3(0f, 2.06f, -0.35f), new Vector3(0.46f, 0.3f, 0.17f), material3, (PrimitiveType)3);
			for (int i = -1; i <= 1; i += 2)
			{
				SceneArt.Part(root.transform, "Armrest", new Vector3((float)i * 0.47f, 1.21f, 0.05f), new Vector3(0.15f, 0.12f, 0.7f), material, (PrimitiveType)3);
				SceneArt.Part(root.transform, "Thruster grip", new Vector3((float)i * 0.47f, 1.38f, 0.23f), new Vector3(0.07f, 0.23f, 0.07f), material2, (PrimitiveType)2);
				SceneArt.Part(root.transform, "Status strip", new Vector3((float)i * 0.49f, 1.29f, 0.11f), new Vector3(0.025f, 0.02f, 0.5f), material4, (PrimitiveType)3);
			}
			SceneArt.Part(root.transform, "Flight console", new Vector3(0f, 1.05f, 2.2f), new Vector3(3.12f, 0.18f, 0.72f), material, (PrimitiveType)3);
			for (int j = -1; j <= 1; j += 2)
			{
				SceneArt.Part(root.transform, "Console support", new Vector3((float)j * 1.27f, 0.52f, 2.44f), new Vector3(0.16f, 1.05f, 0.22f), material2, (PrimitiveType)3);
				SceneArt.Part(root.transform, "Camera rack support", new Vector3((float)j * 1.73f, 1.9f, 2.57f), new Vector3(0.12f, 1.86f, 0.15f), material2, (PrimitiveType)3);
			}
			WindshieldFrame.Build(art, elevatorTransform);
			Seat = new GameObject("Pilot anchor").transform;
			Seat.SetParent(root.transform, false);
			Seat.localPosition = new Vector3(0f, 0.04f, 0f);
			Exit = new GameObject("Pilot exit").transform;
			Exit.SetParent(root.transform, false);
			Exit.localPosition = new Vector3(-0.75f, 0.06f, -1.1f);
			GameObject val = new GameObject("Pilot seat interaction");
			val.transform.SetParent(root.transform, false);
			val.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			val.layer = 9;
			val.tag = "InteractTrigger";
			BoxCollider obj = val.AddComponent<BoxCollider>();
			obj.size = new Vector3(1.05f, 1.35f, 1.05f);
			((Collider)obj).isTrigger = true;
			trigger = val.AddComponent<InteractTrigger>();
			trigger.hoverIcon = Object.FindObjectOfType<StartMatchLever>().triggerScript.hoverIcon;
			trigger.hoverTip = "Pilot ship : [E]";
			trigger.disabledHoverTip = "Pilot seat occupied";
			trigger.interactable = true;
			trigger.holdInteraction = false;
			trigger.cooldownTime = 0.5f;
			trigger.disableTriggerMesh = false;
			trigger.onInteract = new InteractEvent();
			trigger.onInteractEarly = new InteractEvent();
			trigger.onInteractEarlyOtherClients = new InteractEvent();
			trigger.onStopInteract = new InteractEvent();
			trigger.onCancelAnimation = new InteractEvent();
			trigger.holdingInteractEvent = new InteractEventFloat();
			((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB p)
			{
				if ((Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					flight.Request(FlightCommand.ClaimSeat);
				}
			});
			camera = GameNetworkManager.Instance.localPlayerController.gameplayCamera;
			originalMask = camera.cullingMask;
			originalFar = camera.farClipPlane;
			cameraData = ((Component)camera).GetComponent<HDAdditionalCameraData>();
			if ((Object)(object)cameraData != (Object)null)
			{
				originalVolumes = cameraData.volumeLayerMask;
				originalClear = cameraData.clearColorMode;
				originalBackground = cameraData.backgroundColorHDR;
			}
			GameObject val2 = art.Own<GameObject>(new GameObject("Orbital atmosphere settings"));
			spaceVolume = val2.AddComponent<Volume>();
			spaceVolume.isGlobal = true;
			spaceVolume.priority = 10000f;
			VolumeProfile val3 = art.Own<VolumeProfile>(ScriptableObject.CreateInstance<VolumeProfile>());
			spaceVolume.sharedProfile = val3;
			((VolumeParameter<bool>)(object)val3.Add<Fog>(false).enabled).Override(false);
			((VolumeParameter<int>)(object)val3.Add<VisualEnvironment>(false).skyType).Override(0);
			exteriorCameras = new CockpitCameras(flight, root.transform, camera);
		}

		private void MoveStockMonitors(Transform ship)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0177: Expected O, but got Unknown
			//IL_019a: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			terminalParent = Object.FindObjectOfType<Terminal>()?.placeableObject?.parentObject;
			if ((Object)(object)terminalParent != (Object)null)
			{
				originalTerminalOffset = terminalParent.positionOffset;
				terminalParent.positionOffset = new Vector3(2.9f, originalTerminalOffset.y, -9.14f);
				terminalParent.MoveToOffset();
			}
			Transform val = ship.Find("ShipModels2b/MonitorWall/Cube.001");
			Transform val2 = ship.Find("ShipModels2b/MonitorWall/Cube");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform transform = art.Own<GameObject>(new GameObject("Relocated native ship monitors")).transform;
			transform.SetParent(ship, false);
			transform.position = val.position;
			Transform[] array = (Transform[])(object)new Transform[2] { val, val2 };
			foreach (Transform val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					movedMonitors.Add((val3, val3.parent, val3.localPosition, val3.localRotation, val3.localScale));
					val3.SetParent(transform, true);
				}
			}
			transform.localPosition = new Vector3(7.2f, 1.9f, -9.15f);
			transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
			Transform transform2 = art.Own<GameObject>(new GameObject("Native monitor wall panel")).transform;
			transform2.SetParent(ship, false);
			Material material = art.Material(new Color(0.18f, 0.22f, 0.23f));
			Material material2 = art.Material(new Color(0.34f, 0.37f, 0.36f));
			SceneArt.Part(transform2, "Monitor mounting backplate", new Vector3(7.2f, 2.47f, -10.03f), new Vector3(4.15f, 3.88f, 0.16f), material, (PrimitiveType)3, collision: true);
			for (int j = -1; j <= 1; j += 2)
			{
				SceneArt.Part(transform2, "Monitor rack upright", new Vector3(7.2f + (float)j * 2.08f, 2.3f, -9.76f), new Vector3(0.12f, 4.4f, 0.18f), material2, (PrimitiveType)3);
			}
			SceneArt.Part(transform2, "Monitor rack sill", new Vector3(7.2f, 0.47f, -9.55f), new Vector3(4.25f, 0.16f, 0.58f), material2, (PrimitiveType)3);
		}

		public void SetPiloting(bool piloting)
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			freeLook = Vector2.zero;
			((Behaviour)camera).enabled = true;
			if (piloting && !seatedView)
			{
				walkingCameraPosition = ((Component)camera).transform.localPosition;
				walkingCameraRotation = ((Component)camera).transform.localRotation;
				seatedView = true;
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if ((Object)(object)localPlayerController.localVisor != (Object)null)
				{
					Renderer[] componentsInChildren = ((Component)localPlayerController.localVisor).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer renderer in componentsInChildren)
					{
						Hide(renderer);
					}
				}
				Hide((Renderer)(object)localPlayerController.thisPlayerModel);
				Hide((Renderer)(object)localPlayerController.thisPlayerModelLOD1);
				Hide((Renderer)(object)localPlayerController.thisPlayerModelLOD2);
				Hide((Renderer)(object)localPlayerController.thisPlayerModelArms);
				HUDManager.Instance.DisplayTip("Pilot controls", "WASD thrust | Space / Ctrl vertical\nHold RMB to look around | E stand up", false, false, "LC_Tip1");
			}
			else if (!piloting)
			{
				RestoreWalkingView();
			}
		}

		private void Hide(Renderer renderer)
		{
			if (!((Object)(object)renderer == (Object)null) && !hiddenPilotRenderers.ContainsKey(renderer))
			{
				hiddenPilotRenderers.Add(renderer, renderer.forceRenderingOff);
				renderer.forceRenderingOff = true;
			}
		}

		private void RestoreWalkingView()
		{
			//IL_0022: 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)
			if (seatedView && (Object)(object)camera != (Object)null)
			{
				((Component)camera).transform.localPosition = walkingCameraPosition;
				((Component)camera).transform.localRotation = walkingCameraRotation;
			}
			foreach (KeyValuePair<Renderer, bool> hiddenPilotRenderer in hiddenPilotRenderers)
			{
				if ((Object)(object)hiddenPilotRenderer.Key != (Object)null)
				{
					hiddenPilotRenderer.Key.forceRenderingOff = hiddenPilotRenderer.Value;
				}
			}
			hiddenPilotRenderers.Clear();
			seatedView = false;
		}

		public void UpdateView()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			bool isSpace = flight.IsSpace;
			camera.cullingMask = originalMask | int.MinValue;
			camera.farClipPlane = (isSpace ? 6500f : originalFar);
			if ((Object)(object)cameraData != (Object)null)
			{
				cameraData.volumeLayerMask = originalVolumes;
				cameraData.clearColorMode = (ClearColorMode)(isSpace ? 1 : ((int)originalClear));
				cameraData.backgroundColorHDR = (Color)(isSpace ? new Color(0.001f, 0.002f, 0.006f) : originalBackground);
			}
			spaceVolume.weight = (isSpace ? 1 : 0);
			trigger.interactable = flight.Snapshot.Pilot == ulong.MaxValue;
		}

		public void UpdateSeatedCamera()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			exteriorCameras.Update();
			if (!flight.IsLocalPilot)
			{
				return;
			}
			if (FreeLooking && Application.isFocused)
			{
				Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue();
				freeLook.x = Mathf.Clamp(freeLook.x + val.x * 0.12f, -120f, 120f);
				freeLook.y = Mathf.Clamp(freeLook.y - val.y * 0.12f, -65f, 65f);
			}
			else
			{
				freeLook = Vector2.Lerp(freeLook, Vector2.zero, Time.deltaTime * 7f);
			}
			((Component)camera).transform.SetPositionAndRotation(PilotEyePosition, Seat.rotation * Quaternion.Euler(freeLook.y, freeLook.x, 0f));
			foreach (KeyValuePair<Renderer, bool> hiddenPilotRenderer in hiddenPilotRenderers)
			{
				if ((Object)(object)hiddenPilotRenderer.Key != (Object)null)
				{
					hiddenPilotRenderer.Key.forceRenderingOff = true;
				}
			}
		}

		public void PosePilot(PlayerControllerB player)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			Animator playerBodyAnimator = player.playerBodyAnimator;
			if (!((Object)(object)playerBodyAnimator == (Object)null) && playerBodyAnimator.isHuman)
			{
				Transform boneTransform = playerBodyAnimator.GetBoneTransform((HumanBodyBones)0);
				if (!((Object)(object)boneTransform == (Object)null))
				{
					boneTransform.position = Seat.position + Seat.up * 1.15f;
					Bend(playerBodyAnimator, (HumanBodyBones)1, (HumanBodyBones)3, Seat.forward);
					Bend(playerBodyAnimator, (HumanBodyBones)2, (HumanBodyBones)4, Seat.forward);
					Bend(playerBodyAnimator, (HumanBodyBones)3, (HumanBodyBones)5, -Seat.up);
					Bend(playerBodyAnimator, (HumanBodyBones)4, (HumanBodyBones)6, -Seat.up);
				}
			}
		}

		private static void Bend(Animator a, HumanBodyBones first, HumanBodyBones second, Vector3 direction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Transform boneTransform = a.GetBoneTransform(first);
			Transform boneTransform2 = a.GetBoneTransform(second);
			if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null)
			{
				boneTransform.rotation = Quaternion.FromToRotation(boneTransform2.position - boneTransform.position, direction) * boneTransform.rotation;
			}
		}

		public void Dispose()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			RestoreWalkingView();
			exteriorCameras.Dispose();
			if ((Object)(object)camera != (Object)null)
			{
				((Behaviour)camera).enabled = true;
				camera.cullingMask = originalMask;
				camera.farClipPlane = originalFar;
			}
			if ((Object)(object)cameraData != (Object)null)
			{
				cameraData.volumeLayerMask = originalVolumes;
				cameraData.clearColorMode = originalClear;
				cameraData.backgroundColorHDR = originalBackground;
			}
			window.Dispose();
			if ((Object)(object)terminalParent != (Object)null)
			{
				terminalParent.positionOffset = originalTerminalOffset;
				terminalParent.MoveToOffset();
			}
			foreach (var movedMonitor in movedMonitors)
			{
				if ((Object)(object)movedMonitor.node != (Object)null && (Object)(object)movedMonitor.parent != (Object)null)
				{
					movedMonitor.node.SetParent(movedMonitor.parent, false);
					movedMonitor.node.localPosition = movedMonitor.position;
					movedMonitor.node.localRotation = movedMonitor.rotation;
					movedMonitor.node.localScale = movedMonitor.scale;
				}
			}
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)root);
			}
			art.Dispose();
		}
	}
	public sealed class FlightHud : IDisposable
	{
		private readonly ShipFlightController flight;

		private readonly GameObject root;

		private readonly SceneArt art = new SceneArt();

		private readonly TextMeshPro motion;

		private readonly TextMeshPro target;

		private readonly TextMeshPro status;

		private float updateAt;

		private static readonly string[] Phases = new string[6] { "ORBITAL FLIGHT", "ATMOSPHERIC ENTRY", "SURFACE FLIGHT", "SURFACE FLIGHT", "SURFACE FLIGHT", "LEAVING ATMOSPHERE" };

		public FlightHud(ShipFlightController flight, Transform cockpit)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0076: 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_00a3: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			this.flight = flight;
			root = new GameObject("Physical flight instruments");
			root.transform.SetParent(cockpit, false);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.45f, 0.9f, 0.94f);
			motion = new CockpitScreen(art, root.transform, "FLIGHT", new Vector3(-0.65f, 1.47f, 2.2f), new Vector2(1.14f, 0.52f)).Text("ORBITAL FLIGHT", new Vector2(1.1f, 0.48f), 0.82f, color);
			target = new CockpitScreen(art, root.transform, "NAVIGATION", new Vector3(0.65f, 1.47f, 2.2f), new Vector2(1.14f, 0.52f)).Text("TARGET", new Vector2(1.1f, 0.48f), 0.67f, color);
			status = new CockpitScreen(art, root.transform, "FLIGHT ASSIST", new Vector3(0f, 1.99f, 2.28f), new Vector2(2.25f, 0.18f)).Text("", new Vector2(2.2f, 0.17f), 0.57f, new Color(1f, 0.73f, 0.28f));
			SceneArt.Label(root.transform, "WASD THRUST   SPACE / CTRL VERTICAL\nO AIRLOCK   TAB TARGET   E STAND", new Vector3(0f, 1.1f, 1.825f), new Vector2(2.3f, 0.13f), 0.47f, color);
		}

		public void Update()
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime < updateAt))
			{
				updateAt = Time.unscaledTime + 0.1f;
				FlightSnapshot snapshot = flight.Snapshot;
				bool isSpace = flight.IsSpace;
				float num = (isSpace ? 0f : flight.Altitude);
				((TMP_Text)motion).text = Phases[(uint)snapshot.Phase] + "\n" + Mathf.RoundToInt(((Vector3)(ref snapshot.Velocity)).magnitude) + " m/s\n" + (isSpace ? "CABIN GRAVITY" : ((num < 0f) ? "NO GROUND BELOW" : ("ALT " + Mathf.RoundToInt(num) + " m")));
				OrbitalWorld.Moon moon = flight.SpaceWorld.Moons[snapshot.TargetLevel];
				Vector3 val = moon.Position - snapshot.SpacePosition;
				int num2 = Mathf.RoundToInt(Mathf.Repeat(Mathf.Atan2(val.x, val.z) * 57.29578f, 360f));
				((TMP_Text)target).text = (isSpace ? ("TARGET: " + moon.Name + "\n" + Mathf.RoundToInt(Mathf.Max(0f, ((Vector3)(ref val)).magnitude - moon.Radius)) + " m  |  BRG " + num2.ToString("000") + "°") : ("LOCATION\n" + flight.Round.currentLevel.PlanetName)) + "\nAIRLOCK: " + (snapshot.DoorOpen ? "OPEN" : "CLOSED");
				((TMP_Text)status).text = ((snapshot.Notice != FlightNotice.Ready) ? Notice(snapshot.Notice) : (isSpace ? "MANUAL FLIGHT" : "HOVER HOLD  |  CLIMB TO LEAVE MOON"));
			}
		}

		internal static string Notice(FlightNotice n)
		{
			return n switch
			{
				FlightNotice.PilotOccupied => "PILOT SEAT OCCUPIED", 
				FlightNotice.CrewNeedsMod => "ALL CREW MEMBERS NEED LETHAL ORBIT 0.3", 
				FlightNotice.TooFarFromSeat => "MOVE CLOSER TO THE PILOT SEAT", 
				FlightNotice.Obstacle => "SOLID OBSTACLE — CHANGE COURSE", 
				FlightNotice.GroundTooSteep => "UNEVEN GROUND — FIND A FLAT AREA", 
				FlightNotice.NoGround => "NO LANDING SURFACE", 
				FlightNotice.NotEnoughSpace => "NOT ENOUGH ROOM FOR THE SHIP", 
				FlightNotice.LoadingMoon => "ATMOSPHERIC ENTRY — LOADING MOON", 
				FlightNotice.LeavingMoon => "LEAVING ATMOSPHERE", 
				FlightNotice.Landing => "LANDING GEAR DOWN — DESCENDING", 
				FlightNotice.TooLowForOrbit => "CLIMB 100 m ABOVE THE ARRIVAL POINT", 
				FlightNotice.WaitForCrew => "WAITING FOR CREW / LOADING", 
				FlightNotice.PilotLost => "PILOT UNAVAILABLE — SHIP STABILIZED", 
				FlightNotice.Boundary => "FLIGHT AREA LIMIT", 
				_ => "", 
			};
		}

		public void Dispose()
		{
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)root);
			}
			art.Dispose();
		}
	}
	public enum FlightPhase : byte
	{
		Orbit,
		EnteringAtmosphere,
		SurfaceFlight,
		Landing,
		Landed,
		LeavingMoon
	}
	public enum FlightCommand : byte
	{
		ClaimSeat,
		LeaveSeat,
		Land,
		TakeOff,
		ReturnToOrbit,
		NextTarget,
		PreviousTarget,
		Brake,
		OpenDoor,
		CloseDoor
	}
	public enum FlightNotice : byte
	{
		Ready,
		PilotOccupied,
		CrewNeedsMod,
		Obstacle,
		GroundTooSteep,
		NoGround,
		NotEnoughSpace,
		Landing,
		LoadingMoon,
		LeavingMoon,
		TooFarFromSeat,
		TooLowForOrbit,
		WaitForCrew,
		PilotLost,
		Boundary
	}
	public struct PilotInput
	{
		public float Forward;

		public float Strafe;

		public float Lift;

		public float Yaw;

		public float Pitch;

		public bool Boost;

		public bool Brake;

		public bool IsFinite
		{
			get
			{
				if (Finite(Forward) && Finite(Strafe) && Finite(Lift) && Finite(Yaw))
				{
					return Finite(Pitch);
				}
				return false;
			}
		}

		private static bool Finite(float v)
		{
			if (!float.IsNaN(v))
			{
				return !float.IsInfinity(v);
			}
			return false;
		}

		public void Clamp()
		{
			Forward = Mathf.Clamp(Forward, -1f, 1f);
			Strafe = Mathf.Clamp(Strafe, -1f, 1f);
			Lift = Mathf.Clamp(Lift, -1f, 1f);
			Yaw = Mathf.Clamp(Yaw, -1f, 1f);
			Pitch = Mathf.Clamp(Pitch, -1f, 1f);
		}
	}
	public struct FlightSnapshot
	{
		public FlightPhase Phase;

		public ulong Pilot;

		public Vector3 SpacePosition;

		public Vector3 ShipPosition;

		public Vector3 Velocity;

		public Vector3 SurfaceOrigin;

		public float Yaw;

		public float Pitch;

		public float ShipYaw;

		public int TargetLevel;

		public FlightNotice Notice;

		public bool SurfaceReady;

		public bool DoorOpen;
	}
	public sealed class FlightSettings
	{
		public readonly ConfigEntry<float> OrbitSpeed;

		public readonly ConfigEntry<float> BoostSpeed;

		public readonly ConfigEntry<float> SurfaceSpeed;

		public readonly ConfigEntry<float> VerticalSpeed;

		public readonly ConfigEntry<float> TurnSpeed;

		public readonly ConfigEntry<float> Sensitivity;

		public readonly ConfigEntry<float> SurfaceCeiling;

		public readonly ConfigEntry<float> SurfaceRadius;

		public readonly ConfigEntry<float> ArrivalAltitude;

		public FlightSettings(ConfigFile config)
		{
			OrbitSpeed = Float(config, "Flight", "OrbitSpeed", 110f, 20f, 500f, "Orbital flight speed.");
			BoostSpeed = Float(config, "Flight", "OrbitBoostSpeed", 320f, 50f, 900f, "Orbital flight speed while holding Shift.");
			SurfaceSpeed = Float(config, "Flight", "SurfaceSpeed", 14f, 2f, 30f, "Horizontal flight speed on a moon.");
			VerticalSpeed = Float(config, "Flight", "VerticalSpeed", 9f, 1f, 20f, "Vertical flight speed on a moon.");
			TurnSpeed = Float(config, "Controls", "TurnSpeed", 65f, 15f, 120f, "Maximum turning speed in degrees per second.");
			Sensitivity = Float(config, "Controls", "MouseSensitivity", 0.025f, 0.001f, 0.15f, "Mouse steering sensitivity.");
			SurfaceCeiling = Float(config, "World", "SurfaceCeiling", 220f, 100f, 400f, "Altitude above the arrival point at which upward flight automatically leaves the atmosphere.");
			SurfaceRadius = Float(config, "World", "SurfaceRadius", 600f, 100f, 1500f, "Maximum flight radius around the map.");
			ArrivalAltitude = Float(config, "World", "ArrivalAltitude", 45f, 20f, 100f, "Initial altitude above the original landing point.");
		}

		private static ConfigEntry<float> Float(ConfigFile c, string section, string key, float value, float min, float max, string description)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return c.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
		}
	}
	internal sealed class FlightNetwork : IDisposable
	{
		private const string Hello = "LethalOrbit.Hello.3";

		private const string Command = "LethalOrbit.Command.3";

		private const string Input = "LethalOrbit.Input.3";

		private const string State = "LethalOrbit.State.3";

		private const string Notice = "LethalOrbit.Notice.3";

		private const string Destruction = "LethalOrbit.Destruction.3";

		private readonly ShipFlightController owner;

		private readonly NetworkManager manager;

		private readonly HashSet<ulong> peers = new HashSet<ulong>();

		private float lastHello;

		private float lastSend;

		private readonly Dictionary<ulong, float> lastCommand = new Dictionary<ulong, float>();

		public bool IsServer => manager.IsServer;

		public bool AllPeersReady
		{
			get
			{
				if (!manager.IsServer)
				{
					return true;
				}
				foreach (ulong connectedClientsId in manager.ConnectedClientsIds)
				{
					if (connectedClientsId != 0L && !peers.Contains(connectedClientsId))
					{
						return false;
					}
				}
				return true;
			}
		}

		public FlightNetwork(ShipFlightController controller)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			owner = controller;
			manager = NetworkManager.Singleton;
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.Hello.3", new HandleNamedMessageDelegate(OnHello));
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.Command.3", new HandleNamedMessageDelegate(OnCommand));
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.Input.3", new HandleNamedMessageDelegate(OnInput));
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.State.3", new HandleNamedMessageDelegate(OnState));
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.Notice.3", new HandleNamedMessageDelegate(OnNotice));
			manager.CustomMessagingManager.RegisterNamedMessageHandler("LethalOrbit.Destruction.3", new HandleNamedMessageDelegate(OnDestruction));
			manager.OnClientDisconnectCallback += Disconnected;
			peers.Add(0uL);
			SendHello();
		}

		public void Tick()
		{
			if (manager.IsListening)
			{
				if (!IsServer && Time.unscaledTime - lastHello > 2f)
				{
					SendHello();
				}
				if (IsServer && Time.unscaledTime - lastSend >= 0.05f)
				{
					Broadcast();
				}
			}
		}

		private unsafe void SendHello()
		{
			//IL_0033: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			lastHello = Time.unscaledTime;
			if (IsServer || !manager.IsListening)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1);
			try
			{
				byte b = 3;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.Hello.3", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnHello(ulong sender, FastBufferReader reader)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!IsServer || ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position != 1)
			{
				return;
			}
			byte b = default(byte);
			((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
			if (b != 3)
			{
				return;
			}
			if (peers.Add(sender))
			{
				Plugin.Log.LogDebug((object)("Flight handshake: " + sender));
				foreach (ulong item in owner.Scenery.Destroyed)
				{
					if (owner.Scenery.TryGet(item, out var obstacle))
					{
						SendDestruction(sender, item, ((Bounds)(ref obstacle.Bounds)).center, obstacle.Metal);
					}
				}
			}
			SendState(sender);
		}

		public unsafe void SendCommand(FlightCommand command)
		{
			//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_0050: Unknown result type (might be due to invalid IL or missing references)
			if (IsServer)
			{
				owner.AcceptCommand(manager.LocalClientId, command);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1);
			try
			{
				byte b = (byte)command;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.Command.3", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public unsafe void RejectCommand(ulong recipient, FlightNotice notice)
		{
			//IL_002d: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			if (recipient == manager.LocalClientId)
			{
				owner.ShowNotice(notice);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1);
			try
			{
				byte b = (byte)notice;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.Notice.3", recipient, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnNotice(ulong sender, FastBufferReader reader)
		{
			//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)
			if (!IsServer && sender == 0L && ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position == 1)
			{
				byte b = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
				if (b <= 14)
				{
					owner.ShowNotice((FlightNotice)b);
				}
			}
		}

		private void OnCommand(ulong sender, FastBufferReader reader)
		{
			//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)
			if (IsServer && peers.Contains(sender) && ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position == 1 && (!lastCommand.TryGetValue(sender, out var value) || !(Time.unscaledTime - value < 0.12f)))
			{
				lastCommand[sender] = Time.unscaledTime;
				byte b = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
				if (b <= 9)
				{
					owner.AcceptCommand(sender, (FlightCommand)b);
				}
			}
		}

		public unsafe void SendInput(PilotInput input)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0064: 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_007b: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (IsServer)
			{
				owner.AcceptInput(manager.LocalClientId, input);
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref input.Forward, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref input.Strafe, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref input.Lift, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref input.Yaw, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref input.Pitch, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref input.Boost, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref input.Brake, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.Input.3", 0uL, val, (NetworkDelivery)1);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnInput(ulong sender, FastBufferReader reader)
		{
			//IL_0042: 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_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_0070: 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_0087: 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_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)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			if (IsServer && sender == owner.Snapshot.Pilot && ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position == 22)
			{
				PilotInput next = default(PilotInput);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref next.Forward, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref next.Strafe, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref next.Lift, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref next.Yaw, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref next.Pitch, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref next.Boost, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref next.Brake, default(ForPrimitives));
				if (next.IsFinite)
				{
					next.Clamp();
					owner.AcceptInput(sender, next);
				}
			}
		}

		private static void Write(FastBufferWriter w, FlightSnapshot s)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00a1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			byte phase = (byte)s.Phase;
			((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref phase, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref s.Pilot, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe(ref s.SpacePosition);
			((FastBufferWriter)(ref w)).WriteValueSafe(ref s.ShipPosition);
			((FastBufferWriter)(ref w)).WriteValueSafe(ref s.Velocity);
			((FastBufferWriter)(ref w)).WriteValueSafe(ref s.SurfaceOrigin);
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref s.Yaw, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref s.Pitch, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref s.ShipYaw, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref s.TargetLevel, default(ForPrimitives));
			phase = (byte)s.Notice;
			((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref phase, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref s.SurfaceReady, default(ForPrimitives));
			((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref s.DoorOpen, default(ForPrimitives));
		}

		public unsafe void Broadcast()
		{
			//IL_002f: 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)
			if (!IsServer || !manager.IsListening)
			{
				return;
			}
			lastSend = Time.unscaledTime;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
			try
			{
				Write(val, owner.Snapshot);
				foreach (ulong peer in peers)
				{
					if (peer != 0L)
					{
						manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.State.3", peer, val, (NetworkDelivery)1);
					}
				}
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private unsafe void SendState(ulong recipient)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
			try
			{
				Write(val, owner.Snapshot);
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.State.3", recipient, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnState(ulong sender, FastBufferReader r)
		{
			//IL_002d: 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_004c: 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_009b: 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_00b2: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsServer && sender == 0L && ((FastBufferReader)(ref r)).Length - ((FastBufferReader)(ref r)).Position == 76)
			{
				FlightSnapshot snapshot = default(FlightSnapshot);
				byte b = default(byte);
				((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
				snapshot.Phase = (FlightPhase)b;
				((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref snapshot.Pilot, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe(ref snapshot.SpacePosition);
				((FastBufferReader)(ref r)).ReadValueSafe(ref snapshot.ShipPosition);
				((FastBufferReader)(ref r)).ReadValueSafe(ref snapshot.Velocity);
				((FastBufferReader)(ref r)).ReadValueSafe(ref snapshot.SurfaceOrigin);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref snapshot.Yaw, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref snapshot.Pitch, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref snapshot.ShipYaw, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref snapshot.TargetLevel, default(ForPrimitives));
				byte notice = default(byte);
				((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref notice, default(ForPrimitives));
				snapshot.Notice = (FlightNotice)notice;
				((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref snapshot.SurfaceReady, default(ForPrimitives));
				((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref snapshot.DoorOpen, default(ForPrimitives));
				if (b <= 5 && snapshot.TargetLevel >= 0 && snapshot.TargetLevel < owner.Round.levels.Length)
				{
					owner.ReceiveSnapshot(snapshot);
				}
			}
		}

		private void Disconnected(ulong id)
		{
			peers.Remove(id);
			lastCommand.Remove(id);
			if (IsServer && owner.Snapshot.Pilot == id)
			{
				owner.ReleasePilot(FlightNotice.PilotLost);
			}
		}

		public void BroadcastDestruction(ulong id, Vector3 point, bool metal)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!IsServer)
			{
				return;
			}
			foreach (ulong peer in peers)
			{
				if (peer != 0L)
				{
					SendDestruction(peer, id, point, metal);
				}
			}
		}

		private unsafe void SendDestruction(ulong recipient, ulong id, Vector3 point, bool metal)
		{
			//IL_0011: 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_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_0049: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(ref point);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref metal, default(ForPrimitives));
				manager.CustomMessagingManager.SendNamedMessage("LethalOrbit.Destruction.3", recipient, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnDestruction(ulong sender, FastBufferReader reader)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!IsServer && sender == 0L && ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position == 21)
			{
				ulong id = default(ulong);
				((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
				Vector3 point = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref point);
				bool isMetal = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isMetal, default(ForPrimitives));
				owner.Scenery.Apply(id, point, isMetal);
			}
		}

		public void Dispose()
		{
			if (!((Object)(object)manager == (Object)null))
			{
				manager.OnClientDisconnectCallback -= Disconnected;
				CustomMessagingManager customMessagingManager = manager.CustomMessagingManager;
				if (customMessagingManager != null)
				{
					customMessagingManager.UnregisterNamedMessageHandler("LethalOrbit.Hello.3");
					customMessagingManager.UnregisterNamedMessageHandler("LethalOrbit.Command.3");