Decompiled source of ZephtSun v1.0.0

ZephtSun.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
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 InscryptionCommunityPatch.Card;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ZephtSun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ZephtSun")]
[assembly: AssemblyTitle("ZephtSun")]
[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 ZephtSun
{
	public static class ext
	{
		public static int GetSunCost(this CardInfo info)
		{
			int? extendedPropertyAsInt = CardExtensions.GetExtendedPropertyAsInt(info, "SunCost");
			return extendedPropertyAsInt.HasValue ? extendedPropertyAsInt.Value : 0;
		}
	}
	[BepInPlugin("zepht.inscryption.ZephtSun", "PvZSunbyZepht", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public class SunmakerX : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			private int SunValue
			{
				get
				{
					int result = 1;
					if (CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").HasValue)
					{
						result = CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").Value;
					}
					return result;
				}
			}

			public override bool RespondsToTurnEnd(bool playerTurnEnd)
			{
				return ((AbilityBehaviour)this).Card.OpponentCard != playerTurnEnd && !((AbilityBehaviour)this).Card.Dead;
			}

			public override IEnumerator OnTurnEnd(bool playerTurnEnd)
			{
				if (!((AbilityBehaviour)this).Card.OpponentCard)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
					yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
					yield return gainSunFromCard(SunValue, ((AbilityBehaviour)this).Card);
					yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
					Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
				}
			}

			public override bool RespondsToDrawn()
			{
				return true;
			}

			public override IEnumerator OnDrawn()
			{
				ReRenderCard(SunValue);
				yield break;
			}

			public override bool RespondsToResolveOnBoard()
			{
				return true;
			}

			public override IEnumerator OnResolveOnBoard()
			{
				ReRenderCard(SunValue);
				yield break;
			}

			private void ReRenderCard(int num)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				((Card)((AbilityBehaviour)this).Card).RenderInfo.OverrideAbilityIcon(ability, pixelSunmakerIcons[Mathf.Clamp(num, 0, pixelSunmakerIcons.Count - 1)]);
				((Card)((AbilityBehaviour)this).Card).RenderInfo.OverrideAbilityIcon(ability, sunmakerIcons[Mathf.Clamp(num, 0, sunmakerIcons.Count - 1)]);
				((Card)((AbilityBehaviour)this).Card).RenderCard();
			}
		}

		public class Sunmaker1 : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			public override bool RespondsToTurnEnd(bool playerTurnEnd)
			{
				return ((AbilityBehaviour)this).Card.OpponentCard != playerTurnEnd && !((AbilityBehaviour)this).Card.Dead;
			}

			public override IEnumerator OnTurnEnd(bool playerTurnEnd)
			{
				if (!((AbilityBehaviour)this).Card.OpponentCard)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
					yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
					yield return gainSunFromCard(1, ((AbilityBehaviour)this).Card);
					yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
					Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
				}
			}
		}

		public class Sunmaker2 : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			public override bool RespondsToTurnEnd(bool playerTurnEnd)
			{
				return ((AbilityBehaviour)this).Card.OpponentCard != playerTurnEnd && !((AbilityBehaviour)this).Card.Dead;
			}

			public override IEnumerator OnTurnEnd(bool playerTurnEnd)
			{
				if (!((AbilityBehaviour)this).Card.OpponentCard)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
					yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
					yield return gainSunFromCard(2, ((AbilityBehaviour)this).Card);
					yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
					Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
				}
			}
		}

		public class Sunmaker3 : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			public override bool RespondsToTurnEnd(bool playerTurnEnd)
			{
				return ((AbilityBehaviour)this).Card.OpponentCard != playerTurnEnd && !((AbilityBehaviour)this).Card.Dead;
			}

			public override IEnumerator OnTurnEnd(bool playerTurnEnd)
			{
				if (!((AbilityBehaviour)this).Card.OpponentCard)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
					yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
					yield return gainSunFromCard(3, ((AbilityBehaviour)this).Card);
					yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
					Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
				}
			}
		}

		public class SunKill : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			private int SunValue
			{
				get
				{
					int result = 1;
					if (CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").HasValue)
					{
						result = CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").Value;
					}
					return result;
				}
			}

			public override bool RespondsToOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
			{
				return (Object)(object)killer != (Object)null && (Object)(object)killer == (Object)(object)((AbilityBehaviour)this).Card;
			}

			public override IEnumerator OnOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
			{
				Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
				yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
				yield return gainSunFromCard(SunValue, ((AbilityBehaviour)this).Card);
				yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}
		}

		public class SunBoost : AbilityBehaviour
		{
			public static Ability ability;

			public override Ability Ability => ability;

			private int SunValue
			{
				get
				{
					int result = 1;
					if (CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").HasValue)
					{
						result = CardExtensions.GetExtendedPropertyAsInt(((Card)((AbilityBehaviour)this).Card).Info, "Sunmaker").Value;
					}
					return result;
				}
			}

			public override bool RespondsToResolveOnBoard()
			{
				return ((AbilityBehaviour)this).Card.OnBoard;
			}

			public override IEnumerator OnResolveOnBoard()
			{
				yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
				((Card)((AbilityBehaviour)this).Card).Anim.LightNegationEffect();
				Singleton<ViewManager>.Instance.SwitchToView((View)7, false, true);
				yield return gainSunFromCard(SunValue, ((AbilityBehaviour)this).Card);
				yield return ((AbilityBehaviour)this).LearnAbility(0.1f);
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}
		}

		[HarmonyPatch(typeof(PlayableCard), "CanPlay")]
		public class CanPlay_patch
		{
			[HarmonyPostfix]
			public static void Postfix(ref bool __result, ref PlayableCard __instance)
			{
				if (((Card)__instance).Info.GetSunCost() > 0)
				{
					int sunCost = ((Card)__instance).Info.GetSunCost();
					if (sunCost > Sun)
					{
						__result = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(HintsHandler), "OnNonplayableCardClicked")]
		public class CanPlayHint_patch
		{
			[HarmonyPrefix]
			public static bool Prefix(PlayableCard card, List<PlayableCard> cardsInHand)
			{
				if (SaveManager.SaveFile.IsPart2)
				{
					HintsHandler.OnGBCNonPlayableCardPressed(card);
					return false;
				}
				if (((Card)card).Info.GetSunCost() > Sun)
				{
					SayQuick("You dont have enough sun for that one");
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PlayerHand))]
		public class paySun_patch
		{
			[HarmonyPostfix]
			[HarmonyPatch("SelectSlotForCard")]
			public static IEnumerator Postfix(IEnumerator enumerator, PlayerHand __instance, PlayableCard card)
			{
				if (((Card)card).Info.GetSunCost() > 0)
				{
					__instance.CardsInHand.ForEach(delegate(PlayableCard x)
					{
						((InteractableBase)x).SetEnabled(false);
					});
					yield return (object)new WaitWhile((Func<bool>)(() => __instance.ChoosingSlot));
					__instance.OnSelectSlotStartedForCard(card);
					if ((Object)(object)Singleton<RuleBookController>.Instance != (Object)null)
					{
						Singleton<RuleBookController>.Instance.SetShown(false, true);
					}
					Singleton<BoardManager>.Instance.CancelledSacrifice = false;
					__instance.choosingSlotCard = card;
					if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null)
					{
						((Card)card).Anim.SetSelectedToPlay(true);
					}
					Singleton<BoardManager>.Instance.ShowCardNearBoard(card, true);
					if ((Object)(object)Singleton<TurnManager>.Instance.SpecialSequencer != (Object)null)
					{
						yield return Singleton<TurnManager>.Instance.SpecialSequencer.CardSelectedFromHand(card);
					}
					bool cardWasPlayed = false;
					bool requiresSacrifices = ((Card)card).Info.BloodCost > 0;
					if (requiresSacrifices)
					{
						List<CardSlot> validSlots = Singleton<BoardManager>.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null);
						yield return Singleton<BoardManager>.Instance.ChooseSacrificesForCard(validSlots, card);
					}
					if (!Singleton<BoardManager>.Instance.CancelledSacrifice)
					{
						List<CardSlot> validSlots2 = Singleton<BoardManager>.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card == (Object)null);
						yield return Singleton<BoardManager>.Instance.ChooseSlot(validSlots2, !requiresSacrifices);
						CardSlot lastSelectedSlot = Singleton<BoardManager>.Instance.LastSelectedSlot;
						if ((Object)(object)lastSelectedSlot != (Object)null)
						{
							cardWasPlayed = true;
							((Card)card).Anim.SetSelectedToPlay(false);
							yield return __instance.PlayCardOnSlot(card, lastSelectedSlot);
							if (((Card)card).Info.BonesCost > 0)
							{
								yield return Singleton<ResourcesManager>.Instance.SpendBones(((Card)card).Info.BonesCost);
							}
							if (card.EnergyCost > 0)
							{
								yield return Singleton<ResourcesManager>.Instance.SpendEnergy(card.EnergyCost);
							}
							if (((Card)card).Info.GetSunCost() > 0 && !SaveManager.SaveFile.IsPart2)
							{
								int costToPay = ((Card)card).Info.GetSunCost();
								yield return extractSun(costToPay);
							}
						}
					}
					if (!cardWasPlayed)
					{
						Singleton<BoardManager>.Instance.ShowCardNearBoard(card, false);
					}
					__instance.choosingSlotCard = null;
					if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null)
					{
						((Card)card).Anim.SetSelectedToPlay(false);
					}
					__instance.CardsInHand.ForEach(delegate(PlayableCard x)
					{
						((InteractableBase)x).SetEnabled(true);
					});
				}
				else
				{
					yield return enumerator;
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class CardInfo_CostTier_Patch
		{
			[HarmonyPostfix]
			public static void Postfix(ref int __result, ref CardInfo __instance)
			{
				__result += Mathf.CeilToInt((float)__instance.GetSunCost() / 3f);
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class Deck_CardCanBePlayedByTurn2WithHand
		{
			[HarmonyPostfix]
			public static void Postfix(ref CardInfo card, List<CardInfo> hand, ref bool __result, ref Deck __instance)
			{
				__result = __result && card.GetSunCost() <= 2;
			}
		}

		[HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")]
		public class TurnStart_patch
		{
			[HarmonyPostfix]
			public static void Postfix(ref bool playerUpkeep)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (playerUpkeep && !AscensionSaveData.Data.ChallengeIsActive(noSunChallenge.challengeType))
				{
					Log.LogInfo((object)"Sun upkeep patch initialised");
					SunCounterCard.Anim.LightNegationEffect();
					Sun++;
					UpdateSunCounter();
				}
			}
		}

		[HarmonyPatch(typeof(GameFlowManager), "TransitionTo")]
		public class Transition_To_patch
		{
			[HarmonyPrefix]
			public static void Prefix()
			{
				Sun = 2;
			}
		}

		[HarmonyPatch(typeof(CardDrawPiles), "Initialize")]
		public class Initialise_patch
		{
			[HarmonyPostfix]
			public static void Postfix()
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				Log.LogInfo((object)"Sun counter patch initialised");
				SunCounterObject = Object.Instantiate<GameObject>(Singleton<CardSpawner>.Instance.playableCardPrefab);
				UpdateSunCounter();
				SunCounterCard.Anim.StrongNegationEffect();
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(1.24f, 1.05f, 5.014f);
				SunCounterObject.transform.Translate(val);
				((Vector3)(ref val))..ctor(-2.82f, -0.6f, -5.63f);
				SunCounterObject.transform.Translate(val);
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(-90f, 0f, 0f);
				SunCounterObject.transform.Rotate(val2);
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(15f, -35f, 0f);
				SunCounterObject.transform.Rotate(val3);
				SunCounterObject.transform.localScale = new Vector3(1.3f, 1.3f, 1.3f);
			}
		}

		[HarmonyPatch(typeof(CardDrawPiles), "CleanUp")]
		public class Cleanup_patch
		{
			[HarmonyPostfix]
			public static void Postfix()
			{
				Log.LogInfo((object)"Sun counter patch clean up");
				if ((Object)(object)SunCounterObject != (Object)null)
				{
					SunCounterCard.Anim.StrongNegationEffect();
					Object.Destroy((Object)(object)SunCounterObject.gameObject);
				}
			}
		}

		public class SunCounterBackground : CardAppearanceBehaviour
		{
			public static Appearance CustomAppearance;

			public override void ApplyAppearance()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				((CardAppearanceBehaviour)this).Card.RenderInfo.baseTextureOverride = (Texture)(object)findTexture("SunCounter");
				Color nameTextColor = default(Color);
				nameTextColor.a = 1f;
				nameTextColor.r = 1f;
				nameTextColor.g = 0.5f;
				nameTextColor.b = 0f;
				((CardAppearanceBehaviour)this).Card.RenderInfo.nameTextColor = nameTextColor;
				SunCounterCard = ((CardAppearanceBehaviour)this).Card;
			}
		}

		[HarmonyPatch(typeof(CardSingleChoicesSequencer), "GetCardbackTexture")]
		public class SunCostBack_patch
		{
			[HarmonyPostfix]
			public static void Postfix(ref Texture __result, CardChoice choice)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				if (choice.resourceType == SunResource)
				{
					__result = (Texture)(object)findTexture("SunCostTrial");
				}
			}
		}

		[HarmonyPatch(typeof(Part1CardChoiceGenerator), "GenerateCostChoices")]
		public class CostChoice_patch
		{
			[HarmonyPostfix]
			public static void Postfix(ref List<CardChoice> __result, int randomSeed)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Expected O, but got Unknown
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				List<CardChoice> list = __result;
				CardChoice val = new CardChoice();
				val.resourceType = SunResource;
				val.resourceAmount = 1;
				list.Add(val);
				ShuffleChoice(list);
				while (list.Count > 3)
				{
					list.RemoveAt(SeededRandom.Range(0, list.Count, randomSeed++));
				}
				if (list[0] != val && list[1] != val && list[2] != val)
				{
					list[0] = val;
					ShuffleChoice(list);
				}
				__result = list;
			}
		}

		[HarmonyPatch(typeof(CardSingleChoicesSequencer))]
		public class SunCostCreateCard_patch
		{
			[HarmonyPostfix]
			[HarmonyPatch("CostChoiceChosen")]
			public static IEnumerator Postfix(IEnumerator enumerator, CardSingleChoicesSequencer __instance, SelectableCard card)
			{
				if (card.ChoiceInfo.resourceType == SunResource)
				{
					CardInfo cardInfo = GetRandomChoosablePlantCard(SaveManager.SaveFile.GetCurrentRandomSeed());
					((Card)card).SetInfo(cardInfo);
					((Card)card).SetFaceDown(false, false);
					((Card)card).SetInteractionEnabled(false);
					yield return __instance.TutorialTextSequence(card);
					((Card)card).SetCardbackToDefault();
					yield return __instance.WaitForCardToBeTaken(card);
				}
				else
				{
					yield return enumerator;
				}
			}
		}

		public const string PluginGuid = "zepht.inscryption.ZephtSun";

		private const string PluginName = "PvZSunbyZepht";

		private const string PluginVersion = "1.0.0";

		public static int Sun;

		public static Texture[] costDecals;

		public static readonly Appearance SunCounterApp = CardAppearanceBehaviourManager.Add("zepht.inscryption.ZephtSun", "SunCounterApp", typeof(SunCounterBackground)).Id;

		public static ResourceType SunResource = (ResourceType)78;

		public static Card SunCounterCard;

		public static CardInfo SunCounterCardInfo = ScriptableObject.CreateInstance<CardInfo>();

		public static GameObject SunCounterObject;

		internal static ManualLogSource Log;

		public static Random rng = new Random();

		public static AscensionChallengeInfo noSunChallenge;

		public static Dictionary<int, Texture> sunmakerIcons;

		public static Dictionary<int, Texture> pixelSunmakerIcons;

		public static Assembly _assembly;

		public static GameObject Particle;

		public static Assembly CurrentAssembly => _assembly ?? (_assembly = Assembly.GetExecutingAssembly());

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Loaded PvZSunbyZepht!");
			Log.LogInfo((object)"Inside Awake");
			Harmony val = new Harmony("zepht.inscryption.ZephtSun");
			val.PatchAll();
			Log.LogInfo((object)"DonePatch");
			AddSigils();
			Log.LogInfo((object)"DoneSigils");
			AddCards();
			Log.LogInfo((object)"DoneCards");
			AddChallenges();
			Log.LogInfo((object)"DoneChallenges");
		}

		private void AddChallenges()
		{
			AddNoSunChallenge();
		}

		private void AddNoSunChallenge()
		{
			noSunChallenge = FullChallenge.op_Implicit(ChallengeManager.AddSpecific("zepht.inscryption.ZephtSun", "Night time", "You will no longer get passive sun falling from the sky.", 10, findTexture("ChallengeNight"), findTexture("ChallengeNightActive"), 2, 1));
		}

		private void AddCards()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected I4, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected I4, but got Unknown
			Part1CardCostRender.UpdateCardCost += delegate(CardInfo card, List<Texture2D> costs)
			{
				int sunCost = card.GetSunCost();
				if (sunCost > 0)
				{
					costs.Add(findTexture("SunCost" + sunCost));
				}
			};
			Texture2D val = findTexture("ZA");
			string text = "zep_pvz";
			SunCounterCardInfo = CardManager.New(text, "suncounter", "Sun: ", 0, 0, ".");
			CardExtensions.AddAppearances(SunCounterCardInfo, (Appearance[])(object)new Appearance[1] { (Appearance)(int)SunCounterApp });
			SunCounterCardInfo.hideAttackAndHealth = true;
			string text2 = "ZombieArm";
			Ability[] array = (Ability[])(object)new Ability[1] { (Ability)(int)SunBoost.ability };
			Trait[] array2 = (Trait[])(object)new Trait[0];
			Tribe[] array3 = (Tribe[])(object)new Tribe[0];
			string text3 = null;
			string text4 = "leaflitter";
			CardInfo val2 = CardManager.New(text, "debugSun", "DebugSun", 1, 1, "what");
			CardExtensions.AddAppearances(val2, Array.Empty<Appearance>());
			CardExtensions.AddMetaCategories(val2, Array.Empty<CardMetaCategory>());
			val2.defaultEvolutionName = "Debuggest";
			CardExtensions.SetExtendedProperty(val2, "Sunmaker", (object)6);
			CardExtensions.SetPortrait(val2, findTexture(text2), (FilterMode?)null);
			CardExtensions.SetEmissivePortrait(val2, findTexture(text2 + "2"), (FilterMode?)null);
			CardExtensions.AddDecal(val2, (Texture[])(object)new Texture[1] { (Texture)val });
			CardExtensions.AddAbilities(val2, array);
			CardExtensions.AddTraits(val2, array2);
			if (text3 != null)
			{
				CardExtensions.SetEvolve(val2, text + "_" + text3, 1, (IEnumerable<CardModificationInfo>)null);
			}
			CardExtensions.SetTail(val2, text + "_" + text4, (IEnumerable<CardModificationInfo>)null);
			CardExtensions.SetIceCube(val2, text + "_" + text4, (IEnumerable<CardModificationInfo>)null);
			CardExtensions.AddTribes(val2, array3);
		}

		private void AddSigils()
		{
			AddSunmakerX();
			AddSunmaker1();
			AddSunmaker2();
			AddSunmaker3();
			AddSunKill();
			AddSunBoost();
		}

		private void AddSunmakerX()
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunmaker";
			string name = "SunMaker";
			string description = "At the end of the owner's turn, [creature] will produce X sun, if it belongs to the player. Some cards produce more sun than others.";
			string learntext = "Every little bit counts";
			Type typeFromHandle = typeof(SunmakerX);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)0,
				(AbilityMetaCategory)1
			};
			sunmakerIcons = new Dictionary<int, Texture>
			{
				{
					0,
					(Texture)(object)findTexture("Sunmaker")
				},
				{
					1,
					(Texture)(object)findTexture("Sunmaker1")
				},
				{
					2,
					(Texture)(object)findTexture("Sunmaker2")
				},
				{
					3,
					(Texture)(object)findTexture("Sunmaker3")
				},
				{
					4,
					(Texture)(object)findTexture("Sunmaker4")
				},
				{
					5,
					(Texture)(object)findTexture("Sunmaker5")
				}
			};
			pixelSunmakerIcons = new Dictionary<int, Texture>
			{
				{
					0,
					(Texture)(object)findTexture("Sunmaker-p")
				},
				{
					1,
					(Texture)(object)findTexture("Sunmaker1-p")
				},
				{
					2,
					(Texture)(object)findTexture("Sunmaker2-p")
				},
				{
					3,
					(Texture)(object)findTexture("Sunmaker3-p")
				},
				{
					4,
					(Texture)(object)findTexture("Sunmaker4-p")
				},
				{
					5,
					(Texture)(object)findTexture("Sunmaker5-p")
				}
			};
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			SunmakerX.ability = val.ability;
		}

		private void AddSunmaker1()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunmaker1";
			string name = "SunMaker 1";
			string description = "At the end of the owner's turn, [creature] will produce 1 sun, if it belongs to the player.";
			string learntext = "Every little bit counts";
			Type typeFromHandle = typeof(Sunmaker1);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory>
			{
				(AbilityMetaCategory)0,
				(AbilityMetaCategory)1
			};
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			Sunmaker1.ability = val.ability;
		}

		private void AddSunmaker2()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunmaker2";
			string name = "SunMaker 2";
			string description = "At the end of the owner's turn, [creature] will produce 2 sun, if it belongs to the player.";
			string learntext = "If only the moon was this useful";
			Type typeFromHandle = typeof(Sunmaker2);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			Sunmaker2.ability = val.ability;
		}

		private void AddSunmaker3()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunmaker3";
			string name = "SunMaker 3";
			string description = "At the end of the owner's turn, [creature] will produce 3 sun, if it belongs to the player.";
			string learntext = "The power of the sun, in the palm of your hand";
			Type typeFromHandle = typeof(Sunmaker3);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			Sunmaker3.ability = val.ability;
		}

		private void AddSunKill()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunkill";
			string name = "SunKill";
			string description = "When [creature] defeats another card, the other card will drop sun.";
			string learntext = "Recycle your enemies back into nutrients";
			Type typeFromHandle = typeof(SunKill);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			SunKill.ability = val.ability;
		}

		private void AddSunBoost()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			string text = "Sunboost";
			string name = "SunBoost";
			string description = "When [creature] is placed on the board, the owner will gain sun.";
			string learntext = "Wise use of emergency supplies.";
			Type typeFromHandle = typeof(SunBoost);
			bool opponentUsable = false;
			bool flips = false;
			List<AbilityMetaCategory> categories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
			AbilityInfo val = MakeNewSigil(name, description, learntext, typeFromHandle, categories, opponentUsable, flips, (Texture)(object)findTexture(text), 0, stackable: false, findTexture(text + "-p"));
			SunBoost.ability = val.ability;
		}

		private void Update()
		{
		}

		public static IEnumerator gainSunFromCard(int SunToGain, PlayableCard card)
		{
			for (int i = 0; i < SunToGain; i++)
			{
				((Card)card).Anim.LightNegationEffect();
				Sun++;
				UpdateSunCounter();
				SunCounterCard.Anim.LightNegationEffect();
				yield return (object)new WaitForSeconds(0.2f);
			}
		}

		public static IEnumerator extractSun(int SunToLose)
		{
			for (int i = 0; i < SunToLose; i++)
			{
				Sun--;
				UpdateSunCounter();
				SunCounterCard.Anim.LightNegationEffect();
				yield return (object)new WaitForSeconds(0.05f);
			}
		}

		public static void UpdateSunCounter()
		{
			PlayableCard component = SunCounterObject.GetComponent<PlayableCard>();
			SunCounterCardInfo.displayedName = "Sun: " + Sun;
			((Card)component).SetInfo(SunCounterCardInfo);
		}

		public static CardInfo GetRandomChoosablePlantCard(int randomSeed)
		{
			List<CardInfo> list = CardLoader.RemoveDeckSingletonsIfInDeck(ScriptableObjectLoader<CardInfo>.AllData.FindAll((CardInfo x) => x.metaCategories.Contains((CardMetaCategory)0) && x.GetSunCost() > 0));
			if (list.Count == 0)
			{
				return CardLoader.Clone(CardLoader.GetCardByName("zep_pvz_puffshroom"));
			}
			return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]);
		}

		public static Texture2D findTexture(string name)
		{
			if (name == null)
			{
				return null;
			}
			return TextureHelper.GetImageAsTexture(name + (name.EndsWith(".png") ? "" : ".png"), CurrentAssembly, (FilterMode)0);
		}

		public static Sprite findStatIconSprite(string name)
		{
			if (name == null)
			{
				return null;
			}
			return TextureHelper.GetImageAsSprite(name + (name.EndsWith(".png") ? "" : ".png"), (SpriteType)3, (FilterMode)0);
		}

		public static AbilityInfo MakeNewSigil(string name, string description, string learntext, Type behaviour, List<AbilityMetaCategory> categories, bool opponentUsable, bool flips, Texture tex = null, int powerLevel = 0, bool stackable = false, Texture2D pixelTex = null, bool isConduit = false, bool isActivated = false)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			AbilityInfo val = AbilityManager.New("zepht.inscryption.ZephtSun", name, description, behaviour, (Texture)(((Object)(object)tex != (Object)null) ? ((object)tex) : ((object)findTexture("Spudow"))));
			val.powerLevel = powerLevel;
			val.canStack = stackable;
			val.opponentUsable = opponentUsable;
			val.flipYIfOpponent = flips;
			val.metaCategories = ((categories != null) ? categories : new List<AbilityMetaCategory>());
			val.conduit = isConduit;
			val.activated = isActivated;
			if ((Object)(object)pixelTex != (Object)null)
			{
				AbilityExtensions.SetPixelAbilityIcon(val, pixelTex, (FilterMode?)null);
			}
			List<Line> list = new List<Line>();
			Line val2 = new Line();
			val2.text = learntext;
			list.Add(val2);
			val.abilityLearnedDialogue = new LineSet(list);
			return val;
		}

		public static void MakeNewStarterDeck(string title, string sprName, string cardName1, string cardName2, string cardName3)
		{
			StarterDeckInfo val = ScriptableObject.CreateInstance<StarterDeckInfo>();
			val.title = title;
			val.iconSprite = TextureHelper.ConvertTexture(findTexture(sprName), (SpriteType)9, (FilterMode)0);
			val.cards = new List<CardInfo>
			{
				CardLoader.GetCardByName(cardName1),
				CardLoader.GetCardByName(cardName2),
				CardLoader.GetCardByName(cardName3)
			};
			StarterDeckManager.Add("zepht.inscryption.ZephtSun", val, 0);
		}

		private static void Say(string text)
		{
			((MonoBehaviour)Singleton<TextDisplayer>.Instance).StartCoroutine(Singleton<TextDisplayer>.Instance.ShowUntilInput(text, 0f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true));
		}

		private static void SayQuick(string text)
		{
			((MonoBehaviour)Singleton<TextDisplayer>.Instance).StartCoroutine(Singleton<TextDisplayer>.Instance.ShowThenClear(text, 2f, 0f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null));
		}

		public static void ShuffleChoice(List<CardChoice> list)
		{
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = rng.Next(num + 1);
				CardChoice value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}

		public static CardInfo GetRandomChoosableCardWithSunCost(int randomSeed)
		{
			List<CardInfo> list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => CardExtensions.GetExtendedProperty(x, "SunCost") != null);
			if (list.Count == 0)
			{
				return null;
			}
			return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ZephtSun";

		public const string PLUGIN_NAME = "ZephtSun";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}