Decompiled source of Useful Zap Gun v0.4.2

UsefulZapGun.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UsefulZapGun.Methods;
using UsefulZapGun.NetcodePatcher;
using UsefulZapGun.Network;
using UsefulZapGun.Patches;
using UsefulZapGun.Patches.Enemy;
using UsefulZapGun.Patches.Items;
using UsefulZapGun.Scripts.Hazards;
using UsefulZapGun.Scripts.Items;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UsefulZapGun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+99ffbb5faa8bfcaaa771c91bd3c77d36c6e96d3b")]
[assembly: AssemblyProduct("UsefulZapGun")]
[assembly: AssemblyTitle("UsefulZapGun")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace UsefulZapGun
{
	internal class UZGConfig
	{
		private static ConfigFile cfg;

		internal static ConfigEntry<bool> enableLogging;

		internal static ConfigEntry<int> zapgunPrice;

		internal static ConfigEntry<bool> enableDifficultyMultiplierPatch;

		internal static ConfigEntry<float> distanceDivider;

		internal static ConfigEntry<string> enemyListString;

		internal static Dictionary<Item, ConfigEntry<float>> multiplayerDict = new Dictionary<Item, ConfigEntry<float>>();

		internal static List<string> enemyList;

		internal static Dictionary<EnemyType, ConfigEntry<float>> timeDict = new Dictionary<EnemyType, ConfigEntry<float>>();

		internal static ConfigEntry<bool> enableExplosion;

		internal static ConfigEntry<bool> setForestGiantsOnFire;

		internal static ConfigEntry<float> timeToStartAFire;

		internal static ConfigEntry<bool> evaporateBlob;

		internal static ConfigEntry<float> timeToEvaporate;

		internal static ConfigEntry<bool> enableDOTEnemy;

		internal static ConfigEntry<bool> enableDOTPlayers;

		internal static ConfigEntry<int> zapDamage;

		internal static ConfigEntry<int> zapDamageToPlayer;

		internal static ConfigEntry<float> zapTimeToDamage;

		internal static ConfigEntry<bool> enableItemCharging;

		internal static ConfigEntry<float> chargeLifeTime;

		internal static ConfigEntry<bool> enableWeaponCharging;

		internal static ConfigEntry<float> needForShovelCharge;

		internal static ConfigEntry<bool> enableZapHazards;

		internal static ConfigEntry<float> timeNeedForTurretDisable;

		internal static ConfigEntry<int> spiketrapZapNeeded;

		internal static void ConfigSetup(ConfigFile PluginConfig)
		{
			cfg = PluginConfig;
			enableLogging = cfg.Bind<bool>("General", "Enable logging", true, (ConfigDescription)null);
			zapgunPrice = cfg.Bind<int>("General", "Zap gun price", 400, (ConfigDescription)null);
			enableDifficultyMultiplierPatch = cfg.Bind<bool>("General", "Enable Difficulty Multiplier Patch", true, "Formula: result = vanilaValue * Distance(localPlayer, enemy)/distanceDivider");
			distanceDivider = cfg.Bind<float>("General", "Distance Divider", 5f, (ConfigDescription)null);
			setForestGiantsOnFire = cfg.Bind<bool>("Enemies", "Set forest giants on fire", true, (ConfigDescription)null);
			timeToStartAFire = cfg.Bind<float>("Enemies", "Time to start a fire", 3f, (ConfigDescription)null);
			evaporateBlob = cfg.Bind<bool>("Enemies", "Evaporate blob", true, (ConfigDescription)null);
			enemyListString = cfg.Bind<string>("Enemies", "Enemy list", "Red Locust Bees,Butler Bees", (ConfigDescription)null);
			enableExplosion = cfg.Bind<bool>("Enemies", "Enable enemy explosion", true, (ConfigDescription)null);
			enableDOTEnemy = cfg.Bind<bool>("DOT", "Damage enemy with zap", false, (ConfigDescription)null);
			enableDOTPlayers = cfg.Bind<bool>("DOT", "Damage players with zap", false, (ConfigDescription)null);
			zapDamage = cfg.Bind<int>("DOT", "Zapgun damage to enemy", 1, (ConfigDescription)null);
			zapDamageToPlayer = cfg.Bind<int>("DOT", "Zapgun damage to player", 10, (ConfigDescription)null);
			zapTimeToDamage = cfg.Bind<float>("DOT", "Time to damage (seconds)", 1f, (ConfigDescription)null);
			enemyList = enemyListString.Value.Split(',').ToList();
			enableItemCharging = cfg.Bind<bool>("Items", "Enable equipment charging", true, "Charging ratio: chargeMultiplier * (Time.deltaTime / item.itemProperties.batteryUsage)");
			enableWeaponCharging = cfg.Bind<bool>("Weapon", "Enable weapon charging", true, "x2 damage for charged weapon (shovel, stop sign, mace (code rebirth), etc.");
			chargeLifeTime = cfg.Bind<float>("Weapon", "Time until charge runs out", 15f, (ConfigDescription)null);
			needForShovelCharge = cfg.Bind<float>("Weapon", "Zap gun charge% for charged state", 33f, (ConfigDescription)null);
			enableZapHazards = cfg.Bind<bool>("Hazards", "Enable hazard zap", true, (ConfigDescription)null);
			timeNeedForTurretDisable = cfg.Bind<float>("Hazards", "Time need for turret", 3f, (ConfigDescription)null);
			spiketrapZapNeeded = cfg.Bind<int>("Hazards", "Zaps before deactivating the spiketrap", 2, (ConfigDescription)null);
			CheckConfig();
		}

		private static void CheckConfig()
		{
			enemyList.Remove("Bruce");
			if (zapDamage.Value <= 0)
			{
				zapDamage.Value = 1;
			}
		}

		internal static void CreateAndCheckConfigEntryForItem(Item item, float multiplayer)
		{
			ConfigEntry<float> value = cfg.Bind<float>("Items", item.itemName + ": charge multiplayer", multiplayer, (ConfigDescription)null);
			multiplayerDict.TryAdd(item, value);
		}

		internal static void CreateAndCheckConfigEntryForEnemy(EnemyType enemy, float time)
		{
			ConfigEntry<float> val = cfg.Bind<float>("Enemies", enemy.enemyName + ": time needed for explosion", time, (ConfigDescription)null);
			if (val.Value <= 0f)
			{
				val.Value = 1f;
			}
			timeDict.TryAdd(enemy, val);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("mborsh.UsefulZapGun", "UsefulZapGun", "0.4.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal enum spamType
		{
			info,
			message,
			warning,
			debug,
			error,
			fatal
		}

		private const string modGUID = "mborsh.UsefulZapGun";

		private const string modName = "UsefulZapGun";

		private const string modVersion = "0.4.1";

		private readonly Harmony harmony = new Harmony("mborsh.UsefulZapGun");

		private static ManualLogSource mls;

		private static Plugin Instance;

		internal static bool enemiesAndItemsFound;

		private static string sAssemblyLocation;

		public static AssetBundle mainAssetBundle;

		private static ConfigFile cfg;

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void Awake()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			NetcodePatcher();
			Instance = this;
			mls = Logger.CreateLogSource("UsefulZapGun");
			mls = ((BaseUnityPlugin)this).Logger;
			sAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(sAssemblyLocation, "zapgunnetworkobject"));
			cfg = new ConfigFile(Path.Combine(Paths.ConfigPath, "mborsh.UsefulZapGun.cfg"), true);
			UZGConfig.ConfigSetup(cfg);
			mls.LogInfo((object)"UsefulZapGun 0.4.1 loaded. Patching.");
			PatchAllStuff();
		}

		internal static void SpamLog(string message, spamType type)
		{
			if (UZGConfig.enableLogging.Value)
			{
				switch (type)
				{
				case spamType.info:
					mls.LogInfo((object)message);
					break;
				case spamType.message:
					mls.LogMessage((object)message);
					break;
				case spamType.warning:
					mls.LogWarning((object)message);
					break;
				case spamType.debug:
					mls.LogDebug((object)message);
					break;
				case spamType.error:
					mls.LogError((object)message);
					break;
				case spamType.fatal:
					mls.LogFatal((object)message);
					break;
				}
			}
		}

		private void PatchAllStuff()
		{
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(MenuManagerPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(TerminalPatch));
			harmony.PatchAll(typeof(EnemyAICollisionDetectPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(PatcherToolPatch));
			if (UZGConfig.enableZapHazards.Value)
			{
				harmony.PatchAll(typeof(MapHazardsPatch));
			}
			if (UZGConfig.enableWeaponCharging.Value)
			{
				harmony.PatchAll(typeof(ShovelPatch));
			}
			if (UZGConfig.enableItemCharging.Value)
			{
				harmony.PatchAll(typeof(GrabbableObjectPatch));
			}
		}
	}
}
namespace UsefulZapGun.Scripts.Items
{
	internal class ConductiveShockableScript : MonoBehaviour, IShockableWithGun
	{
		private GrabbableObject itemScript;

		private void Start()
		{
			itemScript = ((Component)this).GetComponent<GrabbableObject>();
		}

		public bool CanBeShocked()
		{
			return (Object)(object)itemScript.playerHeldBy == (Object)null;
		}

		public float GetDifficultyMultiplier()
		{
			return 0f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)itemScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			Plugin.SpamLog("Shock conductive item (" + itemScript.itemProperties.itemName + ")", Plugin.spamType.message);
			if (!((Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				itemScript.grabbable = false;
				PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
				((MonoBehaviour)this).StartCoroutine(WaitFrameAndDamage(zapgun, shockedByPlayer));
			}
		}

		private IEnumerator WaitFrameAndDamage(PatcherTool zapgun, PlayerControllerB shockedByPlayer)
		{
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			zapgun.StopShockingAnomalyOnClient(true);
			yield return (object)new WaitForEndOfFrame();
			shockedByPlayer.DamagePlayer(15, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
		}

		public void StopShockingWithGun()
		{
			itemScript.grabbable = true;
		}
	}
	internal class EquipmentShockableScript : MonoBehaviour, IShockableWithGun
	{
		private GrabbableObject itemScript;

		private float chargeMultiplier;

		private Coroutine chargeCoroutine;

		private void Start()
		{
			itemScript = ((Component)this).GetComponent<GrabbableObject>();
			string itemName = itemScript.itemProperties.itemName;
			chargeMultiplier = UZGConfig.multiplayerDict[itemScript.itemProperties].Value;
		}

		public bool CanBeShocked()
		{
			return itemScript.insertedBattery.charge < 1f && (Object)(object)itemScript.playerHeldBy == (Object)null;
		}

		public float GetDifficultyMultiplier()
		{
			return 0.3f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)itemScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			Plugin.SpamLog("Shock item with battery (" + itemScript.itemProperties.itemName + ")", Plugin.spamType.message);
			itemScript.grabbable = false;
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			chargeCoroutine = ((MonoBehaviour)this).StartCoroutine(ChargeItem(zapgun, itemScript));
		}

		public void StopShockingWithGun()
		{
			((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
			itemScript.grabbable = true;
			Plugin.SpamLog($"charge = {itemScript.insertedBattery.charge}", Plugin.spamType.debug);
			itemScript.SyncBatteryServerRpc((int)(itemScript.insertedBattery.charge * 100f));
		}

		private IEnumerator ChargeItem(PatcherTool zapgun, GrabbableObject item)
		{
			if (item.insertedBattery.empty)
			{
				item.insertedBattery.empty = false;
			}
			while (item.insertedBattery.charge < 1f)
			{
				yield return (object)new WaitForEndOfFrame();
				Battery insertedBattery = item.insertedBattery;
				insertedBattery.charge += chargeMultiplier * (Time.deltaTime / item.itemProperties.batteryUsage);
			}
			zapgun.StopShockingAnomalyOnClient(true);
		}
	}
	internal class WeaponShockableScript : MonoBehaviour, IShockableWithGun
	{
		private Shovel itemScript;

		private bool charged;

		private Coroutine chargeCoroutine;

		private float batteryChargeNeedUntilChargedState;

		private void Start()
		{
			itemScript = ((Component)this).GetComponent<Shovel>();
			charged = false;
			batteryChargeNeedUntilChargedState = UZGConfig.needForShovelCharge.Value / 100f;
		}

		public bool CanBeShocked()
		{
			return (Object)(object)((GrabbableObject)itemScript).playerHeldBy == (Object)null && !charged;
		}

		public float GetDifficultyMultiplier()
		{
			return 0.3f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)itemScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)itemScript).transform.position + new Vector3(0f, 0.2f, 0f);
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Plugin.SpamLog("Shock weapon (" + ((GrabbableObject)itemScript).itemProperties.itemName + ")", Plugin.spamType.message);
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			if (charged)
			{
				WaitFrameAndDamage(zapgun, shockedByPlayer);
				return;
			}
			chargeCoroutine = ((MonoBehaviour)this).StartCoroutine(ChargeWeapon(zapgun));
			((GrabbableObject)itemScript).grabbable = false;
		}

		public void StopShockingWithGun()
		{
			if (chargeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(chargeCoroutine);
			}
			((GrabbableObject)itemScript).grabbable = true;
		}

		private IEnumerator WaitFrameAndDamage(PatcherTool zapgun, PlayerControllerB shockedByPlayer)
		{
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			zapgun.StopShockingAnomalyOnClient(true);
			yield return (object)new WaitForEndOfFrame();
			shockedByPlayer.DamagePlayer(15, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
		}

		private IEnumerator ChargeWeapon(PatcherTool zapgun)
		{
			float chargeNeeded = ((GrabbableObject)zapgun).insertedBattery.charge - batteryChargeNeedUntilChargedState;
			while (((GrabbableObject)zapgun).insertedBattery.charge > 0f && ((GrabbableObject)zapgun).insertedBattery.charge >= chargeNeeded)
			{
				yield return (object)new WaitForEndOfFrame();
			}
			NetworkObjectReference shovelNORef = new NetworkObjectReference(GetNetworkObject());
			GameNetworkManagerPatch.hostNetHandler.SyncShovelDamageServerRpc(shovelNORef);
			zapgun.StopShockingAnomalyOnClient(true);
		}

		private IEnumerator WaitUntilChargeRunsOut(float seconds)
		{
			yield return (object)new WaitForSeconds(seconds);
			charged = false;
			Shovel obj = itemScript;
			obj.shovelHitForce /= 2;
		}

		internal void SyncDamageOnLocalClient(float seconds = 0f)
		{
			charged = true;
			Shovel obj = itemScript;
			obj.shovelHitForce *= 2;
			((MonoBehaviour)this).StartCoroutine(WaitUntilChargeRunsOut(seconds));
		}
	}
}
namespace UsefulZapGun.Scripts.Hazards
{
	internal class LandmineShockableScript : MonoBehaviour, IShockableWithGun
	{
		private Landmine mineScript;

		private bool isShocked;

		private void Start()
		{
			mineScript = ((Component)this).GetComponent<Landmine>();
		}

		public bool CanBeShocked()
		{
			return !mineScript.hasExploded && !isShocked;
		}

		public float GetDifficultyMultiplier()
		{
			return 0f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)mineScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mineScript).transform.position + new Vector3(0f, 0.5f, 0f);
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			Plugin.SpamLog("Shock landmine", Plugin.spamType.message);
			isShocked = (Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController;
		}

		public void StopShockingWithGun()
		{
			mineScript.ExplodeMineServerRpc();
		}
	}
	internal class SpiketrapShockableScript : MonoBehaviour, IShockableWithGun
	{
		internal int zapCount;

		private SpikeRoofTrap spikeScript;

		private Coroutine coroutine;

		private bool localPlayer;

		private void Start()
		{
			zapCount = 0;
			spikeScript = ((Component)((Component)this).transform.parent.Find("Trigger")).GetComponent<SpikeRoofTrap>();
		}

		public bool CanBeShocked()
		{
			return spikeScript.trapActive && !localPlayer;
		}

		public float GetDifficultyMultiplier()
		{
			return 0.4f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)spikeScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Plugin.SpamLog("Shock spiketrap", Plugin.spamType.message);
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			coroutine = ((MonoBehaviour)this).StartCoroutine(WaitAndStopShocking(zapgun));
			localPlayer = (Object)(object)shockedByPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController;
		}

		public void StopShockingWithGun()
		{
			if (coroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(coroutine);
			}
			localPlayer = false;
		}

		internal void SyncCanShockOnLocalClient(bool sync)
		{
			spikeScript.trapActive = sync;
			((Behaviour)((Component)this).GetComponent<Light>()).enabled = sync;
		}

		private IEnumerator WaitAndStopShocking(PatcherTool zapgun)
		{
			yield return (object)new WaitForSeconds(1f);
			if (zapgun.shockedTargetScript == this && ((GrabbableObject)zapgun).isBeingUsed && localPlayer)
			{
				NetworkObjectReference NORef = new NetworkObjectReference(GetNetworkObject());
				GameNetworkManagerPatch.hostNetHandler.SyncZapCountServerRpc(NORef, zapCount + 1);
				zapgun.StopShockingAnomalyOnClient(true);
			}
		}
	}
	internal class TurretShockableScript : MonoBehaviour, IShockableWithGun
	{
		private Turret turretScript;

		private Coroutine coroutine;

		private void Start()
		{
			turretScript = ((Component)this).GetComponent<Turret>();
		}

		public bool CanBeShocked()
		{
			return turretScript.turretActive;
		}

		public float GetDifficultyMultiplier()
		{
			return 0.9f;
		}

		public NetworkObject GetNetworkObject()
		{
			return ((NetworkBehaviour)turretScript).NetworkObject;
		}

		public Vector3 GetShockablePosition()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public Transform GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		public void ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Plugin.SpamLog("Shock turret", Plugin.spamType.message);
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			coroutine = ((MonoBehaviour)this).StartCoroutine(Wait(zapgun, shockedByPlayer));
		}

		public void StopShockingWithGun()
		{
			if (coroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(coroutine);
			}
		}

		private IEnumerator Wait(PatcherTool zapgun, PlayerControllerB player)
		{
			yield return (object)new WaitForSeconds(UZGConfig.timeNeedForTurretDisable.Value);
			if (zapgun.shockedTargetScript == this && ((GrabbableObject)zapgun).isBeingUsed)
			{
				((MonoBehaviour)this).StartCoroutine(BerserkAndDisable(player));
			}
		}

		private IEnumerator BerserkAndDisable(PlayerControllerB player)
		{
			turretScript.turretMode = (TurretMode)3;
			turretScript.EnterBerserkModeServerRpc((int)player.playerClientId);
			yield return (object)new WaitForSeconds(10.4f);
			yield return (object)new WaitForEndOfFrame();
			turretScript.turretMode = (TurretMode)0;
			yield return (object)new WaitForEndOfFrame();
			turretScript.ToggleTurretServerRpc(false);
		}
	}
}
namespace UsefulZapGun.Patches
{
	internal class GameNetworkManagerPatch
	{
		internal static GameObject netHandler;

