Decompiled source of RCCars v1.0.3

RCCars.dll

Decompiled an hour 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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using RCCars.Scripts;
using StaticNetcodeLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RCCars")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("RCCars")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dd886e93ca1d5de94fe92744948ca5169377e5cd")]
[assembly: AssemblyProduct("RCCars")]
[assembly: AssemblyTitle("RCCars")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RCCars
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("wexop.rc_cars", "RCCars", "1.0.3")]
	public class RCCarsPlugin : BaseUnityPlugin
	{
		private const string GUID = "wexop.rc_cars";

		private const string NAME = "RCCars";

		private const string VERSION = "1.0.3";

		public static RCCarsPlugin instance;

		public Dictionary<ulong, RegistredCar> RegistredCars = new Dictionary<ulong, RegistredCar>();

		public ConfigEntry<float> honkVolume;

		public ConfigEntry<float> engineVolume;

		public ConfigEntry<float> rotationSpeed;

		public ConfigEntry<int> explosionDamage;

		public ConfigEntry<float> syncInterval;

		public ConfigEntry<int> carPrice;

		public ConfigEntry<int> policeCarPrice;

		public ConfigEntry<int> ambulanceCarPrice;

		public ConfigEntry<int> sportCarPrice;

		public ConfigEntry<int> bombCarPrice;

		public ConfigEntry<int> cruiserCarPrice;

		private void Awake()
		{
			instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RCCars starting....");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rccars");
			AssetBundle bundle = AssetBundle.LoadFromFile(text);
			LoadConfigs();
			RegisterCar(bundle);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RCCars ready !!");
		}

		private void RegisterCar(AssetBundle bundle)
		{
			Item val = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCCar.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterItem(val);
			Items.RegisterShopItem(val, instance.carPrice.Value);
			Item val2 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCCarPolice.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val2).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val2.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterItem(val2);
			Items.RegisterShopItem(val2, instance.policeCarPrice.Value);
			Item val3 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCCarAmbulance.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val3).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val3.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			Items.RegisterItem(val3);
			Items.RegisterShopItem(val3, instance.ambulanceCarPrice.Value);
			Item val4 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCSportCar.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val4).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val4.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Utilities.FixMixerGroups(val4.spawnPrefab);
			Items.RegisterItem(val4);
			Items.RegisterShopItem(val4, instance.sportCarPrice.Value);
			Item val5 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCCarBomb.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val5).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val5.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Utilities.FixMixerGroups(val5.spawnPrefab);
			Items.RegisterItem(val5);
			Items.RegisterShopItem(val5, instance.bombCarPrice.Value);
			Item val6 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/RCCars/RCCruiserCar.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val6).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val6.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
			Utilities.FixMixerGroups(val6.spawnPrefab);
			Items.RegisterItem(val6);
			Items.RegisterShopItem(val6, instance.cruiserCarPrice.Value);
		}

		public void LoadConfigs()
		{
			honkVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "honkVolume", 1f, "Honk volume. No need to restart the game :)");
			CreateFloatConfig(honkVolume, 0f, 2f);
			engineVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "engineVolume", 0.2f, "Engine volume. No need to restart the game :)");
			CreateFloatConfig(engineVolume, 0f, 2f);
			rotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "rotationSpeed", 7f, "Cars rotation speed. No need to restart the game :)");
			CreateFloatConfig(rotationSpeed, 0f, 200f);
			explosionDamage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "explosionDamage", 50, "Cars explosion damage on destroy. No need to restart the game :)");
			CreateIntConfig(explosionDamage, 0, 200);
			syncInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "syncInterval", 0.35f, "Cars sync interval between players. No need to restart the game :)");
			CreateFloatConfig(syncInterval, 0f, 2f);
			carPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "carPrice", 100, "Normal car price. You need to restart the game.");
			CreateIntConfig(carPrice, 0, 1000, restart: true);
			policeCarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "policeCarPrice", 150, "Police car price. You need to restart the game.");
			CreateIntConfig(policeCarPrice, 0, 1000, restart: true);
			ambulanceCarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "ambulanceCarPrice", 175, "Ambulance car price. You need to restart the game.");
			CreateIntConfig(ambulanceCarPrice, 0, 1000, restart: true);
			sportCarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "sportCarPrice", 200, "Sport car price. You need to restart the game.");
			CreateIntConfig(sportCarPrice, 0, 1000, restart: true);
			bombCarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "bombCarPrice", 75, "Bomb car price. You need to restart the game.");
			CreateIntConfig(bombCarPrice, 0, 1000, restart: true);
			cruiserCarPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Price", "cruiserCarPrice", 125, "Cruiser car price. You need to restart the game.");
			CreateIntConfig(cruiserCarPrice, 0, 1000, restart: true);
		}

		private void CreateFloatConfig(ConfigEntry<float> configEntry, float min = 0f, float max = 100f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = min;
			((BaseRangeOptions<float>)val).Max = max;
			((BaseOptions)val).RequiresRestart = false;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(configEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateIntConfig(ConfigEntry<int> configEntry, int min = 0, int max = 100, bool restart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = min;
			((BaseRangeOptions<int>)val).Max = max;
			((BaseOptions)val).RequiresRestart = restart;
			IntSliderConfigItem val2 = new IntSliderConfigItem(configEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateStringConfig(ConfigEntry<string> configEntry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			TextInputFieldConfigItem val = new TextInputFieldConfigItem(configEntry, new TextInputFieldOptions
			{
				RequiresRestart = false
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
		}

		private void CreateBoolConfig(ConfigEntry<bool> configEntry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(configEntry, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RCCars";

		public const string PLUGIN_NAME = "RCCars";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RCCars.Scripts
{
	public class RCBombCarItem : RCCarItem
	{
		public override void Honk()
		{
			SetNewHealth(0);
		}
	}
	public class RCCarItem : PhysicsProp, IHittable
	{
		public Rigidbody rigidbody;

		public NavMeshAgent navMeshAgent;

		public TextMeshProUGUI playerText;

		public List<Light> carLights;

		public Light carVisionLight;

		public Color carLightsColor;

		public Camera carCamera;

		public Transform itemHeldPosition;

		public AudioSource SfxAudioSource;

		public AudioSource drivingAudioSource;

		public GameObject carBody;

		public AudioClip honkAudio;

		public AudioClip drivingLoop;

		public GrabbableObject itemHeld;

		public float speed = 0.4f;

		public float syncInterval = 0.5f;

		public bool playerIsDriving;

		public bool playerIsLocal;

		public float honkInterval = 1f;

		public float rotationSpeed = 10f;

		public int MaxHealth = 2;

		public int Health = 2;

		public ParticleSystem smokeParticules;

		public ParticleSystem explosion;

		public AudioClip explosionAudio;

		public float explosionRange;

		private PlayerControllerB playerDriving;

		private Camera playerCamera;

		private Ray interactRay;

		private RaycastHit hit;

		private Vector3 dropPos;

		private bool shouldBeDropPos;

		private bool carIsMoving;

		private bool lastFrameCarIsMoving;

		private float interactTimer;

		private float honkTimer;

		private float posSyncTimer;

		private float hitTimer;

		public void RegisterCar()
		{
			if (RCCarsPlugin.instance.RegistredCars.ContainsKey(((NetworkBehaviour)this).NetworkObjectId))
			{
				RCCarsPlugin.instance.RegistredCars.Remove(((NetworkBehaviour)this).NetworkObjectId);
			}
			RegistredCar registredCar = new RegistredCar();
			registredCar.networkObjectId = ((NetworkBehaviour)this).NetworkObjectId;
			registredCar.rcCarItem = this;
			RCCarsPlugin.instance.RegistredCars.Add(((NetworkBehaviour)this).NetworkObjectId, registredCar);
		}

		public void RefreshPluginValues()
		{
			drivingAudioSource.volume = RCCarsPlugin.instance.engineVolume.Value;
			SfxAudioSource.volume = RCCarsPlugin.instance.honkVolume.Value;
			rotationSpeed = RCCarsPlugin.instance.rotationSpeed.Value;
			syncInterval = RCCarsPlugin.instance.syncInterval.Value;
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			EnableCamera(enable: false);
			CarLights(on: false);
			navMeshAgent.speed = 50f;
			((Behaviour)navMeshAgent).enabled = false;
			RegisterCar();
			RefreshPluginValues();
			((TMP_Text)playerText).text = "";
		}

		public void EnableCamera(bool enable)
		{
			((Component)carCamera).gameObject.SetActive(enable);
		}

		public void CarLights(bool on)
		{
			carLights.ForEach(delegate(Light l)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				l.color = (on ? carLightsColor : Color.black);
			});
			((Behaviour)carVisionLight).enabled = on;
		}

		public void ChangeToolTips()
		{
			List<string> list = new List<string> { "[G] Leave RCCar", "[LMB] Honk" };
			if ((Object)(object)itemHeld != (Object)null)
			{
				list.Add("[E] Drop " + itemHeld.itemProperties.itemName);
			}
			HUDManager.Instance.ClearControlTips();
			HUDManager.Instance.ChangeControlTipMultiple(list.ToArray(), false, (Item)null);
		}

		public IEnumerator SetPlayerBack(PlayerControllerB player)
		{
			yield return (object)new WaitForSeconds((Health <= 0) ? 0.8f : 0f);
			EnableCamera(enable: false);
			if ((Object)(object)playerCamera != (Object)null)
			{
				player.gameplayCamera = playerCamera;
			}
			player.disableMoveInput = false;
			player.disableLookInput = false;
			player.disableInteract = false;
			HUDManager.Instance.ClearControlTips();
		}

		public void ChangePlayerControls(PlayerControllerB player, bool driving)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			RefreshPluginValues();
			playerIsLocal = player.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId;
			if (player.isInHangarShipRoom && driving)
			{
				if (playerIsLocal)
				{
					HUDManager.Instance.DisplayTip("Warning", "You can't drive in the ship !", false, false, "LC_Tip1");
				}
				return;
			}
			if (RoundManager.Instance.currentLevel.PlanetName.Contains("Gordion") && driving)
			{
				if (playerIsLocal)
				{
					HUDManager.Instance.DisplayTip("Warning", "You can't drive in company building !", false, false, "LC_Tip1");
				}
				return;
			}
			dropPos = ((Component)this).transform.localPosition;
			playerIsDriving = driving;
			((GrabbableObject)this).grabbable = !driving;
			CarLights(driving);
			rigidbody.useGravity = driving;
			((Behaviour)navMeshAgent).enabled = driving;
			if (driving)
			{
				if (playerIsLocal)
				{
					EnableCamera(enable: true);
					player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
					playerCamera = player.gameplayCamera;
					player.gameplayCamera = carCamera;
					player.disableMoveInput = true;
					player.disableLookInput = true;
					player.disableInteract = true;
					ChangeToolTips();
				}
				else
				{
					((TMP_Text)playerText).text = player.playerUsername;
				}
				((GrabbableObject)this).targetFloorPosition = ((GrabbableObject)this).GetItemFloorPosition(((Component)this).transform.localPosition);
				((GrabbableObject)this).parentObject = null;
				honkTimer = honkInterval - 1f;
				playerDriving = player;
			}
			else
			{
				if (playerIsLocal)
				{
					((MonoBehaviour)this).StartCoroutine(SetPlayerBack(player));
				}
				((GrabbableObject)this).parentObject = null;
				((TMP_Text)playerText).text = "";
				((GrabbableObject)this).reachedFloorTarget = false;
				((Component)this).transform.localPosition = dropPos;
				((GrabbableObject)this).startFallingPosition = dropPos;
				((GrabbableObject)this).FallToGround(false);
				((GrabbableObject)this).grabbable = true;
				DropHeldItem();
				drivingAudioSource.Stop();
				playerIsLocal = false;
			}
		}

		public void OnStopUsingCar(Vector3 pos)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)playerDriving))
			{
				((Component)this).transform.position = pos;
				if (playerIsLocal)
				{
					ChangePlayerControls(GameNetworkManager.Instance.localPlayerController, driving: false);
				}
				else
				{
					ChangePlayerControls(playerDriving, driving: false);
				}
			}
		}

		public void DropHeldItem()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)itemHeld == (Object)null))
			{
				itemHeld.reachedFloorTarget = false;
				((Component)itemHeld).transform.position = ((Component)itemHeld).transform.position;
				itemHeld.targetFloorPosition = ((Component)itemHeld).transform.position;
				itemHeld.startFallingPosition = ((Component)itemHeld).transform.position;
				itemHeld.FallToGround(false);
				itemHeld.grabbable = true;
				itemHeld = null;
				ChangeToolTips();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (Object.op_Implicit((Object)(object)((GrabbableObject)this).playerHeldBy))
			{
				ChangePlayerControls(((GrabbableObject)this).playerHeldBy, driving: true);
			}
		}

		public void GrabItem(GrabbableObject item)
		{
			DropHeldItem();
			itemHeld = item;
			itemHeld.grabbable = false;
			ChangeToolTips();
		}

		public void HonkOnEveryClient()
		{
			RCCarNetwork.CarHonkServerRpc(((NetworkBehaviour)this).NetworkObjectId);
		}

		public virtual void Honk()
		{
			RefreshPluginValues();
			SfxAudioSource.clip = honkAudio;
			SfxAudioSource.Play();
			honkTimer = 0f;
		}

		public void SyncPositionClient(Vector3 pos)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)playerDriving) && !playerIsLocal && ((Behaviour)navMeshAgent).enabled)
			{
				navMeshAgent.SetDestination(pos);
			}
		}

		public void StopDrivingSoundClient(bool turnOff)
		{
			if (turnOff)
			{
				drivingAudioSource.Stop();
			}
			else
			{
				drivingAudioSource.Play();
			}
		}

		public override void Update()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			hitTimer += Time.deltaTime;
			if (Object.op_Implicit((Object)(object)playerDriving) && !playerIsLocal)
			{
				Vector3 velocity = navMeshAgent.velocity;
				carIsMoving = !((Vector3)(ref velocity)).Equals(Vector3.zero);
				if (carIsMoving != lastFrameCarIsMoving)
				{
					lastFrameCarIsMoving = carIsMoving;
					if (!carIsMoving)
					{
						drivingAudioSource.Stop();
					}
					else
					{
						drivingAudioSource.clip = drivingLoop;
						drivingAudioSource.Play();
					}
				}
			}
			if (shouldBeDropPos)
			{
				((Component)this).transform.position = dropPos;
				shouldBeDropPos = false;
			}
			if (!playerIsDriving)
			{
				((GrabbableObject)this).Update();
			}
			if (!playerIsDriving || !playerIsLocal)
			{
				return;
			}
			if (playerDriving.isPlayerDead)
			{
				RCCarNetwork.StopUseCarServerRpc(((NetworkBehaviour)this).NetworkObjectId, ((Component)this).transform.position);
			}
			if (!playerIsDriving)
			{
				return;
			}
			interactTimer += Time.deltaTime;
			honkTimer += Time.deltaTime;
			posSyncTimer += Time.deltaTime;
			float num = IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false).ReadValue<float>();
			if (num > 0f && honkTimer >= honkInterval)
			{
				HonkOnEveryClient();
			}
			Vector3 val = Vector2.op_Implicit(IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).ReadValue<Vector2>());
			if (val.x != 0f || val.y != 0f)
			{
				if (!drivingAudioSource.isPlaying)
				{
					drivingAudioSource.clip = drivingLoop;
					drivingAudioSource.Play();
				}
				if (val.y > 0f)
				{
					navMeshAgent.Move(((Component)this).transform.forward * speed * Time.deltaTime);
				}
				((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y + val.x * rotationSpeed, 0f);
			}
			else
			{
				drivingAudioSource.Stop();
			}
		}

		public override void LateUpdate()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			if (!playerIsDriving)
			{
				((GrabbableObject)this).LateUpdate();
			}
			if ((Object)(object)itemHeld != (Object)null)
			{
				((GrabbableObject)this).reachedFloorTarget = false;
				itemHeld.targetFloorPosition = itemHeldPosition.position;
				itemHeld.startFallingPosition = itemHeldPosition.position;
				((Component)itemHeld).gameObject.transform.position = itemHeldPosition.position + Vector3.up * (float)itemHeld.itemProperties.floorYOffset;
			}
			if (!playerIsDriving || !playerIsLocal)
			{
				return;
			}
			float num = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false).ReadValue<float>();
			if (num > 0f && (Object)(object)itemHeld != (Object)null && interactTimer >= 1f)
			{
				interactTimer = 0f;
				RCCarNetwork.CarDropItemServerRpc(((NetworkBehaviour)this).NetworkObjectId);
				ChangeToolTips();
			}
			float num2 = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).ReadValue<float>();
			if (num2 > 0f)
			{
				RCCarNetwork.StopUseCarServerRpc(((NetworkBehaviour)this).NetworkObjectId, ((Component)this).transform.position);
			}
			interactRay = new Ray(((Component)this).transform.position, ((Component)this).transform.forward);
			if (Physics.Raycast(interactRay, ref hit, 10f, 1073742656) && ((Component)((RaycastHit)(ref hit)).collider).gameObject.layer != 8 && ((Component)((RaycastHit)(ref hit)).collider).gameObject.layer != 30)
			{
				GrabbableObject component = ((Component)((RaycastHit)(ref hit)).collider).gameObject.GetComponent<GrabbableObject>();
				if (component.grabbable)
				{
					((TMP_Text)GameNetworkManager.Instance.localPlayerController.cursorTip).text = "Grab : [E]";
					if (num > 0f)
					{
						interactTimer = 0f;
						RCCarNetwork.CarGrabItemServerRpc(((NetworkBehaviour)this).NetworkObjectId, ((NetworkBehaviour)component).NetworkObjectId);
					}
				}
			}
			if (posSyncTimer >= syncInterval)
			{
				posSyncTimer = 0f;
				RCCarNetwork.SyncCarPositionServerRpc(((NetworkBehaviour)this).NetworkObjectId, ((Component)this).transform.position);
			}
		}

		public void SetNewHealth(int health)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			Health = health;
			if (Health < MaxHealth && !smokeParticules.isPlaying)
			{
				smokeParticules.Play();
			}
			if (Health > 0)
			{
				return;
			}
			explosion.Play();
			SfxAudioSource.PlayOneShot(explosionAudio);
			RCCarNetwork.StopUseCarServerRpc(((NetworkBehaviour)this).NetworkObjectId, ((Component)this).transform.position);
			if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position) <= explosionRange)
			{
				GameNetworkManager.Instance.localPlayerController.DamagePlayer(RCCarsPlugin.instance.explosionDamage.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			}
			List<EnemyAI> list = Object.FindObjectsOfType<EnemyAI>().ToList();
			list.ForEach(delegate(EnemyAI enemy)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Vector3.Distance(((Component)enemy).transform.position, ((Component)this).transform.position) <= explosionRange)
				{
					enemy.HitEnemy(3, (PlayerControllerB)null, false, -1);
				}
			});
			List<RCCarItem> list2 = Object.FindObjectsOfType<RCCarItem>().ToList();
			list2.ForEach(delegate(RCCarItem car)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)car).NetworkObjectId != ((NetworkBehaviour)this).NetworkObjectId && car.Health > 0 && Vector3.Distance(((Component)car).transform.position, ((Component)this).transform.position) <= explosionRange && ((NetworkBehaviour)this).IsServer)
				{
					RCCarNetwork.SetCarHealthServerRpc(((NetworkBehaviour)car).NetworkObjectId, car.Health - 2);
				}
			});
			((MonoBehaviour)this).StartCoroutine(DestroyObject());
		}

		public IEnumerator DestroyObject()
		{
			carBody.SetActive(false);
			yield return (object)new WaitForSeconds(1f);
			RCCarsPlugin.instance.RegistredCars.Remove(((NetworkBehaviour)this).NetworkObjectId);
			if (((NetworkBehaviour)this).IsServer)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (hitTimer >= 0.2f)
			{
				hitTimer = 0f;
				RCCarNetwork.SetCarHealthServerRpc(((NetworkBehaviour)this).NetworkObjectId, Health - force);
			}
			return true;
		}
	}
	[StaticNetcode]
	public class RCCarNetwork
	{
		public static RegistredCar GetRegistredCar(ulong networkId)
		{
			RegistredCar registredCar = null;
			if (RCCarsPlugin.instance.RegistredCars.ContainsKey(networkId))
			{
				registredCar = RCCarsPlugin.instance.RegistredCars[networkId];
			}
			if (registredCar == null)
			{
				Debug.LogError((object)$"COULD NOT FOUND CAR WITH ID {networkId}");
			}
			return registredCar;
		}

		public static GrabbableObject GetItem(ulong networkId)
		{
			List<GrabbableObject> list = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0).ToList();
			GrabbableObject val = list.Find((GrabbableObject e) => ((NetworkBehaviour)e).NetworkObjectId == networkId);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)$"COULD NOT FOUND ITEM WITH ID {networkId}");
			}
			return val;
		}

		[ServerRpc]
		public static void CarHonkServerRpc(ulong networkId)
		{
			CarHonkClientRpc(networkId);
		}

		[ClientRpc]
		public static void CarHonkClientRpc(ulong networkId)
		{
			GetRegistredCar(networkId)?.rcCarItem.Honk();
		}

		[ServerRpc]
		public static void StopUseCarServerRpc(ulong networkId, Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			StopUseCarClientRpc(networkId, pos);
		}

		[ClientRpc]
		public static void StopUseCarClientRpc(ulong networkId, Vector3 pos)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GetRegistredCar(networkId)?.rcCarItem.OnStopUsingCar(pos);
		}

		[ServerRpc]
		public static void UpdateDrivingSoundServerRpc(ulong networkId, bool value)
		{
			UpdateDrivingSoundClientRpc(networkId, value);
		}

		[ClientRpc]
		public static void UpdateDrivingSoundClientRpc(ulong networkId, bool value)
		{
			GetRegistredCar(networkId)?.rcCarItem.StopDrivingSoundClient(value);
		}

		[ServerRpc]
		public static void CarGrabItemServerRpc(ulong networkId, ulong itemNetworkId)
		{
			CarGrabItemClientRpc(networkId, itemNetworkId);
		}

		[ClientRpc]
		public static void CarGrabItemClientRpc(ulong networkId, ulong itemNetworkId)
		{
			RegistredCar registredCar = GetRegistredCar(networkId);
			if (registredCar != null)
			{
				GrabbableObject item = GetItem(itemNetworkId);
				if (!((Object)(object)item == (Object)null))
				{
					registredCar.rcCarItem.GrabItem(item);
				}
			}
		}

		[ServerRpc]
		public static void CarDropItemServerRpc(ulong networkId)
		{
			CarDropItemClientRpc(networkId);
		}

		[ClientRpc]
		public static void CarDropItemClientRpc(ulong networkId)
		{
			GetRegistredCar(networkId)?.rcCarItem.DropHeldItem();
		}

		[ServerRpc]
		public static void SyncCarPositionServerRpc(ulong networkId, Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			SyncCarPositionClientRpc(networkId, pos);
		}

		[ClientRpc]
		public static void SyncCarPositionClientRpc(ulong networkId, Vector3 pos)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GetRegistredCar(networkId)?.rcCarItem.SyncPositionClient(pos);
		}

		[ServerRpc]
		public static void SetCarHealthServerRpc(ulong networkId, int health)
		{
			SetCarHealthClientRpc(networkId, health);
		}

		[ClientRpc]
		public static void SetCarHealthClientRpc(ulong networkId, int health)
		{
			GetRegistredCar(networkId)?.rcCarItem.SetNewHealth(health);
		}
	}
	public class RCPoliceCarItem : RCCarItem
	{
		public List<Light> blueLights;

		private bool blueLightsAnimationRunning;

		private int actualBlueLightEnabled;

		private float blueLightsAnimationTimer;

		private float blueLightsInterval = 0.5f;

		public override void Start()
		{
			TurnOffBlueLights();
			base.Start();
		}

		public void SwitchBlueLights()
		{
			((Behaviour)blueLights[0]).enabled = actualBlueLightEnabled == 1;
			((Behaviour)blueLights[1]).enabled = actualBlueLightEnabled == 0;
			actualBlueLightEnabled = ((actualBlueLightEnabled == 0) ? 1 : 0);
		}

		public void TurnOffBlueLights()
		{
			blueLights.ForEach(delegate(Light l)
			{
				((Behaviour)l).enabled = false;
			});
		}

		public IEnumerator RunBlueLightsAnimation()
		{
			yield return (object)new WaitForSeconds(10f);
			blueLightsAnimationRunning = false;
			TurnOffBlueLights();
		}

		public override void Honk()
		{
			base.Honk();
			blueLightsAnimationRunning = true;
			((MonoBehaviour)this).StopCoroutine(RunBlueLightsAnimation());
			((MonoBehaviour)this).StartCoroutine(RunBlueLightsAnimation());
		}

		public override void Update()
		{
			if (blueLightsAnimationRunning)
			{
				blueLightsAnimationTimer += Time.deltaTime;
				if (blueLightsAnimationTimer >= blueLightsInterval)
				{
					SwitchBlueLights();
					blueLightsAnimationTimer = 0f;
				}
			}
			base.Update();
		}
	}
	public class RegistredCar
	{
		public ulong networkObjectId;

		public RCCarItem rcCarItem;
	}
}