Decompiled source of AndysMods v1.8.9

AndysModsPlugin.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AndysModsPlugin.NetcodePatcher;
using AndysModsPlugin.mods.LethalTurrets;
using AndysModsPlugin.mods.ModManager;
using AndysModsPlugin.mods.ModToggle;
using AndysModsPlugin.mods.QuickSwitch;
using AndysModsPlugin.utils;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.ClientAPI;
using LC_API.GameInterfaceAPI.Features;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AndysModsPlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Collection of mods packaged with care and love by Andy aka \"DrFeederino\".")]
[assembly: AssemblyFileVersion("1.8.9.0")]
[assembly: AssemblyInformationalVersion("1.8.9+71f28602c3c2d365035ddf72530c5f0b6915f2d4")]
[assembly: AssemblyProduct("AndysModsPlugin")]
[assembly: AssemblyTitle("AndysModsPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AndysModsPlugin
{
	[BepInPlugin("AndysModsPlugin", "AndysModsPlugin", "1.8.9")]
	[BepInProcess("Lethal Company.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class AndysModsPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static string PluginPath;

		internal static AndysModsPlugin Instance { get; private set; }

		private void Awake()
		{
			//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_004a: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = ((BaseUnityPlugin)this).Info.Location.TrimEnd("AndysModsPlugin.dll".ToCharArray());
			GameObject val = new GameObject("AndysModsPlugin-1.8.9");
			val.AddComponent<AndysMods>().Init();
			Object.DontDestroyOnLoad((Object)val);
			Log.LogInfo((object)("Full plugin path: " + ((BaseUnityPlugin)this).Info.Location));
			Log.LogInfo((object)("Path to plugin is: " + PluginPath));
			NetcodePatcher();
		}

		public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
		{
			config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AndysModsPlugin";

		public const string PLUGIN_NAME = "AndysModsPlugin";

		public const string PLUGIN_VERSION = "1.8.9";
	}
}
namespace AndysModsPlugin.utils
{
	public class AndysMods : MonoBehaviour
	{
		private readonly Harmony harmony = new Harmony("AndysModsPlugin");

		public void Init()
		{
			AndysModsPlugin.Log.LogInfo((object)"AndysMods is installed. Have fun!");
			harmony.PatchAll();
			ModManager.Init();
		}
	}
	internal static class AssetBundleClass
	{
		public static readonly AssetBundle AndysModsAssetBundle = AssetBundle.LoadFromFile(AndysModsPlugin.PluginPath + "andysmods");

		public static readonly AudioClip[] BonkHitSfx = AndysModsAssetBundle.LoadAssetWithSubAssets<AudioClip>("bonk.mp3");

		public static readonly GameObject AndysModsNetworkPrefab = AndysModsAssetBundle.LoadAsset<GameObject>("AndysModsNetworkHandler");

		public static readonly GameObject LethalTurretsNetworkPrefab = AndysModsAssetBundle.LoadAsset<GameObject>("LethalTurretsNetworkPrefab");

		public static readonly GameObject UsefulMaskedNetworkPrefab = AndysModsAssetBundle.LoadAsset<GameObject>("UsefulMaskedNetworkPrefab");
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	[HarmonyWrapSafe]
	internal static class GamenetworkPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void AddBonkNetworkPrefab()
		{
			AssetBundleClass.AndysModsNetworkPrefab.AddComponent<ModNetworkHandler>();
			AssetBundleClass.AndysModsNetworkPrefab.AddComponent<QuickSwitchBehaviour>();
			AndysModsPlugin.Log.LogInfo((object)"Rare Bonk: added ModNetworkHandler and QuickSwitchBehaviour to custom network prefab.");
			AssetBundleClass.LethalTurretsNetworkPrefab.AddComponent<LethalTurretBehaviour>();
			AndysModsPlugin.Log.LogInfo((object)"Lethal Turrets: added LethalTurretBehaviour to custom network prefab.");
			NetworkManager.Singleton.AddNetworkPrefab(AssetBundleClass.AndysModsNetworkPrefab);
			NetworkManager.Singleton.AddNetworkPrefab(AssetBundleClass.LethalTurretsNetworkPrefab);
			AndysModsPlugin.Log.LogInfo((object)"AndysModsPlugin: Custom NetworkPrefabs were added to NetworkManager.");
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class ModNetworkHandlerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyWrapSafe]
		private static void SpawnNetworkHandler()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AssetBundleClass.AndysModsNetworkPrefab, Vector3.zero, Quaternion.identity);
			AndysModsPlugin.Log.LogInfo((object)"AndysModsPlugin: Custom NetworkPrefab was created for client.");
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				AndysModsPlugin.Log.LogInfo((object)"AndysModsPlugin: Custom NetworkPrefab was spawned on the host.");
				val.GetComponent<NetworkObject>().Spawn(false);
			}
			else if ((Object)(object)val.GetComponent<NetworkObject>() != (Object)null && val.GetComponent<NetworkObject>().IsSpawned)
			{
				AndysModsPlugin.Log.LogInfo((object)"AndysModsPlugin: Custom NetworkPrefab was despawned for client.");
				NetworkObject component = val.GetComponent<NetworkObject>();
				if (component != null)
				{
					component.Despawn(true);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Turret), "Start")]
		[HarmonyWrapSafe]
		private static void SpawnTurretsServer(Turret __instance)
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				ModNetworkHandler.Instance.ReplaceTurretServerRpc(((NetworkBehaviour)__instance).NetworkObjectId);
			}
		}
	}
	public class ModNetworkHandler : NetworkBehaviour
	{
		public static ModNetworkHandler Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			AndysModsPlugin.Log.LogInfo((object)"AndysModsPlugin: spawned ModNetworkHandler for sounds!");
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc]
		public void ReplaceTurretServerRpc(ulong turretId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2331673231u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, turretId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2331673231u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ModManager.LethalTurrets.enabled.Value)
			{
				ReplaceTurretClientRpc(turretId);
			}
		}

		[ClientRpc]
		public void ReplaceTurretClientRpc(ulong turretId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4277860744u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, turretId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4277860744u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ModManager.LethalTurrets.enabled.Value)
				{
					ReplaceTurret(turretId);
				}
			}
		}

		private void ReplaceTurret(ulong turretId)
		{
			//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)
			AndysModsPlugin.Log.LogInfo((object)("Lethal Turrets: replacing turret with a more lethal version for " + GameNetworkManager.Instance.localPlayerController?.playerUsername + "."));
			NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(turretId, out var value);
			Turret componentInChildren = ((Component)value).gameObject.GetComponentInChildren<Turret>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				AndysModsPlugin.Log.LogInfo((object)$"Lethal Turrets: can't spawn a NULL turret {GameNetworkManager.Instance.localPlayerController?.playerUsername}, turretID: {turretId}.");
			}
			else if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject obj = Object.Instantiate<GameObject>(AssetBundleClass.LethalTurretsNetworkPrefab, ((Component)componentInChildren).gameObject.transform.position, ((Component)componentInChildren).gameObject.transform.rotation);
				obj.GetComponent<NetworkObject>().Spawn(true);
				obj.GetComponent<LethalTurretBehaviour>().SpawnTurretServerRpc(((NetworkBehaviour)componentInChildren).NetworkObjectId);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SellScrapServerRpc(ulong[] soldItems)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4011880348u, val, (RpcDelivery)0);
				bool flag = soldItems != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(soldItems, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4011880348u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SellScrapClientRpc(soldItems);
			}
		}

		[ClientRpc]
		public void SellScrapClientRpc(ulong[] soldItems)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(455993887u, val, (RpcDelivery)0);
				bool flag = soldItems != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(soldItems, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 455993887u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				SellScrapLocally(soldItems);
			}
		}

		public void SellScrapLocally(ulong[] soldItems)
		{
			AndysModsPlugin.Log.LogInfo((object)"Optimal Sell: selling items to the company.");
			DepositItemsDesk desk = Object.FindObjectOfType<DepositItemsDesk>();
			CollectionExtensions.Do<ulong>((IEnumerable<ulong>)soldItems, (Action<ulong>)delegate(ulong itemId)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				NetworkObject val = PlaceObjectOnDesk(itemId, desk);
				DepositItemsDesk obj = desk;
				if (obj != null)
				{
					obj.AddObjectToDeskServerRpc(NetworkObjectReference.op_Implicit(val));
				}
			});
		}

		private NetworkObject PlaceObjectOnDesk(ulong itemId, DepositItemsDesk desk)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = RoundManager.RandomPointInBounds(((Collider)desk.triggerCollider).bounds);
			Bounds bounds = ((Collider)desk.triggerCollider).bounds;
			val.y = ((Bounds)(ref bounds)).min.y;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(new Ray(val + Vector3.up * 3f, Vector3.down), ref val2, 8f, 1048640, (QueryTriggerInteraction)2))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			NetworkObject component = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[itemId]).gameObject.GetComponent<NetworkObject>();
			GrabbableObject componentInChildren = ((Component)component).gameObject.GetComponentInChildren<GrabbableObject>();
			val.y += componentInChildren.itemProperties.verticalOffset;
			val = ((Component)desk.deskObjectsContainer).transform.InverseTransformPoint(val);
			componentInChildren.EnablePhysics(true);
			componentInChildren.EnableItemMeshes(true);
			componentInChildren.isHeld = false;
			componentInChildren.isPocketed = false;
			componentInChildren.heldByPlayerOnServer = false;
			componentInChildren.parentObject = null;
			((Component)componentInChildren).transform.SetParent(((Component)desk.deskObjectsContainer).transform, true);
			componentInChildren.startFallingPosition = ((Component)componentInChildren).transform.localPosition;
			((Component)componentInChildren).transform.localScale = componentInChildren.originalScale;
			((Component)componentInChildren).transform.localPosition = val;
			componentInChildren.targetFloorPosition = val;
			componentInChildren.fallTime = 0f;
			componentInChildren.OnPlaceObject();
			return component;
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayBonkServerRpc(ulong shovelId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2225120421u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, shovelId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2225120421u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ModManager.RareBonk.enabled.Value)
				{
					PlayBonkClientRpc(shovelId);
				}
			}
		}

		[ClientRpc]
		public void PlayBonkClientRpc(ulong shovelId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1041231060u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, shovelId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1041231060u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Shovel val3 = default(Shovel);
					((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[shovelId]).TryGetComponent<Shovel>(ref val3);
					AndysModsPlugin.Log.LogInfo((object)$"Rare Bonk: playing BONK with found shovel {val3}!");
					RoundManager.PlayRandomClip(val3.shovelAudio, AssetBundleClass.BonkHitSfx, true, 1f, 0, 1000);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ModNetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2331673231u, new RpcReceiveHandler(__rpc_handler_2331673231));
			NetworkManager.__rpc_func_table.Add(4277860744u, new RpcReceiveHandler(__rpc_handler_4277860744));
			NetworkManager.__rpc_func_table.Add(4011880348u, new RpcReceiveHandler(__rpc_handler_4011880348));
			NetworkManager.__rpc_func_table.Add(455993887u, new RpcReceiveHandler(__rpc_handler_455993887));
			NetworkManager.__rpc_func_table.Add(2225120421u, new RpcReceiveHandler(__rpc_handler_2225120421));
			NetworkManager.__rpc_func_table.Add(1041231060u, new RpcReceiveHandler(__rpc_handler_1041231060));
		}

		private static void __rpc_handler_2331673231(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				ulong turretId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref turretId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ModNetworkHandler)(object)target).ReplaceTurretServerRpc(turretId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_4011880348(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ulong[] soldItems = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref soldItems, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ModNetworkHandler)(object)target).SellScrapServerRpc(soldItems);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_455993887(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				ulong[] soldItems = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref soldItems, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ModNetworkHandler)(object)target).SellScrapClientRpc(soldItems);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		protected internal override string __getTypeName()
		{
			return "ModNetworkHandler";
		}
	}
}
namespace AndysModsPlugin.mods.RareBonk
{
	[HarmonyPatch(typeof(Shovel))]
	[HarmonyWrapSafe]
	internal static class RareBonkPatch
	{
		public const int BonkShovelForce = 100;

		public const int OriginalShovelForce = 1;

		[HarmonyPatch("HitShovel")]
		[HarmonyPrefix]
		private static void PatchBonkShovel(Shovel __instance)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.RareBonk.enabled.Value)
			{
				int num = Random.Range(1, 100);
				if ((Object)(object)__instance != (Object)null && num <= 10)
				{
					AndysModsPlugin.Log.LogInfo((object)("Rare Bonk: BONK by " + ((GrabbableObject)__instance).playerHeldBy?.playerUsername + "!"));
					__instance.shovelHitForce = 100;
					ModNetworkHandler.Instance?.PlayBonkServerRpc(((NetworkBehaviour)__instance).NetworkObjectId);
				}
			}
		}

		[HarmonyPatch("HitShovel")]
		[HarmonyPostfix]
		private static void RemovePatchShovel(Shovel __instance)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.RareBonk.enabled.Value && (Object)(object)__instance != (Object)null && __instance.shovelHitForce != 1)
			{
				__instance.shovelHitForce = 1;
				AndysModsPlugin.Log.LogInfo((object)$"Rare Bonk: restored original shovelHitForce {__instance?.shovelHitForce}.");
			}
		}
	}
}
namespace AndysModsPlugin.mods.QuickSwitch
{
	internal class QuickSwitchBehaviour : NetworkBehaviour
	{
		public override void OnNetworkSpawn()
		{
			AndysModsPlugin.Log.LogInfo((object)"Quick Switch: setting up keyboard callbacks.");
			SetupKeybindCallbacks();
			QuickSwitchInput.Instance.EnableModInputActions();
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public void SetupKeybindCallbacks()
		{
			QuickSwitchInput.Instance.QuickItemFirstKey.performed += OnFirstSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemSecondKey.performed += OnSecondSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemThirdKey.performed += OnThirdSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemFourthKey.performed += OnFourthSwitchKeyPressed;
			AndysModsPlugin.Log.LogInfo((object)"Quick Switch: input callbacks are set up.");
		}

		public override void OnDestroy()
		{
			QuickSwitchInput.Instance.DisableModInputActions();
			QuickSwitchInput.Instance.QuickItemFirstKey.performed -= OnFirstSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemSecondKey.performed -= OnSecondSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemThirdKey.performed -= OnThirdSwitchKeyPressed;
			QuickSwitchInput.Instance.QuickItemFourthKey.performed -= OnFourthSwitchKeyPressed;
			AndysModsPlugin.Log.LogInfo((object)"Quick Switch: input callbacks are removed.");
			((NetworkBehaviour)this).OnDestroy();
		}

		private void OnFirstSwitchKeyPressed(CallbackContext context)
		{
			if (((CallbackContext)(ref context)).performed)
			{
				ChangePlayerItemSlot(0);
			}
		}

		private void OnSecondSwitchKeyPressed(CallbackContext context)
		{
			if (((CallbackContext)(ref context)).performed)
			{
				ChangePlayerItemSlot(1);
			}
		}

		private void OnThirdSwitchKeyPressed(CallbackContext context)
		{
			if (((CallbackContext)(ref context)).performed)
			{
				ChangePlayerItemSlot(2);
			}
		}

		private void OnFourthSwitchKeyPressed(CallbackContext context)
		{
			if (((CallbackContext)(ref context)).performed)
			{
				ChangePlayerItemSlot(3);
			}
		}

		private void ChangePlayerItemSlot(int keyNum)
		{
			if (!QuickSwitchInput.QuickSwitchMod.enabled.Value)
			{
				QuickSwitchInput.Instance.DisableModInputActions();
				return;
			}
			if (!((LcInputActions)QuickSwitchInput.Instance).Enabled)
			{
				QuickSwitchInput.Instance.EnableModInputActions();
			}
			if (!((Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null) && !GameNetworkManager.Instance.localPlayerController.inTerminalMenu)
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				Traverse val = Traverse.Create((object)localPlayerController);
				if (GameNetworkManager.Instance.localPlayerController.currentItemSlot != keyNum && ((((NetworkBehaviour)localPlayerController).IsOwner && localPlayerController.isPlayerControlled && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject)) || localPlayerController.isTestingPlayer) && !(val.Field<float>("timeSinceSwitchingSlots").Value < 0.3f) && !localPlayerController.isGrabbingObjectAnimation && !localPlayerController.quickMenuManager.isMenuOpen && !localPlayerController.inSpecialInteractAnimation && !val.Field<bool>("throwingObject").Value && !localPlayerController.isTypingChat && !localPlayerController.twoHanded && !localPlayerController.activatingItem && !localPlayerController.jetpackControls && !localPlayerController.disablingJetpackControls)
				{
					SwitchItemSlotsServerRpc(keyNum, ((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).NetworkObjectId);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwitchItemSlotsServerRpc(int slot, ulong playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2579500861u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, slot);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2579500861u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SwitchItemSlotsClientRpc(slot, playerId);
				}
			}
		}

		[ClientRpc]
		public void SwitchItemSlotsClientRpc(int slot, ulong playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(676562058u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, slot);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 676562058u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				ulong playerId2 = playerId;
				int slot2 = slot;
				CollectionExtensions.DoIf<PlayerControllerB>((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts, (Func<PlayerControllerB, bool>)((PlayerControllerB player) => ((NetworkBehaviour)player).NetworkObjectId == playerId2), (Action<PlayerControllerB>)delegate(PlayerControllerB player)
				{
					((object)player)?.GetType().GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(player, new object[2] { slot2, null });
				});
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_QuickSwitchBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2579500861u, new RpcReceiveHandler(__rpc_handler_2579500861));
			NetworkManager.__rpc_func_table.Add(676562058u, new RpcReceiveHandler(__rpc_handler_676562058));
		}

		private static void __rpc_handler_2579500861(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int slot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref slot);
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((QuickSwitchBehaviour)(object)target).SwitchItemSlotsServerRpc(slot, playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_676562058(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int slot = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref slot);
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((QuickSwitchBehaviour)(object)target).SwitchItemSlotsClientRpc(slot, playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "QuickSwitchBehaviour";
		}
	}
	public class QuickSwitchInput : LcInputActions
	{
		private PlayerInput playerInput = IngamePlayerSettings.Instance?.playerInput;

		public static readonly QuickSwitchInput Instance = new QuickSwitchInput();

		public static readonly ToggleModClass QuickSwitchMod = new ToggleModClass("Quick Switch");

		[InputAction("<Keyboard>/1", Name = "Change Player Item Slot #1")]
		public InputAction QuickItemFirstKey { get; set; }

		[InputAction("<Keyboard>/2", Name = "Change Player Item Slot #2")]
		public InputAction QuickItemSecondKey { get; set; }

		[InputAction("<Keyboard>/3", Name = "Change Player Item Slot #3")]
		public InputAction QuickItemThirdKey { get; set; }

		[InputAction("<Keyboard>/4", Name = "Change Player Item Slot #4")]
		public InputAction QuickItemFourthKey { get; set; }

		public void ToggleMod()
		{
			QuickSwitchMod.Toggle();
			if (QuickSwitchMod.enabled.Value)
			{
				EnableModInputActions();
			}
			else
			{
				DisableModInputActions();
			}
		}

		private void DisableExistingButtonActions()
		{
			if ((Object)(object)playerInput == (Object)null)
			{
				playerInput = IngamePlayerSettings.Instance?.playerInput;
			}
			AndysModsPlugin.Log.LogInfo((object)"Quick Switch: disabling all known InputActions to avoid collisions.");
			PlayerInput obj = playerInput;
			if (obj != null)
			{
				InputAction obj2 = obj.actions.FindAction("Emote1", false);
				if (obj2 != null)
				{
					obj2.Disable();
				}
			}
			PlayerInput obj3 = playerInput;
			if (obj3 != null)
			{
				InputAction obj4 = obj3.actions.FindAction("Emote2", false);
				if (obj4 != null)
				{
					obj4.Disable();
				}
			}
			PlayerInput obj5 = playerInput;
			if (obj5 != null)
			{
				InputAction obj6 = obj5.actions.FindAction("Middle Finger", false);
				if (obj6 != null)
				{
					obj6.Disable();
				}
			}
			PlayerInput obj7 = playerInput;
			if (obj7 != null)
			{
				InputAction obj8 = obj7.actions.FindAction("Clap", false);
				if (obj8 != null)
				{
					obj8.Disable();
				}
			}
		}

		public void DisableModInputActions()
		{
			if (!((LcInputActions)this).Enabled)
			{
				return;
			}
			AndysModsPlugin.Log.LogInfo((object)"QuickSwitch: disabling mod's buttons.");
			((LcInputActions)this).Disable();
			PlayerInput obj = playerInput;
			if (obj != null)
			{
				InputAction obj2 = obj.actions.FindAction("Emote1", false);
				if (obj2 != null)
				{
					obj2.Enable();
				}
			}
			PlayerInput obj3 = playerInput;
			if (obj3 != null)
			{
				InputAction obj4 = obj3.actions.FindAction("Emote2", false);
				if (obj4 != null)
				{
					obj4.Enable();
				}
			}
			PlayerInput obj5 = playerInput;
			if (obj5 != null)
			{
				InputAction obj6 = obj5.actions.FindAction("Middle Finger", false);
				if (obj6 != null)
				{
					obj6.Enable();
				}
			}
			PlayerInput obj7 = playerInput;
			if (obj7 != null)
			{
				InputAction obj8 = obj7.actions.FindAction("Clap", false);
				if (obj8 != null)
				{
					obj8.Enable();
				}
			}
		}

		public void EnableModInputActions()
		{
			if (QuickSwitchMod.enabled.Value)
			{
				AndysModsPlugin.Log.LogInfo((object)"Quick Switch: enabling mod's inputs.");
				((LcInputActions)this).Enable();
				DisableExistingButtonActions();
			}
			else
			{
				AndysModsPlugin.Log.LogInfo((object)"Quick Switch: mod is disabled.");
				DisableModInputActions();
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	[HarmonyWrapSafe]
	internal static class QuickSwitchPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void AddQuickSwitchBehaviour(GameNetworkManager __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject.GetComponent<QuickSwitchBehaviour>() != (Object)null))
			{
				AndysModsPlugin.Log.LogInfo((object)"QuickSwitch: registering QuickSwitchBehaviour.");
				((Component)__instance).gameObject.AddComponent<QuickSwitchBehaviour>();
			}
		}
	}
}
namespace AndysModsPlugin.mods.OptimizeMySellsPatch
{
	[HarmonyPatch(typeof(Terminal))]
	internal class OptimizeMySellsPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ParsePlayerSentence")]
		private static void ParsePlayerText(ref Terminal __instance, ref TerminalNode __result)
		{
			ParseOptimizeMySells(__instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded), ref __result);
		}

