Skip to content

Commit 6a07d96

Browse files
Fix Ice Cube card mods not being added
1 parent 3fca80d commit 6a07d96

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# 2.23.6
2+
- Fixed card modifications added to a card's base ice cube card via CardInfo.SetIceCube being ignored
13
# 2.23.5
24
- Fixed cards appearing as blank outside Act 1
35
- Added extension methods for FullAbility that mirror AbilityInfo extension methods

InscryptionAPI/Card/AbilityManager.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using InscryptionAPI.Helpers;
55
using InscryptionAPI.Helpers.Extensions;
66
using InscryptionAPI.RuleBook;
7+
using Sirenix.Utilities;
78
using System.Collections;
89
using System.Collections.ObjectModel;
910
using System.Reflection;
@@ -683,6 +684,38 @@ private static void LogAbilityInfo(Ability ability, AbilityInfo abilityInfo, Car
683684
InscryptionAPIPlugin.Logger.LogError("Cannot find ability " + ability + " for " + info.displayedName);
684685
}
685686

687+
[HarmonyPatch(typeof(IceCube), nameof(IceCube.OnDie), MethodType.Enumerator)]
688+
[HarmonyTranspiler]
689+
private static IEnumerable<CodeInstruction> AddInherentModsToIceCube(IEnumerable<CodeInstruction> instructions) {
690+
List<CodeInstruction> codes = new(instructions);
691+
692+
for (int i = 0; i < codes.Count; i++) {
693+
if (codes[i].opcode == OpCodes.Ldloc_2) {
694+
// this probably belongs in the community patches but this transpiler was already here, so eh
695+
// overrides the transformer icon so it can display numbers
696+
MethodInfo customMethod = AccessTools.Method(typeof(AbilityManager), nameof(AbilityManager.GetIceCubeInfoWithMods),
697+
new Type[] { typeof(IceCube), typeof(string) });
698+
699+
// ldloc_1 <- IceCube
700+
// ldloc_2 <- name
701+
// call (customMethod)
702+
codes[i + 1] = new(OpCodes.Call, customMethod);
703+
codes.Insert(i, new(OpCodes.Ldloc_1));
704+
break;
705+
}
706+
}
707+
codes.LogCodeInscryptions();
708+
return codes;
709+
}
710+
711+
private static CardInfo GetIceCubeInfoWithMods(IceCube instance, string cardName) {
712+
CardInfo info = CardLoader.GetCardByName(cardName);
713+
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) {
714+
info.Mods.AddRange(instance.Card.Info.iceCubeParams.creatureWithin.mods);
715+
}
716+
return info;
717+
}
718+
686719
#region Evolve Changes
687720
[HarmonyPatch(typeof(Evolve), nameof(Evolve.OnUpkeep), MethodType.Enumerator)]
688721
[HarmonyTranspiler]
@@ -734,13 +767,6 @@ private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInter
734767
}
735768
return true;
736769
}
737-
//[HarmonyPrefix, HarmonyPatch(typeof(AbilitiesUtil), nameof(AbilitiesUtil.LoadAbilityIcon))]
738-
//private static bool OverrideEvolveAndTransformerIcon(ref Texture __result, string abilityName) {
739-
// if (abilityName.StartsWith("Evolve") || abilityName.StartsWith("Transformer")) {
740-
// return false;
741-
// }
742-
// return true;
743-
//}
744770
private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve)
745771
{
746772
if (evolve.Ability == Ability.Evolve)

InscryptionAPI/InscryptionAPI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<DebugType>full</DebugType>
1111
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1212
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
13-
<Version>2.23.5</Version>
13+
<Version>2.23.6</Version>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>

InscryptionAPI/InscryptionAPIPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
3131
{
3232
public const string ModGUID = "cyantist.inscryption.api";
3333
public const string ModName = "InscryptionAPI";
34-
public const string ModVer = "2.23.5";
34+
public const string ModVer = "2.23.6";
3535

3636
public static string Directory = "";
3737

0 commit comments

Comments
 (0)