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.4.2
Tomatobird.AutoRevive.dll
Decompiled a week 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tomatobird.AutoRevive")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.4.2.0")] [assembly: AssemblyInformationalVersion("0.4.2+5781fd83927d489a13ce6ffe707d62620b729918")] [assembly: AssemblyProduct("LCAutoRevive")] [assembly: AssemblyTitle("Tomatobird.AutoRevive")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LCAutoRevive { [BepInPlugin("Tomatobird.AutoRevive", "LCAutoRevive", "0.4.2")] [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; internal static string replacementSymbol = "$"; internal static string reviveTimerText = "Reviving... $"; internal static string waitingForInputText = "Press $ to revive"; internal static string revivingNowText = "Reviving now"; internal static string revivesLeftText = "Revives left: $"; internal static string outOfRevivesText = "Out of revives"; public static LCAutoRevive Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; 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? Only works when LethalCompanyInputUtils is installed.").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>("UI", "FontSize", 24f, "Size of the revive timer text.").Value; replacementSymbol = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "ReplacementSymbol", "$", "Which symbol should be replaced with a variable provided for the text?").Value; reviveTimerText = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "ReviveTimerText", "Reviving... $", "Text for the revive timer. The variable is a timer which displays seconds left until revive.").Value; waitingForInputText = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "WaitingForInputText", "Press $ to revive", "Text for waiting for input to revive. The variable is a string that represents the key needed to press to revive.").Value; revivingNowText = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "RevivingNowText", "Reviving now", "Text for reviving now.").Value; revivesLeftText = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "RevivesLeftText", "Revives left: $", "Text for how many revives are left. The variable is the amount of revives left.").Value; outOfRevivesText = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "OutOfRevivesText", "Out of revives", "Text displayed when you have no revives left.").Value; Patch(); Logger.LogInfo((object)"Tomatobird.AutoRevive v0.4.2 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.4.2"; } } namespace LCAutoRevive.Utils { internal class HUDHandler : MonoBehaviour { 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(LCAutoRevive.outOfRevivesText, 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()); } } private IEnumerator WaitForPlayerRevival() { isRunning = true; float timeLeft = ((LCAutoRevive.reviveDelayPenalty >= 0f) ? (LCAutoRevive.reviveDelay + LCAutoRevive.reviveDelayPenalty * (float)reviveCount) : LCAutoRevive.reviveDelay); float interval = 0.1f; while (timeLeft >= 0f) { yield return (object)new WaitForEndOfFrame(); if (interval > 0f) { interval -= Time.deltaTime; continue; } if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase) { ((TMP_Text)text).text = EditText("", showRevives: false); isRunning = false; reviveCount = 0; yield break; } interval = 0.1f; timeLeft -= 0.1f + (interval - 0.1f) + Time.deltaTime; ((TMP_Text)text).text = EditText(LCAutoRevive.reviveTimerText, showRevives: true, Mathf.CeilToInt(timeLeft).ToString()); } canRevive = true; if (InputUtilsCompat.Enabled && InputUtilsCompat.ReviveKey != null && LCAutoRevive.waitForInput) { ((TMP_Text)text).text = EditText(LCAutoRevive.waitingForInputText, showRevives: true, InputUtilsCompat.ReviveKey.controls[0].displayName); } else { ((TMP_Text)text).text = EditText(LCAutoRevive.revivingNowText, showRevives: true); if (!StartOfRound.Instance.shipIsLeaving && !StartOfRound.Instance.inShipPhase) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB player in allPlayerScripts) { if ((Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController && player.isPlayerDead) { NetworkHandler.Instance.RevivePlayerServerRpc((int)player.playerClientId); canRevive = false; reviveCount++; break; } } } } isRunning = false; } internal string EditText(string s, bool showRevives, string value = "") { string text = s; text = text.Replace(LCAutoRevive.replacementSymbol, value); if (LCAutoRevive.reviveLimit > reviveCount && showRevives) { text = text + "\n" + LCAutoRevive.revivesLeftText.Replace(LCAutoRevive.replacementSymbol, (LCAutoRevive.reviveLimit - reviveCount).ToString()); } 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: 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_00d7; } } 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_00d7; IL_00d7: 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; } } CadaverGrowthAI[] array = Object.FindObjectsOfType<CadaverGrowthAI>(); for (int i = 0; i < array.Length; i++) { if (array[i].playerInfections[playerId] == null) { continue; } array[i].playerInfections[playerId].infectionMeter = 0f; array[i].playerInfections[playerId].burstMeter = 0f; array[i].playerInfections[playerId].infected = false; array[i].playerInfections[playerId].severe = false; array[i].playerInfections[playerId].emittingSpores = false; StartOfRound.Instance.allPlayerScripts[playerId].overridePoisonValue = false; if (array[i].playerInfections[playerId].backFlowerRenderers == null) { continue; } for (int j = 0; j < array[i].playerInfections[playerId].backFlowerRenderers.Length; j++) { if ((Object)(object)array[i].playerInfections[playerId].backFlowerRenderers[j] != (Object)null) { ((Renderer)array[i].playerInfections[playerId].backFlowerRenderers[j]).enabled = false; } } if ((Object)(object)array[i].playerInfections[playerId].backFlowersScanNode != (Object)null) { array[i].playerInfections[playerId].backFlowersScanNode.SetActive(false); } } RagdollGrabbableObject[] array2 = Object.FindObjectsOfType<RagdollGrabbableObject>(); for (int k = 0; k < array2.Length; k++) { if (array2[k].bodyID != playerId) { continue; } if (!((GrabbableObject)array2[k]).isHeld) { if (((NetworkBehaviour)StartOfRound.Instance).IsServer) { if (((NetworkBehaviour)array2[k]).NetworkObject.IsSpawned) { ((NetworkBehaviour)array2[k]).NetworkObject.Despawn(true); } else { Object.Destroy((Object)(object)((Component)array2[k]).gameObject); } break; } } else { if (!((GrabbableObject)array2[k]).isHeld || !((Object)(object)((GrabbableObject)array2[k]).playerHeldBy != (Object)null)) { continue; } ((GrabbableObject)array2[k]).playerHeldBy.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3)); if (((NetworkBehaviour)StartOfRound.Instance).IsServer) { if (((NetworkBehaviour)array2[k]).NetworkObject.IsSpawned) { ((NetworkBehaviour)array2[k]).NetworkObject.Despawn(true); } else { Object.Destroy((Object)(object)((Component)array2[k]).gameObject); } break; } } } DeadBodyInfo[] array3 = Object.FindObjectsOfType<DeadBodyInfo>(true); for (int l = 0; l < array3.Length; l++) { if (array3[l].playerObjectId == playerId) { Object.Destroy((Object)(object)((Component)array3[l]).gameObject); break; } } if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { HUDManager.Instance.UpdateBoxesSpectateUI(); } 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 Start_Postfix() { NetworkHandler.CreateAndRegisterPrefab(); } [HarmonyPatch("Disconnect")] [HarmonyPostfix] private static void Disconnect_Postfix() { NetworkHandler.DespawnNetworkHandler(); } } [HarmonyPatch(typeof(HUDManager))] internal class HUDPatcher { [HarmonyPatch("Start")] [HarmonyPostfix] internal static void Start_Postfix(HUDManager __instance) { ((Component)__instance.gameOverAnimator).gameObject.AddComponent<HUDHandler>(); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatcher { [HarmonyPatch("KillPlayer")] [HarmonyPostfix] internal static void KillPlayer_Postfix(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 ShipLeaveAutomatically_Prefix(StartOfRound __instance, bool leavingOnMidnight) { LCAutoRevive.Logger.LogDebug((object)$"leavingOnMidnight: {leavingOnMidnight} AllPlayersPermaDead(): {NetworkHandler.Instance.AllPlayersPermaDead()} StartOfRound.Instance.allPlayersDead: {__instance.allPlayersDead}"); if (!LCAutoRevive.preventShipLeave || NetworkHandler.Instance.AllPlayersPermaDead()) { return true; } if (!leavingOnMidnight) { LCAutoRevive.Logger.LogDebug((object)"Setting allPlayersDead to false."); __instance.allPlayersDead = false; return false; } return true; } [HarmonyPatch("OnPlayerDC")] [HarmonyPostfix] internal static void OnPlayerDC_PostFix(StartOfRound __instance, int playerObjectNumber, ulong clientId) { if (__instance.allPlayerObjects[playerObjectNumber].GetComponent<PlayerControllerB>().disconnectedMidGame && ((NetworkBehaviour)__instance).IsServer) { NetworkHandler.Instance.DisconnectPermaDeadPlayer((int)clientId); } } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] internal static void ReviveDeadPlayers_Postfix() { 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 ShipLeave_Postfix(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) { LCAutoRevive.Logger.LogDebug((object)$"onPlayerDC: {onPlayerDC} permaDeadPlayers.Count: {PermaDeadPlayers.Count} connectedPlayers: {GameNetworkManager.Instance.connectedPlayers}"); if (GetPermaDeadPlayerCount(onPlayerDC) >= (onPlayerDC ? (GameNetworkManager.Instance.connectedPlayers + 1) : GameNetworkManager.Instance.connectedPlayers) && !allPlayersDead) { allPlayersDead = true; AllPlayersDeadClientRpc(); } } [Rpc(/*Could not decode attribute arguments.*/)] 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3047310335u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerid); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3047310335u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; RevivePlayerClientRpc(playerid); } } } [Rpc(/*Could not decode attribute arguments.*/)] 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(632973755u, val3, val, (SendTo)6, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerid); ((NetworkBehaviour)this).__endSendRpc(ref val2, 632973755u, val3, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; RevivePlayer.ReiveDeadPlayer(playerid); } } } [Rpc(/*Could not decode attribute arguments.*/)] 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2091644702u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerid); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2091644702u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { 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); } } [Rpc(/*Could not decode attribute arguments.*/)] 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3770377985u, val3, val, (SendTo)6, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3770377985u, val3, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; allPlayersDead = true; StartOfRound.Instance.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 { } }