Decompiled source of OprahMod v1.0.0

plugins/OprahMod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 InscryptionAPI.Card;
using InscryptionAPI.Guid;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("OprahMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OprahMod")]
[assembly: AssemblyTitle("OprahMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OprahMod;

public class CompanyPromotionSigil : AbilityBehaviour
{
	[CompilerGenerated]
	private sealed class <GiveComplimentCards>d__7 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public int count;

		private int <totalCompliments>5__2;

		private int <i>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <GiveComplimentCards>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<totalCompliments>5__2 = Plugin.Compliments.Count;
				<i>5__3 = 0;
				goto IL_00ee;
			case 1:
				<>1__state = -1;
				goto IL_00bc;
			case 2:
				<>1__state = -1;
				goto IL_00dc;
			case 3:
				{
					<>1__state = -1;
					return false;
				}
				IL_00ee:
				if (<i>5__3 < count)
				{
					int num = Random.Range(0, <totalCompliments>5__2);
					string text = string.Format("{0}{1}", "OprahMod_Compliment_", num);
					CardInfo cardByName = CardLoader.GetCardByName(text);
					if ((Object)(object)cardByName == (Object)null)
					{
						Debug.LogWarning((object)("[OprahMod] Could not find card: " + text));
						goto IL_00dc;
					}
					if ((Object)(object)Singleton<PlayerHand>.Instance != (Object)null)
					{
						<>2__current = Singleton<CardSpawner>.Instance.SpawnCardToHand(cardByName, (List<CardModificationInfo>)null, 0.25f, (Action<PlayableCard>)null);
						<>1__state = 1;
						return true;
					}
					goto IL_00bc;
				}
				<>2__current = Singleton<TextDisplayer>.Instance.ShowUntilInput("EVERYBODY gets a compliment!", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)1, (Speaker)0, (string[])null, true);
				<>1__state = 3;
				return true;
				IL_00dc:
				<i>5__3++;
				goto IL_00ee;
				IL_00bc:
				<>2__current = (object)new WaitForSeconds(0.15f);
				<>1__state = 2;
				return true;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <OnResolveOnBoard>d__5 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public CompanyPromotionSigil <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <OnResolveOnBoard>d__5(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			int num = <>1__state;
			CompanyPromotionSigil companyPromotionSigil = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = ((AbilityBehaviour)companyPromotionSigil).PreSuccessfulTriggerSequence();
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = companyPromotionSigil.QueueOpponentCards(3);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = companyPromotionSigil.GiveComplimentCards(3);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>2__current = ((AbilityBehaviour)companyPromotionSigil).LearnAbility(0.5f);
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <QueueOpponentCards>d__6 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public CompanyPromotionSigil <>4__this;

		public int count;

		private List<CardInfo> <pool>5__2;

		private int <i>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <QueueOpponentCards>d__6(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<pool>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			int num = <>1__state;
			CompanyPromotionSigil companyPromotionSigil = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<pool>5__2 = companyPromotionSigil.GetOpponentCardPool();
				if (<pool>5__2.Count == 0)
				{
					Debug.LogWarning((object)"[OprahMod] No opponent card pool found.");
					return false;
				}
				<i>5__3 = 0;
				goto IL_0111;
			case 1:
				<>1__state = -1;
				<i>5__3++;
				goto IL_0111;
			case 2:
				{
					<>1__state = -1;
					return false;
				}
				IL_0111:
				if (<i>5__3 < count)
				{
					CardInfo item = <pool>5__2[Random.Range(0, <pool>5__2.Count)];
					TurnManager instance = Singleton<TurnManager>.Instance;
					if ((Object)(object)((instance != null) ? instance.Opponent : null) != (Object)null)
					{
						Opponent opponent = Singleton<TurnManager>.Instance.Opponent;
						PropertyInfo property = ((object)opponent).GetType().GetProperty("TurnPlan", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (property != null && property.GetValue(opponent) is List<List<CardInfo>> list)
						{
							list.Add(new List<CardInfo> { item });
						}
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				}
				<>2__current = Singleton<TextDisplayer>.Instance.ShowUntilInput("YOU get a card! And YOU get a card!", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)1, (Speaker)0, (string[])null, true);
				<>1__state = 2;
				return true;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static Ability AbilityId;

	public override Ability Ability => AbilityId;

	public static Ability Register(ManualLogSource logger)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected I4, but got Unknown
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		AbilityInfo obj = AbilityManager.New("oprahmod.inscryption.oprahcard", "Company Promotion", "When [creature] is played, 3 random cards are queued on the opponent's side and 3 Compliment cards are added to your hand.", typeof(CompanyPromotionSigil), (Texture)(object)TextureFromResource("company_promotion_sigil.png"));
		obj.powerLevel = 4;
		obj.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
		AbilityId = obj.ability;
		logger.LogInfo((object)$"  Registered ability: Company Promotion ({(int)AbilityId})");
		return AbilityId;
	}

	public override bool RespondsToResolveOnBoard()
	{
		return true;
	}

	[IteratorStateMachine(typeof(<OnResolveOnBoard>d__5))]
	public override IEnumerator OnResolveOnBoard()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <OnResolveOnBoard>d__5(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<QueueOpponentCards>d__6))]
	private IEnumerator QueueOpponentCards(int count)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <QueueOpponentCards>d__6(0)
		{
			<>4__this = this,
			count = count
		};
	}

	[IteratorStateMachine(typeof(<GiveComplimentCards>d__7))]
	private IEnumerator GiveComplimentCards(int count)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <GiveComplimentCards>d__7(0)
		{
			count = count
		};
	}

	private List<CardInfo> GetOpponentCardPool()
	{
		List<CardInfo> list = new List<CardInfo>();
		TurnManager instance = Singleton<TurnManager>.Instance;
		if ((Object)(object)((instance != null) ? instance.Opponent : null) != (Object)null)
		{
			list = CardManager.AllCardsCopy.Where((CardInfo c) => (int)c.temple == 0 && c.Attack <= 3 && c.Health <= 4 && !c.HasTrait((Trait)14) && c.metaCategories.Contains((CardMetaCategory)0)).ToList();
		}
		if (list.Count == 0)
		{
			string[] array = new string[7] { "Stoat", "Bullfrog", "Wolf", "Adder", "Sparrow", "Bloodhound", "Rabbit" };
			for (int i = 0; i < array.Length; i++)
			{
				CardInfo cardByName = CardLoader.GetCardByName(array[i]);
				if ((Object)(object)cardByName != (Object)null)
				{
					list.Add(cardByName);
				}
			}
		}
		return list;
	}

	private static Texture2D TextureFromResource(string fileName)
	{
		return Plugin.TextureFromFile(fileName);
	}
}
public class HeartStatIcon : VariableStatBehaviour
{
	public static SpecialStatIcon HeartIconId;