		internal static UZGNetwork hostNetHandler;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		public static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(netHandler);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		public static void FindNetworkHandler()
		{
			hostNetHandler = Object.FindAnyObjectByType<UZGNetwork>();
			Plugin.SpamLog("hostNetHandler found", Plugin.spamType.debug);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		private static void AddPrefabsToNetwork()
		{
			netHandler = Plugin.mainAssetBundle.LoadAsset<GameObject>("zapgunnetworkobject.prefab");
			netHandler.AddComponent<UZGNetwork>();
			NetworkManager.Singleton.AddNetworkPrefab(netHandler);
		}
	}
	internal class MapHazardsPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Turret), "Start")]
		private static void TurretStartPatch(ref Turret __instance)
		{
			((Component)__instance).gameObject.AddComponent<TurretShockableScript>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Landmine), "Start")]
		private static void LandmineStartPatch(ref Landmine __instance)
		{
			((Component)__instance).gameObject.AddComponent<LandmineShockableScript>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SpikeRoofTrap), "Start")]
		private static void SpiketrapStartPatch(ref SpikeRoofTrap __instance)
		{
			GameObject gameObject = ((Component)__instance).gameObject;
			gameObject = ((Component)gameObject.transform.parent.Find("Spot Light")).gameObject;
			BoxCollider val = gameObject.AddComponent<BoxCollider>();
			((Collider)val).isTrigger = true;
			gameObject.AddComponent<SpiketrapShockableScript>();
			gameObject.layer = 21;
			((Component)gameObject.transform.parent).gameObject.layer = 21;
			((Component)gameObject.transform.parent.parent).gameObject.layer = 21;
			((Component)gameObject.transform.parent.parent.parent).gameObject.layer = 21;
		}
	}
	internal class MenuManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(MenuManager), "Start")]
		private static void FindAllEnemiesPatch()
		{
			if (Plugin.enemiesAndItemsFound)
			{
				return;
			}
			EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
			EnemyType[] array2 = array;
			foreach (EnemyType val in array2)
			{
				if (!string.IsNullOrEmpty(val.enemyName))
				{
					Plugin.SpamLog(val.enemyName + " has been found!", Plugin.spamType.message);
					if (UZGConfig.enemyList.Contains(val.enemyName))
					{
						UZGConfig.CreateAndCheckConfigEntryForEnemy(val, 3f);
						val.canBeStunned = true;
						val.canBeDestroyed = true;
						Plugin.SpamLog(val.enemyName + " can be stunned and destoyed now!", Plugin.spamType.info);
					}
				}
			}
			Plugin.SpamLog("---------------------------------------------------------", Plugin.spamType.message);
			if (UZGConfig.enableItemCharging.Value)
			{
				Item[] array3 = Resources.FindObjectsOfTypeAll<Item>();
				Item[] array4 = array3;
				foreach (Item val2 in array4)
				{
					if (val2.requiresBattery && !string.IsNullOrEmpty(val2.itemName))
					{
						UZGConfig.CreateAndCheckConfigEntryForItem(val2, val2.batteryUsage / 22f);
						Plugin.SpamLog(val2.itemName + " has been found!", Plugin.spamType.message);
					}
				}
			}
			Plugin.enemiesAndItemsFound = true;
		}
	}
	internal class PlayerControllerBPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "IShockableWithGun.ShockWithGun")]
		private static void ShockWithGunPatch(ref PlayerControllerB __instance, PlayerControllerB shockedByPlayer)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Plugin.SpamLog("Shock Player", Plugin.spamType.message);
			if (UZGConfig.enableDOTPlayers.Value)
			{
				NetworkBehaviourReference val = default(NetworkBehaviourReference);
				((NetworkBehaviourReference)(ref val))..ctor((NetworkBehaviour)(object)__instance);
				GameNetworkManagerPatch.hostNetHandler.DOTPlayerServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)__instance), (int)shockedByPlayer.playerClientId);
			}
		}
	}
	internal class TerminalPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Terminal), "Awake")]
		[HarmonyPriority(200)]
		private static void AwakePatch(ref Terminal __instance)
		{
			Item[] buyableItemsList = __instance.buyableItemsList;
			foreach (Item val in buyableItemsList)
			{
				if (val.itemName == "Zap gun")
				{
					val.creditsWorth = UZGConfig.zapgunPrice.Value;
					Plugin.SpamLog("Zap gun price: " + val.creditsWorth, Plugin.spamType.message);
					break;
				}
			}
		}
	}
}
namespace UsefulZapGun.Patches.Items
{
	internal class GrabbableObjectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		private static void StartPatch(ref GrabbableObject __instance)
		{
			if (!(__instance is Shovel))
			{
				EquipmentShockableScript equipmentShockableScript = default(EquipmentShockableScript);
				ConductiveShockableScript conductiveShockableScript = default(ConductiveShockableScript);
				if (__instance.itemProperties.requiresBattery && !((Component)__instance).gameObject.TryGetComponent<EquipmentShockableScript>(ref equipmentShockableScript) && __instance.itemProperties.requiresBattery)
				{
					((Component)__instance).gameObject.AddComponent<EquipmentShockableScript>();
				}
				else if (!((Component)__instance).gameObject.TryGetComponent<ConductiveShockableScript>(ref conductiveShockableScript) && __instance.itemProperties.isConductiveMetal)
				{
					((Component)__instance).gameObject.AddComponent<ConductiveShockableScript>();
				}
			}
		}
	}
	internal class PatcherToolPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PatcherTool), "BeginShockingAnomalyOnClient")]
		private static void AddZapGun(ref PatcherTool __instance)
		{
			ZapGunMethods.zapGuns.Add(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PatcherTool), "StopShockingAnomalyOnClient")]
		private static void RemoveZapGun(ref PatcherTool __instance)
		{
			if (!ZapGunMethods.zapGuns.Remove(__instance))
			{
				Plugin.SpamLog($"Couldn't remove the zap gun! networkObjectID: {((NetworkBehaviour)__instance).NetworkObjectId}", Plugin.spamType.warning);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PatcherTool), "Start")]
		private static void StartPatch(ref int ___anomalyMask)
		{
			___anomalyMask = 2621512;
		}
	}
	internal class ShovelPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		private static void StartPatch(ref GrabbableObject __instance)
		{
			WeaponShockableScript weaponShockableScript = default(WeaponShockableScript);
			if (__instance is Shovel && !((Component)__instance).gameObject.TryGetComponent<WeaponShockableScript>(ref weaponShockableScript))
			{
				((Component)__instance).gameObject.AddComponent<WeaponShockableScript>();
			}
		}
	}
}
namespace UsefulZapGun.Patches.Enemy
{
	internal class EnemyAICollisionDetectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.ShockWithGun")]
		private static void ShockWithGunPatch(ref EnemyAICollisionDetect __instance, PlayerControllerB shockedByPlayer)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			Plugin.SpamLog("Shock Enemy", Plugin.spamType.message);
			if (UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType) && UZGConfig.enableExplosion.Value)
			{
				ZapGunMethods.WaitAndExplode(__instance, __instance.mainScript, UZGConfig.timeDict[__instance.mainScript.enemyType].Value);
				return;
			}
			NetworkBehaviourReference enemyNBRef = default(NetworkBehaviourReference);
			((NetworkBehaviourReference)(ref enemyNBRef))..ctor((NetworkBehaviour)(object)__instance.mainScript);
			NetworkBehaviourReference playerWhoHitNBRef = default(NetworkBehaviourReference);
			((NetworkBehaviourReference)(ref playerWhoHitNBRef))..ctor((NetworkBehaviour)(object)shockedByPlayer);
			GameNetworkManagerPatch.hostNetHandler.DOTEnemyServerRpc(enemyNBRef, playerWhoHitNBRef);
			if (__instance.mainScript is ForestGiantAI && UZGConfig.setForestGiantsOnFire.Value && !UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType))
			{
				ZapGunMethods.StartFire(__instance, (ForestGiantAI)__instance.mainScript);
			}
			else if (__instance.mainScript is BlobAI && UZGConfig.evaporateBlob.Value && !UZGConfig.timeDict.ContainsKey(__instance.mainScript.enemyType))
			{
				ZapGunMethods.StartEvaporation(__instance, (BlobAI)__instance.mainScript);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAICollisionDetect), "IShockableWithGun.GetDifficultyMultiplier")]
		private static void GetDifficultyMultiplierPatch(ref EnemyAICollisionDetect __instance, ref float __result)
		{
			//IL_0050: 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)
			if (UZGConfig.enableDifficultyMultiplierPatch.Value && UZGConfig.distanceDivider.Value != 0f)
			{
				Plugin.SpamLog("GetDifficultyMultilier before = " + __result, Plugin.spamType.debug);
				__result *= Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)__instance.mainScript).transform.position) / UZGConfig.distanceDivider.Value;
				Plugin.SpamLog("GetDifficultyMultilier after = " + __result, Plugin.spamType.debug);
			}
		}
	}
	internal class EnemyAIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "KillEnemyServerRpc")]
		private static void KillEnemyServerRpcPatch(ref EnemyAI __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
			{
				EnemyAICollisionDetect val = (EnemyAICollisionDetect)zapGun.shockedTargetScript;
				if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)val.mainScript == (Object)(object)__instance)
				{
					zapGun.StopShockingAnomalyOnClient(true);
				}
			}
		}
	}
}
namespace UsefulZapGun.Network
{
	internal class UZGNetwork : NetworkBehaviour
	{
		internal PatcherTool zapgun;

