using System;
using System.Collections;
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.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour.HookGen;
using On;
using UnityEngine;
using Zorro.Core;
[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("ElectricSteve.surfacediefix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SurfaceDieFix")]
[assembly: AssemblyTitle("ElectricSteve.surfacediefix")]
[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.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 SurfaceDieFix
{
public class Patches
{
[CompilerGenerated]
private static class <>O
{
public static hook_CheckForAllDead <0>__PhotonGameLobbyHandlerOnCheckForAllDead;
public static hook_RPCA_PlayerDie <1>__PlayerOnRPCA_PlayerDie;
}
internal static void Init()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
object obj = <>O.<0>__PhotonGameLobbyHandlerOnCheckForAllDead;
if (obj == null)
{
hook_CheckForAllDead val = PhotonGameLobbyHandlerOnCheckForAllDead;
<>O.<0>__PhotonGameLobbyHandlerOnCheckForAllDead = val;
obj = (object)val;
}
PhotonGameLobbyHandler.CheckForAllDead += (hook_CheckForAllDead)obj;
object obj2 = <>O.<1>__PlayerOnRPCA_PlayerDie;
if (obj2 == null)
{
hook_RPCA_PlayerDie val2 = PlayerOnRPCA_PlayerDie;
<>O.<1>__PlayerOnRPCA_PlayerDie = val2;
obj2 = (object)val2;
}
Player.RPCA_PlayerDie += (hook_RPCA_PlayerDie)obj2;
}
private static void PlayerOnRPCA_PlayerDie(orig_RPCA_PlayerDie orig, Player self)
{
orig.Invoke(self);
if (PhotonGameLobbyHandler.IsSurface && self.refs.view.IsMine)
{
((MonoBehaviour)SurfaceDieFix.Instance).StartCoroutine(WaitAndRevive(2f));
}
}
private static void PhotonGameLobbyHandlerOnCheckForAllDead(orig_CheckForAllDead orig, PhotonGameLobbyHandler self)
{
if (PhotonGameLobbyHandler.IsSurface)
{
SurfaceDieFix.Logger.LogDebug((object)"Not checking for all dead, is surface. Returning...");
}
else
{
orig.Invoke(self);
}
}
private static IEnumerator WaitAndRevive(float waitTime)
{
yield return (object)new WaitForSeconds(waitTime);
RetrievableResourceSingleton<TransitionHandler>.Instance.TransitionToBlack(0f, (Action)delegate
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
Player.localPlayer.Teleport(((Component)Hospital.instance).transform.position, Vector3.back);
Player.localPlayer.data.fallTime = 0f;
RetrievableResourceSingleton<TransitionHandler>.Instance.FadeOut((Action)delegate
{
}, 1f);
}, 0f);
yield return (object)new WaitForSeconds(1f);
SurfaceDieFix.Logger.LogDebug((object)"Reviving player...");
Player.localPlayer.CallRevive();
SurfaceDieFix.Logger.LogDebug((object)"Healing player...");
float healAmount = PlayerData.maxHealth - Player.localPlayer.data.health;
Player.localPlayer.CallHeal(healAmount);
}
}
[ContentWarningPlugin("ElectricSteve.surfacediefix", "1.0.0", false)]
[BepInPlugin("ElectricSteve.surfacediefix", "SurfaceDieFix", "1.0.0")]
public class SurfaceDieFix : BaseUnityPlugin
{
public static SurfaceDieFix Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Logger.LogDebug((object)"Hooking...");
Patches.Init();
Logger.LogDebug((object)"Finished Hooking!");
Logger.LogInfo((object)"ElectricSteve.surfacediefix v1.0.0 has loaded!");
}
private void OnDestroy()
{
Logger.LogDebug((object)"Unhooking...");
HookEndpointManager.RemoveAllOwnedBy((object)Assembly.GetExecutingAssembly());
Logger.LogDebug((object)"Finished Unhooking!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ElectricSteve.surfacediefix";
public const string PLUGIN_NAME = "SurfaceDieFix";
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)
{
}
}
}