Decompiled source of TVFsBosses v1.0.0

TVFsBosses.dll

Decompiled a day 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 DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Encounters;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Regions;
using Microsoft.CodeAnalysis;
using Pixelplacement;
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("TVFsBosses")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Placeholder description")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TVFsBosses")]
[assembly: AssemblyTitle("TVFsBosses")]
[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 TVFsBosses
{
	[BepInPlugin("tvflabs.inscryption.TVFsBosses", "TVFsBosses", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public class TVFWoodcarverColoredEmission : CardAppearanceBehaviour
		{
			public override void ApplyAppearance()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				if (((CardAppearanceBehaviour)this).Card.Info.tribes.Count > 1)
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.nearWhite);
				}
				else if (((CardAppearanceBehaviour)this).Card.Info.tribes.Contains((Tribe)2))
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.blue);
				}
				else if (((CardAppearanceBehaviour)this).Card.Info.tribes.Contains((Tribe)3))
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.darkLimeGreen);
				}
				else if (((CardAppearanceBehaviour)this).Card.Info.tribes.Contains((Tribe)4))
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.yellow);
				}
				else if (((CardAppearanceBehaviour)this).Card.Info.tribes.Contains((Tribe)5))
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.red);
				}
				else if (((CardAppearanceBehaviour)this).Card.Info.tribes.Contains((Tribe)6))
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.purple);
				}
				else
				{
					((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.glowSeafoam);
				}
			}

			public override void ResetAppearance()
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				((CardAppearanceBehaviour)this).Card.StatsLayer.SetEmissionColor(GameColors.Instance.glowSeafoam);
			}
		}

		public class TVFWoodcarverBoss : Part1BossOpponent
		{
			public static readonly Type ID = OpponentManager.Add("tvflabs.inscryption.TVFsBosses", "TVFWoodcarverBoss", TVFWoodcarverBossSequencer.ID, typeof(TVFWoodcarverBoss), new List<Texture2D>(4)
			{
				TextureHelper.GetImageAsTexture("Node_TVFWoodcarverBoss_1.png", (FilterMode)0),
				TextureHelper.GetImageAsTexture("Node_TVFWoodcarverBoss_2.png", (FilterMode)0),
				TextureHelper.GetImageAsTexture("Node_TVFWoodcarverBoss_3.png", (FilterMode)0),
				TextureHelper.GetImageAsTexture("Node_TVFWoodcarverBoss_4.png", (FilterMode)0)
			}).Id;

			private Color oldFogColor = GameColors.Instance.nearWhite;

			private List<Tribe> tribes = new List<Tribe>(5)
			{
				(Tribe)2,
				(Tribe)3,
				(Tribe)4,
				(Tribe)5,
				(Tribe)6
			};

			private List<Vector3> totemPositions = new List<Vector3>(5)
			{
				new Vector3(0f, 5f, 4.3f),
				new Vector3(1.2f, 5f, 4.4f),
				new Vector3(2.3f, 5f, 4.4f),
				new Vector3(3.1f, 5f, 3.4f),
				new Vector3(3.9f, 5f, 2.4f)
			};

			private List<Vector3> totemRotations = new List<Vector3>(5)
			{
				new Vector3(0f, 172f, 0f),
				new Vector3(0f, 200f, 0f),
				new Vector3(0f, 202f, 0f),
				new Vector3(0f, 210f, 0f),
				new Vector3(0f, 233f, 0f)
			};

			private List<OpponentTotem> tribeTotems = new List<OpponentTotem>(5) { null, null, null, null, null };

			private List<Color> totemColors = new List<Color>(5)
			{
				GameColors.Instance.blue,
				GameColors.Instance.darkLimeGreen,
				GameColors.Instance.yellow,
				GameColors.Instance.red,
				GameColors.Instance.purple
			};

			private List<Ability> currentAbilitiesForTribes = new List<Ability>(5)
			{
				(Ability)0,
				(Ability)0,
				(Ability)0,
				(Ability)0,
				(Ability)0
			};

			public override string DefeatedPlayerDialogue => "...";

			public override Color InteractablesGlowColor => GameColors.Instance.lightGray;

			public override IEnumerator IntroSequence(EncounterData encounter)
			{
				AudioController.Instance.FadeOutLoop(0.75f, Array.Empty<int>());
				RunState.CurrentMapRegion.FadeOutAmbientAudio();
				yield return ((Part1BossOpponent)this).ReducePlayerLivesSequence();
				yield return (object)new WaitForSeconds(0.25f);
				Singleton<ViewManager>.Instance.SwitchToView((View)19, false, true);
				yield return (object)new WaitForSeconds(0.5f);
				GameObject gameObject = Object.Instantiate<GameObject>(ResourceBank.Get<GameObject>("Prefabs/CardBattle/" + ((Part1BossOpponent)this).BossSkullPrefabId), ((Component)this).transform);
				base.bossSkull = gameObject.GetComponent<BossSkull>();
				yield return (object)new WaitForSeconds(0.166f);
				((Part1BossOpponent)this).SetSceneEffectsShown(true);
				((Part1BossOpponent)this).SpawnScenery("ForestTableEffects");
				yield return (object)new WaitForSeconds(0.5f);
				AudioController.Instance.PlaySound2D("prospector_trees_enter", (MixerGroup)4, 0.2f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true);
				yield return (object)new WaitForSeconds(0.25f);
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent(woodcarverPreIntroDialogue.id, (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				yield return (object)new WaitForSeconds(0.15f);
				LeshyAnimationController.Instance.PutOnMask((Mask)1, false);
				yield return (object)new WaitForSeconds(1.5f);
				yield return ((Part1BossOpponent)this).FaceZoomSequence();
				yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent(woodcarverIntroDialogue.id, (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true);
				yield return AssembleTotems();
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}

			public override IEnumerator OutroSequence(bool wasDefeated)
			{
				if (!wasDefeated)
				{
					base.bossSkull.ExitSimple();
					yield return (object)new WaitForSeconds(0.1f);
					RemoveTotems();
				}
			}

			public override void SetSceneEffectsShown(bool shown)
			{
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				Singleton<TableVisualEffectsManager>.Instance.SetFogPlaneShown(shown);
				Singleton<CameraEffects>.Instance.SetFogEnabled(shown);
				if (shown)
				{
					oldFogColor = new Color(Singleton<CameraEffects>.Instance.fog.color.r, Singleton<CameraEffects>.Instance.fog.color.g, Singleton<CameraEffects>.Instance.fog.color.b, Singleton<CameraEffects>.Instance.fog.color.a);
					Singleton<CameraEffects>.Instance.SetFogAlpha(0f);
					Singleton<CameraEffects>.Instance.TweenFogAlpha(0.75f, 2f);
					Singleton<CameraEffects>.Instance.fog.color = GameColors.Instance.nearWhite;
					Color gray = GameColors.Instance.gray;
					gray.a = 0.5f;
					Singleton<TableVisualEffectsManager>.Instance.ChangeTableColors(GameColors.Instance.gray, GameColors.Instance.nearWhite, ((Part1Opponent)this).InteractablesGlowColor, gray, GameColors.Instance.gray, ((Part1Opponent)this).InteractablesGlowColor, GameColors.Instance.nearWhite, GameColors.Instance.nearWhite, GameColors.Instance.brightNearWhite);
				}
				else
				{
					RemoveTotems();
					Singleton<CameraEffects>.Instance.fog.color = oldFogColor;
					Singleton<TableVisualEffectsManager>.Instance.ResetTableColors();
				}
			}

			private IEnumerator AssembleTotems()
			{
				for (int i = 0; i < tribes.Count; i++)
				{
					TotemItemData totemData = ScriptableObject.CreateInstance<TotemItemData>();
					totemData.top = new TotemTopData(tribes[i]);
					totemData.bottom = new TotemBottomData();
					totemData.bottom.effect = (TotemEffect)0;
					totemData.bottom.effectParams = new EffectParameters();
					totemData.bottom.effectParams.ability = (Ability)0;
					Color c = totemColors[i];
					bool particlesActive = false;
					GameObject gameObject = Object.Instantiate<GameObject>(ResourceBank.Get<GameObject>("Prefabs/Items/CompositeTotem_Opponent"), ((Component)this).transform);
					gameObject.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
					OpponentTotem newTotem = gameObject.GetComponent<OpponentTotem>();
					tribeTotems[i] = newTotem;
					((Component)newTotem).transform.position = totemPositions[i];
					((Component)newTotem).transform.eulerAngles = totemRotations[i];
					yield return (object)new WaitForSeconds(0.18f);
					Singleton<OpponentAnimationController>.Instance.SetLookTarget(((Component)newTotem).transform, Vector3.up * 2f + Vector3.back * 2f);
					((Item)newTotem).SetData((ItemData)(object)totemData);
					newTotem.SetColor(c);
					((Item)newTotem).Anim.Play("assemble", 0, 0f);
					yield return (object)new WaitForSeconds(0.9f);
					((Item)newTotem).ShowHighlighted(true, true);
					Singleton<TableVisualEffectsManager>.Instance.ThumpTable(0.2f);
					newTotem.SetEffectsActive(particlesActive, true);
					AudioController.Instance.PlaySound2D("metal_object_up#2", (MixerGroup)4, 1f, 0.25f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
				}
				Singleton<OpponentAnimationController>.Instance.ClearLookTarget();
			}

			private void RemoveTotems()
			{
				foreach (OpponentTotem tribeTotem in tribeTotems)
				{
					if ((Object)(object)tribeTotem != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)tribeTotem).gameObject);
					}
				}
			}

			public override IEnumerator StartNewPhaseSequence()
			{
				if (((Part1BossOpponent)this).HasGrizzlyGlitchPhase(int.MinValue))
				{
					yield return ((Part1BossOpponent)this).GrizzlyGlitchSequence();
					yield break;
				}
				Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
				yield return ((Opponent)this).ClearBoard();
				yield return ((Opponent)this).ClearQueue();
				foreach (Ability sigil in currentAbilitiesForTribes)
				{
					if ((int)sigil == 0)
					{
						yield return RandomizeTotemSigils();
						break;
					}
				}
				PlayableCard amalgamCard = CardSpawner.SpawnPlayableCard(CardLoader.GetCardByName("Amalgam"));
				amalgamCard.SetIsOpponentCard(true);
				Singleton<TurnManager>.Instance.Opponent.ModifySpawnedCard(amalgamCard);
				((MonoBehaviour)this).StartCoroutine(AddTotemSigilsToCard(amalgamCard, playAnimation: false));
				yield return Singleton<BoardManager>.Instance.TransitionAndResolveCreatedCard(amalgamCard, Singleton<BoardManager>.Instance.GetSlots(false)[0], 0.1f, true);
				foreach (CardSlot slot in Singleton<BoardManager>.Instance.GetSlots(true))
				{
					if ((Object)(object)slot.Card != (Object)null)
					{
						yield return Singleton<BoardManager>.Instance.AssignCardToSlot(amalgamCard, slot.opposingSlot, 0.1f, (Action)null, true);
						CardModificationInfo removeFlyingMod = null;
						if (amalgamCard.HasAbility((Ability)19))
						{
							removeFlyingMod = new CardModificationInfo();
							removeFlyingMod.negateAbilities.Add((Ability)19);
							amalgamCard.AddTemporaryMod(removeFlyingMod);
						}
						yield return Singleton<TurnManager>.Instance.CombatPhaseManager.SlotAttackSlot(amalgamCard.Slot, slot, 0f);
						if (removeFlyingMod != null)
						{
							amalgamCard.RemoveTemporaryMod(removeFlyingMod, true);
						}
						yield return (object)new WaitForSeconds(0.25f);
					}
				}
				if ((Object)(object)amalgamCard.slot == (Object)null)
				{
					yield return Singleton<BoardManager>.Instance.AssignCardToSlot(amalgamCard, Singleton<BoardManager>.Instance.GetSlots(false)[0], 0.1f, (Action)null, true);
				}
				yield return (object)new WaitForSeconds(0.25f);
				if (amalgamCard.HasAbility((Ability)13) || amalgamCard.HasAbility((Ability)89))
				{
					foreach (Tuple<Ability, AbilityBehaviour> abilityTuple in amalgamCard.TriggerHandler.triggeredAbilities)
					{
						if (abilityTuple.Item2 is Submerge)
						{
							AbilityBehaviour item = abilityTuple.Item2;
							yield return ((TriggerReceiver)((item is Submerge) ? item : null)).OnTurnEnd(false);
							Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
						}
					}
				}
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}

			public IEnumerator AddTotemSigilsToCard(PlayableCard card, bool playAnimation)
			{
				List<CardModificationInfo> modsToRemove = new List<CardModificationInfo>();
				foreach (CardModificationInfo tempMod in card.TemporaryMods)
				{
					if (tempMod.fromTotem)
					{
						modsToRemove.Add(tempMod);
					}
				}
				foreach (CardModificationInfo tempMod2 in modsToRemove)
				{
					card.RemoveTemporaryMod(tempMod2, true);
				}
				int tribes = 0;
				if (CardExtensions.IsOfTribe(card, (Tribe)2))
				{
					tribes++;
					CardModificationInfo sigilMod = new CardModificationInfo();
					CardModificationInfoExtensions.AddAbilities(sigilMod, (Ability[])(object)new Ability[1] { (Ability)(int)currentAbilitiesForTribes[0] });
					sigilMod.fromTotem = true;
					card.AddTemporaryMod(sigilMod);
				}
				if (CardExtensions.IsOfTribe(card, (Tribe)3))
				{
					tribes++;
					CardModificationInfo sigilMod5 = new CardModificationInfo();
					CardModificationInfoExtensions.AddAbilities(sigilMod5, (Ability[])(object)new Ability[1] { (Ability)(int)currentAbilitiesForTribes[1] });
					sigilMod5.fromTotem = true;
					card.AddTemporaryMod(sigilMod5);
				}
				if (CardExtensions.IsOfTribe(card, (Tribe)4))
				{
					tribes++;
					CardModificationInfo sigilMod4 = new CardModificationInfo();
					CardModificationInfoExtensions.AddAbilities(sigilMod4, (Ability[])(object)new Ability[1] { (Ability)(int)currentAbilitiesForTribes[2] });
					sigilMod4.fromTotem = true;
					card.AddTemporaryMod(sigilMod4);
				}
				if (CardExtensions.IsOfTribe(card, (Tribe)5))
				{
					tribes++;
					CardModificationInfo sigilMod3 = new CardModificationInfo();
					CardModificationInfoExtensions.AddAbilities(sigilMod3, (Ability[])(object)new Ability[1] { (Ability)(int)currentAbilitiesForTribes[3] });
					sigilMod3.fromTotem = true;
					card.AddTemporaryMod(sigilMod3);
				}
				if (CardExtensions.IsOfTribe(card, (Tribe)6))
				{
					tribes++;
					CardModificationInfo sigilMod2 = new CardModificationInfo();
					CardModificationInfoExtensions.AddAbilities(sigilMod2, (Ability[])(object)new Ability[1] { (Ability)(int)currentAbilitiesForTribes[4] });
					sigilMod2.fromTotem = true;
					card.AddTemporaryMod(sigilMod2);
				}
				if (tribes > 0)
				{
					((Card)card).ApplyAppearanceBehaviours(new List<Appearance>(1) { GuidManager.GetEnumValue<Appearance>("tvflabs.inscryption.TVFsBosses", "TVFWoodcarverColoredEmission") });
				}
				int numSigilsFromTotem = 0;
				foreach (CardModificationInfo cardMod in card.TemporaryMods)
				{
					if (cardMod.fromTotem)
					{
						numSigilsFromTotem++;
					}
				}
				if (playAnimation)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)6, false, true);
					if ((card.HasAbility((Ability)13) || card.HasAbility((Ability)89)) && ((Card)card).FaceDown && card.OnBoard)
					{
						foreach (Tuple<Ability, AbilityBehaviour> abilityTuple2 in card.TriggerHandler.triggeredAbilities)
						{
							if (abilityTuple2.Item2 is Submerge)
							{
								AbilityBehaviour item = abilityTuple2.Item2;
								yield return ((TriggerReceiver)((item is Submerge) ? item : null)).OnUpkeep(false);
								Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
							}
						}
					}
					else if (((Card)card).FaceDown && card.OnBoard)
					{
						Singleton<ViewManager>.Instance.SwitchToView((View)4, false, true);
						yield return (object)new WaitForSeconds(0.15f);
						((Card)card).SetFaceDown(false, false);
						card.UpdateFaceUpOnBoardEffects();
						yield return (object)new WaitForSeconds(0.3f);
					}
					yield return (object)new WaitForSeconds(0.15f);
					((Card)card).Anim.PlayTransformAnimation();
					yield return (object)new WaitForSeconds(0.15f);
					((Card)card).RenderCard();
					card.UpdateFaceUpOnBoardEffects();
					yield return (object)new WaitForSeconds(0.25f);
					if ((!card.HasAbility((Ability)13) && !card.HasAbility((Ability)89)) || ((Card)card).FaceDown || !card.OnBoard)
					{
						yield break;
					}
					foreach (Tuple<Ability, AbilityBehaviour> abilityTuple in card.TriggerHandler.triggeredAbilities)
					{
						if (abilityTuple.Item2 is Submerge)
						{
							AbilityBehaviour item2 = abilityTuple.Item2;
							yield return ((TriggerReceiver)((item2 is Submerge) ? item2 : null)).OnTurnEnd(false);
							Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
						}
					}
				}
				else
				{
					((Card)card).RenderCard();
				}
			}

			public IEnumerator RandomizeTotemSigils()
			{
				int num = (int)Mathf.Ceil((float)Singleton<TurnManager>.Instance.BattleNodeData.difficulty / 5f);
				List<Ability> learnedAbilities = AbilitiesUtil.GetLearnedAbilities(true, num - 1, num, (AbilityMetaCategory)1);
				List<Ability> alreadyUsedAbilities = new List<Ability>();
				for (int j = 0; j < currentAbilitiesForTribes.Count; j++)
				{
					List<Ability> redundantAbilities = TotemsUtil.GetRedundantAbilitiesForTribe(tribes[j]);
					Ability ability = (Ability)15;
					List<Ability> abilityList = new List<Ability>();
					foreach (Ability ab3 in learnedAbilities)
					{
						if (!redundantAbilities.Contains(ab3) && !alreadyUsedAbilities.Contains(ab3))
						{
							abilityList.Add(ab3);
						}
					}
					if (abilityList.Count == 0)
					{
						foreach (Ability ab2 in learnedAbilities)
						{
							if (!redundantAbilities.Contains(ab2))
							{
								abilityList.Add(ab2);
							}
						}
					}
					if (abilityList.Count == 0)
					{
						foreach (Ability ab in learnedAbilities)
						{
							abilityList.Add(ab);
						}
					}
					if (abilityList.Count > 0)
					{
						ability = abilityList[SeededRandom.Range(0, abilityList.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
						SaveFile saveFile = SaveManager.SaveFile;
						saveFile.randomSeed++;
					}
					currentAbilitiesForTribes[j] = ability;
					alreadyUsedAbilities.Add(ability);
				}
				Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true);
				for (int i = 0; i < tribeTotems.Count; i++)
				{
					if (!(((Item)tribeTotems[i]).Data is TotemItemData))
					{
						continue;
					}
					ItemData data = ((Item)tribeTotems[i]).Data;
					((TotemItemData)((data is TotemItemData) ? data : null)).bottom.effectParams.ability = currentAbilitiesForTribes[i];
					CompositeTotemPiece[] pieces = ((Component)tribeTotems[i]).GetComponentsInChildren<CompositeTotemPiece>();
					CompositeTotemPiece[] array = pieces;
					foreach (CompositeTotemPiece piece in array)
					{
						if (((Item)piece).Data is TotemBottomData)
						{
							Singleton<OpponentAnimationController>.Instance.SetLookTarget(((Component)tribeTotems[i]).transform, Vector3.up * 2f + Vector3.back * 2f);
							yield return (object)new WaitForSeconds(0.1f);
							Color onColor = new Color(piece.EmissionColor.r, piece.EmissionColor.g, piece.EmissionColor.b, 1f);
							Color offColor = Color.black;
							offColor.a = 0f;
							AudioController.Instance.PlaySound2D("totem_activate", (MixerGroup)4, 1f, 0.25f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
							Tween.ShaderColor(piece.emissiveRenderer.material, "_EmissionColor", offColor, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
							yield return (object)new WaitForSeconds(0.2f);
							? val = piece;
							ItemData data2 = ((Item)tribeTotems[i]).Data;
							((Item)val).SetData((ItemData)(object)((TotemItemData)((data2 is TotemItemData) ? data2 : null)).bottom);
							Tween.ShaderColor(piece.emissiveRenderer.material, "_EmissionColor", onColor, 0.2f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true);
							yield return (object)new WaitForSeconds(0.2f);
						}
					}
				}
				Singleton<OpponentAnimationController>.Instance.ClearLookTarget();
				bool addedSigilsToAnything = false;
				foreach (PlayableCard card in ((Opponent)this).Queue)
				{
					((MonoBehaviour)this).StartCoroutine(AddTotemSigilsToCard(card, playAnimation: true));
					addedSigilsToAnything = true;
				}
				foreach (CardSlot cardSlot in Singleton<BoardManager>.Instance.OpponentSlotsCopy)
				{
					if ((Object)(object)cardSlot.Card != (Object)null)
					{
						((MonoBehaviour)this).StartCoroutine(AddTotemSigilsToCard(cardSlot.Card, playAnimation: true));
						addedSigilsToAnything = true;
					}
				}
				if (addedSigilsToAnything)
				{
					Singleton<ViewManager>.Instance.SwitchToView((View)6, false, true);
					yield return (object)new WaitForSeconds(0.75f);
				}
				Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
			}
		}

		public class TVFWoodcarverBossSequencer : Part1BossBattleSequencer
		{
			public static readonly string ID = SpecialSequenceManager.Add("tvflabs.inscryption.TVFsBosses", "TVFWoodcarverBossSequencer", typeof(TVFWoodcarverBossSequencer)).Id;

			public override Type BossType => TVFWoodcarverBoss.ID;

			public override StoryEvent DefeatedStoryEvent => GuidManager.GetEnumValue<StoryEvent>("tvflabs.inscryption.TVFsBosses", "TVFWoodcarverDefeated");

			public override EncounterData BuildCustomEncounter(CardBattleNodeData nodeData)
			{
				EncounterData val = ((BossBattleSequencer)this).BuildCustomEncounter(nodeData);
				val.opponentTurnPlan = EncounterBuilder.BuildOpponentTurnPlan(GetRandomCardsOfAllTribes(), nodeData.difficulty, true);
				return val;
			}

			public override IEnumerator OnTurnEnd(bool playerTurnEnd)
			{
				if (Singleton<TurnManager>.Instance.Opponent is TVFWoodcarverBoss && (!((Part1BossOpponent)(Singleton<TurnManager>.Instance.Opponent as TVFWoodcarverBoss)).HasGrizzlyGlitchPhase(int.MinValue) || ((Opponent)(Singleton<TurnManager>.Instance.Opponent as TVFWoodcarverBoss)).NumLives >= 2))
				{
					yield return (Singleton<TurnManager>.Instance.Opponent as TVFWoodcarverBoss).RandomizeTotemSigils();
				}
			}

			public override bool RespondsToTurnEnd(bool playerTurnEnd)
			{
				return !playerTurnEnd;
			}

			private EncounterBlueprintData GetRandomCardsOfAllTribes()
			{
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Invalid comparison between Unknown and I4
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Invalid comparison between Unknown and I4
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0250: Unknown result type (might be due to invalid IL or missing references)
				//IL_031e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0287: Unknown result type (might be due to invalid IL or missing references)
				//IL_028d: Invalid comparison between Unknown and I4
				//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0447: Unknown result type (might be due to invalid IL or missing references)
				//IL_0291: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: Invalid comparison between Unknown and I4
				//IL_0370: Unknown result type (might be due to invalid IL or missing references)
				//IL_0375: Unknown result type (might be due to invalid IL or missing references)
				//IL_0378: Unknown result type (might be due to invalid IL or missing references)
				//IL_0499: Unknown result type (might be due to invalid IL or missing references)
				//IL_049e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03af: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b5: Invalid comparison between Unknown and I4
				//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04de: Invalid comparison between Unknown and I4
				//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bf: Invalid comparison between Unknown and I4
				//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e8: Invalid comparison between Unknown and I4
				EncounterBlueprintData val = ScriptableObject.CreateInstance<EncounterBlueprintData>();
				List<Tribe> list = new List<Tribe>(5)
				{
					(Tribe)3,
					(Tribe)4,
					(Tribe)5,
					(Tribe)2,
					(Tribe)6
				};
				int count = list.Count;
				for (int i = 0; i < count * 2; i++)
				{
					if (list.Count == 0)
					{
						list = new List<Tribe>(5)
						{
							(Tribe)3,
							(Tribe)4,
							(Tribe)5,
							(Tribe)2,
							(Tribe)6
						};
					}
					Tribe item = list[SeededRandom.Range(0, list.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
					List<CardInfo> list2 = new List<CardInfo>();
					foreach (CardInfo item2 in CardManager.AllCardsCopy)
					{
						if (!item2.metaCategories.Contains((CardMetaCategory)0) || (int)item2.temple != 0 || !item2.tribes.Contains(item) || item2.CostTier >= 2 || item2.metaCategories.Contains((CardMetaCategory)3))
						{
							continue;
						}
						bool flag = false;
						foreach (Ability ability in item2.Abilities)
						{
							if (!AbilitiesUtil.GetInfo(ability).opponentUsable)
							{
								flag = true;
							}
						}
						if ((int)item2.SpecialStatIcon == 2 || (int)item2.SpecialStatIcon == 6)
						{
							flag = true;
						}
						if (!flag)
						{
							list2.Add(item2);
						}
					}
					List<CardInfo> list3 = new List<CardInfo>();
					foreach (CardInfo item3 in CardManager.AllCardsCopy)
					{
						if (!item3.metaCategories.Contains((CardMetaCategory)0) || (int)item3.temple != 0 || !item3.tribes.Contains(item) || item3.CostTier <= 1 || item3.metaCategories.Contains((CardMetaCategory)3))
						{
							continue;
						}
						bool flag2 = false;
						foreach (Ability ability2 in item3.Abilities)
						{
							if (!AbilitiesUtil.GetInfo(ability2).opponentUsable)
							{
								flag2 = true;
							}
						}
						if ((int)item3.SpecialStatIcon == 2 || (int)item3.SpecialStatIcon == 6)
						{
							flag2 = true;
						}
						if (!flag2)
						{
							list3.Add(item3);
						}
					}
					if (list2.Count == 0)
					{
						foreach (CardInfo item4 in CardManager.AllCardsCopy)
						{
							if (!item4.metaCategories.Contains((CardMetaCategory)0) || (int)item4.temple != 0 || item4.CostTier >= 2 || item4.metaCategories.Contains((CardMetaCategory)3) || item4.tribes.Count != 1)
							{
								continue;
							}
							bool flag3 = false;
							foreach (Ability ability3 in item4.Abilities)
							{
								if (!AbilitiesUtil.GetInfo(ability3).opponentUsable)
								{
									flag3 = true;
								}
							}
							if ((int)item4.SpecialStatIcon == 2 || (int)item4.SpecialStatIcon == 6)
							{
								flag3 = true;
							}
							if (!flag3)
							{
								list2.Add(item4);
							}
						}
					}
					if (list3.Count == 0)
					{
						foreach (CardInfo item5 in CardManager.AllCardsCopy)
						{
							if (!item5.metaCategories.Contains((CardMetaCategory)0) || (int)item5.temple != 0 || item5.CostTier <= 1 || item5.metaCategories.Contains((CardMetaCategory)3) || item5.tribes.Count != 1)
							{
								continue;
							}
							bool flag4 = false;
							foreach (Ability ability4 in item5.Abilities)
							{
								if (!AbilitiesUtil.GetInfo(ability4).opponentUsable)
								{
									flag4 = true;
								}
							}
							if ((int)item5.SpecialStatIcon == 2 || (int)item5.SpecialStatIcon == 6)
							{
								flag4 = true;
							}
							if (!flag4)
							{
								list3.Add(item5);
							}
						}
					}
					if (list2.Count == 0)
					{
						list2.Add(CardLoader.GetCardByName("Opossum"));
					}
					if (list3.Count == 0)
					{
						list3.Add(CardLoader.GetCardByName("Grizzly"));
					}
					CardInfo val2 = list2[SeededRandom.Range(0, list2.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
					SaveFile saveFile = SaveManager.SaveFile;
					saveFile.randomSeed++;
					CardInfo val3 = list3[SeededRandom.Range(0, list3.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
					SaveFile saveFile2 = SaveManager.SaveFile;
					saveFile2.randomSeed++;
					CardInfo val4 = list2[SeededRandom.Range(0, list2.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
					SaveFile saveFile3 = SaveManager.SaveFile;
					saveFile3.randomSeed++;
					CardInfo val5 = list3[SeededRandom.Range(0, list3.Count, SaveManager.SaveFile.GetCurrentRandomSeed())];
					SaveFile saveFile4 = SaveManager.SaveFile;
					saveFile4.randomSeed++;
					if (i < 2)
					{
						EncounterExtensions.AddTurn<EncounterBlueprintData>(val, (CardBlueprint[])(object)new CardBlueprint[1] { EncounterManager.NewCardBlueprint(((Object)val2).name, 0, true, 8, ((Object)val3).name, 1, 20) });
					}
					else
					{
						EncounterExtensions.AddTurn<EncounterBlueprintData>(val, (CardBlueprint[])(object)new CardBlueprint[2]
						{
							EncounterManager.NewCardBlueprint(((Object)val2).name, 0, true, 12, ((Object)val3).name, 1, 20),
							EncounterManager.NewCardBlueprint(((Object)val5).name, 0, false, 0, (string)null, 1, 20)
						});
					}
					list.Remove(item);
				}
				return val;
			}
		}

		[HarmonyPatch(typeof(CompositeTotemPiece), "SetIcon")]
		private class CompositeTotemPiece_SetIcon_Patch
		{
			private static bool Prefix(Ability ability, CompositeTotemPiece __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Invalid comparison between Unknown and I4
				if ((int)ability == 0)
				{
					((Component)__instance.emissiveRenderer).gameObject.SetActive(false);
					__instance.SetIconInteractable(false);
					return false;
				}
				((Component)__instance.emissiveRenderer).gameObject.SetActive(true);
				__instance.SetIconInteractable(Singleton<TurnManager>.Instance.IsPlayerMainPhase && Singleton<GlobalTriggerHandler>.Instance.StackSize == 0);
				return true;
			}
		}

		[HarmonyPatch(typeof(MapGenerator), "CreateNode")]
		private class MapGenerator_CreateNode_Patch
		{
			private static void Postfix(int x, int y, List<NodeData> nodesInRow, List<NodeData> previousNodes, int mapLength, MapGenerator __instance, ref NodeData __result)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Invalid comparison between Unknown and I4
				//IL_004c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
				if (AscensionSaveData.Data.ChallengeIsActive(woodcarverBossChallenge.Challenge.challengeType) && __result is BossBattleNodeData && (int)((BossBattleNodeData)/*isinst with value type is only supported in some contexts*/).bossType == 3)
				{
					NodeData obj = __result;
					((BossBattleNodeData)((obj is BossBattleNodeData) ? obj : null)).bossType = TVFWoodcarverBoss.ID;
					NodeData obj2 = __result;
					((CardBattleNodeData)((obj2 is BossBattleNodeData) ? obj2 : null)).specialBattleId = BossBattleSequencer.GetSequencerIdForBoss(TVFWoodcarverBoss.ID);
				}
			}
		}

		[HarmonyPatch(typeof(CardAbilityIcons), "UpdateAbilityIcons")]
		private class CardAbilityIcons_UpdateAbilityIcons_Patch
		{
			private static void Prefix(CardInfo info, List<CardModificationInfo> mods, PlayableCard playableCard, List<Ability> hiddenAbilities, CardAbilityIcons __instance)
			{
				//IL_0033: 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_0233: Unknown result type (might be due to invalid IL or missing references)
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				//IL_029f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0331: Unknown result type (might be due to invalid IL or missing references)
				//IL_035e: Unknown result type (might be due to invalid IL or missing references)
				int num = 0;
				foreach (CardModificationInfo mod in mods)
				{
					if (!mod.fromTotem)
					{
						continue;
					}
					foreach (Ability ability in mod.abilities)
					{
						num++;
					}
				}
				if (num > __instance.totemIcons.Count || num > __instance.emissiveTotemIcons.Count)
				{
					AbilityIconInteractable val = __instance.emissiveTotemIcons[0];
					AbilityIconInteractable val2 = __instance.totemIcons[0];
					for (int i = __instance.emissiveTotemIcons.Count; i < 5; i++)
					{
						GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
						__instance.emissiveTotemIcons.Add(val3.GetComponent<AbilityIconInteractable>());
					}
					for (int j = __instance.totemIcons.Count; j < 5; j++)
					{
						GameObject val4 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)val2).transform.parent);
						__instance.totemIcons.Add(val4.GetComponent<AbilityIconInteractable>());
					}
				}
				if (num == 1)
				{
					__instance.emissiveTotemIcons[0].OriginalLocalPosition = new Vector3(0.224f, 0.262f, 0f);
					((Component)__instance.emissiveTotemIcons[0]).transform.localScale = new Vector3(0.2957f, 0.1975f, 1f);
					__instance.totemIcons[0].OriginalLocalPosition = new Vector3(0.224f, 0.262f, 0f);
					((Component)__instance.totemIcons[0]).transform.localScale = new Vector3(0.2957f, 0.1975f, 1f);
					return;
				}
				List<Vector3> list = new List<Vector3>(5)
				{
					new Vector3(-0.33f, 0.493f, 0f),
					new Vector3(0f, 0.493f, 0f),
					new Vector3(0.33f, 0.493f, 0f),
					new Vector3(-0.184f, 0.164f, 0f),
					new Vector3(0.184f, 0.164f, 0f)
				};
				for (int k = 0; k < __instance.emissiveTotemIcons.Count; k++)
				{
					__instance.emissiveTotemIcons[k].OriginalLocalPosition = list[k];
					((Component)__instance.emissiveTotemIcons[k]).transform.localScale = new Vector3(0.2217f, 0.1481f, 1f);
				}
				for (int l = 0; l < __instance.totemIcons.Count; l++)
				{
					__instance.totemIcons[l].OriginalLocalPosition = list[l];
					((Component)__instance.totemIcons[l]).transform.localScale = new Vector3(0.2217f, 0.1481f, 1f);
				}
			}
		}

		private Harmony harmony = new Harmony("tvflabs.inscryption.TVFsBosses");

		private const string PluginGuid = "tvflabs.inscryption.TVFsBosses";

		private const string PluginName = "TVFsBosses";

		private const string PluginVersion = "1.0.0";

		private const string PluginPrefix = "TVFsBosses";

		private static Part1RegionData woodcarverRegion;

		private static EncounterBlueprintData woodcarverBlueprint;

		private static DialogueEvent woodcarverPreIntroDialogue;

		private static DialogueEvent woodcarverIntroDialogue;

		private static FullCardAppearanceBehaviour woodcarverColoredEmissionBehaviour;

		private static FullChallenge woodcarverBossChallenge;

		private void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded TVFsBosses!");
			harmony.PatchAll();
			woodcarverBlueprint = EncounterManager.New("TVFWoodcarverBossP1", true);
			woodcarverPreIntroDialogue = DialogueManager.GenerateEvent("tvflabs.inscryption.TVFsBosses", "tvfwoodcarverPreIntroDialogue", new List<CustomLine>(2)
			{
				CustomLine.op_Implicit("The [c:bR]Woodcarver[c:] emerged from the thicket."),
				CustomLine.op_Implicit("Her face looked somehow more stern than usual.")
			}, new List<List<CustomLine>>(2)
			{
				new List<CustomLine>(2)
				{
					CustomLine.op_Implicit("An ancient woman approached."),
					CustomLine.op_Implicit("She looked intensely displeased with you.")
				},
				new List<CustomLine>(2)
				{
					CustomLine.op_Implicit("Nearby branches rustled as The [c:bR]Woodcarver[c:] revealed herself."),
					CustomLine.op_Implicit("She had no offerings this time.")
				}
			}, (MaxRepeatsBehaviour)0, (Speaker)1);
			woodcarverIntroDialogue = DialogueManager.GenerateEvent("tvflabs.inscryption.TVFsBosses", "tvfwoodcarverIntroDialogue", new List<CustomLine>(1) { CustomLine.op_Implicit("[c:bR]Leave.[c:]") }, new List<List<CustomLine>>(4)
			{
				new List<CustomLine>(1) { CustomLine.op_Implicit("Turn back.") },
				new List<CustomLine>(1) { CustomLine.op_Implicit("...") },
				new List<CustomLine>(1) { CustomLine.op_Implicit("You are not prepared.") },
				new List<CustomLine>(1) { CustomLine.op_Implicit("[c:bR]Leave.[c:]") }
			}, (MaxRepeatsBehaviour)0, (Speaker)1);
			woodcarverBossChallenge = ChallengeManager.Add("tvflabs.inscryption.TVFsBosses", "Woodcarver Boss", "The Prospector is replaced as the boss of the Woodlands.", 0, TextureHelper.GetImageAsTexture("Challenge_TVFWoodcarverBoss.png", (FilterMode)0), TextureHelper.GetImageAsTexture("Challenge_TVFWoodcarverBoss_a.png", (FilterMode)0), 0, false);
			woodcarverColoredEmissionBehaviour = CardAppearanceBehaviourManager.Add("tvflabs.inscryption.TVFsBosses", "TVFWoodcarverColoredEmission", typeof(TVFWoodcarverColoredEmission));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TVFsBosses";

		public const string PLUGIN_NAME = "TVFsBosses";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}