Decompiled source of LC Plan de Resurrection v2.1.0

LePlanDeResurection.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCTarrotCard.Cards;
using LCTarrotCard.Ressource;
using LePlanDeResurection;
using LePlanDeResurection.Assets;
using LePlanDeResurection.Item;
using LePlanDeResurection.NetcodePatcher;
using LePlanDeResurection.Util;
using LePlanDeResurrection.Item;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LePlanDeResurection")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LePlanDeResurection")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4BB4F307-9517-4301-ACD8-E3586F60815B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
namespace LePlanDeResurrection.Item
{
	internal class Lada : GrabbableObject
	{
		private readonly Vector3 tpsPositionOffset = new Vector3(-1.3f, -0.4f, 0.3f);

		private readonly Quaternion tpsRotationOffset = Quaternion.Euler(-90f, 10f, -73f);

		private AudioSource _audioSource;

		public float soundVolume = 1f;

		public AudioClip[] engineLoopSounds;

		private const float SpeedMultiplier = 2.5f;

		private const float BoostSpeedMultiplier = 2f;

		private const float BoostVolumeMultiplier = 2f;

		private const float batteryDrainPerSecond = 0.015f;

		private const float TurboBatteryDrainMultiplier = 2f;

		private const float KillRange = 0f;

		private const float DamageRange = 0f;

		private const int ExplosionDamage = 0;

		private const float ExplosionForce = 2.5f;

		private float baseMovementSpeedBeforeBoost;

		private bool boostApplied;

		private bool turboActive;

		private Key boostKey;

		private const float groundScalePercent = 0.2f;

		private readonly Vector3 handScale = new Vector3(0.15f, 0.15f, 0.15f);

		private Vector3 groundScale;

		public override void Start()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Start();
			groundScale = handScale * 0.2f;
			UpdateItemScale();
			if (!base.isHeld)
			{
				((Component)this).transform.localScale = groundScale;
			}
			if (base.insertedBattery != null)
			{
				base.insertedBattery.charge = 1f;
			}
			_audioSource = ((Component)this).GetComponent<AudioSource>();
			if ((Object)(object)_audioSource == (Object)null)
			{
				_audioSource = ((Component)this).GetComponentInChildren<AudioSource>();
			}
			if ((Object)(object)_audioSource == (Object)null)
			{
				_audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				ModMain.Instance.logger.LogDebug((object)"[Lada] AudioSource créé automatiquement");
			}
			_audioSource.spatialBlend = 1f;
			_audioSource.volume = soundVolume;
			_audioSource.minDistance = 1f;
			_audioSource.maxDistance = 50f;
			_audioSource.rolloffMode = (AudioRolloffMode)1;
			_audioSource.playOnAwake = false;
			_audioSource.loop = true;
			Keyboard current = Keyboard.current;
			boostKey = (Key)((current != null) ? ((int)current.FindKeyOnCurrentKeyboardLayout("A").keyCode) : 0);
		}

		public override void Update()
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Invalid comparison between Unknown and I4
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			bool flag = (Object)(object)base.playerHeldBy != (Object)null && !base.isPocketed;
			if (boostApplied && (Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.sprintMeter = 1f;
			}
			if (((NetworkBehaviour)this).IsOwner && flag && base.insertedBattery != null && base.insertedBattery.charge > 0f)
			{
				float num = 0.015f * (turboActive ? 2f : 1f);
				base.insertedBattery.charge = Mathf.Max(0f, base.insertedBattery.charge - num * Time.deltaTime);
				if (base.insertedBattery.charge <= 0f)
				{
					base.insertedBattery.empty = true;
				}
			}
			if (flag)
			{
				UpdateBatteryState();
			}
			else if (boostApplied || turboActive)
			{
				FullReset();
			}
			if (((NetworkBehaviour)this).IsOwner && !((Object)(object)base.playerHeldBy == (Object)null) && (int)boostKey != 0 && ((ButtonControl)Keyboard.current[boostKey]).wasPressedThisFrame && base.insertedBattery != null && base.insertedBattery.charge > 0f)
			{
				turboActive = !turboActive;
				SetTurboServerRpc(turboActive);
			}
		}

