Decompiled source of AutoRevive v0.1.0

Tomatobird.AutoRevive.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCAutoRevive.Compat;
using LCAutoRevive.Input;
using LCAutoRevive.Network;
using LCAutoRevive.Patches;
using LCAutoRevive.Utils;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using TMPro;
using Tomatobird.AutoRevive.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[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("Tomatobird.AutoRevive")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+a472f1259f517c70c363861ef4fb9e81b24755df")]
[assembly: AssemblyProduct("LCAutoRevive")]
[assembly: AssemblyTitle("Tomatobird.AutoRevive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LCAutoRevive
{
	[BepInPlugin("Tomatobird.AutoRevive", "LCAutoRevive", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LCAutoRevive : BaseUnityPlugin
	{
		internal static float reviveDelay;

		internal static bool waitForInput;

		internal static bool preventShipLeave;

		public static LCAutoRevive Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			reviveDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReviveDelay", 15f, "How long should the player be dead until revived?").Value;
			waitForInput = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "WaitForInput", true, "Should player revival require pressing the revive button after timer is up?").Value;
			preventShipLeave = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PreventShipLeave", true, "Should ship leaving be prevented when all players die?").Value;
			Patch();
			Logger.LogInfo((object)"Tomatobird.AutoRevive v0.1.0 has loaded!");
		}

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

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.AutoRevive";

		public const string PLUGIN_NAME = "LCAutoRevive";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace LCAutoRevive.Utils
{
	internal class HUDHandler : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <WaitForPlayerRevival>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public HUDHandler <>4__this;

			private TextMeshProUGUI <t>5__1;

			private float <timeLeft>5__2;

			private float <interval>5__3;

			private PlayerControllerB[] <>s__4;

			private int <>s__5;

			private PlayerControllerB <player>5__6;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<t>5__1 = null;
				<>s__4 = null;
				<player>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.isRunning = true;
					<t>5__1 = <>4__this.deathCounterTextObject.GetComponent<TextMeshProUGUI>();
					<timeLeft>5__2 = ((LCAutoRevive.reviveDelay >= 0f) ? LCAutoRevive.reviveDelay : 0f);
					<interval>5__3 = 0.1f;
					break;
				case 1:
					<>1__state = -1;
					if (<interval>5__3 > 0f)
					{
						<interval>5__3 -= Time.deltaTime;
						break;
					}
					if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase)
					{
						((TMP_Text)<t>5__1).text = "";
						<>4__this.isRunning = false;
						return false;
					}
					<interval>5__3 = 0.1f;
					<timeLeft>5__2 -= 0.1f + (<interval>5__3 - 0.1f) + Time.deltaTime;
					((TMP_Text)<t>5__1).text = $"Reviving... {Mathf.CeilToInt(<timeLeft>5__2)}";
					break;
				}
				if (<timeLeft>5__2 >= 0f)
				{
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				}
				<>4__this.canRevive = true;
				if (InputUtilsCompat.Enabled && InputUtilsCompat.ReviveKey != null && LCAutoRevive.waitForInput)
				{
					((TMP_Text)<t>5__1).text = "Press " + InputUtilsCompat.ReviveKey.controls[0].displayName + " to revive";
				}
				else
				{
					((TMP_Text)<t>5__1).text = "Reviving now";
					if (!StartOfRound.Instance.shipIsLeaving && !StartOfRound.Instance.inShipPhase)
					{
						<>s__4 = StartOfRound.Instance.allPlayerScripts;
						for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
						{
							<player>5__6 = <>s__4[<>s__5];
							if ((Object)(object)<player>5__6 == (Object)(object)StartOfRound.Instance.localPlayerController && <player>5__6.isPlayerDead)
							{
								NetworkHandler.Instance.RevivePlayerServerRpc((int)<player>5__6.playerClientId);
								<>4__this.canRevive = false;
							}
							<player>5__6 = null;
						}
						<>s__4 = null;
					}
				}
				<>4__this.isRunning = false;
				return false;
			}

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

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

		private GameObject deathCounterTextObject = null;

		internal bool isRunning = false;

		internal bool canRevive = false;

		public static HUDHandler Instance { get; private set; }

		public void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			deathCounterTextObject = new GameObject("ReviveCountDownText");
			deathCounterTextObject.transform.parent = ((Component)HUDManager.Instance.gameOverAnimator).transform.Find("SpectateUI");
			TextMeshProUGUI val = deathCounterTextObject.AddComponent<TextMeshProUGUI>();
			TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.EndOfRunStatsText).font;
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val).font = font;
			}
			((Graphic)val).color = new Color(1f, 0.5647f, 0f, 1f);
			((TMP_Text)val).alignment = (TextAlignmentOptions)1026;
			((Transform)((TMP_Text)val).rectTransform).localScale = Vector3.one;
			((TMP_Text)val).rectTransform.anchoredPosition = new Vector2(0f, -170f);
			((TMP_Text)val).rectTransform.anchoredPosition3D = new Vector3(0f, -170f, 0f);
			((TMP_Text)val).rectTransform.anchorMax = new Vector2(1f, 0f);
			((TMP_Text)val).rectTransform.anchorMin = new Vector2(0f, 0f);
			((TMP_Text)val).rectTransform.offsetMax = new Vector2(0f, -170f);
			((TMP_Text)val).rectTransform.offsetMin = new Vector2(0f, -170f);
			((TMP_Text)val).rectTransform.sizeDelta = new Vector2(0f, 0f);
			((TMP_Text)val).fontSize = 24f;
			((TMP_Text)val).enableWordWrapping = false;
			((TMP_Text)val).text = "Initiating...";
			if (InputUtilsCompat.Enabled && InputUtilsCompat.ReviveKey != null && LCAutoRevive.waitForInput)
			{
				InputUtilsCompat.ReviveKey.performed += OnActionPerformed;
			}
		}

		public void OnActionPerformed(CallbackContext context)
		{
			if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase || !canRevive || !Application.isFocused)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val == (Object)(object)StartOfRound.Instance.localPlayerController && val.isPlayerDead && !val.isTypingChat)
				{
					NetworkHandler.Instance.RevivePlayerServerRpc((int)val.playerClientId);
					canRevive = false;
				}
			}
		}

		public void StartPlayerRevivalCountDown()
		{
			if (!isRunning)
			{
				canRevive = false;
				((MonoBehaviour)this).StartCoroutine(WaitForPlayerRevival());
			}
		}

		[IteratorStateMachine(typeof(<WaitForPlayerRevival>d__10))]
		private IEnumerator WaitForPlayerRevival()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayerRevival>d__10(0)
			{
				<>4__this = this
			};
		}
	}
	public static class RevivePlayer
	{
		public static void ReiveDeadPlayer(int playerId)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			val.ResetPlayerBloodObjects(val.isPlayerDead);
			if (!val.isPlayerDead)
			{
				return;
			}
			val.isClimbingLadder = false;
			if (val.inSpecialInteractAnimation)
			{
				bool num = (Object)(object)val.currentTriggerInAnimationWith == (Object)null;
				InteractTrigger currentTriggerInAnimationWith = val.currentTriggerInAnimationWith;
				if (!(num | !Object.op_Implicit((Object)(object)((currentTriggerInAnimationWith != null) ? ((Component)currentTriggerInAnimationWith).GetComponentInChildren<MoveToExitSpecialAnimation>() : null))))
				{
					goto IL_00d5;
				}
			}
			val.clampLooking = false;
			((Component)val.gameplayCamera).transform.localEulerAngles = new Vector3(((Component)val.gameplayCamera).transform.localEulerAngles.x, 0f, ((Component)val.gameplayCamera).transform.localEulerAngles.z);
			val.inVehicleAnimation = false;
			goto IL_00d5;
			IL_00d5:
			val.disableMoveInput = false;
			val.ResetZAndXRotation();
			((Collider)val.thisController).enabled = true;
			val.health = 100;
			val.hasBeenCriticallyInjured = false;
			val.disableLookInput = false;
			val.disableInteract = false;
			((Behaviour)val.nightVisionRadar).enabled = false;
			if (val.isPlayerDead)
			{
				val.isPlayerDead = false;
				val.isPlayerControlled = true;
				val.isInElevator = true;
				val.isInHangarShipRoom = true;
				val.isInsideFactory = false;
				val.parentedToElevatorLastFrame = false;
				val.overrideGameOverSpectatePivot = null;
				StartOfRound.Instance.SetPlayerObjectExtrapolate(false);
				val.TeleportPlayer(StartOfRound.Instance.GetPlayerSpawnPosition(playerId, false), false, 0f, false, true);
				val.setPositionOfDeadPlayer = false;
				val.DisablePlayerModel(((Component)val).gameObject, true, true);
				((Behaviour)val.helmetLight).enabled = false;
				val.Crouch(false);
				val.criticallyInjured = false;
				if ((Object)(object)val.playerBodyAnimator != (Object)null)
				{
					val.playerBodyAnimator.SetBool("Limp", false);
				}
				val.bleedingHeavily = false;
				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.health = 100;
				val.mapRadarDotAnimator.SetBool("dead", false);
				val.externalForceAutoFade = Vector3.zero;
				((Renderer)val.thisPlayerModel).enabled = true;
				StartOfRound.Instance.allPlayersDead = false;
				if (((NetworkBehaviour)val).IsOwner)
				{
					HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
					val.hasBegunSpectating = false;
					HUDManager.Instance.RemoveSpectateUI();
					HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
					HUDManager.Instance.UpdateHealthUI(100, false);
					val.spectatedPlayerScript = null;
					val.hinderedMultiplier = 1f;
					val.isMovementHindered = 0;
					val.sourcesCausingSinking = 0;
					val.reverbPreset = StartOfRound.Instance.shipReverb;
					HUDManager.Instance.HideHUD(false);
					SoundManager.Instance.earsRingingTimer = 0f;
					TimeOfDay.Instance.DisableAllWeather(false);
					StartOfRound.Instance.SetSpectateCameraToGameOverMode(false, val);
					((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
				}
				else
				{
					((Renderer)val.thisPlayerModelLOD1).enabled = true;
					((Renderer)val.thisPlayerModelLOD2).enabled = true;
				}
				val.voiceMuffledByEnemy = false;
				SoundManager.Instance.playerVoicePitchTargets[val.playerClientId] = 1f;
				SoundManager.Instance.SetPlayerPitch(1f, (int)val.playerClientId);
				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();
					}
					if ((Object)(object)val.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						return;
					}
					((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
				}
			}
			RagdollGrabbableObject[] array = Object.FindObjectsOfType<RagdollGrabbableObject>();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].bodyID.Value != playerId)
				{
					continue;
				}
				if (!((GrabbableObject)array[i]).isHeld)
				{
					if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
					{
						if (((NetworkBehaviour)array[i]).NetworkObject.IsSpawned)
						{
							((NetworkBehaviour)array[i]).NetworkObject.Despawn(true);
						}
						else
						{
							Object.Destroy((Object)(object)((Component)array[i]).gameObject);
						}
						break;
					}
				}
				else if (((GrabbableObject)array[i]).isHeld && (Object)(object)((GrabbableObject)array[i]).playerHeldBy != (Object)null)
				{
					((GrabbableObject)array[i]).playerHeldBy.DropAllHeldItems(true, false);
					break;
				}
			}
			DeadBodyInfo[] array2 = Object.FindObjectsOfType<DeadBodyInfo>(true);
			for (int j = 0; j < array2.Length; j++)
			{
				Object.Destroy((Object)(object)((Component)array2[j]).gameObject);
			}
			StartOfRound.Instance.livingPlayers = StartOfRound.Instance.connectedPlayersAmount + 1;
			StartOfRound.Instance.UpdatePlayerVoiceEffects();
		}
	}
}
namespace LCAutoRevive.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPostfix()
		{
			NetworkHandler.CreateAndRegisterPrefab();
		}

		private static void DisconnectPostfix()
		{
			NetworkHandler.DespawnNetworkHandler();
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDPatcher
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void SpectateUIStartPatch(HUDManager __instance)
		{
			((Component)__instance.gameOverAnimator).gameObject.AddComponent<HUDHandler>();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatcher
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		internal static void KillPlayerPostfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && __instance.AllowPlayerDeath())
			{
				HUDHandler.Instance.StartPlayerRevivalCountDown();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatcher
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void AwakePrefix()
		{
			NetworkHandler.SpawnNetworkHandler();
		}

		[HarmonyPatch("ShipLeaveAutomatically")]
		[HarmonyPrefix]
		internal static bool ShipLeaveAutomaticallyPatch(StartOfRound __instance, ref bool leavingOnMidnight)
		{
			if (!LCAutoRevive.preventShipLeave)
			{
				return true;
			}
			if (!leavingOnMidnight)
			{
				__instance.allPlayersDead = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch("ReviveDeadPlayers")]
		[HarmonyPostfix]
		internal static void ReviveDeadPlayersPostfix()
		{
			HUDHandler.Instance.canRevive = false;
			HUDHandler.Instance.isRunning = false;
		}
	}
}
namespace LCAutoRevive.Network
{
	internal class NetworkHandler : NetworkBehaviour
	{
		private static GameObject? prefab;

		public static NetworkHandler Instance { get; private set; }

		public static void CreateAndRegisterPrefab()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prefab != (Object)null))
			{
				prefab = new GameObject("Tomatobird.AutoRevive Prefab");
				GameObject? obj = prefab;
				((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D);
				NetworkObject obj2 = prefab.AddComponent<NetworkObject>();
				FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
				field.SetValue(obj2, GetHash("Tomatobird.AutoRevive Prefab"));
				prefab.AddComponent<NetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(prefab);
				LCAutoRevive.Logger.LogInfo((object)"Prefab changes done.");
			}
		}

		public static void SpawnNetworkHandler()
		{
			if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
			{
				GameObject obj = Object.Instantiate<GameObject>(prefab);
				if (obj != null)
				{
					obj.GetComponent<NetworkObject>().Spawn(false);
				}
				LCAutoRevive.Logger.LogInfo((object)"Spawned network handler.");
			}
		}

		public static void DespawnNetworkHandler()
		{
			if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost))
			{
				((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				LCAutoRevive.Logger.LogInfo((object)"Despawned network handler.");
			}
		}

		private void Awake()
		{
			Instance = this;
		}

		[ServerRpc(RequireOwnership = false)]
		public void RevivePlayerServerRpc(int playerid)
		{
			//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)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3047310335u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerid);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3047310335u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					RevivePlayerClientRpc(playerid);
				}
			}
		}

		[ClientRpc]
		public void RevivePlayerClientRpc(int playerid)
		{
			//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)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(632973755u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerid);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 632973755u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					RevivePlayer.ReiveDeadPlayer(playerid);
				}
			}
		}

		protected internal static uint GetHash(string value)
		{
			return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3047310335u, new RpcReceiveHandler(__rpc_handler_3047310335), "RevivePlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(632973755u, new RpcReceiveHandler(__rpc_handler_632973755), "RevivePlayerClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_3047310335(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 playerid = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerid);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).RevivePlayerServerRpc(playerid);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_632973755(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 playerid = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerid);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NetworkHandler)(object)target).RevivePlayerClientRpc(playerid);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
}
namespace LCAutoRevive.Input
{
	public class ReviveKey : LcInputActions
	{
		public static readonly ReviveKey Instance = new ReviveKey();

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction? ReviveButton { get; set; }
	}
}
namespace LCAutoRevive.Compat
{
	internal static class InputUtilsCompat
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils");

		public static InputAction? ReviveKey => global::LCAutoRevive.Input.ReviveKey.Instance.ReviveButton;
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace Tomatobird.AutoRevive.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}