		internal static void ParseOptimizeMySells(string fullText, ref TerminalNode node)
		{
			string[] array = fullText.ToLower().Split();
			string text = array[0].Trim();
			string text2 = ((array.Length > 1) ? array[1].Trim() : "");
			if (text.Contains("sell"))
			{
				if (!global::AndysModsPlugin.mods.ModManager.ModManager.OptimalSells.enabled.Value)
				{
					node = CreateTerminalNode("Optimal Sells mod is disabled. Enable it via command chat \"/sell\".\n\n");
				}
				else if ((Object)(object)Object.FindObjectOfType<DepositItemsDesk>() == (Object)null)
				{
					node = CreateTerminalNode("You have to be on the Company planet in order to sell.\n\n");
				}
				else if (text2 == "-all")
				{
					node = SellScrap(isSellingAll: true);
				}
				else
				{
					node = SellScrap(isSellingAll: false);
				}
			}
		}

		private static TerminalNode SellScrap(bool isSellingAll)
		{
			List<GrabbableObject> list = (from gameObject in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
				where ((Object)gameObject).name != "KeyItem" && !gameObject.isBeingUsed && !gameObject.isHeld && !gameObject.isHeldByEnemy && !gameObject.isHeld && gameObject.itemProperties.isScrap && !gameObject.isPocketed
				select gameObject).ToList();
			list.Sort((GrabbableObject firstItem, GrabbableObject secondItem) => (firstItem.scrapValue <= secondItem.scrapValue) ? 1 : 0);
			string[] array = ((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text.Split(new char[1] { '/' });
			int.TryParse(array[0].Replace("PROFIT QUOTA:", "").Trim().Substring(1), out var currentQuota);
			int.TryParse(array[1].Trim().Substring(1), out var neededQuota);
			int scrapSum = 0;
			float num = 0f;
			if (isSellingAll)
			{
				scrapSum = list.Sum((GrabbableObject item) => item.scrapValue);
			}
			else
			{
				if (currentQuota >= neededQuota)
				{
					return CreateTerminalNode("The quota has been hit! No optimal item selling strategy can be provided. If you want to force sell everything on the ship, call the command with \"-all\" option.\n\n");
				}
				int count = 0;
				CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap)
				{
					if ((float)currentQuota + (float)scrapSum * StartOfRound.Instance.companyBuyingRate < (float)neededQuota)
					{
						scrapSum += scrap.scrapValue;
						count++;
					}
				});
				list = list.Take(count).ToList();
			}
			if (list.Count == 0)
			{
				return CreateTerminalNode("Optimal item selling strategy has not been found. Check if you hit the quota and/or have items on the ship!\n\n");
			}
			num = (float)scrapSum * StartOfRound.Instance.companyBuyingRate;
			ulong[] array2 = list.Select((GrabbableObject scrap) => ((NetworkBehaviour)scrap).NetworkObjectId).ToArray();
			ModNetworkHandler.Instance?.SellScrapServerRpc(array2);
			return CreateTerminalNode($"{array2.Length} items are placed on the desk counter. Total: {scrapSum}, Paycheck: {num} with Company Buying Rate {StartOfRound.Instance.companyBuyingRate * 100f}%. Don't forget to ring the bell. Thank you for the hard work!\n\n");
		}

