Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AutoRevive v0.3.0
Tomatobird.AutoRevive.dll
Decompiled a month agousing 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tomatobird.AutoRevive")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+435ede64621ad09469983f35c504a8c7e6b3b78a")] [assembly: AssemblyProduct("LCAutoRevive")] [assembly: AssemblyTitle("Tomatobird.AutoRevive")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.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.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LCAutoRevive : BaseUnityPlugin { internal static float reviveDelay; internal static bool waitForInput; internal static bool preventShipLeave; internal static float fontSize; internal static float reviveDelayPenalty; internal static int reviveLimit; 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, "Time until reviving is allowed.").Value; reviveDelayPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReviveDelayPenalty", 0f, "Increase in revive delay per death. 0 to disable.").Value; reviveLimit = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ReviveLimit", 0, "Amount of revives allowed per day. 0 to disable.").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 are dead? Ship will leave anyway if no players have revives left.").Value; fontSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FontSize", 24f, "Size of the revive timer text.").Value; Patch(); Logger.LogInfo((object)"Tomatobird.AutoRevive v0.3.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.3.0"; } } namespace LCAutoRevive.Utils { internal class HUDHandler : MonoBehaviour { [CompilerGenerated] private sealed class <WaitForPlayerRevival>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public HUDHandler <>4__this; private float <timeLeft>5__1; private float <interval>5__2; private PlayerControllerB[] <>s__3; private int <>s__4; private PlayerControllerB <player>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForPlayerRevival>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__3 = null; <player>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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; <timeLeft>5__1 = ((LCAutoRevive.reviveDelayPenalty >= 0f) ? (LCAutoRevive.reviveDelay + LCAutoRevive.reviveDelayPenalty * (float)<>4__this.reviveCount) : LCAutoRevive.reviveDelay); <interval>5__2 = 0.1f; break; case 1: <>1__state = -1; if (<interval>5__2 > 0f) { <interval>5__2 -= Time.deltaTime; break; } if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase) { ((TMP_Text)<>4__this.text).text = <>4__this.EditText("", showRevives: false); <>4__this.isRunning = false; <>4__this.reviveCount = 0; return false; } <interval>5__2 = 0.1f; <timeLeft>5__1 -= 0.1f + (<interval>5__2 - 0.1f) + Time.deltaTime; ((TMP_Text)<>4__this.text).text = <>4__this.EditText($"Reviving... {Mathf.CeilToInt(<timeLeft>5__1)}", showRevives: true); break; } if (<timeLeft>5__1 >= 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)<>4__this.text).text = <>4__this.EditText("Press " + InputUtilsCompat.ReviveKey.controls[0].displayName + " to revive", showRevives: true); } else { ((TMP_Text)<>4__this.text).text = <>4__this.EditText("Reviving now", showRevives: true); if (!StartOfRound.Instance.shipIsLeaving && !StartOfRound.Instance.inShipPhase) { <>s__3 = StartOfRound.Instance.allPlayerScripts; for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++) { <player>5__5 = <>s__3[<>s__4]; if ((Object)(object)<player>5__5 == (Object)(object)StartOfRound.Instance.localPlayerController && <player>5__5.isPlayerDead) { NetworkHandler.Instance.RevivePlayerServerRpc((int)<player>5__5.playerClientId); <>4__this.canRevive = false; <>4__this.reviveCount++; break; } <player>5__5 = null; } <>s__3 = 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(); } } internal GameObject deathCountDownTextObject = null; internal GameObject reviveCounterTextObject = null; internal TextMeshProUGUI text = null; internal TextMeshProUGUI reviveText = null; internal bool isRunning = false; internal bool canRevive = false; internal bool isPermaDead = false; internal int reviveCount = 0; private Color textColor = new Color(1f, 0.5647f, 0f, 1f); 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) Instance = this; deathCountDownTextObject = new GameObject("ReviveCountDownText"); deathCountDownTextObject.transform.parent = ((Component)HUDManager.Instance.gameOverAnimator).transform.Find("SpectateUI"); text = deathCountDownTextObject.AddComponent<TextMeshProUGUI>(); TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.EndOfRunStatsText).font; if ((Object)(object)font != (Object)null) { ((TMP_Text)text).font = font; } ((Graphic)text).color = textColor; ((TMP_Text)text).alignment = (TextAlignmentOptions)1026; ((Transform)((TMP_Text)text).rectTransform).localScale = Vector3.one; ((TMP_Text)text).rectTransform.anchoredPosition = new Vector2(0f, -170f); ((TMP_Text)text).rectTransform.anchoredPosition3D = new Vector3(0f, -170f, 0f); ((TMP_Text)text).rectTransform.anchorMax = new Vector2(1f, 0f); ((TMP_Text)text).rectTransform.anchorMin = new Vector2(0f, 0f); ((TMP_Text)text).rectTransform.offsetMax = new Vector2(0f, -170f); ((TMP_Text)text).rectTransform.offsetMin = new Vector2(0f, -170f); ((TMP_Text)text).rectTransform.sizeDelta = new Vector2(0f, 0f); ((TMP_Text)text).fontSize = LCAutoRevive.fontSize; ((TMP_Text)text).enableWordWrapping = false; ((TMP_Text)text).text = EditText("Initiating...", showRevives: false); 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 || (LCAutoRevive.reviveLimit > 0 && reviveCount >= LCAutoRevive.reviveLimit)) { 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; reviveCount++; break; } } } public void StartPlayerRevivalCountDown() { if (isRunning || isPermaDead) { return; } canRevive = false; if (reviveCount >= LCAutoRevive.reviveLimit && LCAutoRevive.reviveLimit > 0) { ((TMP_Text)text).text = EditText("Out of revives", showRevives: false); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)(object)StartOfRound.Instance.localPlayerController) { NetworkHandler.Instance.PermaDeadPlayerServerRpc((int)val.playerClientId); isPermaDead = true; break; } } } else { ((MonoBehaviour)this).StartCoroutine(WaitForPlayerRevival()); } } [IteratorStateMachine(typeof(<WaitForPlayerRevival>d__16))] private IEnumerator WaitForPlayerRevival() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPlayerRevival>d__16(0) { <>4__this = this }; } internal string EditText(string s, bool showRevives) { string text = s; if (LCAutoRevive.reviveLimit > reviveCount && showRevives) { text += $"\nRevives left: {LCAutoRevive.reviveLimit - reviveCount}"; } return text; } internal void ShipLeave() { canRevive = false; reviveCount = 0; if (!((Object)(object)text == (Object)null)) { ((TMP_Text)text).text = EditText("", showRevives: false); } } } 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055e: 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.overridePoisonValue = false; 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.enemyWaitingForBodyRagdoll = null; 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.SetCracksOnVisor(100f); 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; StartOfRound.Instance.SendChangedWeightEvent(); 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; val.sprintMeter = 1f; } 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 != 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, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3)); 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(); } [HarmonyPatch("Disconnect")] [HarmonyPostfix] 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 || NetworkHandler.Instance.AllPlayersPermaDead()) { return true; } if (!leavingOnMidnight) { __instance.allPlayersDead = false; return false; } return true; } [HarmonyPatch("OnPlayerDC")] [HarmonyPostfix] internal static void OnPlayerDCPostFix(StartOfRound __instance, ref int playerObjectNumber, ref ulong clientId) { if (__instance.allPlayerObjects[playerObjectNumber].GetComponent<PlayerControllerB>().disconnectedMidGame && ((NetworkBehaviour)__instance).IsServer) { NetworkHandler.Instance.DisconnectPermaDeadPlayer((int)clientId); } } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] internal static void ReviveDeadPlayersPostfix() { HUDHandler.Instance.canRevive = false; HUDHandler.Instance.isRunning = false; HUDHandler.Instance.isPermaDead = false; HUDHandler.Instance.reviveCount = 0; NetworkHandler.Instance.ResetPermaDeadPlayers(); } [HarmonyPatch("ShipLeave")] [HarmonyPostfix] internal static void ShipLeavePostfix(StartOfRound __instance) { if (__instance.shipIsLeaving) { HUDHandler.Instance.ShipLeave(); } } } } namespace LCAutoRevive.Network { internal class NetworkHandler : NetworkBehaviour { private static GameObject? prefab = null; internal static List<int> PermaDeadPlayers = new List<int>(); internal static bool allPlayersDead; public static NetworkHandler Instance { get; private set; } = null; 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; } public void ResetPermaDeadPlayers() { PermaDeadPlayers = new List<int>(); allPlayersDead = false; } public int GetPermaDeadPlayerCount(bool onPlayerDC) { return onPlayerDC ? (PermaDeadPlayers.Count + 1) : PermaDeadPlayers.Count; } public bool AllPlayersPermaDead() { return allPlayersDead; } public void CheckIfAllPlayersDead(bool onPlayerDC) { if (GetPermaDeadPlayerCount(onPlayerDC) >= GameNetworkManager.Instance.connectedPlayers && !allPlayersDead) { allPlayersDead = true; AllPlayersDeadClientRpc(); } } [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); } } } [ServerRpc(RequireOwnership = false)] public void PermaDeadPlayerServerRpc(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) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2091644702u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerid); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2091644702u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!PermaDeadPlayers.Contains(playerid)) { PermaDeadPlayers.Add(playerid); LCAutoRevive.Logger.LogDebug((object)$"Player {playerid} added to the permanently dead players list."); } CheckIfAllPlayersDead(onPlayerDC: false); } } public void DisconnectPermaDeadPlayer(int playerid) { if (PermaDeadPlayers.Contains(playerid)) { bool flag = PermaDeadPlayers.Remove(playerid); LCAutoRevive.Logger.LogInfo((object)$"Player {playerid} removed from list? {flag}"); CheckIfAllPlayersDead(onPlayerDC: false); } else { CheckIfAllPlayersDead(onPlayerDC: true); } } [ClientRpc] public void AllPlayersDeadClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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(3770377985u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3770377985u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; allPlayersDead = true; StartOfRound.Instance.ShipLeaveAutomatically(false); } } } 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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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).__registerRpc(2091644702u, new RpcReceiveHandler(__rpc_handler_2091644702), "PermaDeadPlayerServerRpc"); ((NetworkBehaviour)this).__registerRpc(3770377985u, new RpcReceiveHandler(__rpc_handler_3770377985), "AllPlayersDeadClientRpc"); ((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; } } private static void __rpc_handler_2091644702(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).PermaDeadPlayerServerRpc(playerid); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3770377985(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NetworkHandler)(object)target).AllPlayersDeadClientRpc(); 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 System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace Tomatobird.AutoRevive.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }