diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc43c89..c8c13a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# 2.23.6 +- Fixed card modifications added to a card's base ice cube card via CardInfo.SetIceCube being ignored # 2.23.5 - Fixed cards appearing as blank outside Act 1 - Added extension methods for FullAbility that mirror AbilityInfo extension methods diff --git a/InscryptionAPI/Card/AbilityManager.cs b/InscryptionAPI/Card/AbilityManager.cs index c39e0a92..b8f85825 100644 --- a/InscryptionAPI/Card/AbilityManager.cs +++ b/InscryptionAPI/Card/AbilityManager.cs @@ -4,6 +4,7 @@ using InscryptionAPI.Helpers; using InscryptionAPI.Helpers.Extensions; using InscryptionAPI.RuleBook; +using Sirenix.Utilities; using System.Collections; using System.Collections.ObjectModel; using System.Reflection; @@ -683,6 +684,38 @@ private static void LogAbilityInfo(Ability ability, AbilityInfo abilityInfo, Car InscryptionAPIPlugin.Logger.LogError("Cannot find ability " + ability + " for " + info.displayedName); } + [HarmonyPatch(typeof(IceCube), nameof(IceCube.OnDie), MethodType.Enumerator)] + [HarmonyTranspiler] + private static IEnumerable AddInherentModsToIceCube(IEnumerable instructions) { + List codes = new(instructions); + + for (int i = 0; i < codes.Count; i++) { + if (codes[i].opcode == OpCodes.Ldloc_2) { + // this probably belongs in the community patches but this transpiler was already here, so eh + // overrides the transformer icon so it can display numbers + MethodInfo customMethod = AccessTools.Method(typeof(AbilityManager), nameof(AbilityManager.GetIceCubeInfoWithMods), + new Type[] { typeof(IceCube), typeof(string) }); + + // ldloc_1 <- IceCube + // ldloc_2 <- name + // call (customMethod) + codes[i + 1] = new(OpCodes.Call, customMethod); + codes.Insert(i, new(OpCodes.Ldloc_1)); + break; + } + } + + return codes; + } + + private static CardInfo GetIceCubeInfoWithMods(IceCube instance, string cardName) { + CardInfo info = CardLoader.GetCardByName(cardName); + if (instance.Card.Info.iceCubeParams != null && instance.Card.Info.iceCubeParams.creatureWithin != null && instance.Card.Info.iceCubeParams.creatureWithin.mods != null && instance.Card.Info.iceCubeParams.creatureWithin.mods.Count > 0) { + info.Mods.AddRange(instance.Card.Info.iceCubeParams.creatureWithin.mods); + } + return info; + } + #region Evolve Changes [HarmonyPatch(typeof(Evolve), nameof(Evolve.OnUpkeep), MethodType.Enumerator)] [HarmonyTranspiler] @@ -734,13 +767,6 @@ private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInter } return true; } - //[HarmonyPrefix, HarmonyPatch(typeof(AbilitiesUtil), nameof(AbilitiesUtil.LoadAbilityIcon))] - //private static bool OverrideEvolveAndTransformerIcon(ref Texture __result, string abilityName) { - // if (abilityName.StartsWith("Evolve") || abilityName.StartsWith("Transformer")) { - // return false; - // } - // return true; - //} private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve) { if (evolve.Ability == Ability.Evolve) diff --git a/InscryptionAPI/InscryptionAPI.csproj b/InscryptionAPI/InscryptionAPI.csproj index a11afb37..66183eab 100644 --- a/InscryptionAPI/InscryptionAPI.csproj +++ b/InscryptionAPI/InscryptionAPI.csproj @@ -10,7 +10,7 @@ full false true - 2.23.5 + 2.23.6 diff --git a/InscryptionAPI/InscryptionAPIPlugin.cs b/InscryptionAPI/InscryptionAPIPlugin.cs index e50389f4..676a1aaf 100644 --- a/InscryptionAPI/InscryptionAPIPlugin.cs +++ b/InscryptionAPI/InscryptionAPIPlugin.cs @@ -31,7 +31,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin { public const string ModGUID = "cyantist.inscryption.api"; public const string ModName = "InscryptionAPI"; - public const string ModVer = "2.23.5"; + public const string ModVer = "2.23.6"; public static string Directory = "";