Decompiled source of StandaloneDefibrillator v4.1.0

StandaloneDefibrillator.dll

Decompiled 2 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.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using StandaloneDefibrillator.NetcodePatcher;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("StandaloneDefibrillator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.1.0.0")]
[assembly: AssemblyInformationalVersion("4.1.0")]
[assembly: AssemblyProduct("StandaloneDefibrillator")]
[assembly: AssemblyTitle("StandaloneDefibrillator")]
[assembly: AssemblyVersion("4.1.0.0")]
[module: NetcodePatchedAssembly]
namespace StandaloneDefibrillator
{
	[HarmonyPatch]
	internal static class Defib
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<FastBufferWriter> <>9__12_0;

			public static Action<FastBufferWriter> <>9__12_1;

			public static HandleNamedMessageDelegate <>9__13_0;

			public static HandleNamedMessageDelegate <>9__13_1;

			public static HandleNamedMessageDelegate <>9__13_2;

			public static HandleNamedMessageDelegate <>9__13_3;

			internal void <LocalTick>b__12_0(FastBufferWriter _)
			{
			}

			internal void <LocalTick>b__12_1(FastBufferWriter _)
			{
			}

			internal void <RegisterHandlers>b__13_0(ulong sender, FastBufferReader _)
			{
				ServerSpawn(sender);
			}

			internal void <RegisterHandlers>b__13_1(ulong sender, FastBufferReader _)
			{
				RelayUnequip(sender);
			}

