Decompiled source of The Company Pistol v1.0.0

CompanyPistol.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using Class1;
using CompanyPistol.Scripts;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CompanyPistol.Scripts
{
	internal class _1911_Script : PhysicsProp
	{
		private enum ImpactType
		{
			None,
			Rock,
			Metal,
			Gravel,
			Wood,
			Grass,
			Snow,
			Bush,
			Water,
			Untagged
		}

		[DefaultExecutionOrder(1000)]
		private class ReloadTiltApplier : MonoBehaviour
		{
			public _1911_Script owner;

			private void LateUpdate()
			{
				if ((Object)(object)owner != (Object)null)
				{
					owner.ApplyReloadTilt();
				}
			}
		}

		private struct ShotExtras
		{
			public bool hitVehicle;

			public Vector3 vehiclePoint;

			public Quaternion vehicleRotation;

			public int ammoLeft;

			public bool startReload;

			public bool igniteHood;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnShotMessage;

			public static HandleNamedMessageDelegate <1>__OnFxMessage;

			public static HandleNamedMessageDelegate <2>__OnDamageMessage;
		}

		private Item RockSound;

		private Item MetalSound;

		private Item GravelSound;

		private Item WaterSound;

		private Item WoodSound;

		private Item UntaggedSound;

		private Item GrassSound;

		private Item SnowSound;

		private Item BushSound;

		private Item ReloadSound;

		private bool canShoot;

		private const int MagazineSize = 11;

		private const float ReloadTiltDegrees = 35f;

		private const float FallbackReloadSeconds = 2.5f;

		private int displayAmmo = 11;

		private float reloadStartTime = -100f;

		private float reloadEndTime = -100f;

		private ReloadTiltApplier tiltApplier;

		private int serverAmmo = 11;

		private float serverReloadEndTime;

		private float lastShotFeedbackTime = -10f;

		private const string ShotMessageName = "CompanyPistol.Shot";

		private const string FxMessageName = "CompanyPistol.Fx";

		private const string DamageMessageName = "CompanyPistol.Damage";

		private static CustomMessagingManager registeredMessenger;

		private const bool PlayersCanDamagePlayers = true;

		private const int PlayerShotDamage = 8;

		private const float MaxOriginDrift = 8f;

		private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static bool cruiserApiLogged;

		private const int RadMechInactiveState = 0;

		private const int RadMechActiveState = 1;

		private const int ShotsToExplodeCruiser = 12;

		private const int HoodFireShotsRemaining = 5;

		private const int FallbackCruiserHp = 50;

		private static readonly Dictionary<int, int> cruiserShots = new Dictionary<int, int>();

		private static readonly Dictionary<int, int> cruiserMaxHp = new Dictionary<int, int>();

		private Material sparkMaterial;

		private static readonly HashSet<int> ignitedCruisers = new HashSet<int>();

		private static bool hoodFireApiLogged;

		private static bool radMechApiLogged;

		private static GUIStyle ammoStyle;

		private static GUIStyle ammoShadowStyle;

		private bool isReloading => Time.time < reloadEndTime;

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			canShoot = true;
			LoadSoundItems();
			EnsureTiltApplier();
		}

		private void LoadSoundItems()
		{
			PluginForThePistol instance = PluginForThePistol.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				RockSound = instance.SoundObjectRock;
				MetalSound = instance.SoundObjectMetal;
				GravelSound = instance.SoundObjectGravel;
				WaterSound = instance.SoundObjectWater;
				WoodSound = instance.SoundObjectWood;
				UntaggedSound = instance.SoundObjectUntagged;
				GrassSound = instance.SoundObjectGrass;
				SnowSound = instance.SoundObjectSnow;
				BushSound = instance.SoundObjectBush;
				ReloadSound = instance.SoundObjectReload;
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown || !canShoot || (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null || isReloading)
			{
				return;
			}
			canShoot = false;
			((MonoBehaviour)this).StartCoroutine(WaitForShotDelay());
			PlayShotFeedbackOnce();
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if (!((Object)(object)val != (Object)null) || !((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)(object)val))
			{
				displayAmmo = Mathf.Max(0, displayAmmo - 1);
				Vector3 position = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.position;
				Vector3 forward = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.forward;
				Vector3 normalized = ((Vector3)(ref forward)).normalized;
				if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening)
				{
					SendShotRequest(position, normalized);
				}
				else
				{
					ResolveShot(0uL, position, normalized);
				}
			}
		}

		private bool ClaimShotFeedback()
		{
			if (Time.time - lastShotFeedbackTime < 0.4f)
			{
				return false;
			}
			lastShotFeedbackTime = Time.time;
			return true;
		}

		private void PlayShotFeedbackOnce()
		{
			if (ClaimShotFeedback())
			{
				PlayLocalMuzzleAndGunshot();
			}
		}

		private void PlayLocalMuzzleAndGunshot()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.itemAudio != (Object)null && (Object)(object)PluginForThePistol.instance != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.itemAudio.PlayOneShot(PluginForThePistol.instance.Shoot);
			}
			ParticleSystem componentInChildren = ((Component)this).GetComponentInChildren<ParticleSystem>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.Play();
			}
		}

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

		private static void RegisterMessageHandlers()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null && registeredMessenger != singleton.CustomMessagingManager)
			{
				CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager;
				object obj = <>O.<0>__OnShotMessage;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnShotMessage;
					<>O.<0>__OnShotMessage = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("CompanyPistol.Shot", (HandleNamedMessageDelegate)obj);
				CustomMessagingManager customMessagingManager2 = singleton.CustomMessagingManager;
				object obj2 = <>O.<1>__OnFxMessage;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val2 = OnFxMessage;
					<>O.<1>__OnFxMessage = val2;
					obj2 = (object)val2;
				}
				customMessagingManager2.RegisterNamedMessageHandler("CompanyPistol.Fx", (HandleNamedMessageDelegate)obj2);
				CustomMessagingManager customMessagingManager3 = singleton.CustomMessagingManager;
				object obj3 = <>O.<2>__OnDamageMessage;
				if (obj3 == null)
				{
					HandleNamedMessageDelegate val3 = OnDamageMessage;
					<>O.<2>__OnDamageMessage = val3;
					obj3 = (object)val3;
				}
				customMessagingManager3.RegisterNamedMessageHandler("CompanyPistol.Damage", (HandleNamedMessageDelegate)obj3);
				registeredMessenger = singleton.CustomMessagingManager;
				Debug.Log((object)"[CompanyPistol] Network message handlers registered.");
			}
		}

		private static _1911_Script FindPistol(ulong networkObjectId)
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || singleton.SpawnManager == null)
			{
				return null;
			}
			if (!singleton.SpawnManager.SpawnedObjects.TryGetValue(networkObjectId, out var value) || (Object)(object)value == (Object)null)
			{
				return null;
			}
			return ((Component)value).GetComponent<_1911_Script>();
		}

		private unsafe void SendShotRequest(Vector3 origin, Vector3 direction)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			//IL_0044: 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)
			NetworkManager singleton = NetworkManager.Singleton;
			if (singleton.IsServer)
			{
				HandleShotRequest(0uL, origin, direction);
				return;
			}
			RegisterMessageHandlers();
			ulong networkObjectId = ((NetworkBehaviour)this).NetworkObjectId;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(ref origin);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref direction);
				singleton.CustomMessagingManager.SendNamedMessage("CompanyPistol.Shot", 0uL, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void OnShotMessage(ulong senderClientId, FastBufferReader reader)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			ulong networkObjectId = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
			Vector3 clientOrigin = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref clientOrigin);
			Vector3 direction = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref direction);
			_1911_Script _1911_Script2 = FindPistol(networkObjectId);
			if ((Object)(object)_1911_Script2 == (Object)null)
			{
				Debug.LogWarning((object)("[CompanyPistol] Shot request from client " + senderClientId + " for unknown pistol object " + networkObjectId + "."));
			}
			else
			{
				_1911_Script2.HandleShotRequest(senderClientId, clientOrigin, direction);
			}
		}

		private unsafe void BroadcastShotEffects(ulong shooterId, Vector3 shooterPosition, Vector3 impactPoint, Quaternion impactRotation, int impactType, bool hasImpact, bool hitCharacter, Vector3 characterImpactPoint, Quaternion characterImpactRotation, float pitch, ShotExtras extras)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			PlayShotEffects(shooterId, shooterPosition, impactPoint, impactRotation, impactType, hasImpact, hitCharacter, characterImpactPoint, characterImpactRotation, pitch, extras);
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null)
			{
				return;
			}
			ulong networkObjectId = ((NetworkBehaviour)this).NetworkObjectId;
			int num = (hasImpact ? 1 : 0);
			int num2 = (hitCharacter ? 1 : 0);
			int num3 = (extras.hitVehicle ? 1 : 0);
			int num4 = (extras.startReload ? 1 : 0);
			int num5 = (extras.igniteHood ? 1 : 0);
			int ammoLeft = extras.ammoLeft;
			Vector3 vehiclePoint = extras.vehiclePoint;
			Quaternion vehicleRotation = extras.vehicleRotation;
			FastBufferWriter val = default(FastBufferWriter);
			foreach (ulong connectedClientsId in singleton.ConnectedClientsIds)
			{
				if (connectedClientsId != 0)
				{
					((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1);
					try
					{
						((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref shooterId, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe(ref shooterPosition);
						((FastBufferWriter)(ref val)).WriteValueSafe(ref impactPoint);
						((FastBufferWriter)(ref val)).WriteValueSafe(ref impactRotation);
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref impactType, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num2, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe(ref characterImpactPoint);
						((FastBufferWriter)(ref val)).WriteValueSafe(ref characterImpactRotation);
						((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num3, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe(ref vehiclePoint);
						((FastBufferWriter)(ref val)).WriteValueSafe(ref vehicleRotation);
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref ammoLeft, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num4, default(ForPrimitives));
						((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num5, default(ForPrimitives));
						singleton.CustomMessagingManager.SendNamedMessage("CompanyPistol.Fx", connectedClientsId, val, (NetworkDelivery)2);
					}
					finally
					{
						((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
		}

		private static void OnFxMessage(ulong senderClientId, FastBufferReader reader)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			ulong networkObjectId = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
			ulong shooterId = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref shooterId, default(ForPrimitives));
			Vector3 shooterPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref shooterPosition);
			Vector3 impactPoint = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref impactPoint);
			Quaternion impactRotation = default(Quaternion);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref impactRotation);
			int impactType = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref impactType, default(ForPrimitives));
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			int num2 = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives));
			Vector3 characterImpactPoint = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref characterImpactPoint);
			Quaternion characterImpactRotation = default(Quaternion);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref characterImpactRotation);
			float pitch = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
			int num3 = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives));
			Vector3 vehiclePoint = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref vehiclePoint);
			Quaternion vehicleRotation = default(Quaternion);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref vehicleRotation);
			int ammoLeft = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref ammoLeft, default(ForPrimitives));
			int num4 = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num4, default(ForPrimitives));
			int num5 = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num5, default(ForPrimitives));
			_1911_Script _1911_Script2 = FindPistol(networkObjectId);
			if (!((Object)(object)_1911_Script2 == (Object)null))
			{
				ShotExtras extras = new ShotExtras
				{
					hitVehicle = (num3 != 0),
					vehiclePoint = vehiclePoint,
					vehicleRotation = vehicleRotation,
					ammoLeft = ammoLeft,
					startReload = (num4 != 0),
					igniteHood = (num5 != 0)
				};
				_1911_Script2.PlayShotEffects(shooterId, shooterPosition, impactPoint, impactRotation, impactType, num != 0, num2 != 0, characterImpactPoint, characterImpactRotation, pitch, extras);
			}
		}

		private bool ResolvePlayerHit(PlayerControllerB shooter, RaycastHit[] sortedHits, float blockDistance, Vector3 direction, ref Vector3 characterImpactPoint, ref Quaternion characterImpactRotation)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < sortedHits.Length; i++)
			{
				RaycastHit hit = sortedHits[i];
				if (((RaycastHit)(ref hit)).distance > blockDistance + 0.01f)
				{
					break;
				}
				if (!((Object)(object)((RaycastHit)(ref hit)).transform == (Object)null) && !(((Component)((RaycastHit)(ref hit)).transform).tag != "Player"))
				{
					PlayerControllerB componentInParent = ((Component)((RaycastHit)(ref hit)).transform).GetComponentInParent<PlayerControllerB>();
					if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)shooter) && !componentInParent.isPlayerDead && componentInParent.isPlayerControlled)
					{
						DamagePlayerFromShot(componentInParent, 8);
						characterImpactPoint = ((RaycastHit)(ref hit)).point;
						characterImpactRotation = GetBloodRotation(hit, direction);
						return true;
					}
				}
			}
			return false;
		}

		private unsafe static void DamagePlayerFromShot(PlayerControllerB target, int damage)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || !singleton.IsListening || target.actualClientId == 0)
			{
				target.DamagePlayer(damage, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
				return;
			}
			int num = damage;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				singleton.CustomMessagingManager.SendNamedMessage("CompanyPistol.Damage", target.actualClientId, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void OnDamageMessage(ulong senderClientId, FastBufferReader reader)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (senderClientId == 0)
			{
				PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
				if (!((Object)(object)val == (Object)null) && !val.isPlayerDead)
				{
					val.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
				}
			}
		}

		private void HandleShotRequest(ulong shooterId, Vector3 clientOrigin, Vector3 direction)
		{
			//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_003d: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_00de: 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)
			PlayerControllerB player = GetPlayer(shooterId);
			if (!((Object)(object)player == (Object)null) && !((Object)(object)player.gameplayCamera == (Object)null))
			{
				Vector3 position = ((Component)player.gameplayCamera).transform.position;
				float num = Vector3.Distance(clientOrigin, position);
				Vector3 origin = ((num <= 8f) ? clientOrigin : position);
				direction = ((((Vector3)(ref direction)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref direction)).normalized : ((Component)player.gameplayCamera).transform.forward);
				Debug.Log((object)("[CompanyPistol] Shot from client " + shooterId + ": origin drift " + num.ToString("F2") + "m, using " + ((num <= 8f) ? "client" : "server") + " origin."));
				ResolveShot(shooterId, origin, direction);
			}
		}

		private void ResolveShot(ulong shooterId, Vector3 origin, Vector3 direction)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening && !NetworkManager.Singleton.IsServer)
			{
				Debug.LogError((object)"[CompanyPistol] ResolveShot was called on a client; ignoring.");
				return;
			}
			PlayerControllerB player = GetPlayer(shooterId);
			if ((Object)(object)player == (Object)null || Time.time < serverReloadEndTime)
			{
				return;
			}
			serverAmmo--;
			bool flag = serverAmmo <= 0;
			if (flag)
			{
				serverAmmo = 11;
				serverReloadEndTime = Time.time + GetReloadDuration();
			}
			AttractMouthDogs(player);
			RaycastHit[] array = Physics.RaycastAll(origin, direction, 350f);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			ImpactType impactType = ImpactType.None;
			Vector3 impactPoint = Vector3.zero;
			Quaternion impactRotation = Quaternion.identity;
			bool hasImpact = false;
			float blockDistance = float.PositiveInfinity;
			string blockerInfo = "nothing";
			RaycastHit[] array2 = array;
			for (int num = 0; num < array2.Length; num++)
			{
				RaycastHit rayHit = array2[num];
				if (TryGetImpact(rayHit, out var impactType2, out var blocksPlayer))
				{
					impactType = impactType2;
					impactPoint = ((RaycastHit)(ref rayHit)).point;
					impactRotation = ((RaycastHit)(ref rayHit)).transform.rotation;
					hasImpact = true;
					if (blocksPlayer)
					{
						blockDistance = ((RaycastHit)(ref rayHit)).distance;
						blockerInfo = "'" + ((Object)((RaycastHit)(ref rayHit)).transform).name + "' (tag " + ((Component)((RaycastHit)(ref rayHit)).transform).tag + ", layer " + ((Component)((RaycastHit)(ref rayHit)).transform).gameObject.layer + ")";
						break;
					}
				}
			}
			ShotExtras extras = default(ShotExtras);
			extras.ammoLeft = serverAmmo;
			extras.startReload = flag;
			extras.hitVehicle = ResolveVehicleHit(player, array, blockDistance, blockerInfo, direction, out extras.vehiclePoint, out extras.vehicleRotation, out extras.igniteHood);
			WakeRadMechFromShot(array, blockDistance);
			Vector3 characterImpactPoint = Vector3.zero;
			Quaternion characterImpactRotation = Quaternion.identity;
			bool flag2 = ResolveEnemyAndHazardHit(player, origin, direction, ref characterImpactPoint, ref characterImpactRotation);
			bool flag3 = true;
			flag2 |= ResolvePlayerHit(player, array, blockDistance, direction, ref characterImpactPoint, ref characterImpactRotation);
			if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening)
			{
				BroadcastShotEffects(shooterId, ((Component)player).transform.position, impactPoint, impactRotation, (int)impactType, hasImpact, flag2, characterImpactPoint, characterImpactRotation, Random.Range(0.75f, 1.35f), extras);
			}
			else
			{
				PlayShotEffects(shooterId, ((Component)player).transform.position, impactPoint, impactRotation, (int)impactType, hasImpact, flag2, characterImpactPoint, characterImpactRotation, Random.Range(0.75f, 1.35f), extras);
			}
		}

		private static float GetReloadDuration()
		{
			AudioClip val = (((Object)(object)PluginForThePistol.instance != (Object)null) ? PluginForThePistol.instance.Reload : null);
			return ((Object)(object)val != (Object)null) ? Mathf.Clamp(val.length, 1.5f, 6f) : 2.5f;
		}

		private static Quaternion GetBloodRotation(RaycastHit hit, Vector3 shotDirection)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((RaycastHit)(ref hit)).normal;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = -shotDirection;
			}
			return Quaternion.LookRotation(((Vector3)(ref val)).normalized);
		}

		private bool ResolveVehicleHit(PlayerControllerB shooter, RaycastHit[] sortedHits, float blockDistance, string blockerInfo, Vector3 direction, out Vector3 hitPoint, out Quaternion hitRotation, out bool igniteHood)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			hitPoint = Vector3.zero;
			hitRotation = Quaternion.identity;
			igniteHood = false;
			for (int i = 0; i < sortedHits.Length; i++)
			{
				RaycastHit hit = sortedHits[i];
				if ((Object)(object)((RaycastHit)(ref hit)).transform == (Object)null)
				{
					continue;
				}
				VehicleController componentInParent = ((Component)((RaycastHit)(ref hit)).transform).GetComponentInParent<VehicleController>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					if (((RaycastHit)(ref hit)).distance > blockDistance + 0.01f)
					{
						Debug.Log((object)("[CompanyPistol] Shot at the cruiser was blocked by " + blockerInfo + " at " + blockDistance.ToString("F2") + "m (cruiser at " + ((RaycastHit)(ref hit)).distance.ToString("F2") + "m)."));
						return false;
					}
					igniteHood = DamageCruiser(componentInParent, shooter, ((RaycastHit)(ref hit)).point);
					hitPoint = ((RaycastHit)(ref hit)).point;
					hitRotation = GetBloodRotation(hit, direction);
					return true;
				}
			}
			return false;
		}

		private bool DamageCruiser(VehicleController vehicle, PlayerControllerB shooter, Vector3 hitPoint)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			Type typeFromHandle = typeof(VehicleController);
			LogCruiserApiOnce(typeFromHandle);
			int num = ReadIntField(vehicle, "carHP");
			bool flag = false;
			int instanceID = ((Object)vehicle).GetInstanceID();
			cruiserShots.TryGetValue(instanceID, out var value);
			value++;
			cruiserShots[instanceID] = value;
			if (!cruiserMaxHp.TryGetValue(instanceID, out var value2))
			{
				value2 = ((num > 0) ? num : 50);
				cruiserMaxHp[instanceID] = value2;
			}
			int num2 = Mathf.Max(1, value2 / 12);
			if (value >= 12)
			{
				num2 = Mathf.Max(num2, (num > 0) ? num : value2);
			}
			MethodInfo method = typeFromHandle.GetMethod("DealPermanentDamage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				try
				{
					method.Invoke(vehicle, BuildArgs(method, num2, hitPoint));
					flag = true;
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[CompanyPistol] DealPermanentDamage failed: " + ex.Message));
				}
			}
			if (!flag)
			{
				vehicle.DealDamageClientRpc(num2, ((Object)((Component)shooter).gameObject).GetInstanceID());
				int num3 = ReadIntField(vehicle, "carHP");
				if (num != int.MinValue && num3 == num)
				{
					WriteIntField(vehicle, "carHP", num - num2);
				}
			}
			int num4 = ReadIntField(vehicle, "carHP");
			bool flag2 = ReadBoolField(vehicle, "carDestroyed");
			Debug.Log((object)("[CompanyPistol] Cruiser hit " + value + "/" + 12 + ": damage " + num2 + ", carHP " + num + " -> " + num4 + ", destroyed=" + flag2 + ", usedDealPermanentDamage=" + flag));
			bool flag3 = value >= 12 || (num4 != int.MinValue && num4 <= 0);
			if (flag3 && !flag2)
			{
				if (num4 > 0)
				{
					WriteIntField(vehicle, "carHP", 0);
				}
				cruiserShots.Remove(instanceID);
				cruiserMaxHp.Remove(instanceID);
				MethodInfo method2 = typeFromHandle.GetMethod("DestroyCar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (method2 != null)
				{
					try
					{
						method2.Invoke(vehicle, null);
					}
					catch (Exception ex2)
					{
						Debug.LogWarning((object)("[CompanyPistol] DestroyCar failed: " + ex2.Message));
					}
				}
				else
				{
					Debug.LogWarning((object)"[CompanyPistol] Cruiser is at 0 HP but no parameterless DestroyCar() method was found.");
				}
			}
			return !flag3 && value >= 7;
		}

		private static object[] BuildArgs(MethodInfo method, int damage, Vector3 hitPoint)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			ParameterInfo[] parameters = method.GetParameters();
			object[] array = new object[parameters.Length];
			for (int i = 0; i < parameters.Length; i++)
			{
				Type parameterType = parameters[i].ParameterType;
				if (i == 0 && parameterType == typeof(int))
				{
					array[i] = damage;
				}
				else if (parameterType == typeof(Vector3))
				{
					array[i] = hitPoint;
				}
				else if (parameters[i].HasDefaultValue)
				{
					array[i] = parameters[i].DefaultValue;
				}
				else
				{
					array[i] = (parameterType.IsValueType ? Activator.CreateInstance(parameterType) : null);
				}
			}
			return array;
		}

		private static int ReadIntField(object target, string name)
		{
			FieldInfo field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return (field != null && field.FieldType == typeof(int)) ? ((int)field.GetValue(target)) : int.MinValue;
		}

		private static void WriteIntField(object target, string name, int value)
		{
			FieldInfo field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field.FieldType == typeof(int))
			{
				field.SetValue(target, value);
			}
		}

		private static bool ReadBoolField(object target, string name)
		{
			FieldInfo field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return field != null && field.FieldType == typeof(bool) && (bool)field.GetValue(target);
		}

		private static void LogCruiserApiOnce(Type type)
		{
			if (cruiserApiLogged)
			{
				return;
			}
			cruiserApiLogged = true;
			StringBuilder stringBuilder = new StringBuilder("[CompanyPistol] VehicleController members: ");
			MemberInfo[] members = type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MemberInfo memberInfo in members)
			{
				string text = memberInfo.Name.ToLowerInvariant();
				if (text.Contains("damage") || text.Contains("destroy") || text.Contains("hp") || text.Contains("health") || text.Contains("explo") || text.Contains("fire") || text.Contains("dead"))
				{
					stringBuilder.Append(memberInfo.MemberType).Append(' ').Append(memberInfo.Name)
						.Append("; ");
				}
			}
			Debug.Log((object)stringBuilder.ToString());
		}

		private static bool IsBeeTarget(EnemyAI enemy, Transform hitTransform)
		{
			if (enemy is RedLocustBees || enemy is DocileLocustBeesAI)
			{
				return true;
			}
			if ((Object)(object)hitTransform != (Object)null)
			{
				if ((Object)(object)((Component)hitTransform).GetComponentInParent<RedLocustBees>() != (Object)null || (Object)(object)((Component)hitTransform).GetComponentInParent<DocileLocustBeesAI>() != (Object)null)
				{
					return true;
				}
				string text = ((Object)hitTransform.root).name.ToLowerInvariant();
				if (text.Contains("locust") || text.Contains("bee") || text.Contains("hive"))
				{
					return true;
				}
			}
			return false;
		}

		private void AttractMouthDogs(PlayerControllerB shooter)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.SpawnedEnemies == null)
			{
				return;
			}
			Vector3 position = ((Component)shooter).transform.position;
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				MouthDogAI val = (MouthDogAI)(object)((spawnedEnemy is MouthDogAI) ? spawnedEnemy : null);
				if (val != null && (Object)(object)val != (Object)null && !((EnemyAI)val).isEnemyDead)
				{
					float num = Vector3.Distance(((Component)val).transform.position, position);
					((EnemyAI)val).DetectNoise(position, Mathf.Max(1f, num * 2f), 0, 0);
				}
			}
		}

		private bool TryGetImpact(RaycastHit rayHit, out ImpactType impactType, out bool blocksPlayer)
		{
			impactType = ImpactType.None;
			blocksPlayer = false;
			Transform transform = ((RaycastHit)(ref rayHit)).transform;
			if ((Object)(object)transform == (Object)null)
			{
				return false;
			}
			GameObject gameObject = ((Component)transform).gameObject;
			string tag = gameObject.tag;
			if (tag == "Concrete" || tag == "Rock")
			{
				impactType = ImpactType.Rock;
				blocksPlayer = true;
				return true;
			}
			if (tag == "Metal" || tag == "Aluminum" || tag == "Catwalk")
			{
				impactType = ImpactType.Metal;
				blocksPlayer = true;
				return true;
			}
			switch (tag)
			{
			case "Gravel":
				impactType = ImpactType.Gravel;
				blocksPlayer = true;
				return true;
			case "Wood":
				impactType = ImpactType.Wood;
				blocksPlayer = true;
				return true;
			case "Grass":
				impactType = ImpactType.Grass;
				blocksPlayer = true;
				return true;
			case "Snow":
				impactType = ImpactType.Snow;
				blocksPlayer = true;
				return true;
			default:
				if (gameObject.layer != 10)
				{
					if (tag == "Puddle")
					{
						impactType = ImpactType.Water;
						blocksPlayer = true;
						return true;
					}
					if (tag == "Untagged")
					{
						if (((Object)gameObject).name == "WaterTrigger")
						{
							impactType = ImpactType.Water;
							blocksPlayer = true;
							return true;
						}
						if (gameObject.layer == 11 || gameObject.layer == 0)
						{
							impactType = ImpactType.Untagged;
							blocksPlayer = true;
							return true;
						}
					}
					return false;
				}
				goto case "Bush";
			case "Bush":
				impactType = ImpactType.Bush;
				blocksPlayer = false;
				return true;
			}
		}

		private bool ResolveEnemyAndHazardHit(PlayerControllerB shooter, Vector3 origin, Vector3 direction, ref Vector3 characterImpactPoint, ref Quaternion characterImpactRotation)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			int num = 19 << LayerMask.NameToLayer("Enemies");
			RaycastHit hit = default(RaycastHit);
			if (Physics.Raycast(origin, direction, ref hit, float.PositiveInfinity, num))
			{
				EnemyAI componentInParent = ((Component)((RaycastHit)(ref hit)).transform).GetComponentInParent<EnemyAI>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.isEnemyDead)
				{
					ApplyEnemyBehavior(componentInParent, shooter);
					if (!IsBeeTarget(componentInParent, ((RaycastHit)(ref hit)).transform))
					{
						characterImpactPoint = ((RaycastHit)(ref hit)).point;
						characterImpactRotation = GetBloodRotation(hit, direction);
						result = true;
					}
				}
			}
			int num2 = 21 << LayerMask.NameToLayer("MapHazards");
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(origin, direction, ref val, float.PositiveInfinity, num2))
			{
				Landmine componentInParent2 = ((Component)((RaycastHit)(ref val)).transform).GetComponentInParent<Landmine>();
				Turret componentInParent3 = ((Component)((RaycastHit)(ref val)).transform).GetComponentInParent<Turret>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					componentInParent2.PressMineClientRpc();
					componentInParent2.ExplodeMineClientRpc();
				}
				else if ((Object)(object)componentInParent3 != (Object)null)
				{
					componentInParent3.EnterBerserkModeClientRpc(((Object)((Component)shooter).gameObject).GetInstanceID());
				}
			}
			return result;
		}

		private void ApplyEnemyBehavior(EnemyAI enemy, PlayerControllerB shooter)
		{
			CaveDwellerAI val = (CaveDwellerAI)(object)((enemy is CaveDwellerAI) ? enemy : null);
			if (val != null)
			{
				((EnemyAI)val).HitEnemy(1, shooter, false, -1);
				val.TurnIntoAdultClientRpc();
				return;
			}
			FlowermanAI val2 = (FlowermanAI)(object)((enemy is FlowermanAI) ? enemy : null);
			if (val2 != null)
			{
				((EnemyAI)val2).HitEnemy(1, shooter, false, -1);
				((EnemyAI)val2).TargetClosestPlayer(1.5f, false, 70f, false, false, true);
				return;
			}
			HoarderBugAI val3 = (HoarderBugAI)(object)((enemy is HoarderBugAI) ? enemy : null);
			if (val3 != null)
			{
				((EnemyAI)val3).HitEnemy(1, shooter, false, -1);
				((EnemyAI)val3).TargetClosestPlayer(1.5f, false, 70f, false, false, true);
				return;
			}
			RadMechAI val4 = (RadMechAI)(object)((enemy is RadMechAI) ? enemy : null);
			if (val4 != null)
			{
				WakeRadMech(val4);
				((EnemyAI)val4).PlayerIsTargetable(shooter, false, true, true);
				((EnemyAI)val4).HitEnemy(1, shooter, false, -1);
				return;
			}
			MouthDogAI val5 = (MouthDogAI)(object)((enemy is MouthDogAI) ? enemy : null);
			if (val5 != null)
			{
				((EnemyAI)val5).HitEnemy(1, shooter, false, -1);
				((EnemyAI)val5).targetPlayer = shooter;
				((EnemyAI)val5).movingTowardsTargetPlayer = true;
				return;
			}
			NutcrackerEnemyAI val6 = (NutcrackerEnemyAI)(object)((enemy is NutcrackerEnemyAI) ? enemy : null);
			if (val6 != null)
			{
				((EnemyAI)val6).HitEnemy(1, shooter, false, -1);
				((EnemyAI)val6).targetPlayer = shooter;
				((EnemyAI)val6).TargetClosestPlayer(1.5f, false, 360f, false, false, true);
				return;
			}
			SandSpiderAI val7 = (SandSpiderAI)(object)((enemy is SandSpiderAI) ? enemy : null);
			if (val7 != null)
			{
				((EnemyAI)val7).HitEnemy(1, shooter, false, -1);
				return;
			}
			SpringManAI val8 = (SpringManAI)(object)((enemy is SpringManAI) ? enemy : null);
			if (val8 != null)
			{
				((EnemyAI)val8).targetPlayer = shooter;
				((EnemyAI)val8).movingTowardsTargetPlayer = true;
				return;
			}
			DocileLocustBeesAI val9 = (DocileLocustBeesAI)(object)((enemy is DocileLocustBeesAI) ? enemy : null);
			if (val9 != null)
			{
				((EnemyAI)val9).targetPlayer = shooter;
				return;
			}
			MaskedPlayerEnemy val10 = (MaskedPlayerEnemy)(object)((enemy is MaskedPlayerEnemy) ? enemy : null);
			if (val10 != null)
			{
				((EnemyAI)val10).HitEnemy(1, shooter, false, -1);
				((EnemyAI)val10).targetPlayer = shooter;
				return;
			}
			CrawlerAI val11 = (CrawlerAI)(object)((enemy is CrawlerAI) ? enemy : null);
			if (val11 != null)
			{
				((EnemyAI)val11).HitEnemy(1, shooter, false, -1);
				val11.BeginChasingPlayerClientRpc(((Object)((Component)shooter).gameObject).GetInstanceID());
				return;
			}
			JesterAI val12 = (JesterAI)(object)((enemy is JesterAI) ? enemy : null);
			if (val12 != null)
			{
				((EnemyAI)val12).targetPlayer = shooter;
				return;
			}
			PufferAI val13 = (PufferAI)(object)((enemy is PufferAI) ? enemy : null);
			if (val13 != null)
			{
				((EnemyAI)val13).HitEnemy(1, shooter, false, -1);
				val13.BitePlayerClientRpc(0);
				return;
			}
			DoublewingAI val14 = (DoublewingAI)(object)((enemy is DoublewingAI) ? enemy : null);
			if (val14 != null)
			{
				((EnemyAI)val14).KillEnemy(false);
			}
			else
			{
				enemy.HitEnemy(1, shooter, false, -1);
			}
		}

		private void PlayShotEffects(ulong shooterId, Vector3 shooterPosition, Vector3 impactPoint, Quaternion impactRotation, int impactType, bool hasImpact, bool hitCharacter, Vector3 characterImpactPoint, Quaternion characterImpactRotation, float pitch, ShotExtras extras)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			displayAmmo = (extras.startReload ? 11 : Mathf.Clamp(extras.ammoLeft, 0, 11));
			if (extras.startReload)
			{
				StartReloadVisuals();
			}
			if ((!((Object)(object)NetworkManager.Singleton != (Object)null) || shooterId != NetworkManager.Singleton.LocalClientId) && ClaimShotFeedback())
			{
				PlayRemoteGunshot(shooterPosition);
				PlayRemoteMuzzleFlash();
			}
			if (hasImpact)
			{
				SpawnImpactLocal(impactPoint, impactRotation, (ImpactType)impactType, hasImpact: true, pitch);
			}
			if (hitCharacter)
			{
				SpawnCharacterHitEffect(characterImpactPoint, characterImpactRotation);
			}
			if (extras.hitVehicle)
			{
				SpawnVehicleHitEffect(extras.vehiclePoint, extras.vehicleRotation, pitch);
			}
			if (extras.igniteHood)
			{
				IgniteHood(extras.vehiclePoint);
			}
		}

		private void EnsureTiltApplier()
		{
			if (!((Object)(object)tiltApplier != (Object)null))
			{
				tiltApplier = ((Component)this).GetComponent<ReloadTiltApplier>();
				if ((Object)(object)tiltApplier == (Object)null)
				{
					tiltApplier = ((Component)this).gameObject.AddComponent<ReloadTiltApplier>();
				}
				tiltApplier.owner = this;
			}
		}

		private void StartReloadVisuals()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if (isReloading)
			{
				return;
			}
			reloadStartTime = Time.time;
			reloadEndTime = Time.time + GetReloadDuration();
			displayAmmo = 11;
			EnsureTiltApplier();
			AudioClip val = (((Object)(object)PluginForThePistol.instance != (Object)null) ? PluginForThePistol.instance.Reload : null);
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.itemAudio != (Object)null)
				{
					((GrabbableObject)this).playerHeldBy.itemAudio.PlayOneShot(val);
				}
				else
				{
					AudioSource.PlayClipAtPoint(val, ((Component)this).transform.position);
				}
			}
		}

		private void ApplyReloadTilt()
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (isReloading && ((GrabbableObject)this).isHeld && !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				float num = Mathf.Max(0.5f, reloadEndTime - reloadStartTime);
				float num2 = Time.time - reloadStartTime;
				float num3 = 1f;
				if (num2 < 0.2f)
				{
					num3 = Mathf.SmoothStep(0f, 1f, num2 / 0.2f);
				}
				else if (num2 > num - 0.25f)
				{
					num3 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num - num2) / 0.25f));
				}
				((Component)this).transform.RotateAround(((Component)this).transform.position, ((Component)((GrabbableObject)this).playerHeldBy).transform.right, 35f * num3);
			}
		}

		private void SpawnVehicleHitEffect(Vector3 point, Quaternion rotation, float pitch)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			SpawnImpactLocal(point, rotation, ImpactType.Metal, hasImpact: true, pitch);
			SpawnCruiserSparks(point, rotation);
		}

		private Material GetSparkMaterial()
		{
			if ((Object)(object)sparkMaterial != (Object)null)
			{
				return sparkMaterial;
			}
			ParticleSystemRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>(true);
			foreach (ParticleSystemRenderer val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)val).sharedMaterial != (Object)null)
				{
					sparkMaterial = ((Renderer)val).sharedMaterial;
					return sparkMaterial;
				}
			}
			return null;
		}

		private void SpawnCruiserSparks(Vector3 point, Quaternion rotation)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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)
			//IL_00ea: 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_0104: 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)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			Material val = GetSparkMaterial();
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("CompanyPistol_CruiserSparks");
				val2.transform.SetPositionAndRotation(point, rotation);
				ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
				val3.Stop(true, (ParticleSystemStopBehavior)0);
				MainModule main = val3.main;
				((MainModule)(ref main)).duration = 0.5f;
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.25f, 0.55f);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(4f, 10f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.07f);
				((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.9f, 0.5f), new Color(1f, 0.5f, 0.1f));
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1.2f);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				EmissionModule emission = val3.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
				{
					new Burst(0f, (short)22)
				});
				ShapeModule shape = val3.shape;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
				((ShapeModule)(ref shape)).angle = 35f;
				((ShapeModule)(ref shape)).radius = 0.02f;
				ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
				component.renderMode = (ParticleSystemRenderMode)1;
				component.velocityScale = 0.06f;
				component.lengthScale = 1.5f;
				((Renderer)component).sharedMaterial = val;
				val3.Play();
				Object.Destroy((Object)(object)val2, 2f);
			}
		}

		private unsafe void IgniteHood(Vector3 hitPoint)
		{
			//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_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
			VehicleController val = null;
			float num = 25f;
			VehicleController[] array = Object.FindObjectsOfType<VehicleController>();
			foreach (VehicleController val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					float num2 = Vector3.Distance(((Component)val2).transform.position, hitPoint);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null || !ignitedCruisers.Add(((Object)val).GetInstanceID()))
			{
				return;
			}
			Type typeFromHandle = typeof(VehicleController);
			if (!hoodFireApiLogged)
			{
				hoodFireApiLogged = true;
				StringBuilder stringBuilder = new StringBuilder("[CompanyPistol] VehicleController fire/smoke members: ");
				FieldInfo[] fields = typeFromHandle.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					string text = fieldInfo.Name.ToLowerInvariant();
					if (text.Contains("fire") || text.Contains("smoke") || text.Contains("burn") || text.Contains("flame"))
					{
						stringBuilder.Append(fieldInfo.FieldType.Name).Append(' ').Append(fieldInfo.Name)
							.Append("; ");
					}
				}
				Debug.Log((object)stringBuilder.ToString());
			}
			int num3 = 0;
			FieldInfo[] fields2 = typeFromHandle.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo2 in fields2)
			{
				string text2 = fieldInfo2.Name.ToLowerInvariant();
				if (!text2.Contains("fire") || text2.Contains("extinguish"))
				{
					continue;
				}
				try
				{
					object value = fieldInfo2.GetValue(val);
					if (fieldInfo2.FieldType == typeof(bool))
					{
						fieldInfo2.SetValue(val, true);
						num3++;
						continue;
					}
					ParticleSystem val3 = (ParticleSystem)((value is ParticleSystem) ? value : null);
					if (val3 != null && (Object)(object)val3 != (Object)null)
					{
						((Component)val3).gameObject.SetActive(true);
						val3.Play(true);
						num3++;
						continue;
					}
					AudioSource val4 = (AudioSource)((value is AudioSource) ? value : null);
					if (val4 != null && (Object)(object)val4 != (Object)null)
					{
						((Component)val4).gameObject.SetActive(true);
						if (!val4.isPlaying)
						{
							val4.Play();
						}
						num3++;
					}
					else
					{
						GameObject val5 = (GameObject)((value is GameObject) ? value : null);
						if (val5 != null && (Object)(object)val5 != (Object)null)
						{
							val5.SetActive(true);
							num3++;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[CompanyPistol] Could not switch on vehicle member " + fieldInfo2.Name + ": " + ex.Message));
				}
			}
			int num4 = 0;
			ParticleSystem val6 = null;
			StringBuilder stringBuilder2 = new StringBuilder();
			ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val7 in componentsInChildren)
			{
				if ((Object)(object)val7 == (Object)null)
				{
					continue;
				}
				string text3 = ((Object)((Component)val7).gameObject).name.ToLowerInvariant();
				if (text3.Contains("fire") || text3.Contains("flame") || text3.Contains("burn") || text3.Contains("smoke"))
				{
					stringBuilder2.Append("ParticleSystem ").Append(((Object)((Component)val7).gameObject).name).Append("; ");
				}
				if ((text3.Contains("fire") || text3.Contains("flame") || text3.Contains("burn")) && !text3.Contains("extinguish"))
				{
					ActivateChain(((Component)val7).transform, ((Component)val).transform);
					val7.Play(true);
					if ((Object)(object)val6 == (Object)null)
					{
						val6 = val7;
					}
					num4++;
					num3++;
				}
			}
			AudioSource[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<AudioSource>(true);
			foreach (AudioSource val8 in componentsInChildren2)
			{
				if ((Object)(object)val8 == (Object)null)
				{
					continue;
				}
				string text4 = ((Object)((Component)val8).gameObject).name.ToLowerInvariant();
				if (text4.Contains("fire") || text4.Contains("flame") || text4.Contains("burn"))
				{
					stringBuilder2.Append("AudioSource ").Append(((Object)((Component)val8).gameObject).name).Append("; ");
					ActivateChain(((Component)val8).transform, ((Component)val).transform);
					if (!val8.isPlaying)
					{
						val8.Play();
					}
					num3++;
				}
			}
			Debug.Log((object)("[CompanyPistol] Cruiser fire-like children: " + ((stringBuilder2.Length > 0) ? stringBuilder2.ToString() : "none")));
			StringBuilder stringBuilder3 = new StringBuilder();
			MethodInfo[] methods = typeFromHandle.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				string text5 = methodInfo.Name.ToLowerInvariant();
				if (!text5.Contains("fire") || text5.Contains("stop") || text5.Contains("extinguish") || text5.Contains("put") || text5.Contains("rpc") || methodInfo.IsAbstract || methodInfo.ContainsGenericParameters)
				{
					continue;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length <= 1 && (parameters.Length != 1 || !(parameters[0].ParameterType != typeof(bool))))
				{
					try
					{
						methodInfo.Invoke(val, (parameters.Length != 1) ? null : new object[1] { true });
						stringBuilder3.Append(methodInfo.Name).Append("(); ");
					}
					catch (Exception ex2)
					{
						Debug.LogWarning((object)("[CompanyPistol] " + methodInfo.Name + " failed: " + ((ex2.InnerException != null) ? ex2.InnerException.Message : ex2.Message)));
					}
				}
			}
			Vector3 val9 = (((Object)(object)val6 != (Object)null) ? ((Component)val6).transform.position : hitPoint);
			bool flag = (Object)(object)val6 != (Object)null && SpawnClonedFire(val6, ((Component)val).transform);
			ParticleSystemRenderer preferred = (((Object)(object)val6 != (Object)null) ? ((Component)val6).GetComponent<ParticleSystemRenderer>() : null);
			bool flag2 = SpawnFallbackFire(((Component)val).transform, val9, preferred);
			if (!flag && !flag2 && num3 == 0)
			{
				ignitedCruisers.Remove(((Object)val).GetInstanceID());
			}
			string[] obj = new string[12]
			{
				"[CompanyPistol] Cruiser hood ignite: built-in members/children used = ",
				num3.ToString(),
				" (particles ",
				num4.ToString(),
				"), methods called = ",
				(stringBuilder3.Length > 0) ? stringBuilder3.ToString() : "none",
				", cloned game fire = ",
				flag.ToString(),
				", own flame effect = ",
				flag2.ToString(),
				", hood at ",
				null
			};
			Vector3 val10 = val9;
			obj[11] = ((object)(*(Vector3*)(&val10))/*cast due to .constrained prefix*/).ToString();
			Debug.Log((object)string.Concat(obj));
		}

		private static bool SpawnClonedFire(ParticleSystem source, Transform vehicle)
		{
			//IL_0030: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Transform val = (((Object)(object)((Component)source).transform.parent != (Object)null) ? ((Component)source).transform.parent : vehicle);
				GameObject val2 = Object.Instantiate<GameObject>(((Component)source).gameObject, ((Component)source).transform.position, ((Component)source).transform.rotation, val);
				((Object)val2).name = "CompanyPistol_HoodFireClone";
				val2.transform.localScale = ((Component)source).transform.localScale;
				ActivateChain(val2.transform, vehicle);
				val2.SetActive(true);
				ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val3 in componentsInChildren)
				{
					MainModule main = val3.main;
					((MainModule)(ref main)).loop = true;
					val3.Play(true);
				}
				AudioSource[] componentsInChildren2 = val2.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val4 in componentsInChildren2)
				{
					((Behaviour)val4).enabled = false;
				}
				Object.Destroy((Object)(object)val2, 120f);
				return true;
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[CompanyPistol] Could not clone the hood fire: " + ex.Message));
				return false;
			}
		}

		private static void ActivateChain(Transform from, Transform stopAt)
		{
			Transform val = from;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)stopAt)
			{
				((Component)val).gameObject.SetActive(true);
				val = val.parent;
			}
		}

		private Material GetFlameMaterial()
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			Material val = null;
			ParticleSystemRenderer[] array = Resources.FindObjectsOfTypeAll<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Renderer)val2).sharedMaterial == (Object)null))
				{
					string text = (((Object)((Renderer)val2).sharedMaterial).name + " " + ((Object)((Component)val2).gameObject).name).ToLowerInvariant();
					if (text.Contains("fire") || text.Contains("flame"))
					{
						return ((Renderer)val2).sharedMaterial;
					}
					if ((Object)(object)val == (Object)null && (text.Contains("smoke") || text.Contains("spark") || text.Contains("explo")))
					{
						val = ((Renderer)val2).sharedMaterial;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Material val3 = GetSparkMaterial();
			if ((Object)(object)val3 != (Object)null)
			{
				return val3;
			}
			ParticleSystemRenderer[] array2 = Resources.FindObjectsOfTypeAll<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val4 in array2)
			{
				if ((Object)(object)val4 != (Object)null && (Object)(object)((Renderer)val4).sharedMaterial != (Object)null)
				{
					return ((Renderer)val4).sharedMaterial;
				}
			}
			string[] array3 = new string[4] { "Sprites/Default", "Legacy Shaders/Particles/Additive", "HDRP/Unlit", "Universal Render Pipeline/Particles/Unlit" };
			string[] array4 = array3;
			foreach (string text2 in array4)
			{
				Shader val5 = Shader.Find(text2);
				if ((Object)(object)val5 != (Object)null)
				{
					Material val6 = new Material(val5);
					val6.color = new Color(1f, 0.5f, 0.1f, 1f);
					return val6;
				}
			}
			return null;
		}

		private bool SpawnFallbackFire(Transform vehicle, Vector3 point, ParticleSystemRenderer preferred)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			Material val = (((Object)(object)preferred != (Object)null && (Object)(object)((Renderer)preferred).sharedMaterial != (Object)null) ? ((Renderer)preferred).sharedMaterial : GetFlameMaterial());
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"[CompanyPistol] No material available for the flame effect.");
				return false;
			}
			GameObject val2 = new GameObject("CompanyPistol_HoodFire");
			val2.transform.SetParent(vehicle, true);
			val2.transform.position = point;
			val2.transform.rotation = Quaternion.LookRotation(Vector3.up);
			ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
			val3.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val3.main;
			((MainModule)(ref main)).duration = 5f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.4f, 0.8f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.8f, 1.8f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.25f, 0.5f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.75f, 0.25f, 0.9f), new Color(1f, 0.35f, 0.05f, 0.9f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.1f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = val3.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(28f);
			ShapeModule shape = val3.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 14f;
			((ShapeModule)(ref shape)).radius = 0.25f;
			ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(new Color(1f, 0.9f, 0.5f), 0f),
				new GradientColorKey(new Color(1f, 0.3f, 0f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(0.9f, 0f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val4);
			SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.2f));
			ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).sharedMaterial = val;
			val3.Play();
			Object.Destroy((Object)(object)val2, 90f);
			return true;
		}

		private void WakeRadMechFromShot(RaycastHit[] sortedHits, float blockDistance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < sortedHits.Length; i++)
			{
				RaycastHit val = sortedHits[i];
				if (!((Object)(object)((RaycastHit)(ref val)).transform == (Object)null) && !(((RaycastHit)(ref val)).distance > blockDistance + 0.01f))
				{
					RadMechAI componentInParent = ((Component)((RaycastHit)(ref val)).transform).GetComponentInParent<RadMechAI>();
					if ((Object)(object)componentInParent != (Object)null && !((EnemyAI)componentInParent).isEnemyDead)
					{
						WakeRadMech(componentInParent);
						break;
					}
				}
			}
		}

		private void WakeRadMech(RadMechAI radMech)
		{
			Type type = ((object)radMech).GetType();
			int currentBehaviourStateIndex = ((EnemyAI)radMech).currentBehaviourStateIndex;
			if (!radMechApiLogged)
			{
				radMechApiLogged = true;
				StringBuilder stringBuilder = new StringBuilder("[CompanyPistol] RadMechAI wake-related members: ");
				MemberInfo[] members = type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MemberInfo memberInfo in members)
				{
					string text = memberInfo.Name.ToLowerInvariant();
					if (text.Contains("active") || text.Contains("dormant") || text.Contains("disabled") || text.Contains("enabled") || text.Contains("awake") || text.Contains("sleep") || text.Contains("wake") || text.Contains("power") || text.Contains("start"))
					{
						stringBuilder.Append(memberInfo.MemberType).Append(' ').Append(memberInfo.Name)
							.Append("; ");
					}
				}
				Debug.Log((object)stringBuilder.ToString());
			}
			StringBuilder stringBuilder2 = new StringBuilder();
			if (!((Behaviour)radMech).enabled)
			{
				((Behaviour)radMech).enabled = true;
				stringBuilder2.Append("enabled component; ");
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.FieldType != typeof(bool))
				{
					continue;
				}
				string text2 = fieldInfo.Name.ToLowerInvariant();
				bool flag = text2.Contains("inactive") || text2.Contains("dormant") || text2.Contains("disabled") || text2.Contains("asleep") || text2.Contains("sleeping");
				bool flag2 = !flag && (text2.Contains("awake") || text2.Contains("activated") || text2 == "isactive" || text2 == "active");
				try
				{
					bool flag3 = (bool)fieldInfo.GetValue(radMech);
					if (flag && flag3)
					{
						fieldInfo.SetValue(radMech, false);
						stringBuilder2.Append(fieldInfo.Name).Append("=false; ");
					}
					else if (flag2 && !flag3)
					{
						fieldInfo.SetValue(radMech, true);
						stringBuilder2.Append(fieldInfo.Name).Append("=true; ");
					}
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[CompanyPistol] RadMech flag " + fieldInfo.Name + ": " + ex.Message));
				}
			}
			MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.GetParameters().Length != 0 || methodInfo.IsAbstract || methodInfo.ContainsGenericParameters)
				{
					continue;
				}
				string text3 = methodInfo.Name.ToLowerInvariant();
				bool flag4 = text3.Contains("wake") || text3.Contains("awaken") || text3.Contains("activate") || text3.Contains("enablemech") || text3.Contains("startup") || text3.Contains("powerup");
				bool flag5 = text3.Contains("deactivate") || text3.Contains("disable") || text3.Contains("sleep") || text3.Contains("shutdown") || text3.Contains("powerdown") || text3.Contains("stop");
				if (!(!flag4 || flag5) && !(text3 == "awake") && !(text3 == "start") && !(text3 == "onenable"))
				{
					try
					{
						methodInfo.Invoke(radMech, null);
						stringBuilder2.Append(methodInfo.Name).Append("(); ");
					}
					catch (Exception ex2)
					{
						Debug.LogWarning((object)("[CompanyPistol] RadMech " + methodInfo.Name + "() failed: " + ((ex2.InnerException != null) ? ex2.InnerException.Message : ex2.Message)));
					}
				}
			}
			if (((EnemyAI)radMech).currentBehaviourStateIndex == 0)
			{
				((EnemyAI)radMech).SwitchToBehaviourState(1);
				stringBuilder2.Append("SwitchToBehaviourState(" + 1 + "); ");
			}
			Debug.Log((object)("[CompanyPistol] RadMech shot: behaviour state " + currentBehaviourStateIndex + " -> " + ((EnemyAI)radMech).currentBehaviourStateIndex + ". Did: " + ((stringBuilder2.Length > 0) ? stringBuilder2.ToString() : "nothing")));
		}

		private static void DrawBox(float x, float y, float w, float h, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = color;
			GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)Texture2D.whiteTexture);
		}

		private void OnGUI()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			//IL_0092: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current == null || (int)Event.current.type != 7)
			{
				return;
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)(object)val) && ((GrabbableObject)this).isHeld && !((GrabbableObject)this).isPocketed && !val.isPlayerDead && (int)Cursor.lockState == 1)
			{
				Color color = GUI.color;
				bool flag = isReloading;
				Color val2 = (flag ? new Color(1f, 0.6f, 0.15f, 0.95f) : new Color(1f, 1f, 1f, 0.95f));
				Color val3 = default(Color);
				((Color)(ref val3))..ctor(0f, 0f, 0f, 0.8f);
				float num = (float)Screen.width * 0.5f;
				float num2 = (float)Screen.height * 0.5f;
				float num3 = 5f;
				float num4 = 9f;
				float num5 = 2f;
				float num6 = 1f;
				for (int i = 0; i < 2; i++)
				{
					float num7 = ((i == 0) ? num6 : 0f);
					Color color2 = ((i == 0) ? val3 : val2);
					DrawBox(num - num3 - num4 - num7, num2 - num5 * 0.5f - num7, num4 + num7 * 2f, num5 + num7 * 2f, color2);
					DrawBox(num + num3 - num7, num2 - num5 * 0.5f - num7, num4 + num7 * 2f, num5 + num7 * 2f, color2);
					DrawBox(num - num5 * 0.5f - num7, num2 - num3 - num4 - num7, num5 + num7 * 2f, num4 + num7 * 2f, color2);
					DrawBox(num - num5 * 0.5f - num7, num2 + num3 - num7, num5 + num7 * 2f, num4 + num7 * 2f, color2);
					DrawBox(num - num5 * 0.5f - num7, num2 - num5 * 0.5f - num7, num5 + num7 * 2f, num5 + num7 * 2f, color2);
				}
				if (ammoStyle == null)
				{
					ammoStyle = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)5,
						fontStyle = (FontStyle)1
					};
					ammoShadowStyle = new GUIStyle(ammoStyle);
				}
				int fontSize = Mathf.Max(14, Mathf.RoundToInt((float)Screen.height * 0.035f));
				ammoStyle.fontSize = fontSize;
				ammoShadowStyle.fontSize = fontSize;
				string text = (flag ? "RELOADING" : (displayAmmo + " / " + 11));
				Rect val4 = default(Rect);
				((Rect)(ref val4))..ctor((float)Screen.width - 330f, (float)Screen.height - 90f, 300f, 60f);
				ammoShadowStyle.normal.textColor = new Color(0f, 0f, 0f, 0.85f);
				GUI.Label(new Rect(((Rect)(ref val4)).x + 2f, ((Rect)(ref val4)).y + 2f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, ammoShadowStyle);
				ammoStyle.normal.textColor = (Color)(flag ? new Color(1f, 0.6f, 0.15f, 1f) : ((displayAmmo <= 3) ? new Color(1f, 0.35f, 0.3f, 1f) : Color.white));
				GUI.Label(val4, text, ammoStyle);
				GUI.color = color;
			}
		}

		private void PlayRemoteMuzzleFlash()
		{
			ParticleSystem componentInChildren = ((Component)this).GetComponentInChildren<ParticleSystem>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.Play();
			}
		}

		private void PlayRemoteGunshot(Vector3 position)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PluginForThePistol.instance == (Object)null))
			{
				GameObject val = new GameObject("CompanyPistol_RemoteShot");
				val.transform.position = position;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.spatialBlend = 1f;
				val2.PlayOneShot(PluginForThePistol.instance.Shoot);
				Object.Destroy((Object)(object)val, 5f);
			}
		}

		private void SpawnImpactLocal(Vector3 point, Quaternion rotation, ImpactType type, bool hasImpact, float pitch)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!hasImpact || type == ImpactType.None)
			{
				return;
			}
			if ((Object)(object)RockSound == (Object)null)
			{
				LoadSoundItems();
			}
			Item impactItem = GetImpactItem(type);
			if (!((Object)(object)impactItem == (Object)null) && !((Object)(object)impactItem.spawnPrefab == (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(impactItem.spawnPrefab, point, rotation);
				AudioSource component = val.GetComponent<AudioSource>();
				if ((Object)(object)component != (Object)null)
				{
					component.pitch = pitch;
				}
				((MonoBehaviour)this).StartCoroutine(DestroyAfterDelay(val, 5f));
			}
		}

		private Item GetImpactItem(ImpactType type)
		{
			return (Item)(type switch
			{
				ImpactType.Rock => RockSound, 
				ImpactType.Metal => MetalSound, 
				ImpactType.Gravel => GravelSound, 
				ImpactType.Wood => WoodSound, 
				ImpactType.Grass => GrassSound, 
				ImpactType.Snow => SnowSound, 
				ImpactType.Bush => BushSound, 
				ImpactType.Water => WaterSound, 
				ImpactType.Untagged => UntaggedSound, 
				_ => null, 
			});
		}

		private void SpawnCharacterHitEffect(Vector3 point, Quaternion rotation)
		{
			//IL_0035: 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_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)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)PluginForThePistol.instance == (Object)null)
			{
				return;
			}
			GameObject hitEffectPrefab = PluginForThePistol.instance.HitEffectPrefab;
			if ((Object)(object)hitEffectPrefab == (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(hitEffectPrefab, point, rotation);
			val.SetActive(true);
			float num = 1f;
			ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val2 in array)
			{
				val2.Play(true);
				MainModule main = val2.main;
				float num2 = num;
				float duration = ((MainModule)(ref main)).duration;
				MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
				num = Mathf.Max(num2, duration + ((MinMaxCurve)(ref startLifetime)).constantMax);
			}
			AudioSource[] componentsInChildren2 = val.GetComponentsInChildren<AudioSource>(true);
			AudioSource[] array2 = componentsInChildren2;
			foreach (AudioSource val3 in array2)
			{
				val3.pitch = Random.Range(0.9f, 1.15f);
				if (!val3.isPlaying)
				{
					val3.Play();
				}
				if ((Object)(object)val3.clip != (Object)null)
				{
					num = Mathf.Max(num, val3.clip.length / Mathf.Max(0.1f, val3.pitch));
				}
			}
			Object.Destroy((Object)(object)val, Mathf.Min(num + 0.5f, 10f));
		}

		private PlayerControllerB GetPlayer(ulong clientId)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return null;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (clientId == 0)
			{
				return (allPlayerScripts.Length != 0) ? allPlayerScripts[0] : null;
			}
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if ((Object)(object)val != (Object)null && val.actualClientId == clientId && (val.isPlayerControlled || val.isPlayerDead))
				{
					return val;
				}
			}
			if (clientId >= (ulong)allPlayerScripts.Length)
			{
				return null;
			}
			return allPlayerScripts[(uint)clientId];
		}

		private IEnumerator WaitForShotDelay()
		{
			yield return (object)new WaitForSeconds(0.5f);
			canShoot = true;
		}

		private IEnumerator DestroyAfterDelay(GameObject obj, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			if ((Object)(object)obj != (Object)null)
			{
				Object.Destroy((Object)(object)obj);
			}
		}
	}
}
namespace Class1
{
	[BepInPlugin("CompanyPistol.pistolmod", "Company pistol", "1.0")]
	public class PluginForThePistol : BaseUnityPlugin
	{
		private const string GUID = "CompanyPistol.pistolmod";