		internal static TerminalNode CreateTerminalNode(string text)
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			obj.displayText = text;
			obj.clearPreviousText = true;
			return obj;
		}
	}
}
namespace AndysModsPlugin.mods.OneOfUsKinda
{
	[HarmonyPatch(typeof(HauntedMaskItem))]
	internal class OneOfUsKindaMaskPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(HauntedMaskItem), "BeginAttachment")]
		[HarmonyWrapSafe]
		internal static bool RerollLuckForPlayer()
		{
			if (!global::AndysModsPlugin.mods.ModManager.ModManager.OneOfUsKinda.enabled.Value)
			{
				return true;
			}
			AndysModsPlugin.Log.LogInfo((object)"One Of Us: re-rolling mask attachment for player.");
			return Random.Range(0, 100) <= 20;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "CheckLineOfSightForPlayer")]
		[HarmonyWrapSafe]
		internal static void CheckLineOfSightForPlayerPatch(ref PlayerControllerB __result)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.OneOfUsKinda.enabled.Value)
			{
				DetargetIfMaskIsActivated(ref __result);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "CheckLineOfSightForClosestPlayer")]
		[HarmonyWrapSafe]
		internal static void CheckLineOfSightForClosestPlayerPatch(ref PlayerControllerB __result)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.OneOfUsKinda.enabled.Value)
			{
				DetargetIfMaskIsActivated(ref __result);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")]
		[HarmonyWrapSafe]
		internal static void PlayerIsTargetablePatch(PlayerControllerB playerScript, ref bool __result)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.OneOfUsKinda.enabled.Value)
			{
				DetargetIfMaskIsActivated(ref playerScript);
				__result = (Object)(object)playerScript != (Object)null;
			}
		}

		private static void DetargetIfMaskIsActivated(ref PlayerControllerB result)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			if ((Object)(object)result != (Object)null && (Object)(object)result.ItemSlots[result.currentItemSlot] != (Object)null && ((Object)result.ItemSlots[result.currentItemSlot]).name.Contains("Mask") && Traverse.Create((object)(HauntedMaskItem)result.ItemSlots[result.currentItemSlot]).Field<bool>("maskOn").Value)
			{
				AndysModsPlugin.Log.LogInfo((object)("One Of Us: de-targeting enemy from player " + result.playerUsername + "."));
				result = null;
			}
		}
	}
}
namespace AndysModsPlugin.mods.ModToggle
{
	public class ToggleModClass
	{
		public ConfigEntry<bool> enabled;

		public string name;

		public ToggleModClass(string name)
		{
			this.name = name;
		}

		public void Toggle()
		{
			enabled.Value = !enabled.Value;
		}
	}
}
namespace AndysModsPlugin.mods.ModManager
{
	public class ModManager
	{
		public static readonly ToggleModClass RareBonk = new ToggleModClass("Rare Bonk");