		[ServerRpc(RequireOwnership = false)]
		internal void BlowUpEnemyServerRpc(NetworkObjectReference enemyNORef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2089966051u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemyNORef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2089966051u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			NetworkObject val3 = default(NetworkObject);
			if (((NetworkObjectReference)(ref enemyNORef)).TryGet(ref val3, (NetworkManager)null))
			{
				if (!UZGConfig.enemyList.Contains(((Component)val3).GetComponent<EnemyAI>().enemyType.enemyName))
				{
					Plugin.SpamLog("The client is trying to send an enemy that is not in the config!!!", Plugin.spamType.error);
				}
				else if (UZGConfig.enableExplosion.Value)
				{
					Vector3 position = ((Component)val3).gameObject.transform.position;
					EnemyAI component = ((Component)val3).gameObject.GetComponent<EnemyAI>();
					if (component.enemyType.canDie)
					{
						component.KillEnemyServerRpc(false);
					}
					else
					{
						component.KillEnemyServerRpc(true);
					}
					BlowUpEnemyClientRpc(position);
				}
			}
			else
			{
				Plugin.SpamLog("The client is trying to send a non-existent enemy!!!", Plugin.spamType.error);
			}
		}

		[ClientRpc]
		private void BlowUpEnemyClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1035235681u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1035235681u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(ZapGunMethods.ExplodeNextFrame(position));
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SyncShovelDamageServerRpc(NetworkObjectReference shovelNORef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3194388427u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3194388427u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			NetworkObject val3 = default(NetworkObject);
			if (((NetworkObjectReference)(ref shovelNORef)).TryGet(ref val3, (NetworkManager)null))
			{
				if (!UZGConfig.enableWeaponCharging.Value)
				{
					Plugin.SpamLog("The client is trying to charge a weapon!!!", Plugin.spamType.error);
					return;
				}
				WeaponShockableScript component = ((Component)val3).gameObject.GetComponent<WeaponShockableScript>();
				SyncShovelDamageClientRpc(shovelNORef, UZGConfig.chargeLifeTime.Value);
			}
			else
			{
				Plugin.SpamLog("The client is trying to send a non-existent shovel!!!", Plugin.spamType.error);
			}
		}

