using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[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: IgnoresAccessChecksTo("0Harmony")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("LethalConfig")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: AssemblyCompany("PlayerRevive")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Revives a dead player when they are in the ship")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerRevive")]
[assembly: AssemblyTitle("PlayerRevive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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 PlayerRevive
{
[BepInPlugin("PlayerRevive", "PlayerRevive", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource LOGGER;
public static Plugin Instance { get; private set; }
public Harmony Harmony { get; private set; }
public ConfigEntry<int> ReviveTimeSeconds { get; private set; }
public ConfigEntry<int> ReviveHealth { get; private set; }
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00b3: 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_00bf: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin PlayerRevive is loaded!");
Instance = this;
LOGGER = ((BaseUnityPlugin)this).Logger;
Harmony = new Harmony("PlayerRevive");
ReviveTimeSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Time for Revive", 60, "The Time(seconds) it takes for the body to be revived from the time it is collected");
ConfigEntry<int> reviveTimeSeconds = ReviveTimeSeconds;
IntSliderOptions val = new IntSliderOptions();
((BaseRangeOptions<int>)val).Min = 0;
((BaseRangeOptions<int>)val).Max = 600;
((BaseOptions)val).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(reviveTimeSeconds, val));
ReviveHealth = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Revive Health", 100, "The health amount when be revived");
ConfigEntry<int> reviveHealth = ReviveHealth;
IntSliderOptions val2 = new IntSliderOptions();
((BaseRangeOptions<int>)val2).Min = 1;
((BaseRangeOptions<int>)val2).Max = 100;
((BaseOptions)val2).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(reviveHealth, val2));
try
{
Harmony.PatchAll(typeof(ReviveSystem));
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to patch Revive System: '" + ex.Message + "'\n" + ex.StackTrace));
}
}
}
internal class RevivePlayerInfo
{
public PlayerControllerB Player { get; }
public RevivePlayerInfo(PlayerControllerB player)
{
Player = player;
}
private int GetPlayerIndex()
{
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null)
{
throw new NullReferenceException("Start of round is null");
}
for (int i = 0; i < instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val = instance.allPlayerScripts[i];
if (val.actualClientId == Player.actualClientId && (val.actualClientId != 0L || val.isHostPlayerObject))
{
return i;
}
}
throw new ArgumentException("Unknown Player Index: " + (object)Player);
}
public void Revive()
{
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
{
return;
}
int playerIndex = GetPlayerIndex();
if (((NetworkBehaviour)RoundManager.Instance).IsServer)
{
NetworkObject component = ((Component)Player.deadBody).gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null && component.IsSpawned)
{
component.Despawn(true);
}
else
{
Object.Destroy((Object)(object)((Component)Player.deadBody).gameObject);
}
}
Player.isClimbingLadder = false;
Player.ResetZAndXRotation();
((Collider)Player.thisController).enabled = true;
Player.disableLookInput = false;
Player.isPlayerDead = false;
Player.isPlayerControlled = true;
Player.isInElevator = true;
Player.isInHangarShipRoom = true;
Player.isInsideFactory = false;
Player.wasInElevatorLastFrame = false;
instance.SetPlayerObjectExtrapolate(false);
Player.TeleportPlayer(instance.GetPlayerSpawnPosition(playerIndex, false), false, 0f, false, true);
Player.setPositionOfDeadPlayer = false;
Player.DisablePlayerModel(instance.allPlayerObjects[playerIndex], true, true);
((Behaviour)Player.helmetLight).enabled = false;
Player.Crouch(false);
Animator playerBodyAnimator = Player.playerBodyAnimator;
if (playerBodyAnimator != null)
{
playerBodyAnimator.SetBool("Limp", false);
}
Player.bleedingHeavily = false;
Player.criticallyInjured = false;
Player.activatingItem = false;
Player.twoHanded = false;
Player.inSpecialInteractAnimation = false;
Player.disableSyncInAnimation = false;
Player.inAnimationWithEnemy = null;
Player.holdingWalkieTalkie = false;
Player.speakingToWalkieTalkie = false;
Player.isSinking = false;
Player.isUnderwater = false;
Player.sinkingValue = 0f;
Player.statusEffectAudio.Stop();
Player.DisableJetpackControlsLocally();
Player.health = Plugin.Instance.ReviveHealth.Value;
Player.mapRadarDotAnimator.SetBool("dead", false);
instance.livingPlayers++;
instance.allPlayersDead = false;
((Renderer)Player.thisPlayerModel).enabled = true;
if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)Player)
{
HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
Player.hasBegunSpectating = false;
HUDManager.Instance.RemoveSpectateUI();
HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
Player.hinderedMultiplier = 1f;
Player.isMovementHindered = 0;
Player.sourcesCausingSinking = 0;
Player.reverbPreset = instance.shipReverb;
HUDManager.Instance.UpdateHealthUI(Plugin.Instance.ReviveHealth.Value, false);
Player.spectatedPlayerScript = null;
((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
instance.SetSpectateCameraToGameOverMode(false, Player);
TimeOfDay.Instance.DisableAllWeather(false);
instance.UpdatePlayerVoiceEffects();
HUDManager.Instance.HideHUD(false);
}
else
{
((Renderer)Player.thisPlayerModelLOD1).enabled = true;
((Renderer)Player.thisPlayerModelLOD2).enabled = true;
}
SoundManager.Instance.earsRingingTimer = 0f;
Player.voiceMuffledByEnemy = false;
SoundManager.Instance.playerVoicePitchTargets[playerIndex] = 1f;
SoundManager.Instance.SetPlayerPitch(1f, playerIndex);
if ((Object)(object)Player.currentVoiceChatIngameSettings == (Object)null)
{
StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
}
if ((Object)(object)Player.currentVoiceChatIngameSettings != (Object)null)
{
if ((Object)(object)Player.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
{
Player.currentVoiceChatIngameSettings.InitializeComponents();
}
if (!((Object)(object)Player.currentVoiceChatIngameSettings.voiceAudio == (Object)null))
{
((Component)Player.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
}
}
}
}
internal static class ReviveSystem
{
private static Dictionary<ulong, float> Timer = new Dictionary<ulong, float>();
[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
[HarmonyPrefix]
private static void Reset()
{
Timer.Clear();
}
[HarmonyPatch(typeof(StartOfRound), "Update")]
[HarmonyPrefix]
private static void Update()
{
StartOfRound instance = StartOfRound.Instance;
if (!instance.shipHasLanded || instance.inShipPhase || instance.allPlayerScripts.Length == 0)
{
return;
}
PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (!val.isPlayerDead)
{
continue;
}
if (val.deadBody.isInShip && (!val.deadBody.grabBodyObject.isHeld || (Object)(object)val.deadBody.grabBodyObject.playerHeldBy == (Object)null))
{
if (!Timer.ContainsKey(val.actualClientId))
{
Timer[val.actualClientId] = 0f;
}
if (Timer[val.actualClientId] < (float)Plugin.Instance.ReviveTimeSeconds.Value)
{
Timer[val.actualClientId] += Time.deltaTime;
continue;
}
Plugin.LOGGER.LogInfo((object)("Player '" + ((Object)val).name + "' is being revived!"));
Timer.Remove(val.actualClientId);
new RevivePlayerInfo(val).Revive();
}
else
{
Timer.Remove(val.actualClientId);
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PlayerRevive";
public const string PLUGIN_NAME = "PlayerRevive";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}