Decompiled source of CruiserJumpPractice v0.1.4

com.aoirint.CruiserJumpPractice.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CruiserJumpPractice.Managers;
using CruiserJumpPractice.NetworkBehaviours;
using CruiserJumpPractice.Utils;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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("com.aoirint.CruiserJumpPractice")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4+679edf9ac6be94a4e3f660ada520f1c68dc9c924")]
[assembly: AssemblyProduct("CruiserJumpPractice")]
[assembly: AssemblyTitle("com.aoirint.CruiserJumpPractice")]
[assembly: AssemblyVersion("0.1.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 CruiserJumpPractice
{
	[BepInPlugin("com.aoirint.CruiserJumpPractice", "CruiserJumpPractice", "0.1.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("Lethal Company.exe")]
	public class CruiserJumpPractice : BaseUnityPlugin
	{
		internal static ManualLogSource? Logger { get; private set; }

		internal static Harmony Harmony { get; } = new Harmony("com.aoirint.CruiserJumpPractice");


		internal static InputActions? InputActions { get; private set; }

		internal static CruiserManager CruiserManager { get; } = new CruiserManager();


		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			InputActions = new InputActions();
			Harmony.PatchAll();
			Logger.LogInfo((object)"Plugin CruiserJumpPractice v0.1.4 is loaded!");
		}
	}
	internal class InputActions : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? LoadCruiserKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? SaveCruiserKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? ToggleMagnetKey { get; set; }
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.aoirint.CruiserJumpPractice";

		public const string PLUGIN_NAME = "CruiserJumpPractice";

		public const string PLUGIN_VERSION = "0.1.4";
	}
}
namespace CruiserJumpPractice.Utils
{
	internal static class CruiserUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal static VehicleController? GetCruiser()
		{
			VehicleController[] array = Object.FindObjectsOfType<VehicleController>();
			if (array == null)
			{
				Logger.LogError((object)"Failed to find VehicleController objects.");
				return null;
			}
			if (array.Length == 0)
			{
				Logger.LogInfo((object)"No VehicleController objects found.");
				return null;
			}
			return array[0];
		}

		internal static bool SetCarHP(VehicleController cruiser, int carHP)
		{
			PlayerControllerB localPlayer = PlayerUtils.GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
				return false;
			}
			cruiser.AddEngineOilOnLocalClient(carHP);
			cruiser.AddEngineOilServerRpc((int)localPlayer.playerClientId, carHP);
			return true;
		}

		internal static int? GetTurboBoosts(VehicleController cruiser)
		{
			try
			{
				FieldInfo field = typeof(VehicleController).GetField("turboBoosts", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null)
				{
					Logger.LogError((object)"Failed to get 'turboBoosts' field from VehicleController.");
					return null;
				}
				if (field.GetValue(cruiser) is int value)
				{
					return value;
				}
				Logger.LogError((object)"'turboBoosts' field is not of type int.");
				return null;
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"Exception while getting 'turboBoosts': {arg}");
				return null;
			}
		}

		internal static bool SetTurboBoosts(VehicleController cruiser, int turboBoosts)
		{
			PlayerControllerB localPlayer = PlayerUtils.GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
				return false;
			}
			cruiser.AddTurboBoostOnLocalClient(turboBoosts);
			cruiser.AddTurboBoostServerRpc((int)localPlayer.playerClientId, turboBoosts);
			return true;
		}
	}
	internal static class HUDManagerUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal static HUDManager? GetHUDManager()
		{
			HUDManager instance = HUDManager.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"HUDManager.Instance is null.");
				return null;
			}
			return instance;
		}

		internal static void DisplayTip(string headerText, string bodyText)
		{
			HUDManager hUDManager = GetHUDManager();
			if ((Object)(object)hUDManager == (Object)null)
			{
				Logger.LogError((object)"Cannot display tip because HUDManager is null.");
			}
			else
			{
				hUDManager.DisplayTip(headerText, bodyText, false, false, "LC_Tip1");
			}
		}
	}
	internal static class MagnetUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal static bool? IsMagnetOn()
		{
			StartOfRound startOfRound = StartOfRoundUtils.GetStartOfRound();
			if ((Object)(object)startOfRound == (Object)null)
			{
				Logger.LogError((object)"StartOfRound is null.");
				return null;
			}
			return startOfRound.magnetOn;
		}

		internal static void ToggleMagnet()
		{
			StartOfRound startOfRound = StartOfRoundUtils.GetStartOfRound();
			if ((Object)(object)startOfRound == (Object)null)
			{
				Logger.LogError((object)"StartOfRound is null.");
				return;
			}
			AnimatedObjectTrigger magnetLever = startOfRound.magnetLever;
			if ((Object)(object)magnetLever == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.magnetLever is null.");
				return;
			}
			PlayerControllerB localPlayer = PlayerUtils.GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
			}
			else
			{
				magnetLever.TriggerAnimation(localPlayer);
			}
		}
	}
	internal static class NetworkBehaviourUtils
	{
		private static CruiserStateNetworkBehaviour? cachedCruiserStateNetworkBehaviour;

		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		public static CruiserStateNetworkBehaviour? GetCruiserStateNetworkBehaviour()
		{
			if ((Object)(object)cachedCruiserStateNetworkBehaviour != (Object)null)
			{
				return cachedCruiserStateNetworkBehaviour;
			}
			HUDManager hUDManager = HUDManagerUtils.GetHUDManager();
			if ((Object)(object)hUDManager == (Object)null)
			{
				Logger.LogError((object)"HUDManager instance is null.");
				return null;
			}
			CruiserStateNetworkBehaviour component = ((Component)hUDManager).GetComponent<CruiserStateNetworkBehaviour>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.LogError((object)"CruiserStateNetworkBehaviour component not found on HUDManager instance.");
				return null;
			}
			cachedCruiserStateNetworkBehaviour = component;
			return component;
		}
	}
	internal static class NetworkUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		public static bool IsServer()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				Logger.LogError((object)"NetworkManager.Singleton is null.");
				return false;
			}
			return singleton.IsServer;
		}

		public static bool IsHost()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				Logger.LogError((object)"NetworkManager.Singleton is null.");
				return false;
			}
			return singleton.IsHost;
		}

		public static bool IsClient()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				Logger.LogError((object)"NetworkManager.Singleton is null.");
				return false;
			}
			return singleton.IsClient;
		}
	}
	internal static class PlayerUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal static GameNetworkManager? GetGameNetworkManager()
		{
			GameNetworkManager instance = GameNetworkManager.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"GameNetworkManager.Instance is null.");
				return null;
			}
			return instance;
		}

		internal static PlayerControllerB? GetLocalPlayer()
		{
			GameNetworkManager gameNetworkManager = GetGameNetworkManager();
			if ((Object)(object)gameNetworkManager == (Object)null)
			{
				Logger.LogError((object)"GameNetworkManager is null.");
				return null;
			}
			PlayerControllerB localPlayerController = gameNetworkManager.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				Logger.LogError((object)"localPlayerController is null.");
				return null;
			}
			return localPlayerController;
		}

		internal static bool IsLocalPlayerBusy()
		{
			if (IsLocalPlayerMenuOpen().GetValueOrDefault())
			{
				return true;
			}
			if (IsLocalPlayerInTerminalMenu().GetValueOrDefault())
			{
				return true;
			}
			if (IsLocalPlayerTypingChat().GetValueOrDefault())
			{
				return true;
			}
			return false;
		}

		internal static bool? IsLocalPlayerInTerminalMenu()
		{
			PlayerControllerB localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
				return null;
			}
			return localPlayer.inTerminalMenu;
		}

		internal static bool? IsLocalPlayerTypingChat()
		{
			PlayerControllerB localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
				return null;
			}
			return localPlayer.isTypingChat;
		}

		internal static QuickMenuManager? GetLocalPlayerQuickMenuManager()
		{
			PlayerControllerB localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				Logger.LogError((object)"Local player is null.");
				return null;
			}
			QuickMenuManager quickMenuManager = localPlayer.quickMenuManager;
			if ((Object)(object)quickMenuManager == (Object)null)
			{
				Logger.LogError((object)"quickMenuManager is null.");
				return null;
			}
			return quickMenuManager;
		}

		internal static bool? IsLocalPlayerMenuOpen()
		{
			QuickMenuManager localPlayerQuickMenuManager = GetLocalPlayerQuickMenuManager();
			if ((Object)(object)localPlayerQuickMenuManager == (Object)null)
			{
				Logger.LogError((object)"QuickMenuManager is null.");
				return null;
			}
			return localPlayerQuickMenuManager.isMenuOpen;
		}
	}
	internal static class StartOfRoundUtils
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal static StartOfRound? GetStartOfRound()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return null;
			}
			return instance;
		}
	}
}
namespace CruiserJumpPractice.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void AwakePostfix(HUDManager __instance)
		{
			GameObject gameObject = ((Component)__instance).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				Logger.LogError((object)"HUDManager.gameObject is null.");
			}
			else
			{
				gameObject.AddComponent<CruiserStateNetworkBehaviour>();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePostfix(HUDManager __instance)
		{
			if (NetworkUtils.IsClient() && !PlayerUtils.IsLocalPlayerBusy())
			{
				UpdateSaveCruiser();
				UpdateLoadCruiser();
				UpdateToggleMagnet();
			}
		}

		internal static void UpdateSaveCruiser()
		{
			InputActions? inputActions = CruiserJumpPractice.InputActions;
			bool? obj;
			if (inputActions == null)
			{
				obj = null;
			}
			else
			{
				InputAction? saveCruiserKey = inputActions.SaveCruiserKey;
				obj = ((saveCruiserKey != null) ? new bool?(saveCruiserKey.triggered) : null);
			}
			bool? flag = obj;
			if (!flag.GetValueOrDefault())
			{
				return;
			}
			if (!NetworkUtils.IsHost())
			{
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Only the host can save the cruiser state.");
				return;
			}
			CruiserStateNetworkBehaviour cruiserStateNetworkBehaviour = NetworkBehaviourUtils.GetCruiserStateNetworkBehaviour();
			if ((Object)(object)cruiserStateNetworkBehaviour == (Object)null)
			{
				Logger.LogError((object)"CruiserStateNetworkBehaviour is null.");
			}
			else
			{
				cruiserStateNetworkBehaviour.SaveCruiserStateServerRpc();
			}
		}

		internal static void UpdateLoadCruiser()
		{
			InputActions? inputActions = CruiserJumpPractice.InputActions;
			bool? obj;
			if (inputActions == null)
			{
				obj = null;
			}
			else
			{
				InputAction? loadCruiserKey = inputActions.LoadCruiserKey;
				obj = ((loadCruiserKey != null) ? new bool?(loadCruiserKey.triggered) : null);
			}
			bool? flag = obj;
			if (!flag.GetValueOrDefault())
			{
				return;
			}
			if (!NetworkUtils.IsHost())
			{
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Only the host can load the cruiser state.");
				return;
			}
			CruiserStateNetworkBehaviour cruiserStateNetworkBehaviour = NetworkBehaviourUtils.GetCruiserStateNetworkBehaviour();
			if ((Object)(object)cruiserStateNetworkBehaviour == (Object)null)
			{
				Logger.LogError((object)"CruiserStateNetworkBehaviour is null.");
			}
			else
			{
				cruiserStateNetworkBehaviour.LoadCruiserStateServerRpc();
			}
		}

		internal static void UpdateToggleMagnet()
		{
			InputActions? inputActions = CruiserJumpPractice.InputActions;
			bool? obj;
			if (inputActions == null)
			{
				obj = null;
			}
			else
			{
				InputAction? toggleMagnetKey = inputActions.ToggleMagnetKey;
				obj = ((toggleMagnetKey != null) ? new bool?(toggleMagnetKey.triggered) : null);
			}
			bool? flag = obj;
			if (!flag.GetValueOrDefault())
			{
				return;
			}
			if (!NetworkUtils.IsHost())
			{
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Only the host can toggle the magnet.");
				return;
			}
			bool? flag2 = MagnetUtils.IsMagnetOn();
			if (!flag2.HasValue)
			{
				Logger.LogError((object)"IsMagnetOn returned null.");
				return;
			}
			bool num = !flag2.Value;
			MagnetUtils.ToggleMagnet();
			string text = (num ? "ON" : "OFF");
			HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Magnet is now " + text + ".");
		}
	}
}
namespace CruiserJumpPractice.NetworkBehaviours
{
	internal enum SaveCruiserStateResult
	{
		Success,
		NoCruiserFound
	}
	internal enum LoadCruiserStateResult
	{
		Success,
		NoCruiserFound,
		NoSavedState,
		MagnetedToShip
	}
	internal class CruiserStateNetworkBehaviour : NetworkBehaviour
	{
		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		[ServerRpc(RequireOwnership = true)]
		public void SaveCruiserStateServerRpc()
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogError((object)"SaveCruiserStateServerRpc called on client. Ignoring.");
			}
			else
			{
				CruiserJumpPractice.CruiserManager.SaveCruiserState();
			}
		}

		[ClientRpc]
		public void SaveCruiserStateDoneClientRpc(SaveCruiserStateResult result)
		{
			if (!NetworkUtils.IsClient())
			{
				Logger.LogError((object)"SaveCruiserStateDoneClientRpc called on server. Ignoring.");
				return;
			}
			switch (result)
			{
			case SaveCruiserStateResult.Success:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Cruiser state saved.");
				break;
			case SaveCruiserStateResult.NoCruiserFound:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "No cruiser found to save.");
				break;
			default:
				Logger.LogError((object)$"Unknown SaveCruiserStateResult: {result}");
				break;
			}
		}

		[ServerRpc(RequireOwnership = true)]
		public void LoadCruiserStateServerRpc()
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogError((object)"LoadCruiserStateServerRpc called on client. Ignoring.");
			}
			else
			{
				CruiserJumpPractice.CruiserManager.LoadCruiserState();
			}
		}

		[ClientRpc]
		public void LoadCruiserStateDoneClientRpc(LoadCruiserStateResult result)
		{
			if (!NetworkUtils.IsClient())
			{
				Logger.LogError((object)"LoadCruiserStateDoneClientRpc called on server. Ignoring.");
				return;
			}
			switch (result)
			{
			case LoadCruiserStateResult.Success:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Cruiser state loaded.");
				break;
			case LoadCruiserStateResult.NoCruiserFound:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "No cruiser found to load.");
				break;
			case LoadCruiserStateResult.NoSavedState:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "No saved cruiser state to load.");
				break;
			case LoadCruiserStateResult.MagnetedToShip:
				HUDManagerUtils.DisplayTip("CruiserJumpPractice", "Cannot load cruiser state while magneted to ship.");
				break;
			default:
				Logger.LogError((object)$"Unknown LoadCruiserStateResult: {result}");
				break;
			}
		}
	}
}
namespace CruiserJumpPractice.Managers
{
	internal sealed class CruiserState
	{
		public Vector3 CarPosition { get; private set; }

