using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("deathCurse")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+80df40e25ed7bef3eef2149b97b7d92bc0a4753d")]
[assembly: AssemblyProduct("deathCurse")]
[assembly: AssemblyTitle("deathCurse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace StatueCurseMod
{
[BepInPlugin("deathCurse", "deathCurse", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
private Harmony _harmony;
public const string Id = "deathCurse";
internal static ManualLogSource Log { get; private set; }
internal static ConfigEntry<bool> CurseOnStatue { get; private set; }
internal static ConfigEntry<bool> CurseOnDeath { get; private set; }
internal static ConfigEntry<float> CurseAmount { get; private set; }
public static string Name => "deathCurse";
public static string Version => "0.1.0";
private void Awake()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
CurseOnStatue = ((BaseUnityPlugin)this).Config.Bind<bool>("Statue", "Enabled", false, "When true, all players receive curse when an Ancient Statue revives players.");
CurseOnDeath = ((BaseUnityPlugin)this).Config.Bind<bool>("Death", "Enabled", true, "When true, all players receive curse whenever any player dies.");
CurseAmount = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CurseAmount", 0.05f, "Curse amount applied per event. For the Ancient Statue this is multiplied by the number of revived players. For death events it is applied directly. For Scout Effigy and Book of Bones revives it is subtracted from all other players. Smallest curse increment in the game is 0.025.");
_harmony = new Harmony("deathCurse");
_harmony.PatchAll();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
}
}
[HarmonyPatch(typeof(RespawnChest), "RespawnAllPlayersHere")]
internal static class RespawnAllPlayersHerePatch
{
internal static bool IsStatueRevive;
[HarmonyPrefix]
private static void Prefix(out int __state)
{
IsStatueRevive = true;
__state = 0;
foreach (Character allCharacter in Character.AllCharacters)
{
if (allCharacter.data.dead || allCharacter.data.fullyPassedOut)
{
__state++;
}
}
}
[HarmonyPostfix]
private static void Postfix(int __state)
{
IsStatueRevive = false;
if (__state <= 0 || !Plugin.CurseOnStatue.Value)
{
return;
}
float num = (float)__state * Plugin.CurseAmount.Value;
Plugin.Log.LogInfo((object)($"Ancient Statue revived {__state} player(s). " + $"Applying {num} curse to all {Character.AllCharacters.Count} player(s)."));
int numStatusTypes = CharacterAfflictions.NumStatusTypes;
int num2 = 5;
foreach (Character allCharacter in Character.AllCharacters)
{
float[] array = new float[numStatusTypes];
array[num2] = num;
((MonoBehaviourPun)allCharacter).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array });
}
}
}
[HarmonyPatch(typeof(Character), "RPCA_Die")]
internal static class DeathCursePatch
{
[HarmonyPostfix]
private static void Postfix(Character __instance)
{
if (!Plugin.CurseOnDeath.Value || !PhotonNetwork.IsMasterClient)
{
return;
}
float value = Plugin.CurseAmount.Value;
Plugin.Log.LogInfo((object)(__instance.characterName + " died. " + $"Applying {value} curse to all {Character.AllCharacters.Count} player(s)."));
int numStatusTypes = CharacterAfflictions.NumStatusTypes;
int num = 5;
foreach (Character allCharacter in Character.AllCharacters)
{
if (!allCharacter.data.dead)
{
float[] array = new float[numStatusTypes];
array[num] = value;
((MonoBehaviourPun)allCharacter).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array });
}
}
}
}
[HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")]
internal static class ReviveAtPositionPatch
{
[HarmonyPostfix]
private static void Postfix(Character __instance)
{
if (!PhotonNetwork.IsMasterClient || RespawnAllPlayersHerePatch.IsStatueRevive)
{
return;
}
float value = Plugin.CurseAmount.Value;
Plugin.Log.LogInfo((object)("Scout Effigy / Book of Bones revived " + __instance.characterName + ". " + $"Removing {value} curse from all other player(s)."));
int numStatusTypes = CharacterAfflictions.NumStatusTypes;
int num = 5;
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)(object)__instance))
{
float[] array = new float[numStatusTypes];
array[num] = 0f - value;
((MonoBehaviourPun)allCharacter).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { array });
}
}
}
}
internal static class EventLogger
{
[HarmonyPatch(typeof(RespawnChest), "SpawnItems")]
internal static class SpawnItemsPatch
{
[HarmonyPrefix]
private static void Prefix(RespawnChest __instance)
{
bool canReviveDead = Ascents.canReviveDead;
bool flag = Character.PlayerIsDeadOrDown();
bool isMasterClient = PhotonNetwork.IsMasterClient;
Plugin.Log.LogInfo((object)($"[SpawnItems] Statue opened. IsMaster={isMasterClient}, " + $"canRevive={canReviveDead}, anyDead={flag}, " + $"IsSpent={__instance.IsSpent}"));
if (isMasterClient && canReviveDead && flag)
{
LogAllPlayers("before revive");
}
}
}
[HarmonyPatch(typeof(Character), "RPCA_Die")]
internal static class DiePatch
{
[HarmonyPostfix]
private static void Postfix(Character __instance)
{
Plugin.Log.LogInfo((object)("[Die] " + __instance.characterName + " died."));
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "RPC_ApplyStatusesFromFloatArray")]
internal static class ApplyStatusesPatch
{
[HarmonyPostfix]
private static void Postfix(CharacterAfflictions __instance, float[] data)
{
int num = 5;
if (num < data.Length && data[num] != 0f)
{
Plugin.Log.LogInfo((object)("[RPC_ApplyStatuses] " + __instance.character.characterName + " " + $"received curse delta={data[num]:F3}, " + $"new curse={__instance.GetCurrentStatus((STATUSTYPE)5):F3}"));
}
}
}
private static string FormatPlayer(Character c)
{
float currentStatus = c.refs.afflictions.GetCurrentStatus((STATUSTYPE)5);
float statusSum = c.refs.afflictions.statusSum;
string text = (c.data.dead ? "DEAD" : (c.data.fullyPassedOut ? "DOWN" : "ALIVE"));
return $"{c.characterName} [{text}] (curse={currentStatus:F3}, total={statusSum:F3})";
}
private static void LogAllPlayers(string context)
{
Plugin.Log.LogInfo((object)("--- Player snapshot (" + context + ") ---"));
foreach (Character allCharacter in Character.AllCharacters)
{
Plugin.Log.LogInfo((object)(" " + FormatPlayer(allCharacter)));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}