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.Bootstrap;
using BepInEx.Logging;
using DiskCardGame;
using GBC;
using HarmonyLib;
using Infiniscryption.Core.Helpers;
using Infiniscryption.PackManagement;
using Infiniscryption.SideDecks.Patchers;
using Infiniscryption.SideDecks.Sequences;
using Infiniscryption.SideDecks.Sigils;
using Infiniscryption.SideDecks.UserInterface;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Encounters;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Saves;
using Pixelplacement;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Infiniscryption.SideDecks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyDescription("Infinite Inscryption - Side Decks")]
[assembly: AssemblyTitle("Infiniscryption.SideDecks")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyProduct("Infiniscryption.SideDecks")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Infiniscryption.SideDecks
{
public static class CardHelpers
{
public static CardInfo SetSideDeck(this CardInfo info, CardTemple temple, int sideDeckValue)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected I4, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
CardExtensions.AddMetaCategories(info, (CardMetaCategory[])(object)new CardMetaCategory[1] { (CardMetaCategory)(int)SideDeckManager.SIDE_DECK });
info.temple = temple;
CardExtensions.SetExtendedProperty(info, "SideDeckValue", (object)sideDeckValue);
return info;
}
public static int GetSideDeckValue(this CardInfo info)
{
int? extendedPropertyAsInt = CardExtensions.GetExtendedPropertyAsInt(info, "SideDeckValue");
return extendedPropertyAsInt.HasValue ? extendedPropertyAsInt.Value : 0;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("zorro.inscryption.infiniscryption.sidedecks", "Infiniscryption Side Decks", "1.0")]
public class SideDecksPlugin : BaseUnityPlugin
{
public const string PluginGuid = "zorro.inscryption.infiniscryption.sidedecks";
public const string PluginName = "Infiniscryption Side Decks";
public const string PluginVersion = "1.0";
public const string CardPrefix = "ZSDD";
internal static ManualLogSource Log;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("zorro.inscryption.infiniscryption.sidedecks");
CustomCards.RegisterCustomCards(val);
val.PatchAll(typeof(SideDeckManager));
val.PatchAll(typeof(SideDeckSelectorScreen));
AscensionScreenManager.RegisterScreen<SideDeckSelectorScreen>();
SideDeckSelectionSequencer.Register();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Infiniscryption Side Decks is loaded!");
}
}
}
namespace Infiniscryption.SideDecks.UserInterface
{
[AscensionScreenSort(/*Could not decode attribute arguments.*/)]
public class SideDeckSelectorScreen : AscensionRunSetupScreenBase
{
private List<CardInfo> sideDeckCards;
public static SideDeckSelectorScreen Instance;
private static bool secondInitialized;
public const int SIDE_DECK_SIZE = 10;
private bool inHardMode = false;
private int scrollIndex = 0;
private GameObject selectedBorder;
public bool resetSelection = true;
public override string headerText => "Select a Side Deck";
public override bool showCardDisplayer => true;
public override bool showCardPanel => true;
public override void InitializeScreen(GameObject partialScreen)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Resources.Load<GameObject>("prefabs/gbcui/pixelselectionborder");
GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)base.cards[0]).gameObject.transform.parent);
val2.GetComponent<SpriteRenderer>().color = GameColors.Instance.brightNearWhite;
val2.AddComponent<PixelSnapElement>();
selectedBorder = val2;
Instance = this;
}
[HarmonyPatch(typeof(AscensionSaveData), "EndRun")]
[HarmonyPostfix]
public static void ResetSideDeckSelection()
{
if ((Object)(object)Instance != (Object)null)
{
SideDeckManager.SelectedSideDeck = "Squirrel";
Instance.resetSelection = true;
}
}
public override void LeftButtonClicked(MainInputInteractable button)
{
if (scrollIndex > 0)
{
scrollIndex--;
ShowPage();
}
}
public override void RightButtonClicked(MainInputInteractable button)
{
if ((scrollIndex + 1) * base.cards.Count < sideDeckCards.Count)
{
scrollIndex++;
ShowPage();
}
}
private void VisualUpdate(bool immediate = false)
{
CardInfo cardByName = CardLoader.GetCardByName(SideDeckManager.SelectedSideDeck);
string text = string.Format(Localization.Translate("{0} SELECTED"), Localization.ToUpper(cardByName.DisplayedNameLocalized));
((AscensionRunSetupScreenBase)this).DisplayChallengeInfo(text, SideDeckManager.SelectedSideDeckCost, immediate);
base.challengeHeaderDisplay.UpdateText();
foreach (PixelSelectableCard card in base.cards)
{
if (((Object)((Card)card).Info).name == SideDeckManager.SelectedSideDeck)
{
selectedBorder.SetActive(true);
selectedBorder.transform.SetParent(((Component)card).transform.Find("Base/PixelSnap"), false);
return;
}
}
selectedBorder.SetActive(false);
}
public override void CardClicked(PixelSelectableCard card)
{
SideDecksPlugin.Log.LogInfo((object)"Player selected sidedeck card");
if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null)
{
SideDecksPlugin.Log.LogInfo((object)("Setting selection to " + ((Object)((Card)card).Info).name));
SideDeckManager.SelectedSideDeck = ((Object)((Card)card).Info).name;
VisualUpdate();
}
}
public void ShowPage()
{
SideDecksPlugin.Log.LogInfo((object)$"Side deck screen: setting page {scrollIndex}. I have {base.cards.Count} card objects to play with");
int num = base.cards.Count * scrollIndex;
int count = Math.Min(base.cards.Count, sideDeckCards.Count - num);
((AscensionRunSetupScreenBase)this).ShowCards(sideDeckCards.GetRange(num, count));
}
public void InitializeCardSelection()
{
SideDecksPlugin.Log.LogInfo((object)"Setting card infos");
sideDeckCards = ((IEnumerable<string>)SideDeckManager.GetAllValidSideDeckCards()).Select((Func<string, CardInfo>)CardLoader.GetCardByName).ToList();
sideDeckCards.Sort((CardInfo a, CardInfo b) => a.GetSideDeckValue() - b.GetSideDeckValue());
((Component)base.leftButton).gameObject.SetActive(base.cards.Count < sideDeckCards.Count);
((Component)base.rightButton).gameObject.SetActive(base.cards.Count < sideDeckCards.Count);
}
public override void OnEnable()
{
((AscensionRunSetupScreenBase)this).OnEnable();
if (resetSelection || inHardMode != AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)12))
{
inHardMode = AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)12);
resetSelection = false;
scrollIndex = 0;
InitializeCardSelection();
ShowPage();
((AscensionRunSetupScreenBase)this).CardClicked(base.cards[0]);
}
VisualUpdate(immediate: true);
}
public override void CardCursorEntered(PixelSelectableCard card)
{
((AscensionRunSetupScreenBase)this).DisplayCardInfo(((Card)card).Info, string.Format("{0} (-{1} points)", ((Card)card).Info.DisplayedNameLocalized, CardExtensions.GetExtendedPropertyAsInt(((Card)card).Info, "SideDeckValue")), (string)null, false);
}
}
}
namespace Infiniscryption.SideDecks.Sigils
{
public class DoubleBlood : AbilityBehaviour
{
public override Ability Ability => AbilityID;
public static Ability AbilityID { get; private set; }
public static void Register(Harmony harmony)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
val.rulebookName = "Acceptable Sacrifice";
val.rulebookDescription = "Sacrificing [creature] will count as if two creatures were sacrificed";
val.canStack = true;
val.powerLevel = 2;
val.opponentUsable = false;
val.passive = false;
val.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
AbilityExtensions.SetPixelAbilityIcon(val, AssetHelper.LoadTexture("pixelability_doubleblood"), (FilterMode?)null);
AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.sidedecks", val, typeof(DoubleBlood), (Texture)(object)AssetHelper.LoadTexture("ability_doubleblood")).Id;
harmony.PatchAll(typeof(DoubleBlood));
}
[HarmonyPatch(typeof(BoardManager), "GetValueOfSacrifices")]
[HarmonyPostfix]
public static void AdjustForDoubleBlood(List<CardSlot> sacrifices, ref int __result)
{
foreach (CardSlot sacrifice in sacrifices)
{
if ((Object)(object)sacrifice != (Object)null && (Object)(object)sacrifice.Card != (Object)null && (Object)(object)((Component)sacrifice.Card).gameObject.GetComponent<DoubleBlood>() != (Object)null)
{
__result++;
}
}
}
}
public class DoubleTeeth : AbilityBehaviour
{
public override Ability Ability => AbilityID;
public static Ability AbilityID { get; private set; }
public static void Register(Harmony harmony)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
val.rulebookName = "Painful Entrance";
val.rulebookDescription = "[creature] will deal two damage to the player when it enters play.";
val.canStack = true;
val.powerLevel = 2;
val.opponentUsable = false;
val.passive = false;
val.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
AbilityExtensions.SetPixelAbilityIcon(val, AssetHelper.LoadTexture("pixelability_doubleteeth"), (FilterMode?)null);
AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.sidedecks", val, typeof(DoubleTeeth), (Texture)(object)AssetHelper.LoadTexture("ability_doubleteeth")).Id;
harmony.PatchAll(typeof(DoubleTeeth));
}
public override bool RespondsToResolveOnBoard()
{
return true;
}
public override IEnumerator OnResolveOnBoard()
{
yield return Singleton<LifeManager>.Instance.ShowDamageSequence(2, 2, true, 0f, (GameObject)null, 0f, true);
yield return (object)new WaitForSeconds(0.5f);
Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
}
}
public class Gelatinous : AbilityBehaviour
{
public override Ability Ability => AbilityID;
public static Ability AbilityID { get; private set; }
public static void Register(Harmony harmony)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
AbilityInfo val = ScriptableObject.CreateInstance<AbilityInfo>();
val.rulebookName = "Gelatinous";
val.rulebookDescription = "[creature] has no bones";
val.canStack = true;
val.powerLevel = -1;
val.opponentUsable = false;
val.passive = false;
val.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)0 };
AbilityExtensions.SetPixelAbilityIcon(val, AssetHelper.LoadTexture("pixelability_gelatinous"), (FilterMode?)null);
AbilityID = AbilityManager.Add("zorro.inscryption.infiniscryption.sidedecks", val, typeof(Gelatinous), (Texture)(object)AssetHelper.LoadTexture("ability_gelatinous")).Id;
harmony.PatchAll(typeof(Gelatinous));
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ResourcesManager), "AddBones")]
public static IEnumerator StopAddingBonesIfGelatinous(IEnumerator sequenceResult, CardSlot slot)
{
if (!((Object)(object)slot != (Object)null) || !((Object)(object)slot.Card != (Object)null) || !((Object)(object)((Component)slot.Card).gameObject != (Object)null) || !((Object)(object)((Component)slot.Card).gameObject.GetComponent<Gelatinous>() != (Object)null))
{
while (sequenceResult.MoveNext())
{
yield return sequenceResult.Current;
}
}
}
}
}
namespace Infiniscryption.SideDecks.Sequences
{
[HarmonyPatch]
public class SideDeckSelectionSequencer : CardChoicesSequencer, ICustomNodeSequence
{
public class SideDeckSelectionNode : CustomNodeData
{
public override void Initialize()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
((CustomNodeData)this).AddGenerationPrerequisite((Func<bool>)(() => !AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)12)));
((NodeData)this).GenerationPrerequisiteConditions.Add((SelectionCondition)new PreviousNodesContent(typeof(SideDeckSelectionNode), false));
((CustomNodeData)this).AddGenerationPrerequisite((Func<bool>)(() => RunState.Run.regionTier == 1 || RunState.Run.regionTier == 2));
((CustomNodeData)this).AddGenerationPrerequisite((Func<bool>)(() => AscensionSaveData.Data.ChallengeIsActive(ChallengeID)));
}
}
private static Traverse _parentContainer;
private string selectedCardName = null;
private Vector3 basePosition;
private readonly Vector3 BASE_ANCHOR = new Vector3(-2.2f, 5.01f, -0.12f);
private readonly Vector3 ROW_OFFSET = new Vector3(0f, 0f, -1.6f);
private readonly Vector3 COL_OFFSET = new Vector3(1.6f, 0f, 0f);
public static AscensionChallenge ChallengeID { get; private set; }
public static void Register()
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
NodeManager.Add<SideDeckSelectionSequencer, SideDeckSelectionNode>((Texture2D[])(object)new Texture2D[4]
{
TextureHelper.GetImageAsTexture("animated_sidedeck_1.png", typeof(SideDeckSelectionSequencer).Assembly, (FilterMode)0),
TextureHelper.GetImageAsTexture("animated_sidedeck_2.png", typeof(SideDeckSelectionSequencer).Assembly, (FilterMode)0),
TextureHelper.GetImageAsTexture("animated_sidedeck_3.png", typeof(SideDeckSelectionSequencer).Assembly, (FilterMode)0),
TextureHelper.GetImageAsTexture("animated_sidedeck_4.png", typeof(SideDeckSelectionSequencer).Assembly, (FilterMode)0)
}, (NodePosition)2);
ChallengeID = ChallengeManager.Add("zorro.inscryption.infiniscryption.sidedecks", "Side Deck Second Chance", "You are given the option to change your side deck on maps two and three", -10, AssetHelper.LoadTexture("assist_side_deck_toggle"), ChallengeManager.HAPPY_ACTIVATED_SPRITE, 0, false).Challenge.challengeType;
}
private static T GetCopiedField<T>(string fieldName) where T : class
{
if (_parentContainer == null)
{
object value = Traverse.Create((object)Singleton<SpecialNodeHandler>.Instance).Field("cardChoiceSequencer").GetValue();
_parentContainer = Traverse.Create((value is CardSingleChoicesSequencer) ? value : null);
}
return _parentContainer.Field(fieldName).GetValue() as T;
}
private void Initialize()
{
//IL_0028: 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)
if ((Object)(object)base.selectableCardPrefab == (Object)null)
{
base.selectableCardPrefab = GetCopiedField<GameObject>("selectableCardPrefab");
}
basePosition = ((Component)this).transform.position;
}
public override IEnumerator CardSelectionSequence(SpecialNodeData nodeData)
{
Initialize();
Singleton<ViewManager>.Instance.SwitchToView((View)3, false, true);
yield return (object)new WaitForSeconds(0.15f);
SideDecksPlugin.Log.LogInfo((object)"Leshy is ready to give us side deck options");
Singleton<ChallengeActivationUI>.Instance.ShowActivation(ChallengeID);
yield return Singleton<TextDisplayer>.Instance.PlayDialogueEvent("SideDeckIntro", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action<Line>)null);
Singleton<TableRuleBook>.Instance.SetOnBoard(true);
base.selectableCards = new List<SelectableCard>();
List<string> allValidCards = SideDeckManager.GetAllValidSideDeckCards();
allValidCards.Remove("Squirrel");
SideDecksPlugin.Log.LogInfo((object)("All known side deck cards: " + string.Join(",", allValidCards)));
selectedCardName = null;
int i = 0;
using (List<string>.Enumerator enumerator = allValidCards.GetEnumerator())
{
while (enumerator.MoveNext())
{
CreateSideDeckCard(cardName: enumerator.Current, index: i, totalCards: allValidCards.Count);
yield return (object)new WaitForSeconds(0.1f);
i++;
}
}
((CardChoicesSequencer)this).SetCollidersEnabled(true);
((CardChoicesSequencer)this).EnableViewDeck((ControlMode)11, basePosition);
yield return (object)new WaitUntil((Func<bool>)(() => !string.IsNullOrEmpty(selectedCardName)));
((CardChoicesSequencer)this).DisableViewDeck();
CleanUpCards();
Singleton<TableRuleBook>.Instance.SetOnBoard(false);
SideDeckManager.SelectedSideDeck = selectedCardName;
SaveManager.SaveToFile(false);
if ((Object)(object)Singleton<GameFlowManager>.Instance != (Object)null)
{
Singleton<GameFlowManager>.Instance.TransitionToGameState((GameState)1, (NodeData)null);
}
}
private Vector3 GetLocationForCard(int index, int totalCards)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: 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_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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)
int num = (int)Math.Ceiling((float)totalCards / 4f);
int num2 = 4;
if (totalCards < 4)
{
num2 = totalCards;
}
if (totalCards == 5 || totalCards == 6 || totalCards == 9)
{
num2 = 3;
}
Vector3 bASE_ANCHOR = BASE_ANCHOR;
float num3 = num switch
{
2 => 0.5f,
1 => 1f,
_ => 0f,
};
float num4 = num2 switch
{
2 => 1f,
3 => 0.5f,
4 => 0f,
_ => 1.5f,
};
num3 += (float)(index / num2);
num4 += (float)(index % num2);
return BASE_ANCHOR + Vector3.Scale(ROW_OFFSET, new Vector3(0f, 0f, num3)) + Vector3.Scale(COL_OFFSET, new Vector3(num4, 0f, 0f));
}
private void CreateSideDeckCard(int index, int totalCards, string cardName, float tweenDelay = 0f)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(base.selectableCardPrefab, ((Component)this).transform);
SelectableCard component = val.GetComponent<SelectableCard>();
((Component)component).gameObject.SetActive(true);
SideDecksPlugin.Log.LogInfo((object)"Starting to create card");
CardInfo cardByName = CardLoader.GetCardByName(cardName);
component.Initialize(cardByName, (Action<SelectableCard>)OnCardChosen, (Action<SelectableCard>)OnCardFlipped, true, (Action<SelectableCard>)base.OnCardInspected);
((Card)component).SetFaceDown(!ProgressionData.IntroducedCard(cardByName), false);
SideDecksPlugin.Log.LogInfo((object)"Calculating card location");
Vector3 locationForCard = GetLocationForCard(index, totalCards);
val.transform.localPosition = locationForCard + Vector3.forward * 6f;
val.transform.localScale = Vector3.Scale(val.transform.localScale, new Vector3(0.8f, 0.8f, 1f));
Tween.LocalPosition(val.transform, locationForCard, 0.2f, tweenDelay, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true);
Tween.Rotate(val.transform, new Vector3(0f, 0f, -2f + Random.value * 4f), (Space)1, 0.25f, tweenDelay, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true);
CustomCoroutine.WaitThenExecute(tweenDelay, (Action)((Card)component).Anim.PlayRiffleSound, false);
SideDecksPlugin.Log.LogInfo((object)"The card is on the table");
base.selectableCards.Add(component);
SideDecksPlugin.Log.LogInfo((object)"Done");
}
private void OnCardChosen(SelectableCard card)
{
if (selectedCardName == null)
{
((CardChoicesSequencer)this).SetCollidersEnabled(false);
selectedCardName = ((Object)((Card)card).Info).name;
}
}
private void OnCardFlipped(SelectableCard card)
{
if ((Object)(object)((Card)card).Info != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(TutorialTextSequence(card));
}
}
private IEnumerator TutorialTextSequence(SelectableCard card)
{
if (!ProgressionData.IntroducedCard(((Card)card).Info))
{
if (!string.IsNullOrEmpty(((Card)card).Info.description))
{
Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
Singleton<RuleBookController>.Instance.SetShown(false, true);
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(((Card)card).Info.description, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
}
ProgressionData.SetCardIntroduced(((Card)card).Info);
}
}
protected void CleanUpCards()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
((CardChoicesSequencer)this).ResetLocalRotations();
foreach (SelectableCard selectableCard in base.selectableCards)
{
((Card)selectableCard).SetInteractionEnabled(false);
Tween.Position(((Component)selectableCard).transform, ((Component)selectableCard).transform.position + Vector3.forward * 20f, 0.5f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true);
Object.Destroy((Object)(object)((Component)selectableCard).gameObject, 0.5f);
}
base.selectableCards.Clear();
}
public IEnumerator ExecuteCustomSequence(CustomNodeData nodeData)
{
yield return ((CardChoicesSequencer)this).CardSelectionSequence((SpecialNodeData)(object)nodeData);
}
[HarmonyAfter(new string[] { "cyantist.inscryption.api" })]
[HarmonyPostfix]
[HarmonyPatch(typeof(AscensionUnlockSchedule), "ChallengeIsUnlockedForLevel")]
public static void ValidP03Challenges(ref bool __result, AscensionChallenge challenge, int level)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
if (challenge == ChallengeID)
{
__result = (int)SideDeckManager.ScreenState == 0;
}
}
}
}
namespace Infiniscryption.SideDecks.Patchers
{
public static class CustomCards
{
public static readonly List<Ability> sideDeckableAbilities = new List<Ability>
{
(Ability)23,
(Ability)54,
(Ability)62,
(Ability)15,
(Ability)51
};
private static void RegisterCustomAbilities(Harmony harmony)
{
Gelatinous.Register(harmony);
DoubleTeeth.Register(harmony);
DoubleBlood.Register(harmony);
}
private static void RegisterMetacategoriesInner()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
PackManager.AddProtectedMetacategory(SideDeckManager.SIDE_DECK);
}
private static void RegisterMetacategories()
{
try
{
RegisterMetacategoriesInner();
}
catch (Exception)
{
SideDecksPlugin.Log.LogInfo((object)"Error registering pack manager exception - pack manager plugin not loaded. This is not a problem.");
}
}
internal static void RegisterCustomCards(Harmony harmony)
{
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Expected I4, but got Unknown
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
//IL_04e3: Expected I4, but got Unknown
//IL_0515: Unknown result type (might be due to invalid IL or missing references)
//IL_059b: Unknown result type (might be due to invalid IL or missing references)
//IL_05a1: Expected I4, but got Unknown
//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0637: Unknown result type (might be due to invalid IL or missing references)
//IL_0685: Unknown result type (might be due to invalid IL or missing references)
//IL_068a: Unknown result type (might be due to invalid IL or missing references)
//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
//IL_06bb: Invalid comparison between Unknown and I4
//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
//IL_06c1: Invalid comparison between Unknown and I4
//IL_073d: Unknown result type (might be due to invalid IL or missing references)
//IL_0740: Expected I4, but got Unknown
//IL_0746: Unknown result type (might be due to invalid IL or missing references)
//IL_074a: Invalid comparison between Unknown and I4
//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
//IL_06c7: Invalid comparison between Unknown and I4
//IL_0782: Unknown result type (might be due to invalid IL or missing references)
//IL_0786: Invalid comparison between Unknown and I4
//IL_0788: Unknown result type (might be due to invalid IL or missing references)
//IL_078c: Invalid comparison between Unknown and I4
//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0800: Expected I4, but got Unknown
//IL_078e: Unknown result type (might be due to invalid IL or missing references)
//IL_0792: Invalid comparison between Unknown and I4
RegisterCustomAbilities(harmony);
RegisterMetacategories();
CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "Squirrel").SetSideDeck((CardTemple)0, 0);
CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "Skeleton").SetSideDeck((CardTemple)1, 0);
CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "EmptyVessel").SetSideDeck((CardTemple)2, 0);
CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "LeapBot").SetSideDeck((CardTemple)2, 0);
CardExtensions.SetPixelPortrait(CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "AquaSquirrel"), AssetHelper.LoadTexture("pixelportrait_aquasquirrel"), (FilterMode?)null);
CardExtensions.SetPixelPortrait(CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "PeltHare"), AssetHelper.LoadTexture("pixelportrait_pelthare"), (FilterMode?)null);
CardExtensions.SetPixelPortrait(CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "PeltWolf"), AssetHelper.LoadTexture("pixelportrait_peltwolf"), (FilterMode?)null);
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
foreach (CardInfo item in cards.Where((CardInfo c) => c.HasTrait(SideDeckManager.BACKWARDS_COMPATIBLE_SIDE_DECK_MARKER)))
{
item.SetSideDeck(item.temple, 10);
item.traits.Remove(SideDeckManager.BACKWARDS_COMPATIBLE_SIDE_DECK_MARKER);
}
return cards;
};
CardExtensions.AddAbilities(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "TreeSquirrel", "Squirrel", 0, 1, "It's a squirrel that can block fliers").SetSideDeck((CardTemple)0, 5), Resources.Load<Texture2D>("art/cards/portraits/portrait_squirrel"), (FilterMode?)null), Resources.Load<Texture2D>("art/gbc/cards/pixelportraits/pixelportrait_squirrel"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)23 });
CardExtensions.AddTribes(CardExtensions.AddAbilities(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "BeeDrone", "Bee Drone", 1, 1, "For when you need just one point of damage").SetSideDeck((CardTemple)0, 10), Resources.Load<Texture2D>("art/cards/portraits/portrait_bee"), (FilterMode?)null), AssetHelper.LoadTexture("pixelportrait_bee"), (FilterMode?)null), (Ability[])(object)new Ability[2]
{
(Ability)19,
(Ability)35
}), (Tribe[])(object)new Tribe[1] { (Tribe)6 });
SpecialStatIcon antHealth = GuidManager.GetEnumValue<SpecialStatIcon>("julianperge.inscryption.specialAbilities.healthForAnts", "Ants (Health)");
CardExtensions.AddTribes(CardExtensions.AddTraits(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "AntDrone", "Ant Drone", 0, 0, "It's not much, but it's an ant.").SetSideDeck((CardTemple)0, 5), AssetHelper.LoadTexture("worker_ant"), (FilterMode?)null), AssetHelper.LoadTexture("pixelportrait_ant_worker"), (FilterMode?)null), (Trait[])(object)new Trait[1] { (Trait)11 }), (Tribe[])(object)new Tribe[1] { (Tribe)6 }).specialStatIcon = antHealth;
foreach (StatIconInfo allStatIconInfo in StatIconManager.AllStatIconInfos)
{
SideDecksPlugin.Log.LogInfo((object)$"Stat Icon: {allStatIconInfo.rulebookName} ({allStatIconInfo.iconType}), looking for {antHealth}");
}
StatIconManager.AllStatIconInfos.First((StatIconInfo si) => si.iconType == antHealth).pixelIconGraphic = Sprite.Create(Resources.Load<Texture2D>("art/gbc/cards/pixel_special_stat_icons"), new Rect(0f, 27f, 16f, 8f), new Vector2(0.5f, 0.5f));
CardExtensions.AddTribes(CardExtensions.AddAbilities(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "Puppy", "Puppy", 0, 1, "This energetic little puppy will dig up a fresh bone every turn").SetSideDeck((CardTemple)0, 10), AssetHelper.LoadTexture("digging_dog"), (FilterMode?)null), AssetHelper.LoadTexture("pixel_digging_dog"), (FilterMode?)null), (Ability[])(object)new Ability[2]
{
(Ability)3,
(Ability)28
}), (Tribe[])(object)new Tribe[1] { (Tribe)3 });
CardInfo val = CardExtensions.AddAbilities(CardExtensions.SetPortrait(CardManager.New("ZSDD", "SpareTentacle_Tail", "Tentacle", 0, 2, (string)null), AssetHelper.LoadTexture("squid_tail"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)Gelatinous.AbilityID });
val.temple = (CardTemple)0;
val.titleGraphic = (Texture)(object)Resources.Load<Texture2D>("art/cards/special/squid_title");
CardInfo val2 = CardExtensions.SetTail(CardExtensions.AddAbilities(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "SpareTentacle", "Spare Tentacle", 0, 2, "I've never seen that [c:bR]thing[c:] before, but I can tell there are no bones in it.").SetSideDeck((CardTemple)0, 10), AssetHelper.LoadTexture("squid_grunt"), (FilterMode?)null), AssetHelper.LoadTexture("pixelportrait_squidgrunt"), (FilterMode?)null), (Ability[])(object)new Ability[2]
{
(Ability)10,
(Ability)(int)Gelatinous.AbilityID
}), ((Object)val).name, AssetHelper.LoadTexture("squid_grunt_taillost"), (FilterMode?)null, (IEnumerable<CardModificationInfo>)null);
val2.temple = (CardTemple)0;
val2.titleGraphic = (Texture)(object)Resources.Load<Texture2D>("art/cards/special/squid_title");
CardExtensions.AddTribes(CardExtensions.SetExtendedProperty(CardExtensions.AddAbilities(CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "OneEyedGoat", "One-Eyed Goat", 0, 1, "This goat generates additional blood...for a price").SetSideDeck((CardTemple)0, 10), AssetHelper.LoadTexture("portrait_goat_double"), (FilterMode?)null), AssetHelper.LoadTexture("pixelportrait_one_eyed_goat"), (FilterMode?)null), (Ability[])(object)new Ability[1] { (Ability)(int)DoubleBlood.AbilityID }), "LifeCost", (object)2), (Tribe[])(object)new Tribe[1] { (Tribe)4 }).temple = (CardTemple)0;
CardInfo val3 = CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "AmalgamEgg", "Amalgam Egg", 0, 1, "I didn't realize this thing came from eggs").SetSideDeck((CardTemple)0, 10), AssetHelper.LoadTexture("egg"), (FilterMode?)null), AssetHelper.LoadTexture("pixel_egg"), (FilterMode?)null);
val3.temple = (CardTemple)0;
string eggName = ((Object)val3).name;
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_004d: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
CardInfo val4 = CardExtensions.CardByName((IEnumerable<CardInfo>)cards, eggName);
if ((Object)(object)val4 != (Object)null)
{
CardExtensions.AddTribes(val4, GuidManager.GetValues<Tribe>().ToArray());
}
val4.evolveParams = new EvolveParams
{
evolution = CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "Amalgam"),
turnsToEvolve = 1
};
val4.iceCubeParams = new IceCubeParams
{
creatureWithin = CardExtensions.CardByName((IEnumerable<CardInfo>)cards, "Amalgam")
};
CardExtensions.AddTraits(val4, (Trait[])(object)new Trait[1] { (Trait)11 });
return cards;
};
CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.BaseGameCards, "EmptyVessel").SetSideDeck((CardTemple)2, 0);
int? num;
foreach (Ability sideDeckableAbility in sideDeckableAbilities)
{
Ability current2 = sideDeckableAbility;
CardInfo obj = CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "EmptyVessel" + ((object)(Ability)(ref current2)).ToString(), "Empty Vessel", 0, 2, (string)null).SetSideDeck((CardTemple)2, ((int)current2 == 51) ? 20 : (((int)current2 == 15 || (int)current2 == 62) ? 10 : 5)), Resources.Load<Texture2D>("art/cards/part 3 portraits/portrait_emptyvessel"), (FilterMode?)null), TextureHelper.GetImageAsTexture("pixel_emptyvessel.png", typeof(CustomCards).Assembly, (FilterMode)0), (FilterMode?)null);
num = 1;
CardExtensions.AddAbilities(CardExtensions.SetCost(obj, (int?)0, (int?)0, num, (List<GemType>)null), (Ability[])(object)new Ability[1] { (Ability)(int)current2 });
if ((int)current2 != 23)
{
CardInfo obj2 = CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "LeapBot" + ((object)(Ability)(ref current2)).ToString(), "L33pB0t", 0, 2, (string)null).SetSideDeck((CardTemple)2, ((int)current2 == 51) ? 20 : (((int)current2 == 15 || (int)current2 == 62) ? 10 : 5)), Resources.Load<Texture2D>("art/cards/part 3 portraits/portrait_leapbot"), (FilterMode?)null), Resources.Load<Texture2D>("art/gbc/cards/pixelportraits/pixelportrait_leapingbot"), (FilterMode?)null);
num = 1;
CardExtensions.AddAbilities(CardExtensions.SetCost(obj2, (int?)0, (int?)0, num, (List<GemType>)null), (Ability[])(object)new Ability[2]
{
(Ability)23,
(Ability)(int)current2
});
}
}
CardInfo obj3 = CardExtensions.SetPixelPortrait(CardExtensions.SetPortrait(CardManager.New("ZSDD", "EmptyVesselSubmerge", "Emptier Vessel", 0, 2, (string)null), Resources.Load<Texture2D>("art/cards/part 3 portraits/portrait_emptyvessel"), (FilterMode?)null), TextureHelper.GetImageAsTexture("pixel_emptyvessel.png", typeof(CustomCards).Assembly, (FilterMode)0), (FilterMode?)null);
num = 1;
CardExtensions.AddAbilities(CardExtensions.SetCost(obj3, (int?)0, (int?)0, num, (List<GemType>)null), (Ability[])(object)new Ability[1] { (Ability)13 });
}
}
public static class SideDeckManager
{
public static Trait BACKWARDS_COMPATIBLE_SIDE_DECK_MARKER = (Trait)5103;
public static CardMetaCategory SIDE_DECK = GuidManager.GetEnumValue<CardMetaCategory>("zorro.inscryption.infiniscryption.sidedecks", "SideDeck");
private const string GRIMORA_MOD = "arackulele.inscryption.grimoramod";
private const string P03_MOD = "zorro.inscryption.infiniscryption.p03kayceerun";
private const string MAGNIFICUS_MOD = "silenceman.inscryption.magnificusmod";
private static readonly AscensionChallenge LEEPBOT_SIDEDECK = GuidManager.GetEnumValue<AscensionChallenge>("zorro.inscryption.infiniscryption.p03kayceerun", "LeepbotSidedeck");
internal static Dictionary<string, string> AcceptedScreenStates = new Dictionary<string, string>
{
{ "zorro.inscryption.infiniscryption.p03kayceerun", "zorro.inscryption.infiniscryption.p03kayceerun" },
{ "arackulele.inscryption.grimoramod", "arackulele.inscryption.grimoramod" },
{ "silenceman.inscryption.magnificusmod", "silenceman.inscryption.magnificusmodstarterdecks" }
};
public const int SIDE_DECK_SIZE = 10;
public static string SelectedSideDeck
{
get
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
string value = ModdedSaveManager.SaveData.GetValue("zorro.inscryption.infiniscryption.sidedecks", $"SideDeck.{ScreenState}.SelectedDeck");
if (string.IsNullOrEmpty(value))
{
return "Squirrel";
}
return value;
}
internal set
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
ModdedSaveManager.SaveData.SetValue("zorro.inscryption.infiniscryption.sidedecks", $"SideDeck.{ScreenState}.SelectedDeck", (object)value.ToString());
}
}
public static int SelectedSideDeckCost
{
get
{
CardInfo info = CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.AllCardsCopy, SelectedSideDeck);
return info.GetSideDeckValue();
}
}
internal static CardTemple ScreenState
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0125: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!string.IsNullOrEmpty(((Scene)(ref activeScene)).name))
{
string text = ((Scene)(ref activeScene)).name.ToLowerInvariant();
if (text.Contains("magnificus"))
{
return (CardTemple)3;
}
if (text.Contains("part3"))
{
return (CardTemple)2;
}
if (text.Contains("grimora"))
{
return (CardTemple)1;
}
if (text.Contains("part1"))
{
return (CardTemple)0;
}
}
foreach (string key in AcceptedScreenStates.Keys)
{
if (Chainloader.PluginInfos.ContainsKey(key))
{
string value = ModdedSaveManager.SaveData.GetValue(AcceptedScreenStates[key], "ScreenState");
if (!string.IsNullOrEmpty(value))
{
return (CardTemple)Enum.Parse(typeof(CardTemple), value);
}
}
}
return (CardTemple)0;
}
}
public static event Action<CardTemple, List<string>> ModifyValidSideDeckCards;
public static List<string> GetAllValidSideDeckCards()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Invalid comparison between Unknown and I4
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Invalid comparison between Unknown and I4
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
List<string> list = (from card in CardManager.AllCardsCopy
where card.metaCategories.Contains(SIDE_DECK) && card.temple == ScreenState
select ((Object)card).name).ToList();
if (AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)12))
{
if ((int)ScreenState == 0)
{
list = new List<string> { "AquaSquirrel" };
}
else if ((int)ScreenState == 2)
{
list = new List<string> { "ZSDD_EmptyVesselSubmerge" };
}
}
if ((int)ScreenState == 2)
{
if (AscensionSaveData.Data.ChallengeIsActive(LEEPBOT_SIDEDECK))
{
list.RemoveAll((string s) => s.Contains("EmptyVessel"));
}
else
{
list.RemoveAll((string s) => s.Contains("LeapBot"));
}
}
SideDeckManager.ModifyValidSideDeckCards?.Invoke(ScreenState, list);
return list;
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
public static bool ReplaceSideDeck(ref List<CardInfo> __result)
{
if (SaveFile.IsAscension)
{
__result = new List<CardInfo>();
string selectedSideDeck = SelectedSideDeck;
for (int i = 0; i < 10; i++)
{
__result.Add(CardLoader.GetCardByName(selectedSideDeck));
}
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static bool ReplaceGrimoraSideDeck(ref List<CardInfo> __result)
{
if (SaveFile.IsAscension)
{
__result = new List<CardInfo>();
string selectedSideDeck = SelectedSideDeck;
for (int i = 0; i < 10; i++)
{
__result.Add(CardLoader.GetCardByName(selectedSideDeck));
}
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(AscensionSaveData), "GetActiveChallengePoints")]
public static void ReduceChallengeIfCustomSideDeckSelected(ref int __result)
{
__result -= SelectedSideDeckCost;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(DialogueDataUtil), "ReadDialogueData")]
public static void CurseDialogue()
{
DialogueHelper.AddOrModifySimpleDialogEvent("SideDeckIntro", new string[1] { "Here you may replace the creatures in your [c:bR]side deck[c:]" });
}
[HarmonyPriority(100)]
[HarmonyPostfix]
[HarmonyPatch(typeof(Part3SaveData), "Initialize")]
private static void AddSideDeckAbilitiesWithMesh(ref Part3SaveData __instance)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
if (!SaveFile.IsAscension)
{
return;
}
CardInfo val = CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.AllCardsCopy, SelectedSideDeck);
foreach (Ability ability in val.Abilities)
{
AbilityInfo info = AbilitiesUtil.GetInfo(ability);
if ((Object)(object)info.mesh3D != (Object)null)
{
__instance.sideDeckAbilities.Add(ability);
}
}
}
[HarmonyPatch(typeof(Part3CardDrawPiles), "AddModsToVessel")]
[HarmonyPriority(100)]
[HarmonyPostfix]
private static void EnsureAllModsOnVessel(CardInfo info)
{
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
if (!SaveFile.IsAscension || !((Object)(object)info != (Object)null))
{
return;
}
CardInfo val = CardExtensions.CardByName((IEnumerable<CardInfo>)CardManager.AllCardsCopy, SelectedSideDeck);
string text = string.Join(", ", info.Abilities);
string text2 = string.Join(", ", val.Abilities);
SideDecksPlugin.Log.LogDebug((object)("Side deck card has " + text + " and needs " + text2));
foreach (IGrouping<Ability, Ability> group in from a in val.Abilities
group a by a)
{
int num = info.Abilities.Where((Ability a) => a == group.Key).Count();
int num2 = group.Count();
if (num < num2)
{
CardModificationInfo val2 = new CardModificationInfo();
val2.sideDeckMod = true;
val2.abilities = new List<Ability>();
val2.abilities.AddRange(Enumerable.Repeat<Ability>(group.Key, num2 - num));
info.mods.Add(val2);
}
}
}
}
}
namespace Core
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "Infiniscryption.Core";
public const string PLUGIN_NAME = "Infiniscryption.Core";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace Infiniscryption.Core.Helpers
{
public static class AssetHelper
{
public static string FindResourceName(string key, string type, Assembly target)
{
string value = "." + key.ToLowerInvariant() + "." + type.ToLowerInvariant();
string[] manifestResourceNames = target.GetManifestResourceNames();
foreach (string text in manifestResourceNames)
{
if (text.ToLowerInvariant().EndsWith(value))
{
return text;
}
}
return null;
}
private static byte[] GetResourceBytes(string key, string type, Assembly target)
{
string text = FindResourceName(key, type, target);
if (string.IsNullOrEmpty(text))
{
string text2 = "";
string[] manifestResourceNames = target.GetManifestResourceNames();
foreach (string text3 in manifestResourceNames)
{
text2 = text2 + "," + text3;
}
throw new InvalidDataException("Could not find resource matching " + key + ". This is what I have: " + text2);
}
using Stream stream = target.GetManifestResourceStream(text);
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
public static string GetResourceString(string key, string type)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = FindResourceName(key, type, executingAssembly);
if (string.IsNullOrEmpty(text))
{
string text2 = "";
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
foreach (string text3 in manifestResourceNames)
{
text2 = text2 + "," + text3;
}
throw new InvalidDataException("Could not find resource matching " + key + ". This is what I have: " + text2);
}
using Stream stream = executingAssembly.GetManifestResourceStream(text);
using StreamReader streamReader = new StreamReader(stream);
return streamReader.ReadToEnd();
}
public static Texture2D LoadTexture(string texture, FilterMode? filterMode = null)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2);
if (filterMode.HasValue)
{
((Texture)val).filterMode = filterMode.Value;
}
byte[] resourceBytes = GetResourceBytes(texture, "png", Assembly.GetExecutingAssembly());
ImageConversion.LoadImage(val, resourceBytes);
((Object)val).name = "Infiniscryption_" + texture;
return val;
}
private static string WriteWavToFile(string wavname)
{
byte[] resourceBytes = GetResourceBytes(wavname, "wav", Assembly.GetExecutingAssembly());
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), wavname + ".wav");
File.WriteAllBytes(text, resourceBytes);
return text;
}
public static void LoadAudioClip(string clipname, ManualLogSource log = null, string group = "Loops")
{
Traverse val = Traverse.Create((object)AudioController.Instance);
List<AudioClip> value = val.Field(group).GetValue<List<AudioClip>>();
if ((Object)(object)value.Find((AudioClip clip) => ((Object)clip).name.Equals(clipname)) != (Object)null)
{
return;
}
string text = WriteWavToFile(clipname);
try
{
if (log != null)
{
log.LogInfo((object)("About to get audio clip at file://" + text));
}
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)20);
try
{
audioClip.SendWebRequest();
while (audioClip.IsExecuting())
{
}
if (audioClip.isHttpError)
{
throw new InvalidOperationException("Bad request getting audio clip " + audioClip.error);
}
AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
((Object)content).name = clipname;
value.Add(content);
}
finally
{
((IDisposable)audioClip)?.Dispose();
}
}
finally
{
if (File.Exists(text))
{
File.Delete(text);
}
}
}
}
public static class AudioHelper
{
public struct AudioState
{
public int sourceNum;
public string clipName;
public float position;
public bool isPlaying;
public float volume;
}
public static List<AudioState> PauseAllLoops()
{
Traverse val = Traverse.Create((object)AudioController.Instance);
List<AudioSource> value = val.Field("loopSources").GetValue<List<AudioSource>>();
List<AudioState> list = new List<AudioState>();
for (int i = 0; i < value.Count; i++)
{
AudioSource val2 = value[i];
if ((Object)(object)val2 == (Object)null || (Object)(object)val2.clip == (Object)null)
{
list.Add(new AudioState
{
sourceNum = i,
position = 0f,
clipName = null,
isPlaying = false
});
}
else
{
list.Add(new AudioState
{
sourceNum = i,
position = (val2.isPlaying ? (val2.time / val2.clip.length) : 0f),
clipName = ((Object)val2.clip).name,
isPlaying = val2.isPlaying,
volume = val2.volume
});
}
}
AudioController.Instance.StopAllLoops();
return list;
}
public static void ResumeAllLoops(List<AudioState> states)
{
for (int i = 0; i < states.Count; i++)
{
if (states[i].isPlaying)
{
AudioController.Instance.SetLoopAndPlay(states[i].clipName, i, true, true);
AudioController.Instance.SetLoopVolumeImmediate(0f, i);
AudioController.Instance.SetLoopTimeNormalized(states[i].position, i);
AudioController.Instance.FadeInLoop(1f, states[i].volume, new int[1] { i });
}
else
{
AudioController.Instance.StopLoop(i);
}
}
}
}
public static class DialogueHelper
{
public static LineSet CreateLineSet(string[] lineString, Emotion emotion = 0, LetterAnimation animation = 2, Face p03Face = 0, int speakerIndex = 0)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
return new LineSet
{
lines = ((IEnumerable<string>)lineString).Select((Func<string, Line>)((string s) => new Line
{
text = s,
emotion = emotion,
letterAnimation = animation,
p03Face = p03Face,
speakerIndex = speakerIndex
})).ToList()
};
}
public static void AddOrModifySimpleDialogEvent(string eventId, string line, LetterAnimation? animation = null, Emotion? emotion = null)
{
string[] lines = new string[1] { line };
AddOrModifySimpleDialogEvent(eventId, lines, null, animation, emotion);
}
private static void SyncLineCollection(List<Line> curLines, string[] newLines, LetterAnimation? animation, Emotion? emotion)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
while (curLines.Count > newLines.Length)
{
curLines.RemoveAt(curLines.Count - 1);
}
for (int i = 0; i < curLines.Count; i++)
{
curLines[i].text = newLines[i];
}
for (int j = curLines.Count; j < newLines.Length; j++)
{
Line val = CloneLine(curLines[0]);
val.text = newLines[j];
if (animation.HasValue)
{
val.letterAnimation = animation.Value;
}
if (emotion.HasValue)
{
val.emotion = emotion.Value;
}
curLines.Add(val);
}
}
public static void AddOrModifySimpleDialogEvent(string eventId, string[] lines, string[][] repeatLines = null, LetterAnimation? animation = null, Emotion? emotion = null, string template = "NewRunDealtDeckDefault")
{
bool flag = false;
DialogueEvent val = DialogueDataUtil.Data.GetEvent(eventId);
if (val == null)
{
flag = true;
val = CloneDialogueEvent(DialogueDataUtil.Data.GetEvent(template), eventId);
while (val.mainLines.lines.Count > lines.Length)
{
val.mainLines.lines.RemoveAt(lines.Length);
}
}
SyncLineCollection(val.mainLines.lines, lines, animation, emotion);
if (repeatLines == null)
{
val.repeatLines.Clear();
}
else
{
while (val.repeatLines.Count > repeatLines.Length)
{
val.repeatLines.RemoveAt(val.repeatLines.Count - 1);
}
for (int i = 0; i < val.repeatLines.Count; i++)
{
SyncLineCollection(val.repeatLines[i].lines, repeatLines[i], animation, emotion);
}
}
if (flag)
{
DialogueDataUtil.Data.events.Add(val);
}
}
public static Line CloneLine(Line line)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
return new Line
{
p03Face = line.p03Face,
emotion = line.emotion,
letterAnimation = line.letterAnimation,
speakerIndex = line.speakerIndex,
text = line.text,
specialInstruction = line.specialInstruction,
storyCondition = line.storyCondition,
storyConditionMustBeMet = line.storyConditionMustBeMet
};
}
public static DialogueEvent CloneDialogueEvent(DialogueEvent dialogueEvent, string newId, bool includeRepeat = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
DialogueEvent val = new DialogueEvent
{
id = newId,
groupId = dialogueEvent.groupId,
mainLines = new LineSet(),
speakers = new List<Speaker>(),
repeatLines = new List<LineSet>()
};
foreach (Line line in dialogueEvent.mainLines.lines)
{
val.mainLines.lines.Add(CloneLine(line));
}
if (includeRepeat)
{
foreach (LineSet repeatLine in dialogueEvent.repeatLines)
{
LineSet val2 = new LineSet();
foreach (Line line2 in repeatLine.lines)
{
val2.lines.Add(CloneLine(line2));
}
val.repeatLines.Add(val2);
}
}
foreach (Speaker speaker in dialogueEvent.speakers)
{
val.speakers.Add(speaker);
}
return val;
}
}
}