Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
unzip build/* -d out

- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: InscryptionAPI
path: out/
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<details>
<summary>View Changelog</summary>
# 2.23.0
- Added 'GBC Vanilla Render' config to community patches (false by default) - makes GBC cards render with vanilla cost sprites
- Added 'Vanilla Stacking' config to community patches (false by default) - renders cards with only two (stacking) sigils as they appear in vanilla, eg Spore Mice and Sporedigger
- Added PostCardGettingAttacked custom trigger
- Added BoardManager.GetCards and BoardManager.GetOpenSlots overloads that retrieve from the entire board
- Fixed incorrect rulebook icon scaling in Act 3
- Fixed rulebook-related null errors when playing during Magnificus' Act
- Fixed slot modification rulebook pages not appearing correctly during Magnificus' Act
- Fixed cards shield sigils not rendering correctly
- DamageShieldBehaviour class now has 'initialised' boolean field
- Highest displayable bone cost value in Act 1 raised from 13+ to 15+
- Minor tweaks to blood and bone cost icons
- Rewrote SlotAttackSlotPatches transpilers to be cleaner

# 2.22.3
- Fixed pelt names when a user goes to the trader with modded cards, Examples shown below.
Expand Down Expand Up @@ -701,6 +712,4 @@
- Custom cards are added via the **CustomCard** constructor rather than through the **AddCard** method.

# v1.1
- Hooked into a much more sensible method to load the cards into the card pool.

</details>
- Hooked into a much more sensible method to load the cards into the card pool.
14 changes: 5 additions & 9 deletions InscryptionAPI/Ascension/AscensionChallengePaginator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using BepInEx;
using DiskCardGame;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using UnityEngine;

Expand All @@ -21,7 +17,7 @@ public void Initialize(AscensionChallengeScreen screen, AscensionMenuScreenTrans
{
//List<GameObject> firstPageObjs = new();
List<AscensionIconInteractable> icons;

// if the screen object exists, use its list of icons; otherwise use the screenInteractables from the transition object
if (screen != null)
{
Expand Down Expand Up @@ -166,7 +162,7 @@ private GameObject CreateIconGameObject(GameObject objectRef, int index, Ascensi
screen?.icons.Add(chall);
if (info != null)
chall.challengeInfo = info;

return newIcon;
}
public void OnEnable()
Expand All @@ -180,7 +176,7 @@ public void OnEnable()

ChallengeManager.SyncChallengeList();
Initialize(GetComponent<AscensionChallengeScreen>(), GetComponent<AscensionMenuScreenTransition>());

if (leftArrow)
{
Destroy(leftArrow.gameObject);
Expand All @@ -202,7 +198,7 @@ public void OnEnable()
if (screen != null)
{
screen.icons?.RemoveAll(x => x == null);

icons = screen.icons;
pageLength = screen.icons.Count;
}
Expand Down Expand Up @@ -287,7 +283,7 @@ public void OnEnable()

challengeObjectsForPages.ForEach(x => x.RemoveAll(x => x == null));
LoadPage(pageIndex = 0);

if (pagesToAdd.Count == 0)
return;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DiskCardGame;
using UnityEngine;

namespace InscryptionAPI.Ascension;

Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Ascension/AscensionChallengeScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static bool UpdateFooterText(AscensionChallengeScreen __instance, Ascensi
{
string arg = Localization.ToUpper(Localization.Translate(challengeInfo.title));
string text = string.Format(Localization.Translate(activated ? "{0} ENABLED" : "{0} DISABLED"), arg);

string text2;
if (activated)
text2 = string.Format(Localization.Translate("{0} Challenge Points Subtracted"), (-challengeInfo.pointValue).ToString());
Expand Down
4 changes: 2 additions & 2 deletions InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediat
actualStrings = dependencyStrings.ConvertAll(x =>
!AscensionSaveData.Data.activeChallenges.Contains(x.challenge) ? $"[c:R]{x.FullText}[c:]" :
AscensionSaveData.Data.activeChallenges.Count(x2 => x2 == x.challenge) < x.number ? x.RedPrefixText : x.FullText);

dependency = "Depends on: " + string.Join(", ", actualStrings);
}
}
Expand All @@ -141,7 +141,7 @@ public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediat
AscensionChallengeInfo info = d.GetInfo();
if (info != null && !challenges.Contains(d))
{
string prefix = AscensionSaveData.Data.activeChallenges.Contains(d) ? $"[c:R]{Localization.Translate(info.title)}[c:]" : Localization.Translate(info.title);
string prefix = AscensionSaveData.Data.activeChallenges.Contains(d) ? $"[c:R]{Localization.Translate(info.title)}[c:]" : Localization.Translate(info.title);
incompatibilityStrings.Add(prefix);
challenges.Add(d);
}
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Ascension/ChallengeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FullChallenge
/// A function that needs to return true for the challenge to be unlocked. Optional. If this isn't set, this check will be bypassed. The int argument is the current Kaycee's Mod challenge level.
/// </summary>
public Func<int, bool> CustomUnlockCheck { get; set; }

/// <summary>
/// If true, this challenge's icon(s) will occupy the entire column like the Final Boss challenge icon, and be ordered to the right of regular challenges.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions InscryptionAPI/Card/AbilityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class FullAbility
/// The unique ID for this ability
/// </summary>
public readonly Ability Id;

/// <summary>
/// The guid of the mod that added this ability
/// </summary>
Expand Down Expand Up @@ -74,7 +74,7 @@ public class FullAbility
/// Tuple.Item3 (string): the id that the API will match against to find the redirect page. Eg, for ability redirects this will be the Ability id as a string.
/// </summary>
public Dictionary<string, RuleBookManager.RedirectInfo> RulebookDescriptionRedirects = new();

internal static ConditionalWeakTable<AbilityInfo, FullAbility> ReverseMapper = new();

/// <summary>
Expand Down Expand Up @@ -265,7 +265,7 @@ private static List<FullAbility> GenBaseGameAbilityList()
baseGame.Add(ab);
continue;
}
baseGame.Add(new FullAbility (
baseGame.Add(new FullAbility(
null,
ability.ability,
ability,
Expand All @@ -276,7 +276,7 @@ private static List<FullAbility> GenBaseGameAbilityList()

return baseGame;
}

/// <summary>
/// Creates a new ability and registers it to be able to be added to cards
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions InscryptionAPI/Card/BasePart2Modular.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using DiskCardGame;
using System;
using System.Collections.Generic;
using System.Text;

namespace InscryptionAPI.Card;
internal class Part2ModularAbilities
Expand Down
5 changes: 1 addition & 4 deletions InscryptionAPI/Card/CardExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using DiskCardGame;
using InscryptionAPI.Helpers;
using InscryptionAPI.Nodes;
using Sirenix.Utilities;
using System.Collections;
using UnityEngine;

namespace InscryptionAPI.Card;
Expand Down Expand Up @@ -343,7 +340,7 @@ public static CardInfo RemoveTraits(this CardInfo info, params Trait[] traits)
}
return info;
}

/// <summary>
/// Removes any number of traits from the card.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Card/CardExtensionsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ public static DamageShieldBehaviour GetShieldBehaviour(this PlayableCard card, A
Type type = ShieldManager.AllShieldAbilities.AbilityByID(ability)?.AbilityBehavior;
if (type == null)
return null;

return card.GetComponent(type) as DamageShieldBehaviour;
}
/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions InscryptionAPI/Card/CardManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using HarmonyLib;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.PixelCard;
using InscryptionAPI.Saves;
using MonoMod.Cil;
using System.Collections.ObjectModel;
Expand All @@ -22,7 +21,7 @@
public readonly Dictionary<Type, object> TypeMap = new();
public readonly Dictionary<string, string> StringMap = new();
}
public class CardAltPortraits
public class CardAltPortraits
{
public Sprite PixelAlternatePortrait = null;
public Sprite SteelTrapPortrait = null;
Expand Down Expand Up @@ -86,7 +85,7 @@
card.evolveParams.evolution.Mods = mods;
}

if (card.iceCubeParams != null && card.iceCubeParams.creatureWithin != null)
if (card.iceCubeParams != null && card.iceCubeParams.creatureWithin != null)
{
List<CardModificationInfo> mods = card.iceCubeParams.creatureWithin.Mods;
card.iceCubeParams.creatureWithin = cards.CardByName(card.iceCubeParams.creatureWithin.name).Clone() as CardInfo;
Expand Down Expand Up @@ -295,7 +294,7 @@

public static Dictionary<string, string> GetCardExtensionTable(this CardInfo card) => CardExtensionProperties.GetOrCreateValue(card).StringMap;
internal static CardAltPortraits GetAltPortraits(this CardInfo card) => CardAlternatePortraits.GetOrCreateValue(card);

public static Sprite PixelAlternatePortrait(this CardInfo card)
{
return card.GetAltPortraits().PixelAlternatePortrait;
Expand Down Expand Up @@ -475,7 +474,7 @@
MethodInfo LogCardInfoMethodInfo = SymbolExtensions.GetMethodInfo(() => LogCardInfo(null, null));
for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode == OpCodes.Call && codes[i].operand == CloneMethodInfo)

Check warning on line 477 in InscryptionAPI/Card/CardManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'MethodInfo'
{
codes.Insert(i++, new CodeInstruction(OpCodes.Ldarg_0)); // name
codes.Insert(i++, new CodeInstruction(OpCodes.Call, LogCardInfoMethodInfo)); // LogCardInfo
Expand Down
7 changes: 3 additions & 4 deletions InscryptionAPI/Card/CardModificationInfoExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using DiskCardGame;
using InscryptionAPI.CardCosts;
using Sirenix.Utilities;
using UnityEngine;
using static InscryptionAPI.Card.CardModificationInfoManager;
namespace InscryptionAPI.Card;

Expand Down Expand Up @@ -109,7 +108,7 @@ public static CardModificationInfo ClearCustomPropertiesId(this CardModification
string properties = GetCustomPropertiesIdString(mod);
if (properties != null)
mod.singletonId = mod.singletonId.Replace(properties, "");

return mod;
}
public static CardModificationInfo ClearCustomCostsId(this CardModificationInfo mod)
Expand All @@ -133,7 +132,7 @@ public static CardModificationInfo SetPropertiesId(this CardModificationInfo mod
{
string newProperties;
string oldProperties = GetCustomPropertiesIdString(mod); // get the current string of properties

// if the property is already set
if (oldProperties.Contains(propertyName))
{
Expand Down Expand Up @@ -239,7 +238,7 @@ public static string GetCustomCostId(this CardModificationInfo mod, string costN
return null;

string pairString = currentCosts.Substring(costIdx);

int valueIdx = pairString.IndexOf(';');
if (valueIdx == -1) // if this is the last valuePair in the string
valueIdx = pairString.IndexOf(']');
Expand Down
1 change: 0 additions & 1 deletion InscryptionAPI/Card/CardModificationInfoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using InscryptionAPI.CardCosts;
using Sirenix.Serialization.Utilities;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace InscryptionAPI.Card;

Expand Down
21 changes: 10 additions & 11 deletions InscryptionAPI/Card/CostProperties.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using DiskCardGame;
using GBC;
using HarmonyLib;
using System.Reflection;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace InscryptionAPI.Card.CostProperties;
Expand Down Expand Up @@ -69,23 +68,23 @@ public bool GemsChanged<T>(List<T> a, List<T> b)
}

public static ConditionalWeakTable<CardInfo, List<WeakReference<PlayableCard>>> CardInfoToCard = new();

/// <summary>
/// ChangeCardCostGetter patches BloodCost so we can change the cost on the fly
/// This reverse patch gives us access to the original method without any changes.
/// This method has a copy of all the code that CardInfo.BloodCost had so it doesn't result in a StackOverflow and freezing the game when called.
/// </summary>
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BloodCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
public static int OriginalBloodCost(CardInfo __instance) { return 0; }

/// <summary>
/// ChangeCardCostGetter patches BoneCost so we can change the cost on the fly
/// This reverse patch gives us access to the original method without any changes.
/// This method has a copy of all the code that CardInfo.BoneCost had so it doesn't result in a StackOverflow and freezing the game when called.
/// </summary>
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BonesCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
public static int OriginalBonesCost(CardInfo __instance) { return 0; }

/// <summary>
/// ChangeCardCostGetter patches GemsCost so we can change the cost on the fly
/// This reverse patch gives us access to the original method without any changes.
Expand Down Expand Up @@ -155,7 +154,7 @@ public static bool BloodCost(CardInfo __instance, ref int __result)
__result = Mathf.Max(0, card?.BloodCost() ?? CostProperties.OriginalBloodCost(__instance));
return false;
}

[HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BonesCost), MethodType.Getter), HarmonyPrefix]
public static bool BoneCost(CardInfo __instance, ref int __result)
{
Expand All @@ -166,15 +165,15 @@ public static bool BoneCost(CardInfo __instance, ref int __result)
__result = Mathf.Max(0, card.BonesCost());
return false;
}

[HarmonyPatch(typeof(CardInfo), nameof(CardInfo.GemsCost), MethodType.Getter), HarmonyPrefix]
public static bool GemsCost(CardInfo __instance, ref List<GemType> __result)
{
PlayableCard card = __instance.GetPlayableCard();
__result = card?.GemsCost() ?? CostProperties.ImprovedGemsCost(__instance);
return false;
}

[HarmonyPatch(typeof(CardInfo), nameof(CardInfo.EnergyCost), MethodType.Getter), HarmonyPrefix]
public static bool EnergyCost(CardInfo __instance, ref int __result)
{
Expand Down Expand Up @@ -297,10 +296,10 @@ private static IEnumerable<MethodBase> TargetMethods()
yield return AccessTools.Method(typeof(TurnManager), nameof(TurnManager.CleanupPhase));
yield return AccessTools.Method(typeof(GBCEncounterManager), nameof(GBCEncounterManager.LoadOverworldScene));
}

private static void Postfix()
{
// NOTE: This is a hack to clear the table
CostProperties.CardInfoToCard = new ConditionalWeakTable<CardInfo, List<WeakReference<PlayableCard>>>();
CostProperties.CardInfoToCard = new ConditionalWeakTable<CardInfo, List<WeakReference<PlayableCard>>>();
}
}
6 changes: 3 additions & 3 deletions InscryptionAPI/Card/DamageShieldBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using DiskCardGame;
using GBC;
using HarmonyLib;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Triggers;
using System.Collections;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace InscryptionAPI.Card;
Expand All @@ -20,10 +17,13 @@ public abstract class DamageShieldBehaviour : AbilityBehaviour
public abstract int StartingNumShields { get; } // how many shields this sigil will provide initially
public bool HasShields() => NumShields > 0;

public bool initialised = false;
public virtual void Start()
{
if (base.Card != null)
numShields = StartingNumShields;

initialised = true;
}

public virtual void AddShields(int amount, bool updateDisplay = true)
Expand Down
Loading
Loading