		private const string NAME = "Company pistol";

		private const string VERSION = "1.0";

		public static PluginForThePistol instance;

		private _1911_Script _1911_Script;

		public AssetBundle bundle;

		public AudioClip Shoot;

		public AudioClip Reload;

		public AudioClip ShootFlyBy;

		public ParticleSystem Particle;

		public GameObject HitEffectPrefab;

		public Item BloodPart;

		private const string BloodPartAssetPath = "Assets/Colt1911/Particle/BloodPart.asset";

		public Item Pistol;

		public Item SoundObjectRock;

		public Item SoundObjectMetal;

		public Item SoundObjectGravel;

		public Item SoundObjectWater;

		public Item SoundObjectWood;

		public Item SoundObjectUntagged;

		public Item SoundObjectGrass;

		public Item SoundObjectSnow;

		public Item SoundObjectBush;

		public Item SoundObjectReload;

		public NetworkPrefabs Rock;

		private void Awake()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			instance = this;
			InitializePatchedNetcode();
			Application.logMessageReceived += new LogCallback(OnUnityLog);
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "companypistolbundle");
			if (!File.Exists(text))
			{
				text = Path.Combine(directoryName, "1911");
				((BaseUnityPlugin)this).Logger.LogWarning((object)"CompanyPistol: 'companypistolbundle' not found, falling back to the old '1911' bundle (no BloodPart blood FX in it).");
			}
			bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)bundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("CompanyPistol: failed to load AssetBundle at '" + text + "'."));
				return;
			}
			Pistol = bundle.LoadAsset<Item>("Assets/Colt1911/CompanyPistol.asset");
			LoadBloodEffect();
			_1911_Script = Pistol.spawnPrefab.AddComponent<_1911_Script>();
			((GrabbableObject)_1911_Script).grabbable = true;
			((GrabbableObject)_1911_Script).grabbableToEnemies = true;
			((GrabbableObject)_1911_Script).itemProperties = Pistol;
			Shoot = bundle.LoadAsset<AudioClip>("Assets/Colt1911/Colt1911_Shooting.mp3");
			Reload = bundle.LoadAsset<AudioClip>("Assets/Colt1911/GunReload.mp3");
			ShootFlyBy = bundle.LoadAsset<AudioClip>("Assets/Colt1911/ShootingFlyBy.mp3");
			SoundObjectRock = bundle.LoadAsset<Item>("Assets/Colt1911/RockHitObject.asset");
			SoundObjectReload = bundle.LoadAsset<Item>("Assets/Colt1911/ReloadObject.asset");
			SoundObjectMetal = bundle.LoadAsset<Item>("Assets/Colt1911/MetalHitObject.asset");
			SoundObjectGravel = bundle.LoadAsset<Item>("Assets/Colt1911/GravelHitObject.asset");
			SoundObjectWater = bundle.LoadAsset<Item>("Assets/Colt1911/WaterHitObject.asset");
			SoundObjectWood = bundle.LoadAsset<Item>("Assets/Colt1911/WoodHitObject.asset");
			SoundObjectUntagged = bundle.LoadAsset<Item>("Assets/Colt1911/UntaggedHitObject.asset");
			SoundObjectGrass = bundle.LoadAsset<Item>("Assets/Colt1911/GrassHitObject.asset");
			SoundObjectBush = bundle.LoadAsset<Item>("Assets/Colt1911/BushHitObject.asset");
			SoundObjectSnow = bundle.LoadAsset<Item>("Assets/Colt1911/SnowHitObject.asset");
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectRock.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectRock.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectMetal.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectMetal.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectWater.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectWater.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectWood.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectWood.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectGravel.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectGravel.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectUntagged.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectUntagged.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectGrass.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectGrass.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectSnow.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectSnow.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(SoundObjectBush.spawnPrefab);
			Utilities.FixMixerGroups(SoundObjectBush.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(Pistol.spawnPrefab);
			Utilities.FixMixerGroups(Pistol.spawnPrefab);
			Items.RegisterScrap(Pistol, 5, (LevelTypes)1, (string[])null);
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			val.displayText = "Standart issue company self-defense weapon for the company worker";
			Items.RegisterShopItem(Pistol, (TerminalNode)null, (TerminalNode)null, val, 5);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gun grabbed!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gun reloaded!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gun shot!");
		}

		private void LoadBloodEffect()
		{
			BloodPart = bundle.LoadAsset<Item>("Assets/Colt1911/Particle/BloodPart.asset");
			if ((Object)(object)BloodPart != (Object)null && (Object)(object)BloodPart.spawnPrefab != (Object)null)
			{
				HitEffectPrefab = BloodPart.spawnPrefab;
				NetworkPrefabs.RegisterNetworkPrefab(HitEffectPrefab);
				Utilities.FixMixerGroups(HitEffectPrefab);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("CompanyPistol: loaded blood hit effect '" + ((Object)HitEffectPrefab).name + "' from BloodPart.asset."));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"CompanyPistol: 'Assets/Colt1911/Particle/BloodPart.asset' not found in the bundle, searching for any blood/hit particle prefab instead.");
				FindHitEffectPrefab();
			}
		}

		private void FindHitEffectPrefab()
		{
			if ((Object)(object)bundle == (Object)null)
			{
				return;
			}
			GameObject[] array = bundle.LoadAllAssets<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val == (Object)null || ((Object)(object)Pistol != (Object)null && (Object)(object)val == (Object)(object)Pistol.spawnPrefab))
				{
					continue;
				}
				Pa