Decompiled source of Extendo Zapper v1.0.2

NoteBoxz.Zapper.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NoteBoxz.Zapper.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("NoteBoxz.Zapper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("Zapper")]
[assembly: AssemblyTitle("NoteBoxz.Zapper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[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 Zapper
{
	[BepInPlugin("NoteBoxz.Zapper", "Zapper", "1.0.2")]
	public class Zapper : BaseUnityPlugin
	{
		internal static AssetBundle assetBundle;

		internal static ConfigEntry<string> BlacklistConfig;

		internal static ConfigEntry<float> VisualScanTime;

		internal static ConfigEntry<bool> EpilepsySafeMode;

		public static Zapper Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			BindConfig();
			NetcodePatcher();
			Patch();
			LoadAssetBundle();
			Item val = assetBundle.LoadAsset<Item>("Assets/LethalCompany/Mods/ZapMod/Zapper.asset");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/ZapMod/ZapperInfo.asset");
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, 625);
			Logger.LogInfo((object)"NoteBoxz.Zapper v1.0.2 has loaded!");
		}

		private void BindConfig()
		{
			BlacklistConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Blacklist", "", "Comma-separated list of enemy names that won't be lit up by the Zapper. Names are matched case-insensitively. Example: Centipede, Bunker Spider, Hoarding bug");
			VisualScanTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "VisualScanTime", 0.2f, "Duration of the visual targeting scan effect in seconds. Basically controls how long the screen goes dark for when zapping.");
			EpilepsySafeMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "EpilepsySafeMode", false, "When enabled, the screen does not darken and the target cubes never light up when zapping. Targeting and damage still work the same; only the flashing visual effect is disabled.");
		}

		internal static HashSet<string> GetBlacklist()
		{
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			string[] array = BlacklistConfig.Value.Split(',');
			foreach (string text in array)
			{
				string text2 = text.Trim();
				if (text2.Length > 0)
				{
					hashSet.Add(text2);
				}
			}
			return hashSet;
		}

		internal static void LoadAssetBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if (directoryName == null)
			{
				throw new InvalidOperationException("Unable to determine assembly location.");
			}
			string text = Path.Combine(directoryName, "zapmod");
			assetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)assetBundle == (Object)null)
			{
				throw new InvalidOperationException("Failed to load AssetBundle.");
			}
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("NoteBoxz.Zapper");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		private void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public class ZapperItem : GrabbableObject
	{
		[CompilerGenerated]
		private sealed class <ZapCorutine>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Vector3 origin;

			public Vector3 forward;

			public float coneAngleDegrees;

			public float maxDistance;

			public ZapperItem <>4__this;

			private bool <epilepsySafe>5__1;

			private HashSet<string> <blacklist>5__2;

			private float <totalScanTime>5__3;

			private List<Collider> <targets>5__4;

			private Collider[] <hits>5__5;

			private float <startTime>5__6;

			private GameObject <previousCube>5__7;

			private Collider[] <>s__8;

			private int <>s__9;

			private Collider <col>5__10;

			private PlayerControllerB <player>5__11;

			private EnemyAI <enemy>5__12;

			private Vector3 <toTarget>5__13;

			private float <angle>5__14;

			private int <i>5__15;

			private Collider <col>5__16;

			private float <deadline>5__17;

			private PlayerControllerB <player>5__18;

			private EnemyAI <enemy>5__19;

			private Vector3 <targetPos>5__20;

			private Vector3 <toTarget>5__21;

			private GameObject <spawned>5__22;

			private float <targetDistance>5__23;

			private RaycastHit <rayHit>5__24;

			private bool <hitSomething>5__25;

			private Renderer <rend>5__26;

			private Vector3 <rayPoint>5__27;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ZapCorutine>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<blacklist>5__2 = null;
				<targets>5__4 = null;
				<hits>5__5 = null;
				<previousCube>5__7 = null;
				<>s__8 = null;
				<col>5__10 = null;
				<player>5__11 = null;
				<enemy>5__12 = null;
				<col>5__16 = null;
				<player>5__18 = null;
				<enemy>5__19 = null;
				<spawned>5__22 = null;
				<rend>5__26 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0667: Unknown result type (might be due to invalid IL or missing references)
				//IL_0671: Expected O, but got Unknown
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_030e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0313: Unknown result type (might be due to invalid IL or missing references)
				//IL_0317: Unknown result type (might be due to invalid IL or missing references)
				//IL_031c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0323: Unknown result type (might be due to invalid IL or missing references)
				//IL_0329: Unknown result type (might be due to invalid IL or missing references)
				//IL_032e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0333: Unknown result type (might be due to invalid IL or missing references)
				//IL_0363: Unknown result type (might be due to invalid IL or missing references)
				//IL_0369: Unknown result type (might be due to invalid IL or missing references)
				//IL_036e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_043c: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0476: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Unknown result type (might be due to invalid IL or missing references)
				//IL_048c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0491: Unknown result type (might be due to invalid IL or missing references)
				//IL_0496: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_0511: Unknown result type (might be due to invalid IL or missing references)
				//IL_0517: Unknown result type (might be due to invalid IL or missing references)
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_0530: Expected O, but got Unknown
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0200: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0589: Unknown result type (might be due to invalid IL or missing references)
				//IL_0593: Expected O, but got Unknown
				Bounds bounds;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<epilepsySafe>5__1 = Zapper.EpilepsySafeMode.Value;
					if (((NetworkBehaviour)((GrabbableObject)<>4__this).playerHeldBy).IsOwner && !<epilepsySafe>5__1)
					{
						<>4__this.DarkenScreen.SetActive(true);
					}
					<>4__this.ClearZapTargets();
					<blacklist>5__2 = Zapper.GetBlacklist();
					<totalScanTime>5__3 = Zapper.VisualScanTime.Value;
					<targets>5__4 = new List<Collider>();
					<hits>5__5 = Physics.OverlapSphere(origin, maxDistance);
					<>s__8 = <hits>5__5;
					for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++)
					{
						<col>5__10 = <>s__8[<>s__9];
						if (!((Object)(object)<col>5__10 == (Object)null) && (((Component)<col>5__10).CompareTag("Enemy") || ((Component)<col>5__10).CompareTag("Player")))
						{
							<player>5__11 = ((Component)<col>5__10).gameObject.GetComponentInParent<PlayerControllerB>();
							<enemy>5__12 = ((Component)<col>5__10).gameObject.GetComponentInParent<EnemyAI>();
							if ((!((Object)(object)<player>5__11 != (Object)null) || !((Object)(object)<player>5__11 == (Object)(object)((GrabbableObject)<>4__this).playerHeldBy)) && (!((Object)(object)<enemy>5__12 != (Object)null) || !((Object)(object)<enemy>5__12.enemyType != (Object)null) || !<blacklist>5__2.Contains(<enemy>5__12.enemyType.enemyName)))
							{
								bounds = <col>5__10.bounds;
								<toTarget>5__13 = ((Bounds)(ref bounds)).center - origin;
								<angle>5__14 = Vector3.Angle(forward, <toTarget>5__13);
								if (<angle>5__14 <= coneAngleDegrees)
								{
									<targets>5__4.Add(<col>5__10);
								}
								<player>5__11 = null;
								<enemy>5__12 = null;
								<col>5__10 = null;
							}
						}
					}
					<>s__8 = null;
					<startTime>5__6 = Time.time;
					<previousCube>5__7 = null;
					<i>5__15 = 0;
					goto IL_0630;
				case 1:
					<>1__state = -1;
					goto IL_064c;
				case 2:
					<>1__state = -1;
					goto IL_064c;
				case 3:
					<>1__state = -1;
					goto IL_0603;
				case 4:
					{
						<>1__state = -1;
						break;
					}
					IL_0630:
					if (<i>5__15 < <targets>5__4.Count)
					{
						<col>5__16 = <targets>5__4[<i>5__15];
						if ((Object)(object)<col>5__16 != (Object)null)
						{
							<player>5__18 = ((Component)<col>5__16).gameObject.GetComponentInParent<PlayerControllerB>();
							<enemy>5__19 = ((Component)<col>5__16).gameObject.GetComponentInParent<EnemyAI>();
							bounds = <col>5__16.bounds;
							<targetPos>5__20 = ((Bounds)(ref bounds)).center;
							<toTarget>5__21 = <targetPos>5__20 - origin;
							if ((Object)(object)<previousCube>5__7 != (Object)null)
							{
								Object.Destroy((Object)(object)<previousCube>5__7);
							}
							<spawned>5__22 = Object.Instantiate<GameObject>(<>4__this.zapTargetPrefab, <targetPos>5__20, Quaternion.LookRotation(forward));
							<previousCube>5__7 = <spawned>5__22;
							if ((Object)(object)<spawned>5__22 != (Object)null)
							{
								Transform transform = <spawned>5__22.transform;
								bounds = <col>5__16.bounds;
								transform.localScale = ((Bounds)(ref bounds)).size;
								<>4__this.zapTargets.Add(<spawned>5__22);
								if (!((NetworkBehaviour)((GrabbableObject)<>4__this).playerHeldBy).IsOwner | <epilepsySafe>5__1)
								{
									<rend>5__26 = <spawned>5__22.GetComponentInChildren<Renderer>();
									<rend>5__26.enabled = false;
									<rend>5__26 = null;
								}
							}
							<targetDistance>5__23 = ((Vector3)(ref <toTarget>5__21)).magnitude;
							<hitSomething>5__25 = Physics.Raycast(origin, forward, ref <rayHit>5__24, <targetDistance>5__23, StartOfRound.Instance.collidersAndRoomMaskAndDefault);
							if (!<hitSomething>5__25)
							{
								<rayPoint>5__27 = origin + ((Vector3)(ref forward)).normalized * <targetDistance>5__23;
								bounds = <col>5__16.bounds;
								if (((Bounds)(ref bounds)).Contains(<rayPoint>5__27))
								{
									Zapper.Logger.LogInfo((object)("Zapped " + ((Object)<col>5__16).name));
									if ((Object)(object)<player>5__18 != (Object)null && ((NetworkBehaviour)<player>5__18).IsOwner)
									{
										<player>5__18.DamagePlayer(25, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
										<>2__current = (object)new WaitForSeconds(<totalScanTime>5__3);
										<>1__state = 1;
										return true;
									}
									if ((Object)(object)<enemy>5__19 != (Object)null && ((NetworkBehaviour)<enemy>5__19).IsOwner)
									{
										<enemy>5__19.HitEnemy(1, ((GrabbableObject)<>4__this).playerHeldBy, true, -1);
										<>2__current = (object)new WaitForSeconds(<totalScanTime>5__3);
										<>1__state = 2;
										return true;
									}
								}
							}
							<player>5__18 = null;
							<enemy>5__19 = null;
							<spawned>5__22 = null;
						}
						<deadline>5__17 = <startTime>5__6 + <totalScanTime>5__3 * (float)(<i>5__15 + 1) / (float)<targets>5__4.Count;
						goto IL_0603;
					}
					goto IL_064c;
					IL_064c:
					if (<targets>5__4.Count == 0)
					{
						<>2__current = (object)new WaitForSeconds(<totalScanTime>5__3);
						<>1__state = 4;
						return true;
					}
					break;
					IL_0603:
					if (Time.time < <deadline>5__17)
					{
						<>2__current = null;
						<>1__state = 3;
						return true;
					}
					<col>5__16 = null;
					<i>5__15++;
					goto IL_0630;
				}
				<>4__this.zapCoroutine = null;
				<>4__this.EndZapScan();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public GameObject DebugArrow = null;

		public GameObject zapTargetPrefab = null;

		public GameObject DarkenScreen = null;

		public AudioSource gunShootAudio = null;

		public AudioClip zapSound = null;

		public List<GameObject> zapTargets = new List<GameObject>();

		private Coroutine? zapCoroutine;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			Transform val = ((Component)this).transform.Find("ZapModel");
			if ((Object)(object)val == (Object)null)
			{
				Zapper.Logger.LogWarning((object)"Could not find a child named \"ZapModel\" to set render queue on.");
				return;
			}
			Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				Material[] materials = val2.materials;
				foreach (Material val3 in materials)
				{
				}
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner && zapCoroutine == null)
			{
				ShootGunAndSync();
			}
		}

		public void ShootGunAndSync()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position;
			Vector3 forward = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward;
			Zapper.Logger.LogInfo((object)"Calling shoot gun....");
			ShootGun(position, forward);
			Zapper.Logger.LogInfo((object)"Calling shoot gun and sync");
			ShootGunServerRpc(position, forward);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ShootGunServerRpc(Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2786371283u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref shotgunPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref shotgunForward);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2786371283u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ShootGunClientRpc(shotgunPosition, shotgunForward);
				}
			}
		}

		[ClientRpc]
		public void ShootGunClientRpc(Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1548251590u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref shotgunPosition);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref shotgunForward);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1548251590u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				Zapper.Logger.LogInfo((object)"Shoot gun client rpc received");
				if (((NetworkBehaviour)this).IsOwner)
				{
					Zapper.Logger.LogInfo((object)"Skipping ClientRpc echo on owner");
				}
				else
				{
					ShootGun(shotgunPosition, shotgunForward);
				}
			}
		}

		public void ShootGun(Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				base.playerHeldBy.playerBodyAnimator.SetTrigger("ShootShotgun");
			}
			gunShootAudio.PlayOneShot(zapSound);
			WalkieTalkie.TransmitOneShotAudio(gunShootAudio, zapSound, 1f);
			DebugArrow.transform.SetParent((Transform)null);
			DebugArrow.transform.position = shotgunPosition;
			DebugArrow.transform.forward = shotgunForward;
			if (zapCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(zapCoroutine);
				EndZapScan();
			}
			zapCoroutine = ((MonoBehaviour)this).StartCoroutine(ZapCorutine(shotgunPosition, shotgunForward));
		}

		[IteratorStateMachine(typeof(<ZapCorutine>d__13))]
		private IEnumerator ZapCorutine(Vector3 origin, Vector3 forward, float coneAngleDegrees = 90f, float maxDistance = 50f)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ZapCorutine>d__13(0)
			{
				<>4__this = this,
				origin = origin,
				forward = forward,
				coneAngleDegrees = coneAngleDegrees,
				maxDistance = maxDistance
			};
		}

		private void EndZapScan()
		{
			if ((Object)(object)DarkenScreen != (Object)null)
			{
				DarkenScreen.SetActive(false);
			}
			ClearZapTargets();
		}

		private void ClearZapTargets()
		{
			for (int num = zapTargets.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)zapTargets[num] != (Object)null)
				{
					Object.Destroy((Object)(object)zapTargets[num]);
				}
			}
			zapTargets.Clear();
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2786371283u, new RpcReceiveHandler(__rpc_handler_2786371283), "ShootGunServerRpc");
			((NetworkBehaviour)this).__registerRpc(1548251590u, new RpcReceiveHandler(__rpc_handler_1548251590), "ShootGunClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_2786371283(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 shotgunPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunPosition);
				Vector3 shotgunForward = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunForward);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ZapperItem)(object)target).ShootGunServerRpc(shotgunPosition, shotgunForward);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1548251590(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 shotgunPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunPosition);
				Vector3 shotgunForward = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunForward);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ZapperItem)(object)target).ShootGunClientRpc(shotgunPosition, shotgunForward);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ZapperItem";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoteBoxz.Zapper";

		public const string PLUGIN_NAME = "Zapper";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
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 NoteBoxz.Zapper.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}