		public static readonly ToggleModClass LethalLandmines = new ToggleModClass("Lethal Mines");

		public static readonly ToggleModClass LethalTurrets = new ToggleModClass("Lethal Turrets");

		public static readonly ToggleModClass OneOfUsKinda = new ToggleModClass("One Of Us, Kinda");

		public static readonly ToggleModClass OptimalSells = new ToggleModClass("Optimal Sells");

		private static readonly Dictionary<string, Action<string[]>> AvailableCommands = new Dictionary<string, Action<string[]>>
		{
			{
				"bonk",
				delegate
				{
					ToggleMod("bonk");
				}
			},
			{
				"quick",
				delegate
				{
					ToggleMod("quick");
				}
			},
			{
				"turrets",
				delegate
				{
					ToggleMod("turrets");
				}
			},
			{
				"mines",
				delegate
				{
					ToggleMod("mines");
				}
			},
			{
				"mask",
				delegate
				{
					ToggleMod("mask");
				}
			},
			{
				"sell",
				delegate
				{
					ToggleMod("sell");
				}
			}
		};

		public static void ToggleMod(string mod)
		{
			string text;
			switch (mod)
			{
			case "bonk":
				RareBonk.Toggle();
				text = RareBonk.name + " is " + (RareBonk.enabled.Value ? "enabled" : "disabled");
				break;
			case "quick":
				QuickSwitchInput.Instance.ToggleMod();
				text = QuickSwitchInput.QuickSwitchMod.name + " is " + (QuickSwitchInput.QuickSwitchMod.enabled.Value ? "enabled" : "disabled");
				break;
			case "mines":
				LethalLandmines.Toggle();
				text = LethalLandmines.name + " is " + (LethalLandmines.enabled.Value ? "enabled" : "disabled");
				break;
			case "turrets":
				LethalTurrets.Toggle();
				text = LethalTurrets.name + " is " + (LethalTurrets.enabled.Value ? "enabled" : "disabled");
				break;
			case "mask":
				OneOfUsKinda.Toggle();
				text = OneOfUsKinda.name + " is " + (OneOfUsKinda.enabled.Value ? "enabled" : "disabled");
				break;
			case "sell":
				OptimalSells.Toggle();
				text = OptimalSells.name + "  is " + (OptimalSells.enabled.Value ? "enabled" : "disabled");
				break;
			default:
				text = "Unrecognized mod " + mod + ". Ignoring.";
				break;
			}
			AndysModsPlugin.Log.LogInfo((object)("Mod Manager: " + text + "!"));
			Player.LocalPlayer.QueueTip("Andy Mods Manager", text, 5f, 0, false, false, "LC_Tip1");
		}

		public static void RegisterChatCommands()
		{
			AndysModsPlugin.Log.LogInfo((object)"ModToggleEnabler: registering chat commands.");
			foreach (KeyValuePair<string, Action<string[]>> availableCommand in AvailableCommands)
			{
				AndysModsPlugin.Log.LogInfo((object)("ModToggleEnabler: registering chat command " + availableCommand.Key + "."));
				CommandHandler.RegisterCommand(availableCommand.Key, availableCommand.Value);
			}
		}

		internal static void BindConfigs()
		{
			RareBonk.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(RareBonk.name, "enabled", true, "Enables/disables " + RareBonk.name + " mod.");
			LethalLandmines.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(LethalLandmines.name, "enabled", true, "Enables/disables " + LethalLandmines.name + " mod.");
			LethalTurrets.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(LethalTurrets.name, "enabled", true, "Enables/disables " + LethalTurrets.name + " mod.");
			OneOfUsKinda.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(OneOfUsKinda.name, "enabled", true, "Enables/disables " + OneOfUsKinda.name + " mod.");
			OptimalSells.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(OptimalSells.name, "enabled", true, "Enables/disables " + OptimalSells.name + " mod.");
			QuickSwitchInput.QuickSwitchMod.enabled = ((BaseUnityPlugin)AndysModsPlugin.Instance).Config.Bind<bool>(QuickSwitchInput.QuickSwitchMod.name, "enabled", true, "Enables/disables " + QuickSwitchInput.QuickSwitchMod.name + " mod.");
		}

		internal static void Init()
		{
			RegisterChatCommands();
			BindConfigs();
		}
	}
}
namespace AndysModsPlugin.mods.LethalTurrets
{
	internal class LethalTurretBehaviour : NetworkBehaviour
	{
		private EnemyAI targetEnemy;

		private bool targetingDeadEnemy;

		private bool wasTargetingEnemyLastFrame;

		private Turret turret;

		private Traverse fieldTraverser;

		private RaycastHit hit;

		private static int turretMask = LayerMask.GetMask(new string[2] { "Enemies", "Room" });

		public void HookupTurret(Turret turret)
		{
			this.turret = turret;
			fieldTraverser = Traverse.Create((object)turret);
			((Behaviour)turret).enabled = false;
		}

		public override void OnNetworkSpawn()
		{
			AndysModsPlugin.Log.LogInfo((object)"Lethal Turrets: spawned network object for turret!");
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		private void SwitchTurretMode(int mode)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			turret.turretMode = (TurretMode)mode;
		}

		private void SetTargetToPlayerBody()
		{
			((object)turret).GetType().GetMethod("SetTargetToPlayerBody", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(turret, Array.Empty<object>());
		}

		private void TurnTowardsTargetIfHasLOS()
		{
			((object)turret).GetType().GetMethod("TurnTowardsTargetIfHasLOS", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(turret, Array.Empty<object>());
		}

		private IEnumerator FadeBulletAudio()
		{
			float initialVolume = turret.bulletCollisionAudio.volume;
			for (int i = 0; i <= 30; i++)
			{
				yield return (object)new WaitForSeconds(0.012f);
				turret.bulletCollisionAudio.volume = Mathf.Lerp(initialVolume, 0f, (float)i / 30f);
			}
			turret.bulletCollisionAudio.Stop();
		}

		public EnemyAI CheckForEnemyInSight(float radius = 3f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = turret.aimPoint.forward;
			forward = Quaternion.Euler(0f, (0f - turret.rotationRange) / radius, 0f) * forward;
			float num = turret.rotationRange / radius * 2f;
			EnemyAICollisionDetect val = default(EnemyAICollisionDetect);
			for (int i = 0; i <= 6; i++)
			{
				fieldTraverser.Field<Ray>("shootRay").Value = new Ray(turret.centerPoint.position, forward);
				if (Physics.Raycast(fieldTraverser.Field<Ray>("shootRay").Value, ref hit, 30f, turretMask, (QueryTriggerInteraction)2))
				{
					if (!((Component)((RaycastHit)(ref hit)).collider).TryGetComponent<EnemyAICollisionDetect>(ref val))
					{
						return null;
					}
					if ((Object)(object)val.mainScript != (Object)null && !val.mainScript.isEnemyDead && val.mainScript.enemyType.canDie)
					{
						return val.mainScript;
					}
				}
				else
				{
					forward = Quaternion.Euler(0f, num / 6f, 0f) * forward;
				}
			}
			return null;
		}

		private void SetTargetToEnemy()
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (targetEnemy.isEnemyDead)
			{
				if (!targetingDeadEnemy)
				{
					targetingDeadEnemy = true;
				}
				return;
			}
			targetingDeadEnemy = false;
			Collider[] componentsInChildren = ((Component)targetEnemy).gameObject.GetComponentsInChildren<Collider>();
			if (componentsInChildren.Length == 0)
			{
				AndysModsPlugin.Log.LogWarning((object)("Lethal turrets: didn't find any Colliders in " + ((Object)targetEnemy).name + ". Setting target enemy's position instead of collider's bounds."));
				turret.targetTransform = ((Component)targetEnemy).gameObject.transform;
				return;
			}
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				if (((Component)val).CompareTag("Enemy"))
				{
					turret.targetTransform = ((Component)val).gameObject.transform;
					Transform tempTransform = turret.tempTransform;
					Bounds bounds = val.bounds;
					tempTransform.position = ((Bounds)(ref bounds)).center;
				}
			}
		}

