Decompiled source of NoExistentialCrisis v1.0.0

plugins/NoExistentialCrisis/NoExistentialCrisis.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NoExistentialCrisis")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e8f79f4ef2de278ca8fc32fd1929320b5c3e8e32")]
[assembly: AssemblyProduct("NoExistentialCrisis")]
[assembly: AssemblyTitle("NoExistentialCrisis")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 NoExistentialCrisis
{
	[BepInPlugin("InfernoDragon0.cotl.NoExistentialCrisis", "NoExistentialCrisis", "1.0.0")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "InfernoDragon0.cotl.NoExistentialCrisis";

		public const string PluginName = "NoExistentialCrisis";

		public const string PluginVer = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("InfernoDragon0.cotl.NoExistentialCrisis");

		internal static string PluginPath;

		internal static ConfigEntry<float> cursedChance;

		internal static ConfigEntry<float> crisisChance;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			cursedChance = ((BaseUnityPlugin)this).Config.Bind<float>("NoExistentialCrisis", "CursedChance", 0f, "Chance for the follower to be cursed upon resurrection. 0.0 for never, 1.0 for always.");
			crisisChance = ((BaseUnityPlugin)this).Config.Bind<float>("NoExistentialCrisis", "CrisisChance", 0f, "Chance for the follower to have an existential crisis upon resurrection. 0.0 for never, 1.0 for always.");
		}

		private void OnEnable()
		{
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded NoExistentialCrisis!");
		}

		private void OnDisable()
		{
			Harmony.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Unloaded NoExistentialCrisis!");
		}
	}
}
namespace NoExistentialCrisis.Patches
{
	[HarmonyPatch]
	internal class CrisisAvertedPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> RitualRessurect_DoRessurectRoutine(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Bge_Un, (object)null, (string)null)
			}).Advance(1).SetOperandAndAdvance((object)Plugin.cursedChance.Value)
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Bge_Un, (object)null, (string)null)
				})
				.Advance(1)
				.SetOperandAndAdvance((object)Plugin.crisisChance.Value)
				.InstructionEnumeration();
		}
	}
}