Skip to content

Commit

Permalink
Merge pull request #35 from divisionbyz0rro/back-compat
Browse files Browse the repository at this point in the history
Backwards compatibility, plus some fixes
  • Loading branch information
IngoHHacks authored Feb 13, 2022
2 parents 6c5d2e1 + b240450 commit 05ad86c
Show file tree
Hide file tree
Showing 119 changed files with 1,646 additions and 35 deletions.
48 changes: 37 additions & 11 deletions InscryptionAPI/Ascension/AscensionRunSetupScreenBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public virtual void InitializeScreen(GameObject partialScreen)

public PixelText secondaryInfoDisplayer;

public AscensionMenuScreenTransition transitionController;

private static void CleanupGameObject(GameObject obj, AscensionMenuScreenTransition transition, bool destroy = true)
{
MainInputInteractable intact = obj.GetComponent<MainInputInteractable>();
if (intact != null)
transition.screenInteractables.Remove(intact);
transition.onEnableRevealedObjects.Remove(obj);

foreach (Transform child in obj.transform)
CleanupGameObject(child.gameObject, transition, destroy:false);

if (destroy)
GameObject.Destroy(obj);
}

public static AscensionRunSetupScreenBase BuildScreen(Type screenType, AscensionMenuScreens.Screen previousScreen, AscensionMenuScreens.Screen nextScreen)
{
// Create the new screen
Expand All @@ -71,6 +87,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
controller.screenTitle = textHeader.GetComponent<PixelText>();
controller.screenTitle.SetText(Localization.ToUpper(Localization.Translate(controller.headerText)));

controller.transitionController = screenObject.GetComponent<AscensionMenuScreenTransition>();

// Check to see if we need the card information displayer
GameObject footer = screenObject.transform.Find("Footer").gameObject;
footer.SetActive(true);
Expand Down Expand Up @@ -99,8 +117,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
{
InscryptionAPIPlugin.Logger.LogDebug($"Destroying unwanted card information displayer");
// Destroy the card text displayer and footer low line
GameObject.Destroy(cardTextDisplayer);
GameObject.Destroy(footerLowline);
CleanupGameObject(cardTextDisplayer, controller.transitionController);
CleanupGameObject(footerLowline, controller.transitionController);

InscryptionAPIPlugin.Logger.LogDebug($"Creating new information displayer");
GameObject newInfoDisplayer = GameObject.Instantiate(textHeader);
Expand All @@ -122,10 +140,6 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
// Sort out the unlocks block
InscryptionAPIPlugin.Logger.LogDebug($"Handling card panel");
controller.cardPanel = screenObject.transform.Find("Unlocks").gameObject;
if (controller.showCardDisplayer)
controller.cardPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f);
else
GameObject.Destroy(controller.cardPanel);

// Clone the challenge information from a challenge screen
InscryptionAPIPlugin.Logger.LogDebug($"Creating challenge text header");
Expand Down Expand Up @@ -174,6 +188,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
controller.rightButton = screenObject.transform.Find("Unlocks/ScreenAnchor/PageRightButton").gameObject.GetComponent<MainInputInteractable>();
if (controller.showCardPanel)
{
controller.cardPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f);

InscryptionAPIPlugin.Logger.LogDebug($"Reassigning left/right scroll buttons");
controller.leftButton.CursorSelectStarted = controller.LeftButtonClicked;
controller.rightButton.CursorSelectStarted = controller.RightButtonClicked;
Expand Down Expand Up @@ -210,14 +226,15 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension

Transform lockTexture = card.gameObject.transform.Find("Locked");
if (lockTexture != null)
GameObject.Destroy(lockTexture.gameObject);
CleanupGameObject(lockTexture.gameObject, controller.transitionController);
}
}
else
{
InscryptionAPIPlugin.Logger.LogDebug($"Destroying scroll buttons");
GameObject.Destroy(controller.leftButton.gameObject);
GameObject.Destroy(controller.rightButton.gameObject);
CleanupGameObject(controller.cardPanel, controller.transitionController);
CleanupGameObject(controller.leftButton.gameObject, controller.transitionController);
CleanupGameObject(controller.rightButton.gameObject, controller.transitionController);

controller.leftButton = null;
controller.rightButton = null;
Expand All @@ -234,7 +251,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
InscryptionAPIPlugin.Logger.LogDebug($"Adding continue button");
GameObject continuePrefab = Resources.Load<GameObject>("prefabs/ui/ascension/ascensionmenucontinuebutton");
GameObject continueButton = GameObject.Instantiate(continuePrefab, screenObject.transform);
continueButton.transform.localPosition = new Vector3(2.15f, 1.13f, 0f);
//continueButton.transform.localPosition = new Vector3(2.15f, 1.13f, 0f);

controller.continueButton = continueButton.GetComponent<AscensionMenuInteractable>();

Expand All @@ -249,7 +266,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension

// Let the base class do its magic
InscryptionAPIPlugin.Logger.LogDebug($"Calling screen implementation to finish creating screen UI elements");
controller.InitializeScreen(screenObject);
controller.InitializeScreen(screenObject);

// And we're done
InscryptionAPIPlugin.Logger.LogDebug($"Done building screen");
Expand Down Expand Up @@ -423,6 +440,15 @@ public void DisplayChallengeInfo(string message, int points, bool immediate=fals
challengeHeaderDisplay.UpdateText();
}

public override void OnEnable()
{
// Set all the viewport camera stuff
foreach (var vrp in this.gameObject.GetComponentsInChildren<ViewportRelativePosition>())
vrp.viewportCam = Camera.main;

base.OnEnable();
}

public void DisplayChallengeInfo(AscensionChallenge challenge, bool immediate=false)
{
AscensionChallengeInfo info = AscensionChallengesUtil.GetInfo(challenge);
Expand Down
Binary file added InscryptionAPI/Assets/GoldenTeeth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/blood_cost_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/bone_cost_6.png
Binary file added InscryptionAPI/Assets/bone_cost_7.png
Binary file added InscryptionAPI/Assets/bone_cost_8.png
Binary file added InscryptionAPI/Assets/bone_cost_9.png
Binary file added InscryptionAPI/Assets/empty_cost.png
Binary file added InscryptionAPI/Assets/energy_cost_0.png
Binary file added InscryptionAPI/Assets/energy_cost_1.png
Binary file added InscryptionAPI/Assets/energy_cost_2.png
Binary file added InscryptionAPI/Assets/energy_cost_3.png
Binary file added InscryptionAPI/Assets/energy_cost_4.png
Binary file added InscryptionAPI/Assets/energy_cost_5.png
Binary file added InscryptionAPI/Assets/energy_cost_6.png
Binary file added InscryptionAPI/Assets/life_cost_1.png
Binary file added InscryptionAPI/Assets/life_cost_10.png
Binary file added InscryptionAPI/Assets/life_cost_2.png
Binary file added InscryptionAPI/Assets/life_cost_3.png
Binary file added InscryptionAPI/Assets/life_cost_4.png
Binary file added InscryptionAPI/Assets/life_cost_5.png
Binary file added InscryptionAPI/Assets/life_cost_6.png
Binary file added InscryptionAPI/Assets/life_cost_7.png
Binary file added InscryptionAPI/Assets/life_cost_8.png
Binary file added InscryptionAPI/Assets/life_cost_9.png
Binary file added InscryptionAPI/Assets/mox_cost_b.png
Binary file added InscryptionAPI/Assets/mox_cost_e.png
Binary file added InscryptionAPI/Assets/mox_cost_empty.png
Binary file added InscryptionAPI/Assets/mox_cost_g.png
Binary file added InscryptionAPI/Assets/mox_cost_o.png
Binary file added InscryptionAPI/Assets/pixel_1.png
Binary file added InscryptionAPI/Assets/pixel_10.png
Binary file added InscryptionAPI/Assets/pixel_11.png
Binary file added InscryptionAPI/Assets/pixel_12.png
Binary file added InscryptionAPI/Assets/pixel_13.png
Binary file added InscryptionAPI/Assets/pixel_14.png
Binary file added InscryptionAPI/Assets/pixel_15.png
Binary file added InscryptionAPI/Assets/pixel_2.png
Binary file added InscryptionAPI/Assets/pixel_3.png
Binary file added InscryptionAPI/Assets/pixel_4.png
Binary file added InscryptionAPI/Assets/pixel_5.png
Binary file added InscryptionAPI/Assets/pixel_6.png
Binary file added InscryptionAPI/Assets/pixel_7.png
Binary file added InscryptionAPI/Assets/pixel_8.png
Binary file added InscryptionAPI/Assets/pixel_9.png
Binary file added InscryptionAPI/Assets/pixel_L_1.png
Binary file added InscryptionAPI/Assets/pixel_L_10.png
Binary file added InscryptionAPI/Assets/pixel_L_11.png
Binary file added InscryptionAPI/Assets/pixel_L_12.png
Binary file added InscryptionAPI/Assets/pixel_L_13.png
Binary file added InscryptionAPI/Assets/pixel_L_14.png
Binary file added InscryptionAPI/Assets/pixel_L_15.png
Binary file added InscryptionAPI/Assets/pixel_L_2.png
Binary file added InscryptionAPI/Assets/pixel_L_3.png
Binary file added InscryptionAPI/Assets/pixel_L_4.png
Binary file added InscryptionAPI/Assets/pixel_L_5.png
Binary file added InscryptionAPI/Assets/pixel_L_6.png
Binary file added InscryptionAPI/Assets/pixel_L_7.png
Binary file added InscryptionAPI/Assets/pixel_L_8.png
Binary file added InscryptionAPI/Assets/pixel_L_9.png
Binary file added InscryptionAPI/Assets/pixel_base.png
Binary file added InscryptionAPI/Assets/pixel_blank.png
Binary file added InscryptionAPI/Assets/pixel_blood.png
Binary file added InscryptionAPI/Assets/pixel_bone.png
Binary file added InscryptionAPI/Assets/pixel_energy.png
Binary file added InscryptionAPI/Assets/pixel_heat.png
Binary file added InscryptionAPI/Assets/pixel_life.png
Binary file added InscryptionAPI/Assets/pixel_mox_blue.png
Binary file added InscryptionAPI/Assets/pixel_mox_empty.png
Binary file added InscryptionAPI/Assets/pixel_mox_green.png
Binary file added InscryptionAPI/Assets/pixel_mox_orange.png
4 changes: 2 additions & 2 deletions InscryptionAPI/Card/AbilityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace InscryptionAPI.Card;

public static class AbilityExtensions
{
public static AbilityInfo AbilityByID(this List<AbilityInfo> abilities, Ability id) => abilities.FirstOrDefault(x => x.ability == id);
public static AbilityInfo AbilityByID(this IEnumerable<AbilityInfo> abilities, Ability id) => abilities.FirstOrDefault(x => x.ability == id);

public static AbilityManager.FullAbility AbilityByID(this List<AbilityManager.FullAbility> abilities, Ability id) => abilities.FirstOrDefault(x => x.Id == id);
public static AbilityManager.FullAbility AbilityByID(this IEnumerable<AbilityManager.FullAbility> abilities, Ability id) => abilities.FirstOrDefault(x => x.Id == id);

public static AbilityInfo SetIcon(this AbilityInfo info, Texture2D icon)
{
Expand Down
41 changes: 39 additions & 2 deletions InscryptionAPI/Card/AbilityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,35 @@ public FullAbility(Ability id, AbilityInfo info, Type behaviour, Texture texture

TypeManager.Add(id.ToString(), behaviour);
}

public FullAbility Clone()
{
AbilityInfo clonedInfo = ScriptableObject.CreateInstance<AbilityInfo>();
clonedInfo.ability = Info.ability;
clonedInfo.abilityLearnedDialogue = Info.abilityLearnedDialogue;
clonedInfo.activated = Info.activated;
clonedInfo.canStack = Info.canStack;
clonedInfo.colorOverride = Info.colorOverride;
clonedInfo.conduit = Info.conduit;
clonedInfo.conduitCell = Info.conduitCell;
clonedInfo.customFlippedIcon = Info.customFlippedIcon;
clonedInfo.customFlippedPixelIcon = Info.customFlippedPixelIcon;
clonedInfo.flipYIfOpponent = Info.flipYIfOpponent;
clonedInfo.hasColorOverride = Info.hasColorOverride;
clonedInfo.keywordAbility = Info.keywordAbility;
clonedInfo.mesh3D = Info.mesh3D;
clonedInfo.metaCategories = new(Info.metaCategories);
clonedInfo.name = Info.name;
clonedInfo.opponentUsable = Info.opponentUsable;
clonedInfo.passive = Info.passive;
clonedInfo.pixelIcon = Info.pixelIcon;
clonedInfo.powerLevel = Info.powerLevel;
clonedInfo.rulebookDescription = Info.rulebookDescription;
clonedInfo.rulebookName = Info.rulebookName;
clonedInfo.triggerText = Info.triggerText;

return new FullAbility(this.Id, clonedInfo, this.AbilityBehavior, this.Texture);
}
}

public readonly static ReadOnlyCollection<FullAbility> BaseGameAbilities = new(GenBaseGameAbilityList());
Expand All @@ -39,6 +68,15 @@ public FullAbility(Ability id, AbilityInfo info, Type behaviour, Texture texture
public static List<FullAbility> AllAbilities { get; private set; } = BaseGameAbilities.ToList();
public static List<AbilityInfo> AllAbilityInfos { get; private set; } = BaseGameAbilities.Select(x => x.Info).ToList();

public static event Func<List<FullAbility>, List<FullAbility>> ModifyAbilityList;

public static void SyncAbilityList()
{
AllAbilities = BaseGameAbilities.Concat(NewAbilities).Select(a => a.Clone()).ToList();
AllAbilities = ModifyAbilityList?.Invoke(AllAbilities) ?? AllAbilities;
AllAbilityInfos = AllAbilities.Select(x => x.Info).ToList();
}

static AbilityManager()
{
InscryptionAPIPlugin.ScriptableObjectLoaderLoad += static type =>
Expand All @@ -50,8 +88,7 @@ static AbilityManager()
};
NewAbilities.CollectionChanged += static (_, _) =>
{
AllAbilities = BaseGameAbilities.Concat(NewAbilities).ToList();
AllAbilityInfos = AllAbilities.Select(x => x.Info).ToList();
SyncAbilityList();
};
}

Expand Down
129 changes: 113 additions & 16 deletions InscryptionAPI/Card/CardExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,42 +179,121 @@ public static CardInfo SetTerrain(this CardInfo info)
return info;
}

public static CardInfo SetTail(this CardInfo info, string tailName)
public static CardInfo SetTail(this CardInfo info, string tailName, string pathToLostTailArt = null, IEnumerable<CardModificationInfo> mods = null)
{
info.tailParams = new();
info.tailParams.tail = CardManager.AllCardsCopy.CardByName(tailName);
info.tailParams.tailLostPortrait = info.portraitTex;
return info;
Texture2D lostTailPortrait = pathToLostTailArt == null ? null : TextureHelper.GetImageAsTexture(pathToLostTailArt);
return info.SetTail(tailName, lostTailPortrait, mods:mods);
}

public static CardInfo SetTail(this CardInfo info, string tailName, string pathToLostTailArt)
public static CardInfo SetTail(this CardInfo info, CardInfo tail, Texture2D tailLostPortrait, FilterMode? filterMode = null, IEnumerable<CardModificationInfo> mods = null)
{
info.tailParams = new();
info.tailParams.tail = CardManager.AllCardsCopy.CardByName(tailName);
info.tailParams.SetLostTailPortrait(pathToLostTailArt, info);
info.tailParams.tail = CardLoader.Clone(tail);

if (tailLostPortrait != null)
info.tailParams.SetLostTailPortrait(tailLostPortrait, info, filterMode);

if (mods != null)
(info.tailParams.tail.mods = info.tailParams.tail.mods ?? new()).AddRange(mods);

return info;
}

public static CardInfo SetTail(this CardInfo info, string tailName, Texture2D tailLostPortrait, FilterMode? filterMode = null)
public static CardInfo SetTail(this CardInfo info, string tailName, Texture2D tailLostPortrait, FilterMode? filterMode = null, IEnumerable<CardModificationInfo> mods = null)
{
info.tailParams = new();
info.tailParams.tail = CardManager.AllCardsCopy.CardByName(tailName);
info.tailParams.SetLostTailPortrait(tailLostPortrait, info, filterMode);
CardInfo tail = CardManager.AllCardsCopy.CardByName(tailName);

if (tail == null) // Try delayed loading
{
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
{
CardInfo target = cards.CardByName(info.name);
CardInfo tailCard = cards.CardByName(tailName);

if (target != null && tailCard != null)
target.SetTail(tailCard, tailLostPortrait, filterMode, mods);

return cards;
};
}
else
{
info.SetTail(tail, tailLostPortrait, filterMode, mods);
}

return info;
}

public static CardInfo SetIceCube(this CardInfo info, string iceCubeName)
public static CardInfo SetIceCube(this CardInfo info, CardInfo iceCube, IEnumerable<CardModificationInfo> mods)
{
info.iceCubeParams = new();
info.iceCubeParams.creatureWithin = CardManager.AllCardsCopy.CardByName(iceCubeName);
info.iceCubeParams.creatureWithin = CardLoader.Clone(iceCube);

if (mods != null)
(info.iceCubeParams.creatureWithin.mods = info.iceCubeParams.creatureWithin.mods ?? new ()).AddRange(mods);

return info;
}

public static CardInfo SetIceCube(this CardInfo info, string iceCubeName, IEnumerable<CardModificationInfo> mods)
{
CardInfo creatureWithin = CardManager.AllCardsCopy.CardByName(iceCubeName);

if (creatureWithin == null) // Try delayed loading
{
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
{
CardInfo target = cards.CardByName(info.name);
CardInfo creatureWithinCard = cards.CardByName(iceCubeName);

if (target != null && creatureWithinCard != null)
target.SetIceCube(creatureWithinCard, mods);

return cards;
};
}
else
{
info.SetIceCube(creatureWithin, mods);
}

return info;
}

public static CardInfo SetEvolve(this CardInfo info, string evolveInto, int numberOfTurns)
public static CardInfo SetEvolve(this CardInfo info, CardInfo evolveCard, int numberOfTurns, IEnumerable<CardModificationInfo> mods = null)
{
info.evolveParams = new();
info.evolveParams.evolution = CardLoader.Clone(evolveCard);

if (mods != null)
(info.evolveParams.evolution.mods = info.evolveParams.evolution.mods ?? new ()).AddRange(mods);

info.evolveParams.turnsToEvolve = numberOfTurns;
info.evolveParams.evolution = CardManager.AllCardsCopy.CardByName(evolveInto);

return info;
}

public static CardInfo SetEvolve(this CardInfo info, string evolveInto, int numberOfTurns, IEnumerable<CardModificationInfo> mods = null)
{
CardInfo evolution = CardManager.AllCardsCopy.CardByName(evolveInto);

if (evolution == null) // Try delayed loading
{
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
{
CardInfo target = cards.CardByName(info.name);
CardInfo evolveIntoCard = cards.CardByName(evolveInto);

if (target != null && evolveIntoCard != null)
target.SetEvolve(evolveIntoCard, numberOfTurns, mods);

return cards;
};
}
else
{
info.SetEvolve(evolution, numberOfTurns, mods);
}
return info;
}

Expand Down Expand Up @@ -288,4 +367,22 @@ public static CardInfo SetGBCPlayable(this CardInfo info, CardTemple temple)
info.temple = temple;
return info;
}

public static CardInfo AddDecal(this CardInfo info, params Texture[] decals)
{
info.decals = info.decals ?? new();
foreach (var dec in decals)
if (!info.decals.Contains(dec))
info.decals.Add(dec);

return info;
}

public static CardInfo AddDecal(this CardInfo info, params string[] decals)
{
if (decals == null)
return info;

return info.AddDecal(decals.Select(d => TextureHelper.GetImageAsTexture(d)).ToArray());
}
}
2 changes: 1 addition & 1 deletion InscryptionAPI/Card/CardManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class CardManager

public static event Func<List<CardInfo>, List<CardInfo>> ModifyCardList;

internal static void SyncCardList()
public static void SyncCardList()
{
var cards = BaseGameCards.Concat(NewCards).Select(x => CardLoader.Clone(x)).ToList();
//var cards = BaseGameCards.Concat(NewCards).ToList();
Expand Down
Loading

0 comments on commit 05ad86c

Please sign in to comment.