Decompiled source of GlobalSigilInjector v1.2.1

GlobalSigilInjector.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AllCardUnkillable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AllCardUnkillable")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("71add3bb-5556-4406-9db9-48ac05f9ccec")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("SmileyTeam.AddSigilToAll", "Global Sigil Injector", "1.2.1")]
[BepInProcess("Inscryption.exe")]
public class GlobalSigilInjector : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CardLoader), "Clone")]
	public class Patch_CardLoaderClone
	{
		[HarmonyPostfix]
		public static void Postfix(ref CardInfo __result)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected I4, but got Unknown
			if ((Object)(object)__result == (Object)null || CheatMode.Value)
			{
				return;
			}
			foreach (Ability normalSigil in NormalSigils)
			{
				if (!__result.HasAbility(normalSigil))
				{
					CardExtensions.AddAbilities(__result, (Ability[])(object)new Ability[1] { (Ability)(int)normalSigil });
				}
			}
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class Patch_CardOnBoard
	{
		[HarmonyPostfix]
		public static void Postfix(CardSlot __instance, Card __0)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			if (!((Object)(object)__0 != (Object)null) || !CheatMode.Value || !__instance.IsPlayerSlot)
			{
				return;
			}
			foreach (Ability normalSigil in NormalSigils)
			{
				if (!__0.Info.HasAbility(normalSigil))
				{
					__0.Info.Mods.Add(new CardModificationInfo(normalSigil));
				}
			}
		}
	}

	public static ConfigEntry<string> ConfigSigilNames;

	public static ConfigEntry<bool> CheatMode;

	public static List<Ability> NormalSigils = new List<Ability>();

	private void Awake()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Global Sigil Injector loaded.");
		ConfigSigilNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Sigil", "", "Comma-separated vanilla or modded ability names\n(e.g., DrawCopyOnDeath, Pinnacle Strike)\nSpaces are automatically handled.");
		CheatMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CheatMode", false, "When enabled, sigils apply only to cards on the player's side\nafter they are placed on the board. They won't work the first\ntime, but will stick permanently—even after reloading the game.\nNote: Side deck cards won't retain or trigger these sigils.");
		LoadAbilities();
		new Harmony("SmileyTeam.addsigil.patch").PatchAll(typeof(GlobalSigilInjector).Assembly);
	}

	private void LoadAbilities()
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		NormalSigils.Clear();
		if (string.IsNullOrWhiteSpace(ConfigSigilNames.Value))
		{
			return;
		}
		string[] array = ConfigSigilNames.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
		foreach (string text in array)
		{
			string trimmed = text.Trim().Replace("\"", "");
			if (Enum.TryParse<Ability>(trimmed, ignoreCase: true, out Ability result))
			{
				NormalSigils.Add(result);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Using vanilla sigil: {result}");
				continue;
			}
			FullAbility val = ((IEnumerable<FullAbility>)AbilityManager.AllAbilities).FirstOrDefault((Func<FullAbility, bool>)delegate(FullAbility a)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Ability id = a.Id;
				return ((object)(Ability)(ref id)).ToString().Replace(" ", "").Equals(trimmed.Replace(" ", ""), StringComparison.OrdinalIgnoreCase) || (a.Info?.rulebookName?.Replace(" ", "").Equals(trimmed.Replace(" ", ""), StringComparison.OrdinalIgnoreCase)).GetValueOrDefault();
			});
			if (val != null)
			{
				NormalSigils.Add(val.Id);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Using modded sigil: {val.Id} ({val.Info.rulebookName})");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find any matching ability for: " + trimmed));
			}
		}
	}
}