		public Vector3 CarRotation { get; private set; }

		public float SteeringInput { get; private set; }

		public float EngineRPM { get; private set; }

		public int CarHP { get; private set; }

		public int TurboBoosts { get; private set; }

		public CruiserState(Vector3 carPosition, Vector3 carRotation, float steeringInput, float engineRPM, int carHP, int turboBoosts)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			CarPosition = carPosition;
			CarRotation = carRotation;
			SteeringInput = steeringInput;
			EngineRPM = engineRPM;
			CarHP = carHP;
			TurboBoosts = turboBoosts;
		}
	}
	internal class CruiserManager
	{
		private CruiserState? savedCruiserState;

		internal static ManualLogSource Logger => CruiserJumpPractice.Logger;

		internal void SaveCruiserState()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			CruiserStateNetworkBehaviour cruiserStateNetworkBehaviour = NetworkBehaviourUtils.GetCruiserStateNetworkBehaviour();
			if ((Object)(object)cruiserStateNetworkBehaviour == (Object)null)
			{
				Logger.LogError((object)"CruiserStateNetworkBehaviour is null.");
				return;
			}
			VehicleController cruiser = CruiserUtils.GetCruiser();
			if ((Object)(object)cruiser == (Object)null)
			{
				cruiserStateNetworkBehaviour.SaveCruiserStateDoneClientRpc(SaveCruiserStateResult.NoCruiserFound);
				return;
			}
			int? turboBoosts = CruiserUtils.GetTurboBoosts(cruiser);
			if (!turboBoosts.HasValue)
			{
				Logger.LogError((object)"Failed to get turbo boosts from cruiser.");
				return;
			}
			savedCruiserState = new CruiserState(((Component)cruiser).transform.position, ((Component)cruiser).transform.eulerAngles, cruiser.moveInputVector.x, cruiser.EngineRPM, cruiser.carHP, turboBoosts.Value);
			cruiserStateNetworkBehaviour.SaveCruiserStateDoneClientRpc(SaveCruiserStateResult.Success);
		}

		internal void LoadCruiserState()
		{
			//IL_0062: 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)
			CruiserStateNetworkBehaviour cruiserStateNetworkBehaviour = NetworkBehaviourUtils.GetCruiserStateNetworkBehaviour();
			if ((Object)(object)cruiserStateNetworkBehaviour == (Object)null)
			{
				Logger.LogError((object)"CruiserStateNetworkBehaviour is null.");
				return;
			}
			VehicleController cruiser = CruiserUtils.GetCruiser();
			if ((Object)(object)cruiser == (Object)null)
			{
				cruiserStateNetworkBehaviour.LoadCruiserStateDoneClientRpc(LoadCruiserStateResult.NoCruiserFound);
				return;
			}
			if (savedCruiserState == null)
			{
				cruiserStateNetworkBehaviour.LoadCruiserStateDoneClientRpc(LoadCruiserStateResult.NoSavedState);
				return;
			}
			if (cruiser.magnetedToShip)
			{
				cruiserStateNetworkBehaviour.LoadCruiserStateDoneClientRpc(LoadCruiserStateResult.MagnetedToShip);
				return;
			}
			((Component)cruiser).transform.position = savedCruiserState.CarPosition;
			((Component)cruiser).transform.eulerAngles = savedCruiserState.CarRotation;
			cruiser.moveInputVector.x = savedCruiserState.SteeringInput;
			cruiser.EngineRPM = savedCruiserState.EngineRPM;
			CruiserUtils.SetCarHP(cruiser, savedCruiserState.CarHP);
			CruiserUtils.SetTurboBoosts(cruiser, savedCruiserState.TurboBoosts);
			cruiserStateNetworkBehaviour.LoadCruiserStateDoneClientRpc(LoadCruiserStateResult.Success);
		}
	}
}