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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("RebirthOfPurity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c210a9d0a9678498e40ae52795188609435734d6")]
[assembly: AssemblyProduct("RebirthOfPurity")]
[assembly: AssemblyTitle("RebirthOfPurity")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RebirthOfPurity;
[BepInPlugin("com.github.system233.rebirthofpurity", "Rebirth Of Purity", "1.0.0")]
public class RebirthOfPurity : BaseUnityPlugin
{
public static ConfigEntry<bool> EnablePurification;
public static ConfigEntry<float> SleepPurificationRate;
private static ManualLogSource logger = Logger.CreateLogSource("RebirthOfPurity");
private static readonly Harmony harmony = new Harmony("com.github.system233.rebirthofpurity");
private void Awake()
{
EnablePurification = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Enable Purification", true, "Enable or disable corruption cleansing effects.");
SleepPurificationRate = ((BaseUnityPlugin)this).Config.Bind<float>("", "Sleep Purification Rate", 100f, "Amount of corruption reduced per unit of in-game sleep time.");
harmony.PatchAll();
logger = Logger.CreateLogSource("Rebirth Of Purity");
logger.LogInfo((object)"loaded");
}
public static void LogInfo(params object[] args)
{
ManualLogSource val = logger;
if (val != null)
{
val.LogDebug((object)string.Join(",", args));
}
}
}
[HarmonyPatch(typeof(Character), "SendResurrect")]
internal class Patch_Character_SendResurrect
{
private static void Postfix(Character __instance)
{
if (RebirthOfPurity.EnablePurification.Value)
{
__instance.PlayerStats.m_corruptionLevel = 0f;
}
}
}
[HarmonyPatch(typeof(PlayerCharacterStats), "UpdateNeeds")]
internal class Patch_PlayerCharacterStats_UpdateNeeds
{
private static void Postfix(PlayerCharacterStats __instance, object[] __args)
{
if (RebirthOfPurity.EnablePurification.Value)
{
float num = (float)__args[0];
__instance.m_corruptionLevel = Mathf.Clamp(__instance.m_corruptionLevel - num * RebirthOfPurity.SleepPurificationRate.Value, 0f, __instance.MaxCorruption);
}
}
}