using System;
using System.Collections.Generic;
using System.Diagnostics;
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 CustomSideDeck.Info;
using DiskCardGame;
using GBC;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Saves;
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 = "")]
[assembly: AssemblyCompany("CustomSideDeck")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows changing the side deck to something other than squirrels")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("CustomSideDeck")]
[assembly: AssemblyTitle("CustomSideDeck")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace CustomSideDeck
{
[BepInPlugin("tvflabs.inscryption.CustomSideDeck", "CustomSideDeck", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public class Part1CardDrawPiles_SideDeckData_Patch
{
public static void Register(Harmony harmony)
{
harmony.PatchAll(typeof(Part1CardDrawPiles_SideDeckData_Patch));
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void OnSideDeckData(ref List<CardInfo> __result)
{
List<CardInfo> sideDeckCards = SideDeckCards;
__result = sideDeckCards;
}
}
public class AscensionStartScreen_ContinueGameSequence_Patch
{
public static void Register(Harmony harmony)
{
harmony.PatchAll(typeof(AscensionStartScreen_ContinueGameSequence_Patch));
}
[HarmonyPatch(typeof(AscensionStartScreen), "ContinueGameSequence")]
[HarmonyPostfix]
public static void OnContinueGameSequence()
{
if (alreadyInitialized)
{
return;
}
if (Chainloader.PluginInfos.ContainsKey("zorro.inscryption.infiniscryption.sidedecks"))
{
foreach (CardInfo item in CardManager.AllCardsCopy.Where((CardInfo c) => CardExtensions.HasCardMetaCategory(c, GuidManager.GetEnumValue<CardMetaCategory>("zorro.inscryption.infiniscryption.sidedecks", "SideDeck"))))
{
if ((!CardExtensions.GetExtendedPropertyAsBool(item, "CSDIsSideDeck")).GetValueOrDefault())
{
SideDeckInfo sideDeckInfo = null;
sideDeckInfo = SideDeckManager.New(CardExtensions.GetModPrefix(item), ((Object)item).name, "Basic", new List<string>(), new List<string>(), ((Object)item).name);
CardExtensions.SetExtendedProperty(item, "CSDAssociatedSideDeck", (object)sideDeckInfo.internalName);
}
}
}
foreach (CardInfo item2 in CardManager.AllCardsCopy.Where((CardInfo c) => CardExtensions.GetExtendedPropertyAsBool(c, "CSDIsSideDeck").GetValueOrDefault()))
{
SideDeckInfo sideDeckInfo2 = null;
if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "basic")
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Basic", new List<string>(), new List<string>(), ((Object)item2).name);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "setcount")
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "SetCount", new List<string>(), new List<string>(), ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "configurable")
{
List<string> list = new List<string>();
for (int i = 0; i < CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumOptions").GetValueOrDefault(); i++)
{
list.Add(CardExtensions.GetExtendedProperty(item2, $"CSDOption{i + 1}"));
}
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Configurable", new List<string>(), list, ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "advanced")
{
List<string> list2 = new List<string>();
for (int j = 0; j < CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumOptions").GetValueOrDefault(); j++)
{
list2.Add(CardExtensions.GetExtendedProperty(item2, $"CSDOption{j + 1}"));
}
List<string> list3 = new List<string>();
for (int k = 0; k < (CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 1); k++)
{
list3.Add(CardExtensions.GetExtendedProperty(item2, $"CSDCard{k + 1}"));
}
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Advanced", list3, list2, ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Basic", new List<string>(), new List<string>(), ((Object)item2).name);
}
CardExtensions.SetExtendedProperty(item2, "CSDAssociatedSideDeck", (object)sideDeckInfo2.internalName);
}
alreadyInitialized = true;
}
}
[AscensionScreenSort(/*Could not decode attribute arguments.*/)]
public class SideDeckSelectionScreen : AscensionRunSetupScreenBase
{
private GameObject selectedBorder;
public static SideDeckSelectionScreen Instance;
public int scrollIndex = 0;
public override string headerText => "Select Side Deck";
public override bool showCardDisplayer => true;
public override bool showCardPanel => true;
public override void InitializeScreen(GameObject partialScreen)
{
//IL_0034: 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);
val2.GetComponent<SpriteRenderer>().color = GameColors.Instance.brightNearWhite;
val2.AddComponent<PixelSnapElement>();
selectedBorder = val2;
Instance = this;
}
public override void CardClicked(PixelSelectableCard card)
{
if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null)
{
CurrentSideDeck = SideDeckManager.GetSideDeckByName(CardExtensions.GetExtendedProperty(((Card)card).Info, "CSDAssociatedSideDeck"));
ShowPage();
}
}
public override void OnEnable()
{
((AscensionRunSetupScreenBase)this).OnEnable();
if (!alreadyInitialized)
{
if (Chainloader.PluginInfos.ContainsKey("zorro.inscryption.infiniscryption.sidedecks"))
{
foreach (CardInfo item in CardManager.AllCardsCopy.Where((CardInfo c) => CardExtensions.HasCardMetaCategory(c, GuidManager.GetEnumValue<CardMetaCategory>("zorro.inscryption.infiniscryption.sidedecks", "SideDeck"))))
{
if ((!CardExtensions.GetExtendedPropertyAsBool(item, "CSDIsSideDeck")).GetValueOrDefault())
{
SideDeckInfo sideDeckInfo = null;
sideDeckInfo = SideDeckManager.New(CardExtensions.GetModPrefix(item), ((Object)item).name, "Basic", new List<string>(), new List<string>(), ((Object)item).name);
CardExtensions.SetExtendedProperty(item, "CSDAssociatedSideDeck", (object)sideDeckInfo.internalName);
}
}
}
foreach (CardInfo item2 in CardManager.AllCardsCopy.Where((CardInfo c) => CardExtensions.GetExtendedPropertyAsBool(c, "CSDIsSideDeck").GetValueOrDefault()))
{
SideDeckInfo sideDeckInfo2 = null;
if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "basic")
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Basic", new List<string>(), new List<string>(), ((Object)item2).name);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "setcount")
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "SetCount", new List<string>(), new List<string>(), ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "configurable")
{
List<string> list = new List<string>();
for (int i = 0; i < CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumOptions").GetValueOrDefault(); i++)
{
list.Add(CardExtensions.GetExtendedProperty(item2, $"CSDOption{i + 1}"));
}
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Configurable", new List<string>(), list, ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else if (CardExtensions.GetExtendedProperty(item2, "CSDSideDeckType").ToLower() == "advanced")
{
List<string> list2 = new List<string>();
for (int j = 0; j < CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumOptions").GetValueOrDefault(); j++)
{
list2.Add(CardExtensions.GetExtendedProperty(item2, $"CSDOption{j + 1}"));
}
List<string> list3 = new List<string>();
for (int k = 0; k < (CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 1); k++)
{
list3.Add(CardExtensions.GetExtendedProperty(item2, $"CSDCard{k + 1}"));
}
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Advanced", list3, list2, ((Object)item2).name, CardExtensions.GetExtendedPropertyAsInt(item2, "CSDNumCards") ?? 10);
}
else
{
sideDeckInfo2 = SideDeckManager.New(CardExtensions.GetModPrefix(item2), ((Object)item2).name, "Basic", new List<string>(), new List<string>(), ((Object)item2).name);
}
CardExtensions.SetExtendedProperty(item2, "CSDAssociatedSideDeck", (object)sideDeckInfo2.internalName);
}
alreadyInitialized = true;
}
ShowPage();
((AscensionRunSetupScreenBase)this).CardClicked(base.cards[0]);
}
public void ShowPage()
{
List<CardInfo> list = new List<CardInfo>();
foreach (SideDeckInfo sideDecks in SideDeckManager.sideDecksList)
{
list.Add(CardLoader.GetCardByName(sideDecks.defaultCard));
}
((AscensionRunSetupScreenBase)this).ShowCards(list.GetRange(scrollIndex, Math.Min(list.Count, 6)));
foreach (PixelSelectableCard card in base.cards)
{
if (CardExtensions.GetExtendedProperty(((Card)card).Info, "CSDAssociatedSideDeck") == CurrentSideDeck.internalName)
{
selectedBorder.SetActive(true);
selectedBorder.transform.SetParent(((Component)card).transform.Find("Base/PixelSnap"), false);
break;
}
selectedBorder.SetActive(false);
}
}
public override void LeftButtonClicked(MainInputInteractable button)
{
if (scrollIndex > 0)
{
scrollIndex--;
ShowPage();
}
}
public override void RightButtonClicked(MainInputInteractable button)
{
if (scrollIndex < SideDeckManager.sideDecksList.Count - 6)
{
scrollIndex++;
ShowPage();
}
}
}
[AscensionScreenSort(/*Could not decode attribute arguments.*/)]
public class SideDeckConfigurationScreen : AscensionRunSetupScreenBase
{
public static SideDeckConfigurationScreen Instance;
public bool isAdvanced = false;
public List<CardInfo> confCards;
public int scrollIndex = 0;
public override string headerText => "Configure Side Deck";
public override bool showCardDisplayer => true;
public override bool showCardPanel => true;
public override void InitializeScreen(GameObject partialScreen)
{
Instance = this;
}
public override void CardClicked(PixelSelectableCard card)
{
if (!((Object)(object)card != (Object)null) || !((Object)(object)((Card)card).Info != (Object)null))
{
return;
}
int index = confCards.IndexOf(((Card)card).Info);
string extendedProperty = CardExtensions.GetExtendedProperty(((Card)card).Info, "ConfIndex");
confCards.RemoveAt(index);
for (int i = 0; i <= CurrentSideDeck.options.Count; i++)
{
if (((Object)((Card)card).Info).name == CurrentSideDeck.options[i])
{
if (i == CurrentSideDeck.options.Count - 1)
{
((Card)card).SetInfo(CardExtensions.SetExtendedProperty(CardLoader.GetCardByName(CurrentSideDeck.options[0]), "ConfIndex", (object)extendedProperty));
}
else
{
((Card)card).SetInfo(CardExtensions.SetExtendedProperty(CardLoader.GetCardByName(CurrentSideDeck.options[i + 1]), "ConfIndex", (object)extendedProperty));
}
break;
}
}
confCards.Insert(index, ((Card)card).Info);
int num = 0;
foreach (CardInfo confCard in confCards)
{
SetConfCard(((Object)confCard).name, num);
num++;
}
ShowPage();
}
public override void OnEnable()
{
int num = 0;
if (CurrentSideDeck.csdType == "Advanced")
{
isAdvanced = true;
for (int i = 1; i <= CurrentSideDeck.cards.Count; i++)
{
if (!Utility.IsNullOrWhiteSpace(CurrentSideDeck.cards[i - 1]) && (CurrentSideDeck.cards[i - 1] == "conf" || CurrentSideDeck.cards[i - 1] == "c"))
{
num++;
}
}
}
else if (CurrentSideDeck.options.Count > 0)
{
num = CurrentSideDeck.numCards;
}
if (CurrentSideDeck.options.Count == 0 || num == 0)
{
Singleton<AscensionMenuScreens>.Instance.TransitionToGame(true);
}
((AscensionRunSetupScreenBase)this).OnEnable();
confCards = new List<CardInfo>();
if (isAdvanced)
{
for (int j = 1; j <= num; j++)
{
confCards.Add(CardLoader.GetCardByName(CurrentSideDeck.options[0]));
}
}
else
{
for (int k = 1; k <= CurrentSideDeck.numCards; k++)
{
confCards.Add(CardLoader.GetCardByName(CurrentSideDeck.options[0]));
}
}
int num2 = 0;
foreach (CardInfo confCard in confCards)
{
SetConfCard(((Object)confCard).name, num2);
num2++;
}
ShowPage();
}
public void ShowPage()
{
((AscensionRunSetupScreenBase)this).ShowCards(confCards.GetRange(scrollIndex, Math.Min(confCards.Count, 6)));
}
public override void LeftButtonClicked(MainInputInteractable button)
{
if (scrollIndex > 0)
{
scrollIndex--;
ShowPage();
}
}
public override void RightButtonClicked(MainInputInteractable button)
{
if (scrollIndex < confCards.Count - 6)
{
scrollIndex++;
ShowPage();
}
}
}
private const string PluginGuid = "tvflabs.inscryption.CustomSideDeck";
private const string PluginName = "CustomSideDeck";
private const string PluginVersion = "1.2.0";
private static bool alreadyInitialized;
public static List<CardInfo> SideDeckCards
{
get
{
List<CardInfo> list = new List<CardInfo>();
if (CurrentSideDeck.csdType != "Advanced")
{
for (int i = 0; i < CurrentSideDeck.numCards; i++)
{
if (CurrentSideDeck.options.Count > 0)
{
list.Add(CardLoader.GetCardByName(GetConfCards()[i]));
}
else
{
list.Add(CardLoader.GetCardByName(CurrentSideDeck.defaultCard));
}
}
}
else
{
int num = 0;
foreach (string card in CurrentSideDeck.cards)
{
if (card == "conf")
{
list.Add(CardLoader.GetCardByName(GetConfCards()[num]));
num++;
}
else if (card == "def" || card == "self")
{
CardLoader.GetCardByName(CurrentSideDeck.defaultCard);
}
else
{
list.Add(CardLoader.GetCardByName(card));
}
}
}
return list;
}
}
public static SideDeckInfo CurrentSideDeck
{
get
{
string value = ModdedSaveManager.SaveData.GetValue("tvflabs.inscryption.CustomSideDeck", "CurrentSideDeck");
if (string.IsNullOrEmpty(value))
{
return SideDeckManager.GetSideDeckByName("CustomSideDeck_Squirrels");
}
return SideDeckManager.GetSideDeckByName(value);
}
set
{
ModdedSaveManager.SaveData.SetValue("tvflabs.inscryption.CustomSideDeck", "CurrentSideDeck", (object)value.internalName);
}
}
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony harmony = new Harmony("tvflabs.inscryption.CustomSideDeck");
Part1CardDrawPiles_SideDeckData_Patch.Register(harmony);
AscensionStartScreen_ContinueGameSequence_Patch.Register(harmony);
AscensionScreenManager.RegisterScreen<SideDeckSelectionScreen>();
AscensionScreenManager.RegisterScreen<SideDeckConfigurationScreen>();
RegisterSideDecks();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded CustomSideDeck!");
}
private void RegisterSideDecks()
{
SideDeckManager.New("CustomSideDeck", "Squirrels", "Basic", new List<string>(), new List<string>(), "Squirrel");
CardExtensions.SetExtendedProperty(CardLoader.GetCardByName("Squirrel"), "CSDAssociatedSideDeck", (object)"CustomSideDeck_Squirrels");
SideDeckManager.New("CustomSideDeck", "Bees", "Basic", new List<string>(), new List<string>(), "Bee");
CardExtensions.SetExtendedProperty(CardLoader.GetCardByName("Bee"), "CSDAssociatedSideDeck", (object)"CustomSideDeck_Bees");
CardExtensions.SetPixelPortrait(CardLoader.GetCardByName("Bee"), TextureHelper.GetImageAsSprite("pixelportrait_bee.png", (SpriteType)1, (FilterMode)0));
SideDeckManager.New("CustomSideDeck", "AquaSquirrels", "Basic", new List<string>(), new List<string>(), "AquaSquirrel");
CardExtensions.SetExtendedProperty(CardLoader.GetCardByName("AquaSquirrel"), "CSDAssociatedSideDeck", (object)"CustomSideDeck_AquaSquirrels");
CardExtensions.SetPixelPortrait(CardLoader.GetCardByName("AquaSquirrel"), TextureHelper.GetImageAsSprite("pixelportrait_aquasquirrel.png", (SpriteType)1, (FilterMode)0));
}
public static List<string> GetConfCards()
{
List<string> list = new List<string>();
if (CurrentSideDeck.csdType != "Advanced")
{
if (CurrentSideDeck.options.Count > 0)
{
for (int i = 0; i < CurrentSideDeck.numCards; i++)
{
list.Add(ModdedSaveManager.SaveData.GetValue("tvflabs.inscryption.CustomSideDeck", $"ConfCard{i}"));
}
}
}
else
{
int num = 0;
foreach (string card in CurrentSideDeck.cards)
{
if (card == "conf")
{
list.Add(ModdedSaveManager.SaveData.GetValue("tvflabs.inscryption.CustomSideDeck", $"ConfCard{num}"));
num++;
}
}
}
return list;
}
public static void SetConfCard(string card, int cardNum)
{
ModdedSaveManager.SaveData.SetValue("tvflabs.inscryption.CustomSideDeck", $"ConfCard{cardNum}", (object)card);
}
}
internal class SideDeckIcon : MainInputInteractable
{
public SideDeckInfo Info;
private Plugin.SideDeckSelectionScreen ScreenParent => ((Component)this).GetComponentInParent<Plugin.SideDeckSelectionScreen>();
protected override bool CollisionIs2D => true;
protected override void OnCursorEnter()
{
((AscensionRunSetupScreenBase)ScreenParent).DisplayCardInfo((CardInfo)null, Localization.Translate(Info.displayName), Info.description + $"\nContains {Info.cards.Count} cards", false);
}
protected override void OnCursorExit()
{
((AscensionRunSetupScreenBase)ScreenParent).ClearMessage();
}
}
public static class SideDeckManager
{
public static List<SideDeckInfo> sideDecksList = new List<SideDeckInfo>();
public static SideDeckInfo New(string modPrefix, string name, string csdType, List<string> cards, List<string> options, string defaultCard, int numCards = 10, string cardBack = null, string pixelCardBack = null)
{
SideDeckInfo sideDeckInfo = new SideDeckInfo();
sideDeckInfo.internalName = modPrefix + "_" + name;
sideDeckInfo.numCards = numCards;
sideDeckInfo.defaultCard = defaultCard;
sideDeckInfo.cards = new List<string>();
sideDeckInfo.options = new List<string>();
sideDeckInfo.csdType = csdType;
foreach (string card in cards)
{
sideDeckInfo.cards.Add(card);
}
foreach (string option in options)
{
sideDeckInfo.options.Add(option);
}
sideDecksList.Add(sideDeckInfo);
return sideDeckInfo;
}
public static SideDeckInfo GetSideDeckByName(string name)
{
return sideDecksList.Find((SideDeckInfo sideDeck) => sideDeck.internalName == name);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CustomSideDeck";
public const string PLUGIN_NAME = "CustomSideDeck";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace CustomSideDeck.Info
{
public class SideDeckInfo
{
public string internalName;
public string displayName;
public string description;
public string csdType;
public int numCards;
public string defaultCard;
public List<string> cards;
public List<string> options;
public string cardBack;
public string pixelCardBack;
}
}