		[ClientRpc]
		private void SyncShovelDamageClientRpc(NetworkObjectReference shovelNORef, float seconds)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1596931241u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref seconds, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1596931241u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = default(NetworkObject);
					((NetworkObjectReference)(ref shovelNORef)).TryGet(ref val3, (NetworkManager)null);
					((Component)val3).GetComponent<WeaponShockableScript>().SyncDamageOnLocalClient(seconds);
				}
			}
		}

		[ClientRpc]
		private void SyncCanShockSpikeClientRpc(NetworkObjectReference obj, bool canShock)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1887262031u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref canShock, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1887262031u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = default(NetworkObject);
					((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null);
					SpiketrapShockableScript componentInChildren = ((Component)val3).GetComponentInChildren<SpiketrapShockableScript>();
					componentInChildren.SyncCanShockOnLocalClient(canShock);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SyncZapCountServerRpc(NetworkObjectReference obj, int zapCount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(23251114u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, zapCount);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 23251114u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (zapCount >= UZGConfig.spiketrapZapNeeded.Value)
				{
					SyncCanShockSpikeClientRpc(obj, canShock: false);
				}
				SyncZapCountClientRpc(obj, zapCount);
			}
		}

		[ClientRpc]
		private void SyncZapCountClientRpc(NetworkObjectReference obj, int zapCount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2552547060u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, zapCount);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2552547060u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null);
				SpiketrapShockableScript componentInChildren = ((Component)val3).GetComponentInChildren<SpiketrapShockableScript>();
				if (componentInChildren.zapCount > zapCount)
				{
					SyncZapCountServerRpc(obj, componentInChildren.zapCount + 1);
				}
				else
				{
					componentInChildren.zapCount = zapCount;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void DOTPlayerServerRpc(NetworkBehaviourReference playerNBRef, int playerWhoHit)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2387514609u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerNBRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, playerWhoHit);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2387514609u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB val3 = default(PlayerControllerB);
			if (((NetworkBehaviourReference)(ref playerNBRef)).TryGet<PlayerControllerB>(ref val3, (NetworkManager)null))
			{
				if (!UZGConfig.enableDOTPlayers.Value || UZGConfig.zapDamageToPlayer.Value == 0)
				{
					return;
				}
				foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
				{
					if (((GrabbableObject)zapGun).isBeingUsed && zapGun.shockedTargetScript == val3)
					{
						zapgun = zapGun;
					}
				}
				((MonoBehaviour)this).StartCoroutine(DOT.DOTPlayer(val3, playerWhoHit, UZGConfig.zapDamageToPlayer.Value, UZGConfig.zapTimeToDamage.Value, zapgun));
			}
			else
			{
				Plugin.SpamLog("Can't find targetedPlayer!!!", Plugin.spamType.error);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void DOTEnemyServerRpc(NetworkBehaviourReference enemyNBRef, NetworkBehaviourReference playerWhoHitNBRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2311549797u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref enemyNBRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerWhoHitNBRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2311549797u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			EnemyAI val3 = default(EnemyAI);
			if (((NetworkBehaviourReference)(ref enemyNBRef)).TryGet<EnemyAI>(ref val3, (NetworkManager)null))
			{
				PlayerControllerB playerWhoHit = default(PlayerControllerB);
				if (((NetworkBehaviourReference)(ref playerWhoHitNBRef)).TryGet<PlayerControllerB>(ref playerWhoHit, (NetworkManager)null))
				{
					if (!UZGConfig.enableDOTEnemy.Value)
					{
						return;
					}
					EnemyAICollisionDetect componentInChildren = ((Component)val3).GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren == (Object)null)
					{
						Plugin.SpamLog("Can't find EnemyAICollisionDetect!!!", Plugin.spamType.error);
						return;
					}
					foreach (PatcherTool zapGun in ZapGunMethods.zapGuns)
					{
						if (((GrabbableObject)zapGun).isBeingUsed && zapGun.shockedTargetScript == componentInChildren)
						{
							zapgun = zapGun;
						}
					}
					((MonoBehaviour)this).StartCoroutine(DOT.DOTEnemy(componentInChildren, playerWhoHit, UZGConfig.zapDamage.Value, UZGConfig.zapTimeToDamage.Value, zapgun));
				}
				else
				{
					Plugin.SpamLog("Can't find playerWhoHit!!!", Plugin.spamType.error);
				}
			}
			else
			{
				Plugin.SpamLog("The client is trying to send a non-existent enemy!!!", Plugin.spamType.error);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_UZGNetwork()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2089966051u, new RpcReceiveHandler(__rpc_handler_2089966051));
			NetworkManager.__rpc_func_table.Add(1035235681u, new RpcReceiveHandler(__rpc_handler_1035235681));
			NetworkManager.__rpc_func_table.Add(3194388427u, new RpcReceiveHandler(__rpc_handler_3194388427));
			NetworkManager.__rpc_func_table.Add(1596931241u, new RpcReceiveHandler(__rpc_handler_1596931241));
			NetworkManager.__rpc_func_table.Add(1887262031u, new RpcReceiveHandler(__rpc_handler_1887262031));
			NetworkManager.__rpc_func_table.Add(23251114u, new RpcReceiveHandler(__rpc_handler_23251114));
			NetworkManager.__rpc_func_table.Add(2552547060u, new RpcReceiveHandler(__rpc_handler_2552547060));
			NetworkManager.__rpc_func_table.Add(2387514609u, new RpcReceiveHandler(__rpc_handler_2387514609));
			NetworkManager.__rpc_func_table.Add(2311549797u, new RpcReceiveHandler(__rpc_handler_2311549797));
		}

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

		private static void __rpc_handler_1035235681(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UZGNetwork)(object)target).BlowUpEnemyClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		private static void __rpc_handler_1596931241(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference shovelNORef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref shovelNORef, default(ForNetworkSerializable));
				float seconds = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref seconds, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UZGNetwork)(object)target).SyncShovelDamageClientRpc(shovelNORef, seconds);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1887262031(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				bool canShock = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref canShock, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UZGNetwork)(object)target).SyncCanShockSpikeClientRpc(obj, canShock);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_23251114(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				int zapCount = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref zapCount);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UZGNetwork)(object)target).SyncZapCountServerRpc(obj, zapCount);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2552547060(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				int zapCount = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref zapCount);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UZGNetwork)(object)target).SyncZapCountClientRpc(obj, zapCount);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2387514609(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerNBRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerNBRef, default(ForNetworkSerializable));
				int playerWhoHit = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerWhoHit);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UZGNetwork)(object)target).DOTPlayerServerRpc(playerNBRef, playerWhoHit);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2311549797(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference enemyNBRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref enemyNBRef, default(ForNetworkSerializable));
				NetworkBehaviourReference playerWhoHitNBRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerWhoHitNBRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UZGNetwork)(object)target).DOTEnemyServerRpc(enemyNBRef, playerWhoHitNBRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "UZGNetwork";
		}
	}
}
namespace UsefulZapGun.Methods
{
	internal class DOT
	{
		internal static IEnumerator DOTPlayer(PlayerControllerB player, int playerWhoHit, int damageToPlayer, float time, PatcherTool zapgun)
		{
			while (zapgun.shockedTargetScript == player && ((GrabbableObject)zapgun).isBeingUsed)
			{
				player.DamagePlayerFromOtherClientServerRpc(damageToPlayer, ((Component)player).transform.position, playerWhoHit);
				yield return (object)new WaitForSeconds(time);
			}
		}