		public override void LateUpdate()
		{
			//IL_008b: 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)
			((GrabbableObject)this).LateUpdate();
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && !((NetworkBehaviour)this).IsOwner)
			{
				if ((Object)(object)((Component)this).transform.parent != (Object)(object)base.playerHeldBy.serverItemHolder && (Object)(object)base.playerHeldBy.serverItemHolder != (Object)null)
				{
					((Component)this).transform.SetParent(base.playerHeldBy.serverItemHolder, false);
				}
				((Component)this).transform.localPosition = tpsPositionOffset;
				((Component)this).transform.localRotation = tpsRotationOffset;
			}
		}

		private void ApplyCarSpeedBoost()
		{
			if (!boostApplied && !((Object)(object)base.playerHeldBy == (Object)null))
			{
				baseMovementSpeedBeforeBoost = base.playerHeldBy.movementSpeed;
				base.playerHeldBy.movementSpeed = baseMovementSpeedBeforeBoost * 2.5f;
				boostApplied = true;
			}
		}

		private void UpdateBatteryState()
		{
			if (base.insertedBattery == null || (Object)(object)base.playerHeldBy == (Object)null)
			{
				return;
			}
			if (base.insertedBattery.charge <= 0f)
			{
				if (boostApplied || turboActive)
				{
					if (((NetworkBehaviour)this).IsOwner && turboActive)
					{
						SetTurboServerRpc(active: false);
					}
					RemoveCarSpeedBoost();
					if (((NetworkBehaviour)this).IsOwner)
					{
						StopEngineLoopServerRpc();
					}
				}
			}
			else if (!boostApplied)
			{
				ApplyCarSpeedBoost();
				if (((NetworkBehaviour)this).IsOwner)
				{
					int clipIndex = Random.Range(0, engineLoopSounds.Length);
					PlayEngineLoopServerRpc(clipIndex);
				}
			}
		}

		public override void EquipItem()
		{
			//IL_000f: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).EquipItem();
			((Component)this).transform.localScale = handScale;
			if ((Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy.serverItemHolder != (Object)null)
			{
				((Component)this).transform.SetParent(base.playerHeldBy.serverItemHolder, false);
				((Component)this).transform.localPosition = Vector3.zero;
				((Component)this).transform.localRotation = Quaternion.identity;
			}
			if (base.insertedBattery != null && base.insertedBattery.charge > 0f)
			{
				ApplyCarSpeedBoost();
				if (((NetworkBehaviour)this).IsOwner)
				{
					int clipIndex = Random.Range(0, engineLoopSounds.Length);
					PlayEngineLoopServerRpc(clipIndex);
				}
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				SetScaleServerRpc(handScale);
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner && buttonDown)
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.inShipPhase)
				{
					ModMain.Instance.logger.LogDebug((object)"[Lada] Explosion annulée : le vaisseau est dans l'espace !");
					return;
				}
				if (base.insertedBattery == null || base.insertedBattery.charge <= 0f)
				{
					ModMain.Instance.logger.LogDebug((object)"[Lada] Explosion annulée : batterie vide.");
					return;
				}
				if (!turboActive)
				{
					ModMain.Instance.logger.LogDebug((object)"[Lada] Explosion annulée : le mode Superboost (A) doit être actif.");
					return;
				}
				ModMain.Instance.logger.LogDebug((object)"[Lada] Conditions remplies ! Envoi de la demande d'explosion...");
				RequestExplosionServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StopEngineLoopServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3113803557u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3113803557u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					StopEngineLoopClientRpc();
				}
			}
		}

		[ClientRpc]
		private void StopEngineLoopClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(291184985u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 291184985u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					StopEngineLoopLocal();
				}
			}
		}

		private void StopEngineLoopLocal()
		{
			if ((Object)(object)_audioSource != (Object)null && _audioSource.isPlaying)
			{
				_audioSource.Stop();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetTurboServerRpc(bool active)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(704699883u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref active, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 704699883u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					turboActive = active;
					SetTurboClientRpc(active);
				}
			}
		}

		[ClientRpc]
		private void SetTurboClientRpc(bool active)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3512242913u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref active, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3512242913u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ApplyLocalTurboState(active);
				}
			}
		}

		private void ApplyLocalTurboState(bool active)
		{
			turboActive = active;
			if ((Object)(object)base.playerHeldBy != (Object)null && boostApplied)
			{
				base.playerHeldBy.movementSpeed = (active ? (baseMovementSpeedBeforeBoost * 2.5f * 2f) : (baseMovementSpeedBeforeBoost * 2.5f));
			}
			if ((Object)(object)_audioSource != (Object)null)
			{
				_audioSource.volume = (active ? Mathf.Clamp01(soundVolume * 2f) : soundVolume);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RequestExplosionServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_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_012d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(174376970u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 174376970u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.inShipPhase)
				{
					ModMain.Instance.logger.LogWarning((object)"[Lada] Explosion annulée par le serveur : vaisseau en orbite.");
				}
				else if (!((Object)(object)base.playerHeldBy == (Object)null))
				{
					Vector3 position = ((Component)base.playerHeldBy).transform.position;
					ulong playerClientId = base.playerHeldBy.playerClientId;
					ExplosionClientRpc(position, playerClientId);
				}
			}
		}

		[ClientRpc]
		private void ExplosionClientRpc(Vector3 explosionPosition, ulong holderId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(774169u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref explosionPosition);
					BytePacker.WriteValueBitPacked(val, holderId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 774169u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ModMain.Instance.logger.LogDebug((object)"[Lada] ExplosionClientRpc reçu, déclenchement de l'explosion.");
					LadaHolderProtection.ProtectedPlayerId = holderId;
					LadaHolderProtection.ClearAfterDelay((MonoBehaviour)(object)this, 2f);
					Landmine.SpawnExplosion(explosionPosition, true, 0f, 0f, 0, 2.5f, (GameObject)null, false);
				}
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			FullReset();
		}

		public override void DiscardItem()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			FullReset();
			((GrabbableObject)this).DiscardItem();
			((Component)this).transform.localScale = groundScale;
			if (((NetworkBehaviour)this).IsOwner)
			{
				Vector3 scaleServerRpc = handScale * 0.2f;
				SetScaleServerRpc(scaleServerRpc);
			}
		}

		private void FullReset()
		{
			if (turboActive)
			{
				turboActive = false;
				if (((NetworkBehaviour)this).IsOwner)
				{
					SetTurboServerRpc(active: false);
				}
			}
			RemoveCarSpeedBoost();
			if (((NetworkBehaviour)this).IsOwner)
			{
				StopEngineLoopServerRpc();
			}
			else
			{
				StopEngineLoopLocal();
			}
		}

		private void RemoveCarSpeedBoost()
		{
			if (!boostApplied || (Object)(object)base.playerHeldBy == (Object)null)
			{
				boostApplied = false;
				return;
			}
			base.playerHeldBy.movementSpeed = baseMovementSpeedBeforeBoost;
			boostApplied = false;
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			UpdateItemScale();
		}

		private void UpdateItemScale()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (base.isHeld || (Object)(object)base.playerHeldBy != (Object)null)
			{
				((Component)this).transform.localScale = handScale;
			}
			else
			{
				((Component)this).transform.localScale = handScale * 0.2f;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetScaleServerRpc(Vector3 newScale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1657264549u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref newScale);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1657264549u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SetScaleClientRpc(newScale);
				}
			}
		}

		[ClientRpc]
		private void SetScaleClientRpc(Vector3 newScale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4228595739u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref newScale);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 4228595739u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					((Component)this).transform.localScale = newScale;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void PlayEngineLoopServerRpc(int clipIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(424657485u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, clipIndex);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 424657485u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					PlayEngineLoopClientRpc(clipIndex);
				}
			}
		}

		[ClientRpc]
		private void PlayEngineLoopClientRpc(int clipIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3449219219u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clipIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3449219219u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (engineLoopSounds == null || clipIndex < 0 || clipIndex >= engineLoopSounds.Length)
				{
					ModMain.Instance.logger.LogWarning((object)"[Lada] Index de clip invalide !");
					return;
				}
				_audioSource.clip = engineLoopSounds[clipIndex];
				_audioSource.loop = true;
				_audioSource.volume = soundVolume;
				_audioSource.Play();
			}
		}

		public void ForceResetOnDeath()
		{
			FullReset();
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3113803557u, new RpcReceiveHandler(__rpc_handler_3113803557), "StopEngineLoopServerRpc");
			((NetworkBehaviour)this).__registerRpc(291184985u, new RpcReceiveHandler(__rpc_handler_291184985), "StopEngineLoopClientRpc");
			((NetworkBehaviour)this).__registerRpc(704699883u, new RpcReceiveHandler(__rpc_handler_704699883), "SetTurboServerRpc");
			((NetworkBehaviour)this).__registerRpc(3512242913u, new RpcReceiveHandler(__rpc_handler_3512242913), "SetTurboClientRpc");
			((NetworkBehaviour)this).__registerRpc(174376970u, new RpcReceiveHandler(__rpc_handler_174376970), "RequestExplosionServerRpc");
			((NetworkBehaviour)this).__registerRpc(774169u, new RpcReceiveHandler(__rpc_handler_774169), "ExplosionClientRpc");
			((NetworkBehaviour)this).__registerRpc(1657264549u, new RpcReceiveHandler(__rpc_handler_1657264549), "SetScaleServerRpc");
			((NetworkBehaviour)this).__registerRpc(4228595739u, new RpcReceiveHandler(__rpc_handler_4228595739), "SetScaleClientRpc");
			((NetworkBehaviour)this).__registerRpc(424657485u, new RpcReceiveHandler(__rpc_handler_424657485), "PlayEngineLoopServerRpc");
			((NetworkBehaviour)this).__registerRpc(3449219219u, new RpcReceiveHandler(__rpc_handler_3449219219), "PlayEngineLoopClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_3113803557(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).StopEngineLoopServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_291184985(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).StopEngineLoopClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_704699883(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool turboServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref turboServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).SetTurboServerRpc(turboServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3512242913(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool turboClientRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref turboClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).SetTurboClientRpc(turboClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_174376970(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).RequestExplosionServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_774169(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 explosionPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref explosionPosition);
				ulong holderId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref holderId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).ExplosionClientRpc(explosionPosition, holderId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1657264549(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 scaleServerRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref scaleServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).SetScaleServerRpc(scaleServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4228595739(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 scaleClientRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref scaleClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).SetScaleClientRpc(scaleClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_424657485(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).PlayEngineLoopServerRpc(clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3449219219(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Lada)(object)target).PlayEngineLoopClientRpc(clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Lada";
		}
	}
	internal static class LadaHolderProtection
	{
		public static ulong? ProtectedPlayerId;

		public static void ClearAfterDelay(MonoBehaviour runner, float delaySeconds)
		{
			runner.StartCoroutine(ClearRoutine(delaySeconds));
		}

		private static IEnumerator ClearRoutine(float delaySeconds)
		{
			yield return (object)new WaitForSeconds(delaySeconds);
			ProtectedPlayerId = null;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
	internal static class Lada_DeathHandlingPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(PlayerControllerB __instance)
		{
			if (LadaHolderProtection.ProtectedPlayerId.HasValue && __instance.playerClientId == LadaHolderProtection.ProtectedPlayerId.Value)
			{
				LadaHolderProtection.ProtectedPlayerId = null;
				return false;
			}
			if (__instance.currentlyHeldObjectServer is Lada lada)
			{
				lada.ForceResetOnDeath();
			}
			return true;
		}
	}
	public class SpaceShuttleE : GrabbableObject
	{
		private static readonly int Trigger = Animator.StringToHash("trigger");

		private PlayerControllerB playerHoldingItem;

		private bool isFlying = false;

		private float baseFlySpeed = 10f;

		private float verticalSpeed = 10f;

		private Vector3 velocity = Vector3.zero;

		private float planeGravity = -2f;

		private float currentVerticalVelocity = 0f;

		private float glideTimer = 0f;

		private const float MaxFlySpeedMultiplier = 2f;

		private const float GlideSpeedRampDuration = 8f;

		private float initialFallVelocity = 0f;

		private float fallCatchUpTimer = 0f;

		private float fallCatchUpDuration = 0f;

		private const float CatchUpSecondsPerMps = 0.08f;

		private const float MinCatchUpDuration = 0.15f;

		private const float MaxCatchUpDuration = 2.5f;

		private float currentSpeed = 0f;

		private const float goodGlideSpeed = 6f;

		private const float maxSpeed = 36f;

		private const float energyConversionRate = 1f;

		private const float speedDrag = 2f;

		private const float groundDrag = 15f;

		private const float horizontalSpeedFactor = 1f;

		private const float climbBonusFactor = 0.3f;

		private const float explosionSpeedBoost = 12f;

		private const float stallGravityMultiplier = 3f;

		private const float stallTerminalVelocity = -14f;

		private const float diveExponentialGrowthRate = 1.5f;

		private const float batteryUsagePerExplosion = 0.05f;

		private const float spaceBatteryDrainPerSecond = 0.02f;

		private float currentRoll = 0f;

		private float previousCameraYaw = 0f;

		private const float maxRollAngle = 25f;

		private const float rollPerTurnSpeed = 0.5f;

		private const float rollPerStrafeInput = 15f;

		private const float rollSmoothSpeed = 6f;

		private const float turnDeadzoneDegrees = 1.5f;

		private Animator animator;

		private bool isOpen = true;

		private Key toggleKey;

		private const float groundScalePercent = 0.2f;

		private readonly Vector3 handScale = new Vector3(0.05f, 0.05f, 0.05f);

		private Vector3 groundScale;

		private readonly Vector3 tpsPositionOffset = new Vector3(-1.2f, -1f, 0.3f);

		private readonly Quaternion tpsRotationOffset = Quaternion.Euler(-90f, -80f, 17f);

		public override void Start()
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Start();
			UpdateItemScale();
			groundScale = handScale * 0.2f;
			if (!base.isHeld)
			{
				((Component)this).transform.localScale = groundScale;
			}
			if (base.insertedBattery != null)
			{
				base.insertedBattery.charge = 1f;
			}
			if ((Object)(object)animator == (Object)null)
			{
				animator = ((Component)this).GetComponentInChildren<Animator>();
			}
			if ((Object)(object)animator == (Object)null)
			{
				ModMain.Instance.logger.LogError((object)"[SpaceShuttleE] Aucun Animator trouve sur le prefab !");
			}
			Keyboard current = Keyboard.current;
			toggleKey = (Key)((current != null) ? ((int)current.FindKeyOnCurrentKeyboardLayout("A").keyCode) : 0);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner && buttonDown && !(base.insertedBattery.charge <= 0f))
			{
				currentSpeed = Mathf.Clamp(currentSpeed + 12f, 0f, 36f);
				float newBatteryCharge = Mathf.Clamp01(base.insertedBattery.charge - 0.05f);
				ActivateitemstsServerRpc(newBatteryCharge);
			}
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!(!((NetworkBehaviour)this).IsOwner || right))
			{
				isOpen = !isOpen;
				ModMain.Instance.logger.LogDebug((object)("SpaceShuttleE: ItemInteractLeftRight " + isOpen));
				ToggleAnimationServerRpc(isOpen);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ActivateitemstsServerRpc(float newBatteryCharge)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(625665929u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref newBatteryCharge, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 625665929u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					TriggerExplosionClientRpc(newBatteryCharge);
				}
			}
		}

		[ClientRpc]
		private void TriggerExplosionClientRpc(float newBatteryCharge)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3105262298u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref newBatteryCharge, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3105262298u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.insertedBattery.charge = newBatteryCharge;
					ModMain.Instance.logger.LogDebug((object)"[Client] Triggering explosion");
					Vector3 position = ((Component)this).transform.position;
					TriggerExplosion(position);
				}
			}
		}

		public override void EquipItem()
		{
			//IL_000f: 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_009a: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).EquipItem();
			((Component)this).transform.localScale = handScale;
			playerHoldingItem = base.playerHeldBy;
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.equippedUsableItemQE = true;
			}
			if ((Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy.serverItemHolder != (Object)null)
			{
				((Component)this).transform.SetParent(base.playerHeldBy.serverItemHolder, false);
				((Component)this).transform.localPosition = Vector3.zero;
				((Component)this).transform.localRotation = Quaternion.identity;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				SetScaleServerRpc(handScale);
			}
			if ((Object)(object)playerHoldingItem != (Object)null)
			{
				isFlying = true;
				float num = (currentVerticalVelocity = (initialFallVelocity = (((Object)(object)playerHoldingItem.thisController != (Object)null) ? playerHoldingItem.thisController.velocity.y : 0f)));
				currentSpeed = Mathf.Clamp(Mathf.Abs(num), 0f, 36f);
				fallCatchUpDuration = Mathf.Clamp(Mathf.Abs(num) * 0.08f, 0.15f, 2.5f);
				fallCatchUpTimer = 0f;
				glideTimer = 0f;
				currentRoll = 0f;
				previousCameraYaw = (((Object)(object)playerHoldingItem.gameplayCamera != (Object)null) ? ((Component)playerHoldingItem.gameplayCamera).transform.eulerAngles.y : 0f);
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			UpdateItemScale();
		}

		public override void DiscardItem()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).DiscardItem();
			StopFlying();
			((Component)this).transform.localScale = groundScale;
			if (!((Object)(object)base.playerHeldBy == (Object)null))
			{
				base.playerHeldBy.equippedUsableItemQE = false;
				if (((NetworkBehaviour)this).IsOwner)
				{
					Vector3 scaleServerRpc = handScale * 0.2f;
					SetScaleServerRpc(scaleServerRpc);
				}
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			StopFlying();
			if (!((Object)(object)base.playerHeldBy == (Object)null))
			{
				base.playerHeldBy.equippedUsableItemQE = false;
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (isFlying && (Object)(object)playerHoldingItem != (Object)null)
			{
				if (playerHoldingItem.isPlayerDead)
				{
					StopFlying();
					return;
				}
				playerHoldingItem.sprintMeter = 1f;
				HandleFlying();
			}
		}

		public override void LateUpdate()
		{
			//IL_008b: 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)
			((GrabbableObject)this).LateUpdate();
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && !((NetworkBehaviour)this).IsOwner)
			{
				if ((Object)(object)((Component)this).transform.parent != (Object)(object)base.playerHeldBy.serverItemHolder && (Object)(object)base.playerHeldBy.serverItemHolder != (Object)null)
				{
					((Component)this).transform.SetParent(base.playerHeldBy.serverItemHolder, false);
				}
				((Component)this).transform.localPosition = tpsPositionOffset;
				((Component)this).transform.localRotation = tpsRotationOffset;
			}
		}

		private void UpdateItemScale()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (base.isHeld || (Object)(object)base.playerHeldBy != (Object)null)
			{
				((Component)this).transform.localScale = handScale;
			}
			else
			{
				((Component)this).transform.localScale = handScale * 0.2f;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetScaleServerRpc(Vector3 newScale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4194129921u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref newScale);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 4194129921u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SetScaleClientRpc(newScale);
				}
			}
		}

		[ClientRpc]
		private void SetScaleClientRpc(Vector3 newScale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(958566157u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref newScale);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 958566157u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					((Component)this).transform.localScale = newScale;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ToggleAnimationServerRpc(bool open)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3824767211u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3824767211u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ToggleAnimationClientRpc(open);
				}
			}
		}

		[ClientRpc]
		private void ToggleAnimationClientRpc(bool open)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3003944447u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3003944447u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				ModMain.Instance.logger.LogDebug((object)$"[SpaceShuttleE] ToggleAnimationClientRpc recu, open={open}, animator null? {(Object)(object)animator == (Object)null}");
				if (!((Object)(object)animator == (Object)null))
				{
					animator.SetTrigger(Trigger);
				}
			}
		}

		private void HandleFlying()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_008c: 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_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			float x = playerHoldingItem.moveInputVector.x;
			float y = playerHoldingItem.moveInputVector.y;
			Transform transform = ((Component)playerHoldingItem.gameplayCamera).transform;
			Vector3 forward = transform.forward;
			Vector3 val = forward;
			Vector3 right = transform.right;
			val.y = 0f;
			right.y = 0f;
			((Vector3)(ref val)).Normalize();
			((Vector3)(ref right)).Normalize();
			Vector3 val2 = val * y + right * x;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float num = 0f;
			if (playerHoldingItem.isPlayerControlled)
			{
				if (IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).IsPressed())
				{
					num = 1f;
				}
				else if (IngamePlayerSettings.Instance.playerInput.actions.FindAction("Crouch", false).IsPressed())
				{
					num = -1f;
				}
			}
			if (num > 0f && (base.insertedBattery == null || base.insertedBattery.charge <= 0f))
			{
				num = 0f;
			}
			if (((NetworkBehaviour)this).IsOwner && num > 0f && base.insertedBattery != null)
			{
				base.insertedBattery.charge = Mathf.Max(0f, base.insertedBattery.charge - 0.02f * Time.deltaTime);
			}
			bool flag = (Object)(object)playerHoldingItem.thisController != (Object)null && playerHoldingItem.thisController.isGrounded;
			float num2 = (flag ? 0f : (currentSpeed * forward.y));
			if (!flag && num2 > 0f)
			{
				float num3 = 1f + Mathf.Clamp01(currentSpeed / 6f) * 0.3f;
				num2 *= num3;
			}
			Vector3 val3;
			if (!flag)
			{
				val2 = new Vector3(forward.x, 0f, forward.z);
				val3 = ((Vector3)(ref val2)).normalized * currentSpeed * Mathf.Clamp01(1f - Mathf.Abs(forward.y)) * 1f;
			}
			else
			{
				val3 = Vector3.zero;
			}
			Vector3 val4 = val3;
			if (!flag)
			{
				float num4 = num2 * Time.deltaTime;
				currentSpeed -= num4 * 1f;
				float num5 = Mathf.Clamp01(0f - forward.y);
				if (num5 > 0f)
				{
					currentSpeed += currentSpeed * num5 * 1.5f * Time.deltaTime;
				}
				currentSpeed = Mathf.Clamp(currentSpeed, 0f, 36f);
			}
			currentSpeed = Mathf.Max(0f, currentSpeed - (flag ? 15f : 2f) * Time.deltaTime);
			float num6 = Mathf.Clamp01(currentSpeed / 6f);
			float num7 = Mathf.Lerp(planeGravity * 3f, planeGravity, num6);
			float num8 = ((num != 0f) ? (num * verticalSpeed + num2) : (num7 + num2));
			if (fallCatchUpTimer < fallCatchUpDuration)
			{
				fallCatchUpTimer += Time.deltaTime;
				float num9 = Mathf.Clamp01(fallCatchUpTimer / fallCatchUpDuration);
				float num10 = num9 * num9 * (3f - 2f * num9);
				currentVerticalVelocity = Mathf.Lerp(initialFallVelocity, num8, num10);
			}
			else
			{
				currentVerticalVelocity = num8;
			}
			glideTimer += Time.deltaTime;
			float num11 = Mathf.Clamp01(glideTimer / 8f);
			float num12 = num11 * num11 * (3f - 2f * num11);
			float num13 = Mathf.Lerp(baseFlySpeed, baseFlySpeed * 2f, num12);
			Vector3 externalForces = normalized * num13 + val4;
			externalForces.y = currentVerticalVelocity;
			playerHoldingItem.externalForces = externalForces;
			playerHoldingItem.fallValue = 0f;
			playerHoldingItem.fallValueUncapped = 0f;
			float y2 = transform.eulerAngles.y;
			float num14 = Mathf.DeltaAngle(previousCameraYaw, y2);
			previousCameraYaw = y2;
			if (Mathf.Abs(num14) < 1.5f)
			{
				num14 = 0f;
			}
			float num15 = num14 / Time.deltaTime;
			float num16 = Mathf.Clamp((0f - num15) * 0.5f - x * 15f, -25f, 25f);
			currentRoll = Mathf.Lerp(currentRoll, num16, Time.deltaTime * 6f);
			Vector3 localEulerAngles = transform.localEulerAngles;
			transform.localRotation = Quaternion.Euler(localEulerAngles.x, localEulerAngles.y, currentRoll);
		}

		private void StopFlying()
		{
			//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_005a: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerHoldingItem != (Object)null)
			{
				isFlying = false;
				playerHoldingItem.externalForces = Vector3.zero;
				currentVerticalVelocity = 0f;
				if ((Object)(object)playerHoldingItem.gameplayCamera != (Object)null)
				{
					Vector3 localEulerAngles = ((Component)playerHoldingItem.gameplayCamera).transform.localEulerAngles;
					((Component)playerHoldingItem.gameplayCamera).transform.localRotation = Quaternion.Euler(localEulerAngles.x, localEulerAngles.y, 0f);
				}
			}
			playerHoldingItem = null;
			glideTimer = 0f;
			currentSpeed = 0f;
			currentRoll = 0f;
		}

		private void TriggerExplosion(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Landmine.SpawnExplosion(position, true, 0f, 0f, 0, 50f, (GameObject)null, false);
			ModMain.Instance.logger.LogDebug((object)"[Client] Landmine explosion spawned");
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(625665929u, new RpcReceiveHandler(__rpc_handler_625665929), "ActivateitemstsServerRpc");
			((NetworkBehaviour)this).__registerRpc(3105262298u, new RpcReceiveHandler(__rpc_handler_3105262298), "TriggerExplosionClientRpc");
			((NetworkBehaviour)this).__registerRpc(4194129921u, new RpcReceiveHandler(__rpc_handler_4194129921), "SetScaleServerRpc");
			((NetworkBehaviour)this).__registerRpc(958566157u, new RpcReceiveHandler(__rpc_handler_958566157), "SetScaleClientRpc");
			((NetworkBehaviour)this).__registerRpc(3824767211u, new RpcReceiveHandler(__rpc_handler_3824767211), "ToggleAnimationServerRpc");
			((NetworkBehaviour)this).__registerRpc(3003944447u, new RpcReceiveHandler(__rpc_handler_3003944447), "ToggleAnimationClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_625665929(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float newBatteryCharge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref newBatteryCharge, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).ActivateitemstsServerRpc(newBatteryCharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3105262298(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float newBatteryCharge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref newBatteryCharge, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).TriggerExplosionClientRpc(newBatteryCharge);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4194129921(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 scaleServerRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref scaleServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).SetScaleServerRpc(scaleServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_958566157(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 scaleClientRpc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref scaleClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).SetScaleClientRpc(scaleClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3824767211(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool open = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref open, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).ToggleAnimationServerRpc(open);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3003944447(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool open = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref open, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpaceShuttleE)(object)target).ToggleAnimationClientRpc(open);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SpaceShuttleE";
		}
	}
}
namespace LePlanDeResurection
{
	[BepInPlugin("LePlanDeResurection", "Le Plan De Resurection", "2.1.0")]
	[BepInDependency("LCTarotCard", "1.1.4")]
	public class ModMain : BaseUnityPlugin
	{
		public static ModMain Instance;