	protected override SpecialStatIcon IconType => HeartIconId;

	public static void Register()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		StatIconInfo obj = StatIconManager.New("oprahmod.inscryption.oprahcard", "Heartfelt", "This card is sustained by love and cannot be sacrificed. The heart represents its unsacrificial nature.", typeof(HeartStatIcon));
		obj.iconGraphic = (Texture)(object)CreateHeartTexture();
		obj.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
		HeartIconId = GuidManager.GetEnumValue<SpecialStatIcon>("oprahmod.inscryption.oprahcard", "Heartfelt");
	}

	protected override int[] GetStatValues()
	{
		int num = ((!((Object)(object)((SpecialCardBehaviour)this).PlayableCard != (Object)null)) ? 1 : ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.Health);
		return new int[2] { 0, num };
	}

	private static Texture2D CreateHeartTexture()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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)
		Texture2D val = Plugin.TextureFromFile("heart_icon.png");
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		int num = 49;
		Texture2D val2 = new Texture2D(num, num, (TextureFormat)4, false);
		((Texture)val2).filterMode = (FilterMode)0;
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.85f, 0.15f, 0.2f, 1f);
		Color clear = Color.clear;
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num2 = ((float)j - (float)num / 2f) / ((float)num / 2f);
				float num3 = ((float)i - (float)num / 2f) / ((float)num / 2f);
				float num4 = num2 * num2;
				float num5 = (num3 - 0.2f) * (num3 - 0.2f);
				float num6 = num3 - 0.2f;
				float num7 = Mathf.Pow(num4 + num5 - 0.45f, 3f) - num4 * num6 * num6 * num6;
				val2.SetPixel(j, i, (num7 <= 0f) ? val3 : clear);
			}
		}
		val2.Apply();
		return val2;
	}
}
[BepInPlugin("oprahmod.inscryption.oprahcard", "Oprah Card Mod", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "oprahmod.inscryption.oprahcard";

	public const string PluginName = "Oprah Card Mod";

	public const string PluginVersion = "1.0.0";

	public static Ability CompanyPromotionAbility;

	public static readonly List<(string compliment, Ability? extraAbility)> Compliments = new List<(string, Ability?)>
	{
		("You Get a Car!", null),
		("You Are Enough", null),
		("Live Your Best Life", null),
		("You Are Beautiful", null),
		("You Are So Strong", (Ability)34),
		("You Inspire Others", (Ability)14),
		("You Light Up the Room", (Ability)15),
		("Never Give Up", (Ability)26),
		("You Are Brave", (Ability)54),
		("Believe in Yourself", (Ability)23),
		("You Have Great Energy", (Ability)76),
		("You Are a Leader", (Ability)18),
		("Spread the Love", (Ability)6),
		("You Are Radiant", (Ability)5)
	};

	public const string OPRAH_CARD_NAME = "OprahMod_Oprah";

	public const string COMPLIMENT_CARD_BASE = "OprahMod_Compliment_";

	private void Awake()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Oprah Card Mod v1.0.0...");
		CompanyPromotionAbility = CompanyPromotionSigil.Register(((BaseUnityPlugin)this).Logger);
		HeartStatIcon.Register();
		RegisterComplimentCards();
		RegisterOprahCard();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Oprah Card Mod loaded successfully!");
	}

	private void RegisterOprahCard()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected I4, but got Unknown
		CardInfo val = CardManager.New("OprahMod", "OprahMod_Oprah", "Oprah", 14, 1, "YOU get a card! And YOU get a card! EVERYBODY gets a card!");
		CardExtensions.SetCost(val, (int?)2, (int?)3, (int?)0, (List<GemType>)null);
		CardExtensions.AddAbilities(val, (Ability[])(object)new Ability[1] { (Ability)(int)CompanyPromotionAbility });
		CardExtensions.SetCardTemple(val, (CardTemple)0);
		CardExtensions.AddMetaCategories(val, (CardMetaCategory[])(object)new CardMetaCategory[2]
		{
			default(CardMetaCategory),
			(CardMetaCategory)1
		});
		CardExtensions.SetRare(val);
		Texture2D val2 = TextureFromFile("oprah_portrait.png");
		if ((Object)(object)val2 != (Object)null)
		{
			CardExtensions.SetPortrait(val, val2, (FilterMode?)null);
		}
		Texture2D val3 = TextureFromFile("oprah_portrait_emission.png");
		if ((Object)(object)val3 != (Object)null)
		{
			CardExtensions.SetEmissivePortrait(val, val3, (FilterMode?)null);
		}
		CardManager.Add("OprahMod", val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Oprah card registered as: " + ((Object)val).name));
	}

	private void RegisterComplimentCards()
	{
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < Compliments.Count; i++)
		{
			(string compliment, Ability? extraAbility) tuple = Compliments[i];
			string item = tuple.compliment;
			Ability? item2 = tuple.extraAbility;
			string text = string.Format("{0}{1}", "OprahMod_Compliment_", i);
			string text2 = (item2.HasValue ? ("Compliment: " + item) : "Compliment");
			CardInfo val = CardManager.New("OprahMod", text, text2, 0, 1, "\"" + item + "\" — Oprah");
			CardExtensions.SetCost(val, (int?)0, (int?)0, (int?)0, (List<GemType>)null);
			List<Ability> list = new List<Ability> { (Ability)105 };
			if (item2.HasValue)
			{
				list.Add(item2.Value);
			}
			CardExtensions.AddAbilities(val, list.ToArray());
			CardExtensions.AddSpecialAbilities(val, (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)15 });
			CardExtensions.SetCardTemple(val, (CardTemple)0);
			CardExtensions.AddTraits(val, (Trait[])(object)new Trait[1] { (Trait)14 });
			CardExtensions.AddAppearances(val, (Appearance[])(object)new Appearance[1] { (Appearance)6 });
			CardExtensions.SetStatIcon(val, HeartStatIcon.HeartIconId);
			Texture2D val2 = TextureFromFile("compliment_portrait.png");
			if ((Object)(object)val2 != (Object)null)
			{
				CardExtensions.SetPortrait(val, val2, (FilterMode?)null);
			}
			CardManager.Add("OprahMod", val);
			if (i == 0)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Compliment card registered as: " + ((Object)val).name));
			}
		}
	}

	public static Texture2D TextureFromFile(string fileName)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_004b: Expected O, but got Unknown
		string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", fileName);
		if (!File.Exists(path))
		{
			return null;
		}
		byte[] array = File.ReadAllBytes(path);
		Texture2D val = new Texture2D(114, 94, (TextureFormat)4, false)
		{
			filterMode = (FilterMode)0
		};
		ImageConversion.LoadImage(val, array);
		return val;
	}
}