diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 62b38921..7e326466 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08fe6113..89d00a9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
-
-View Changelog
+# 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.
@@ -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.
-
-
+- Hooked into a much more sensible method to load the cards into the card pool.
\ No newline at end of file
diff --git a/InscryptionAPI/Ascension/AscensionChallengePaginator.cs b/InscryptionAPI/Ascension/AscensionChallengePaginator.cs
index 514bfdc8..aaff322d 100644
--- a/InscryptionAPI/Ascension/AscensionChallengePaginator.cs
+++ b/InscryptionAPI/Ascension/AscensionChallengePaginator.cs
@@ -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;
@@ -21,7 +17,7 @@ public void Initialize(AscensionChallengeScreen screen, AscensionMenuScreenTrans
{
//List firstPageObjs = new();
List icons;
-
+
// if the screen object exists, use its list of icons; otherwise use the screenInteractables from the transition object
if (screen != null)
{
@@ -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()
@@ -180,7 +176,7 @@ public void OnEnable()
ChallengeManager.SyncChallengeList();
Initialize(GetComponent(), GetComponent());
-
+
if (leftArrow)
{
Destroy(leftArrow.gameObject);
@@ -202,7 +198,7 @@ public void OnEnable()
if (screen != null)
{
screen.icons?.RemoveAll(x => x == null);
-
+
icons = screen.icons;
pageLength = screen.icons.Count;
}
@@ -287,7 +283,7 @@ public void OnEnable()
challengeObjectsForPages.ForEach(x => x.RemoveAll(x => x == null));
LoadPage(pageIndex = 0);
-
+
if (pagesToAdd.Count == 0)
return;
diff --git a/InscryptionAPI/Ascension/AscensionChallengePaginatorSetupifier.cs b/InscryptionAPI/Ascension/AscensionChallengePaginatorSetupifier.cs
index 64569402..5e85925d 100644
--- a/InscryptionAPI/Ascension/AscensionChallengePaginatorSetupifier.cs
+++ b/InscryptionAPI/Ascension/AscensionChallengePaginatorSetupifier.cs
@@ -1,5 +1,4 @@
using DiskCardGame;
-using UnityEngine;
namespace InscryptionAPI.Ascension;
diff --git a/InscryptionAPI/Ascension/AscensionChallengeScreen.cs b/InscryptionAPI/Ascension/AscensionChallengeScreen.cs
index 0329cecf..fa2bf6c9 100644
--- a/InscryptionAPI/Ascension/AscensionChallengeScreen.cs
+++ b/InscryptionAPI/Ascension/AscensionChallengeScreen.cs
@@ -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());
diff --git a/InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs b/InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs
index 48460dd7..67cf8272 100644
--- a/InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs
+++ b/InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs
@@ -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);
}
}
@@ -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);
}
diff --git a/InscryptionAPI/Ascension/ChallengeManager.cs b/InscryptionAPI/Ascension/ChallengeManager.cs
index 5ee288ab..5824764b 100644
--- a/InscryptionAPI/Ascension/ChallengeManager.cs
+++ b/InscryptionAPI/Ascension/ChallengeManager.cs
@@ -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.
///
public Func CustomUnlockCheck { get; set; }
-
+
///
/// 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.
///
diff --git a/InscryptionAPI/Card/AbilityManager.cs b/InscryptionAPI/Card/AbilityManager.cs
index 026a3a00..a4d58c6f 100644
--- a/InscryptionAPI/Card/AbilityManager.cs
+++ b/InscryptionAPI/Card/AbilityManager.cs
@@ -36,7 +36,7 @@ public class FullAbility
/// The unique ID for this ability
///
public readonly Ability Id;
-
+
///
/// The guid of the mod that added this ability
///
@@ -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.
///
public Dictionary RulebookDescriptionRedirects = new();
-
+
internal static ConditionalWeakTable ReverseMapper = new();
///
@@ -265,7 +265,7 @@ private static List GenBaseGameAbilityList()
baseGame.Add(ab);
continue;
}
- baseGame.Add(new FullAbility (
+ baseGame.Add(new FullAbility(
null,
ability.ability,
ability,
@@ -276,7 +276,7 @@ private static List GenBaseGameAbilityList()
return baseGame;
}
-
+
///
/// Creates a new ability and registers it to be able to be added to cards
///
diff --git a/InscryptionAPI/Card/BasePart2Modular.cs b/InscryptionAPI/Card/BasePart2Modular.cs
index 7a575c18..357b626d 100644
--- a/InscryptionAPI/Card/BasePart2Modular.cs
+++ b/InscryptionAPI/Card/BasePart2Modular.cs
@@ -1,7 +1,4 @@
using DiskCardGame;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace InscryptionAPI.Card;
internal class Part2ModularAbilities
diff --git a/InscryptionAPI/Card/CardExtensions.cs b/InscryptionAPI/Card/CardExtensions.cs
index 78dfcd98..bdbcf3f5 100644
--- a/InscryptionAPI/Card/CardExtensions.cs
+++ b/InscryptionAPI/Card/CardExtensions.cs
@@ -1,8 +1,5 @@
using DiskCardGame;
using InscryptionAPI.Helpers;
-using InscryptionAPI.Nodes;
-using Sirenix.Utilities;
-using System.Collections;
using UnityEngine;
namespace InscryptionAPI.Card;
@@ -343,7 +340,7 @@ public static CardInfo RemoveTraits(this CardInfo info, params Trait[] traits)
}
return info;
}
-
+
///
/// Removes any number of traits from the card.
///
diff --git a/InscryptionAPI/Card/CardExtensionsHelpers.cs b/InscryptionAPI/Card/CardExtensionsHelpers.cs
index 05f3a004..5dc89db1 100644
--- a/InscryptionAPI/Card/CardExtensionsHelpers.cs
+++ b/InscryptionAPI/Card/CardExtensionsHelpers.cs
@@ -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;
}
///
diff --git a/InscryptionAPI/Card/CardManager.cs b/InscryptionAPI/Card/CardManager.cs
index 1a01cbff..b4de2a81 100644
--- a/InscryptionAPI/Card/CardManager.cs
+++ b/InscryptionAPI/Card/CardManager.cs
@@ -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;
@@ -22,7 +21,7 @@ private class CardExt // Needs to be defined first so the implicit static constr
public readonly Dictionary TypeMap = new();
public readonly Dictionary StringMap = new();
}
- public class CardAltPortraits
+ public class CardAltPortraits
{
public Sprite PixelAlternatePortrait = null;
public Sprite SteelTrapPortrait = null;
@@ -86,7 +85,7 @@ public static void SyncCardList()
card.evolveParams.evolution.Mods = mods;
}
- if (card.iceCubeParams != null && card.iceCubeParams.creatureWithin != null)
+ if (card.iceCubeParams != null && card.iceCubeParams.creatureWithin != null)
{
List mods = card.iceCubeParams.creatureWithin.Mods;
card.iceCubeParams.creatureWithin = cards.CardByName(card.iceCubeParams.creatureWithin.name).Clone() as CardInfo;
@@ -295,7 +294,7 @@ public static CardInfo New(string modPrefix, string name, string displayName, in
public static Dictionary 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;
diff --git a/InscryptionAPI/Card/CardModificationInfoExtensions.cs b/InscryptionAPI/Card/CardModificationInfoExtensions.cs
index fb5dab09..f299b425 100644
--- a/InscryptionAPI/Card/CardModificationInfoExtensions.cs
+++ b/InscryptionAPI/Card/CardModificationInfoExtensions.cs
@@ -1,7 +1,6 @@
using DiskCardGame;
using InscryptionAPI.CardCosts;
using Sirenix.Utilities;
-using UnityEngine;
using static InscryptionAPI.Card.CardModificationInfoManager;
namespace InscryptionAPI.Card;
@@ -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)
@@ -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))
{
@@ -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(']');
diff --git a/InscryptionAPI/Card/CardModificationInfoManager.cs b/InscryptionAPI/Card/CardModificationInfoManager.cs
index bd31a6b9..765adb38 100644
--- a/InscryptionAPI/Card/CardModificationInfoManager.cs
+++ b/InscryptionAPI/Card/CardModificationInfoManager.cs
@@ -3,7 +3,6 @@
using InscryptionAPI.CardCosts;
using Sirenix.Serialization.Utilities;
using System.Runtime.CompilerServices;
-using UnityEngine;
namespace InscryptionAPI.Card;
diff --git a/InscryptionAPI/Card/CostProperties.cs b/InscryptionAPI/Card/CostProperties.cs
index cab30bea..c89a4cef 100644
--- a/InscryptionAPI/Card/CostProperties.cs
+++ b/InscryptionAPI/Card/CostProperties.cs
@@ -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;
@@ -69,7 +68,7 @@ public bool GemsChanged(List a, List b)
}
public static ConditionalWeakTable>> CardInfoToCard = new();
-
+
///
/// 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.
@@ -77,7 +76,7 @@ public bool GemsChanged(List a, List b)
///
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BloodCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
public static int OriginalBloodCost(CardInfo __instance) { return 0; }
-
+
///
/// 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.
@@ -85,7 +84,7 @@ public bool GemsChanged(List a, List b)
///
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BonesCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
public static int OriginalBonesCost(CardInfo __instance) { return 0; }
-
+
///
/// 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.
@@ -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)
{
@@ -166,7 +165,7 @@ 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 __result)
{
@@ -174,7 +173,7 @@ public static bool GemsCost(CardInfo __instance, ref List __result)
__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)
{
@@ -297,10 +296,10 @@ private static IEnumerable 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>>();
+ CostProperties.CardInfoToCard = new ConditionalWeakTable>>();
}
}
\ No newline at end of file
diff --git a/InscryptionAPI/Card/DamageShieldBehaviour.cs b/InscryptionAPI/Card/DamageShieldBehaviour.cs
index 9f9be3c3..3bc475f5 100644
--- a/InscryptionAPI/Card/DamageShieldBehaviour.cs
+++ b/InscryptionAPI/Card/DamageShieldBehaviour.cs
@@ -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;
@@ -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)
diff --git a/InscryptionAPI/Card/ShieldManager.cs b/InscryptionAPI/Card/ShieldManager.cs
index e1677777..3b86062a 100644
--- a/InscryptionAPI/Card/ShieldManager.cs
+++ b/InscryptionAPI/Card/ShieldManager.cs
@@ -4,7 +4,6 @@
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Triggers;
using System.Collections;
-using System.Collections.ObjectModel;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;
@@ -104,7 +103,7 @@ private static bool PreventShieldReset(PlayableCard target)
[HarmonyPrefix, HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.ResetShield), new Type[] { })]
private static void ResetModShields(PlayableCard __instance) // runs before the base ResetShield logic
{
- foreach (var com in __instance.GetComponents())
+ foreach (DamageShieldBehaviour com in __instance.GetComponents())
com.ResetShields(false);
// if we're using the broken shield portrait, reset to the default portrait - if we're MudTurtle
@@ -216,23 +215,26 @@ private static List HiddensOnlyRemoveStacks(List abilities, Li
{
// remove all abilities that hide the entire stack
abilities.RemoveAll(x => hiddenAbilities.Contains(x) && !x.GetHideSingleStacks());
- foreach (var ab in hiddenAbilities.Where(x => x.GetHideSingleStacks()))
+ foreach (Ability ab in hiddenAbilities.Where(x => x.GetHideSingleStacks()))
abilities.Remove(ab);
+
return abilities;
}
private static void CorrectHiddenAbilityRender(PlayableCard card)
{
- foreach (var com in card.GetComponents())
+ foreach (DamageShieldBehaviour com in card.GetComponents().Where(x => x.initialised))
{
if (com.HasShields())
{
if (com.Ability.GetHideSingleStacks())
{
// if there are more hidden shields than there should be
- int removeStacks = card.Status.hiddenAbilities.Count(x => x == com.Ability) - com.NumShields;
- for (int i = 0; i < removeStacks; i++)
+ if (card.Status.hiddenAbilities.Count(x => x == com.Ability) >= com.NumShields)
{
- card.Status.hiddenAbilities.Remove(com.Ability);
+ for (int i = 0; i < com.NumShields; i++)
+ {
+ card.Status.hiddenAbilities.Remove(com.Ability);
+ }
}
}
else
@@ -245,11 +247,13 @@ private static void CorrectHiddenAbilityRender(PlayableCard card)
{
if (com.Ability.GetHideSingleStacks())
{
+ card.AddShieldCount(1, Ability.DeathShield);
int shieldsLost = com.StartingNumShields - com.NumShields;
if (card.Status.hiddenAbilities.Count(x => x == com.Ability) < shieldsLost)
{
for (int i = 0; i < shieldsLost; i++)
{
+ //Debug.Log($"{com.StartingNumShields} {com.NumShields} {shieldsLost} Add hidden");
card.Status.hiddenAbilities.Add(com.Ability);
}
}
@@ -271,7 +275,7 @@ private static void CorrectHiddenAbilityRender(PlayableCard card)
card.RenderCard();
}
- [HarmonyPostfix, HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.AddTemporaryMod))]
+ [HarmonyPrefix, HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.AddTemporaryMod))]
private static void AddTemporaryShieldCount(PlayableCard __instance, CardModificationInfo mod)
{
if (__instance == null || mod == null)
@@ -287,7 +291,7 @@ private static void AddTemporaryShieldCount(PlayableCard __instance, CardModific
{
DamageShieldBehaviour behaviour = __instance.TriggerHandler.triggeredAbilities.Find(x => x.Item1 == ability).Item2 as DamageShieldBehaviour;
behaviour.AddShields(1);
- //InscryptionAPIPlugin.Logger.LogInfo($"Add: {__instance.Info.name} {behaviour.NumShields} <-- {behaviour.NumShields - 1}");
+ //InscryptionAPIPlugin.Logger.LogInfo($"Add: {__instance.Info.name} {behaviour.NumShields - 1} --> {behaviour.NumShields}");
}
}
}
diff --git a/InscryptionAPI/Card/SpecialTriggeredAbilityManager.cs b/InscryptionAPI/Card/SpecialTriggeredAbilityManager.cs
index 5a91774c..87da2522 100644
--- a/InscryptionAPI/Card/SpecialTriggeredAbilityManager.cs
+++ b/InscryptionAPI/Card/SpecialTriggeredAbilityManager.cs
@@ -15,7 +15,7 @@ public class FullSpecialTriggeredAbility
public FullSpecialTriggeredAbility(SpecialTriggeredAbility id, Type abilityBehaviour) : this(null, abilityBehaviour.ToString(), id, abilityBehaviour)
{
-
+
}
public FullSpecialTriggeredAbility(string guid, string name, SpecialTriggeredAbility id, Type abilityBehaviour)
diff --git a/InscryptionAPI/Costs/CardCostManager.cs b/InscryptionAPI/Costs/CardCostManager.cs
index de555d5e..60a1800d 100644
--- a/InscryptionAPI/Costs/CardCostManager.cs
+++ b/InscryptionAPI/Costs/CardCostManager.cs
@@ -4,7 +4,6 @@
using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Guid;
-using InscryptionAPI.Helpers;
using Sirenix.Utilities;
using System.Collections;
using System.Collections.ObjectModel;
@@ -207,7 +206,7 @@ static CardCostManager()
public static List AllCustomCosts { get; private set; } = new();
internal readonly static ObservableCollection NewCosts = new();
-
+
public static event Func, List> ModifyCustomCostList;
// you don't have the [colour] gem for that.
diff --git a/InscryptionAPI/Dialogue/DialogueManager.cs b/InscryptionAPI/Dialogue/DialogueManager.cs
index 435a289c..c19f5e51 100644
--- a/InscryptionAPI/Dialogue/DialogueManager.cs
+++ b/InscryptionAPI/Dialogue/DialogueManager.cs
@@ -40,7 +40,7 @@ public static Dialogue Add(string pluginGUID, DialogueEvent dialogueEvent)
DialogueDataUtil.Data?.events?.RemoveAll(d => d.id == dialogueEvent.id);
DialogueDataUtil.Data?.events?.Add(dialogueEvent);
-
+
return dialogue;
}
diff --git a/InscryptionAPI/Encounters/EncounterExtensions.cs b/InscryptionAPI/Encounters/EncounterExtensions.cs
index c5f4b220..99a1950e 100644
--- a/InscryptionAPI/Encounters/EncounterExtensions.cs
+++ b/InscryptionAPI/Encounters/EncounterExtensions.cs
@@ -1,9 +1,9 @@
-using System.Collections;
-using System.Runtime.CompilerServices;
using DiskCardGame;
using GBC;
using HarmonyLib;
using InscryptionAPI.Card;
+using System.Collections;
+using System.Runtime.CompilerServices;
using static DiskCardGame.EncounterBlueprintData;
namespace InscryptionAPI.Encounters;
diff --git a/InscryptionAPI/Encounters/OpponentManager.cs b/InscryptionAPI/Encounters/OpponentManager.cs
index 46909bcb..7548873d 100644
--- a/InscryptionAPI/Encounters/OpponentManager.cs
+++ b/InscryptionAPI/Encounters/OpponentManager.cs
@@ -179,7 +179,7 @@ private static bool ReplacePrefabPath(ref string __result, Opponent.Type ___boss
__result = obj != null ? fullPath : "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss";
return false;
}
-
+
[HarmonyPatch(typeof(Opponent), nameof(Opponent.CreateCard))]
[HarmonyPrefix]
private static bool CloneCardInfo(ref CardInfo cardInfo)
@@ -188,7 +188,7 @@ private static bool CloneCardInfo(ref CardInfo cardInfo)
cardInfo = (CardInfo)cardInfo.Clone();
return true;
}
-
+
[HarmonyPatch]
private class MapGenerator_CreateNode
{
@@ -309,7 +309,7 @@ internal class PreventCallsOnScenary_Patches
{
private static readonly Type StartNewPhaseSequence = Type.GetType("DiskCardGame.TrapperTraderBossOpponent+d__6, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
private static readonly MethodInfo PlayAnimationInfo = AccessTools.Method(typeof(PreventCallsOnScenary_Patches), nameof(PlayAnimation), new[] { typeof(Animation), typeof(string) });
-
+
private static IEnumerable TargetMethods()
{
yield return AccessTools.Method(StartNewPhaseSequence, "MoveNext");
@@ -324,21 +324,21 @@ private static IEnumerable Transpiler(IEnumerable(), "knives_table_exit");
-
+
List codes = new List(instructions);
for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode == OpCodes.Ldstr && codes[i].operand == "knives_table_exit")
{
-
+
// ldstr "knives_table_exit"
- codes[i+1] = new CodeInstruction(OpCodes.Call, PlayAnimationInfo); // callvirt instance bool [UnityEngine.AnimationModule]UnityEngine.Animation::Play(string)
+ codes[i + 1] = new CodeInstruction(OpCodes.Call, PlayAnimationInfo); // callvirt instance bool [UnityEngine.AnimationModule]UnityEngine.Animation::Play(string)
// pop
break;
}
}
-
+
return codes;
}
diff --git a/InscryptionAPI/Guid/GuidManager.cs b/InscryptionAPI/Guid/GuidManager.cs
index 3ffb0f31..199857ee 100644
--- a/InscryptionAPI/Guid/GuidManager.cs
+++ b/InscryptionAPI/Guid/GuidManager.cs
@@ -74,7 +74,7 @@ unsafe public static T GetEnumValue(string guid, string value) where T : unma
reverseMapper[enumValue] = typeof(T);
return *(T*)&enumValue;
}
-
+
public static bool TryGetGuidAndKeyEnumValue(T value, out string guid, out string key) where T : System.Enum
{
string prefix = $"{typeof(T).Name}";
diff --git a/InscryptionAPI/Helpers/CustomFields.cs b/InscryptionAPI/Helpers/CustomFields.cs
index 8f4d24fb..4091247e 100644
--- a/InscryptionAPI/Helpers/CustomFields.cs
+++ b/InscryptionAPI/Helpers/CustomFields.cs
@@ -5,105 +5,107 @@ namespace InscryptionAPI.Helpers;
///
/// Allows for an easy way to add custom fields to an object, or to an entire class.
///
-public static class CustomFields {
- static ConditionalWeakTable> objectFields = new ConditionalWeakTable>();
+public static class CustomFields
+{
+ static ConditionalWeakTable> objectFields = new ConditionalWeakTable>();
- ///
- /// Returns a custom field.
- ///
- /// The type of the custom field.
- /// The object which has the custom field.
- /// The name of the custom field.
- /// A custom field of type T. If the field is not found, default(T) is returned.
- public static T Get(object obj, string field)
- {
- if (!HasField(obj, field)) Set(obj, field, default(T));
+ ///
+ /// Returns a custom field.
+ ///
+ /// The type of the custom field.
+ /// The object which has the custom field.
+ /// The name of the custom field.
+ /// A custom field of type T. If the field is not found, default(T) is returned.
+ public static T Get(object obj, string field)
+ {
+ if (!HasField(obj, field)) Set(obj, field, default(T));
- objectFields.TryGetValue(obj, out Dictionary fields);
- return (T)fields[field];
- }
+ objectFields.TryGetValue(obj, out Dictionary fields);
+ return (T)fields[field];
+ }
- ///
- /// Returns a static custom field.
- ///
- /// The type of the custom field.
- /// The class the static field is stored on.
- /// The name of the custom field.
- /// A custom field of type T. If the field is not found, default(T) is returned.
- public static T GetStatic(string field)
- => Get(typeof(C), field);
+ ///
+ /// Returns a static custom field.
+ ///
+ /// The type of the custom field.
+ /// The class the static field is stored on.
+ /// The name of the custom field.
+ /// A custom field of type T. If the field is not found, default(T) is returned.
+ public static T GetStatic(string field)
+ => Get(typeof(C), field);
- ///
- /// Returns a static custom field.
- ///
- /// The type of the custom field.
- /// The name of the custom field.
- /// The type of the class the static field is stored on.
- /// A custom field of type T. If the field is not found, default(T) is returned.
- public static T GetStatic(string field, Type classType)
- => Get(classType, field);
+ ///
+ /// Returns a static custom field.
+ ///
+ /// The type of the custom field.
+ /// The name of the custom field.
+ /// The type of the class the static field is stored on.
+ /// A custom field of type T. If the field is not found, default(T) is returned.
+ public static T GetStatic(string field, Type classType)
+ => Get(classType, field);
- ///
- /// Set a custom field.
- ///
- /// The object which you want to store the custom field on.
- /// The name of the custom field.
- /// The value of the custom field.
- public static void Set(object obj, string field, object value)
- {
- if (!objectFields.TryGetValue(obj, out Dictionary fields)) {
- fields = new Dictionary() ;
- objectFields.Add(obj, fields);
- }
+ ///
+ /// Set a custom field.
+ ///
+ /// The object which you want to store the custom field on.
+ /// The name of the custom field.
+ /// The value of the custom field.
+ public static void Set(object obj, string field, object value)
+ {
+ if (!objectFields.TryGetValue(obj, out Dictionary fields))
+ {
+ fields = new Dictionary();
+ objectFields.Add(obj, fields);
+ }
- fields[field] = value;
- }
+ fields[field] = value;
+ }
- ///
- /// Set a static custom field.
- ///
- /// The class which you want to store the static field is stored on.
- /// The name of the custom field.
- /// The value of the custom field.
- public static void SetStatic(string field, object value)
- => Set(typeof(C), field, value);
+ ///
+ /// Set a static custom field.
+ ///
+ /// The class which you want to store the static field is stored on.
+ /// The name of the custom field.
+ /// The value of the custom field.
+ public static void SetStatic(string field, object value)
+ => Set(typeof(C), field, value);
- ///
- /// Set a static custom field.
- ///
- /// The name of the custom field.
- /// The value of the custom field.
- /// The type of the class which you want to store the static field is stored on.
- public static void SetStatic(string field, object value, Type classType)
- => Set(classType, field, value);
+ ///
+ /// Set a static custom field.
+ ///
+ /// The name of the custom field.
+ /// The value of the custom field.
+ /// The type of the class which you want to store the static field is stored on.
+ public static void SetStatic(string field, object value, Type classType)
+ => Set(classType, field, value);
- ///
- /// Check if an object currently stores a custom field.
- ///
- /// The object to check.
- /// The name of the custom field to check for.
- /// True if the object is storing the custom field.
- public static bool HasField(object obj, string field)
- {
- if (!objectFields.TryGetValue(obj, out Dictionary fields)) return false;
- return fields.ContainsKey(field);
- }
+ ///
+ /// Check if an object currently stores a custom field.
+ ///
+ /// The object to check.
+ /// The name of the custom field to check for.
+ /// True if the object is storing the custom field.
+ public static bool HasField(object obj, string field)
+ {
+ if (!objectFields.TryGetValue(obj, out Dictionary fields)) return false;
+ return fields.ContainsKey(field);
+ }
- ///
- /// Check if a class currently stores a static custom field.
- ///
- /// The class which you want to check.
- /// The name of the static custom field to check for.
- /// True if the class is storing the static custom field.
- public static bool HasStaticField(string field)
- => HasField(typeof(C), field);
+ ///
+ /// Check if a class currently stores a static custom field.
+ ///
+ /// The class which you want to check.
+ /// The name of the static custom field to check for.
+ /// True if the class is storing the static custom field.
+ public static bool HasStaticField(string field)
+ => HasField(typeof(C), field);
- ///
- /// Check if a class currently stores a static custom field.
- ///
- /// The name of the static custom field to check for.
- /// The type of the class which you want to check.
- /// True if the class is storing the static custom field.
- public static bool HasStaticField(string field, Type classType)
- => HasField(classType, field);
+ ///
+ /// Check if a class currently stores a static custom field.
+ ///
+ /// The name of the static custom field to check for.
+ /// The type of the class which you want to check.
+ /// True if the class is storing the static custom field.
+ public static bool HasStaticField(string field, Type classType)
+ => HasField(classType, field);
}
\ No newline at end of file
diff --git a/InscryptionAPI/Helpers/Extensions/BoardManagerExtensions.cs b/InscryptionAPI/Helpers/Extensions/BoardManagerExtensions.cs
index c27433e4..19e94781 100644
--- a/InscryptionAPI/Helpers/Extensions/BoardManagerExtensions.cs
+++ b/InscryptionAPI/Helpers/Extensions/BoardManagerExtensions.cs
@@ -39,6 +39,16 @@ public static List GetCards(
Predicate filterOnPredicate = null
) => manager.GetSlotsCopy(getPlayerCards).SelectCards(filterOnPredicate).ToList();
+ ///
+ /// Retrieve all cards on the board that match the predicate, if given.
+ ///
+ /// Manager instance to access.
+ /// The predicate to filter on each card.
+ /// The list of relevant cards on the board.
+ public static List GetCards(this BoardManager manager, Predicate filterOnPredicate = null)
+ => manager.AllSlotsCopy.SelectCards(filterOnPredicate).ToList();
+
+
///
/// Retrieve all player slots that are not occupied by a card.
///
@@ -74,6 +84,17 @@ public static List GetOpenSlots(
Predicate filterOnPredicate = null
) => manager.GetSlotsCopy(getPlayerSlots).SelectOpenSlots(filterOnPredicate).ToList();
+ ///
+ /// Retrieve all slots on the board that are not occupied by a card.
+ ///
+ /// Manager instance to access.
+ /// The predicate to filter on each slot.
+ /// The list of relevant card slots with no cards.
+ public static List GetOpenSlots(
+ this BoardManager manager,
+ Predicate filterOnPredicate = null
+ ) => manager.AllSlotsCopy.SelectOpenSlots(filterOnPredicate).ToList();
+
///
/// Retrieve a copy of the board slots for the player or opponent's side of the board.
///
@@ -84,7 +105,6 @@ public static List GetOpenSlots(
public static List GetSlotsCopy(this BoardManager manager, bool getPlayerSlotsCopy)
=> getPlayerSlotsCopy ? manager.PlayerSlotsCopy : manager.OpponentSlotsCopy;
-
///
/// Retrieve all player or opponent card slots on the board.
///
diff --git a/InscryptionAPI/Helpers/ResourcesManagerHelpers.cs b/InscryptionAPI/Helpers/ResourcesManagerHelpers.cs
index 5f369c6a..95170918 100644
--- a/InscryptionAPI/Helpers/ResourcesManagerHelpers.cs
+++ b/InscryptionAPI/Helpers/ResourcesManagerHelpers.cs
@@ -109,7 +109,7 @@ public static bool PlayerHasGems(params GemType[] gems)
public static class GetEmptyBatterySprite
{
public static Sprite emptyBatterySprite = null;
-
+
[HarmonyPostfix]
private static void GetSprite(PixelResourcesManager __instance)
{
diff --git a/InscryptionAPI/Helpers/TextureHelper.cs b/InscryptionAPI/Helpers/TextureHelper.cs
index 7d1f2e54..742e1e45 100644
--- a/InscryptionAPI/Helpers/TextureHelper.cs
+++ b/InscryptionAPI/Helpers/TextureHelper.cs
@@ -80,7 +80,11 @@ public enum SpriteType : int
///
/// The texture for a button in Act 2 (same kind of button used for the hammer and activated sigils).
///
- PixelStandardButton = 12
+ PixelStandardButton = 12,
+
+ Act2CostVanillaLeft = 13,
+
+ Act2CostVanillaRight = 14
};
private static Vector2 DEFAULT_PIVOT = new(0.5f, 0.5f);
@@ -89,8 +93,8 @@ public enum SpriteType : int
private static readonly Dictionary SPRITE_RECTS = new()
{
- { SpriteType.CardPortrait, new Rect(0.0f, 0.0f, 114.0f, 94.0f) },
- { SpriteType.PixelPortrait, new Rect(0.0f, 0.0f, 41.0f, 28.0f) },
+ { SpriteType.CardPortrait, new Rect(0f, 0f, 114f, 94f) },
+ { SpriteType.PixelPortrait, new Rect(0f, 0f, 41f, 28f) },
{ SpriteType.PixelAbilityIcon, new Rect(0f, 0f, 17f, 17f) },
{ SpriteType.PixelStatIcon, new Rect(0f, 0f, 16f, 8f) },
{ SpriteType.ChallengeIcon, new Rect(0f, 0f, 49f, 49f) },
@@ -101,7 +105,9 @@ public enum SpriteType : int
{ SpriteType.StarterDeckIcon, new Rect(0f, 0f, 35f, 44f) },
{ SpriteType.PixelDecal, new Rect(0f, 0f, 42f, 56f) },
{ SpriteType.PixelActivatedAbilityIcon, new Rect(0f, 0f, 22f, 10f) },
- { SpriteType.PixelStandardButton, new Rect(0f, 0f, 26f, 17f) }
+ { SpriteType.PixelStandardButton, new Rect(0f, 0f, 26f, 17f) },
+ { SpriteType.Act2CostVanillaLeft, new Rect(0f, 0f, 48f, 28f) }, // vanilla costs should have a creme border on the left and right so we don't need padding
+ { SpriteType.Act2CostVanillaRight, new Rect(0f, 0f, 48f, 28f) }
};
private static readonly Dictionary SPRITE_PIVOTS = new()
@@ -118,7 +124,9 @@ public enum SpriteType : int
{ SpriteType.StarterDeckIcon, DEFAULT_PIVOT },
{ SpriteType.PixelDecal, DEFAULT_PIVOT },
{ SpriteType.PixelActivatedAbilityIcon, DEFAULT_PIVOT },
- { SpriteType.PixelStandardButton, new Vector2(0.5f, 0f) }
+ { SpriteType.PixelStandardButton, new Vector2(0.5f, 0f) },
+ { SpriteType.Act2CostVanillaLeft, new Vector2(0.58f, 0.77f) },
+ { SpriteType.Act2CostVanillaRight, new Vector2(0.75f, 0.77f) }
};
///
@@ -247,18 +255,18 @@ public static Sprite GetEmissionSprite(this Sprite sprite)
{
if (sprite == null)
return null;
-
+
if (emissionMap.TryGetValue(sprite, out Sprite emission))
return emission;
-
-
+
+
string text = sprite.name + "_emission";
emission = ResourceBank.Get("Art/Cards/Portraits/" + text);
if (emission != null)
{
return emission;
}
-
+
emission = ResourceBank.Get("Art/Cards/GrimoraPortraits/" + text);
if (emission != null)
{
diff --git a/InscryptionAPI/InscryptionAPI.csproj b/InscryptionAPI/InscryptionAPI.csproj
index 97fe1263..44ac6e8e 100644
--- a/InscryptionAPI/InscryptionAPI.csproj
+++ b/InscryptionAPI/InscryptionAPI.csproj
@@ -10,7 +10,7 @@
full
false
true
- 2.22.3
+ 2.23.0
diff --git a/InscryptionAPI/InscryptionAPIPlugin.cs b/InscryptionAPI/InscryptionAPIPlugin.cs
index 8ba20cbe..ffeadde4 100644
--- a/InscryptionAPI/InscryptionAPIPlugin.cs
+++ b/InscryptionAPI/InscryptionAPIPlugin.cs
@@ -30,7 +30,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
{
public const string ModGUID = "cyantist.inscryption.api";
public const string ModName = "InscryptionAPI";
- public const string ModVer = "2.22.3";
+ public const string ModVer = "2.23.0";
public static string Directory = "";
@@ -66,7 +66,7 @@ private void OnEnable()
{
Logger = base.Logger;
Directory = Path.GetDirectoryName(Info.Location);
-
+
HarmonyInstance.PatchAll(typeof(InscryptionAPIPlugin).Assembly);
}
@@ -127,7 +127,7 @@ private void Start()
PeltManager.CreateDialogueEvents();
if (!DialogueManager.CustomDialogue.Exists(x => x.DialogueEvent.id == "Hint_NotEnoughSameColourGemsHint"))
{
-
+
}
Logger.LogDebug($"Inserted {DialogueManager.CustomDialogue.Count} dialogue event(s)!");
}
diff --git a/InscryptionAPI/Items/ConsumableItemManager.cs b/InscryptionAPI/Items/ConsumableItemManager.cs
index 8f5c395a..a54a17bb 100644
--- a/InscryptionAPI/Items/ConsumableItemManager.cs
+++ b/InscryptionAPI/Items/ConsumableItemManager.cs
@@ -1,11 +1,9 @@
using DiskCardGame;
-using HarmonyLib;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Items.Extensions;
using InscryptionAPI.RuleBook;
-using System.Collections;
using System.Collections.ObjectModel;
using System.Reflection;
using UnityEngine;
diff --git a/InscryptionAPI/Items/ConsumableItemPatches.cs b/InscryptionAPI/Items/ConsumableItemPatches.cs
index ba56f41d..995fbcf5 100644
--- a/InscryptionAPI/Items/ConsumableItemPatches.cs
+++ b/InscryptionAPI/Items/ConsumableItemPatches.cs
@@ -1,15 +1,10 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Boons;
-using InscryptionAPI.Helpers;
using InscryptionAPI.Items.Extensions;
using InscryptionAPI.RuleBook;
-using System;
using System.Collections;
-using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
-using System.Text;
using UnityEngine;
using static InscryptionAPI.Items.ConsumableItemManager;
diff --git a/InscryptionAPI/Localizing/LocalizationManager.cs b/InscryptionAPI/Localizing/LocalizationManager.cs
index 524e3b6f..269104ad 100644
--- a/InscryptionAPI/Localizing/LocalizationManager.cs
+++ b/InscryptionAPI/Localizing/LocalizationManager.cs
@@ -1,6 +1,6 @@
-using System.Text;
using HarmonyLib;
using InscryptionAPI.Guid;
+using System.Text;
using TMPro;
using UnityEngine;
@@ -16,7 +16,7 @@ public class CustomLanguage
public string PathToStringTable;
public Language Language;
}
-
+
public class CustomTranslation
{
public string PluginGUID;
@@ -43,7 +43,7 @@ public enum FontReplacementType
public static string[] AllLanguageNames = new string[] { };
public static string[] AllLanguageButtonText = new string[] { };
-
+
public static List AllLanguages = new();
public static List NewLanguages = new();
public static List CustomTranslations = new();
@@ -87,7 +87,7 @@ static LocalizationManager()
}
}
- public static Language NewLanguage(string pluginGUID, string languageName, string code, string resetButtonText, string stringTablePath = null, List fontReplacements=null)
+ public static Language NewLanguage(string pluginGUID, string languageName, string code, string resetButtonText, string stringTablePath = null, List fontReplacements = null)
{
Language language = GuidManager.GetEnumValue(pluginGUID, languageName);
CustomLanguage customLanguage = new()
@@ -110,7 +110,7 @@ public static Language NewLanguage(string pluginGUID, string languageName, strin
AddFontReplacement(language, replacement);
}
}
-
+
return language;
}
@@ -125,7 +125,7 @@ public static void AddFontReplacement(Language language, FontReplacement replace
});
return;
}
-
+
FontReplacementData.LanguageFontReplacements replacements = FontReplacementData.instance.languageFontReplacements.Find((a) => a.languages.Contains(language));
if (replacements == null)
{
@@ -165,23 +165,23 @@ public static FontReplacement GetFontReplacementForFont(FontReplacementType type
InscryptionAPIPlugin.Logger.LogError("Unknown font replacement type: " + type.ToString().ToUpper());
return null;
}
-
+
if (replacement == null)
{
InscryptionAPIPlugin.Logger.LogError("Could not find font replacement for " + type.ToString().ToUpper());
return null;
}
-
- replacement = UnityObject.Instantiate(replacement);
+
+ replacement = UnityObject.Instantiate(replacement);
if (font != null || tmpFont != null)
{
replacement.replacementFont = font;
replacement.replacementTMPFont = tmpFont;
}
-
+
return replacement;
}
-
+
private static void ImportStringTable(string stringTablePath, Language language)
{
string lines = File.ReadAllText(stringTablePath);
@@ -347,7 +347,7 @@ private static void InsertTranslation(CustomTranslation customTranslation)
}
}
}
-
+
///
/// Retrieves the LanguageCode for the given Language.
///
@@ -358,7 +358,7 @@ public static string LanguageToCode(Language language)
{
return customLanguage.LanguageCode;
}
-
+
return null;
}
@@ -372,7 +372,7 @@ public static Language CodeToLanguage(string code)
{
return customLanguage.Language;
}
-
+
return Language.NUM_LANGUAGES;
}
@@ -412,7 +412,7 @@ public static void ExportAllToCSV()
File.WriteAllText(path, stringBuilder.ToString());
InscryptionAPIPlugin.Logger.LogInfo($"Exported .csv file to {path}");
}
-
+
[Obsolete("Use Translate() instead")]
public static CustomTranslation New(string pluginGUID, string id, string englishString, string translatedString, Language language)
{
diff --git a/InscryptionAPI/Localizing/LocalizationManager_Patches.cs b/InscryptionAPI/Localizing/LocalizationManager_Patches.cs
index 3ffe7d38..5f5e8c9c 100644
--- a/InscryptionAPI/Localizing/LocalizationManager_Patches.cs
+++ b/InscryptionAPI/Localizing/LocalizationManager_Patches.cs
@@ -1,7 +1,7 @@
-using System.Reflection;
using DiskCardGame;
using GBC;
using HarmonyLib;
+using System.Reflection;
using UnityEngine;
namespace InscryptionAPI.Localizing;
@@ -26,21 +26,21 @@ private static void Localization_ReadCSVFileIntoTranslationData(Language languag
OnLanguageLoaded?.Invoke(language);
}
-
+
[HarmonyPatch(typeof(Localization), nameof(Localization.TrySetToSystemLanguage))]
[HarmonyPrefix]
private static void Localization_TrySetToSystemLanguage()
{
foreach (CustomLanguage language in AllLanguages)
{
- if(language.LanguageName == Application.systemLanguage.ToString())
+ if (language.LanguageName == Application.systemLanguage.ToString())
{
Localization.CurrentLanguage = language.Language;
return;
}
}
}
-
+
[HarmonyPatch(typeof(OptionsUI), nameof(OptionsUI.OnSetLanguageButtonPressed))]
[HarmonyPrefix]
private static bool OptionsUI_OnSetLanguageButtonPressed(OptionsUI __instance)
@@ -49,7 +49,7 @@ private static bool OptionsUI_OnSetLanguageButtonPressed(OptionsUI __instance)
Localization.CurrentLanguage = NewLanguages[(__instance.languageField.Value - (int)Language.NUM_LANGUAGES)].Language;
else
Localization.CurrentLanguage = (Language)__instance.languageField.Value;
-
+
__instance.setLanguageButton.SetEnabled(enabled: false);
Singleton.Instance.SetEnabled(enabled: false);
CustomCoroutine.WaitThenExecute(0.1f, delegate
@@ -88,7 +88,7 @@ private static void FontReplacementData_Initialize()
[HarmonyPostfix]
private static void OptionsUI_OnLanguageChanged(OptionsUI __instance, int newValue)
{
- int indexOf = AllLanguages.FindIndex((a)=>a.Language == Localization.CurrentLanguage);
+ int indexOf = AllLanguages.FindIndex((a) => a.Language == Localization.CurrentLanguage);
__instance.setLanguageButton.gameObject.SetActive(newValue != indexOf);
}
@@ -98,29 +98,29 @@ private static bool OptionsUI_InitializeLanguageField(OptionsUI __instance)
{
__instance.languageField.AssignTextItems(new List(AllLanguageNames));
- int indexOf = AllLanguages.FindIndex((a)=>a.Language == Localization.CurrentLanguage);
+ int indexOf = AllLanguages.FindIndex((a) => a.Language == Localization.CurrentLanguage);
__instance.languageField.ShowValue(indexOf, immediate: true);
return false;
}
-
+
[HarmonyPatch(typeof(OptionsUI), nameof(OptionsUI.InitializeLanguageField))]
[HarmonyPatch(typeof(OptionsUI), nameof(OptionsUI.OnLanguageChanged))]
private static List Transpiler(IEnumerable instructions)
{
// LocalizedLanguageNames.NAMES
// LocalizedLanguageNames.SET_LANGUAGE_BUTTON_TEXT
-
+
// To
-
+
// LocalizationManager.AllLanguageNames
// LocalizationManager.AllLanguageButtonText
-
+
FieldInfo NAMES = AccessTools.Field(typeof(LocalizedLanguageNames), nameof(LocalizedLanguageNames.NAMES));
FieldInfo SET_LANGUAGE_BUTTON_TEXT = AccessTools.Field(typeof(LocalizedLanguageNames), nameof(LocalizedLanguageNames.SET_LANGUAGE_BUTTON_TEXT));
-
+
FieldInfo NEW_NAMES = AccessTools.Field(typeof(LocalizationManager), nameof(LocalizationManager.AllLanguageNames));
FieldInfo NEW_SET_LANGUAGE_BUTTON_TEXT = AccessTools.Field(typeof(LocalizationManager), nameof(LocalizationManager.AllLanguageButtonText));
-
+
List codes = new List(instructions);
for (int i = 0; i < codes.Count; i++)
{
diff --git a/InscryptionAPI/Pelts/Patches/TradePeltsSequencer_Patches.cs b/InscryptionAPI/Pelts/Patches/TradePeltsSequencer_Patches.cs
index 1467fecb..363aa830 100644
--- a/InscryptionAPI/Pelts/Patches/TradePeltsSequencer_Patches.cs
+++ b/InscryptionAPI/Pelts/Patches/TradePeltsSequencer_Patches.cs
@@ -185,7 +185,7 @@ private static IEnumerable CapCreatedPeltCards(IEnumerable x.opcode == OpCodes.Callvirt && x.operand.ToString() == GetTradeCardInfos);
int endIndex = codes.FindIndex(searchIndex, x => x.opcode == OpCodes.Stfld && x.operand.ToString() == Current);
@@ -238,7 +238,7 @@ public static IEnumerator CentreCreateTradeCards(TradePeltsSequencer __instance,
float anchorOffset = (4 - actualCardsPerRow) * (__instance.CARD_SPACING.x / 2f);
Vector3 vector = __instance.CARDS_ANCHOR + new Vector3(anchorOffset + __instance.CARD_SPACING.x * num, 0f, __instance.CARD_SPACING.y * num2);
-
+
// we treat this as a bool indicating whether there's 1 row or 2
if (rareCards)
vector.z = -2f;
diff --git a/InscryptionAPI/Pelts/PeltManager.cs b/InscryptionAPI/Pelts/PeltManager.cs
index d4d0f951..cc35a9eb 100644
--- a/InscryptionAPI/Pelts/PeltManager.cs
+++ b/InscryptionAPI/Pelts/PeltManager.cs
@@ -2,7 +2,6 @@
using DiskCardGame;
using InscryptionAPI.Dialogue;
using InscryptionAPI.Guid;
-using InscryptionAPI.Helpers;
using Sirenix.Utilities;
using System.Reflection;
using UnityEngine;
@@ -207,14 +206,17 @@ internal static void CreateDialogueEvents()
string dialogueId = "TraderPelts" + name;
if (!DialogueManager.CustomDialogue.Exists(x => x.DialogueEvent.id == dialogueId))
{
- if (name.Contains("pelt") || name.Contains("pelt")) {
+ if (name.Contains("pelt") || name.Contains("pelt"))
+ {
DialogueManager.GenerateEvent(InscryptionAPIPlugin.ModGUID, dialogueId,
new()
{
name + "pelts..."
}
);
- } else {
+ }
+ else
+ {
DialogueManager.GenerateEvent(InscryptionAPIPlugin.ModGUID, dialogueId,
new()
{
@@ -229,10 +231,13 @@ internal static void CreateDialogueEvents()
public static string GetTierNameFromPelt(string cardName)
{
string result = "";
- if (cardName.Contains("pelt") || cardName.Contains("pelt")) {
+ if (cardName.Contains("pelt") || cardName.Contains("pelt"))
+ {
result = cardName.ToLowerInvariant().Replace("pelt", "").Replace("pelts", "");
result = result.Split('_').Last().ToTitleCase();
- } else {
+ }
+ else
+ {
result = cardName.ToLowerInvariant();
result = result.Split('_').Last().ToTitleCase();
}
diff --git a/InscryptionAPI/PixelCard/GBCPackManager.cs b/InscryptionAPI/PixelCard/GBCPackManager.cs
index d56906bd..1bd4a287 100644
--- a/InscryptionAPI/PixelCard/GBCPackManager.cs
+++ b/InscryptionAPI/PixelCard/GBCPackManager.cs
@@ -1,14 +1,8 @@
using DiskCardGame;
using GBC;
using HarmonyLib;
-using InscryptionAPI.Card;
-using InscryptionAPI.Helpers;
-using InscryptionAPI.Resource;
-using Mono.Cecil;
using System.Reflection;
using System.Reflection.Emit;
-using UnityEngine;
-using UnityEngine.SceneManagement;
namespace InscryptionAPI.PixelCard;
diff --git a/InscryptionAPI/PixelCard/PixelCardManager.cs b/InscryptionAPI/PixelCard/PixelCardManager.cs
index 292ff388..2b89df7a 100644
--- a/InscryptionAPI/PixelCard/PixelCardManager.cs
+++ b/InscryptionAPI/PixelCard/PixelCardManager.cs
@@ -3,10 +3,7 @@
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
-using InscryptionAPI.Resource;
-using Mono.Cecil;
using System.Collections;
-using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -26,7 +23,7 @@ public class PixelDecalData
public static PixelDecalData AddGBCDecal(string pluginGUID, string textureName, Texture2D texture)
{
- PixelDecalData result = new()
+ PixelDecalData result = new()
{
PluginGUID = pluginGUID,
TextureName = textureName,
@@ -34,7 +31,7 @@ public static PixelDecalData AddGBCDecal(string pluginGUID, string textureName,
};
if (!CustomPixelDecals.Contains(result))
CustomPixelDecals.Add(result);
-
+
return result;
}
internal static void Initialise()
diff --git a/InscryptionAPI/Regions/Part1RegionData.cs b/InscryptionAPI/Regions/Part1RegionData.cs
index ea357f79..0b977823 100644
--- a/InscryptionAPI/Regions/Part1RegionData.cs
+++ b/InscryptionAPI/Regions/Part1RegionData.cs
@@ -1,6 +1,6 @@
-using System.Reflection;
using DiskCardGame;
using InscryptionAPI.Guid;
+using System.Reflection;
namespace InscryptionAPI.Regions;
@@ -20,12 +20,12 @@ public class Part1RegionData
private int tier;
private RegionData region;
-
+
public Part1RegionData(RegionData region, int tier)
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
GUID = TypeManager.GetModIdFromCallstack(callingAssembly);
-
+
AllowSacrificableTerrainCards = false;
AllowLockedTerrainCards = false;
MinTerrain = -2;
diff --git a/InscryptionAPI/Rulebook/PageTextInteractable.cs b/InscryptionAPI/Rulebook/PageTextInteractable.cs
index dc969a3c..c6b15155 100644
--- a/InscryptionAPI/Rulebook/PageTextInteractable.cs
+++ b/InscryptionAPI/Rulebook/PageTextInteractable.cs
@@ -1,10 +1,4 @@
using DiskCardGame;
-using InscryptionAPI.Card;
-using InscryptionAPI.Nodes;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using UnityEngine;
namespace InscryptionAPI.RuleBook;
diff --git a/InscryptionAPI/Rulebook/RuleBookManager.cs b/InscryptionAPI/Rulebook/RuleBookManager.cs
index f748923d..f253299f 100644
--- a/InscryptionAPI/Rulebook/RuleBookManager.cs
+++ b/InscryptionAPI/Rulebook/RuleBookManager.cs
@@ -1,13 +1,6 @@
using DiskCardGame;
-using HarmonyLib;
-using InscryptionAPI.Card;
-using InscryptionAPI.Guid;
-using InscryptionAPI.Helpers;
-using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Items.Extensions;
-using System.Collections;
using System.Collections.ObjectModel;
-using System.Reflection;
using UnityEngine;
using static InscryptionAPI.Boons.BoonManager;
using static InscryptionAPI.Slots.SlotModificationManager;
@@ -23,7 +16,7 @@ public class RedirectInfo
public Color redirectTextColour;
public string redirectPageId;
- public RedirectInfo (PageRangeType redirectType, Color redirectTextColour, string redirectPageId)
+ public RedirectInfo(PageRangeType redirectType, Color redirectTextColour, string redirectPageId)
{
this.redirectType = redirectType;
this.redirectTextColour = redirectTextColour;
@@ -112,7 +105,7 @@ public class FullRuleBookRangeInfo
public int GetStartingNumber(List pages) => GetStartingNumberFunc(pages);
public int GetInsertPosition(PageRangeInfo currentPageRange, List pages) => GetInsertPositionFunc(currentPageRange, pages);
- public List CreatePages(RuleBookInfo instance, PageRangeInfo currentPageRange, AbilityMetaCategory metaCategory) => CreatePagesFunc(instance, currentPageRange,metaCategory);
+ public List CreatePages(RuleBookInfo instance, PageRangeInfo currentPageRange, AbilityMetaCategory metaCategory) => CreatePagesFunc(instance, currentPageRange, metaCategory);
public void FillRuleBookPage(RuleBookPage instance, string pageId, params object[] otherArgs) => FillPageAction(instance, pageId, otherArgs);
public FullRuleBookRangeInfo(
@@ -148,7 +141,7 @@ public FullRuleBookRangeInfo Clone()
public static List AllRuleBookInfos { get; private set; }
public static event Func, List> ModifyRuleBookInfos;
-
+
static RuleBookManager()
{
NewRuleBookInfos.CollectionChanged += static (_, _) =>
@@ -212,7 +205,7 @@ public static FullRuleBookRangeInfo New(
Func, int> getInsertPositionFunc,
Func> createPagesFunc)
{
-
+
FullRuleBookRangeInfo info = new(
modGuid, pageType,
headerPrefix, subsectionName,
@@ -307,8 +300,8 @@ public static string GetUnformattedPageId(string pageId)
/// Whether to offset the camera view down when opening the rulebook.
public static void OpenToCustomPage(this RuleBookController instance, string pageId, bool offsetView = false)
{
- instance.SetShown(shown: true, offsetView);
int pageIndex = -1;
+ instance.SetShown(shown: true, offsetView);
if (pageId.StartsWith(RuleBookManagerPatches.API_ID))
pageIndex = instance.PageData.IndexOf(instance.PageData.Find(x => !string.IsNullOrEmpty(x.pageId) && x.pageId == pageId));
else
diff --git a/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs b/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs
index 7ed8b105..cbcf2201 100644
--- a/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs
+++ b/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs
@@ -1,12 +1,4 @@
using DiskCardGame;
-using HarmonyLib;
-using InscryptionAPI.Card;
-using InscryptionAPI.Helpers.Extensions;
-using Steamworks;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
using TMPro;
using UnityEngine;
@@ -267,7 +259,7 @@ private void CreateColliderSizeAndPosition(Transform textMesh, float sizeY, floa
correctedYProportion = (descriptionTopLeft.y - wordPos.y) / descriptionLengths[1];
zCorrection = zLength * correctedYProportion;
correctedY = currentPageTopLeft.y - (currentPageLengths[1] * correctedYProportion) - (zCorrection * correctedYProportion);
-
+
}
correctedPos = new(correctedX, correctedY, currentPageTopLeft.z + (zCorrection + zCorrection * correctedYProportion));
//Debug.Log($"[Corrected] ({correctedPos.x} {correctedPos.y} {correctedPos.z}) | {correctedXProportion} {correctedYProportion}");
diff --git a/InscryptionAPI/Rulebook/RulebookRedirectPatches.cs b/InscryptionAPI/Rulebook/RulebookRedirectPatches.cs
index 2781739a..0c5b9862 100644
--- a/InscryptionAPI/Rulebook/RulebookRedirectPatches.cs
+++ b/InscryptionAPI/Rulebook/RulebookRedirectPatches.cs
@@ -1,12 +1,6 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Card;
-using InscryptionAPI.Helpers.Extensions;
-using System;
using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text;
using TMPro;
using UnityEngine;
@@ -31,9 +25,9 @@ public static class RulebookRedirectPatches
[HarmonyPostfix, HarmonyPatch(typeof(RuleBookController), nameof(RuleBookController.Start))]
private static void CreateRedirectManager(RuleBookController __instance)
{
- if (RuleBookRedirectManager.m_Instance == null)
+ if (__instance.gameObject.GetComponent() == null)
{
- __instance.gameObject.AddComponent();
+ RuleBookRedirectManager.m_Instance = __instance.gameObject.AddComponent();
}
}
diff --git a/InscryptionAPI/Saves/ModdedSaveData.cs b/InscryptionAPI/Saves/ModdedSaveData.cs
index f1212528..cdb3437f 100644
--- a/InscryptionAPI/Saves/ModdedSaveData.cs
+++ b/InscryptionAPI/Saves/ModdedSaveData.cs
@@ -27,9 +27,9 @@ public T GetValueAsObject(string guid, string key)
public bool TryGetGuidAndKey(string prefix, string enumValue, out string guid, out string key)
{
- foreach (KeyValuePair> pair in SaveData)
+ foreach (KeyValuePair> pair in SaveData)
{
- foreach (KeyValuePair valuePair in pair.Value)
+ foreach (KeyValuePair valuePair in pair.Value)
{
if (valuePair.Key.StartsWith(prefix, StringComparison.Ordinal))
{
@@ -39,16 +39,16 @@ public bool TryGetGuidAndKey(string prefix, string enumValue, out string guid, o
// to
// guid: jamesgames.inscryption.starcraftcore
// key: Abduct
- string name = valuePair.Key.Substring(prefix.Length+1);
+ string name = valuePair.Key.Substring(prefix.Length + 1);
int underscoreIndex = name.IndexOf('_');
guid = name.Substring(0, underscoreIndex);
- key = name.Substring(underscoreIndex+1);
+ key = name.Substring(underscoreIndex + 1);
return true;
}
}
}
}
-
+
guid = null;
key = null;
return false;
diff --git a/InscryptionAPI/Slots/SlotModificationBehaviour.cs b/InscryptionAPI/Slots/SlotModificationBehaviour.cs
index 392addcf..06974afb 100644
--- a/InscryptionAPI/Slots/SlotModificationBehaviour.cs
+++ b/InscryptionAPI/Slots/SlotModificationBehaviour.cs
@@ -1,5 +1,5 @@
-using System.Collections;
using DiskCardGame;
+using System.Collections;
namespace InscryptionAPI.Slots;
diff --git a/InscryptionAPI/Slots/SlotModificationExtensions.cs b/InscryptionAPI/Slots/SlotModificationExtensions.cs
index fe6872f8..ed6af50d 100644
--- a/InscryptionAPI/Slots/SlotModificationExtensions.cs
+++ b/InscryptionAPI/Slots/SlotModificationExtensions.cs
@@ -1,4 +1,3 @@
-using System.Collections;
using DiskCardGame;
using GBC;
using HarmonyLib;
@@ -6,8 +5,8 @@
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Saves;
+using System.Collections;
using UnityEngine;
-using UnityEngine.UIElements;
using static InscryptionAPI.Slots.SlotModificationManager;
namespace InscryptionAPI.Slots;
diff --git a/InscryptionAPI/Slots/SlotModificationGainAbilityBehaviour.cs b/InscryptionAPI/Slots/SlotModificationGainAbilityBehaviour.cs
index 25ab4976..31bb3eab 100644
--- a/InscryptionAPI/Slots/SlotModificationGainAbilityBehaviour.cs
+++ b/InscryptionAPI/Slots/SlotModificationGainAbilityBehaviour.cs
@@ -1,5 +1,5 @@
-using System.Collections;
using DiskCardGame;
+using System.Collections;
using UnityEngine;
namespace InscryptionAPI.Slots;
diff --git a/InscryptionAPI/Slots/SlotModificationInteractable.cs b/InscryptionAPI/Slots/SlotModificationInteractable.cs
index e5fcc361..61a149d9 100644
--- a/InscryptionAPI/Slots/SlotModificationInteractable.cs
+++ b/InscryptionAPI/Slots/SlotModificationInteractable.cs
@@ -1,4 +1,3 @@
-using System.Collections;
using DiskCardGame;
namespace InscryptionAPI.Slots;
diff --git a/InscryptionAPI/Slots/SlotModificationManager.cs b/InscryptionAPI/Slots/SlotModificationManager.cs
index 44244af9..5e93078c 100644
--- a/InscryptionAPI/Slots/SlotModificationManager.cs
+++ b/InscryptionAPI/Slots/SlotModificationManager.cs
@@ -1,18 +1,12 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
using DiskCardGame;
using GBC;
using HarmonyLib;
-using InscryptionAPI.Card;
using InscryptionAPI.Guid;
using InscryptionAPI.Helpers;
-using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.RuleBook;
-using InscryptionAPI.Triggers;
using Sirenix.Serialization.Utilities;
+using System.Collections;
+using System.Collections.ObjectModel;
using UnityEngine;
namespace InscryptionAPI.Slots;
@@ -76,7 +70,7 @@ public class Info
///
public ModificationType SharedRulebook { get; set; } = ModificationType.NoModification;
public List MetaCategories = new();
-
+
///
/// The slot's modified texture in 3D scenes (Leshy, P03, etc) (154x226)
///
@@ -551,12 +545,14 @@ private static void AddSlotModificationsToRuleBook(AbilityMetaCategory metaCateg
return;
int curPageNum = 1;
- GameObject itemPrefab = __instance.pageRanges.Find(x => x.type == PageRangeType.Items).rangePrefab;
- int insertPosition = __result.FindLastIndex(rbi => itemPrefab) + 1;
+ PageRangeInfo itemPageRange = __instance.pageRanges.Find(x => x.type == PageRangeType.Items);
+ PageRangeInfo abilityRange = __instance.pageRanges.Find(x => x.type == PageRangeType.Abilities);
+ GameObject pagePrefab = (itemPageRange ?? abilityRange).rangePrefab;
+ int insertPosition = __result.FindLastIndex(rbi => pagePrefab) + 1;
foreach (Info slot in infos)
{
RuleBookPageInfo info = new();
- info.pagePrefab = SaveManager.SaveFile.IsPart1 ? itemPrefab : __instance.pageRanges.Find(x => x.type == PageRangeType.Abilities).rangePrefab;
+ info.pagePrefab = (SaveManager.SaveFile.IsPart1 ? itemPageRange : abilityRange).rangePrefab;
info.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - SLOT EFFECTS {0}"), curPageNum);
info.pageId = SLOT_PAGEID + (int)slot.ModificationType;
__result.Insert(insertPosition, info);
@@ -566,6 +562,7 @@ private static void AddSlotModificationsToRuleBook(AbilityMetaCategory metaCateg
}
public const string SLOT_PAGEID = "SlotModification_";
+ private static Vector3 PART_3_SCALE = new(0.7f, 0.7f, 1f);
[HarmonyPrefix, HarmonyPatch(typeof(ItemPage), nameof(ItemPage.FillPage))]
private static bool OverrideWithSlotInfo(ItemPage __instance, string headerText, params object[] otherArgs)
@@ -574,7 +571,7 @@ private static bool OverrideWithSlotInfo(ItemPage __instance, string headerText,
return true;
// Slot modification pages use ItemPage format in Act 1
- __instance.iconRenderer.transform.localScale = Vector3.one;
+ __instance.iconRenderer.transform.localScale = SaveManager.SaveFile.IsPart3 ? PART_3_SCALE : Vector3.one;
if (otherArgs[0] is string pageId && pageId.StartsWith(SLOT_PAGEID))
{
string modString = pageId.Replace(SLOT_PAGEID, "");
@@ -588,24 +585,26 @@ private static bool OverrideWithSlotInfo(ItemPage __instance, string headerText,
__instance.nameTextMesh.text = Localization.Translate(info.RulebookName);
__instance.descriptionTextMesh.text = Localization.Translate(info.RulebookDescription);
__instance.iconRenderer.sprite = info.RulebookSprite;
- __instance.iconRenderer.transform.localScale = new(0.8f, 0.8f, 0.8f);
+ __instance.iconRenderer.transform.localScale = new(0.8f, 0.8f, 1f);
InscryptionAPIPlugin.Logger.LogDebug($"Create rulebook page for slot modification [{info.ModificationType}] ({info.RulebookName}).");
return false;
}
}
return true;
}
+
[HarmonyPrefix, HarmonyPatch(typeof(AbilityPage), nameof(AbilityPage.FillPage))]
private static bool OverrideWithSlotInfo(AbilityPage __instance, string headerText, params object[] otherArgs)
{
if (SaveManager.SaveFile.IsPart1)
return true;
- __instance.mainAbilityGroup.iconRenderer.transform.localScale = Vector3.one;
+ __instance.mainAbilityGroup.iconRenderer.transform.localScale = SaveManager.SaveFile.IsPart3 ? PART_3_SCALE : Vector3.one;
Transform slotRendererObj = __instance.mainAbilityGroup.transform.Find("SlotRenderer");
slotRendererObj?.gameObject.SetActive(false);
__instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(true);
+ // if this page should be filled with info from a slot modification
if (otherArgs.Length > 0 && otherArgs.Last() is string pageId && pageId.StartsWith(SLOT_PAGEID))
{
string modString = pageId.Replace(SLOT_PAGEID, "");
@@ -633,12 +632,24 @@ private static bool OverrideWithSlotInfo(AbilityPage __instance, string headerTe
__instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(false);
slotRendererObj.GetComponent().sprite = info.P03RulebookSprite ?? info.RulebookSprite;
}
+ else if (SaveManager.SaveFile.IsMagnificus)
+ {
+ if (slotRendererObj == null)
+ {
+ slotRendererObj = Instantiate(__instance.mainAbilityGroup.iconRenderer.transform.parent, __instance.mainAbilityGroup.transform);
+ slotRendererObj.name = "SlotRenderer";
+ slotRendererObj.localPosition += new Vector3(0.1f, -0.1f, 0f);
+ }
+ slotRendererObj.gameObject.SetActive(true);
+ __instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(false);
+ slotRendererObj.GetChild(0).GetComponent().material.mainTexture = (info.MagnificusRulebookSprite ?? info.RulebookSprite).texture;
+ }
else
{
- Debug.Log("Help");
+ InscryptionAPIPlugin.Logger.LogDebug("Slot modification page: WIP");
}
-
- __instance.mainAbilityGroup.iconRenderer.transform.localScale = new(0.8f, 0.8f, 0.8f);
+
+ __instance.mainAbilityGroup.iconRenderer.transform.localScale = new(0.8f, 0.8f, 1f);
//InscryptionAPIPlugin.Logger.LogDebug($"Create rulebook page for slot modification [{info.ModificationType}] ({info.RulebookName}).");
return false;
}
diff --git a/InscryptionAPI/Totems/TotemManager.cs b/InscryptionAPI/Totems/TotemManager.cs
index ab1679fe..0bb4dab3 100644
--- a/InscryptionAPI/Totems/TotemManager.cs
+++ b/InscryptionAPI/Totems/TotemManager.cs
@@ -17,7 +17,7 @@ internal enum TotemTopState
CustomTribes,
AllTribes
}
-
+
#region Patches
[HarmonyPatch(typeof(BuildTotemSequencer), "GenerateTotemChoices", new Type[] { typeof(BuildTotemNodeData), typeof(int) })]
private class ItemsUtil_AllConsumables
@@ -76,13 +76,13 @@ public static IEnumerable Transpiler(IEnumerable list)
{
list.AddRange(TribeManager.NewTribes.Where(x => x.tribeChoice).Select(x => x.tribe));
InscryptionAPIPlugin.Logger.LogDebug($"Total Tribes: {list.Count}");
-
+
List cardsWithTribes = CardManager.AllCardsCopy.FindAll(x => x.tribes.Count > 0);
list.RemoveAll(x => !cardsWithTribes.Exists(ci => ci.IsOfTribe(x)));
@@ -158,7 +158,7 @@ private static bool Prefix(TotemTopData __instance, ref string __result)
return true;
}
}
-
+
///
/// If someone added a mod with sigils then removed the mod. They have learned the ability but it no longer exists.
/// This breaks the new totem sequence because it's not checking if the ability info exists.
diff --git a/InscryptionAPI/Triggers/CustomTriggerFinder.cs b/InscryptionAPI/Triggers/CustomTriggerFinder.cs
index 50cc73c3..87c9d094 100644
--- a/InscryptionAPI/Triggers/CustomTriggerFinder.cs
+++ b/InscryptionAPI/Triggers/CustomTriggerFinder.cs
@@ -1,8 +1,8 @@
-using System.Collections;
using DiskCardGame;
using InscryptionAPI.Card;
using InscryptionAPI.Slots;
using Sirenix.Serialization.Utilities;
+using System.Collections;
namespace InscryptionAPI.Triggers;
diff --git a/InscryptionAPI/Triggers/CustomTriggerPatches.cs b/InscryptionAPI/Triggers/CustomTriggerPatches.cs
index ba4b309d..beac3fed 100644
--- a/InscryptionAPI/Triggers/CustomTriggerPatches.cs
+++ b/InscryptionAPI/Triggers/CustomTriggerPatches.cs
@@ -1,9 +1,7 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.Slots;
using System.Collections;
-using System.ComponentModel;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;
diff --git a/InscryptionAPI/Triggers/DoCombatPhasePatches.cs b/InscryptionAPI/Triggers/DoCombatPhasePatches.cs
index 66c0386f..2f44d051 100644
--- a/InscryptionAPI/Triggers/DoCombatPhasePatches.cs
+++ b/InscryptionAPI/Triggers/DoCombatPhasePatches.cs
@@ -1,6 +1,5 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using System.Collections;
using System.Reflection;
@@ -68,10 +67,10 @@ public static List ModifyAttackingSlots(bool playerIsAttacker)
{
List originalSlots = BoardManager.Instance.GetSlotsCopy(playerIsAttacker);
List currentSlots = new(originalSlots);
-
+
var triggers = CustomTriggerFinder.FindTriggersOnBoard(false).ToList();
triggers.Sort((IGetAttackingSlots a, IGetAttackingSlots b) => b.TriggerPriority(playerIsAttacker, originalSlots) - a.TriggerPriority(playerIsAttacker, originalSlots));
-
+
foreach (IGetAttackingSlots t in triggers)
{
if ((t as TriggerReceiver) != null && t.RespondsToGetAttackingSlots(playerIsAttacker, originalSlots, currentSlots))
diff --git a/InscryptionAPI/Triggers/Interfaces.cs b/InscryptionAPI/Triggers/Interfaces.cs
index 30714e18..1fdf8dee 100644
--- a/InscryptionAPI/Triggers/Interfaces.cs
+++ b/InscryptionAPI/Triggers/Interfaces.cs
@@ -1,6 +1,5 @@
using DiskCardGame;
using System.Collections;
-using UnityEngine;
namespace InscryptionAPI.Triggers;
@@ -820,6 +819,16 @@ public interface IShieldPreventedDamageInHand
public IEnumerator OnShieldPreventedDamageInHand(PlayableCard target, int damage, PlayableCard attacker);
public int ShieldPreventedDamageInHandPriority(PlayableCard target, int damage, PlayableCard attacker);
}
+///
+/// Expanded version of CardGettingAttacked trigger, executed before it, that includes the attacker as an argument
+///
+public interface IPostCardGettingAttacked
+{
+ public bool RespondsToPostCardGettingAttacked(PlayableCard target, PlayableCard attacker);
+ public IEnumerator OnPostCardGettingAttacked(PlayableCard target, PlayableCard attacker);
+ public int PostCardGettingAttackedPriority(PlayableCard target, PlayableCard attacker);
+}
+
/*public interface IOnPreTakeDamageFromHammer
{
public bool RespondsToPreTakeDamageFromHammer(HammerItem hammer, CardSlot targetSlot, GameObject firstPersonItem);
diff --git a/InscryptionAPI/Triggers/SlotAttackSlotPatches.cs b/InscryptionAPI/Triggers/SlotAttackSlotPatches.cs
index ef47e9ef..79111558 100644
--- a/InscryptionAPI/Triggers/SlotAttackSlotPatches.cs
+++ b/InscryptionAPI/Triggers/SlotAttackSlotPatches.cs
@@ -21,39 +21,26 @@ public static class SlotAttackSlotPatches
private const string name_AttackingSlot = "DiskCardGame.CardSlot attackingSlot";
private const string name_CanAttackDirectly = "Boolean CanAttackDirectly(DiskCardGame.CardSlot)";
private const string name_VisualizeCardAttackingDirectly = "System.Collections.IEnumerator VisualizeCardAttackingDirectly(DiskCardGame.CardSlot, DiskCardGame.CardSlot, Int32)";
-
private const string modifiedAttackCustomField = "modifiedAttack";
private static readonly MethodInfo method_GetCard = AccessTools.PropertyGetter(typeof(CardSlot), nameof(CardSlot.Card));
- private static readonly MethodInfo method_NewDamage = AccessTools.Method(typeof(SlotAttackSlotPatches), nameof(SlotAttackSlotPatches.DamageToDealThisPhase),
- new Type[] { typeof(CardSlot), typeof(CardSlot) });
-
- private static readonly MethodInfo method_NewTriggers = AccessTools.Method(typeof(SlotAttackSlotPatches), nameof(SlotAttackSlotPatches.TriggerOnDirectDamageTriggers),
- new Type[] { typeof(PlayableCard), typeof(CardSlot) });
-
- private static readonly MethodInfo method_SetCustomField = AccessTools.Method(typeof(CustomFields), nameof(CustomFields.Set));
-
- private static readonly MethodInfo method_GetCustomField = AccessTools.Method(typeof(CustomFields), nameof(CustomFields.Get),
- new Type[] { typeof(object), typeof(string) }, new Type[] { typeof(int) });
-
- // make this public so people can alter it themselves
public static int DamageToDealThisPhase(CardSlot attackingSlot, CardSlot opposingSlot)
{
int originalDamage = attackingSlot.Card.Attack;
int damage = originalDamage;
// Trigger IModifyDirectDamage first and treat the new damage as the attacking card's attack
- var modifyDirectDamage = CustomTriggerFinder.FindGlobalTriggers(true).ToList();
- modifyDirectDamage.Sort((a, b) =>
+ List modifyDirectDamage = CustomTriggerFinder.FindGlobalTriggers(true).ToList();
+ modifyDirectDamage.Sort((a, b) =>
b.TriggerPriority(opposingSlot, damage, attackingSlot.Card)
- a.TriggerPriority(opposingSlot, damage, attackingSlot.Card)
);
- foreach (var modify in modifyDirectDamage)
+ foreach (IModifyDirectDamage modify in modifyDirectDamage)
{
if (modify.RespondsToModifyDirectDamage(opposingSlot, damage, attackingSlot.Card, originalDamage))
- damage = modify.OnModifyDirectDamage(opposingSlot, damage, attackingSlot.Card, originalDamage);
+ damage = modify.OnModifyDirectDamage(opposingSlot, damage, attackingSlot.Card, originalDamage);
}
// first thing we check for is self-damage; if the attacking slot is on the same side as the opposing slot, deal self-damage
@@ -76,25 +63,56 @@ public static int DamageToDealThisPhase(CardSlot attackingSlot, CardSlot opposin
return damage;
}
+ // Trigger both the vanilla trigger and the new trigger
+ public static IEnumerator TriggerOnDirectDamageTriggers(PlayableCard attacker, CardSlot opposingSlot)
+ {
+ int damage = CustomFields.Get(attacker, modifiedAttackCustomField);
+
+ // trigger the vanilla trigger
+ if (attacker.TriggerHandler.RespondsToTrigger(Trigger.DealDamageDirectly, new object[] { damage }))
+ {
+ yield return attacker.TriggerHandler.OnTrigger(Trigger.DealDamageDirectly, new object[] { damage });
+ }
+
+ // trigger the new modded trigger
+ yield return CustomTriggerFinder.TriggerAll(false, x => x.RespondsToCardDealtDamageDirectly(attacker, opposingSlot, damage), x => x.OnCardDealtDamageDirectly(attacker, opposingSlot, damage));
+ }
+
+ public static IEnumerator TriggerCardGettingAttackedTriggers(PlayableCard attacker, PlayableCard opposingCard)
+ {
+ yield return Singleton.Instance.TriggerCardsOnBoard(Trigger.CardGettingAttacked, false, opposingCard);
+
+ List postAttacked = CustomTriggerFinder.FindGlobalTriggers(true).ToList();
+ postAttacked.Sort((a, b) => b.PostCardGettingAttackedPriority(opposingCard, attacker) - a.PostCardGettingAttackedPriority(opposingCard, attacker));
+ foreach (IPostCardGettingAttacked modify in postAttacked)
+ {
+ if (modify != null && modify.RespondsToPostCardGettingAttacked(opposingCard, attacker))
+ yield return modify.OnPostCardGettingAttacked(opposingCard, attacker);
+ }
+ }
+
// We want to add a null check after CardGettingAttacked is triggered, so we'll look for triggers
[HarmonyTranspiler, HarmonyPatch(typeof(CombatPhaseManager), nameof(CombatPhaseManager.SlotAttackSlot), MethodType.Enumerator)]
private static IEnumerable Transpiler(IEnumerable instructions)
{
List codes = new(instructions);
-
+ object displayClassOperand = codes.First(x => x.opcode == OpCodes.Ldfld && x.operand.ToString() == name_CombatPhase).operand;
+ object attackingSlotOperand = codes.First(x => x.opcode == OpCodes.Stfld && x.operand.ToString() == name_AttackingSlot).operand;
+ object opposingSlotOperand = codes.First(x => x.opcode == OpCodes.Ldfld && x.operand.ToString() == name_OpposingSlot).operand;
+
// we want to slowly narrow our search until we find exactly where we want to insert our code
- for (int a = 0; a < codes.Count; a++)
+ /*for (int a = 0; a < codes.Count; a++)
{
// separated into their own methods so I can save on eye strain and brain fog
- if (ModifyDirectDamageCheck(codes, ref a))
+ if (ModifyDirectDamageCheck(codes, combatPhaseOperand, attackingSlotOperand, opposingSlotOperand, ref a))
{
for (int b = a; b < codes.Count; b++)
{
- if (CallTriggerOnDirectDamage(codes, ref b))
+ if (CallTriggerOnDirectDamage(codes, opposingSlotOperand, ref b))
{
for (int c = b; c < codes.Count; c++)
{
- if (OpposingCardNullCheck(codes, c))
+ if (OpposingCardNullCheck(codes, opposingSlotOperand, combatPhaseOperand, attackingSlotOperand, c))
break;
}
break;
@@ -102,198 +120,117 @@ private static IEnumerable Transpiler(IEnumerable codes, int i)
+ private static void OpposingCardNullCheck(List codes, int start, object opposingSlotOp, object displayClassOp, object attackingSlotOp)
{
// Looking for where GlobalTriggerHandler is called for CardGettingAttacked (enum 7)
- if (codes[i].opcode == OpCodes.Call && codes[i].operand.ToString() == name_GlobalTrigger && codes[i + 1].opcode == OpCodes.Ldc_I4_7)
- {
- MethodInfo op_Inequality = null;
- object op_OpposingSlot = null;
- object op_GetCard = null;
- object op_BreakLabel = null;
-
- for (int j = i + 1; j < codes.Count; j++)
- {
- // we need to get the operand for opposingSlot so we can insert it later
- if (codes[j].opcode == OpCodes.Ldfld && codes[j].operand.ToString() == name_OpposingSlot && op_OpposingSlot == null)
- op_OpposingSlot = codes[j].operand;
-
- // also get the operand for get_card
- if (codes[j].opcode == OpCodes.Callvirt && codes[j].operand.ToString() == name_GetCard && op_GetCard == null)
- op_GetCard = codes[j].operand;
-
- // if true, we've found the start of the if statement we'll be nesting in
- if (codes[j].opcode == OpCodes.Stfld && codes[j - 1].opcode == OpCodes.Ldc_I4_M1)
- {
- for (int k = j + 1; k < codes.Count; k++)
- {
- // we want to grab the operand for !=
- if (codes[k].opcode == OpCodes.Call && op_Inequality == null)
- op_Inequality = (MethodInfo)codes[k].operand;
-
- // we also want to grab the break label so we know where to jump
- if (op_BreakLabel == null && codes[k].opcode == OpCodes.Brfalse)
- op_BreakLabel = codes[k].operand;
-
- // if true, we've found where we want to insert our junk
- if (codes[k].opcode == OpCodes.Stfld)
- {
- // if (this.opposingSlot.Card != null)
- codes.Insert(k + 1, new CodeInstruction(OpCodes.Ldarg_0));
- codes.Insert(k + 2, new CodeInstruction(OpCodes.Ldfld, op_OpposingSlot));
- codes.Insert(k + 3, new CodeInstruction(OpCodes.Callvirt, op_GetCard));
- codes.Insert(k + 4, new CodeInstruction(OpCodes.Ldnull));
- codes.Insert(k + 5, new CodeInstruction(OpCodes.Call, op_Inequality));
- codes.Insert(k + 6, new CodeInstruction(OpCodes.Brfalse, op_BreakLabel));
- return true;
- }
- }
- break;
- }
- }
- }
-
- return false;
+ int index = 8 + codes.FindIndex(start, x => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Void SetAnimationPaused(Boolean)");
+ object op_BreakLabel = null;
+ MethodInfo op_Inequality = null;
+ MethodInfo cardGettingAttacked = AccessTools.Method(typeof(SlotAttackSlotPatches), nameof(SlotAttackSlotPatches.TriggerCardGettingAttackedTriggers),
+ new Type[] { typeof(PlayableCard), typeof(PlayableCard) });
+
+ codes.RemoveRange(index, codes.FindIndex(index, x => x.opcode == OpCodes.Stfld) - index);
+
+ // yield return TriggerCardGetting...(PlayableCard card, CardSlot slot)
+ // this.attackingSlot.Card
+ // this.opposingSlot
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, displayClassOp));
+ codes.Insert(index++, new(OpCodes.Ldfld, attackingSlotOp));
+ codes.Insert(index++, new(OpCodes.Callvirt, method_GetCard));
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, opposingSlotOp));
+ codes.Insert(index++, new(OpCodes.Callvirt, method_GetCard));
+ codes.Insert(index++, new(OpCodes.Callvirt, cardGettingAttacked));
+
+ op_Inequality = (MethodInfo)codes[codes.FindIndex(index, x => x.opcode == OpCodes.Call && x.operand.ToString() == "Boolean op_Inequality(UnityEngine.Object, UnityEngine.Object)")].operand;
+ op_BreakLabel = codes[codes.FindIndex(index, x => x.opcode == OpCodes.Brfalse)].operand;
+
+ index = 1 + codes.FindIndex(2 + codes.FindIndex(index, x => x.opcode == OpCodes.Ldc_I4_M1), x => x.opcode == OpCodes.Stfld);
+
+ codes.Insert(index++, new CodeInstruction(OpCodes.Ldarg_0));
+ codes.Insert(index++, new CodeInstruction(OpCodes.Ldfld, opposingSlotOp));
+ codes.Insert(index++, new CodeInstruction(OpCodes.Callvirt, method_GetCard));
+ codes.Insert(index++, new CodeInstruction(OpCodes.Ldnull));
+ codes.Insert(index++, new CodeInstruction(OpCodes.Call, op_Inequality));
+ codes.Insert(index++, new CodeInstruction(OpCodes.Brfalse, op_BreakLabel));
}
- // Modifies direct attack damage and stores the new damage in a custom field
- private static bool ModifyDirectDamageCheck(List codes, ref int index)
+ ///
+ /// Replaces the DealDamageDirectly trigger call with a call to TriggerOnDirectDamageTriggers
+ ///
+ private static int CallTriggerOnDirectDamage(List codes, int startIndex, object displayClassOperand, object attackingSlotOperand, object opposingSlotOp)
{
- if (codes[index].opcode == OpCodes.Callvirt && codes[index].operand.ToString() == name_CanAttackDirectly)
- {
- int startIndex = index + 2;
-
- object op_OpposingSlot = null;
- object op_DisplayClass = null;
- object op_AttackingSlot = null;
-
- // look backwards and retrieve opposingSlot
- for (int i = index - 1; i > 0; i--)
- {
- if (op_OpposingSlot == null && codes[i].operand?.ToString() == name_OpposingSlot)
- {
- op_OpposingSlot = codes[i].operand;
- break;
- }
- }
-
- // look forward and retrieve displayClass and attackingSlot
- for (int i = startIndex; i < codes.Count; i++)
- {
- if (op_DisplayClass == null && codes[i].operand?.ToString() == name_CombatPhase)
- {
- op_DisplayClass = codes[i].operand;
- op_AttackingSlot = codes[i+1].operand;
- break;
- }
- }
-
- int j = startIndex;
-
- // CustomFields.Set(this.CombatPhase.AttackingSlot.Card, "modifiedAttack", DamageToDealThisPhase(this.CombatPhase.AttackingSlot, this.OpposingSlot));
- codes.Insert(j++, new(OpCodes.Ldarg_0));
- codes.Insert(j++, new(OpCodes.Ldfld, op_DisplayClass));
- codes.Insert(j++, new(OpCodes.Ldfld, op_AttackingSlot));
- codes.Insert(j++, new(OpCodes.Callvirt, method_GetCard));
- codes.Insert(j++, new(OpCodes.Ldstr, modifiedAttackCustomField));
- codes.Insert(j++, new(OpCodes.Ldarg_0));
- codes.Insert(j++, new(OpCodes.Ldfld, op_DisplayClass));
- codes.Insert(j++, new(OpCodes.Ldfld, op_AttackingSlot));
- codes.Insert(j++, new(OpCodes.Ldarg_0));
- codes.Insert(j++, new(OpCodes.Ldfld, op_OpposingSlot));
- codes.Insert(j++, new(OpCodes.Callvirt, method_NewDamage));
- codes.Insert(j++, new(OpCodes.Box, typeof(int)));
- codes.Insert(j++, new(OpCodes.Call, method_SetCustomField));
-
- index = j;
-
- // replace the next 2 occurances of get_Attack() with the custom field call
- for (int c = 0; c < 2; c++)
- {
- for (; j < codes.Count; j++)
- {
- if (codes[j].opcode != OpCodes.Callvirt || codes[j].operand.ToString() != name_GetAttack) continue;
-
- codes[j++] = new(OpCodes.Ldstr, modifiedAttackCustomField);
- codes.Insert(j++, new(OpCodes.Callvirt, method_GetCustomField));
-
- index = j;
- break;
- }
- }
-
- return true;
- }
- return false;
- }
-
- // Repalces the DealDamageDirectly trigger call with a call to TriggerOnDirectDamageTriggers
- private static bool CallTriggerOnDirectDamage(List codes, ref int index)
- {
- if (codes[index].opcode != OpCodes.Callvirt || codes[index].operand.ToString() != name_GetCard) return false;
- int startIndex = ++index;
-
- object op_OpposingSlot = null;
-
- // look backwards and retrieve opposingSlot
- for (int i = startIndex - 1; i > 0; i--)
- {
- if (op_OpposingSlot == null && codes[i].operand?.ToString() == name_OpposingSlot)
- {
- op_OpposingSlot = codes[i].operand;
- break;
- }
- }
-
- // look backwards for ldarg0 and duplicate it
- for (int i = startIndex - 1; i > 0; i--)
- {
- if (codes[i].opcode == OpCodes.Ldarg_0)
- {
- codes.Insert(i, new(OpCodes.Ldarg_0));
-
- index++;
- startIndex++;
-
- break;
- }
- }
-
- for (int i = startIndex; i < codes.Count; i++)
- {
- if (codes[i].opcode != OpCodes.Ldc_I4_7) continue;
-
- // remove the existing trigger call
- codes.RemoveRange(startIndex, i - startIndex - 2);
-
- // insert the call to our new trigger
- codes.Insert(index++, new(OpCodes.Ldarg_0));
- codes.Insert(index++, new(OpCodes.Ldfld, op_OpposingSlot));
- codes.Insert(index++, new(OpCodes.Callvirt, method_NewTriggers));
-
- break;
- }
-
- return true;
+ int index = codes.FindIndex(startIndex, x => x.opcode == OpCodes.Callvirt && x.operand.ToString() == name_GetCard) - 2;
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ index += 3;
+
+ MethodInfo info = AccessTools.Method(typeof(SlotAttackSlotPatches), nameof(SlotAttackSlotPatches.TriggerOnDirectDamageTriggers),
+ new Type[] { typeof(PlayableCard), typeof(CardSlot) });
+
+ // remove the existing trigger call
+ codes.RemoveRange(index, codes.FindIndex(index, x => x.opcode == OpCodes.Ldc_I4_7) - 2 - index);
+ //index = startIndex + 1;
+ //return index;
+ // insert the call to our new trigger
+ // this.displayClass.attackingSlot.Card
+ // this.opposingSlot
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, opposingSlotOp));
+ codes.Insert(index++, new(OpCodes.Callvirt, info));
+
+ return index;
}
- // Trigger both the vanilla trigger and the new trigger
- private static IEnumerator TriggerOnDirectDamageTriggers(PlayableCard attacker, CardSlot opposingSlot)
+ ///
+ /// Modifies the damage value added to DamageDealtThisPhase to support IModifyDirectDamage and negative damage values (self-damage)
+ ///
+ private static int ModifyDirectDamageCheck(List codes, object displayClassOperand, object attackingSlotOperand, object opposingSlotOperand)
{
- int damage = CustomFields.Get(attacker, modifiedAttackCustomField);
-
- // trigger the vanilla trigger
- if (attacker.TriggerHandler.RespondsToTrigger(Trigger.DealDamageDirectly, new object[] { damage }))
- {
- yield return attacker.TriggerHandler.OnTrigger(Trigger.DealDamageDirectly, new object[] { damage });
- }
-
- // trigger the new modded trigger
- yield return CustomTriggerFinder.TriggerAll(false, x => x.RespondsToCardDealtDamageDirectly(attacker, opposingSlot, damage), x => x.OnCardDealtDamageDirectly(attacker, opposingSlot, damage));
+ int index = codes.FindIndex(x => x.opcode == OpCodes.Callvirt && x.operand.ToString() == name_CanAttackDirectly) + 2;
+
+ MethodInfo setCustomField = AccessTools.Method(typeof(CustomFields), nameof(CustomFields.Set));
+ MethodInfo damageToDeal = AccessTools.Method(typeof(SlotAttackSlotPatches), nameof(SlotAttackSlotPatches.DamageToDealThisPhase),
+ new Type[] { typeof(CardSlot), typeof(CardSlot) });
+
+ MethodInfo getCustomField = AccessTools.Method(typeof(CustomFields), nameof(CustomFields.Get),
+ new Type[] { typeof(object), typeof(string) }, new Type[] { typeof(int) });
+
+ // CustomFields.Set(this.CombatPhase.AttackingSlot.Card, "modifiedAttack", DamageToDealThisPhase(this.CombatPhase.AttackingSlot, this.OpposingSlot));
+ // change DamageDealtThisPhase += attackingCard.Attack
+ // to DamageDealtThisPhase += (int)modifiedAttack
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, displayClassOperand));
+ codes.Insert(index++, new(OpCodes.Ldfld, attackingSlotOperand));
+ codes.Insert(index++, new(OpCodes.Callvirt, method_GetCard));
+ codes.Insert(index++, new(OpCodes.Ldstr, modifiedAttackCustomField));
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, displayClassOperand));
+ codes.Insert(index++, new(OpCodes.Ldfld, attackingSlotOperand));
+ codes.Insert(index++, new(OpCodes.Ldarg_0));
+ codes.Insert(index++, new(OpCodes.Ldfld, opposingSlotOperand));
+ codes.Insert(index++, new(OpCodes.Callvirt, damageToDeal));
+ codes.Insert(index++, new(OpCodes.Box, typeof(int)));
+ codes.Insert(index++, new(OpCodes.Call, setCustomField));
+
+ // replace the next 2 occurences of get_Attack() with the custom field call
+ index = codes.FindIndex(index, x => x.opcode == OpCodes.Callvirt && x.operand.ToString() == name_GetAttack);
+ codes[index++] = new(OpCodes.Ldstr, modifiedAttackCustomField);
+ codes.Insert(index++, new(OpCodes.Callvirt, getCustomField));
+
+ index = codes.FindIndex(index, x => x.opcode == OpCodes.Callvirt && x.operand.ToString() == name_GetAttack);
+ codes[index++] = new(OpCodes.Ldstr, modifiedAttackCustomField);
+ codes.Insert(index++, new(OpCodes.Callvirt, getCustomField));
+
+ return index;
}
}
\ No newline at end of file
diff --git a/InscryptionAPI/Triggers/TakeDamagePatches.cs b/InscryptionAPI/Triggers/TakeDamagePatches.cs
index 3dce8d36..21a1e7b3 100644
--- a/InscryptionAPI/Triggers/TakeDamagePatches.cs
+++ b/InscryptionAPI/Triggers/TakeDamagePatches.cs
@@ -1,13 +1,9 @@
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
-using InscryptionAPI.Helpers;
-using InscryptionAPI.Helpers.Extensions;
-using Sirenix.Serialization.Utilities;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-using UnityEngine;
namespace InscryptionAPI.Triggers;
@@ -47,7 +43,7 @@ private static bool AddModifyDamageTrigger(PlayableCard __instance, ref int dama
foreach (IModifyDamageTaken modify in modifyTakeDamage)
{
if (modify != null && modify.RespondsToModifyDamageTaken(__instance, damage, attacker, originalDamage))
- damage = modify.OnModifyDamageTaken(__instance, damage, attacker, originalDamage);
+ damage = modify.OnModifyDamageTaken(__instance, damage, attacker, originalDamage);
}
// no negative damage
@@ -68,7 +64,7 @@ private static IEnumerator AddTakeDamageTriggers(IEnumerator enumerator, Playabl
yield return enumerator;
if (__instance == null) yield break;
-
+
if (!__instance.HasShield() && attacker != null)
{
yield return CustomTriggerFinder.TriggerInHand(
@@ -94,7 +90,7 @@ private static IEnumerable TakeDamageTranspiler(IEnumerable masterTextures;
-
+
int bloodCost = playableCard?.BloodCost() ?? cardInfo.BloodCost;
int bonesCost = playableCard?.BonesCost() ?? cardInfo.BonesCost;
int energyCost = playableCard?.EnergyCost ?? cardInfo.EnergyCost;
@@ -79,19 +78,25 @@ private static void CreateFullCostSprite(CardDisplayer __instance, CardRenderInf
{
__instance.costRenderer.sprite = FinalCostSprite(renderInfo.baseInfo, playableCard, TextureHelper.SpriteType.OversizedCostDecal, 28);
}
- else if (__instance is PixelCardDisplayer && PatchPlugin.act2CostRender.Value)
+ else if (__instance is PixelCardDisplayer pixelDisplay && PatchPlugin.act2CostRender.Value)
{
- __instance.costRenderer.sprite = FinalCostSprite(renderInfo.baseInfo, playableCard,
- PatchPlugin.rightAct2Cost.Value ? TextureHelper.SpriteType.Act2CostDecalRight : TextureHelper.SpriteType.Act2CostDecalLeft, 8);
+ if (PatchPlugin.act2VanillaStyle.Value)
+ {
+ __instance.costRenderer.sprite = Part2CardCostRender.FinalVanillaCostSprite(pixelDisplay, renderInfo.baseInfo, playableCard, !PatchPlugin.rightAct2Cost.Value);
+ }
+ else
+ {
+ __instance.costRenderer.sprite = FinalCostSprite(renderInfo.baseInfo, playableCard,
+ PatchPlugin.rightAct2Cost.Value ? TextureHelper.SpriteType.Act2CostDecalRight : TextureHelper.SpriteType.Act2CostDecalLeft, 8);
+ }
}
}
+ // prevents indexing error when a card has a cost greater than the vanilla limits
[HarmonyPrefix, HarmonyPatch(typeof(CardDisplayer), nameof(CardDisplayer.GetCostSpriteForCard))]
- private static bool Part1CardCostDisplayerPatch(CardDisplayer __instance)
+ private static bool Part1CardCostDisplayerPatch(CardDisplayer __instance, ref Sprite __result, CardInfo card)
{
- //Make sure we are in Leshy's Cabin
- // prevents indexing error when a card has a cost greater than the vanilla limits
- if (__instance is CardDisplayer3D && SceneLoader.ActiveSceneName.StartsWith("Part1"))
+ if (__instance is CardDisplayer3D && SceneLoader.ActiveSceneName.StartsWith("Part1")) // Make sure we are in Leshy's Cabin
{
return false;
}
@@ -100,7 +105,6 @@ private static bool Part1CardCostDisplayerPatch(CardDisplayer __instance)
return false;
}
-
return true;
}
}
\ No newline at end of file
diff --git a/InscryptionCommunityPatch/Card/HiddenCharIndexFIx.cs b/InscryptionCommunityPatch/Card/HiddenCharIndexFIx.cs
index 58250b1f..e402a590 100644
--- a/InscryptionCommunityPatch/Card/HiddenCharIndexFIx.cs
+++ b/InscryptionCommunityPatch/Card/HiddenCharIndexFIx.cs
@@ -1,8 +1,5 @@
using DiskCardGame;
-using GBC;
using HarmonyLib;
-using System.Collections;
-using UnityEngine;
namespace InscryptionCommunityPatch.Card;
diff --git a/InscryptionCommunityPatch/Card/Part1CardCostRender.cs b/InscryptionCommunityPatch/Card/Part1CardCostRender.cs
index fe745572..dccb04f3 100644
--- a/InscryptionCommunityPatch/Card/Part1CardCostRender.cs
+++ b/InscryptionCommunityPatch/Card/Part1CardCostRender.cs
@@ -1,11 +1,8 @@
using DiskCardGame;
-using GBC;
-using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.CardCosts;
//using InscryptionAPI.CardCosts;
using InscryptionAPI.Helpers;
-using System.Linq;
using UnityEngine;
namespace InscryptionCommunityPatch.Card;
@@ -32,7 +29,7 @@ public static List CostTextures(CardInfo cardInfo, PlayableCard playa
costTextures.Add(CardCostRender.GetTextureByName($"energy_cost_{Mathf.Min(7, energyCost)}"));
if (bonesCost > 0)
- costTextures.Add(CardCostRender.GetTextureByName($"bone_cost_{Mathf.Min(14, bonesCost)}"));
+ costTextures.Add(CardCostRender.GetTextureByName($"bone_cost_{Mathf.Min(16, bonesCost)}"));
if (bloodCost > 0)
costTextures.Add(CardCostRender.GetTextureByName($"blood_cost_{Mathf.Min(14, bloodCost)}"));
diff --git a/InscryptionCommunityPatch/Card/Part2CardCostRender.cs b/InscryptionCommunityPatch/Card/Part2CardCostRender.cs
index a098b00f..b6e3727c 100644
--- a/InscryptionCommunityPatch/Card/Part2CardCostRender.cs
+++ b/InscryptionCommunityPatch/Card/Part2CardCostRender.cs
@@ -1,15 +1,13 @@
using DiskCardGame;
using GBC;
-using HarmonyLib;
-using InscryptionAPI;
using InscryptionAPI.Card;
using InscryptionAPI.CardCosts;
using InscryptionAPI.Helpers;
using UnityEngine;
+using static InscryptionAPI.Helpers.TextureHelper;
namespace InscryptionCommunityPatch.Card;
-//[HarmonyPatch]
///
/// Modifies how card costs are rendered in Act 2 to add support for mixed costs and custom costs.
/// Also reduces the size of card costs so they take up less space on the card.
@@ -17,8 +15,143 @@ namespace InscryptionCommunityPatch.Card;
public static class Part2CardCostRender
{
public static event Action> UpdateCardCost;
+ public static event Action> UpdateVanillaCardCost; // 24 x 13
+
public static bool RightAct2Cost => PatchPlugin.rightAct2Cost.Value;
+ public static Sprite FinalVanillaCostSprite(
+ PixelCardDisplayer display,
+ CardInfo cardInfo,
+ PlayableCard playableCard,
+ bool leftOriented)
+ {
+ Debug.Log($"Use vanilla style");
+
+ Texture2D baseTexture;
+ List masterTextures;
+ List topTextures = new();
+ List bottomTextures = new();
+
+ int bloodCost = playableCard?.BloodCost() ?? cardInfo.BloodCost;
+ int bonesCost = playableCard?.BonesCost() ?? cardInfo.BonesCost;
+ int energyCost = playableCard?.EnergyCost ?? cardInfo.EnergyCost;
+ List gemsCost = playableCard?.GemsCost() ?? cardInfo.GemsCost;
+
+ baseTexture = TextureHelper.GetImageAsTexture("pixel_base_large.png", typeof(CardCostRender).Assembly);
+ masterTextures = VanillaCostTextures(display, cardInfo, playableCard, bloodCost, bonesCost, energyCost, gemsCost);
+
+ while (masterTextures.Count < 4)
+ masterTextures.Add(null);
+
+ if (leftOriented)
+ {
+ topTextures.Add(masterTextures[0]);
+ topTextures.Add(masterTextures[2]);
+ bottomTextures.Add(masterTextures[1]);
+ bottomTextures.Add(masterTextures[3]);
+ }
+ else
+ {
+ topTextures.Add(masterTextures[2]);
+ topTextures.Add(masterTextures[0]);
+ bottomTextures.Add(masterTextures[3]);
+ bottomTextures.Add(masterTextures[1]);
+ }
+
+ Texture2D topTexture = CombineVanillaCostTextures(topTextures, baseTexture, leftOriented, 15);
+ Texture2D finalCombinedTex = CombineVanillaCostTextures(bottomTextures, topTexture, leftOriented, 1);
+
+ return TextureHelper.ConvertTexture(finalCombinedTex, leftOriented ? SpriteType.Act2CostVanillaLeft : SpriteType.Act2CostVanillaRight);
+ }
+
+ ///
+ /// A variant of TextureHelper.CombineTextures specifically designed for combining vanilla cost textures.
+ /// Each cost texture is assumed to be 13 pixels in height and UP TO 24 pixels in width, and this method compensates for any textures thinner than 24 px.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Texture2D CombineVanillaCostTextures(List textures, Texture2D baseTexture, bool leftOriented, int yOffset)
+ {
+ if (textures != null)
+ {
+ int xStep = leftOriented ? 0 : 24;
+ for (int j = 0; j < textures.Count; j++)
+ {
+ if (textures[j] != null)
+ {
+ int xOffset = leftOriented ? 0 : 24 - textures[j].width;
+ baseTexture.SetPixels(xOffset + xStep * j, yOffset, textures[j].width, textures[j].height, textures[j].GetPixels(), 0);
+ }
+ }
+
+ baseTexture.Apply();
+ }
+
+ return baseTexture;
+ }
+
+ public static List VanillaCostTextures(PixelCardDisplayer display, CardInfo cardInfo, PlayableCard playableCard, int bloodCost, int bonesCost, int energyCost, List gemsCost)
+ {
+ List costTextures = new();
+
+ if (bloodCost > 0)
+ {
+ costTextures.Add(CardCostRender.GetTextureByName($"pixel_blood_large_{Mathf.Min(14, bloodCost)}"));
+ }
+
+ if (bonesCost > 0)
+ {
+ costTextures.Add(CardCostRender.GetTextureByName($"pixel_bone_large_{Mathf.Min(16, bonesCost)}"));
+ }
+
+ if (energyCost > 0)
+ {
+ costTextures.Add(CardCostRender.GetTextureByName($"pixel_energy_large_{Mathf.Min(7, energyCost)}"));
+ }
+
+ if (gemsCost.Count > 0)
+ {
+ costTextures.AddRange(GetVanillaMoxTextures(gemsCost));
+ }
+
+ // get a list of the custom costs we need textures for
+ // check for PlayableCard to account for possible dynamic costs (no API support but who knows what modders do)
+ List customCosts;
+ if (playableCard != null)
+ customCosts = playableCard.GetCustomCardCosts().Select(x => CardCostManager.AllCustomCosts.Find(c => c.CostName == x.CostName)).ToList();
+ else
+ customCosts = cardInfo.GetCustomCosts();
+
+ foreach (CardCostManager.FullCardCost fullCost in customCosts)
+ {
+ int amount = playableCard?.GetCustomCost(fullCost) ?? cardInfo.GetCustomCost(fullCost);
+ string key = $"{fullCost.ModGUID}_{fullCost.CostName}_{amount}_vanilla_part2";
+ if (CardCostRender.AssembledTextures.ContainsKey(key))
+ {
+ if (CardCostRender.AssembledTextures[key] != null)
+ costTextures.Add(CardCostRender.AssembledTextures[key]);
+ else
+ CardCostRender.AssembledTextures.Remove(key);
+ }
+ else
+ {
+ Texture2D costTex = fullCost.PixelCostTexture(amount, cardInfo, playableCard);
+ if (costTex != null)
+ {
+ costTextures.Add(costTex);
+ CardCostRender.AssembledTextures.Add(key, costTex);
+ }
+ }
+ }
+
+ // Call the event and allow others to modify the list of textures
+ UpdateCardCost?.Invoke(cardInfo, costTextures);
+ return costTextures;
+ }
+
public static List CostTextures(CardInfo cardInfo, PlayableCard playableCard, int bloodCost, int bonesCost, int energyCost, List gemsCost)
{
List costTextures = new();
@@ -112,6 +245,61 @@ private static Texture2D CombineMoxTextures(List pieces, Texture2D ba
return baseTexture;
}
+ public static List GetVanillaMoxTextures(List gemsCost) // vanilla order is OGB
+ {
+ List gemTextures = new();
+ int orangeCount = Mathf.Min(4, gemsCost.Count(x => x == GemType.Orange));
+ int greenCount = Mathf.Min(4, gemsCost.Count(x => x == GemType.Green));
+ int blueCount = Mathf.Min(4, gemsCost.Count(y => y == GemType.Blue));
+
+ if (orangeCount > 0)
+ {
+ if (orangeCount == 1)
+ {
+ if (gemsCost.Count == 2) // 1 orange and 1 other
+ {
+ if (greenCount > 0)
+ {
+ gemTextures.Add(CardCostRender.GetTextureByName("pixel_mox_green_orange_large"));
+ }
+ else
+ {
+ gemTextures.Add(CardCostRender.GetTextureByName("pixel_mox_blue_orange_large"));
+ }
+ return gemTextures;
+ }
+ else if (gemsCost.Count == 3 && greenCount == orangeCount && blueCount == orangeCount) // one of each
+ {
+ gemTextures.Add(CardCostRender.GetTextureByName("pixel_mox_grand_large"));
+ return gemTextures;
+ }
+ }
+
+ // default behaviour, accounts for multi mono mox
+ gemTextures.Add(CardCostRender.GetTextureByName($"pixel_mox_orange_large_{orangeCount}"));
+ }
+
+ if (greenCount > 0)
+ {
+ if (greenCount == 1 && blueCount == 1)
+ {
+ gemTextures.Add(CardCostRender.GetTextureByName("pixel_mox_blue_green_large"));
+ return gemTextures;
+ }
+
+ // default behaviour, accounts for multi mono mox
+ gemTextures.Add(CardCostRender.GetTextureByName($"pixel_mox_green_large_{greenCount}"));
+ }
+
+ if (blueCount > 0) // at this point, we have eliminated all vanilla costs and we only some combination of multi mono costs
+ {
+ // default behaviour, accounts for multi mono mox
+ gemTextures.Add(CardCostRender.GetTextureByName($"pixel_mox_blue_large_{blueCount}"));
+ }
+
+ return gemTextures;
+ }
+
public static List GetMoxTextures(List gemsCost) // vanilla order is OGB
{
List gemCost = new();
diff --git a/InscryptionCommunityPatch/Card/Part3CardCostRender.cs b/InscryptionCommunityPatch/Card/Part3CardCostRender.cs
index e9d7ab0f..b9946063 100644
--- a/InscryptionCommunityPatch/Card/Part3CardCostRender.cs
+++ b/InscryptionCommunityPatch/Card/Part3CardCostRender.cs
@@ -1,10 +1,10 @@
-using System.Runtime.CompilerServices;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.CardCosts;
using InscryptionAPI.Helpers;
using Sirenix.Serialization.Utilities;
+using System.Runtime.CompilerServices;
using UnityEngine;
namespace InscryptionCommunityPatch.Card;
diff --git a/InscryptionCommunityPatch/Card/PixelCurrentDeckPatch.cs b/InscryptionCommunityPatch/Card/PixelCurrentDeckPatch.cs
index 4d253ff3..26e7357e 100644
--- a/InscryptionCommunityPatch/Card/PixelCurrentDeckPatch.cs
+++ b/InscryptionCommunityPatch/Card/PixelCurrentDeckPatch.cs
@@ -1,8 +1,5 @@
using DiskCardGame;
-using GBC;
using HarmonyLib;
-using System.Collections;
-using UnityEngine;
namespace InscryptionCommunityPatch.Card;
diff --git a/InscryptionCommunityPatch/Card/StackAbilityIcons.cs b/InscryptionCommunityPatch/Card/StackAbilityIcons.cs
index 3c82971d..2f8277a4 100644
--- a/InscryptionCommunityPatch/Card/StackAbilityIcons.cs
+++ b/InscryptionCommunityPatch/Card/StackAbilityIcons.cs
@@ -1,12 +1,9 @@
using DiskCardGame;
using GBC;
-using GracesGames.Common.Scripts;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
-using InscryptionAPI.Helpers.Extensions;
using UnityEngine;
-using UnityEngine.UIElements;
namespace InscryptionCommunityPatch.Card;
@@ -56,7 +53,7 @@ public static class StackAbilityIcons
private static Sprite GetGBCNumberSprite(int number)
{
- var stackGBC = "stack_gbc.png";
+ string stackGBC = "stack_gbc.png";
if (!PatchPlugin.act2StackIconType.Value)
stackGBC = "stack_gbc_alt.png";
@@ -101,13 +98,6 @@ private static Color[] LEFT_BORDER
private static readonly Dictionary patchedTexture = new();
private static readonly Dictionary> patchLocations = new();
- [HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")]
- [HarmonyPostfix]
- private static void ClearStackableIcons(ref List __result, CardInfo info, List mods, List hiddenAbilities)
- {
- __result = __result.Distinct().ToList();
- }
-
private static Vector2Int FindMatchingOnesDigit(Texture2D searchTex, bool normalSize = true)
{
Texture2D onesTexture = normalSize ? NUMBER_TEXTURES[1] : MEDIUM_NUMBER_TEXTURES[1];
@@ -245,7 +235,7 @@ private static Texture2D PatchTexture(Ability ability, int count)
if (patchedTexture.ContainsKey(textureName))
return patchedTexture[textureName];
- PatchPlugin.Logger.LogDebug($"Ability [{AbilitiesUtil.GetInfo(ability).rulebookName}] stacks {count} times.");
+ PatchPlugin.Logger.LogDebug($"Ability [{AbilitiesUtil.GetInfo(ability).rulebookName}] stacks [{count}] time(s).");
// Copy the old texture to the new texture
bool doubleDigit = count > 9;
@@ -301,6 +291,18 @@ private static Texture2D PatchTexture(Ability ability, int count)
return newTexture;
}
+ [HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")]
+ [HarmonyPostfix]
+ private static void ClearStackableIcons(ref List __result, CardInfo info, List mods, List hiddenAbilities)
+ {
+ int preDistinctCount = __result.Count;
+ __result = __result.Distinct().ToList();
+ if (PatchPlugin.doubleStackSplit.Value && __result.Count == 1 && preDistinctCount == 2 && AbilitiesUtil.GetInfo(__result[0]).canStack)
+ {
+ __result.Add(__result[0]);
+ }
+ }
+
[HarmonyPatch(typeof(AbilityIconInteractable), "AssignAbility")]
[HarmonyPostfix]
private static void AddIconNumber(Ability ability, CardInfo info, PlayableCard card, ref AbilityIconInteractable __instance)
@@ -312,12 +314,12 @@ private static void AddIconNumber(Ability ability, CardInfo info, PlayableCard c
// Find all abilities on the card
// Replace all of the textures where it stacks with a texture showing that it stacks
// Okay, go through each ability on the card and see how many instances it has.
- List baseAbilities = new(info.Abilities);
int? count = null;
+ List baseAbilities = new(info.Abilities);
+ AbilityInfo ai = AbilityManager.AllAbilityInfos.AbilityByID(ability);
if (card != null)
{
- baseAbilities.AddRange(AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods));
- AbilityInfo ai = AbilityManager.AllAbilityInfos.AbilityByID(ability);
+ baseAbilities.AddRange(AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods/*.Where(x => !x.fromTotem && (!x.fromCardMerge || PatchPlugin.configMergeOnBottom.Value)).ToList()*/));
if (ai.GetHideSingleStacks())
{
for (int i = 0; i < card.Status.hiddenAbilities.Count(x => x == ability); i++)
@@ -331,12 +333,17 @@ private static void AddIconNumber(Ability ability, CardInfo info, PlayableCard c
if (ai.IsShieldAbility())
count = card.GetShieldBehaviour(ability)?.NumShields;
}
-
+
count ??= baseAbilities.Count(ab => ab == ability);
- //Debug.Log($"[{AbilitiesUtil.GetInfo(ability).rulebookName}] {count}");
+ //PatchPlugin.Logger.LogDebug($"[{AbilitiesUtil.GetInfo(ability).rulebookName}] {count} {baseAbilities.Count}");
- if (count > 1) // We need to add an override
- __instance.SetIcon(PatchTexture(ability, (int)count));
+ if (count > 1) // we have a stack and need to add an override
+ {
+ if (PatchPlugin.doubleStackSplit.Value && count == 2 && count == baseAbilities.Count)
+ __instance.SetIcon(__instance.LoadIcon(info, ai, card != null && card.OpponentCard));//RenderSameSigilTwice(__instance, ai, info, card);
+ else
+ __instance.SetIcon(PatchTexture(ability, (int)count));
+ }
}
[HarmonyPatch(typeof(PixelCardAbilityIcons), "DisplayAbilities", new Type[] { typeof(List), typeof(PlayableCard) })]
@@ -348,7 +355,6 @@ private static bool PatchPixelCardStacks(PixelCardAbilityIcons __instance, List<
public static bool RenderPixelAbilityStacks(PixelCardAbilityIcons __instance, List abilities, PlayableCard card)
{
- List> grps = abilities.Distinct().Select(a => new Tuple(a, abilities.Where(ab => ab == a).Count())).ToList();
List abilityIconGroups = __instance.abilityIconGroups;
if (abilityIconGroups.Count == 0)
return false;
@@ -356,22 +362,55 @@ public static bool RenderPixelAbilityStacks(PixelCardAbilityIcons __instance, Li
foreach (GameObject gameObject in abilityIconGroups)
gameObject.gameObject.SetActive(false);
- if (grps.Count > 0 && grps.Count - 1 < abilityIconGroups.Count)
+ List allDisplayableAbilities = new(abilities);
+ if (card != null)
+ {
+ allDisplayableAbilities.AddRange(AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods));
+ }
+
+ List> grps = allDisplayableAbilities.Distinct().Select(a => new Tuple(a, AbilitiesUtil.GetInfo(a).canStack ? abilities.Count(ab => ab == a) : 1)).ToList();
+
+ if (grps.Count > 0 && grps.Count - 1 < abilityIconGroups.Count) // if there are displayable sigils and there are enough icon groups
{
+ // if there is only 1 ability and there are two stacks of it, render it twice
+ if (PatchPlugin.doubleStackSplit.Value && grps.Count == 1 && grps[0].Item2 == 2/* && AbilitiesUtil.GetInfo(grps[0].Item1).canStack*/)
+ {
+ //PatchPlugin.Logger.LogDebug($"Displaying {grps[0].Item1} twice");
+ grps[0] = new Tuple(grps[0].Item1, 1);
+ grps.Add(grps[0]);
+ }
+
GameObject iconGroup = abilityIconGroups[grps.Count - 1];
iconGroup.gameObject.SetActive(true);
- List componentsInChildren = new();
+ List abilityRenderers = new();
foreach (Transform child in iconGroup.transform)
- componentsInChildren.Add(child.gameObject.GetComponent());
+ abilityRenderers.Add(child.gameObject.GetComponent());
- componentsInChildren.RemoveAll(sr => sr == null);
+ abilityRenderers.RemoveAll(sr => sr == null);
- for (int i = 0; i < componentsInChildren.Count; i++)
+ CardInfo cardInfo = card?.Info ?? __instance.GetComponentInParent()?.Info;
+ for (int i = 0; i < abilityRenderers.Count; i++)
{
- SpriteRenderer abilityRenderer = componentsInChildren[i];
+ SpriteRenderer abilityRenderer = abilityRenderers[i];
AbilityInfo abilityInfo = AbilitiesUtil.GetInfo(grps[i].Item1);
- CardInfo cardInfo = card?.Info ?? __instance.GetComponentInParent()?.Info;
+ int stackCount = grps[i].Item2;
+ if (card != null)
+ {
+ if (abilityInfo.GetHideSingleStacks())
+ {
+ for (int j = 0; j < card.Status.hiddenAbilities.Count(x => x == grps[i].Item1); j++)
+ {
+ stackCount--;
+ }
+ }
+ else if (card.Status.hiddenAbilities.Contains(grps[i].Item1))
+ stackCount -= allDisplayableAbilities.Count(x => x == grps[i].Item1);
+
+ if (abilityInfo.IsShieldAbility())
+ stackCount = card.GetShieldBehaviour(grps[i].Item1)?.NumShields ?? 0;
+ }
+
abilityRenderer.sprite = abilityInfo.activated ? new() : OverridePixelSprite(abilityInfo, cardInfo, card);
if (abilityInfo.flipYIfOpponent && card != null && card.OpponentCard)
{
@@ -383,7 +422,8 @@ public static bool RenderPixelAbilityStacks(PixelCardAbilityIcons __instance, Li
else
abilityRenderer.flipY = false;
- AddStackCount(abilityRenderer, grps[i]);
+ PatchPlugin.Logger.LogDebug($"Ability [{grps[i].Item1}] stacks [{stackCount}] time(s)");
+ AddStackCount(abilityRenderer, grps[i].Item1, stackCount);
}
}
__instance.conduitIcon.SetActive(abilities.Exists((Ability x) => AbilitiesUtil.GetInfo(x).conduit));
@@ -402,14 +442,14 @@ public static bool RenderPixelAbilityStacks(PixelCardAbilityIcons __instance, Li
return false;
}
- private static void AddStackCount(SpriteRenderer abilityRenderer, Tuple grpsI)
+ private static void AddStackCount(SpriteRenderer abilityRenderer, Ability ability, int count)
{
// And now my custom code to add the ability counter if we need to
Transform countTransform = abilityRenderer.transform.Find("Count");
if (countTransform == null)
{
- if (grpsI.Item2 <= 1)
+ if (count <= 1)
return;
GameObject counter = new();
@@ -428,17 +468,18 @@ private static void AddStackCount(SpriteRenderer abilityRenderer, Tuple().sprite = GBC_NUMBER_SPRITES[grpsI.Item2 - 1];
+ PatchPlugin.Logger.LogDebug($"countTransform [{count - 1}]");
+ countTransform.gameObject.GetComponent().sprite = GBC_NUMBER_SPRITES[count - 1];
}
}
private static Sprite OverridePixelSprite(AbilityInfo abilityInfo, CardInfo cardInfo, PlayableCard card)
{
+ // countdown numbers for evolve and transformer
if (cardInfo != null && (abilityInfo.ability == Ability.Evolve || abilityInfo.ability == Ability.Transformer))
{
int turnsInPlay = card?.GetComponentInChildren()?.numTurnsInPlay ?? 0;
@@ -457,7 +498,7 @@ private static Sprite OverridePixelSprite(AbilityInfo abilityInfo, CardInfo card
return TextureHelper.ConvertTexture(texture, TextureHelper.SpriteType.PixelAbilityIcon);
}
- if (card && card.RenderInfo.overriddenAbilityIcons.ContainsKey(abilityInfo.ability))
+ if (card != null && card.RenderInfo.overriddenAbilityIcons.ContainsKey(abilityInfo.ability))
{
card.RenderInfo.overriddenAbilityIcons.TryGetValue(abilityInfo.ability, out Texture texture);
diff --git a/InscryptionCommunityPatch/Card/TempModDecalsFix.cs b/InscryptionCommunityPatch/Card/TempModDecalsFix.cs
index 28775a4a..8fb0cc47 100644
--- a/InscryptionCommunityPatch/Card/TempModDecalsFix.cs
+++ b/InscryptionCommunityPatch/Card/TempModDecalsFix.cs
@@ -1,5 +1,4 @@
using DiskCardGame;
-using GBC;
using HarmonyLib;
using InscryptionAPI.Card;
using System.Collections;
diff --git a/InscryptionCommunityPatch/Card/TempModPixelSigilsFix.cs b/InscryptionCommunityPatch/Card/TempModPixelSigilsFix.cs
index 971913db..fe23143d 100644
--- a/InscryptionCommunityPatch/Card/TempModPixelSigilsFix.cs
+++ b/InscryptionCommunityPatch/Card/TempModPixelSigilsFix.cs
@@ -1,7 +1,6 @@
using DiskCardGame;
using GBC;
using HarmonyLib;
-using InscryptionAPI.Card;
using System.Reflection;
using System.Reflection.Emit;
@@ -38,7 +37,7 @@ public static List RenderTemporarySigils(CardInfo info, PlayableCard ca
List abilities = new(info.Abilities);
List tempAbilities = new();
-
+
foreach (CardModificationInfo mod in card.RenderInfo.temporaryMods)
{
if (mod.singletonId != "paint") // ignore abilities added by Magnificus
diff --git a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/Act2ShapeshifterPatches.cs b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/Act2ShapeshifterPatches.cs
index 41f5f7d4..d06f1df6 100644
--- a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/Act2ShapeshifterPatches.cs
+++ b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/Act2ShapeshifterPatches.cs
@@ -1,9 +1,7 @@
using DiskCardGame;
using GBC;
using HarmonyLib;
-using InscryptionAPI.Card;
using InscryptionAPI.Dialogue;
-using InscryptionAPI.Helpers;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
diff --git a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawCopyOnDeathFix.cs b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawCopyOnDeathFix.cs
index b3028f91..6306ba7c 100644
--- a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawCopyOnDeathFix.cs
+++ b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawCopyOnDeathFix.cs
@@ -1,8 +1,5 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Card;
-using System.Collections;
-using UnityEngine;
namespace InscryptionCommunityPatch.Card;
diff --git a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawNewHand3DFixes.cs b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawNewHand3DFixes.cs
index 4a2612ae..c905adc0 100644
--- a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawNewHand3DFixes.cs
+++ b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/DrawNewHand3DFixes.cs
@@ -1,6 +1,5 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Helpers;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
diff --git a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/SniperFix.cs b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/SniperFix.cs
index 6f68ecf9..1539c78e 100644
--- a/InscryptionCommunityPatch/Card/Vanilla Ability Patches/SniperFix.cs
+++ b/InscryptionCommunityPatch/Card/Vanilla Ability Patches/SniperFix.cs
@@ -2,7 +2,6 @@
using HarmonyLib;
using InscryptionAPI.Helpers.Extensions;
using System.Collections;
-using System.Linq.Expressions;
using UnityEngine;
namespace InscryptionCommunityPatch.Card;
diff --git a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj
index 3ba1dbb4..1fa61d60 100644
--- a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj
+++ b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj
@@ -9,7 +9,7 @@
true
full
false
- 2.22.0
+ 2.23.0
diff --git a/InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs b/InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs
index a8dca8c4..71937425 100644
--- a/InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs
+++ b/InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs
@@ -36,6 +36,9 @@ public class PatchPlugin : BaseUnityPlugin
internal static ConfigEntry rightAct2Cost;
internal static ConfigEntry act2CostRender;
+ internal static ConfigEntry act2VanillaStyle;
+
+ internal static ConfigEntry doubleStackSplit;
internal static ConfigEntry act2StackIconType;
@@ -54,6 +57,7 @@ public class PatchPlugin : BaseUnityPlugin
internal static ConfigEntry act2TutorCenterRows;
+
new internal static ManualLogSource Logger;
private readonly Harmony HarmonyInstance = new(ModGUID);
@@ -91,8 +95,11 @@ private void Awake()
configShowSquirrelTribeOnCards = Config.Bind("Tribes", "Show Squirrel Tribe", false, "Shows the Squirrel tribe icon on cards");
act2CostRender = Config.Bind("Card Costs", "GBC Cost render", true, "GBC Cards are able to display custom costs and hybrid costs through the API.");
rightAct2Cost = Config.Bind("Card Costs", "GBC Cost On Right", true, "GBC Cards display their costs on the top-right corner. If false, display on the top-left corner");
+ act2VanillaStyle = Config.Bind("Card Costs", "GBC Vanilla Render", false, "GBC cards use vanilla sprites when rendering multiple and custom costs.");
configMergeOnBottom = Config.Bind("Sigil Display", "Merge_On_Botom", false, "Makes it so if enabled, merged sigils will display on the bottom of the card instead of on the artwork. In extreme cases, this can cause some visual bugs.");
configRemovePatches = Config.Bind("Sigil Display", "Remove_Patches", false, "Makes it so if enabled, merged sigils will not have a patch behind them anymore and will instead be glowing yellow (only works with Merge_On_Bottom).");
+ doubleStackSplit = Config.Bind("Sigil Display", "Vanilla Stacking", false, "If enabled, cards with only two visible sigils will display each separately even if they can stack.");
+
configSmallPricetags = Config.Bind("Act 1", "Smaller Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be scaled down.");
configMovePricetags = Config.Bind("Act 1", "Move Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be moved to the right.");
act2StackIconType = Config.Bind("Sigil Display", "Act 2 Sigil icon type", true, "If true, stacking icons are a cream outline with a black center. If false, stacking icons are a black outline with a cream center. Act 2");
diff --git a/InscryptionCommunityPatch/PixelTutor/PixelPlayableCardArray.cs b/InscryptionCommunityPatch/PixelTutor/PixelPlayableCardArray.cs
index 2f9729a9..126f3a71 100644
--- a/InscryptionCommunityPatch/PixelTutor/PixelPlayableCardArray.cs
+++ b/InscryptionCommunityPatch/PixelTutor/PixelPlayableCardArray.cs
@@ -1,9 +1,7 @@
using DiskCardGame;
using GBC;
-using InscryptionAPI;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
-using InscryptionCommunityPatch.Card;
using Pixelplacement;
using Sirenix.Utilities;
using System.Collections;
@@ -95,7 +93,7 @@ public IEnumerator SelectPixelCardFrom(
}
InitializeGamepadGrid();
-
+
yield return SpawnAndPlaceCards(cards, GetNumRows(cards.Count), 0, false, forPositiveEffect);
InitialiseButtons(cards, false, forPositiveEffect);
diff --git a/InscryptionCommunityPatch/ResourceManagers/ActOneEnergyDrone.cs b/InscryptionCommunityPatch/ResourceManagers/ActOneEnergyDrone.cs
index dd95f551..0f7fe52f 100644
--- a/InscryptionCommunityPatch/ResourceManagers/ActOneEnergyDrone.cs
+++ b/InscryptionCommunityPatch/ResourceManagers/ActOneEnergyDrone.cs
@@ -44,7 +44,7 @@ public static bool SceneCanHaveEnergyDrone(string sceneName)
string activeSceneName = sceneName.ToLowerInvariant();
if (activeSceneName.Contains("part1"))
return !activeSceneName.Contains("sanctum") && !activeSceneName.Contains("finale");
-
+
return activeSceneName.Contains("magnificus") || activeSceneName.Contains("grimora");
}
diff --git a/InscryptionCommunityPatch/ResourceManagers/ActThreeBonesDisplayer.cs b/InscryptionCommunityPatch/ResourceManagers/ActThreeBonesDisplayer.cs
index e1f61c4f..0d962fb1 100644
--- a/InscryptionCommunityPatch/ResourceManagers/ActThreeBonesDisplayer.cs
+++ b/InscryptionCommunityPatch/ResourceManagers/ActThreeBonesDisplayer.cs
@@ -1,10 +1,10 @@
-using System.Collections;
-using System.Runtime.CompilerServices;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionCommunityPatch.Card;
using Pixelplacement;
+using System.Collections;
+using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.SceneManagement;
diff --git a/InscryptionCommunityPatch/Sequencers/BuyPeltsSmallTags.cs b/InscryptionCommunityPatch/Sequencers/BuyPeltsSmallTags.cs
index 3d3038b6..b74bab35 100644
--- a/InscryptionCommunityPatch/Sequencers/BuyPeltsSmallTags.cs
+++ b/InscryptionCommunityPatch/Sequencers/BuyPeltsSmallTags.cs
@@ -1,10 +1,5 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Card;
-using Pixelplacement;
-using System.Collections;
-using System.Reflection;
-using System.Reflection.Emit;
using UnityEngine;
namespace InscryptionCommunityPatch.Sequencers;
diff --git a/InscryptionCommunityPatch/Sequencers/CardCostChoiceNodePatch.cs b/InscryptionCommunityPatch/Sequencers/CardCostChoiceNodePatch.cs
index 99550760..2451696b 100644
--- a/InscryptionCommunityPatch/Sequencers/CardCostChoiceNodePatch.cs
+++ b/InscryptionCommunityPatch/Sequencers/CardCostChoiceNodePatch.cs
@@ -1,7 +1,6 @@
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Helpers;
-using System.Collections;
using UnityEngine;
namespace InscryptionCommunityPatch.Sequencers;
diff --git a/InscryptionCommunityPatch/Sequencers/LeshyResetRedEyes.cs b/InscryptionCommunityPatch/Sequencers/LeshyResetRedEyes.cs
index e3645615..0e9f940b 100644
--- a/InscryptionCommunityPatch/Sequencers/LeshyResetRedEyes.cs
+++ b/InscryptionCommunityPatch/Sequencers/LeshyResetRedEyes.cs
@@ -1,11 +1,6 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Card;
-using Pixelplacement;
using System.Collections;
-using System.Reflection;
-using System.Reflection.Emit;
-using UnityEngine;
namespace InscryptionCommunityPatch.Sequencers;
diff --git a/InscryptionCommunityPatch/Sequencers/PackRatNodeBackgroundFix.cs b/InscryptionCommunityPatch/Sequencers/PackRatNodeBackgroundFix.cs
index 0efb2d09..0cdd0a8f 100644
--- a/InscryptionCommunityPatch/Sequencers/PackRatNodeBackgroundFix.cs
+++ b/InscryptionCommunityPatch/Sequencers/PackRatNodeBackgroundFix.cs
@@ -1,12 +1,6 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Helpers;
-using InscryptionCommunityPatch.Card;
-using Pixelplacement;
-using System.Collections;
-using System.Reflection;
using System.Reflection.Emit;
-using UnityEngine;
namespace InscryptionCommunityPatch.Sequencers;
@@ -18,7 +12,7 @@ internal class PackRatNodeBackgroundFix
private static IEnumerable FixRareBackground(IEnumerable instructions)
{
List codes = new(instructions);
-
+
// a part of the code block we want to remove can't be removed without breaking the ienum
// so we cut around it
for (int i = 0; i < codes.Count; i++)
diff --git a/InscryptionCommunityPatch/Sequencers/TradeableTalkingCardFix.cs b/InscryptionCommunityPatch/Sequencers/TradeableTalkingCardFix.cs
index e7ed5c59..9dadc5ff 100644
--- a/InscryptionCommunityPatch/Sequencers/TradeableTalkingCardFix.cs
+++ b/InscryptionCommunityPatch/Sequencers/TradeableTalkingCardFix.cs
@@ -1,10 +1,7 @@
using DiskCardGame;
using HarmonyLib;
-using InscryptionAPI.Card;
using Pixelplacement;
using System.Collections;
-using System.Reflection;
-using System.Reflection.Emit;
using UnityEngine;
namespace InscryptionCommunityPatch.Sequencers;
diff --git a/InscryptionCommunityPatch/Tests/TestCost.cs b/InscryptionCommunityPatch/Tests/TestCost.cs
index 3e1a8989..c0b2b896 100644
--- a/InscryptionCommunityPatch/Tests/TestCost.cs
+++ b/InscryptionCommunityPatch/Tests/TestCost.cs
@@ -1,11 +1,9 @@
using DiskCardGame;
using InscryptionAPI;
-using InscryptionAPI.Boons;
using InscryptionAPI.CardCosts;
using InscryptionAPI.Helpers;
using InscryptionCommunityPatch.Card;
using System.Collections;
-using TMPro;
using UnityEngine;
namespace InscryptionCommunityPatch.Tests;
@@ -16,7 +14,7 @@ public class TestCost : CustomCardCost
public static void Init()
{
PatchPlugin.Logger.LogDebug("Adding TestCost");
-
+
CardCostManager.Register(InscryptionAPIPlugin.ModGUID, "TestCost", typeof(TestCost), Texture3D, TexturePixel)
.SetCostTier(CostTier)
.SetCanBePlayedByTurn2WithHand(CanBePlayed)