		private void TurnTowardsTargetEnemyIfHasLos()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			if (targetingDeadEnemy || Vector3.Angle(turret.targetTransform.position - turret.centerPoint.position, turret.forwardFacingPos.forward) > turret.rotationRange)
			{
				flag = false;
			}
			if (Physics.Linecast(turret.aimPoint.position, turret.targetTransform.position, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
			{
				flag = false;
			}
			if (flag)
			{
				fieldTraverser.Field<bool>("hasLineOfSight").Value = true;
				fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
				if ((Object)(object)turret.tempTransform == (Object)null)
				{
					AndysModsPlugin.Log.LogWarning((object)("Lethal turrets: temporary transform is null when turning towards target enemy. Looking up collider for " + ((Object)targetEnemy).name + "."));
					Collider[] componentsInChildren = ((Component)targetEnemy).gameObject.GetComponentsInChildren<Collider>();
					foreach (Collider val in componentsInChildren)
					{
						if (((Component)val).tag.Equals("Enemy"))
						{
							Transform tempTransform = turret.tempTransform;
							Bounds bounds = val.bounds;
							tempTransform.position = ((Bounds)(ref bounds)).center;
						}
					}
				}
				turret.turnTowardsObjectCompass.LookAt(turret.tempTransform);
				return;
			}
			if (fieldTraverser.Field<bool>("hasLineOfSight").Value)
			{
				fieldTraverser.Field<bool>("hasLineOfSight").Value = false;
				fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
			}
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			Traverse<float> obj = fieldTraverser.Field<float>("lostLOSTimer");
			obj.Value += Time.deltaTime;
			if (fieldTraverser.Field<float>("lostLOSTimer").Value >= 2f)
			{
				fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
				EnemyAI val2 = CheckForEnemyInSight();
				turret.targetPlayerWithRotation = null;
				if ((Object)(object)val2 != (Object)null)
				{
					targetEnemy = val2;
					SwitchTargetedEnemyClientRpc(((NetworkBehaviour)val2).NetworkObjectId);
				}
				else
				{
					targetEnemy = null;
					RemoveTargetedEnemyClientRpc();
				}
			}
		}

		private void Update()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected I4, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Invalid comparison between Unknown and I4
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_0718: Invalid comparison between Unknown and I4
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0980: Invalid comparison between Unknown and I4
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dea: Unknown result type (might be due to invalid IL or missing references)
			//IL_091b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0920: Unknown result type (might be due to invalid IL or missing references)
			//IL_0935: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)turret == (Object)null)
			{
				AndysModsPlugin.Log.LogInfo((object)"Lethal turrets: tried to call on NULL turret.");
				if (((NetworkBehaviour)this).NetworkObject.IsSpawned && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					AndysModsPlugin.Log.LogInfo((object)"Lethal turrets: despawned network object for client.");
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
				((Component)this).gameObject.SetActive(false);
				Object.Destroy((Object)(object)this);
				return;
			}
			if (!turret.turretActive)
			{
				fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value = false;
				wasTargetingEnemyLastFrame = false;
				turret.turretMode = (TurretMode)0;
				turret.targetPlayerWithRotation = null;
				targetEnemy = null;
				turret.mainAudio.Stop();
				turret.farAudio.Stop();
				turret.berserkAudio.Stop();
				turret.bulletCollisionAudio.Stop();
				turret.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
				if (fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value != null)
				{
					((MonoBehaviour)this).StopCoroutine(fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value);
				}
				return;
			}
			if ((Object)(object)targetEnemy != (Object)null)
			{
				if (!wasTargetingEnemyLastFrame)
				{
					wasTargetingEnemyLastFrame = true;
					if ((int)turret.turretMode == 0)
					{
						turret.turretMode = (TurretMode)1;
					}
				}
				SetTargetToEnemy();
				TurnTowardsTargetEnemyIfHasLos();
			}
			else if ((Object)(object)turret.targetPlayerWithRotation != (Object)null)
			{
				if (!fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value)
				{
					fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value = true;
					if ((int)turret.turretMode == 0)
					{
						turret.turretMode = (TurretMode)1;
					}
				}
				SetTargetToPlayerBody();
				TurnTowardsTargetIfHasLOS();
			}
			else if (fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value)
			{
				fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value = false;
				turret.turretMode = (TurretMode)0;
			}
			else if (wasTargetingEnemyLastFrame)
			{
				wasTargetingEnemyLastFrame = false;
				turret.turretMode = (TurretMode)0;
			}
			TurretMode turretMode = turret.turretMode;
			Ray value;
			switch ((int)turretMode)
			{
			case 0:
				if ((int)fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value != 0)
				{
					fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value = (TurretMode)0;
					fieldTraverser.Field<bool>("rotatingClockwise").Value = false;
					turret.mainAudio.Stop();
					turret.farAudio.Stop();
					turret.berserkAudio.Stop();
					if (fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value != null)
					{
						((MonoBehaviour)this).StopCoroutine(fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value);
					}
					fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value = ((MonoBehaviour)this).StartCoroutine(FadeBulletAudio());
					turret.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
					turret.rotationSpeed = 28f;
					fieldTraverser.Field<bool>("rotatingSmoothly").Value = true;
					turret.turretAnimator.SetInteger("TurretMode", 0);
					fieldTraverser.Field<float>("turretInterval").Value = Random.Range(0f, 0.15f);
				}
				if (!((NetworkBehaviour)this).IsServer)
				{
					break;
				}
				if (fieldTraverser.Field<float>("switchRotationTimer").Value >= 7f)
				{
					fieldTraverser.Field<float>("switchRotationTimer").Value = 0f;
					bool flag = !fieldTraverser.Field<bool>("rotatingRight").Value;
					turret.SwitchRotationClientRpc(flag);
					turret.SwitchRotationOnInterval(flag);
				}
				else
				{
					Traverse<float> obj4 = fieldTraverser.Field<float>("switchRotationTimer");
					obj4.Value += Time.deltaTime;
				}
				if (fieldTraverser.Field<float>("turretInterval").Value >= 0.25f)
				{
					fieldTraverser.Field<float>("turretInterval").Value = 0f;
					PlayerControllerB val = turret.CheckForPlayersInLineOfSight(1.35f, true);
					EnemyAI val2 = CheckForEnemyInSight(1.35f);
					if ((Object)(object)val2 != (Object)null)
					{
						targetEnemy = val2;
						SwitchTurretMode(1);
						SwitchTargetedEnemyClientRpc(((NetworkBehaviour)val2).NetworkObjectId, setModeToCharging: true);
					}
					else if ((Object)(object)val != (Object)null && !val.isPlayerDead)
					{
						turret.targetPlayerWithRotation = val;
						SwitchTurretMode(1);
						turret.SwitchTargetedPlayerClientRpc((int)val.playerClientId, true);
					}
				}
				else
				{
					Traverse<float> obj5 = fieldTraverser.Field<float>("turretInterval");
					obj5.Value += Time.deltaTime;
				}
				break;
			case 1:
				if ((int)fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value != 1)
				{
					fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value = (TurretMode)1;
					fieldTraverser.Field<bool>("rotatingClockwise").Value = false;
					turret.mainAudio.PlayOneShot(turret.detectPlayerSFX);
					turret.berserkAudio.Stop();
					WalkieTalkie.TransmitOneShotAudio(turret.mainAudio, turret.detectPlayerSFX, 1f);
					fieldTraverser.Field<float>("rotationSpeed").Value = 95f;
					fieldTraverser.Field<bool>("rotatingSmoothly").Value = false;
					fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
					turret.turretAnimator.SetInteger("TurretMode", 1);
				}
				if (!((NetworkBehaviour)this).IsServer)
				{
					break;
				}
				if (fieldTraverser.Field<float>("turretInterval").Value >= 1.5f)
				{
					fieldTraverser.Field<float>("turretInterval").Value = 0f;
					if (!fieldTraverser.Field<bool>("hasLineOfSight").Value && (Object)(object)turret.targetPlayerWithRotation != (Object)null)
					{
						turret.targetPlayerWithRotation = null;
						turret.RemoveTargetedPlayerClientRpc();
					}
					if (!fieldTraverser.Field<bool>("hasLineOfSight").Value)
					{
						targetEnemy = null;
						RemoveTargetedEnemyClientRpc();
					}
					else
					{
						SwitchTurretMode(2);
						turret.SetToModeClientRpc(2);
					}
				}
				else
				{
					Traverse<float> obj6 = fieldTraverser.Field<float>("turretInterval");
					obj6.Value += Time.deltaTime;
				}
				break;
			case 2:
				if ((int)fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value != 2)
				{
					fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value = (TurretMode)2;
					turret.berserkAudio.Stop();
					turret.mainAudio.clip = turret.firingSFX;
					turret.mainAudio.Play();
					turret.farAudio.clip = turret.firingFarSFX;
					turret.farAudio.Play();
					turret.bulletParticles.Play(true);
					turret.bulletCollisionAudio.Play();
					if (fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value != null)
					{
						((MonoBehaviour)this).StopCoroutine(fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value);
					}
					turret.bulletCollisionAudio.volume = 1f;
					fieldTraverser.Field<bool>("rotatingSmoothly").Value = false;
					fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
					turret.turretAnimator.SetInteger("TurretMode", 2);
				}
				if (fieldTraverser.Field<float>("turretInterval").Value >= 0.21f)
				{
					fieldTraverser.Field<float>("turretInterval").Value = 0f;
					DamagePlayerIfInSight();
					DamageEnemyIfInSight();
					fieldTraverser.Field<Ray>("shootRay").Value = new Ray(turret.aimPoint.position, turret.aimPoint.forward);
					if (Physics.Raycast(fieldTraverser.Field<Ray>("shootRay").Value, ref hit, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						Transform transform2 = ((Component)turret.bulletCollisionAudio).transform;
						value = fieldTraverser.Field<Ray>("shootRay").Value;
						transform2.position = ((Ray)(ref value)).GetPoint(((RaycastHit)(ref hit)).distance - 0.5f);
					}
				}
				else
				{
					Traverse<float> obj7 = fieldTraverser.Field<float>("turretInterval");
					obj7.Value += Time.deltaTime;
				}
				break;
			case 3:
				if ((int)fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value != 3)
				{
					fieldTraverser.Field<TurretMode>("turretModeLastFrame").Value = (TurretMode)3;
					turret.turretAnimator.SetInteger("TurretMode", 1);
					fieldTraverser.Field<float>("berserkTimer").Value = 1.3f;
					turret.berserkAudio.Play();
					fieldTraverser.Field<float>("rotationSpeed").Value = 77f;
					fieldTraverser.Field<bool>("enteringBerserkMode").Value = true;
					fieldTraverser.Field<bool>("rotatingSmoothly").Value = true;
					fieldTraverser.Field<float>("lostLOSTimer").Value = 0f;
					fieldTraverser.Field<bool>("wasTargetingPlayerLastFrame").Value = false;
					turret.targetPlayerWithRotation = null;
					wasTargetingEnemyLastFrame = false;
					targetEnemy = null;
				}
				if (fieldTraverser.Field<bool>("enteringBerserkMode").Value)
				{
					Traverse<float> obj = fieldTraverser.Field<float>("berserkTimer");
					obj.Value -= Time.deltaTime;
					if (fieldTraverser.Field<float>("berserkTimer").Value <= 0f)
					{
						fieldTraverser.Field<bool>("enteringBerserkMode").Value = false;
						fieldTraverser.Field<bool>("rotatingClockwise").Value = true;
						fieldTraverser.Field<float>("berserkTimer").Value = 9f;
						turret.turretAnimator.SetInteger("TurretMode", 2);
						turret.mainAudio.clip = turret.firingSFX;
						turret.mainAudio.Play();
						turret.farAudio.clip = turret.firingFarSFX;
						turret.farAudio.Play();
						turret.bulletParticles.Play(true);
						turret.bulletCollisionAudio.Play();
						if (fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value != null)
						{
							((MonoBehaviour)this).StopCoroutine(fieldTraverser.Field<Coroutine>("fadeBulletAudioCoroutine").Value);
						}
						turret.bulletCollisionAudio.volume = 1f;
					}
					break;
				}
				if (fieldTraverser.Field<float>("turretInterval").Value >= 0.21f)
				{
					fieldTraverser.Field<float>("turretInterval").Value = 0f;
					DamagePlayerIfInSight();
					DamageEnemyIfInSight();
					fieldTraverser.Field<Ray>("shootRay").Value = new Ray(turret.aimPoint.position, turret.aimPoint.forward);
					if (Physics.Raycast(fieldTraverser.Field<Ray>("shootRay").Value, ref hit, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						Transform transform = ((Component)turret.bulletCollisionAudio).transform;
						value = fieldTraverser.Field<Ray>("shootRay").Value;
						transform.position = ((Ray)(ref value)).GetPoint(((RaycastHit)(ref hit)).distance - 0.5f);
					}
				}
				else
				{
					Traverse<float> obj2 = fieldTraverser.Field<float>("turretInterval");
					obj2.Value += Time.deltaTime;
				}
				if (((NetworkBehaviour)this).IsServer)
				{
					Traverse<float> obj3 = fieldTraverser.Field<float>("berserkTimer");
					obj3.Value -= Time.deltaTime;
					if (fieldTraverser.Field<float>("berserkTimer").Value <= 0f)
					{
						SwitchTurretMode(0);
						turret.SetToModeClientRpc(0);
					}
				}
				break;
			}
			if (fieldTraverser.Field<bool>("rotatingClockwise").Value)
			{
				turret.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, turret.turretRod.localEulerAngles.y - Time.deltaTime * 20f, 180f);
				turret.turretRod.rotation = Quaternion.RotateTowards(turret.turretRod.rotation, turret.turnTowardsObjectCompass.rotation, turret.rotationSpeed * Time.deltaTime);
				return;
			}
			if (fieldTraverser.Field<bool>("rotatingSmoothly").Value)
			{
				turret.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, Mathf.Clamp(turret.targetRotation, 0f - turret.rotationRange, turret.rotationRange), 180f);
			}
			turret.turretRod.rotation = Quaternion.RotateTowards(turret.turretRod.rotation, turret.turnTowardsObjectCompass.rotation, turret.rotationSpeed * Time.deltaTime);
		}

		[ServerRpc]
		public void SpawnTurretServerRpc(ulong turretId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3636784134u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, turretId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3636784134u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SpawnTurretClientRpc(turretId);
			}
		}

