Decompiled source of PermaDeath v1.0.4

GeckVolantMarin-PermaDeath.dll

Decompiled 4 days ago
using System;
using System.Collections;
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.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
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("GeckVolantMarin-PermaDeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GeckVolantMarin-PermaDeath")]
[assembly: AssemblyTitle("GeckVolantMarin-PermaDeath")]
[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 GeckVolantMarin
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GeckVolantMarin-PermaDeath";

		public const string PLUGIN_NAME = "GeckVolantMarin-PermaDeath";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace PermaDeath
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GeckVolantMarin-PermaDeath";

		public const string PLUGIN_NAME = "GeckVolantMarin-PermaDeath";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("GeckVolantMarin-PermaDeath", "GeckVolantMarin-PermaDeath", "1.0.0")]
	[BepInProcess("Inscryption.exe")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static string directory;

		private readonly Harmony HarmonyInstance = new Harmony("GeckVolantMarin-PermaDeath");

		private static AscensionChallengeInfo permaDeathChallenge;

		private static AscensionChallengeInfo permaDeathChallenge2;

		[HarmonyPatch(typeof(PlayableCard), "Die")]
		[HarmonyPrefix]
		private static bool PermaDeathPatch(PlayableCard __instance, bool wasSacrifice, PlayableCard killer, bool playSound, ref IEnumerator __result)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (SaveFile.IsAscension && AscensionSaveData.Data.ChallengeIsActive(permaDeathChallenge.challengeType) && CardExtensions.IsPlayerCard(__instance))
			{
				DeckInfo playerDeck = SaveManager.SaveFile.ascensionData.currentRun.playerDeck;
				CardInfo val = ((CardCollectionInfo)playerDeck).Cards.Find((CardInfo x) => ((Object)x).name == ((Object)((Card)__instance).Info).name && CardExtensions.HasAllAbilities(__instance, x.ModAbilities.ToArray()) && __instance.MaxHealth == x.Health);
				if ((Object)(object)val != (Object)null)
				{
					((CardCollectionInfo)playerDeck).RemoveCard(val);
					((Card)__instance).Anim.PlayPermaDeathAnimation(playSound);
					Singleton<ChallengeActivationUI>.Instance.ShowTextLines(new string[2]
					{
						"PERMADEATH TRIGGERED:",
						"CurrentDeck.RemoveCard(" + ((Object)val).name + ")"
					});
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayableCard), "Sacrifice")]
		[HarmonyPrefix]
		private static bool PermaDeathPatch2(PlayableCard __instance, ref IEnumerator __result)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (SaveFile.IsAscension && AscensionSaveData.Data.ChallengeIsActive(permaDeathChallenge2.challengeType) && CardExtensions.IsPlayerCard(__instance))
			{
				DeckInfo playerDeck = SaveManager.SaveFile.ascensionData.currentRun.playerDeck;
				CardInfo val = ((CardCollectionInfo)playerDeck).Cards.Find((CardInfo x) => ((Object)x).name == ((Object)((Card)__instance).Info).name && CardExtensions.HasAllAbilities(__instance, x.ModAbilities.ToArray()) && __instance.MaxHealth == x.Health);
				if ((Object)(object)val != (Object)null)
				{
					((CardCollectionInfo)playerDeck).RemoveCard(val);
					Singleton<ChallengeActivationUI>.Instance.ShowTextLines(new string[2]
					{
						"PERMADEATH TRIGGERED:",
						"CurrentDeck.RemoveCard(" + ((Object)val).name + ")"
					});
				}
			}
			return true;
		}

		private void createPermaDeathChallenge()
		{
			FullChallenge val = ChallengeManager.AddSpecific("GeckVolantMarin-PermaDeath", "Perma Death on die", "All card are removed from your deck if killed.", 50, TextureHelper.GetImageAsTexture("permaDeathChallenge.png", (FilterMode)0), TextureHelper.GetImageAsTexture("permaDeathChallengeEmission.png", (FilterMode)0), 10, 1);
			permaDeathChallenge = val.Challenge;
		}

		private void createPermaDeathChallenge2()
		{
			FullChallenge val = ChallengeManager.AddSpecific("GeckVolantMarin-PermaDeath", "Perma Death on sacrifice", "All card are removed from your deck if sacrificed.", 50, TextureHelper.GetImageAsTexture("permaDeathChallenge2.png", (FilterMode)0), TextureHelper.GetImageAsTexture("permaDeathChallengeEmission.png", (FilterMode)0), 10, 1);
			permaDeathChallenge2 = val.Challenge;
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			directory = ((BaseUnityPlugin)this).Info.Location;
			createPermaDeathChallenge();
			createPermaDeathChallenge2();
			HarmonyInstance.PatchAll(typeof(Plugin).Assembly);
			Logger.LogInfo((object)"Reussi?");
			Logger.LogInfo((object)"Plugin GeckVolantMarin-PermaDeath is loaded!");
		}
	}
}