			internal void <RegisterHandlers>b__13_2(ulong _, FastBufferReader r)
			{
				//IL_0006: 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_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				int index = default(int);
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref index, default(ForPrimitives));
				ulong id = default(ulong);
				((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
				Equip(index, id);
			}

			internal void <RegisterHandlers>b__13_3(ulong _, FastBufferReader r)
			{
				//IL_0006: 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)
				int index = default(int);
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref index, default(ForPrimitives));
				Unequip(Player(index));
			}
		}

		private const string MsgRequest = "StandaloneDefib.Request";

		private const string MsgEquip = "StandaloneDefib.Equip";

		private const string MsgUnequip = "StandaloneDefib.Unequip";

		private const string MsgUnequipFx = "StandaloneDefib.UnequipFx";

		internal static Item item = null;

		internal static InputAction key = null;

		private static float requestedAt = -10f;

		private static readonly MethodInfo switchToItemSlot = AccessTools.Method(typeof(PlayerControllerB), "SwitchToItemSlot", (Type[])null, (Type[])null);

		private static readonly MethodInfo setSpecialGrabAnimationBool = AccessTools.Method(typeof(PlayerControllerB), "SetSpecialGrabAnimationBool", (Type[])null, (Type[])null);

		private static NetworkManager Net => NetworkManager.Singleton;

		private static bool HoldingDefib(PlayerControllerB p)
		{
			return p.currentlyHeldObjectServer is DefibrillatorScript;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void LocalTick(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance?.localPlayerController || !key.WasPressedThisFrame() || (Object)(object)Net == (Object)null || !Net.IsConnectedClient || !__instance.isPlayerControlled || __instance.isPlayerDead || __instance.inTerminalMenu || __instance.isTypingChat || __instance.quickMenuManager.isMenuOpen || __instance.isGrabbingObjectAnimation || __instance.inSpecialInteractAnimation || __instance.activatingItem)
			{
				return;
			}
			if (HoldingDefib(__instance))
			{
				Unequip(__instance);
				if (Net.IsServer)
				{
					RelayUnequip(0uL);
				}
				else
				{
					Send("StandaloneDefib.Unequip", 0uL, delegate
					{
					});
				}
			}
			else if (!__instance.twoHanded && !__instance.isClimbingLadder && !(Time.time - requestedAt < 2f))
			{
				requestedAt = Time.time;
				if (Net.IsServer)
				{
					ServerSpawn(0uL);
				}
				else
				{
					Send("StandaloneDefib.Request", 0uL, delegate
					{
					});
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void RegisterHandlers()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = Net.CustomMessagingManager;
			if (Net.IsServer)
			{
				object obj = <>c.<>9__13_0;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader _)
					{
						ServerSpawn(sender);
					};
					<>c.<>9__13_0 = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("StandaloneDefib.Request", (HandleNamedMessageDelegate)obj);
				object obj2 = <>c.<>9__13_1;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader _)
					{
						RelayUnequip(sender);
					};
					<>c.<>9__13_1 = val2;
					obj2 = (object)val2;
				}
				customMessagingManager.RegisterNamedMessageHandler("StandaloneDefib.Unequip", (HandleNamedMessageDelegate)obj2);
			}
			object obj3 = <>c.<>9__13_2;
			if (obj3 == null)
			{
				HandleNamedMessageDelegate val3 = delegate(ulong _, FastBufferReader r)
				{
					//IL_0006: 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_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					int index = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref index, default(ForPrimitives));
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Equip(index, id);
				};
				<>c.<>9__13_2 = val3;
				obj3 = (object)val3;
			}
			customMessagingManager.RegisterNamedMessageHandler("StandaloneDefib.Equip", (HandleNamedMessageDelegate)obj3);
			object obj4 = <>c.<>9__13_3;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val4 = delegate(ulong _, FastBufferReader r)
				{
					//IL_0006: 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)
					int index = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref index, default(ForPrimitives));
					Unequip(Player(index));
				};
				<>c.<>9__13_3 = val4;
				obj4 = (object)val4;
			}
			customMessagingManager.RegisterNamedMessageHandler("StandaloneDefib.UnequipFx", (HandleNamedMessageDelegate)obj4);
		}

		private unsafe static void Send(string msg, ulong to, Action<FastBufferWriter> write)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
			try
			{
				write(val);
				Net.CustomMessagingManager.SendNamedMessage(msg, to, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void SendToClients(string msg, ulong except, Action<FastBufferWriter> write)
		{
			foreach (ulong connectedClientsId in Net.ConnectedClientsIds)
			{
				if (connectedClientsId != 0L && connectedClientsId != except)
				{
					Send(msg, connectedClientsId, write);
				}
			}
		}

		private static PlayerControllerB Player(int index)
		{
			return StartOfRound.Instance.allPlayerScripts[index];
		}

		private static void ServerSpawn(ulong sender)
		{
			//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (!StartOfRound.Instance.ClientPlayerList.TryGetValue(sender, out var index))
			{
				return;
			}
			PlayerControllerB val = Player(index);
			if (!val.isPlayerDead && !HoldingDefib(val))
			{
				DefibrillatorScript component = Object.Instantiate<GameObject>(item.spawnPrefab, ((Component)val).transform.position + Vector3.up, Quaternion.identity, StartOfRound.Instance.propsContainer).GetComponent<DefibrillatorScript>();
				((GrabbableObject)component).fallTime = 0f;
				((NetworkBehaviour)component).NetworkObject.SpawnWithOwnership(sender, false);
				ulong id = ((NetworkBehaviour)component).NetworkObjectId;
				Equip(index, id);
				SendToClients("StandaloneDefib.Equip", 0uL, delegate(FastBufferWriter w)
				{
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref index, default(ForPrimitives));
					((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
				});
			}
		}

		private static void RelayUnequip(ulong sender)
		{
			if (StartOfRound.Instance.ClientPlayerList.TryGetValue(sender, out var index))
			{
				if (sender != 0L)
				{
					Unequip(Player(index));
				}
				SendToClients("StandaloneDefib.UnequipFx", sender, delegate(FastBufferWriter w)
				{
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref index, default(ForPrimitives));
				});
			}
		}

		private static void Equip(int index, ulong id)
		{
			PlayerControllerB obj = Player(index);
			((MonoBehaviour)obj).StartCoroutine(EquipWhenSpawned(obj, id));
		}

		private static IEnumerator EquipWhenSpawned(PlayerControllerB p, ulong id)
		{
			NetworkObject no = null;
			for (float t = 0f; t < 3f; t += Time.deltaTime)
			{
				if (Net.SpawnManager.SpawnedObjects.TryGetValue(id, out no))
				{
					break;
				}
				yield return null;
			}
			if ((Object)(object)no == (Object)null)
			{
				yield break;
			}
			DefibrillatorScript d = ((Component)no).GetComponent<DefibrillatorScript>();
			while ((Object)(object)d != (Object)null && ((GrabbableObject)d).propColliders == null)
			{
				yield return null;
			}
			yield return null;
			if ((Object)(object)d == (Object)null || p.isPlayerDead)
			{
				yield break;
			}
			((GrabbableObject)d).parentObject = (((Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController) ? p.localItemHolder : p.serverItemHolder);
			((GrabbableObject)d).isHeld = true;
			((GrabbableObject)d).hasHitGround = false;
			((GrabbableObject)d).isInFactory = p.isInsideFactory;
			((GrabbableObject)d).EnablePhysics(false);
			d.attached = true;
			GrabbableObject currentlyHeldObjectServer = p.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null)
			{
				currentlyHeldObjectServer.playerHeldBy = p;
				if (((NetworkBehaviour)p).IsOwner)
				{
					setSpecialGrabAnimationBool.Invoke(p, new object[2] { false, currentlyHeldObjectServer });
				}
				currentlyHeldObjectServer.PocketItem();
			}
			((GrabbableObject)d).playerHeldBy = p;
			((GrabbableObject)d).EquipItem();
			if (((NetworkBehaviour)p).IsOwner)
			{
				setSpecialGrabAnimationBool.Invoke(p, new object[2] { true, d });
			}
			if ((Object)(object)currentlyHeldObjectServer != (Object)null)
			{
				if (((GrabbableObject)d).itemProperties.twoHandedAnimation || currentlyHeldObjectServer.itemProperties.twoHandedAnimation)
				{
					p.playerBodyAnimator.ResetTrigger("SwitchHoldAnimationTwoHanded");
					p.playerBodyAnimator.SetTrigger("SwitchHoldAnimationTwoHanded");
				}
				p.playerBodyAnimator.ResetTrigger("SwitchHoldAnimation");
				p.playerBodyAnimator.SetTrigger("SwitchHoldAnimation");
			}
			p.twoHandedAnimation = ((GrabbableObject)d).itemProperties.twoHandedAnimation;
			p.twoHanded = ((GrabbableObject)d).itemProperties.twoHanded;
			p.playerBodyAnimator.SetBool("GrabValidated", true);
			p.playerBodyAnimator.SetBool("cancelHolding", false);
			p.isHoldingObject = true;
			p.currentlyHeldObjectServer = (GrabbableObject)(object)d;
		}

		private static void Unequip(PlayerControllerB p)
		{
			if (HoldingDefib(p))
			{
				switchToItemSlot.Invoke(p, new object[2] { p.currentItemSlot, null });
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Discard_performed")]
		[HarmonyPrefix]
		private static bool BlockDropKey(PlayerControllerB __instance)
		{
			return !HoldingDefib(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		[HarmonyPrefix]
		private static bool BlockDrop(PlayerControllerB __instance)
		{
			return !HoldingDefib(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DropAllHeldItems")]
		[HarmonyPrefix]
		private static void BeforeDropAll(PlayerControllerB __instance)
		{
			if (HoldingDefib(__instance))
			{
				__instance.currentlyHeldObjectServer.PocketItem();
				__instance.currentlyHeldObjectServer = __instance.ItemSlots[__instance.currentItemSlot];
			}
		}
	}
	public class DefibrillatorScript : GrabbableObject
	{
		private Coroutine coroutine;

		private bool ReadyingDefib;

		private Renderer[] displayRenderers;

		private GameObject ChargeDisplayOne;

		private GameObject ChargeDisplayTwo;

		private GameObject ChargeDisplayThree;

		private GameObject ChargeDisplayFour;

		private GameObject ChargeDisplayFive;

		private GameObject BatteryDisplay;

		private Renderer DisplayOneRenderer;

		private Renderer DisplayTwoRenderer;

		private Renderer DisplayThreeRenderer;

		private Renderer DisplayFourRenderer;

		private Renderer DisplayFiveRenderer;

		private Renderer BatteryDisplayRenderer;

		private AudioSource ChargedAudio;

		private AudioSource ShockAudio;

		private AudioSource ChargeUpAudio;

		internal static AudioClip ChargeUpClip;

		private int timeToHold;

		private float batteryCost;

		private bool RequiresBattery;

		private bool UsesLimited;

		private bool PermaDeathRule;

		private bool DefibrillatorRefillsOnLanding;

		private int useLimit;

		public NetworkVariable<int> savedUseLimit = new NetworkVariable<int>(3, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		internal bool attached;

		private float spawnedAt = -1f;

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			if (useLimit <= 0)
			{
				savedUseLimit.Value = -1;
			}
			else
			{
				savedUseLimit.Value = useLimit;
			}
			return savedUseLimit.Value;
		}

		public override void LoadItemSaveData(int saveData)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).LoadItemSaveData(saveData);
			if (saveData == -1)
			{
				useLimit = 0;
				Renderer[] array = displayRenderers;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].material.SetColor("_EmissiveColor", Color.red);
				}
			}
			else
			{
				useLimit = saveData;
			}
		}

		public void Awake()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			BatteryDisplay = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("BatteryDisplay")).gameObject;
			BatteryDisplayRenderer = BatteryDisplay.GetComponent<Renderer>();
			RequiresBattery = Plugin.instance.RequiresBattery.Value;
			BatteryDisplayRenderer.material.SetColor("_EmissiveColor", Color.yellow);
			if (RequiresBattery)
			{
				base.insertedBattery = new Battery(false, 1f);
				batteryCost = base.insertedBattery.charge / 2f;
			}
			else
			{
				base.itemProperties.requiresBattery = false;
			}
			AudioSource[] components = ((Component)((Component)this).transform.Find("DefibrillatorSounds")).gameObject.GetComponents<AudioSource>();
			ChargedAudio = components[0];
			ShockAudio = components[1];
			if ((Object)(object)ChargeUpClip != (Object)null)
			{
				ChargeUpAudio = ((Component)ChargedAudio).gameObject.AddComponent<AudioSource>();
				ChargeUpAudio.clip = ChargeUpClip;
				ChargeUpAudio.playOnAwake = false;
				ChargeUpAudio.outputAudioMixerGroup = ChargedAudio.outputAudioMixerGroup;
				ChargeUpAudio.spatialBlend = ChargedAudio.spatialBlend;
				ChargeUpAudio.rolloffMode = ChargedAudio.rolloffMode;
				ChargeUpAudio.minDistance = ChargedAudio.minDistance;
				ChargeUpAudio.maxDistance = ChargedAudio.maxDistance;
				ChargeUpAudio.volume = ChargedAudio.volume;
			}
			ChargeDisplayOne = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("Charge1")).gameObject;
			ChargeDisplayTwo = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("Charge2")).gameObject;
			ChargeDisplayThree = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("Charge3")).gameObject;
			ChargeDisplayFour = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("Charge4")).gameObject;
			ChargeDisplayFive = ((Component)((Component)((Component)this).transform.Find("DefibrillatorModel")).gameObject.transform.Find("Charge5")).gameObject;
			DisplayOneRenderer = ChargeDisplayOne.GetComponent<Renderer>();
			DisplayTwoRenderer = ChargeDisplayTwo.GetComponent<Renderer>();
			DisplayThreeRenderer = ChargeDisplayThree.GetComponent<Renderer>();
			DisplayFourRenderer = ChargeDisplayFour.GetComponent<Renderer>();
			DisplayFiveRenderer = ChargeDisplayFive.GetComponent<Renderer>();
			displayRenderers = (Renderer[])(object)new Renderer[5] { DisplayOneRenderer, DisplayTwoRenderer, DisplayThreeRenderer, DisplayFourRenderer, DisplayFiveRenderer };
			UsesLimited = Plugin.instance.UsesLimited.Value;
			useLimit = Plugin.instance.UseLimit.Value;
			PermaDeathRule = Plugin.instance.PermaDeathRule.Value;
			DefibrillatorRefillsOnLanding = Plugin.instance.RefillsOnLanding.Value;
			if (UsesLimited && useLimit < 1)
			{
				MonoBehaviour.print((object)"US - US_Defibrillator savedUses enabled but number of savedUses less than the minimum of 1! setting savedUses to 1.");
				useLimit = 1;
			}
		}

		public override void ChargeBatteries()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ChargeBatteries();
			if (RequiresBattery)
			{
				BatteryDisplayRenderer.material.SetColor("_EmissiveColor", Color.yellow);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			DespawnWhenPutDown();
			if (DefibrillatorRefillsOnLanding && StartOfRound.Instance.inShipPhase && useLimit != Plugin.instance.UseLimit.Value)
			{
				useLimit = Plugin.instance.UseLimit.Value;
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (base.heldByPlayerOnServer && UsesLimited)
			{
				base.itemProperties.toolTips[0] = $"Remaining Uses - {useLimit}";
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if (base.heldByPlayerOnServer && UsesLimited)
			{
				base.itemProperties.toolTips[0] = $"Remaining Uses - {useLimit}";
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (buttonDown)
			{
				if (RequiresBattery && !base.insertedBattery.empty)
				{
					Renderer[] array = displayRenderers;
					for (int i = 0; i < array.Length; i++)
					{
						array[i].material.SetColor("_EmissiveColor", Color.black);
					}
					if (UsesLimited && useLimit <= 0)
					{
						array = displayRenderers;
						for (int i = 0; i < array.Length; i++)
						{
							array[i].material.SetColor("_EmissiveColor", Color.red);
						}
						return;
					}
					ReadyingDefib = true;
					coroutine = ((MonoBehaviour)this).StartCoroutine(ReadyDefib());
				}
				else if (!RequiresBattery)
				{
					Renderer[] array = displayRenderers;
					for (int i = 0; i < array.Length; i++)
					{
						array[i].material.SetColor("_EmissiveColor", Color.black);
					}
					if (UsesLimited && useLimit <= 0)
					{
						array = displayRenderers;
						for (int i = 0; i < array.Length; i++)
						{
							array[i].material.SetColor("_EmissiveColor", Color.red);
						}
						return;
					}
					ReadyingDefib = true;
					coroutine = ((MonoBehaviour)this).StartCoroutine(ReadyDefib());
				}
			}
			if (!buttonDown)
			{
				ReadyingDefib = false;
				AudioSource chargeUpAudio = ChargeUpAudio;
				if (chargeUpAudio != null)
				{
					chargeUpAudio.Stop();
				}
			}
		}

		private IEnumerator ReadyDefib()
		{
			timeToHold = 160;
			base.isBeingUsed = true;
			if ((Object)(object)ChargeUpAudio != (Object)null)
			{
				ChargeUpAudio.Play();
			}
			Renderer[] array;
			while (ReadyingDefib)
			{
				yield return (object)new WaitForSeconds(0.05f);
				int i;
				if (!base.isHeld || base.isPocketed)
				{
					AudioSource chargeUpAudio = ChargeUpAudio;
					if (chargeUpAudio != null)
					{
						chargeUpAudio.Stop();
					}
					ReadyingDefib = false;
					array = displayRenderers;
					for (i = 0; i < array.Length; i++)
					{
						array[i].material.SetColor("_EmissiveColor", Color.black);
					}
					base.isBeingUsed = false;
					yield break;
				}
				if (timeToHold > 0)
				{
					timeToHold--;
				}
				if (timeToHold > 120)
				{
					DisplayOneRenderer.material.SetColor("_EmissiveColor", Color.green);
				}
				i = timeToHold;
				if (i <= 120 && i > 80)
				{
					DisplayTwoRenderer.material.SetColor("_EmissiveColor", Color.green);
				}
				i = timeToHold;
				if (i <= 80 && i > 40)
				{
					DisplayThreeRenderer.material.SetColor("_EmissiveColor", Color.green);
				}
				i = timeToHold;
				if (i <= 40 && i > 0)
				{
					DisplayFourRenderer.material.SetColor("_EmissiveColor", Color.green);
				}
				if (timeToHold != 0 || !ReadyingDefib)
				{
					continue;
				}
				DisplayFiveRenderer.material.SetColor("_EmissiveColor", Color.green);
				ChargedAudio.PlayOneShot(ChargedAudio.clip);
				yield return (object)new WaitUntil((Func<bool>)(() => !ReadyingDefib || !base.isHeld || base.isPocketed));
				AudioSource chargeUpAudio2 = ChargeUpAudio;
				if (chargeUpAudio2 != null)
				{
					chargeUpAudio2.Stop();
				}
				ShockAudio.PlayOneShot(ShockAudio.clip);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				if (RequiresBattery)
				{
					if (base.insertedBattery.charge > batteryCost)
					{
						base.insertedBattery.charge = base.insertedBattery.charge - batteryCost;
					}
					else if (base.insertedBattery.charge < batteryCost)
					{
						BatteryDisplayRenderer.material.SetColor("_EmissiveColor", Color.black);
						base.insertedBattery.empty = true;
						base.insertedBattery.charge = 0f;
						base.isBeingUsed = false;
					}
				}
				if (!base.isHeld || base.isPocketed)
				{
					ReadyingDefib = false;
					base.isBeingUsed = false;
					array = displayRenderers;
					for (i = 0; i < array.Length; i++)
					{
						array[i].material.SetColor("_EmissiveColor", Color.black);
					}
					yield break;
				}
				ReadyingDefib = false;
				break;
			}
			AudioSource chargeUpAudio3 = ChargeUpAudio;
			if (chargeUpAudio3 != null)
			{
				chargeUpAudio3.Stop();
			}
			array = displayRenderers;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].material.SetColor("_EmissiveColor", Color.black);
			}
			base.isBeingUsed = false;
			if (base.isHeld && timeToHold == 0)
			{
				FindBody();
			}
		}

		public void FindBody()
		{
			//IL_0010: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.SphereCastAll(((Component)base.playerHeldBy.gameplayCamera).transform.position, 3f, ((Component)base.playerHeldBy.gameplayCamera).transform.forward, 5f, LayerMask.GetMask(new string[1] { "PlayerRagdoll" }));
			DeadBodyInfo val2 = default(DeadBodyInfo);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<DeadBodyInfo>(ref val2))
				{
					continue;
				}
				int playerObjectId = val2.playerObjectId;
				PlayerControllerB val3 = RoundManager.Instance.playersManager.allPlayerScripts[playerObjectId];
				Vector3 spawnPosition = ((RaycastHit)(ref val)).transform.position + Vector3.up * 0.25f;
				if (PermaDeathRule && ((int)val2.causeOfDeath == 17 || val2.detachedHead))
				{
					MonoBehaviour.print((object)"US - This corpse can't be saved. What a mess.");
					break;
				}
				if (!((Object)(object)val3 != (Object)null) || !val3.isPlayerDead || Object.op_Implicit((Object)(object)val3.currentlyHeldObject))
				{
					continue;
				}
				RevivePlayerServerRpc(playerObjectId, spawnPosition);
				if (((NetworkBehaviour)this).IsHost)
				{
					DeadBodyInfo[] array2 = Object.FindObjectsOfType<DeadBodyInfo>(true);
					foreach (DeadBodyInfo val4 in array2)
					{
						if (val4.playerObjectId != playerObjectId)
						{
							continue;
						}
						RagdollGrabbableObject[] array3 = Object.FindObjectsOfType<RagdollGrabbableObject>(true);
						foreach (RagdollGrabbableObject val5 in array3)
						{
							if (val5.ragdoll.playerObjectId == val4.playerObjectId)
							{
								Object.Destroy((Object)(object)((Component)((Component)val5).transform).gameObject);
							}
						}
					}
				}
				else if (((NetworkBehaviour)this).IsClient)
				{
					DestroyBodyServerRpc(playerObjectId);
				}
				break;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DestroyBodyServerRpc(int ID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3796529404u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, ID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3796529404u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(true);
			foreach (DeadBodyInfo val3 in array)
			{
				if (val3.playerObjectId != ID)
				{
					continue;
				}
				RagdollGrabbableObject[] array2 = Object.FindObjectsOfType<RagdollGrabbableObject>(true);
				foreach (RagdollGrabbableObject val4 in array2)
				{
					if (val4.ragdoll.playerObjectId == val3.playerObjectId)
					{
						Object.Destroy((Object)(object)((Component)((Component)val4).transform).gameObject);
					}
				}
			}
		}

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

		[ClientRpc]
		public void RevivePlayerClientRpc(int ID, Vector3 SpawnPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(642176207u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, ID);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref SpawnPosition);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 642176207u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					RevivePlayer(ID, SpawnPosition);
				}
			}
		}

		public void RevivePlayer(int PlayerID, Vector3 SpawnPosition)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerID < 0)
			{
				MonoBehaviour.print((object)"US - No player inital id? returning..");
				return;
			}
			PlayerControllerB val = RoundManager.Instance.playersManager.allPlayerScripts[PlayerID];
			if (!val.isPlayerDead)
			{
				return;
			}
			if (base.playerHeldBy.isInsideFactory)
			{
				val.isInsideFactory = true;
				val.isInElevator = false;
				val.isInHangarShipRoom = false;
			}
			else
			{
				val.isInsideFactory = false;
				val.isInElevator = true;
				val.isInHangarShipRoom = true;
			}
			val.ResetPlayerBloodObjects(val.isPlayerDead);
			val.health = 5;
			val.isClimbingLadder = false;
			val.clampLooking = false;
			val.inVehicleAnimation = false;
			val.disableMoveInput = false;
			val.disableLookInput = false;
			val.disableInteract = false;
			val.ResetZAndXRotation();
			((Collider)val.thisController).enabled = true;
			if (val.isPlayerDead)
			{
				MonoBehaviour.print((object)"US - Player inital is dead, reviving them!");
				((Collider)val.thisController).enabled = true;
				val.isPlayerDead = false;
				val.isPlayerControlled = true;
				val.health = 5;
				val.hasBeenCriticallyInjured = false;
				val.criticallyInjured = false;
				val.playerBodyAnimator.SetBool("Limp", false);
				val.TeleportPlayer(SpawnPosition, false, 0f, false, true);
				val.parentedToElevatorLastFrame = false;
				val.overrideGameOverSpectatePivot = null;
				StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
				val.setPositionOfDeadPlayer = false;
				val.DisablePlayerModel(((Component)val).gameObject, true, true);
				((Behaviour)val.helmetLight).enabled = false;
				val.Crouch(false);
				if ((Object)(object)val.playerBodyAnimator != (Object)null)
				{
					val.playerBodyAnimator.SetBool("Limp", false);
				}
				val.bleedingHeavily = true;
				val.deadBody = null;
				val.activatingItem = false;
				val.twoHanded = false;
				val.inShockingMinigame = false;
				val.inSpecialInteractAnimation = false;
				val.freeRotationInInteractAnimation = false;
				val.disableSyncInAnimation = false;
				val.inAnimationWithEnemy = null;
				val.holdingWalkieTalkie = false;
				val.speakingToWalkieTalkie = false;
				val.isSinking = false;
				val.isUnderwater = false;
				val.sinkingValue = 0f;
				val.statusEffectAudio.Stop();
				val.DisableJetpackControlsLocally();
				val.mapRadarDotAnimator.SetBool("dead", false);
				val.hasBegunSpectating = false;
				val.externalForceAutoFade = Vector3.zero;
				val.hinderedMultiplier = 1f;
				val.isMovementHindered = 0;
				val.sourcesCausingSinking = 0;
				val.reverbPreset = StartOfRound.Instance.shipReverb;
				SoundManager.Instance.earsRingingTimer = 0f;
				val.voiceMuffledByEnemy = false;
				SoundManager.Instance.playerVoicePitchTargets[PlayerID] = 1f;
				SoundManager.Instance.SetPlayerPitch(1f, PlayerID);
				if ((Object)(object)val.currentVoiceChatIngameSettings == (Object)null)
				{
					StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
				}
				if ((Object)(object)val.currentVoiceChatIngameSettings != (Object)null)
				{
					if ((Object)(object)val.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						val.currentVoiceChatIngameSettings.InitializeComponents();
					}
					try
					{
						((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
					}
					catch
					{
						Debug.LogError((object)("Audio error for player " + ((Object)val).name + ", US."));
					}
				}
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController.playerClientId == val.playerClientId)
			{
				localPlayerController.bleedingHeavily = false;
				localPlayerController.criticallyInjured = false;
				localPlayerController.health = 5;
				HUDManager.Instance.UpdateHealthUI(5, true);
				localPlayerController.playerBodyAnimator.SetBool("Limp", false);
				localPlayerController.spectatedPlayerScript = null;
				StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, localPlayerController);
				StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
				((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
				HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
				HUDManager.Instance.RemoveSpectateUI();
				HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
			}
			StartOfRound.Instance.allPlayersDead = false;
			StartOfRound instance = StartOfRound.Instance;
			instance.livingPlayers++;
			if (GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				HUDManager.Instance.UpdateBoxesSpectateUI();
			}
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
			if (UsesLimited && useLimit > 0)
			{
				useLimit--;
				if (useLimit <= 0)
				{
					Renderer[] array = displayRenderers;
					for (int i = 0; i < array.Length; i++)
					{
						array[i].material.SetColor("_EmissiveColor", Color.red);
					}
				}
			}
			if (base.heldByPlayerOnServer && UsesLimited)
			{
				base.itemProperties.toolTips[0] = $"Remaining Uses - {useLimit}";
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		private void DespawnWhenPutDown()
		{
			if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			if (spawnedAt < 0f)
			{
				spawnedAt = Time.time;
			}
			if (!attached)
			{
				if (Time.time - spawnedAt > 5f)
				{
					((NetworkBehaviour)this).NetworkObject.Despawn(true);
				}
			}
			else if ((Object)(object)base.playerHeldBy == (Object)null || (Object)(object)base.playerHeldBy.currentlyHeldObjectServer != (Object)(object)this)
			{
				((NetworkBehaviour)this).NetworkObject.Despawn(true);
			}
		}

		protected override void __initializeVariables()
		{
			if (savedUseLimit == null)
			{
				throw new Exception("DefibrillatorScript.savedUseLimit cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)savedUseLimit).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)savedUseLimit, "savedUseLimit");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)savedUseLimit);
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3796529404u, new RpcReceiveHandler(__rpc_handler_3796529404), "DestroyBodyServerRpc");
			((NetworkBehaviour)this).__registerRpc(1838494011u, new RpcReceiveHandler(__rpc_handler_1838494011), "RevivePlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(642176207u, new RpcReceiveHandler(__rpc_handler_642176207), "RevivePlayerClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

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

		private static void __rpc_handler_1838494011(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int iD = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iD);
				Vector3 spawnPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DefibrillatorScript)(object)target).RevivePlayerServerRpc(iD, spawnPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_642176207(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int iD = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref iD);
				Vector3 spawnPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DefibrillatorScript)(object)target).RevivePlayerClientRpc(iD, spawnPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DefibrillatorScript";
		}
	}
	[BepInPlugin("StandaloneDefibrillator", "StandaloneDefibrillator", "4.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "StandaloneDefibrillator";

		public const string PLUGIN_NAME = "StandaloneDefibrillator";

		public const string PLUGIN_VERSION = "4.1.0";

		internal static Plugin instance;

		internal static ManualLogSource Log;

		internal ConfigEntry<string> Key;

		internal ConfigEntry<bool> RequiresBattery;

		internal ConfigEntry<bool> UsesLimited;

		internal ConfigEntry<int> UseLimit;

		internal ConfigEntry<bool> RefillsOnLanding;

		internal ConfigEntry<bool> PermaDeathRule;

		public void Awake()
		{
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Invalid comparison between Unknown and I4
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			Key = ((BaseUnityPlugin)this).Config.Bind<string>("Defibrillator", "Equip key", "<Keyboard>/x", "Press to put a defibrillator in your hand, press again to remove it. Unity Input System path, e.g. <Keyboard>/x, <Keyboard>/r, <Mouse>/middleButton");
			RequiresBattery = ((BaseUnityPlugin)this).Config.Bind<bool>("Defibrillator", "Defibrillator requires battery", false, "Whether or not the Defibrillator requires battery");
			UsesLimited = ((BaseUnityPlugin)this).Config.Bind<bool>("Defibrillator", "Defibrillator uses are limited", false, "Whether or not Defibrillators have limited uses");
			UseLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Defibrillator", "Defibrillators use limit", 3, "The number of uses each Defibrillator has (Uses have a minimum of 1, uses are used up on players successfully revived only)");
			RefillsOnLanding = ((BaseUnityPlugin)this).Config.Bind<bool>("Defibrillator", "Defibrillator refills every moon landing", false, "Whether or not existing Defibrillators will refill their uses upon landing on a moon");
			PermaDeathRule = ((BaseUnityPlugin)this).Config.Bind<bool>("Defibrillator", "Defibrillator follows perma-death rules", true, "Whether or not specific causes of death will prevent the defibrillator from reviving players (Ex - Corpses decapitated by CoilHeads, Corpses snipped in half by a Barber, Corpses head popped by the Ghost Girl)");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "usualscrapassetbundle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not load asset bundle at " + text));
				return;
			}
			string text2 = Path.Combine(Path.GetDirectoryName(text), "defibchargeup.mp3");
			if (File.Exists(text2))
			{
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(new Uri(text2).AbsoluteUri, (AudioType)13);
				try
				{
					audioClip.SendWebRequest();
					while (!audioClip.isDone)
					{
					}
					if ((int)audioClip.result == 1)
					{
						DefibrillatorScript.ChargeUpClip = DownloadHandlerAudioClip.GetContent(audioClip);
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogError((object)("Could not load " + text2 + ": " + audioClip.error));
					}
				}
				finally
				{
					((IDisposable)audioClip)?.Dispose();
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)(text2 + " not found, charge-up sound disabled"));
			}
			Item val2 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/DefibrillatorAssets/US_DefibrillatorItem.asset");
			DefibrillatorScript defibrillatorScript = val2.spawnPrefab.AddComponent<DefibrillatorScript>();
			((GrabbableObject)defibrillatorScript).grabbable = true;
			((GrabbableObject)defibrillatorScript).grabbableToEnemies = true;
			((GrabbableObject)defibrillatorScript).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterItem(val2);
			Defib.item = val2;
			Defib.key = new InputAction("StandaloneDefibEquip", (InputActionType)1, Key.Value, (string)null, (string)null, (string)null);
			Defib.key.Enable();
			new Harmony("StandaloneDefibrillator").PatchAll(typeof(Defib));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"StandaloneDefibrillator 4.1.0 loaded");
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace StandaloneDefibrillator.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}