using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HuraReviveContinued")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+0200ba96c257e7ed6cdf63af9ecab53d6dec33ff")]
[assembly: AssemblyProduct("HuraReviveContinued")]
[assembly: AssemblyTitle("HuraReviveContinued")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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 Hura
{
internal static class LuggageRevive
{
private static bool IsSupported(Luggage luggage)
{
if ((Object)(object)luggage == (Object)null)
{
return false;
}
Type type = ((object)luggage).GetType();
if (!(type == typeof(Luggage)))
{
return type == typeof(LuggageCursed);
}
return true;
}
[HarmonyPatch(typeof(Luggage), "GetInteractionText")]
[HarmonyPostfix]
internal static void GetInteractionText_Patch(Luggage __instance, ref string __result)
{
if (Settings.ReviveEnabled && IsSupported(__instance) && Ascents.canReviveDead && Character.PlayerIsDeadOrDown())
{
__result = __result + " + " + LocalizedText.GetText("REVIVESCOUTS", true);
}
}
[HarmonyPatch(typeof(Spawner), "SpawnItems", new Type[] { typeof(List<Transform>) })]
[HarmonyPostfix]
internal static void SpawnItems_Patch(Spawner __instance)
{
Luggage luggage = (Luggage)(object)((__instance is Luggage) ? __instance : null);
if (!Settings.ReviveEnabled || !IsSupported(luggage) || !PhotonNetwork.IsMasterClient)
{
return;
}
if (!Ascents.canReviveDead)
{
Mod.ModLogger.LogInfo((object)"Luggage revive skipped: revival is disabled by the run settings.");
return;
}
try
{
RespawnAllPlayersAtLuggage(luggage);
}
catch (Exception ex)
{
Mod.ModLogger.LogError((object)("Luggage revive failed: " + ex));
}
}
private static void RespawnAllPlayersAtLuggage(Luggage luggage)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)luggage).transform.position + ((Component)luggage).transform.up * 2f;
int num = 0;
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && (allCharacter.data.dead || allCharacter.data.fullyPassedOut))
{
PhotonView photonView = ((MonoBehaviourPun)allCharacter).photonView;
if ((Object)(object)photonView == (Object)null)
{
Mod.ModLogger.LogWarning((object)"Skipped an unconscious/dead character without a PhotonView.");
continue;
}
photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
{
val,
Settings.ReviveWithMalus,
-1
});
num++;
}
}
Mod.ModLogger.LogInfo((object)("Luggage opened: requested revival for " + num + " player(s); applyStatus=" + Settings.ReviveWithMalus + "."));
}
}
[BepInPlugin("Peak.Hura.Revive", "Hura Revive Continued", "1.1.0")]
public sealed class Mod : BaseUnityPlugin
{
public const string GUID = "Peak.Hura.Revive";
public const string NAME = "Hura Revive Continued";
public const string VERSION = "1.1.0";
private Harmony harmony;
public static Mod Instance { get; private set; }
internal static ManualLogSource ModLogger => ((BaseUnityPlugin)Instance).Logger;
private void Awake()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
Instance = this;
try
{
Settings.Bind(this);
if (AccessTools.Method(typeof(Character), "RPCA_ReviveAtPosition", new Type[3]
{
typeof(Vector3),
typeof(bool),
typeof(int)
}, (Type[])null) == null)
{
throw new MissingMethodException("Expected RPCA_ReviveAtPosition(Vector3, bool, int).");
}
harmony = new Harmony("Peak.Hura.Revive");
harmony.PatchAll(typeof(LuggageRevive));
((BaseUnityPlugin)this).Logger.LogInfo((object)("Hura Revive Continued 1.1.0 ready: current dead property and three-argument revive RPC. Enable Revive=" + Settings.ReviveEnabled + "; Revive With Malus=" + Settings.ReviveWithMalus + "."));
}
catch (Exception ex)
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
((BaseUnityPlugin)this).Logger.LogError((object)("Initialization failed; luggage revive is disabled: " + ex));
}
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
}
internal static class Settings
{
private static ConfigEntry<bool> enableRevive;
private static ConfigEntry<bool> reviveWithMalus;
internal static bool ReviveEnabled => enableRevive.Value;
internal static bool ReviveWithMalus => reviveWithMalus.Value;
internal static void Bind(Mod mod)
{
enableRevive = ((BaseUnityPlugin)mod).Config.Bind<bool>("General", "Enable Revive", true, "When enabled, player will revive when a case is opened.");
reviveWithMalus = ((BaseUnityPlugin)mod).Config.Bind<bool>("General", "Revive With Malus", true, "When enabled, player will revive with the usual revive malus (hunger + curse).");
}
}
}