		public ManualLogSource logger;

		internal Harmony harmony;

		internal static KeyboardShortcut testkey = new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>());

		private void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)Instance == (Object)null))
			{
				return;
			}
			Instance = this;
			harmony = new Harmony("LePlanDeResurection");
			logger = Logger.CreateLogSource("LePlanDeResurection");
			harmony.PatchAll();
			logger.LogMessage((object)"                                                                            \n\n      db                                     mm    `7MMF'       7MMMMMMML \n     ;MM:                                    MM      MM          MM       \n    ,V^MM.    ,p6\"bo   ,6\"Yb.  `7MMpMMMb.  mmMMmm    MMpMMMb.    MM       \n   ,M  `MM   6M'  OO  8)   MM    MM    MM    MM      MM    MM    MMMMML   \n   AbmmmqMA  8M        ,pm9MM    MM    MM    MM      MM    MM    MM       \n  A'     VML YM.    , 8M   MM    MM    MM    MM      MM    MM    MM       \n.AMA.   .AMMA.YMbmd'  `Moo9^Yo..JMML  JMML.  `Mbmo .JMML  JMML..JMMMMMMML.\n");
			LePlanDeResurection.Assets.Assets.Init();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class Test
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void TestPatch(PlayerControllerB __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (((NetworkBehaviour)__instance).IsOwner && ((KeyboardShortcut)(ref ModMain.testkey)).IsDown() && 1 == 0)
			{
				GameObject val = Object.Instantiate<GameObject>(LePlanDeResurection.Assets.Assets.Spaceshuttle.spawnPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
				GrabbableObject component = val.GetComponent<GrabbableObject>();
				((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
				component.fallTime = 0f;
				component.scrapValue = 20000;
				NetworkObject component2 = val.GetComponent<NetworkObject>();
				component2.Spawn(false);
			}
		}
	}
}
namespace LePlanDeResurection.Util
{
	[HarmonyPatch]
	public class Networker : NetworkBehaviour
	{
		private static GameObject NetworkPrefab;

		public static Networker Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public override void OnNetworkDespawn()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void SpawnNetHandler()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				Object.Instantiate<GameObject>(NetworkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		private static void Init()
		{
			if (!((Object)(object)NetworkPrefab != (Object)null))
			{
				NetworkPrefab = LePlanDeResurection.Assets.Assets._aassetBundle.LoadAsset<GameObject>("Assets/network.prefab");
				NetworkPrefab.AddComponent<Networker>();
				NetworkManager.Singleton.AddNetworkPrefab(NetworkPrefab);
			}
		}

		[ClientRpc]
		public void ExplodeRandomPlayerClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1799687101u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1799687101u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					Landmine.SpawnExplosion(position, true, 0f, 6f, 42, 42f, (GameObject)null, false);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1799687101u, new RpcReceiveHandler(__rpc_handler_1799687101), "ExplodeRandomPlayerClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1799687101(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Networker)(object)target).ExplodeRandomPlayerClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Networker";
		}
	}
	public class SpawnRarity
	{
		private readonly Dictionary<Planet, int> rarities = new Dictionary<Planet, int>();

		private readonly Item item;

		private int defaultValue;

		public SpawnRarity(int baseValue, Item itemIn)
		{
			item = itemIn;
			defaultValue = baseValue;
			foreach (Planet value in Enum.GetValues(typeof(Planet)))
			{
				rarities.Add(value, baseValue);
			}
		}

		public int GetRarityFor(Planet planet)
		{
			return rarities[planet];
		}

		public int GetRarityFor(int planet)
		{
			return rarities.Values.ToList()[planet];
		}

		public void SetValues(int experimentation = -1, int assurance = -1, int vow = -1, int march = -1, int offense = -1, int adamance = -1, int rend = -1, int dine = -1, int titan = -1, int artifice = -1, int embrion = -1)
		{
			rarities[Planet.EXPERIMENTATION] = experimentation;
			rarities[Planet.ASSURANCE] = assurance;
			rarities[Planet.VOW] = vow;
			rarities[Planet.MARCH] = march;
			rarities[Planet.OFFENSE] = offense;
			rarities[Planet.ADAMANCE] = adamance;
			rarities[Planet.REND] = rend;
			rarities[Planet.DINE] = dine;
			rarities[Planet.TITAN] = titan;
			rarities[Planet.ARTIFICE] = artifice;
			rarities[Planet.EMBRION] = embrion;
		}

		public void CopyRaritiesFrom(SpawnRarity other)
		{
			rarities[Planet.EXPERIMENTATION] = other.rarities[Planet.EXPERIMENTATION];
			rarities[Planet.ASSURANCE] = other.rarities[Planet.ASSURANCE];
			rarities[Planet.VOW] = other.rarities[Planet.VOW];
			rarities[Planet.MARCH] = other.rarities[Planet.MARCH];
			rarities[Planet.OFFENSE] = other.rarities[Planet.OFFENSE];
			rarities[Planet.ADAMANCE] = other.rarities[Planet.ADAMANCE];
			rarities[Planet.REND] = other.rarities[Planet.REND];
			rarities[Planet.DINE] = other.rarities[Planet.DINE];
			rarities[Planet.TITAN] = other.rarities[Planet.TITAN];
			rarities[Planet.ARTIFICE] = other.rarities[Planet.ARTIFICE];
			rarities[Planet.EMBRION] = other.rarities[Planet.EMBRION];
		}

		public void Multiply(float factor)
		{
			foreach (Planet item in rarities.Keys.ToList())
			{
				rarities[item] = (int)((float)rarities[item] * factor);
			}
		}

		public SpawnableItemWithRarity GetSpawnableItemForPlanet(Planet planet)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return new SpawnableItemWithRarity(item, AccessRaritySafe((int)planet));
		}

		public SpawnableItemWithRarity GetSpawnableItemForPlanet(int planet)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return new SpawnableItemWithRarity(item, AccessRaritySafe(planet));
		}

		private int AccessRaritySafe(int planet)
		{
			try
			{
				return (rarities.Values.ToList()[planet] < 0) ? defaultValue : rarities.Values.ToList()[planet];
			}
			catch (Exception)
			{
			}
			return defaultValue;
		}

		public void ApplySpawnRarity(SelectableLevel level)
		{
			level.spawnableScrap.Add(GetSpawnableItemForPlanet(level.levelID));
		}
	}
	public enum Planet
	{
		EXPERIMENTATION,
		ASSURANCE,
		VOW,
		GORDION,
		MARCH,
		ADAMANCE,
		REND,
		DINE,
		OFFENSE,
		TITAN,
		ARTIFICE,
		LIQUIDATION,
		EMBRION
	}
}
namespace LePlanDeResurection.Item
{
	public class Blasteur2caca : GrabbableObject
	{
		private AudioSource _audioSource;