		internal static IEnumerator DOTEnemy(EnemyAICollisionDetect enemyAICol, PlayerControllerB playerWhoHit, int force, float time, PatcherTool zapgun)
		{
			while (zapgun.shockedTargetScript == enemyAICol && ((GrabbableObject)zapgun).isBeingUsed)
			{
				((IHittable)enemyAICol).Hit(force, ((Component)enemyAICol).transform.position, playerWhoHit, false, -1);
				yield return (object)new WaitForSeconds(time);
			}
		}
	}
	internal class ZapGunMethods
	{
		internal static List<PatcherTool> zapGuns = new List<PatcherTool>();

		private static Coroutine coroutine;

		internal static IEnumerator ExplodeNextFrame(Vector3 position)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForEndOfFrame();
			Landmine.SpawnExplosion(position, true, 0f, 5f, 20, 3f, (GameObject)null, false);
		}

		internal static void WaitAndExplode(EnemyAICollisionDetect enemyCol, EnemyAI enemyScript, float time)
		{
			foreach (PatcherTool zapGun in zapGuns)
			{
				if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
				{
					coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitAndExplodeCoroutine(zapGun, enemyCol, enemyScript, time));
				}
			}
		}

		private static IEnumerator WaitAndExplodeCoroutine(PatcherTool zapgun, EnemyAICollisionDetect enemyCol, EnemyAI enemyScript, float time)
		{
			while (time > 0f)
			{
				yield return (object)new WaitForSeconds(0.1f);
				time -= 0.1f;
				Plugin.SpamLog($"time = {time}", Plugin.spamType.debug);
				if (!((GrabbableObject)zapgun).isBeingUsed || zapgun.shockedTargetScript != enemyCol)
				{
					Plugin.SpamLog("Stop charging explosion!", Plugin.spamType.debug);
					((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
				}
			}
			zapgun.StopShockingAnomalyOnClient(true);
			yield return (object)new WaitForEndOfFrame();
			NetworkObjectReference enemyNORef = new NetworkObjectReference(((NetworkBehaviour)enemyScript).NetworkObject);
			GameNetworkManagerPatch.hostNetHandler.BlowUpEnemyServerRpc(enemyNORef);
		}

		internal static void StartFire(EnemyAICollisionDetect enemyCol, ForestGiantAI enemyScript)
		{
			foreach (PatcherTool zapGun in zapGuns)
			{
				if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
				{
					coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitAndStartFire(enemyScript, zapGun, enemyCol));
				}
			}
		}

		private static IEnumerator WaitAndStartFire(ForestGiantAI enemyScript, PatcherTool zapgun, EnemyAICollisionDetect enemyCol)
		{
			float time = UZGConfig.timeToStartAFire.Value;
			while (time > 0f)
			{
				yield return (object)new WaitForSeconds(0.1f);
				time -= 0.1f;
				Plugin.SpamLog($"time = {time}", Plugin.spamType.debug);
				if (!((GrabbableObject)zapgun).isBeingUsed || zapgun.shockedTargetScript != enemyCol)
				{
					Plugin.SpamLog("Stop zapping giant!", Plugin.spamType.debug);
					((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
				}
			}
			yield return (object)new WaitForEndOfFrame();
			((EnemyAI)enemyScript).HitFromExplosion(Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)enemyScript).transform.position));
		}

		internal static void StartEvaporation(EnemyAICollisionDetect enemyCol, BlobAI enemyScript)
		{
			foreach (PatcherTool zapGun in zapGuns)
			{
				if (((GrabbableObject)zapGun).isBeingUsed && (Object)(object)((GrabbableObject)zapGun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController && zapGun.shockedTargetScript == enemyCol)
				{
					coroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(Evaporate(enemyScript, zapGun, enemyCol));
				}
			}
		}

		private static IEnumerator Evaporate(BlobAI enemyScript, PatcherTool zapgun, EnemyAICollisionDetect enemyCol)
		{
			float blobYScale = 1f;
			while (blobYScale > 0f)
			{
				blobYScale = ((Component)enemyScript).gameObject.transform.localScale.y;
				Plugin.SpamLog($"blob Y scale: {blobYScale}", Plugin.spamType.debug);
				yield return (object)new WaitForSeconds(0.1f);
				Transform transform = ((Component)enemyScript).transform;
				transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f);
				if (zapgun.shockedTargetScript != enemyCol || !((GrabbableObject)zapgun).isBeingUsed)
				{
					Plugin.SpamLog("Stop zapping blob!", Plugin.spamType.debug);
					((MonoBehaviour)StartOfRound.Instance).StopCoroutine(coroutine);
				}
			}
			zapgun.StopShockingAnomalyOnClient(true);
			yield return (object)new WaitForEndOfFrame();
			if (((EnemyAI)enemyScript).enemyType.canDie)
			{
				((EnemyAI)enemyScript).KillEnemyServerRpc(false);
			}
			else
			{
				((EnemyAI)enemyScript).KillEnemyServerRpc(true);
			}
		}
	}
}
namespace UsefulZapGun.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}

