Decompiled source of MissileTurretsFork v1.4.0

MissileTurret.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using JetBrains.Annotations;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MissileTurret.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("BepInEx")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ContentLoadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PropertiesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MissileTurret")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds turrets that shoot missile to Lethal Company")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+a16e9585c6e7db94ec87a784aef1821129692570")]
[assembly: AssemblyProduct("MissileTurret")]
[assembly: AssemblyTitle("MissileTurret")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 MissileTurret
{
	public class MissileAI : NetworkBehaviour
	{
		public Transform player;

		private float _speed;

		private float _currentLaunchTime;

		private readonly float launchTimeSeconds = 0.4f;

		private float _aliveTimeSeconds;

		private Rigidbody _rigidbody;

		public static float MaxTurnSpeed;

		public static float MaxSpeed;

		public static float Acceleration;

		public static float KillRange;

		public static float DamageRange;

		private float _isClientMult = 1f;

		private void Awake()
		{
			_rigidbody = ((Component)this).GetComponent<Rigidbody>();
			_currentLaunchTime = launchTimeSeconds;
		}

		private void Update()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				_aliveTimeSeconds += Time.deltaTime;
				if (_currentLaunchTime > 0f)
				{
					_currentLaunchTime -= Time.deltaTime;
					_speed += Acceleration * Time.deltaTime;
				}
				_speed = Mathf.Clamp(_speed, 0f, MaxSpeed);
				Vector3 forward = ((Component)this).transform.forward;
				Vector3 val = _rigidbody.position + forward * (_speed * Time.deltaTime);
				_rigidbody.MovePosition(val);
				if ((Object)(object)player != (Object)null)
				{
					Vector3 val2 = player.position + Vector3.up / 2f - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					Quaternion val3 = Quaternion.LookRotation(normalized);
					Quaternion val4 = Quaternion.RotateTowards(_rigidbody.rotation, val3, MaxTurnSpeed * Time.deltaTime);
					_rigidbody.MoveRotation(val4);
				}
				if (_aliveTimeSeconds > 10f)
				{
					EndIt();
				}
			}
		}

		private void OnCollisionEnter(Collision other)
		{
			EndIt();
		}

		private void EndIt()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				ExplodeClientRpc(((Component)this).transform.position, KillRange, DamageRange);
				NetworkObject val = default(NetworkObject);
				if (((Component)this).TryGetComponent<NetworkObject>(ref val) && val.IsSpawned)
				{
					val.Despawn(true);
				}
			}
		}

		[ClientRpc]
		public void ExplodeClientRpc(Vector3 position, float killRange, float damageRange)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1416639908u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref killRange, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref damageRange, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1416639908u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!((NetworkBehaviour)this).IsServer)
				{
					_isClientMult = 1.5f;
				}
				Landmine.SpawnExplosion(position, true, killRange * _isClientMult, damageRange, 50, 0f, (GameObject)null, false);
			}
		}

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

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

		private static void __rpc_handler_1416639908(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				float killRange = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref killRange, default(ForPrimitives));
				float damageRange = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref damageRange, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileAI)(object)target).ExplodeClientRpc(position, killRange, damageRange);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MissileAI";
		}
	}
	public class MissileTurretAI : NetworkBehaviour, IIndoorMapHazard
	{
		private enum MissileTurretState
		{
			SEARCHING,
			FIRING,
			CHARGING,
			DISABLED
		}

		public Transform rod;

		public Transform rail;

		public GameObject missile;

		public GameObject laser;

		public static float RotationRange;

		public static float RotationSpeed;

		private float _currentRotationSpeed;

		private MissileTurretState _state;

		private MissileTurretState _lastState;

		[CanBeNull]
		private PlayerControllerB _targetPlayer;

		private RaycastHit _hit;

		private float _currentReloadTime;

		public static float ReloadTimeSeconds;

		private float _currentChargeTime;

		public static float ChargeTimeSeconds;

		public AudioSource acquireTargetAudio;

		public AudioSource disableAudio;

		public AudioSource enableAudio;

		private float _currentDisableTime;

		public static float DisableTimeSeconds = 8f;

		public bool IsActivated()
		{
			if (_state != MissileTurretState.DISABLED)
			{
				return _currentReloadTime <= 0f;
			}
			return false;
		}

		public bool IsExtremelyHazardous()
		{
			MissileTurretState state = _state;
			if ((uint)(state - 1) <= 1u)
			{
				return true;
			}
			return false;
		}

		public IndoorMapHazardType GetMapHazardType()
		{
			return Plugin.MissileTurretMapType;
		}

		private void Awake()
		{
			_currentReloadTime = ReloadTimeSeconds;
			_currentChargeTime = ChargeTimeSeconds;
			_currentRotationSpeed = RotationSpeed;
			_currentDisableTime = DisableTimeSeconds;
			TerminalAccessibleObject val = default(TerminalAccessibleObject);
			if (((Component)this).TryGetComponent<TerminalAccessibleObject>(ref val))
			{
				((UnityEvent<PlayerControllerB>)(object)val.terminalCodeEvent).AddListener((UnityAction<PlayerControllerB>)DisableTurret);
			}
			laser.SetActive(false);
		}

		private void Update()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			MissileTurretState missileTurretState = _state;
			switch (_state)
			{
			case MissileTurretState.SEARCHING:
			{
				if (Physics.Raycast(rod.position + rod.up, rod.up, ref _hit, 30f, 1051400, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref _hit)).collider != (Object)null)
				{
					if ((Object)(object)_targetPlayer != (Object)null || ((Component)((RaycastHit)(ref _hit)).collider).TryGetComponent<PlayerControllerB>(ref _targetPlayer))
					{
						missileTurretState = MissileTurretState.CHARGING;
					}
				}
				else
				{
					_targetPlayer = null;
					missileTurretState = MissileTurretState.SEARCHING;
				}
				float z = rod.localEulerAngles.z;
				if ((z > RotationRange && z <= 180f && _currentRotationSpeed > 0f) || (z < 360f - RotationRange && z > 180f && _currentRotationSpeed < 0f))
				{
					if (((NetworkBehaviour)this).IsServer)
					{
						SetSpeedClientRpc(0f - _currentRotationSpeed);
					}
				}
				else
				{
					rod.Rotate(Vector3.forward, _currentRotationSpeed * Time.deltaTime);
				}
				break;
			}
			case MissileTurretState.CHARGING:
				if (_lastState != MissileTurretState.CHARGING)
				{
					acquireTargetAudio.Play();
					if (((NetworkBehaviour)this).IsServer)
					{
						ToggleLaserClientRpc(active: true);
					}
				}
				if (_currentChargeTime <= 0f && (Object)(object)_targetPlayer != (Object)null)
				{
					_currentChargeTime = ChargeTimeSeconds;
					missileTurretState = ((Physics.Raycast(rod.position + rod.up, ((Component)_targetPlayer).transform.position - rod.position, ref _hit, 30f, 1051400, (QueryTriggerInteraction)1) && !((Object)(object)((RaycastHit)(ref _hit)).collider == (Object)null) && ((Component)((RaycastHit)(ref _hit)).collider).TryGetComponent<PlayerControllerB>(ref _targetPlayer)) ? MissileTurretState.FIRING : MissileTurretState.SEARCHING);
					if (((NetworkBehaviour)this).IsServer)
					{
						ToggleLaserClientRpc(active: false);
					}
				}
				else
				{
					_currentChargeTime -= Time.deltaTime;
				}
				break;
			case MissileTurretState.FIRING:
				if ((Object)(object)_targetPlayer == (Object)null)
				{
					missileTurretState = MissileTurretState.SEARCHING;
					break;
				}
				if (_lastState != MissileTurretState.FIRING && ((NetworkBehaviour)this).IsServer)
				{
					MissileAI component = Object.Instantiate<GameObject>(Plugin.MissilePrefab, rod.position + Vector3.up, Quaternion.LookRotation(rod.up) * Quaternion.Euler(2f, 0f, 0f)).GetComponent<MissileAI>();
					component.player = ((Component)_targetPlayer).transform;
					((Component)component).GetComponent<NetworkObject>().Spawn(true);
					ToggleMissileClientRpc(active: false);
				}
				if (_currentReloadTime <= 0f)
				{
					if (((NetworkBehaviour)this).IsServer)
					{
						ToggleMissileClientRpc(active: true);
					}
					_currentReloadTime = ReloadTimeSeconds;
					missileTurretState = MissileTurretState.SEARCHING;
				}
				else
				{
					_currentReloadTime -= Time.deltaTime;
				}
				break;
			case MissileTurretState.DISABLED:
				if (_lastState != MissileTurretState.DISABLED)
				{
					disableAudio.Play();
					if (((NetworkBehaviour)this).IsServer)
					{
						Vector3 localEulerAngles = rail.localEulerAngles;
						localEulerAngles.x = -30f;
						rail.localEulerAngles = localEulerAngles;
						Vector3 localPosition = rail.localPosition;
						localPosition.y = -0.67f;
						rail.localPosition = localPosition;
						SetRailClientRpc(localEulerAngles, localPosition);
					}
				}
				if (_currentDisableTime <= 0f)
				{
					_currentDisableTime = DisableTimeSeconds;
					enableAudio.Play();
					if (((NetworkBehaviour)this).IsServer)
					{
						Vector3 localEulerAngles2 = rail.localEulerAngles;
						localEulerAngles2.x = 0f;
						rail.localEulerAngles = localEulerAngles2;
						Vector3 localPosition2 = rail.localPosition;
						localPosition2.y = 0f;
						rail.localPosition = localPosition2;
						SetRailClientRpc(localEulerAngles2, localPosition2);
					}
					missileTurretState = MissileTurretState.SEARCHING;
				}
				else
				{
					_currentDisableTime -= Time.deltaTime;
				}
				break;
			}
			_lastState = _state;
			if (missileTurretState != _state && ((NetworkBehaviour)this).IsServer)
			{
				_state = missileTurretState;
				SetStateClientRpc(_state, _lastState);
			}
		}

		public void DisableTurret(PlayerControllerB pc)
		{
			if ((Object)(object)pc != (Object)null && ((NetworkBehaviour)pc).IsOwner)
			{
				SetStateClientRpc(MissileTurretState.DISABLED, _state);
			}
		}

		[ClientRpc(RequireOwnership = false)]
		private void SetStateClientRpc(MissileTurretState state, MissileTurretState lastState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3177718372u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<MissileTurretState>(ref state, default(ForEnums));
					((FastBufferWriter)(ref val)).WriteValueSafe<MissileTurretState>(ref lastState, default(ForEnums));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3177718372u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					_state = state;
					_lastState = lastState;
				}
			}
		}

		[ClientRpc(DeferLocal = true)]
		private void SetSpeedClientRpc(float rotationSpeed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(515399522u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref rotationSpeed, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 515399522u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					_currentRotationSpeed = rotationSpeed;
				}
			}
		}

		[ClientRpc]
		private void SetRailClientRpc(Vector3 localEulers, Vector3 localPos)
		{
			//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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3970896126u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref localEulers);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref localPos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3970896126u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					rail.localPosition = localPos;
					rail.localEulerAngles = localEulers;
				}
			}
		}

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

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

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3177718372u, new RpcReceiveHandler(__rpc_handler_3177718372), "SetStateClientRpc");
			((NetworkBehaviour)this).__registerRpc(515399522u, new RpcReceiveHandler(__rpc_handler_515399522), "SetSpeedClientRpc");
			((NetworkBehaviour)this).__registerRpc(3970896126u, new RpcReceiveHandler(__rpc_handler_3970896126), "SetRailClientRpc");
			((NetworkBehaviour)this).__registerRpc(1599590863u, new RpcReceiveHandler(__rpc_handler_1599590863), "ToggleMissileClientRpc");
			((NetworkBehaviour)this).__registerRpc(1199733162u, new RpcReceiveHandler(__rpc_handler_1199733162), "ToggleLaserClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_3177718372(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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				MissileTurretState state = default(MissileTurretState);
				((FastBufferReader)(ref reader)).ReadValueSafe<MissileTurretState>(ref state, default(ForEnums));
				MissileTurretState lastState = default(MissileTurretState);
				((FastBufferReader)(ref reader)).ReadValueSafe<MissileTurretState>(ref lastState, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileTurretAI)(object)target).SetStateClientRpc(state, lastState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_515399522(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float speedClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref speedClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileTurretAI)(object)target).SetSpeedClientRpc(speedClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3970896126(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 localEulers = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref localEulers);
				Vector3 localPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref localPos);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileTurretAI)(object)target).SetRailClientRpc(localEulers, localPos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1599590863(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool active = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref active, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileTurretAI)(object)target).ToggleMissileClientRpc(active);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1199733162(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool active = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref active, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MissileTurretAI)(object)target).ToggleLaserClientRpc(active);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MissileTurretAI";
		}
	}
	[BepInPlugin("Finnerex.MissileTurret", "MissileTurret", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPriority(200)]
		public static class Patch_StartOfRoundStart
		{
			private static void Postfix(SelectableLevel[] ___levels)
			{
				if (___levels == null || ___levels.Length == 0)
				{
					return;
				}
				SelectableLevel val = ___levels[0];
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				IndoorMapHazard[] indoorMapHazards = val.indoorMapHazards;
				if (indoorMapHazards != null && indoorMapHazards.Length != 0)
				{
					IndoorMapHazard val2 = Array.Find(val.indoorMapHazards, (IndoorMapHazard mapHazard) => mapHazard != null && (Object)(object)mapHazard.hazardType != (Object)null && string.Equals(((Object)mapHazard.hazardType).name, "Turrets", StringComparison.Ordinal));
					if (val2 != null && (Object)(object)val2.hazardType.prefabToSpawn != (Object)null)
					{
						VanillaTurretPrefab = val2.hazardType.prefabToSpawn;
					}
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")]
		[HarmonyPriority(200)]
		public static class Patch_SpawnMapObjects
		{
			private static void Prefix()
			{
				RandomMapObject[] array = Object.FindObjectsByType<RandomMapObject>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				RandomMapObject[] array2 = array;
				foreach (RandomMapObject val in array2)
				{
					if (!((Object)(object)val == (Object)null) && val.spawnablePrefabs != null && val.spawnablePrefabs.Count != 0 && val.spawnablePrefabs.Contains(MissileTurretPrefab) && !val.spawnablePrefabs.Contains(VanillaTurretPrefab))
					{
						val.spawnablePrefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)(object)MissileTurretPrefab);
					}
				}
			}
		}

		public static IndoorMapHazardType MissileTurretMapType;

		public static GameObject MissileTurretPrefab;

		public static GameObject MissilePrefab;

		public static GameObject VanillaTurretPrefab;

		public static ManualLogSource TheLogger;

		public int MaxTurrets;

		public int MinTurrets;

		public static AnimationCurve curve;

		private void Awake()
		{
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			TheLogger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Missile Turret Loading???");
			Configure();
			Patch();
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "missileturretassetbundle"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load assets");
				return;
			}
			MissileTurretPrefab = val.LoadAsset<GameObject>("MissileTurret");
			MissilePrefab = val.LoadAsset<GameObject>("Missile");
			MissileTurretAI missileTurretAI = MissileTurretPrefab.AddComponent<MissileTurretAI>();
			missileTurretAI.rod = MissileTurretPrefab.transform.Find("missileTurret/Mount/Rod");
			missileTurretAI.rail = missileTurretAI.rod.Find("Rod.001");
			missileTurretAI.missile = ((Component)missileTurretAI.rail.Find("Cylinder")).gameObject;
			missileTurretAI.acquireTargetAudio = ((Component)missileTurretAI.rod).GetComponent<AudioSource>();
			missileTurretAI.disableAudio = ((Component)missileTurretAI.rod.Find("DisableSound")).GetComponent<AudioSource>();
			missileTurretAI.enableAudio = ((Component)missileTurretAI.rod.Find("EnableSound")).GetComponent<AudioSource>();
			missileTurretAI.laser = ((Component)missileTurretAI.rod.Find("LaserLight")).gameObject;
			MissilePrefab.AddComponent<MissileAI>();
			Utilities.FixMixerGroups(MissileTurretPrefab);
			Utilities.FixMixerGroups(MissilePrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MissileTurretPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(MissilePrefab);
			if (MinTurrets >= MaxTurrets)
			{
				curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)MinTurrets, 0f, 0f),
					new Keyframe(1f, (float)MaxTurrets, 0f, 0f)
				});
			}
			else
			{
				curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)MinTurrets, 0.267f, 0.267f, 0f, 0.246f),
					new Keyframe(1f, (float)MaxTurrets, 61f, 61f, 0.015f * (float)MaxTurrets, 0f)
				});
			}
			SpawnableMapObject val2 = new SpawnableMapObject
			{
				prefabToSpawn = MissileTurretPrefab,
				spawnFacingAwayFromWall = true,
				numberToSpawn = curve
			};
			MapObjects.RegisterMapObject(val2, (LevelTypes)(-1), (Func<SelectableLevel, AnimationCurve>)((SelectableLevel _) => curve));
			RegisteredMapObject val3 = MapObjects.mapObjects.Find((RegisteredMapObject x) => (Object)(object)x.indoorMapHazardType != (Object)null && (Object)(object)x.indoorMapHazardType.prefabToSpawn == (Object)(object)MissileTurretPrefab);
			if (val3 != null)
			{
				MissileTurretMapType = val3.indoorMapHazardType;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Missile Turret Loaded!!!");
		}

		private void Patch()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Harmony val = new Harmony("Finnerex.MissileTurret");
			val.PatchAll(typeof(Patch_StartOfRoundStart));
			val.PatchAll(typeof(Patch_SpawnMapObjects));
		}

		private void Configure()
		{
			//IL_001d: 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_0038: Expected O, but got Unknown
			//IL_0038: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_006e: Expected O, but got Unknown
			//IL_0088: 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_00a7: Expected O, but got Unknown
			//IL_00a7: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00e6: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_011f: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_015e: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_0197: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01d0: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_0209: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0248: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_0281: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			MaxTurrets = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("Spawn Options", "Max Turrets"), 6, new ConfigDescription("Maximum number of turrets that can be spawned", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MinTurrets = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("Spawn Options", "Min Turrets"), 0, new ConfigDescription("Minimum number of turrets that can be spawned", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileAI.MaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Options", "Max Speed"), 0.7f, new ConfigDescription("Maximum speed of a missile", (AcceptableValueBase)null, Array.Empty<object>())).Value * 100f;
			MissileAI.MaxTurnSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Options", "Turn Rate"), 0.6f, new ConfigDescription("How fast the missile can turn", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileAI.Acceleration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Options", "Acceleration"), 0.6f, new ConfigDescription("Acceleration of the missile", (AcceptableValueBase)null, Array.Empty<object>())).Value * 100f;
			MissileAI.KillRange = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Options", "Explosive Kill Range"), 2f, new ConfigDescription("Distance from explosion to kill", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileAI.DamageRange = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Options", "Explosive Damage Range"), 5f, new ConfigDescription("Distance from explosion to damage", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileTurretAI.RotationRange = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Turret Options", "Rotation Range"), 45f, new ConfigDescription("The angle the turret's search is restricted to in degrees left & right", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileTurretAI.RotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Turret Options", "Rotation Rate"), 0.25f, new ConfigDescription("The speed at which the turret rotates", (AcceptableValueBase)null, Array.Empty<object>())).Value * 100f;
			MissileTurretAI.ReloadTimeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Turret Options", "Reload Time"), 6f, new ConfigDescription("The time it takes for the turret to reload in seconds", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MissileTurretAI.ChargeTimeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Missile Turret Options", "Charge Time"), 0.5f, new ConfigDescription("The time it takes for the turret to shoot at a target in seconds", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			((BaseUnityPlugin)this).Config.OrphanedEntries.Clear();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MissileTurret";

		public const string PLUGIN_NAME = "MissileTurret";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace MissileTurret.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}