		public AudioClip tipi;

		public float soundVolume = 1f;

		[SerializeField]
		private float batteryUsagePerUse = 0.5f;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			if (base.insertedBattery != null)
			{
				base.insertedBattery.charge = 1f;
			}
			_audioSource = ((Component)this).GetComponent<AudioSource>();
			if ((Object)(object)_audioSource == (Object)null)
			{
				_audioSource = ((Component)this).GetComponentInChildren<AudioSource>();
			}
			if ((Object)(object)_audioSource == (Object)null)
			{
				_audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				ModMain.Instance.logger.LogDebug((object)"[BolDeCaca] AudioSource créé automatiquement");
			}
			_audioSource.spatialBlend = 1f;
			_audioSource.volume = soundVolume;
			_audioSource.minDistance = 1f;
			_audioSource.maxDistance = 50f;
			_audioSource.rolloffMode = (AudioRolloffMode)1;
			_audioSource.playOnAwake = false;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((NetworkBehaviour)this).IsOwner || !buttonDown || base.insertedBattery == null)
			{
				return;
			}
			if (base.insertedBattery.charge > 0f)
			{
				Battery insertedBattery = base.insertedBattery;
				insertedBattery.charge -= batteryUsagePerUse;
				UseitemServerRpc();
				SwapPlayerPositions();
				ModMain.Instance.logger.LogDebug((object)$"Batterie restante : {base.insertedBattery.charge * 100f}%");
				ModMain.Instance.logger.LogDebug((object)"item utilise%");
				if (base.insertedBattery.charge < 0f)
				{
					base.insertedBattery.charge = 0f;
				}
			}
			else
			{
				ModMain.Instance.logger.LogDebug((object)"Batterie vide, impossible d'utiliser l'item !");
			}
		}

		private void SwapPlayerPositions()
		{
			if ((Object)(object)base.playerHeldBy == (Object)null)
			{
				ModMain.Instance.logger.LogWarning((object)"Aucun joueur ne tient l'item !");
			}
			else if (((NetworkBehaviour)this).IsServer)
			{
				PerformSwap(base.playerHeldBy);
			}
			else
			{
				RequestSwapServerRpc(base.playerHeldBy.actualClientId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void RequestSwapServerRpc(ulong requesterId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(287025985u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, requesterId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 287025985u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = FindPlayerById(requesterId);
				if ((Object)(object)val3 != (Object)null)
				{
					PerformSwap(val3);
				}
			}
		}

		private PlayerControllerB FindPlayerById(ulong clientId)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.actualClientId == clientId && val.isPlayerControlled && !val.isPlayerDead)
				{
					return val;
				}
			}
			return null;
		}

		private bool IsPositionInsideFactory(Vector3 position)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RoundManager.Instance == (Object)null)
			{
				return false;
			}
			GameObject[] insideAINodes = RoundManager.Instance.insideAINodes;
			GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			if (insideAINodes != null)
			{
				GameObject[] array = insideAINodes;
				foreach (GameObject val in array)
				{
					if (!((Object)(object)val == (Object)null))
					{
						float num3 = Vector3.Distance(position, val.transform.position);
						if (num3 < num)
						{
							num = num3;
						}
					}
				}
			}
			if (outsideAINodes != null)
			{
				GameObject[] array2 = outsideAINodes;
				foreach (GameObject val2 in array2)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						float num4 = Vector3.Distance(position, val2.transform.position);
						if (num4 < num2)
						{
							num2 = num4;
						}
					}
				}
			}
			return num < num2;
		}

		private void PerformSwap(PlayerControllerB playerA)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0103: 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_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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead && !((Object)(object)val == (Object)(object)playerA))
				{
					list.Add(val);
				}
			}
			if (list.Count == 0)
			{
				ModMain.Instance.logger.LogWarning((object)"Aucun autre joueur disponible pour l'échange !");
				NotifyNoPlayerAvailableClientRpc(playerA.actualClientId);
				return;
			}
			PlayerControllerB val2 = list[Random.Range(0, list.Count)];
			if ((Object)(object)val2 == (Object)null || val2.isPlayerDead)
			{
				ModMain.Instance.logger.LogError((object)"Le joueur B sélectionné est invalide ou mort !");
				return;
			}
			Vector3 position = ((Component)playerA).transform.position;
			Vector3 position2 = ((Component)val2).transform.position;
			Quaternion rotation = ((Component)playerA).transform.rotation;
			Quaternion rotation2 = ((Component)val2).transform.rotation;
			ModMain.Instance.logger.LogDebug((object)$"[Server] Swap START: {playerA.playerUsername} @ {position} <-> {val2.playerUsername} @ {position2}");
			((MonoBehaviour)this).StartCoroutine(PerformSwapWithDelay(playerA, val2, position, position2, rotation, rotation2));
		}

		[ClientRpc]
		private void NotifyNoPlayerAvailableClientRpc(ulong playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(37845483u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 37845483u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB val3 = FindPlayerById(playerId);
				if ((Object)(object)val3 != (Object)null && ((NetworkBehaviour)val3).IsOwner)
				{
					HUDManager.Instance.DisplayTip("Swap Item", "Aucun joueur disponible pour l'echange !", true, false, "LC_Tip1");
				}
			}
		}

		private IEnumerator PerformSwapWithDelay(PlayerControllerB playerA, PlayerControllerB playerB, Vector3 posA, Vector3 posB, Quaternion rotA, Quaternion rotB)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			if ((Object)(object)playerA == (Object)null || (Object)(object)playerB == (Object)null || playerA.isPlayerDead || playerB.isPlayerDead)
			{
				ModMain.Instance.logger.LogError((object)"Un des joueurs est devenu invalide pendant le swap !");
				yield break;
			}
			CharacterController controllerA = ((Component)playerA).GetComponent<CharacterController>();
			CharacterController controllerB = ((Component)playerB).GetComponent<CharacterController>();
			bool playerAInsideApresSwap = IsPositionInsideFactory(posB);
			bool playerBInsideApresSwap = IsPositionInsideFactory(posA);
			bool wasEnabledA = (Object)(object)controllerA != (Object)null && ((Collider)controllerA).enabled;
			bool wasEnabledB = (Object)(object)controllerB != (Object)null && ((Collider)controllerB).enabled;
			if ((Object)(object)controllerA != (Object)null)
			{
				((Collider)controllerA).enabled = false;
			}
			if ((Object)(object)controllerB != (Object)null)
			{
				((Collider)controllerB).enabled = false;
			}
			yield return null;
			if ((Object)(object)playerB != (Object)null && !playerB.isPlayerDead)
			{
				playerB.TeleportPlayer(posA, false, 0f, false, true);
				playerB.isInsideFactory = playerBInsideApresSwap;
			}
			yield return (object)new WaitForSeconds(0.1f);
			if ((Object)(object)playerA != (Object)null && !playerA.isPlayerDead)
			{
				playerA.TeleportPlayer(posB, false, 0f, false, true);
				playerA.isInsideFactory = playerAInsideApresSwap;
			}
			yield return (object)new WaitForSeconds(0.1f);
			if ((Object)(object)controllerA != (Object)null && wasEnabledA)
			{
				((Collider)controllerA).enabled = true;
			}
			if ((Object)(object)controllerB != (Object)null && wasEnabledB)
			{
				((Collider)controllerB).enabled = true;
			}
			ResetPlayerPhysics(playerA);
			ResetPlayerPhysics(playerB);
			if ((Object)(object)playerA != (Object)null && !playerA.isPlayerDead)
			{
				((Component)playerA).transform.rotation = rotB;
			}
			if ((Object)(object)playerB != (Object)null && !playerB.isPlayerDead)
			{
				((Component)playerB).transform.rotation = rotA;
			}
			SyncPlayer