Decompiled source of ShockMine v1.0.0

plugins/com.github.BETCGaming.ShockMine.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FMOD.Studio;
using FMODUnity;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: IgnoresAccessChecksTo("SharedAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.BETCGaming.ShockMine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+45c1abe0e7e4f9df0b08d85184bdadd611a8dcf1")]
[assembly: AssemblyProduct("com.github.BETCGaming.ShockMine")]
[assembly: AssemblyTitle("ShockMine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace ShockMine
{
	internal static class LandmineParity
	{
		internal static bool IsShockMineEquipped(PlayerInfo player)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			if (Plugin.Enabled.Value)
			{
				return (int)player.Inventory.GetEffectivelyEquippedItem(true) == 201;
			}
			return false;
		}

		internal static bool IsShockMineItem(Hittable hittable)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if (hittable.AsEntity.IsItem)
			{
				return (int)hittable.AsEntity.AsItem.ItemType == 201;
			}
			return false;
		}

		internal static MethodInfo? FindLocalFunction(Type type, string outer, string local)
		{
			string prefix = "<" + outer + ">g__" + local + "|";
			return new Type[1] { type }.Concat(type.GetNestedTypes(AccessTools.all)).SelectMany((Func<Type, IEnumerable<MethodInfo>>)AccessTools.GetDeclaredMethods).FirstOrDefault((MethodInfo m) => m.Name.StartsWith(prefix, StringComparison.Ordinal) && m.ReturnType == typeof(bool));
		}

		internal static bool ReportMissing(MethodInfo? method, string what)
		{
			if ((object)method == null)
			{
				Plugin.Log.LogWarning((object)("Could not find " + what + "; the Shock Mine will not follow that landmine rule."));
			}
			return (object)method != null;
		}
	}
	[HarmonyPatch(typeof(PlayerMovement), "CanMove")]
	internal static class ShockCanMovePatch
	{
		private static void Postfix(PlayerMovement __instance, ref bool __result)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if (__result && LandmineParity.IsShockMineEquipped(__instance.PlayerInfo) && (int)__instance.PlayerInfo.Inventory.CurrentItemUse == 1)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerMovement), "CanJump")]
	internal static class ShockCanJumpPatch
	{
		private static void Postfix(PlayerMovement __instance, ref bool __result)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (__result && LandmineParity.IsShockMineEquipped(__instance.PlayerInfo) && (int)__instance.PlayerInfo.Inventory.CurrentItemUse != 0)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch]
	internal static class ShockCanRotatePatch
	{
		private static readonly MethodInfo? Target = LandmineParity.FindLocalFunction(typeof(PlayerMovement), "ApplyRotation", "CanRotate");

		private static bool Prepare()
		{
			return LandmineParity.ReportMissing(Target, "PlayerMovement's ApplyRotation.CanRotate");
		}

		private static MethodBase? TargetMethod()
		{
			return Target;
		}

		private static void Postfix(PlayerMovement __instance, ref bool __result)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			if (__result && Plugin.Enabled.Value && (int)__instance.PlayerInfo.Inventory.GetEffectivelyEquippedItem(false) == 201 && __instance.PlayerInfo.Inventory.IsUsingItemAtAll)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch]
	internal static class ShockVaporizePatch
	{
		private static readonly MethodInfo? Target = LandmineParity.FindLocalFunction(typeof(Hittable), "HitWithItemInternal", "ShouldBeDestroyedByHit");

		private static readonly FieldInfo? This;

		private static bool Prepare()
		{
			return LandmineParity.ReportMissing(Target, "Hittable's HitWithItemInternal.ShouldBeDestroyedByHit");
		}

		private static MethodBase? TargetMethod()
		{
			return Target;
		}

		private static void Postfix(object __instance, ref bool __result)
		{
			if (__result && Plugin.Enabled.Value)
			{
				Hittable val = (Hittable)(((__instance is Hittable) ? __instance : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
				if ((Object)(object)val != (Object)null && LandmineParity.IsShockMineItem(val))
				{
					__result = false;
				}
			}
		}

		static ShockVaporizePatch()
		{
			Type type = Target?.DeclaringType;
			This = (((object)type != null && type != typeof(Hittable)) ? AccessTools.Field(type, "<>4__this") : null);
		}
	}
	[HarmonyPatch]
	internal static class ShockRocketTrailPatch
	{
		private static readonly MethodInfo? Target = LandmineParity.FindLocalFunction(typeof(Hittable), "UpdateSwungByRocketDriverTrailEffects", "ShouldPlay");

		private static bool Prepare()
		{
			return LandmineParity.ReportMissing(Target, "Hittable's rocket-driver trail ShouldPlay");
		}

		private static MethodBase? TargetMethod()
		{
			return Target;
		}

		private static void Postfix(Hittable __instance, ref bool __result)
		{
			Landmine val = default(Landmine);
			if (__result && Plugin.Enabled.Value && LandmineParity.IsShockMineItem(__instance) && ((Component)__instance).TryGetComponent<Landmine>(ref val) && val.IsPlanted)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch]
	internal static class ShockDisarmNoticePatch
	{
		private static PlayerInventory? pendingDisarmer;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PhysicalItem), "UserCode_CmdGiveToPlayer__PlayerInventory__NetworkConnectionToClient")]
		private static void GivePrefix(PhysicalItem __instance, PlayerInventory player)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			pendingDisarmer = null;
			Landmine val = default(Landmine);
			if (Plugin.Enabled.Value && (int)__instance.ItemType == 201 && !((Object)(object)player == (Object)null) && ((Component)__instance).TryGetComponent<Landmine>(ref val) && val.IsArmed && (Object)(object)val.Owner != (Object)(object)player)
			{
				pendingDisarmer = player;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PhysicalItem), "UserCode_CmdGiveToPlayer__PlayerInventory__NetworkConnectionToClient")]
		private static void GivePostfix()
		{
			pendingDisarmer = null;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerInventory), "ServerTryAddItem")]
		private static void AddPostfix(PlayerInventory __instance, ItemType itemToAdd, bool __result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if (__result && (int)itemToAdd == 201 && !((Object)(object)pendingDisarmer != (Object)(object)__instance))
			{
				pendingDisarmer = null;
				if (NetworkServer.active)
				{
					__instance.PlayerInfo.RpcInformDisarmedLandmine();
					Trace.Log("server: " + ((Object)__instance.PlayerInfo).name + " disarmed a Shock Mine");
				}
			}
		}
	}
	[HarmonyPatch(typeof(Landmine), "ServerExplode")]
	internal static class LandmineExplodePatch
	{
		private static bool Prefix(Landmine __instance)
		{
			ShockMarker shockMarker = default(ShockMarker);
			if (!Plugin.Enabled.Value || !((Component)__instance).TryGetComponent<ShockMarker>(ref shockMarker))
			{
				return true;
			}
			if (!NetworkServer.active)
			{
				return false;
			}
			if ((Object)(object)((Component)__instance).GetComponent<ShockSeizeWindow>() != (Object)null)
			{
				return false;
			}
			ShockSeizeWindow.Begin(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(Hittable), "UpdateIceBlock")]
	internal static class HittableIceBlockPatch
	{
		private static void Postfix(Hittable __instance)
		{
			if (Plugin.Enabled.Value && ShockVictims.IsHeld(__instance) && (Object)(object)__instance.IceBlock != (Object)null)
			{
				IceBlockHider.Hide(__instance.IceBlock);
			}
		}
	}
	internal static class IceBlockHider
	{
		private sealed class Hidden
		{
			public Renderer[] Renderers = Array.Empty<Renderer>();

			public bool ColliderWasEnabled;

			public Action? Restore;
		}

		private static readonly Dictionary<FreezeBombIceBlock, Hidden> Blocks = new Dictionary<FreezeBombIceBlock, Hidden>();

		public static void Hide(FreezeBombIceBlock block)
		{
			if ((Object)(object)block == (Object)null || Blocks.ContainsKey(block))
			{
				return;
			}
			List<Renderer> list = new List<Renderer>();
			Renderer[] componentsInChildren = ((Component)block).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled)
				{
					val.enabled = false;
					list.Add(val);
				}
			}
			Hidden hidden = new Hidden
			{
				Renderers = list.ToArray(),
				ColliderWasEnabled = ((Object)(object)block.Collider != (Object)null && ((Collider)block.Collider).enabled)
			};
			if ((Object)(object)block.Collider != (Object)null)
			{
				((Collider)block.Collider).enabled = false;
			}
			hidden.Restore = delegate
			{
				Restore(block);
			};
			block.WillBeReturnedToPool += hidden.Restore;
			Blocks[block] = hidden;
		}

		private static void Restore(FreezeBombIceBlock block)
		{
			if ((Object)(object)block == (Object)null || !Blocks.TryGetValue(block, out Hidden value))
			{
				return;
			}
			Blocks.Remove(block);
			if (value.Restore != null)
			{
				block.WillBeReturnedToPool -= value.Restore;
			}
			Renderer[] renderers = value.Renderers;
			foreach (Renderer val in renderers)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.enabled = true;
				}
			}
			if ((Object)(object)block.Collider != (Object)null && value.ColliderWasEnabled)
			{
				((Collider)block.Collider).enabled = true;
			}
		}

		public static void Reset()
		{
			foreach (FreezeBombIceBlock item in new List<FreezeBombIceBlock>(Blocks.Keys))
			{
				Restore(item);
			}
			Blocks.Clear();
		}
	}
	internal static class MirrorSerializers
	{
		public static void Register()
		{
			Writer<ShockSpawnMessage>.write = delegate(NetworkWriter writer, ShockSpawnMessage message)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				writer.Write<Vector3>(message.Position);
				writer.Write<Quaternion>(message.Rotation);
				writer.Write<Vector3>(message.Velocity);
				writer.Write<Vector3>(message.AngularVelocity);
				writer.Write<byte>(message.ArmType);
				writer.Write<ItemUseId>(message.UseId);
				writer.Write<ulong>(message.UseHash);
			};
			Reader<ShockSpawnMessage>.read = (NetworkReader reader) => new ShockSpawnMessage
			{
				Position = reader.Read<Vector3>(),
				Rotation = reader.Read<Quaternion>(),
				Velocity = reader.Read<Vector3>(),
				AngularVelocity = reader.Read<Vector3>(),
				ArmType = reader.Read<byte>(),
				UseId = reader.Read<ItemUseId>(),
				UseHash = reader.Read<ulong>()
			};
			Writer<ShockSeizedMessage>.write = delegate(NetworkWriter writer, ShockSeizedMessage message)
			{
				writer.Write<uint>(message.VictimNetId);
				writer.Write<float>(message.RemainingSeconds);
			};
			Reader<ShockSeizedMessage>.read = (NetworkReader reader) => new ShockSeizedMessage
			{
				VictimNetId = reader.Read<uint>(),
				RemainingSeconds = reader.Read<float>()
			};
			Writer<ShockReleasedMessage>.write = delegate(NetworkWriter writer, ShockReleasedMessage message)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				writer.Write<uint>(message.VictimNetId);
				writer.Write<uint>(message.OwnerNetId);
				writer.Write<ItemUseId>(message.UseId);
				writer.Write<Vector3>(message.MinePosition);
			};
			Reader<ShockReleasedMessage>.read = (NetworkReader reader) => new ShockReleasedMessage
			{
				VictimNetId = reader.Read<uint>(),
				OwnerNetId = reader.Read<uint>(),
				UseId = reader.Read<ItemUseId>(),
				MinePosition = reader.Read<Vector3>()
			};
			Writer<ShockSprungMessage>.write = delegate(NetworkWriter writer, ShockSprungMessage message)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				writer.Write<Vector3>(message.Position);
			};
			Reader<ShockSprungMessage>.read = (NetworkReader reader) => new ShockSprungMessage
			{
				Position = reader.Read<Vector3>()
			};
			Writer<ShockHelloMessage>.write = delegate
			{
			};
			Reader<ShockHelloMessage>.read = (NetworkReader _) => default(ShockHelloMessage);
			Plugin.Log.LogInfo((object)"Registered Shock Mine message serializers.");
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct ShockHelloMessage : NetworkMessage
	{
	}
	internal static class ModGate
	{
		private const float GraceSeconds = 10f;

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

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

		private static bool serverHandlerRegistered;

		private static bool helloSent;

		public static void Reset()
		{
			FirstSeen.Clear();
			Modded.Clear();
		}

		public static void Tick()
		{
			EnsureHandlers();
			AnnounceSelf();
			KickUnmodded();
		}

		private static void EnsureHandlers()
		{
			if (NetworkServer.active)
			{
				if (!serverHandlerRegistered)
				{
					NetworkServer.RegisterHandler<ShockHelloMessage>((Action<NetworkConnectionToClient, ShockHelloMessage>)delegate(NetworkConnectionToClient conn, ShockHelloMessage _)
					{
						MarkModded(conn);
					}, true);
					serverHandlerRegistered = true;
				}
			}
			else if (serverHandlerRegistered)
			{
				serverHandlerRegistered = false;
				Reset();
			}
		}

		private static void AnnounceSelf()
		{
			if (!NetworkClient.active || NetworkServer.active)
			{
				helloSent = NetworkServer.active;
			}
			else if (!helloSent && NetworkClient.isConnected && ((NetworkConnection)NetworkClient.connection).isAuthenticated)
			{
				NetworkClient.Send<ShockHelloMessage>(default(ShockHelloMessage), 0);
				helloSent = true;
				Trace.Log("client: announced the mod to the host");
			}
		}

		private static void MarkModded(NetworkConnectionToClient? conn)
		{
			if (conn != null && Modded.Add(conn.connectionId))
			{
				Plugin.Log.LogInfo((object)$"Connection {conn.connectionId} has ShockMine installed.");
			}
		}

		private static void KickUnmodded()
		{
			if (!NetworkServer.active || !Plugin.BlockUnmodded.Value || !Plugin.Enabled.Value)
			{
				return;
			}
			float time = Time.time;
			List<NetworkConnectionToClient> list = null;
			foreach (NetworkConnectionToClient value2 in NetworkServer.connections.Values)
			{
				if (value2 != null && !Modded.Contains(value2.connectionId) && (object)value2 != NetworkServer.localConnection && ((NetworkConnection)value2).isAuthenticated)
				{
					if (!FirstSeen.TryGetValue(value2.connectionId, out var value))
					{
						FirstSeen[value2.connectionId] = time;
					}
					else if (time - value >= 10f)
					{
						(list ?? (list = new List<NetworkConnectionToClient>())).Add(value2);
					}
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (NetworkConnectionToClient item in list)
			{
				Plugin.Log.LogWarning((object)($"Disconnecting connection {item.connectionId}: ShockMine is not installed. " + "Set BlockUnmodded to false to allow unmodded players (they will still be handed Shock Mines they cannot resolve, so this is not recommended)."));
				FirstSeen.Remove(item.connectionId);
				((NetworkConnection)item).Disconnect();
			}
		}
	}
	internal sealed class ModRunner : MonoBehaviour
	{
		internal static ModRunner? Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void FixedUpdate()
		{
			ShockLocalVictim.FixedTick();
		}

		private void Update()
		{
			ShockNetwork.EnsureHandlers();
			ShockLocalization.EnsureApplied();
			ShockItem.EnsureNetworkPrefabRegistered();
			ShockEquipment.EnsureRegistered();
			ShockVfx.Tick();
			ShockUi.Tick();
			ShockLocalVictim.Tick();
			ModGate.Tick();
			if (Plugin.DebugHotkeys.Value && Keyboard.current != null)
			{
				if (((ButtonControl)Keyboard.current[(Key)100]).wasPressedThisFrame)
				{
					GiveMine();
				}
				if (((ButtonControl)Keyboard.current[(Key)101]).wasPressedThisFrame)
				{
					TripNearestMine();
				}
			}
		}

		private static void TripNearestMine()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Plugin.Log.LogWarning((object)"F8 ignored: only the host can trip a mine.");
				return;
			}
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if ((Object)(object)localPlayerInfo == (Object)null)
			{
				Plugin.Log.LogWarning((object)"F8 ignored: no local player yet.");
				return;
			}
			Landmine val = null;
			float num = float.MaxValue;
			ShockMarker[] array = Object.FindObjectsByType<ShockMarker>((FindObjectsSortMode)0);
			Landmine val2 = default(Landmine);
			foreach (ShockMarker shockMarker in array)
			{
				if (((Component)shockMarker).TryGetComponent<Landmine>(ref val2) && !((Object)(object)((Component)val2).GetComponent<ShockSeizeWindow>() != (Object)null))
				{
					Vector3 val3 = ((Component)shockMarker).transform.position - ((Component)localPlayerInfo).transform.position;
					float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogInfo((object)"F8: no unsprung Shock Mine in the scene.");
				return;
			}
			ShockSeizeWindow.Begin(val);
			Plugin.Log.LogInfo((object)$"F8: sprung a Shock Mine {Mathf.Sqrt(num):0.#}m away.");
		}

		private static void GiveMine()
		{
			if (!NetworkServer.active)
			{
				Plugin.Log.LogWarning((object)"F7 ignored: only the host can hand out items directly.");
				return;
			}
			PlayerInventory localPlayerInventory = GameManager.LocalPlayerInventory;
			if ((Object)(object)localPlayerInventory == (Object)null)
			{
				Plugin.Log.LogWarning((object)"F7 ignored: no local player inventory yet.");
				return;
			}
			bool flag = localPlayerInventory.ServerTryAddItem((ItemType)201, 1);
			Plugin.Log.LogInfo((object)(flag ? "Gave the local player a Shock Mine." : "Could not give a Shock Mine (inventory full?)."));
		}
	}
	[BepInPlugin("com.github.BETCGaming.ShockMine", "ShockMine", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Id = "com.github.BETCGaming.ShockMine";

		internal static ManualLogSource Log { get; private set; }

		internal static ConfigEntry<bool> Enabled { get; private set; }

		internal static ConfigEntry<bool> BlockUnmodded { get; private set; }

		internal static ConfigEntry<float> SoundVolume { get; private set; }

		internal static ConfigEntry<bool> DebugHotkeys { get; private set; }

		internal static ConfigEntry<bool> VerboseLogging { get; private set; }

		public static string Name => "ShockMine";

		public static string Version => "1.0.0";

		private void Awake()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the Shock Mine. When off, the item is not registered and never spawns.");
			SoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SoundVolume", 0.8f, new ConfigDescription("Volume of the zapping loop played while a player is seized.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			BlockUnmodded = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "BlockUnmodded", true, "Disconnect players who do not have this mod installed. They cannot handle the Shock Mine if the item pool hands them one. Host setting; ignored on clients.");
			DebugHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugHotkeys", false, "F7 gives the local player a Shock Mine, F8 trips the nearest one. Host only, for testing.");
			VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Log every step of planting a mine, tripping it and releasing its victims. For diagnosing a mine that never fires or never lets go.");
			MirrorSerializers.Register();
			ShockLocalization.Initialize();
			new Harmony("com.github.BETCGaming.ShockMine").PatchAll();
			((Component)this).gameObject.AddComponent<ModRunner>();
			Log.LogInfo((object)("Plugin " + Name + " v" + Version + " is loaded!"));
		}
	}
	internal static class ShockAudio
	{
		private static readonly Dictionary<uint, EventInstance> Hums = new Dictionary<uint, EventInstance>();

		public static void PlayCatch(Vector3 position)
		{
			//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)
			//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)
			EventReference thunderstormLightningStrikeEvent = GameManager.AudioSettings.ThunderstormLightningStrikeEvent;
			if (!((EventReference)(ref thunderstormLightningStrikeEvent)).IsNull)
			{
				RuntimeManager.PlayOneShot(thunderstormLightningStrikeEvent, position);
			}
		}

		public static void BeginHum(uint victimNetId, Vector3 position)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			if (!Hums.ContainsKey(victimNetId))
			{
				EventReference electromagnetShieldHumEvent = GameManager.AudioSettings.ElectromagnetShieldHumEvent;
				if (!((EventReference)(ref electromagnetShieldHumEvent)).IsNull)
				{
					EventInstance value = RuntimeManager.CreateInstance(electromagnetShieldHumEvent);
					((EventInstance)(ref value)).set3DAttributes(RuntimeUtils.To3DAttributes(position));
					((EventInstance)(ref value)).setVolume(Plugin.SoundVolume.Value);
					((EventInstance)(ref value)).start();
					Hums[victimNetId] = value;
				}
			}
		}

		public static void Follow(uint victimNetId, Vector3 position)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (Hums.TryGetValue(victimNetId, out var value) && ((EventInstance)(ref value)).isValid())
			{
				((EventInstance)(ref value)).set3DAttributes(RuntimeUtils.To3DAttributes(position));
			}
		}

		public static void EndHum(uint victimNetId)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Hums.TryGetValue(victimNetId, out var value))
			{
				Hums.Remove(victimNetId);
				Stop(value);
			}
		}

		public static void Reset()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<uint, EventInstance> hum in Hums)
			{
				Stop(hum.Value);
			}
			Hums.Clear();
		}

		private static void Stop(EventInstance instance)
		{
			//IL_000d: 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)
			if (((EventInstance)(ref instance)).isValid())
			{
				((EventInstance)(ref instance)).stop((STOP_MODE)0);
				((EventInstance)(ref instance)).release();
			}
		}
	}
	internal static class ShockEquipment
	{
		public const EquipmentType Type = (EquipmentType)201;

		private static EquipmentSettings? settings;

		private static bool failedOnce;

		public static void EnsureRegistered()
		{
			if (SingletonBehaviour<EquipmentManager>.HasInstance)
			{
				EquipmentCollection equipmentCollection = SingletonBehaviour<EquipmentManager>.Instance.equipmentCollection;
				if ((Object)(object)equipmentCollection != (Object)null)
				{
					Register(equipmentCollection);
				}
			}
		}

		public static void Register(EquipmentCollection collection)
		{
			if (!Plugin.Enabled.Value || failedOnce)
			{
				return;
			}
			try
			{
				if (settings == null)
				{
					settings = Build(collection);
				}
				if (settings != null)
				{
					if (Array.IndexOf(collection.equipment, settings) < 0)
					{
						EquipmentSettings[] array = collection.equipment;
						Array.Resize(ref array, array.Length + 1);
						array[^1] = settings;
						collection.equipment = array;
					}
					collection.equipmentDictionary[(EquipmentType)201] = settings;
				}
			}
			catch (Exception arg)
			{
				failedOnce = true;
				Plugin.Log.LogError((object)$"Could not register the Shock Mine's held model: {arg}");
			}
		}

		private static EquipmentSettings? Build(EquipmentCollection collection)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0093: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			EquipmentSettings val = default(EquipmentSettings);
			if (!collection.TryGetEquipmentSettings((EquipmentType)10, ref val) || (Object)(object)val.Prefab == (Object)null)
			{
				return null;
			}
			GameObject gameObject = ((Component)val.Prefab).gameObject;
			bool activeSelf = gameObject.activeSelf;
			gameObject.SetActive(false);
			GameObject val2;
			try
			{
				val2 = Object.Instantiate<GameObject>(gameObject);
			}
			finally
			{
				gameObject.SetActive(activeSelf);
			}
			((Object)val2).name = "ShockMineModel";
			ShockItem.Recolour(val2);
			GameObject val3 = new GameObject("ShockMineEquipment");
			val3.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)val3);
			val2.transform.SetParent(val3.transform, false);
			val2.SetActive(true);
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			Equipment val4 = val3.AddComponent<Equipment>();
			val4.Type = (EquipmentType)201;
			Equipment val5 = default(Equipment);
			if (val2.TryGetComponent<Equipment>(ref val5))
			{
				val5.Type = (EquipmentType)201;
			}
			EquipmentSettings val6 = new EquipmentSettings();
			val6.Type = (EquipmentType)201;
			val6.Prefab = val4;
			Plugin.Log.LogInfo((object)$"Built the Shock Mine's held model as EquipmentType {201}.");
			return val6;
		}
	}
	[HarmonyPatch(typeof(EquipmentCollection), "Initialize")]
	internal static class EquipmentCollectionInitializePatch
	{
		private static void Postfix(EquipmentCollection __instance)
		{
			ShockEquipment.Register(__instance);
		}
	}
	[HarmonyPatch(typeof(PlayerInventory), "LocalPlayerUpdateEquipmentSwitchers")]
	internal static class EquipmentSwitcherPatch
	{
		private static readonly MethodInfo? CanHoldEquipment = FindCanHoldEquipment();

		private static bool Prefix(PlayerInventory __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.GetEffectivelyEquippedItem(false) != 201)
			{
				return true;
			}
			ShockEquipment.EnsureRegistered();
			if ((object)CanHoldEquipment == null)
			{
				return true;
			}
			bool flag = (bool)CanHoldEquipment.Invoke(__instance, null);
			bool flag2 = !((Enum)__instance.thrownItem).HasFlag((Enum)(object)(ThrownItemHand)2);
			__instance.PlayerInfo.RightHandEquipmentSwitcher.SetEquipment((EquipmentType)((flag && flag2) ? 201 : 0));
			__instance.PlayerInfo.LeftHandEquipmentSwitcher.SetEquipment((EquipmentType)0);
			return false;
		}

		private static MethodInfo? FindCanHoldEquipment()
		{
			MethodInfo methodInfo = AccessTools.GetDeclaredMethods(typeof(PlayerInventory)).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("<LocalPlayerUpdateEquipmentSwitchers>g__CanHoldEquipment", StringComparison.Ordinal) && m.ReturnType == typeof(bool) && m.GetParameters().Length == 0);
			if ((object)methodInfo == null)
			{
				Plugin.Log.LogWarning((object)"Could not find PlayerInventory's CanHoldEquipment; the Shock Mine will not show in hand.");
			}
			return methodInfo;
		}
	}
	internal sealed class ShockMarker : MonoBehaviour
	{
	}
	internal static class ShockItem
	{
		public const ItemType Type = (ItemType)201;

		public const string DisplayName = "Shock Mine";

		public const Rule SeizeDurationRule = (Rule)202;

		internal static readonly Color DeviceColor = new Color(0.3529412f, 38f / 51f, 44f / 51f, 1f);

		private const uint NetworkAssetId = 3047489793u;

		private static ItemData? itemData;

		private static bool failedOnce;

		private static GameObject? prefabHolder;

		private static GameObject PrefabHolder
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)prefabHolder == (Object)null)
				{
					prefabHolder = new GameObject("ShockMinePrefabs");
					prefabHolder.SetActive(false);
					Object.DontDestroyOnLoad((Object)(object)prefabHolder);
				}
				return prefabHolder;
			}
		}

		public static GameObject? Prefab
		{
			get
			{
				ItemData? obj = itemData;
				if (obj == null)
				{
					return null;
				}
				return obj.Prefab;
			}
		}

		public static void Register(ItemCollection collection)
		{
			if (!Plugin.Enabled.Value || failedOnce)
			{
				return;
			}
			try
			{
				if (itemData == null)
				{
					itemData = BuildItemData(collection);
				}
				if (itemData != null)
				{
					if (Array.IndexOf(collection.items, itemData) < 0)
					{
						ItemData[] array = collection.items;
						Array.Resize(ref array, array.Length + 1);
						array[^1] = itemData;
						collection.items = array;
					}
					collection.allItemData[(ItemType)201] = itemData;
				}
			}
			catch (Exception arg)
			{
				failedOnce = true;
				Plugin.Log.LogError((object)$"Failed to register the Shock Mine, it will not appear: {arg}");
			}
		}

		private static ItemData? BuildItemData(ItemCollection collection)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			ItemData val = default(ItemData);
			if (!collection.TryGetItemData((ItemType)8, ref val))
			{
				Plugin.Log.LogError((object)"Landmine item data not found; cannot build the Shock Mine from it.");
				return null;
			}
			if ((Object)(object)val.Prefab == (Object)null)
			{
				return null;
			}
			ItemData val2 = new ItemData();
			FieldInfo[] fields = typeof(ItemData).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				fieldInfo.SetValue(val2, fieldInfo.GetValue(val));
			}
			val2.Type = (ItemType)201;
			val2.Icon = BuildIcon();
			val2.Prefab = BuildPrefab(val.Prefab);
			val2.HitInfoFeedMessageIcon = (InfoFeedIconType)19;
			val2.name = null;
			val2.Initialize();
			Plugin.Log.LogInfo((object)$"Built Shock Mine item data as ItemType {201}.");
			return val2;
		}

		private static GameObject BuildPrefab(GameObject donorPrefab)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			bool activeSelf = donorPrefab.activeSelf;
			donorPrefab.SetActive(false);
			GameObject val;
			try
			{
				val = Object.Instantiate<GameObject>(donorPrefab);
			}
			finally
			{
				donorPrefab.SetActive(activeSelf);
			}
			((Object)val).name = "ShockMineItem";
			PhysicalItem val2 = default(PhysicalItem);
			if (val.TryGetComponent<PhysicalItem>(ref val2))
			{
				val2.itemType = (ItemType)201;
			}
			else
			{
				Plugin.Log.LogWarning((object)"Shock Mine pickup has no PhysicalItem component.");
			}
			if ((Object)(object)val.GetComponent<Landmine>() == (Object)null)
			{
				Plugin.Log.LogError((object)"The landmine prefab has no Landmine component; the mine will never arm or trip.");
			}
			val.AddComponent<ShockMarker>();
			val.transform.SetParent(PrefabHolder.transform, false);
			val.SetActive(true);
			Recolour(val);
			RegisterNetworkPrefab(val);
			return val;
		}

		private static void RegisterNetworkPrefab(GameObject prefab)
		{
			NetworkIdentity val = default(NetworkIdentity);
			if (!prefab.TryGetComponent<NetworkIdentity>(ref val))
			{
				Plugin.Log.LogWarning((object)"Shock Mine pickup has no NetworkIdentity; it will not spawn when dropped.");
				return;
			}
			FieldInfo fieldInfo = AccessTools.Field(typeof(NetworkIdentity), "_assetId");
			if ((object)fieldInfo == null)
			{
				Plugin.Log.LogWarning((object)"Mirror's assetId field was not found; dropped mines may appear as ordinary landmines.");
				return;
			}
			fieldInfo.SetValue(val, 0u);
			NetworkClient.RegisterPrefab(prefab, 3047489793u);
			Plugin.Log.LogInfo((object)$"Registered the Shock Mine pickup as network asset {val.assetId}.");
		}

		public static void EnsureNetworkPrefabRegistered()
		{
			ItemData? obj = itemData;
			if (!((Object)(object)((obj != null) ? obj.Prefab : null) == (Object)null) && (!NetworkClient.prefabs.TryGetValue(3047489793u, out var value) || !((Object)(object)value == (Object)(object)itemData.Prefab)))
			{
				NetworkClient.RegisterPrefab(itemData.Prefab, 3047489793u);
			}
		}

		internal static void Recolour(GameObject target)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = target.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if (val2.HasProperty("_BaseColor"))
					{
						val2.SetColor("_BaseColor", DeviceColor);
					}
					if (val2.HasProperty("_Color"))
					{
						val2.SetColor("_Color", DeviceColor);
					}
				}
			}
		}

		private static Sprite? BuildIcon()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			using Stream stream = typeof(ShockItem).Assembly.GetManifestResourceStream("ShockMine.Assets.shock-mine-icon.png");
			if (stream == null)
			{
				Plugin.Log.LogWarning((object)"Embedded Shock Mine icon missing; the item will show no icon.");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				Plugin.Log.LogWarning((object)"Shock Mine icon failed to decode; the item will show no icon.");
				return null;
			}
			((Object)val).name = "ShockMineIcon";
			Object.DontDestroyOnLoad((Object)(object)val);
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			((Object)val2).name = "ShockMineIcon";
			Object.DontDestroyOnLoad((Object)(object)val2);
			return val2;
		}
	}
	[HarmonyPatch(typeof(ItemCollection), "Initialize")]
	internal static class ItemCollectionInitializePatch
	{
		private static void Postfix(ItemCollection __instance)
		{
			ShockItem.Register(__instance);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class ItemDataNamePatch
	{
		private static bool Prefix(ItemData __instance, ref string __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			if ((int)__instance.Type != 201)
			{
				return true;
			}
			__result = "Shock Mine";
			return false;
		}
	}
	internal static class ShockLocalization
	{
		private static bool applied;

		public static void Initialize()
		{
			LocalizationManager.LanguageChanged += delegate
			{
				applied = false;
			};
		}

		public static void EnsureApplied()
		{
			//IL_0016: 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)
			if (applied)
			{
				return;
			}
			try
			{
				StringTable val = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase)?.GetTable(TableReference.op_Implicit(((object)(StringTable)1/*cast due to .constrained prefix*/).ToString()), (Locale)null);
				if (!((Object)(object)val == (Object)null))
				{
					string text = $"ITEM_{201}";
					((DetailedLocalizationTable<StringTableEntry>)(object)val).AddEntry(text, "Shock Mine");
					applied = true;
					Plugin.Log.LogInfo((object)("Registered the name 'Shock Mine' as " + text + "."));
				}
			}
			catch (Exception ex)
			{
				applied = true;
				Plugin.Log.LogWarning((object)("Could not name the Shock Mine, its name may show as a key: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAnimatorIo), "SetEquippedItem")]
	internal static class AnimatorEquippedItemPatch
	{
		private static void Prefix(ref ItemType equippedItem)
		{
			if ((int)equippedItem == 201)
			{
				equippedItem = (ItemType)8;
			}
		}
	}
	internal static class ShockLocalVictim
	{
		private sealed class PendingKnockout
		{
			public ShockReleasedMessage Message;

			public double Deadline;
		}

		private const double ThawTimeoutSeconds = 3.0;

		private static readonly List<PendingKnockout> Pending = new List<PendingKnockout>();

		public static void FixedTick()
		{
			//IL_005d: 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)
			if (!Plugin.Enabled.Value || !NetworkClient.active)
			{
				return;
			}
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if (!((Object)(object)localPlayerInfo == (Object)null) && ShockVictims.IsHeld(((NetworkBehaviour)localPlayerInfo).netId))
			{
				Entity asEntity = localPlayerInfo.AsEntity;
				if (!((Object)(object)asEntity == (Object)null) && asEntity.HasRigidbody && !asEntity.Rigidbody.isKinematic)
				{
					asEntity.Rigidbody.linearVelocity = Vector3.zero;
					asEntity.Rigidbody.angularVelocity = Vector3.zero;
				}
			}
		}

		public static void QueueKnockout(ShockReleasedMessage message)
		{
			Pending.Add(new PendingKnockout
			{
				Message = message,
				Deadline = Time.timeAsDouble + 3.0
			});
		}

		public static void Tick()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			if (Pending.Count == 0)
			{
				return;
			}
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			for (int num = Pending.Count - 1; num >= 0; num--)
			{
				PendingKnockout pendingKnockout = Pending[num];
				if ((Object)(object)localPlayerInfo == (Object)null || ((NetworkBehaviour)localPlayerInfo).netId != pendingKnockout.Message.VictimNetId)
				{
					Pending.RemoveAt(num);
				}
				else if ((int)localPlayerInfo.AsHittable.FrozenState == 2)
				{
					if (Time.timeAsDouble >= pendingKnockout.Deadline)
					{
						Plugin.Log.LogWarning((object)"Shock Mine: the thaw never arrived, so the knockout was skipped.");
						Pending.RemoveAt(num);
					}
				}
				else
				{
					Pending.RemoveAt(num);
					KnockOut(localPlayerInfo, pendingKnockout.Message);
				}
			}
		}

		public static void Reset()
		{
			Pending.Clear();
		}

		private static void KnockOut(PlayerInfo local, ShockReleasedMessage message)
		{
			//IL_0049: 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_0059: 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_0069: 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)
			PlayerInfo val = null;
			if (message.OwnerNetId != 0 && NetworkClient.spawned.TryGetValue(message.OwnerNetId, out var value) && (Object)(object)value != (Object)null)
			{
				((Component)value).TryGetComponent<PlayerInfo>(ref val);
			}
			PlayerMovement movement = local.Movement;
			movement.CancelKnockoutImmunity();
			bool flag2 = default(bool);
			bool flag3 = default(bool);
			bool flag = movement.TryKnockOut(val, (KnockoutType)12, false, ((Component)local).transform.InverseTransformPoint(message.MinePosition), Vector3.Distance(((Component)local).transform.position, message.MinePosition), Vector3.zero, (ElectromagnetShieldHitBlockType)2, message.UseId, false, true, ref flag2, ref flag3);
			Trace.Log($"client: local player drops over (knocked={flag}, " + $"teamProtected={flag3})");
		}
	}
	internal struct ShockSpawnMessage : NetworkMessage
	{
		public Vector3 Position;

		public Quaternion Rotation;

		public Vector3 Velocity;

		public Vector3 AngularVelocity;

		public byte ArmType;

		public ItemUseId UseId;

		public ulong UseHash;
	}
	internal struct ShockSeizedMessage : NetworkMessage
	{
		public uint VictimNetId;

		public float RemainingSeconds;
	}
	internal struct ShockSprungMessage : NetworkMessage
	{
		public Vector3 Position;
	}
	internal struct ShockReleasedMessage : NetworkMessage
	{
		public uint VictimNetId;

		public uint OwnerNetId;

		public ItemUseId UseId;

		public Vector3 MinePosition;
	}
	internal static class ShockNetwork
	{
		private const double MinSecondsBetweenSpawns = 0.2;

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

		private static bool serverHandlerRegistered;

		private static bool clientHandlerRegistered;

		public static void EnsureHandlers()
		{
			if (NetworkServer.active)
			{
				if (!serverHandlerRegistered)
				{
					NetworkServer.RegisterHandler<ShockSpawnMessage>((Action<NetworkConnectionToClient, ShockSpawnMessage>)OnServerSpawnRequest, true);
					serverHandlerRegistered = true;
					Trace.Log("server: registered the mine spawn handler");
				}
			}
			else if (serverHandlerRegistered)
			{
				serverHandlerRegistered = false;
				LastSpawnPerConnection.Clear();
			}
			if (NetworkClient.active)
			{
				if (!clientHandlerRegistered)
				{
					NetworkClient.RegisterHandler<ShockSeizedMessage>((Action<ShockSeizedMessage>)OnClientSeized, true);
					NetworkClient.RegisterHandler<ShockReleasedMessage>((Action<ShockReleasedMessage>)OnClientReleased, true);
					NetworkClient.RegisterHandler<ShockSprungMessage>((Action<ShockSprungMessage>)OnClientSprung, true);
					clientHandlerRegistered = true;
					Trace.Log("client: registered the seize handlers");
				}
			}
			else if (clientHandlerRegistered)
			{
				clientHandlerRegistered = false;
				ShockVictims.Reset();
				ShockVfx.Reset();
				ShockAudio.Reset();
				ShockUi.Clear();
				IceBlockHider.Reset();
				ShockLocalVictim.Reset();
			}
		}

		public static void ServerAnnounceSeized(Hittable victim, float remainingSeconds)
		{
			ShockVictims.MarkHeld(((NetworkBehaviour)victim).netId);
			NetworkServer.SendToAll<ShockSeizedMessage>(new ShockSeizedMessage
			{
				VictimNetId = ((NetworkBehaviour)victim).netId,
				RemainingSeconds = remainingSeconds
			}, 0, false);
		}

		public static void ServerAnnounceReleased(Hittable victim, PlayerInfo? owner, ItemUseId useId, Vector3 minePosition)
		{
			//IL_003b: 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_0043: 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)
			ShockVictims.MarkReleased(((NetworkBehaviour)victim).netId);
			NetworkServer.SendToAll<ShockReleasedMessage>(new ShockReleasedMessage
			{
				VictimNetId = ((NetworkBehaviour)victim).netId,
				OwnerNetId = (((Object)(object)owner != (Object)null) ? ((NetworkBehaviour)owner).netId : 0u),
				UseId = useId,
				MinePosition = minePosition
			}, 0, false);
		}

		public static void ServerAnnounceSprung(Vector3 position)
		{
			//IL_000a: 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)
			NetworkServer.SendToAll<ShockSprungMessage>(new ShockSprungMessage
			{
				Position = position
			}, 0, false);
		}

		private static void OnClientSprung(ShockSprungMessage message)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ShockAudio.PlayCatch(message.Position);
		}

		private static void OnClientSeized(ShockSeizedMessage message)
		{
			//IL_0063: 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_0069: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			ShockVictims.MarkHeld(message.VictimNetId);
			ShockVfx.BeginZap(message.VictimNetId, message.RemainingSeconds);
			if (NetworkClient.spawned.TryGetValue(message.VictimNetId, out var value) && !((Object)(object)value == (Object)null))
			{
				Hittable val = default(Hittable);
				if (((Component)value).TryGetComponent<Hittable>(ref val) && (Object)(object)val.IceBlock != (Object)null)
				{
					IceBlockHider.Hide(val.IceBlock);
				}
				Vector3 position = ((Component)value).transform.position;
				ShockAudio.PlayCatch(position);
				ShockAudio.BeginHum(message.VictimNetId, position);
				if (value.isLocalPlayer)
				{
					CameraModuleController.Shake(GameManager.CameraGameplaySettings.ThunderstormExplosionScreenshakeSettings, position, 1f, 1f);
					ShockUi.BeginCountdown(message.RemainingSeconds);
				}
			}
		}

		private static void OnClientReleased(ShockReleasedMessage message)
		{
			ShockVictims.MarkReleased(message.VictimNetId);
			ShockVfx.EndZap(message.VictimNetId);
			ShockAudio.EndHum(message.VictimNetId);
			if (NetworkClient.spawned.TryGetValue(message.VictimNetId, out var value) && (Object)(object)value != (Object)null && value.isLocalPlayer)
			{
				ShockUi.Clear();
				ShockLocalVictim.QueueKnockout(message);
			}
		}

		public static void RequestSpawn(Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity, LandmineArmType armType, ItemUseId useId, ulong useHash)
		{
			//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0034: 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)
			ShockSpawnMessage shockSpawnMessage = new ShockSpawnMessage
			{
				Position = position,
				Rotation = rotation,
				Velocity = velocity,
				AngularVelocity = angularVelocity,
				ArmType = (byte)armType,
				UseId = useId,
				UseHash = useHash
			};
			if (NetworkServer.active)
			{
				ServerSpawn((NetworkConnection?)(object)NetworkServer.localConnection, shockSpawnMessage);
			}
			else
			{
				NetworkClient.Send<ShockSpawnMessage>(shockSpawnMessage, 0);
			}
		}

		private static void OnServerSpawnRequest(NetworkConnectionToClient conn, ShockSpawnMessage message)
		{
			double timeAsDouble = Time.timeAsDouble;
			if (LastSpawnPerConnection.TryGetValue(conn.connectionId, out var value) && timeAsDouble - value < 0.2)
			{
				Plugin.Log.LogWarning((object)$"Ignoring rapid mine spawn from connection {conn.connectionId}.");
				return;
			}
			LastSpawnPerConnection[conn.connectionId] = timeAsDouble;
			ServerSpawn((NetworkConnection?)(object)conn, message);
		}

		private static void ServerSpawn(NetworkConnection? conn, ShockSpawnMessage message)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			PlayerInventory val = ResolveInventory(conn);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Mine spawn ignored: the requesting connection has no player.");
				return;
			}
			if (!val.ServerValidateAndConsumeItemUse(message.UseHash))
			{
				Plugin.Log.LogWarning((object)"Mine spawn refused: the item use did not validate.");
				return;
			}
			if (!SingletonNetworkBehaviour<CourseManager>.HasInstance)
			{
				Plugin.Log.LogWarning((object)"Mine spawn ignored: no CourseManager yet.");
				return;
			}
			PhysicalItem val2 = SingletonNetworkBehaviour<CourseManager>.Instance.ServerSpawnItem((ItemType)201, 1, message.Position, message.Rotation, message.Velocity, message.AngularVelocity, (PlayerInventory)null, message.UseId, false);
			Landmine val3 = default(Landmine);
			if ((Object)(object)val2 == (Object)null)
			{
				Plugin.Log.LogError((object)"Mine spawn failed: the item did not instantiate.");
			}
			else if (!((Component)val2).TryGetComponent<Landmine>(ref val3))
			{
				Plugin.Log.LogError((object)"Spawned Shock Mine has no Landmine component; destroying it.");
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			else
			{
				val3.ServerInitialize((LandmineArmType)message.ArmType, val, message.UseId);
				NetworkServer.Spawn(((Component)val3).gameObject, (NetworkConnectionToClient)null);
				Trace.Log($"server: spawned a mine as {(object)(LandmineArmType)message.ArmType} for {((Object)val).name}");
			}
		}

		private static PlayerInventory? ResolveInventory(NetworkConnection? conn)
		{
			if ((Object)(object)((conn != null) ? conn.identity : null) == (Object)null)
			{
				return null;
			}
			PlayerInfo component = ((Component)conn.identity).GetComponent<PlayerInfo>();
			if (component == null)
			{
				return null;
			}
			return component.Inventory;
		}
	}
	internal static class ShockPool
	{
		private static ItemSpawnerSettings? managed;

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

		public static bool FallbackActive { get; private set; }

		public static void Remember(ItemSpawnerSettings settings)
		{
			managed = settings;
		}

		public static bool IsManaged(ItemSpawnerSettings settings)
		{
			return (Object)(object)managed == (Object)(object)settings;
		}

		public static bool IsManagedPool(ItemPool pool)
		{
			return ManagedPools.Contains(((Object)pool).GetInstanceID());
		}

		public static void EnsureInjected()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			if (!Plugin.Enabled.Value || (Object)(object)managed == (Object)null || FallbackActive)
			{
				return;
			}
			try
			{
				ManagedPools.Clear();
				Inject(managed.AheadOfBallItemPoolDefaults);
				Inject(managed.AheadOfBallItemPool);
				foreach (ItemPoolData itemPoolsDefault in managed.ItemPoolsDefaults)
				{
					Inject(itemPoolsDefault.pool);
				}
				foreach (ItemPoolData itemPool in managed.ItemPools)
				{
					Inject(itemPool.pool);
				}
			}
			catch (Exception arg)
			{
				UseFallback($"the Shock Mine could not be added to the item pools: {arg}");
			}
		}

		private static void Inject(ItemPool? pool)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pool == (Object)null)
			{
				return;
			}
			float spawnChanceWeight = pool.GetSpawnChanceWeight((ItemType)8);
			if (!(spawnChanceWeight <= 0f))
			{
				ManagedPools.Add(((Object)pool).GetInstanceID());
				if (!pool.ContainsItemType((ItemType)201))
				{
					ItemSpawnChance[] array = pool.spawnChances;
					Array.Resize(ref array, array.Length + 1);
					array[^1] = new ItemSpawnChance
					{
						item = (ItemType)201,
						spawnChanceWeight = spawnChanceWeight
					};
					pool.spawnChances = array;
					pool.UpdateTotalWeight();
					Plugin.Log.LogInfo((object)$"Added the Shock Mine to pool '{((Object)pool).name}' at weight {spawnChanceWeight:0.###}.");
				}
			}
		}

		public static void UseFallback(string reason)
		{
			if (!FallbackActive)
			{
				FallbackActive = true;
				Plugin.Log.LogError((object)("Shock Mine item probabilities are unavailable: " + reason + " Falling back to picking the item as items are drawn, so it still spawns, but it has no slider in the match setup."));
				Withdraw();
			}
		}

		private static void Withdraw()
		{
			//IL_0041: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)managed == (Object)null)
			{
				return;
			}
			try
			{
				RemoveFrom(managed.AheadOfBallItemPoolDefaults);
				RemoveFrom(managed.AheadOfBallItemPool);
				foreach (ItemPoolData itemPoolsDefault in managed.ItemPoolsDefaults)
				{
					RemoveFrom(itemPoolsDefault.pool);
				}
				foreach (ItemPoolData itemPool in managed.ItemPools)
				{
					RemoveFrom(itemPool.pool);
				}
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Could not take the Shock Mine back out of the item pools: {arg}");
			}
		}

		private static void RemoveFrom(ItemPool? pool)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0043: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pool == (Object)null || !pool.ContainsItemType((ItemType)201))
			{
				return;
			}
			List<ItemSpawnChance> list = new List<ItemSpawnChance>(pool.spawnChances.Length);
			ItemSpawnChance[] spawnChances = pool.spawnChances;
			foreach (ItemSpawnChance val in spawnChances)
			{
				if ((int)val.item != 201)
				{
					list.Add(val);
				}
			}
			pool.spawnChances = list.ToArray();
			pool.UpdateTotalWeight();
		}
	}
	[HarmonyPatch(typeof(ItemSpawnerSettings), "ResetRuntimeData")]
	internal static class ItemSpawnerRuntimePoolPatch
	{
		private static void Postfix(ItemSpawnerSettings __instance)
		{
			if (ShockPool.IsManaged(__instance))
			{
				ShockPool.EnsureInjected();
			}
		}
	}
	[HarmonyPatch(typeof(ItemPool), "GetWeightedRandomItem")]
	internal static class ItemPoolDrawPatch
	{
		private static bool Prefix(ItemPool __instance, ref ItemType __result)
		{
			if (!Plugin.Enabled.Value || !ShockPool.FallbackActive)
			{
				return true;
			}
			if (!ShockPool.IsManagedPool(__instance))
			{
				return true;
			}
			float spawnChanceWeight = __instance.GetSpawnChanceWeight((ItemType)8);
			float totalSpawnChanceWeight = __instance.TotalSpawnChanceWeight;
			if (spawnChanceWeight <= 0f || totalSpawnChanceWeight <= 0f)
			{
				return true;
			}
			if (Random.value >= spawnChanceWeight / (totalSpawnChanceWeight + spawnChanceWeight))
			{
				return true;
			}
			__result = (ItemType)201;
			return false;
		}
	}
	[HarmonyPatch(typeof(MatchSetupRules), "Initialize")]
	internal static class MatchSetupRuleRowPatch
	{
		private const string DurationKey = "RULE_SHOCK_MINE_SEIZE_DURATION";

		private const string DurationText = "Shock Mine seize duration";

		private static DropdownOption? durationRow;

		private static int ownerId;

		private static TableReference labelTable;

		private static bool labelTableKnown;

		private static bool languageHookInstalled;

		private static void Postfix(MatchSetupRules __instance)
		{
			if (!Plugin.Enabled.Value)
			{
				return;
			}
			try
			{
				Build(__instance);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)($"Could not add the Shock Mine row to the match setup: {arg} The seize duration " + "stays at its default."));
			}
		}

		private static void Build(MatchSetupRules rules)
		{
			MatchSetupRules.CategoryPerRule[(Rule)202] = (RuleCategory)3;
			if ((Object)(object)durationRow == (Object)null || ownerId != ((Object)rules).GetInstanceID())
			{
				durationRow = Clone(rules, "ShockMineSeizeDuration", "RULE_SHOCK_MINE_SEIZE_DURATION", "Shock Mine seize duration");
			}
			ownerId = ((Object)rules).GetInstanceID();
			if (!((Object)(object)durationRow == (Object)null))
			{
				SetDurationOptions(durationRow);
				AccessTools.Method(typeof(MatchSetupRules), "InitDropdown", (Type[])null, (Type[])null).Invoke(rules, new object[3]
				{
					durationRow,
					(object)(Rule)202,
					null
				});
				if (durationRow.OptionsCount != ShockRules.DurationOptions.Length)
				{
					Plugin.Log.LogWarning((object)($"The seize duration row has {durationRow.OptionsCount} options rather than " + $"{ShockRules.DurationOptions.Length}; something is repopulating it."));
				}
			}
		}

		private static DropdownOption? Clone(MatchSetupRules rules, string name, string key, string text)
		{
			DropdownOption hitOtherPlayersBalls = rules.hitOtherPlayersBalls;
			if ((Object)(object)hitOtherPlayersBalls == (Object)null)
			{
				Plugin.Log.LogWarning((object)("No battle row to copy; '" + text + "' has no control."));
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)hitOtherPlayersBalls).gameObject, ((Component)hitOtherPlayersBalls).transform.parent);
			((Object)val).name = name;
			val.transform.SetSiblingIndex(((Component)hitOtherPlayersBalls).transform.GetSiblingIndex() + 1);
			DropdownOption component = val.GetComponent<DropdownOption>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				Plugin.Log.LogWarning((object)("The copied battle row has no DropdownOption; leaving '" + text + "' out of the UI."));
				return null;
			}
			LocalizedDropdownSuppressor.Suppress(component.Localized);
			Label(val, key, text);
			Plugin.Log.LogInfo((object)("Added '" + text + "' to the match setup's Battle section."));
			return component;
		}

		private static void SetDurationOptions(DropdownOption row)
		{
			LocalizedDropdownSuppressor.Suppress(row.Localized);
			List<string> list = new List<string>(ShockRules.DurationOptions.Length);
			float[] durationOptions = ShockRules.DurationOptions;
			foreach (float num in durationOptions)
			{
				list.Add(num.ToString("0", CultureInfo.InvariantCulture) + "s");
			}
			row.SetOptions(list);
		}

		private static void Label(GameObject clone, string key, string text)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			LocalizeStringEvent componentInChildren = clone.GetComponentInChildren<LocalizeStringEvent>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				Plugin.Log.LogWarning((object)"The copied row has no localized label; it will read as the row it was copied from.");
				return;
			}
			labelTable = ((LocalizedReference)componentInChildren.StringReference).TableReference;
			labelTableKnown = true;
			if (AddEntry(key, text))
			{
				((LocalizedReference)componentInChildren.StringReference).TableEntryReference = TableEntryReference.op_Implicit(key);
				componentInChildren.RefreshString();
				InstallLanguageHook();
				return;
			}
			TMP_Text component = ((Component)componentInChildren).GetComponent<TMP_Text>();
			Object.Destroy((Object)(object)componentInChildren);
			if ((Object)(object)component != (Object)null)
			{
				component.text = text;
				Plugin.Log.LogWarning((object)("Localization was not ready; '" + text + "' is labelled in English only."));
			}
		}

		private static bool AddEntry(string key, string text)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!labelTableKnown)
			{
				return false;
			}
			try
			{
				StringTable val = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase)?.GetTable(labelTable, (Locale)null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				((DetailedLocalizationTable<StringTableEntry>)(object)val).AddEntry(key, text);
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not name the rule '" + text + "': " + ex.Message));
				return false;
			}
		}

		private static void InstallLanguageHook()
		{
			if (!languageHookInstalled)
			{
				LocalizationManager.LanguageChanged += delegate
				{
					AddEntry("RULE_SHOCK_MINE_SEIZE_DURATION", "Shock Mine seize duration");
				};
				languageHookInstalled = true;
			}
		}
	}
	[HarmonyPatch(typeof(LocalizeDropdown), "RefreshOptions")]
	internal static class LocalizedDropdownSuppressor
	{
		private static readonly HashSet<int> Suppressed = new HashSet<int>();

		public static void Suppress(LocalizeDropdown? localized)
		{
			if ((Object)(object)localized != (Object)null)
			{
				Suppressed.Add(((Object)localized).GetInstanceID());
			}
		}

		private static bool Prefix(LocalizeDropdown __instance)
		{
			if (Plugin.Enabled.Value)
			{
				return !Suppressed.Contains(((Object)__instance).GetInstanceID());
			}
			return true;
		}
	}
	internal static class ShockRules
	{
		internal static readonly float[] DurationOptions = new float[4] { 3f, 5f, 7f, 9f };

		internal const int DefaultDurationIndex = 1;

		public static float SeizeSeconds
		{
			get
			{
				int num = Mathf.Clamp((int)MatchSetupRules.GetValue((Rule)202), 0, DurationOptions.Length - 1);
				return DurationOptions[num];
			}
		}
	}
	[HarmonyPatch(typeof(MatchSetupRules), "GetDefaultValue")]
	internal static class DefaultValuePatch
	{
		private static bool Prefix(Rule rule, ref float __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)rule == 202)
			{
				__result = 1f;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(MatchSetupRules), "Initialize")]
	internal static class MatchSetupRulesPatch
	{
		private static void Prefix(MatchSetupRules __instance)
		{
			if (Plugin.Enabled.Value && !ShockPool.FallbackActive)
			{
				try
				{
					Extend(__instance);
				}
				catch (Exception arg)
				{
					ShockPool.UseFallback($"the match setup screen could not be extended: {arg}");
					return;
				}
				ShockPool.Remember(__instance.itemSpawnerSettings);
				ShockPool.EnsureInjected();
			}
		}

		private static void Extend(MatchSetupRules rules)
		{
			ItemType[] array = rules.itemOrder;
			if (Array.IndexOf(array, (ItemType)201) < 0)
			{
				ItemType[] array2 = (ItemType[])(object)new ItemType[array.Length + 1];
				Array.Copy(array, array2, array.Length);
				array2[^1] = (ItemType)201;
				array = array2;
			}
			int[] array3 = new int[Math.Max(201, array.Length)];
			for (int i = 0; i < array3.Length; i++)
			{
				array3[i] = Array.IndexOf(array, (ItemType)(i + 1));
			}
			rules.itemOrder = array;
			rules.itemOrderLookup = array3;
		}
	}
	internal sealed class ShockSeizeWindow : MonoBehaviour
	{
		private Landmine mine;

		private ItemUseId useId;

		private double endTime;

		private readonly List<Hittable> held = new List<Hittable>();

		private bool firstSweepDone;

		public static ShockSeizeWindow Begin(Landmine mine)
		{
			//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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			ShockSeizeWindow shockSeizeWindow = ((Component)mine).gameObject.AddComponent<ShockSeizeWindow>();
			shockSeizeWindow.mine = mine;
			shockSeizeWindow.useId = mine.itemUseId;
			shockSeizeWindow.endTime = Time.timeAsDouble + (double)ShockRules.SeizeSeconds;
			Trace.Log($"server: mine sprung, window of {ShockRules.SeizeSeconds:0.#}s begins");
			VfxManager.ServerPlayPooledVfxForAllClients((VfxType)134, ((Component)mine).transform.position, Quaternion.identity, default(Vector3), 0u, false, 0f, (NetworkConnectionToClient)null);
			ShockNetwork.ServerAnnounceSprung(((Component)mine).transform.position);
			return shockSeizeWindow;
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			if (Time.timeAsDouble >= endTime)
			{
				Finish();
				return;
			}
			Catch();
			if (!firstSweepDone)
			{
				firstSweepDone = true;
				if (held.Count == 0)
				{
					Trace.Log("server: discharge caught nothing, mine spent at once");
					Finish();
					return;
				}
			}
			HoldStill();
		}

		private void Catch()
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)mine).transform.position;
			int num = Physics.OverlapSphereNonAlloc(position, GameManager.ItemSettings.LandmineExplosionRange, PlayerGolfer.overlappingColliderBuffer, LayerMask.op_Implicit(GameManager.LayerSettings.LandmineHittablesMask), (QueryTriggerInteraction)1);
			List<Hittable> list = new List<Hittable>();
			Hittable val = default(Hittable);
			for (int i = 0; i < num; i++)
			{
				if (ComponentExtensions.TryGetComponentInParent<Hittable>((Component)(object)PlayerGolfer.overlappingColliderBuffer[i], ref val, true) && IsEligible(val) && !list.Contains(val))
				{
					list.Add(val);
				}
			}
			foreach (Hittable item in list)
			{
				if (item.AsEntity.IsGolfCart)
				{
					Evacuate(item.AsEntity.AsGolfCart);
				}
				Seize(item);
			}
		}

		private void Evacuate(GolfCartInfo cart)
		{
			List<PlayerInfo> list = new List<PlayerInfo>((IEnumerable<PlayerInfo>)cart.passengers);
			foreach (PlayerInfo item in list)
			{
				if (!((Object)(object)item == (Object)null))
				{
					item.ExitGolfCart((GolfCartExitType)2);
					Trace.Log("server: ejected " + ((Object)item).name + " from a cart");
					if ((Object)(object)item.AsHittable != (Object)null && IsEligible(item.AsHittable))
					{
						Seize(item.AsHittable);
					}
				}
			}
		}

		private bool IsEligible(Hittable hittable)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hittable == (Object)(object)mine.AsEntity.AsHittable)
			{
				return false;
			}
			if (held.Contains(hittable))
			{
				return false;
			}
			Entity asEntity = hittable.AsEntity;
			if ((Object)(object)asEntity == (Object)null || asEntity.IsDestroyed)
			{
				return false;
			}
			if (asEntity.IsTrafficVehicle)
			{
				return false;
			}
			if (!asEntity.HasRigidbody)
			{
				return false;
			}
			if ((int)hittable.FrozenState != 0)
			{
				return false;
			}
			return !IsTeammateOfOwner(asEntity);
		}

		private bool IsTeammateOfOwner(Entity entity)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			PlayerInventory owner = mine.Owner;
			if ((Object)(object)owner == (Object)null || (int)MatchSetupMenu.CurrentGameMode != 1)
			{
				return false;
			}
			if (entity.IsPlayer)
			{
				return owner.PlayerInfo.IsTeammateOf(entity.PlayerInfo, true);
			}
			if (entity.IsGolfCart)
			{
				return entity.AsGolfCart.ContainsOnlyTeammatesOf(owner.PlayerInfo, true);
			}
			return false;
		}

		private void Seize(Hittable hittable)
		{
			ShockVictims.MarkHeld(((NetworkBehaviour)hittable).netId);
			hittable.NetworkfrozenState = (FrozenState)2;
			held.Add(hittable);
			ShockNetwork.ServerAnnounceSeized(hittable, (float)(endTime - Time.timeAsDouble));
			AnnounceToFeed(hittable);
			Trace.Log("server: seized " + ((Object)hittable).name);
		}

		private void AnnounceToFeed(Hittable victim)
		{
			if (victim.AsEntity.IsPlayer && !((Object)(object)mine.Owner == (Object)null))
			{
				InfoFeed.ShowItemHitMessage(mine.Owner.PlayerInfo, victim.AsEntity.PlayerInfo, (ItemType)201);
			}
		}

		private void HoldStill()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			foreach (Hittable item in held)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.AsEntity == (Object)null) && item.AsEntity.HasRigidbody)
				{
					Rigidbody rigidbody = item.AsEntity.Rigidbody;
					if (!rigidbody.isKinematic)
					{
						rigidbody.linearVelocity = Vector3.zero;
						rigidbody.angularVelocity = Vector3.zero;
					}
				}
			}
		}

		private void Finish()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_0072: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			foreach (Hittable item in held)
			{
				if (!((Object)(object)item == (Object)null))
				{
					if ((int)item.FrozenState == 2)
					{
						item.NetworkfrozenState = (FrozenState)0;
					}
					CreditPlanter(item);
					ShockNetwork.ServerAnnounceReleased(item, ((Object)(object)mine != (Object)null && (Object)(object)mine.Owner != (Object)null) ? mine.Owner.PlayerInfo : null, useId, ((Object)(object)mine != (Object)null) ? ((Component)mine).transform.position : ((Component)item).transform.position);
				}
			}
			Trace.Log($"server: window over, released {held.Count} victim(s), mine spent");
			held.Clear();
			((Behaviour)this).enabled = false;
			if ((Object)(object)mine != (Object)null && (Object)(object)mine.AsEntity != (Object)null && !mine.AsEntity.IsDestroyed)
			{
				mine.AsEntity.DestroyEntity();
			}
		}

		private void CreditPlanter(Hittable victim)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (victim.AsEntity.IsPlayer)
			{
				PlayerInfo val = (((Object)(object)mine != (Object)null && (Object)(object)mine.Owner != (Object)null) ? mine.Owner.PlayerInfo : null);
				victim.AsEntity.PlayerInfo.AsGolfer.ServerSetPotentialEliminationReason(((Object)(object)val != (Object)null) ? val.AsGolfer : null, useId, (EliminationReason)18);
			}
		}
	}
	internal static class ShockVictims
	{
		private static readonly HashSet<uint> Held = new HashSet<uint>();

		public static bool IsHeld(uint netId)
		{
			return Held.Contains(netId);
		}

		public static bool IsHeld(Hittable hittable)
		{
			if ((Object)(object)hittable != (Object)null)
			{
				return Held.Contains(((NetworkBehaviour)hittable).netId);
			}
			return false;
		}

		public static void MarkHeld(uint netId)
		{
			Held.Add(netId);
		}

		public static void MarkReleased(uint netId)
		{
			Held.Remove(netId);
		}

		public static void Reset()
		{
			Held.Clear();
		}
	}
	internal static class ShockUi
	{
		private static readonly Color32 GradientBottom = new Color32(byte.MaxValue, (byte)252, (byte)212, byte.MaxValue);

		private const float DenialSeconds = 1.6f;

		private const float DenialFlashHz = 4f;

		private static TextMeshProUGUI? label;

		private static CanvasGroup? group;

		private static float endTime;

		private static float denialEndTime;

		private static string denialText = string.Empty;

		public static void BeginCountdown(float seconds)
		{
			endTime = Time.time + seconds;
		}

		public static void ShowDenial(string message)
		{
			denialText = message;
			denialEndTime = Time.time + 1.6f;
		}

		public static void Clear()
		{
			endTime = 0f;
		}

		public static void Tick()
		{
			float num = endTime - Time.time;
			float num2 = denialEndTime - Time.time;
			if (num <= 0f && num2 <= 0f)
			{
				if ((Object)(object)group != (Object)null && group.alpha != 0f)
				{
					group.alpha = 0f;
				}
			}
			else if (EnsureLabel())
			{
				group.alpha = 1f;
				if (num2 > 0f)
				{
					((TMP_Text)label).text = denialText;
					bool flag = Mathf.Repeat(num2 * 4f, 1f) > 0.5f;
					((TMP_Text)label).alpha = (flag ? 1f : 0.15f);
				}
				else
				{
					((TMP_Text)label).alpha = 1f;
					((TMP_Text)label).text = $"SEIZED  {Mathf.CeilToInt(num)}";
				}
			}
		}

		private static bool EnsureLabel()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)label != (Object)null)
			{
				return true;
			}
			TMP_FontAsset val = FindGameFont();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = new GameObject("ShockMineCountdown");
			Object.DontDestroyOnLoad((Object)(object)val2);
			Canvas val3 = val2.AddComponent<Canvas>();
			val3.renderMode = (RenderMode)0;
			val3.sortingOrder = 500;
			CanvasScaler val4 = val2.AddComponent<CanvasScaler>();
			val4.uiScaleMode = (ScaleMode)1;
			val4.referenceResolution = new Vector2(1920f, 1080f);
			val4.screenMatchMode = (ScreenMatchMode)0;
			val4.matchWidthOrHeight = 1f;
			group = val2.AddComponent<CanvasGroup>();
			group.alpha = 0f;
			group.interactable = false;
			group.blocksRaycasts = false;
			GameObject val5 = new GameObject("Label");
			val5.transform.SetParent(val2.transform, false);
			label = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)label).font = val;
			((TMP_Text)label).fontSize = 68f;
			((TMP_Text)label).alignment = (TextAlignmentOptions)514;
			((TMP_Text)label).textWrappingMode = (TextWrappingModes)0;
			((Graphic)label).raycastTarget = false;
			((TMP_Text)label).enableVertexGradient = true;
			((TMP_Text)label).colorGradient = new VertexGradient(Color.white, Color.white, Color32.op_Implicit(GradientBottom), Color32.op_Implicit(GradientBottom));
			((TMP_Text)label).outlineWidth = 0.2f;
			((TMP_Text)label).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
			RectTransform rectTransform = ((TMP_Text)label).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 1f);
			rectTransform.anchorMax = new Vector2(0.5f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 1f);
			rectTransform.anchoredPosition = new Vector2(0f, -200f);
			rectTransform.sizeDelta = new Vector2(1400f, 120f);
			return true;
		}

		private static TMP_FontAsset? FindGameFont()
		{
			TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>();
			if (array.Length == 0)
			{
				return null;
			}
			return (from text in array
				select text.font into font
				where (Object)(object)font != (Object)null
				group font by font into @group
				orderby @group.Count() descending
				select @group.Key).FirstOrDefault();
		}
	}
	[HarmonyPatch(typeof(PlayerInventory), "TryUseItem")]
	internal static class ShockUsePatch
	{
		private static bool Prefix(PlayerInventory __instance, bool isAirhornReaction, ref bool shouldEatInput, ref bool __result)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			shouldEatInput = true;
			if (!((NetworkBehaviour)__instance).isLocalPlayer)
			{
				return true;
			}
			if ((int)__instance.GetEffectivelyEquippedItem(false) != 201)
			{
				return true;
			}
			if (SingletonBehaviour<DrivingRangeManager>.HasInstance)
			{
				Trace.Log("use refused: driving range");
				ShockUi.ShowDenial("NOT HERE");
				__result = false;
				return false;
			}
			InventorySlot val = default(InventorySlot);
			ItemData val2 = default(ItemData);
			bool flag = default(bool);
			if (!__instance.CanUseEquippedItem(false, isAirhornReaction, ref val, ref val2, ref shouldEatInput, ref flag))
			{
				__result = false;
				return false;
			}
			bool flag2 = isAirhornReaction || __instance.PlayerInfo.Input.IsHoldingAimSwing;
			Trace.Log(string.Format("use accepted, {0}, slot={1}", flag2 ? "tossing" : "planting", __instance.EquippedItemIndex));
			__instance.ItemUseTimestamp = Time.timeAsDouble;
			__instance.CancelItemUse();
			__instance.itemUseRoutine = ((MonoBehaviour)__instance).StartCoroutine(flag2 ? TossRoutine(__instance) : PlantRoutine(__instance));
			__instance.PlayerInfo.CancelEmote(false);
			__instance.CancelItemFlourish();
			__result = true;
			return false;
		}

		private static IEnumerator PlantRoutine(PlayerInventory inventory)
		{
			inventory.SetCurrentItemUse((ItemUseType)1);
			bool jammedIntoGround = false;
			for (float timeSince = BMath.GetTimeSince(inventory.ItemUseTimestamp); timeSince < GameManager.ItemSettings.LandminePlantingTime; timeSince = BMath.GetTimeSince(inventory.ItemUseTimestamp))
			{
				if (!jammedIntoGround && timeSince >= GameManager.ItemSettings.LandminePlantingStickIntoGroundTime)
				{
					Vector3 position = ((Component)inventory.PlayerInfo.RightHandEquipmentSwitcher).transform.position;
					position.y = ((Component)inventory).transform.position.y;
					PlayBurrowVfx(inventory, position);
					CameraModuleController.Shake(GameManager.CameraGameplaySettings.LandminePlantJamScreenshakeSettings, ((Component)inventory).transform.position, 1f, 1f);
					inventory.PlayerInfo.PlayerAudio.PlayLandminePlantForAllClients(false);
					jammedIntoGround = true;
				}
				yield return null;
			}
			if (!inventory.PlayerInfo.Movement.IsGrounded)
			{
				Trace.Log("plant: cancelled, left the ground");
				inventory.CancelItemUse();
				yield break;
			}
			ulong equippedItemUseHash = inventory.GetEquippedItemUseHash();
			inventory.DecrementUseFromSlotAt(inventory.EquippedItemIndex);
			Vector3 position2 = ((Component)inventory).transform.position;
			Quaternion effectiveRotation = GetEffectiveRotation(inventory);
			Vector3 val = effectiveRotation * Vector3.down * GameManager.ItemSettings.LandminePlantingOffsetIntoGround;
			inventory.LocalPlayerMarkThrownItem((ThrownItemHand)2);
			ShockNetwork.RequestSpawn(position2 + val, effectiveRotation, Vector3.zero, Vector3.zero, (LandmineArmType)1, inventory.IncrementAndGetCurrentItemUseId((ItemType)201), equippedItemUseHash);
			PlayBurrowVfx(inventory, position2);
			CameraModuleController.Shake(GameManager.CameraGameplaySettings.LandminePlantStompScreenshakeSettings, ((Component)inventory).transform.position, 1f, 1f);
			inventory.PlayerInfo.PlayerAudio.PlayLandminePlantForAllClients(true);
			yield return (object)new WaitForSeconds(GameManager.ItemSettings.LandminePostPlantingTime);
			inventory.SetCurrentItemUse((ItemUseType)0);
			inventory.RemoveIfOutOfUses(inventory.EquippedItemIndex, true);
			Trace.Log("plant: finished");
		}

		private static IEnumerator TossRoutine(PlayerInventory inventory)
		{
			inventory.SetCurrentItemUse((ItemUseType)2);
			inventory.PlayerInfo.Movement.AlignWithCameraImmediately();
			for (float time = 0f; time < GameManager.ItemSettings.LandmineTossingTime; time += Time.deltaTime)
			{
				yield return null;
				inventory.PlayerInfo.Movement.AlignWithCameraImmediately();
			}
			ulong equippedItemUseHash = inventory.GetEquippedItemUseHash();
			inventory.DecrementUseFromSlotAt(inventory.EquippedItemIndex);
			Vector3 position = default(Vector3);
			Quaternion rotation = default(Quaternion);
			((Component)inventory.PlayerInfo.RightHandEquipmentSwitcher).transform.GetPositionAndRotation(ref position, ref rotation);
			Vector3 val = ((Component)inventory).transform.TransformDirection(GameManager.ItemSettings.LandmineTossingDirectionLocalRotation * Vector3.forward);
			Vector3 val2 = ((Component)inventory).transform.TransformDirection(GameManager.ItemSettings.LandmineTossingDirectionLocalRotation * GameManager.ItemSettings.LandmineTossingLocalAngularVelocity);
			Vector3 velocity = inventory.PlayerInfo.Rigidbody.linearVelocity + val * GameManager.ItemSettings.LandmineTossingSpeed;
			Vector3 angularVelocity = inventory.PlayerInfo.Rigidbody.angularVelocity + val2;
			inventory.LocalPlayerMarkThrownItem((ThrownItemHand)2);
			ShockNetwork.RequestSpawn(position, rotation, velocity, angularVelocity, (LandmineArmType)2, inventory.IncrementAndGetCurrentItemUseId((ItemType)201), equippedItemUseHash);
			yield return (object)new WaitForSeconds(GameManager.ItemSettings.LandminePostTossingTime);
			inventory.SetCurrentItemUse((ItemUseType)0);
			inventory.RemoveIfOutOfUses(inventory.EquippedItemIndex, true);
			Trace.Log("toss: finished");
		}

		private static Quaternion GetEffectiveRotation(PlayerInventory inventory)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			Vector3 normal = inventory.PlayerInfo.Movement.GroundData.normal;
			Vector3 val = default(Vector3);
			if (!VectorExtensions.TryProjectOnPlaneAlong(((Component)inventory).transform.forward, Vector3.up, normal, ref val))
			{
				return Quaternion.Euler(0f, ((Component)GameManager.LocalPlayerInfo).transform.eulerAngles.y, 0f);
			}
			return Quaternion.LookRotation(val, normal);
		}

		private static void PlayBurrowVfx(PlayerInventory inventory, Vector3 position)
		{
			//IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			//IL_000b: 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: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)inventory).isServer)
			{
				VfxManager.ServerPlayPooledVfxForAllClients((VfxType)23, position, Quaternion.identity, default(Vector3), 0u, false, 0f, (NetworkConnectionToClient)null);
			}
			else
			{
				VfxManager.ClientPlayPooledVfxForAllClients((VfxType)23, position, Quaternion.identity, default(Vector3), 0u, false, 0f);
			}
		}
	}
	[HarmonyPatch]
	internal static class ShockLandmineGatePatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerInventory), "TrySelectItemSlot")]
		private static void SelectPostfix(PlayerInventory __instance, int index, bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			if (__result && Plugin.Enabled.Value && (int)__instance.GetEffectiveSlot(index).itemType == 201 && __instance.PlayerInfo.Input.IsHoldingAimSwing)
			{
				__instance.isWaitingForAltUseInputRelease = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerInventory), "CanUseEquippedItem")]
		private static void CanUsePostfix(PlayerInventory __instance, ref bool __result)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			if (__result && Plugin.Enabled.Value && (int)__instance.GetEffectiveSlot(__instance.EquippedItemIndex).itemType == 201 && !__instance.IsAimingItem && !__instance.PlayerInfo.Movement.IsGrounded)
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerInventory), "InformLocalPlayerGroundedChanged")]
		private static void GroundedPostfix(PlayerInventory __instance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			if (Plugin.Enabled.Value && !__instance.PlayerInfo.Movement.IsGrounded && (int)__instance.CurrentItemUse == 1 && (int)__instance.GetEffectivelyEquippedItem(false) == 201)
			{
				__instance.CancelItemUse();
			}
		}
	}
	internal static class ShockVfx
	{
		private sealed class Zap
		{
			public PoolableParticleSystem? Particles;

			public Transform? Follow;

			public bool IsGolfCart;
		}

		private static readonly Dictionary<uint, Zap> Active = new Dictionary<uint, Zap>();

		public static void BeginZap(uint victimNetId, float remainingSeconds)
		{
			Hittable val = default(Hittable);
			if (!Active.ContainsKey(victimNetId) && NetworkClient.spawned.TryGetValue(victimNetId, out var value) && !((Object)(object)value == (Object)null) && ((Component)value).TryGetComponent<Hittable>(ref val) && !((Object)(object)val.AsEntity == (Object)null))
			{
				Zap zap = new Zap
				{
					Follow = AttachPoint(val),
					IsGolfCart = val.AsEntity.IsGolfCart
				};
				Active[victimNetId] = zap;
				Acquire(zap);
				Trace.Log($"client: zap started on {victimNetId} for {remainingSeconds:0.#}s");
			}
		}

		public static void EndZap(uint victimNetId)
		{
			//IL_0037: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (Active.TryGetValue(victimNetId, out Zap value))
			{
				Active.Remove(victimNetId);
				Vector3 position = (((Object)(object)value.Follow != (Object)null) ? value.Follow.position : Vector3.zero);
				Release(value);
				VfxType val = (VfxType)(value.IsGolfCart ? 127 : 131);
				PoolableParticleSystem val2 = default(PoolableParticleSystem);
				if (VfxPersistentData.TryGetPooledVfx(val, ref val2))
				{
					((Component)val2).transform.SetParent((Transform)null, false);
					((Component)val2).transform.position = position;
					val2.Play(true);
				}
				Trace.Log($"client: zap ended on {victimNetId}");
			}
		}

		public static void Tick()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (Active.Count == 0)
			{
				return;
			}
			foreach (KeyValuePair<uint, Zap> item in Active)
			{
				Zap value = item.Value;
				if (!((Object)(object)value.Follow == (Object)null))
				{
					if ((Object)(object)value.Particles == (Object)null)
					{
						Acquire(value);
					}
					else if (!value.Particles.IsPlaying)
					{
						value.Particles.Play(false);
					}
					ShockAudio.Follow(item.Key, value.Follow.position);
				}
			}
		}

		private static void Acquire(Zap zap)
		{
			//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_004e: 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)
			if (!((Object)(object)zap.Follow == (Object)null))
			{
				VfxType val = (VfxType)(zap.IsGolfCart ? 128 : 132);
				PoolableParticleSystem val2 = default(PoolableParticleSystem);
				if (VfxPersistentData.TryGetPooledVfx(val, ref val2))
				{
					zap.Particles = val2;
					((Component)val2).transform.SetParent(zap.Follow, false);
					((Component)val2).transform.localPosition = Vector3.zero;
					((Component)val2).transform.localRotation = Quaternion.identity;
					val2.Play(false);
				}
			}
		}

		private static void Release(Zap zap)
		{
			PoolableParticleSystem particles = zap.Particles;
			zap.Particles = null;
			if (!((Object)(object)particles == (Object)null))
			{
				particles.Stop((ParticleSystemStopBehavior)0);
				((Component)particles).transform.SetParent((Transform)null, false);
				particles.ReturnToPool();
			}
		}

		private static Transform AttachPoint(Hittable hittable)
		{
			return ((Component)hittable).transform;
		}

		public static void Reset()
		{
			foreach (KeyValuePair<uint, Zap> item in Active)
			{
				Release(item.Value);
			}
			Active.Clear();
		}
	}
	internal static class Trace
	{
		public static void Log(string message)
		{
			if (Plugin.VerboseLogging.Value)
			{
				Plugin.Log.LogInfo((object)("[trace] " + message));
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | Attribu