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 GlobalEnums;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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("com.blueraja.rosaries_never_permanently_lost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+f83cd5b0175296b8a399eb484cbdf5479f6085c6")]
[assembly: AssemblyProduct("Rosaries Never Permanently Lost")]
[assembly: AssemblyTitle("com.blueraja.rosaries_never_permanently_lost")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace rosaries_never_permanently_lost
{
[BepInPlugin("com.blueraja.rosaries_never_permanently_lost", "Rosaries Never Permanently Lost", "1.1.0")]
[BepInProcess("Hollow Knight Silksong.exe")]
public class Plugin : BaseUnityPlugin
{
private static ConfigEntry<float> _onDeathCocoonMultiplier;
private static ConfigEntry<bool> _cocoonShouldStayInPlace;
private static string _lastHeroCorpseScene;
private static int _lastHeroCorpseMoneyPool;
private static byte[] _lastHeroCorpseMarkerGuid;
private static HeroDeathCocoonTypes _lastHeroCorpseType;
private static ManualLogSource Logger;
private void Awake()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
_onDeathCocoonMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cheats", "OnDeathCocoonMultiplier", 1f, new ConfigDescription("What percentage of rosaries should be kept in the cocoon each time you die. For instance, if this is set to 0.75 and the cocoon from your previous death(s) has 1000 rosaries, then if you die another time, the cocoon will have 750 rosaries + whatever you were holding", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
_cocoonShouldStayInPlace = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "CocoonShouldStayInPlace", true, "If set to true, the cocoon will stay in the same place until it's collected, no matter how many times you die. If false, the cocoon moves to your last death location each time you die.");
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin com.blueraja.rosaries_never_permanently_lost is loaded!");
}
[HarmonyPatch(typeof(HeroController), "Die")]
[HarmonyPrefix]
private static void DiePrefix(HeroController __instance)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
_lastHeroCorpseScene = __instance.playerData.HeroCorpseScene;
_lastHeroCorpseMoneyPool = __instance.playerData.HeroCorpseMoneyPool;
_lastHeroCorpseMarkerGuid = __instance.playerData.HeroCorpseMarkerGuid;
_lastHeroCorpseType = __instance.playerData.HeroCorpseType;
}
[HarmonyPatch(typeof(GameManager), "PlayerDead")]
[HarmonyPrefix]
private static void PlayerDeadPrefix(GameManager __instance)
{
//IL_0046: 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_0050: 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)
if (_cocoonShouldStayInPlace.Value && _lastHeroCorpseMarkerGuid != null && !string.IsNullOrEmpty(_lastHeroCorpseScene))
{
__instance.playerData.HeroCorpseScene = _lastHeroCorpseScene;
__instance.playerData.HeroCorpseMarkerGuid = _lastHeroCorpseMarkerGuid;
PlayerData playerData = __instance.playerData;
playerData.HeroCorpseType |= _lastHeroCorpseType;
}
PlayerData playerData2 = __instance.playerData;
playerData2.HeroCorpseMoneyPool += (int)Math.Round((float)_lastHeroCorpseMoneyPool * _onDeathCocoonMultiplier.Value);
Logger.LogInfo((object)$"Death cocoon now holds {__instance.playerData.HeroCorpseMoneyPool} rosaries");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.blueraja.rosaries_never_permanently_lost";
public const string PLUGIN_NAME = "Rosaries Never Permanently Lost";
public const string PLUGIN_VERSION = "1.1.0";
}
}