Decompiled source of Eternal Torment v1.2.0

EternalTorment.dll

Decompiled 2 weeks ago
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 GlobalSettings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EternalTorment")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("EternalTorment")]
[assembly: AssemblyTitle("EternalTorment")]
[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 EternalTorment
{
	[BepInPlugin("io.github.eternaltorment", "Eternal Torment", "1.2.0")]
	public class EternalTormentPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static ConfigEntry<bool> rosaryPreservation;

		public static ConfigEntry<bool> shardsRecycling;

		public static int Money;

		public const string Id = "io.github.eternaltorment";

		public static string Name => "Eternal Torment";

		public static string Version => "1.2.0";

		private void Awake()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			rosaryPreservation = ((BaseUnityPlugin)this).Config.Bind<bool>(Name, "Rosary Preservation", false, "Keep part of your rosaries on death. % based on your max health.");
			shardsRecycling = ((BaseUnityPlugin)this).Config.Bind<bool>(Name, "Shards Recycling", false, "Gain shards when breaking your cocoon. 5 times your max health.");
			Harmony val = new Harmony("io.github.eternaltorment");
			val.PatchAll();
		}
	}
	[HarmonyPatch(typeof(PlayerData), "TakeHealth")]
	internal class TakeHealth_Patch
	{
		private static void Prefix(ref int amount)
		{
			amount = 999;
			EternalTormentPlugin.Logger.LogInfo((object)"Torment is eternal");
		}
	}
	[HarmonyPatch(typeof(HeroController), "CocoonBroken", new Type[]
	{
		typeof(bool),
		typeof(bool)
	})]
	internal class CocoonBroken_Patch
	{
		private static void Prefix(HeroController __instance)
		{
			int heroCorpseMoneyPool = __instance.playerData.HeroCorpseMoneyPool;
			EternalTormentPlugin.Logger.LogInfo((object)$"Cocoon has {heroCorpseMoneyPool} rosaries.");
			if (EternalTormentPlugin.shardsRecycling.Value)
			{
				int num = __instance.playerData.maxHealth * 5;
				CurrencyManager.AddCurrency(num, (CurrencyType)1, true);
				EternalTormentPlugin.Logger.LogInfo((object)$"Cocoon has {num} shards.");
			}
		}
	}
	[HarmonyPatch(typeof(HeroController), "Die")]
	internal class Die_Patch
	{
		private static void Prefix(HeroController __instance)
		{
			EternalTormentPlugin.Money = __instance.playerData.geo;
			EternalTormentPlugin.Logger.LogInfo((object)$"Money is {EternalTormentPlugin.Money}.");
		}
	}
	[HarmonyPatch(typeof(HeroController), "Respawn")]
	internal class Respawn_Patch
	{
		private static void Prefix(HeroController __instance)
		{
			if (__instance.cState.dead && EternalTormentPlugin.rosaryPreservation.Value)
			{
				int money = EternalTormentPlugin.Money;
				int num = __instance.playerData.maxHealth;
				if (((ToolBase)Gameplay.DeadPurseTool).IsEquipped)
				{
					num = 10;
				}
				int num2 = Mathf.RoundToInt((float)money * (float)num / 10f);
				money -= num2;
				__instance.playerData.geo = num2;
				__instance.playerData.HeroCorpseMoneyPool = Mathf.RoundToInt((float)money);
				EternalTormentPlugin.Logger.LogInfo((object)$"Kept {num2} rosaries.");
			}
		}
	}
}