|
4 | 4 | using InscryptionAPI.Helpers; |
5 | 5 | using InscryptionAPI.Helpers.Extensions; |
6 | 6 | using InscryptionAPI.RuleBook; |
| 7 | +using Sirenix.Utilities; |
7 | 8 | using System.Collections; |
8 | 9 | using System.Collections.ObjectModel; |
9 | 10 | using System.Reflection; |
@@ -683,6 +684,38 @@ private static void LogAbilityInfo(Ability ability, AbilityInfo abilityInfo, Car |
683 | 684 | InscryptionAPIPlugin.Logger.LogError("Cannot find ability " + ability + " for " + info.displayedName); |
684 | 685 | } |
685 | 686 |
|
| 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 | + |
686 | 719 | #region Evolve Changes |
687 | 720 | [HarmonyPatch(typeof(Evolve), nameof(Evolve.OnUpkeep), MethodType.Enumerator)] |
688 | 721 | [HarmonyTranspiler] |
@@ -734,13 +767,6 @@ private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInter |
734 | 767 | } |
735 | 768 | return true; |
736 | 769 | } |
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 | | - //} |
744 | 770 | private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve) |
745 | 771 | { |
746 | 772 | if (evolve.Ability == Ability.Evolve) |
|
0 commit comments