UZGCodeRebirthCompat.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeRebirth.src.Content.Maps;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UZGCodeRebirthCompat.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UsefulZapGun.Compatibility.CodeRebirth.Network;
using UsefulZapGun.Compatibility.CodeRebirth.Patches;
using UsefulZapGun.Compatibility.CodeRebirth.Scripts;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UZGCodeRebirthCompat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+39f23941af98edbf4c2304695ce7141be76bf902")]
[assembly: AssemblyProduct("UZGCodeRebirthCompat")]
[assembly: AssemblyTitle("UZGCodeRebirthCompat")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
internal class CRConfig
{
	internal static ConfigEntry<bool> enableACUZap;

	internal static ConfigEntry<bool> enableBearTrapZap;

	internal static ConfigEntry<bool> enableFlashZap;

	internal static ConfigEntry<bool> enableFanZap;

	internal static ConfigEntry<bool> enableLaserZap;

	internal static ConfigEntry<bool> enableMicrowaveZap;

	internal static ConfigEntry<bool> enableTeslaZap;

	internal static void RebirthConfigSetup(ConfigFile cfg)
	{
		enableACUZap = cfg.Bind<bool>("Hazards", "Enable ACUnit zap", true, "Decrease radius by 1/15 every second");
		enableBearTrapZap = cfg.Bind<bool>("Hazards", "Enable BearTrap zap", true, "...have you ever tried to charge a conductive item?");
		enableFlashZap = cfg.Bind<bool>("Hazards", "Enable FlashTurret zap", true, "Increases cooldown to a maximum of 1 minute");
		enableFanZap = cfg.Bind<bool>("Hazards", "Enable IndustrialFan zap", true, "Turns off the fan during zap");
		enableLaserZap = cfg.Bind<bool>("Hazards", "Enable LazerTurret zap", true, "Beware of the laser turret battery explosion");
		enableMicrowaveZap = cfg.Bind<bool>("Hazards", "Enable Microwave zap", true, "Toggle microwave");
		enableTeslaZap = cfg.Bind<bool>("Hazards", "Enable Tesla zap", true, "Turns off tesla at half the maximum charge of the zap gun... but beware of the zap gun explosion");
	}
}
[BepInPlugin("mborsh.UsefulZapGun.CRCompat", "UsefulZapGun.CRCompat", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CRPlugin : BaseUnityPlugin
{
	internal enum spamType
	{
		info,
		message,
		warning,
		debug,
		error,
		fatal
	}

	private static ManualLogSource mls;

	private readonly Harmony harmony = new Harmony("mborsh.UsefulZapGun.CRCompat");

	private static ConfigFile cfg;

	private const string modGUID = "mborsh.UsefulZapGun.CRCompat";

	private const string modName = "UsefulZapGun.CRCompat";

	private const string modVersion = "0.0.1";

	public static CRPlugin Instance { get; private set; }

	private static void NetcodePatcher()
	{
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		Type[] array = types;
		foreach (Type type in array)
		{
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
			MethodInfo[] array2 = methods;
			foreach (MethodInfo methodInfo in array2)
			{
				object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
				if (customAttributes.Length != 0)
				{
					methodInfo.Invoke(null, null);
				}
			}
		}
	}

	private void Awake()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		Instance = this;
		mls = Logger.CreateLogSource("UsefulZapGun.CRCompat");
		mls = ((BaseUnityPlugin)this).Logger;
		if (!Chainloader.PluginInfos.ContainsKey("CodeRebirth"))
		{
			mls.LogInfo((object)"CodeRebirth is not installed, skipping!");
			return;
		}
		NetcodePatcher();
		cfg = new ConfigFile(Path.Combine(Paths.ConfigPath, "mborsh.UsefulZapGun.CRCompat.cfg"), true);
		CRConfig.RebirthConfigSetup(cfg);
		mls.LogInfo((object)"mborsh.UsefulZapGun.CRCompat loaded. Patching.");
		harmony.PatchAll(typeof(CodeRebirthMapHazardsPatch));
		harmony.PatchAll(typeof(CodeRebirthGameNetworkManagerPatch));
	}

	internal static void SpamLog(string message, spamType type)
	{
		switch (type)
		{
		case spamType.info:
			mls.LogInfo((object)message);
			break;
		case spamType.message:
			mls.LogMessage((object)message);
			break;
		case spamType.warning:
			mls.LogWarning((object)message);
			break;
		case spamType.debug:
			mls.LogDebug((object)message);
			break;
		case spamType.error:
			mls.LogError((object)message);
			break;
		case spamType.fatal:
			mls.LogFatal((object)message);
			break;
		}
	}
}
namespace UsefulZapGun.Compatibility.CodeRebirth.Scripts
{
	internal class ACUShockableScript : MonoBehaviour, IShockableWithGun
	{
		private AirControlUnit mainScript;

		private float initialRange;

		private Coroutine coroutine;

		private bool isStunnedByLocalClient;

		private void Start()
		{
			mainScript = ((Component)((Component)this).transform.parent).GetComponent<AirControlUnit>();
			initialRange = mainScript.detectionRange;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return mainScript.detectionRange > 0f && coroutine == null;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 1.5f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position + new Vector3(0f, 2f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			CRPlugin.SpamLog("Shock ac unit", CRPlugin.spamType.message);
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			coroutine = ((MonoBehaviour)this).StartCoroutine(DecreaseDetectionRangeEverySecond(zapgun));
			AirControlUnit obj = mainScript;
			obj.rotationSpeed /= 3f;
			isStunnedByLocalClient = (Object)(object)shockedByPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			CRPlugin.SpamLog("Stop zaping ac unit!", CRPlugin.spamType.debug);
			((MonoBehaviour)this).StopCoroutine(coroutine);
			coroutine = null;
			AirControlUnit obj = mainScript;
			obj.rotationSpeed *= 3f;
			if (isStunnedByLocalClient)
			{
				NetworkBehaviourReference aCURef = default(NetworkBehaviourReference);
				((NetworkBehaviourReference)(ref aCURef))..ctor((NetworkBehaviour)(object)mainScript);
				CodeRebirthGameNetworkManagerPatch.rebirthNetwork.SyncACURangeServerRpc(aCURef);
				isStunnedByLocalClient = false;
			}
		}

		private IEnumerator DecreaseDetectionRangeEverySecond(PatcherTool zapgun)
		{
			while (mainScript.detectionRange > 0f)
			{
				yield return (object)new WaitForSeconds(1f);
				AirControlUnit obj = mainScript;
				obj.detectionRange -= initialRange / 15f;
			}
			yield return (object)new WaitForEndOfFrame();
			zapgun.StopShockingAnomalyOnClient(false);
		}
	}
	internal class BearTrapShockableScript : MonoBehaviour, IShockableWithGun
	{
		private BearTrap mainScript;

		private void Start()
		{
			mainScript = ((Component)this).GetComponent<BearTrap>();
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return true;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position + new Vector3(0f, 0.5f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			CRPlugin.SpamLog("Shock bear trap", CRPlugin.spamType.message);
			if (!((Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
				((MonoBehaviour)this).StartCoroutine(WhyDoYouWantToChargeIt(zapgun, shockedByPlayer));
			}
		}

		void IShockableWithGun.StopShockingWithGun()
		{
		}

		private IEnumerator WhyDoYouWantToChargeIt(PatcherTool zapgun, PlayerControllerB shockedByPlayer)
		{
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			zapgun.StopShockingAnomalyOnClient(true);
			yield return (object)new WaitForEndOfFrame();
			shockedByPlayer.DamagePlayer(15, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
			if (!mainScript.trapCollider.enabled)
			{
				mainScript.DoOnCancelReleaseTrapServerRpc();
			}
		}
	}
	internal class FlashShockableScript : MonoBehaviour, IShockableWithGun
	{
		private FlashTurret mainScript;

		private float initialCooldown;

		private float maxCooldown;

		private Coroutine coroutine;

		private bool isStunnedByLocalClient;

		private void Start()
		{
			mainScript = ((Component)this).GetComponent<FlashTurret>();
			initialCooldown = mainScript.flashCooldown;
			maxCooldown = 60f;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return mainScript.flashCooldown < maxCooldown && coroutine == null;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 1.5f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position + new Vector3(0f, 2f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			CRPlugin.SpamLog("Shock flash turret", CRPlugin.spamType.message);
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			coroutine = ((MonoBehaviour)this).StartCoroutine(IncreseCooldown(zapgun));
			FlashTurret obj = mainScript;
			obj.detectionRange *= 5f;
			FlashTurret obj2 = mainScript;
			obj2.rotationSpeed /= 5f;
			isStunnedByLocalClient = (Object)(object)shockedByPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			CRPlugin.SpamLog("Stop zaping flash turret!", CRPlugin.spamType.debug);
			((MonoBehaviour)this).StopCoroutine(coroutine);
			coroutine = null;
			FlashTurret obj = mainScript;
			obj.detectionRange /= 5f;
			FlashTurret obj2 = mainScript;
			obj2.rotationSpeed *= 5f;
			if (isStunnedByLocalClient)
			{
				NetworkBehaviourReference flashRef = default(NetworkBehaviourReference);
				((NetworkBehaviourReference)(ref flashRef))..ctor((NetworkBehaviour)(object)mainScript);
				CodeRebirthGameNetworkManagerPatch.rebirthNetwork.SyncFlashCooldownServerRpc(flashRef);
				isStunnedByLocalClient = false;
			}
		}

		private IEnumerator IncreseCooldown(PatcherTool zapgun)
		{
			while (mainScript.flashCooldown < maxCooldown)
			{
				FlashTurret obj = mainScript;
				obj.flashCooldown += Time.deltaTime;
				yield return (object)new WaitForEndOfFrame();
			}
			if (maxCooldown > mainScript.flashCooldown)
			{
				mainScript.flashCooldown = maxCooldown;
			}
			yield return (object)new WaitForEndOfFrame();
			zapgun.StopShockingAnomalyOnClient(true);
		}
	}
	internal class IndustrialFanShockableScript : MonoBehaviour, IShockableWithGun
	{
		private IndustrialFan mainScript;

		private Animator animator;

		private float defaultSuckForce;

		private float defaultPushForce;

		private float defaultRotationSpeed;

		private bool isShockedByAnotherClient;

		private void Start()
		{
			animator = ((Component)this).GetComponent<Animator>();
			mainScript = ((Component)this).GetComponent<IndustrialFan>();
			defaultSuckForce = mainScript.suctionForce;
			defaultPushForce = mainScript.pushForce;
			defaultRotationSpeed = mainScript.rotationSpeed;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return !isShockedByAnotherClient;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0.9f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_0007: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position + new Vector3(0f, 1f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			if ((Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				isShockedByAnotherClient = true;
			}
			mainScript.windAudioSource.Pause();
			mainScript.rotationSpeed = 0f;
			mainScript.pushForce = 0f;
			mainScript.suctionForce = 0f;
			((Behaviour)animator).enabled = false;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
			isShockedByAnotherClient = false;
			mainScript.windAudioSource.UnPause();
			mainScript.rotationSpeed = defaultRotationSpeed;
			mainScript.pushForce = defaultPushForce;
			mainScript.suctionForce = defaultSuckForce;
			((Behaviour)animator).enabled = true;
		}
	}
	internal class LaserShockableScript : MonoBehaviour, IShockableWithGun
	{
		private LaserTurret mainScript;

		private bool isExploded;

		private void Start()
		{
			mainScript = ((Component)this).GetComponent<LaserTurret>();
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return !isExploded;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position + new Vector3(0f, 0.5f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			isExploded = true;
			((MonoBehaviour)this).StartCoroutine(Explode(zapgun));
		}

		void IShockableWithGun.StopShockingWithGun()
		{
		}

		private IEnumerator Explode(PatcherTool zapgun)
		{
			yield return (object)new WaitForSeconds(1.5f);
			if (((GrabbableObject)zapgun).isBeingUsed && zapgun.shockedTargetScript == this)
			{
				yield return (object)new WaitForEndOfFrame();
				yield return (object)new WaitForEndOfFrame();
				zapgun.StopShockingAnomalyOnClient(false);
				yield return (object)new WaitForEndOfFrame();
				Landmine.SpawnExplosion(((Component)mainScript).transform.position + new Vector3(0f, 0.5f, 0f), true, 2f, 6f, 20, 5f, (GameObject)null, false);
				mainScript.impactAudioSource.Stop();
				((Component)((Component)mainScript).transform.Find("LaserIdleAudioSource")).gameObject.SetActive(false);
				((Component)((Component)mainScript).transform.Find("LaserTrapArmature")).gameObject.SetActive(false);
				((Component)((Component)mainScript).transform.Find("Light (4)")).gameObject.SetActive(false);
				((Behaviour)mainScript).enabled = false;
			}
		}
	}
	internal class MicrowaveShockableScript : MonoBehaviour, IShockableWithGun
	{
		private FunctionalMicrowave mainScript;

		private float microwaveOpeningTimer;

		private float microwaveClosingTimer;

		private bool isShockedByAnotherClient;

		private void Start()
		{
			mainScript = ((Component)this).GetComponent<FunctionalMicrowave>();
			microwaveClosingTimer = mainScript.microwaveClosingTimer;
			microwaveOpeningTimer = mainScript.microwaveOpeningTimer;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return !isShockedByAnotherClient;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position;
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if ((Object)(object)shockedByPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				isShockedByAnotherClient = true;
			}
			PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
			((MonoBehaviour)this).StartCoroutine(ToggleMicrowave(zapgun));
		}

		void IShockableWithGun.StopShockingWithGun()
		{
		}

		private IEnumerator ToggleMicrowave(PatcherTool zapgun)
		{
			if (mainScript.animator.GetBool("isActivated"))
			{
				mainScript.microwaveClosingTimer = 0f;
			}
			else
			{
				mainScript.microwaveOpeningTimer = 0f;
			}
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForEndOfFrame();
			mainScript.microwaveClosingTimer = microwaveClosingTimer;
			mainScript.microwaveOpeningTimer = microwaveOpeningTimer;
			((GrabbableObject)zapgun).insertedBattery.charge = Mathf.Clamp(((GrabbableObject)zapgun).insertedBattery.charge - 0.15f, 0f, 1f);
			zapgun.StopShockingAnomalyOnClient(true);
		}
	}
	internal class TeslaShockableScript : MonoBehaviour, IShockableWithGun
	{
		private TeslaShock mainScript;

		private Coroutine coroutine;

		internal float chargeNeeded;

		internal float charge;

		private void Start()
		{
			mainScript = ((Component)this).GetComponent<TeslaShock>();
			chargeNeeded = 0.4f;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return ((Behaviour)mainScript).enabled;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return 0.8f;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_000c: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)mainScript).transform.position + new Vector3(0f, 2f, 0f);
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)mainScript).transform;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if ((Object)(object)shockedByPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				PatcherTool zapgun = (PatcherTool)shockedByPlayer.currentlyHeldObjectServer;
				coroutine = ((MonoBehaviour)this).StartCoroutine(DrainChargeAndExplode(zapgun));
			}
		}

		void IShockableWithGun.StopShockingWithGun()
		{
			if (coroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(coroutine);
				coroutine = null;
			}
		}

		private IEnumerator DrainChargeAndExplode(PatcherTool zapgun)
		{
			while (((GrabbableObject)zapgun).insertedBattery.charge > 0f)
			{
				charge += Time.deltaTime / 22f;
				if (charge >= chargeNeeded)
				{
					NetworkBehaviourReference TeslaRef = new NetworkBehaviourReference((NetworkBehaviour)(object)mainScript);
					CodeRebirthGameNetworkManagerPatch.rebirthNetwork.SyncTeslaServerRpc(charge, TeslaRef);
					zapgun.StopShockingAnomalyOnClient(false);
				}
				yield return (object)new WaitForEndOfFrame();
			}
			yield return (object)new WaitForEndOfFrame();
			Landmine.SpawnExplosion(((Component)zapgun).transform.position, true, 2f, 4f, 30, 0f, (GameObject)null, false);
		}

		internal void DisableMainScriptOnLocalClient()
		{
			mainScript.teslaIdleAudioSource.Stop();
			mainScript.teslaAudioSource.Stop();
			mainScript.vfx.Stop();
			((Behaviour)mainScript).enabled = false;
			((Component)((Component)mainScript).transform.Find("vg_PlasmaSphere")).gameObject.SetActive(false);
		}
	}
}
namespace UsefulZapGun.Compatibility.CodeRebirth.Patches
{
	internal class CodeRebirthGameNetworkManagerPatch
	{
		internal static GameObject netHandler;

		internal static CodeRebirthNetwork rebirthNetwork;

		internal static GameObject hostNetHandler;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		public static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(netHandler);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		public static void FindNetworkHandler()
		{
			rebirthNetwork = Object.FindAnyObjectByType<CodeRebirthNetwork>();
			CRPlugin.SpamLog("rebirthNerwork found", CRPlugin.spamType.debug);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyAfter(new string[] { "mborsh.UsefulZapGun" })]
		private static void AddPrefabsToNetwork()
		{
			netHandler = Plugin.mainAssetBundle.LoadAsset<GameObject>("CRUsefulZapGunNO.prefab");
			netHandler.AddComponent<CodeRebirthNetwork>();
			NetworkManager.Singleton.AddNetworkPrefab(netHandler);
		}
	}
	internal class CodeRebirthMapHazardsPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(AirControlUnit), "Start")]
		private static void ACUStartPatch(ref AirControlUnit __instance)
		{
			if (CRConfig.enableACUZap.Value)
			{
				((Component)((Component)__instance).transform.Find("Body")).gameObject.AddComponent<ACUShockableScript>();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BearTrap), "Start")]
		private static void BearTrapStartPatch(ref BearTrap __instance)
		{
			if (CRConfig.enableBearTrapZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<BearTrapShockableScript>();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FlashTurret), "Start")]
		private static void FlashStartPatch(ref FlashTurret __instance)
		{
			if (CRConfig.enableFlashZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<FlashShockableScript>();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(IndustrialFan), "Start")]
		private static void FanStartPatch(ref IndustrialFan __instance)
		{
			if (CRConfig.enableFanZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<IndustrialFanShockableScript>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(IndustrialFan), "OnTriggerEnter")]
		private static bool FanOnTriggerEnterPatch(ref IndustrialFan __instance)
		{
			return __instance.suctionForce != 0f;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LaserTurret), "Start")]
		private static void LaserStartPatch(ref LaserTurret __instance)
		{
			if (CRConfig.enableLaserZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<LaserShockableScript>();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FunctionalMicrowave), "Start")]
		private static void MicrowaveStartPatch(ref FunctionalMicrowave __instance)
		{
			if (CRConfig.enableMicrowaveZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<MicrowaveShockableScript>();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TeslaShock), "Start")]
		private static void TeslaStartPatch(ref TeslaShock __instance)
		{
			if (CRConfig.enableTeslaZap.Value)
			{
				((Component)__instance).gameObject.AddComponent<TeslaShockableScript>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(TeslaShock), "OnTriggerEnter")]
		private static bool TeslaOnTriggerEnterPatch(ref TeslaShock __instance)
		{
			return ((Behaviour)__instance).enabled;
		}
	}
}
namespace UsefulZapGun.Compatibility.CodeRebirth.Network
{
	internal class CodeRebirthNetwork : NetworkBehaviour
	{
		[ServerRpc(RequireOwnership = false)]
		internal void SyncACURangeServerRpc(NetworkBehaviourReference ACURef, bool disable = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3185104038u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref ACURef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref disable, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3185104038u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				AirControlUnit val3 = default(AirControlUnit);
				((NetworkBehaviourReference)(ref ACURef)).TryGet<AirControlUnit>(ref val3, (NetworkManager)null);
				if (disable)
				{
					val3.detectionRange = 0f;
				}
				SyncACURangeClientRpc(ACURef, val3.detectionRange);
			}
		}