		[ClientRpc]
		public void SpawnTurretClientRpc(ulong turretId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(28305254u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, turretId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 28305254u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					turret = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[turretId]).gameObject.GetComponentInChildren<Turret>();
					ManualLogSource log = AndysModsPlugin.Log;
					string arg = GameNetworkManager.Instance.localPlayerController?.playerUsername ?? "unknown player";
					Turret obj = turret;
					log.LogInfo((object)$"Lethal Turrets: spawning lethal turret for client {arg}, turret ID: {((obj != null) ? new ulong?(((NetworkBehaviour)obj).NetworkObjectId) : null)}.");
					HookupTurret(turret);
				}
			}
		}

		[ClientRpc]
		private void RemoveTargetedEnemyClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2761243141u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2761243141u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					targetEnemy = null;
				}
			}
		}

		[ClientRpc]
		private void SwitchTargetedEnemyClientRpc(ulong networkObjectId, bool setModeToCharging = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(235466695u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, networkObjectId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref setModeToCharging, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 235466695u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				targetEnemy = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId]).GetComponent<EnemyAI>();
				if (setModeToCharging)
				{
					SwitchTurretMode(1);
				}
			}
		}

		private void DamageEnemyIfInSight()
		{
			EnemyAI val = CheckForEnemyInSight();
			if ((Object)(object)val != (Object)null && (Object)(object)targetEnemy != (Object)null && ((Object)targetEnemy).name == ((Object)val).name && !targetEnemy.isEnemyDead)
			{
				int num = ((((RaycastHit)(ref hit)).distance >= 3f) ? 2 : 3);
				ManualLogSource log = AndysModsPlugin.Log;
				EnemyAI obj = targetEnemy;
				string arg = ((obj != null) ? ((Object)obj).name : null);
				object arg2 = num;
				Turret obj2 = turret;
				log.LogInfo((object)$"Lethal Turrets: hitting {arg} for {arg2} by turret ID: {((obj2 != null) ? new ulong?(((NetworkBehaviour)obj2).NetworkObjectId) : null)}.");
				if (targetEnemy is SandSpiderAI)
				{
					EnemyAI obj3 = targetEnemy;
					Player hostPlayer = Player.HostPlayer;
					obj3.HitEnemy(num, ((hostPlayer != null) ? hostPlayer.PlayerController : null) ?? null, true, -1);
				}
				else
				{
					targetEnemy.HitEnemy(num, (PlayerControllerB)null, true, -1);
				}
			}
		}

		private void DamagePlayerIfInSight()
		{
			//IL_006a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)turret.CheckForPlayersInLineOfSight(3f, false) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				if (GameNetworkManager.Instance.localPlayerController.health > 50)
				{
					GameNetworkManager.Instance.localPlayerController.DamagePlayer(50, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.KillPlayer(turret.aimPoint.forward * 40f, true, (CauseOfDeath)7, 0, default(Vector3));
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LethalTurretBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3636784134u, new RpcReceiveHandler(__rpc_handler_3636784134));
			NetworkManager.__rpc_func_table.Add(28305254u, new RpcReceiveHandler(__rpc_handler_28305254));
			NetworkManager.__rpc_func_table.Add(2761243141u, new RpcReceiveHandler(__rpc_handler_2761243141));
			NetworkManager.__rpc_func_table.Add(235466695u, new RpcReceiveHandler(__rpc_handler_235466695));
		}

		private static void __rpc_handler_3636784134(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				ulong turretId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref turretId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((LethalTurretBehaviour)(object)target).SpawnTurretServerRpc(turretId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		private static void __rpc_handler_235466695(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong networkObjectId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref networkObjectId);
				bool setModeToCharging = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref setModeToCharging, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LethalTurretBehaviour)(object)target).SwitchTargetedEnemyClientRpc(networkObjectId, setModeToCharging);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LethalTurretBehaviour";
		}
	}
}
namespace AndysModsPlugin.mods.LethalLandmines
{
	[HarmonyPatch(typeof(Landmine))]
	[HarmonyWrapSafe]
	internal static class LethalLandminesPatch
	{
		public static bool IsEnemy(Collider enemy)
		{
			if ((Object)(object)enemy == (Object)null || (Object)(object)((Component)enemy).transform == (Object)null || (Object)(object)((Component)enemy).transform.parent == (Object)null || (Object)(object)((Component)((Component)enemy).transform.parent).gameObject == (Object)null)
			{
				return false;
			}
			if (((Component)enemy).CompareTag("Enemy"))
			{
				return ((Component)((Component)enemy).transform.parent).gameObject.GetComponent<EnemyAI>().enemyType.canDie;
			}
			return false;
		}

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		internal static void OnTriggerEnter(Landmine __instance, Collider other, ref bool ___sendingExplosionRPC, ref float ___pressMineDebounceTimer)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.LethalLandmines.enabled.Value && !__instance.hasExploded && !(___pressMineDebounceTimer > 0f))
			{
				TriggerMineIfEnemy(__instance, other, ref ___sendingExplosionRPC, ref ___pressMineDebounceTimer, isExit: false);
			}
		}

		private static void TriggerMineIfEnemy(Landmine __instance, Collider other, ref bool ___sendingExplosionRPC, ref float ___pressMineDebounceTimer, bool isExit)
		{
			if (IsEnemy(other))
			{
				if (isExit)
				{
					AndysModsPlugin.Log.LogInfo((object)$"Lethal Landmines: OnTriggerExit mine explosion for {((Component)((Component)other).transform.parent).gameObject}.");
					__instance.SetOffMineAnimation();
					___sendingExplosionRPC = true;
					__instance.ExplodeMineServerRpc();
				}
				else
				{
					AndysModsPlugin.Log.LogInfo((object)$"Lethal Landmines: OnTriggerEnter mine explosion for {((Component)((Component)other).transform.parent).gameObject}.");
					___pressMineDebounceTimer = 0.5f;
					__instance.PressMineServerRpc();
				}
			}
		}

		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		internal static void OnTriggerExit(Landmine __instance, Collider other, ref bool ___sendingExplosionRPC, ref float ___pressMineDebounceTimer)
		{
			if (global::AndysModsPlugin.mods.ModManager.ModManager.LethalLandmines.enabled.Value && !__instance.hasExploded)
			{
				TriggerMineIfEnemy(__instance, other, ref ___sendingExplosionRPC, ref ___pressMineDebounceTimer, isExit: true);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace AndysModsPlugin.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}