		[ClientRpc]
		private void SyncACURangeClientRpc(NetworkBehaviourReference ACURef, float range)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4072061886u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref ACURef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref range, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4072061886u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					AirControlUnit val3 = default(AirControlUnit);
					((NetworkBehaviourReference)(ref ACURef)).TryGet<AirControlUnit>(ref val3, (NetworkManager)null);
					CRPlugin.SpamLog($"Sync ACU range: {val3.detectionRange} -> {range}", CRPlugin.spamType.info);
					val3.detectionRange = range;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SyncFlashCooldownServerRpc(NetworkBehaviourReference FlashRef, bool disable = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(248246971u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref FlashRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref disable, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 248246971u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				FlashTurret val3 = default(FlashTurret);
				((NetworkBehaviourReference)(ref FlashRef)).TryGet<FlashTurret>(ref val3, (NetworkManager)null);
				if (disable)
				{
					val3.flashCooldown = 60f;
				}
				SyncFlashCooldownClientRpc(FlashRef, val3.flashCooldown);
			}
		}

		[ClientRpc]
		private void SyncFlashCooldownClientRpc(NetworkBehaviourReference FlashRef, float cooldown)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3617916993u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref FlashRef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref cooldown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3617916993u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					FlashTurret val3 = default(FlashTurret);
					((NetworkBehaviourReference)(ref FlashRef)).TryGet<FlashTurret>(ref val3, (NetworkManager)null);
					CRPlugin.SpamLog($"Sync FlashTurret CD: {val3.flashCooldown} -> {cooldown}", CRPlugin.spamType.info);
					val3.flashCooldown = cooldown;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void SyncTeslaServerRpc(float charge, NetworkBehaviourReference TeslaRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2153772629u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref charge, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref TeslaRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2153772629u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				TeslaShock val3 = default(TeslaShock);
				((NetworkBehaviourReference)(ref TeslaRef)).TryGet<TeslaShock>(ref val3, (NetworkManager)null);
				TeslaShockableScript component = ((Component)val3).GetComponent<TeslaShockableScript>();
				bool enabled = true;
				if (charge >= component.chargeNeeded)
				{
					enabled = false;
				}
				SyncTeslaClientRpc(charge, TeslaRef, enabled);
			}
		}

		[ClientRpc]
		private void SyncTeslaClientRpc(float charge, NetworkBehaviourReference TeslaRef, bool enabled)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3625816464u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref charge, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref TeslaRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3625816464u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				TeslaShock val3 = default(TeslaShock);
				((NetworkBehaviourReference)(ref TeslaRef)).TryGet<TeslaShock>(ref val3, (NetworkManager)null);
				TeslaShockableScript component = ((Component)val3).GetComponent<TeslaShockableScript>();
				if (!enabled)
				{
					component.DisableMainScriptOnLocalClient();
				}
				else
				{
					component.charge = charge;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CodeRebirthNetwork()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3185104038u, new RpcReceiveHandler(__rpc_handler_3185104038));
			NetworkManager.__rpc_func_table.Add(4072061886u, new RpcReceiveHandler(__rpc_handler_4072061886));
			NetworkManager.__rpc_func_table.Add(248246971u, new RpcReceiveHandler(__rpc_handler_248246971));
			NetworkManager.__rpc_func_table.Add(3617916993u, new RpcReceiveHandler(__rpc_handler_3617916993));
			NetworkManager.__rpc_func_table.Add(2153772629u, new RpcReceiveHandler(__rpc_handler_2153772629));
			NetworkManager.__rpc_func_table.Add(3625816464u, new RpcReceiveHandler(__rpc_handler_3625816464));
		}

		private static void __rpc_handler_3185104038(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference aCURef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref aCURef, default(ForNetworkSerializable));
				bool disable = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref disable, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CodeRebirthNetwork)(object)target).SyncACURangeServerRpc(aCURef, disable);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4072061886(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference aCURef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref aCURef, default(ForNetworkSerializable));
				float range = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref range, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CodeRebirthNetwork)(object)target).SyncACURangeClientRpc(aCURef, range);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_248246971(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference flashRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref flashRef, default(ForNetworkSerializable));
				bool disable = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref disable, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CodeRebirthNetwork)(object)target).SyncFlashCooldownServerRpc(flashRef, disable);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3617916993(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference flashRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref flashRef, default(ForNetworkSerializable));
				float cooldown = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref cooldown, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CodeRebirthNetwork)(object)target).SyncFlashCooldownClientRpc(flashRef, cooldown);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2153772629(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float charge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref charge, default(ForPrimitives));
				NetworkBehaviourReference teslaRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref teslaRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CodeRebirthNetwork)(object)target).SyncTeslaServerRpc(charge, teslaRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3625816464(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float charge = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref charge, default(ForPrimitives));
				NetworkBehaviourReference teslaRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref teslaRef, default(ForNetworkSerializable));
				bool enabled = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enabled, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CodeRebirthNetwork)(object)target).SyncTeslaClientRpc(charge, teslaRef, enabled);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CodeRebirthNetwork";
		}
	}
}
namespace UZGCodeRebirthCompat.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}