From c571cac2824a4b6d697e226a0ee9e724c9fc8a4f Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Sun, 6 Oct 2024 19:45:42 -0700 Subject: [PATCH 1/7] commented out debug info --- InscryptionAPI/Rulebook/RuleBookRedirectManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs b/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs index a15ae9b6..7ed8b105 100644 --- a/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs +++ b/InscryptionAPI/Rulebook/RuleBookRedirectManager.cs @@ -52,7 +52,7 @@ public void ClearActiveInteractables() } public void UpdateActiveInteractables(TextMeshPro description, GameObject currentPageObj, Dictionary redirects) { - InscryptionAPIPlugin.Logger.LogDebug($"[UpdateActiveInteractables]"); + //InscryptionAPIPlugin.Logger.LogDebug($"[UpdateActiveInteractables]"); Bounds pageBounds; Bounds borderBounds = currentPageObj.transform.Find("Border").GetComponent().bounds; // in world space Vector3 pageBottomLeft; @@ -82,9 +82,9 @@ public void UpdateActiveInteractables(TextMeshPro description, GameObject curren descriptionLengths ??= new float[2] { borderBounds.size.x, (currentPageLengths[1] / currentPageLengths[0]) * borderBounds.size.x }; } zLength = pageBottomLeft.z - currentPageTopLeft.z; - InscryptionAPIPlugin.Logger.LogDebug($"[DescTopLeft] {descriptionTopLeft.x} {descriptionTopLeft.y} {descriptionTopLeft.z}"); - InscryptionAPIPlugin.Logger.LogDebug($"[PageTopLeft] {currentPageTopLeft.x} {currentPageTopLeft.y} {currentPageTopLeft.z}"); - InscryptionAPIPlugin.Logger.LogDebug($"[PageBottomLeft] {pageBottomLeft.x} {pageBottomLeft.y} {pageBottomLeft.z} | {zLength}"); + //InscryptionAPIPlugin.Logger.LogDebug($"[DescTopLeft] {descriptionTopLeft.x} {descriptionTopLeft.y} {descriptionTopLeft.z}"); + //InscryptionAPIPlugin.Logger.LogDebug($"[PageTopLeft] {currentPageTopLeft.x} {currentPageTopLeft.y} {currentPageTopLeft.z}"); + //InscryptionAPIPlugin.Logger.LogDebug($"[PageBottomLeft] {pageBottomLeft.x} {pageBottomLeft.y} {pageBottomLeft.z} | {zLength}"); ClearActiveInteractables(); CreateInteractables(redirects, description, zLength); @@ -113,8 +113,8 @@ public void CreateInteractableObject(Vector3 worldPosition, Vector3 colliderSize Vector3 newWorldPosition = PixelCamera.ScreenToWorldPoint(RuleBookCamera.WorldToScreenPoint(worldPosition)); - InscryptionAPIPlugin.Logger.LogDebug($"[CreateInteractable] ({colliderSize.x} {colliderSize.y})"); - InscryptionAPIPlugin.Logger.LogDebug($"[CreateInteractable] ({worldPosition.x} {worldPosition.y} {worldPosition.z}) ({newWorldPosition.x} {newWorldPosition.y} {newWorldPosition.z})"); + //InscryptionAPIPlugin.Logger.LogDebug($"[CreateInteractable] ({colliderSize.x} {colliderSize.y})"); + //InscryptionAPIPlugin.Logger.LogDebug($"[CreateInteractable] ({worldPosition.x} {worldPosition.y} {worldPosition.z}) ({newWorldPosition.x} {newWorldPosition.y} {newWorldPosition.z})"); obj.name = $"RuleBookPageInteractable ({keyText})"; obj.transform.SetParent(PixelCamera.transform); @@ -270,7 +270,7 @@ private void CreateColliderSizeAndPosition(Transform textMesh, float sizeY, floa } correctedPos = new(correctedX, correctedY, currentPageTopLeft.z + (zCorrection + zCorrection * correctedYProportion)); - Debug.Log($"[Corrected] ({correctedPos.x} {correctedPos.y} {correctedPos.z}) | {correctedXProportion} {correctedYProportion}"); + //Debug.Log($"[Corrected] ({correctedPos.x} {correctedPos.y} {correctedPos.z}) | {correctedXProportion} {correctedYProportion}"); colliderPositions.Add(correctedPos); colliderSizes.Add(new((topRight.x - bottomLeft.x) + sizeY / 2f, sizeY * 3f / 2f, 0.001f)); // add padding to compensate for inaccurate positioning } From 8502d909aa17984b15971bb95843e3662ad19a61 Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Sun, 6 Oct 2024 20:05:32 -0700 Subject: [PATCH 2/7] add triggers for when damage is prevented by a shield --- InscryptionAPI/Card/ShieldManager.cs | 24 ++++++++++++++++++++++++ InscryptionAPI/Triggers/Interfaces.cs | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/InscryptionAPI/Card/ShieldManager.cs b/InscryptionAPI/Card/ShieldManager.cs index ebdd9233..aeb28cf2 100644 --- a/InscryptionAPI/Card/ShieldManager.cs +++ b/InscryptionAPI/Card/ShieldManager.cs @@ -2,6 +2,7 @@ using DiskCardGame.CompositeRules; using HarmonyLib; using InscryptionAPI.Helpers.Extensions; +using InscryptionAPI.Triggers; using System.Collections; using System.Collections.ObjectModel; using System.Reflection; @@ -24,6 +25,29 @@ public static class ShieldManager public static List AllShieldInfos { get; internal set; } = AllShieldAbilities.Select(x => x.Info).ToList(); + public static IEnumerator TriggerBreakShield(PlayableCard target, int damage, PlayableCard attacker) + { + BreakShield(target, damage, attacker); + + List shieldTriggers = CustomTriggerFinder.FindTriggersOnBoard(false).ToList(); + shieldTriggers.Sort((IShieldPreventDamage a, IShieldPreventDamage b) => b.ShieldPreventDamagePriority(target, damage, attacker) - a.ShieldPreventDamagePriority(target, damage, attacker)); + foreach (IShieldPreventDamage damageTrigger in shieldTriggers) + { + if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventDamage(target, damage, attacker)) + { + yield return damageTrigger.OnShieldPreventDamage(target, damage, attacker); + } + } + List shieldInHandTriggers = CustomTriggerFinder.FindTriggersInHand().ToList(); + shieldInHandTriggers.Sort((IShieldPreventDamageInHand a, IShieldPreventDamageInHand b) => b.ShieldPreventDamageInHandPriority(target, damage, attacker) - a.ShieldPreventDamageInHandPriority(target, damage, attacker)); + foreach (IShieldPreventDamageInHand damageTrigger in shieldInHandTriggers) + { + if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventDamageInHand(target, damage, attacker)) + { + yield return damageTrigger.OnShieldPreventDamageInHand(target, damage, attacker); + } + } + } /// /// The method used for when a shielded card is damaged. Includes extra parameters for modders looking to modify this further. /// This method is only called when damage > 0 and the target has a shield. diff --git a/InscryptionAPI/Triggers/Interfaces.cs b/InscryptionAPI/Triggers/Interfaces.cs index 3e379dbd..f1a31971 100644 --- a/InscryptionAPI/Triggers/Interfaces.cs +++ b/InscryptionAPI/Triggers/Interfaces.cs @@ -802,6 +802,24 @@ public interface IOnCardDealtDamageDirectly public IEnumerator OnCardDealtDamageDirectly(PlayableCard attacker, CardSlot opposingSlot, int damage); } +/// +/// Trigger that is called after a shielded card was attacked and lost a shield. +/// +public interface IShieldPreventDamage +{ + public bool RespondsToShieldPreventDamage(PlayableCard target, int damage, PlayableCard attacker); + public IEnumerator OnShieldPreventDamage(PlayableCard target, int damage, PlayableCard attacker); + public int ShieldPreventDamagePriority(PlayableCard target, int damage, PlayableCard attacker); +} +/// +/// Variant of IShieldPreventDamage that triggers for cards in the hand. +/// +public interface IShieldPreventDamageInHand +{ + public bool RespondsToShieldPreventDamageInHand(PlayableCard target, int damage, PlayableCard attacker); + public IEnumerator OnShieldPreventDamageInHand(PlayableCard target, int damage, PlayableCard attacker); + public int ShieldPreventDamageInHandPriority(PlayableCard target, int damage, PlayableCard attacker); +} /*public interface IOnPreTakeDamageFromHammer { public bool RespondsToPreTakeDamageFromHammer(HammerItem hammer, CardSlot targetSlot, GameObject firstPersonItem); From 564620f8f21b1875b618b8d6db12aa0c729f0a5e Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Sun, 6 Oct 2024 22:56:59 -0700 Subject: [PATCH 3/7] add support for custom exhaust deck sequences during custom opponent fights --- .../Encounters/ICustomExhaustSequence.cs | 18 +++ InscryptionAPI/Encounters/OpponentManager.cs | 105 +++++++++--------- 2 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 InscryptionAPI/Encounters/ICustomExhaustSequence.cs diff --git a/InscryptionAPI/Encounters/ICustomExhaustSequence.cs b/InscryptionAPI/Encounters/ICustomExhaustSequence.cs new file mode 100644 index 00000000..53abf0eb --- /dev/null +++ b/InscryptionAPI/Encounters/ICustomExhaustSequence.cs @@ -0,0 +1,18 @@ +using DiskCardGame; +using System.Collections; + +namespace InscryptionAPI.Encounters; + +/// +/// An Opponent interface that implements custom logic when the player has exhausted both of their draw piles. +/// +public interface ICustomExhaustSequence +{ + public bool RespondsToCustomExhaustSequence(CardDrawPiles drawPiles); + /// + /// Executes the sequence that plays when the player exhausts their draw piles. + /// + /// The CardDrawPiles instance for this scene. + /// An enumeration of Unity events. + public IEnumerator DoCustomExhaustSequence(CardDrawPiles drawPiles); +} \ No newline at end of file diff --git a/InscryptionAPI/Encounters/OpponentManager.cs b/InscryptionAPI/Encounters/OpponentManager.cs index 8a68d8f1..0ea9648c 100644 --- a/InscryptionAPI/Encounters/OpponentManager.cs +++ b/InscryptionAPI/Encounters/OpponentManager.cs @@ -3,6 +3,7 @@ using InscryptionAPI.Guid; using InscryptionAPI.Masks; using InscryptionAPI.Saves; +using System.Collections; using System.Collections.ObjectModel; using System.Reflection; using System.Reflection.Emit; @@ -89,10 +90,49 @@ public static FullOpponent Add(string guid, string opponentName, string sequence NewOpponents.Add(opp); return opp; } + public static List RunStateOpponents + { + get + { + List previousBosses = new List(); + + string value = ModdedSaveManager.RunState.GetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses"); // 2,0,1 + if (value == null) + { + // Do nothing + } + else if (!value.Contains(',')) + { + // Single boss encounter + previousBosses.Add((Opponent.Type)int.Parse(value)); + } + else + { + // Multiple boss encounters + IEnumerable ids = value.Split(',').Select(static (a) => (Opponent.Type)int.Parse(a)); + previousBosses.AddRange(ids); + } + + return previousBosses; + } + set + { + string result = ""; // 2,0,1 + for (int i = 0; i < value.Count; i++) + { + if (i > 0) + { + result += ","; + } + result += (int)value[i]; + + } + ModdedSaveManager.RunState.SetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses", result); + } + } #region Patches - [HarmonyPatch(typeof(Opponent), nameof(Opponent.SpawnOpponent))] - [HarmonyPrefix] + [HarmonyPrefix, HarmonyPatch(typeof(Opponent), nameof(Opponent.SpawnOpponent))] private static bool ReplaceSpawnOpponent(EncounterData encounterData, ref Opponent __result) { if (encounterData.opponentType == Opponent.Type.Default || !ProgressionData.LearnedMechanic(MechanicsConcept.OpponentQueue)) @@ -124,27 +164,19 @@ private static bool ReplaceSpawnOpponent(EncounterData encounterData, ref Oppone [MethodImpl(MethodImplOptions.NoInlining)] public static string OriginalGetSequencerIdForBoss(Opponent.Type bossType) { throw new NotImplementedException(); } - [HarmonyPatch(typeof(BossBattleSequencer), nameof(BossBattleSequencer.GetSequencerIdForBoss))] - [HarmonyPrefix] + [HarmonyPrefix, HarmonyPatch(typeof(BossBattleSequencer), nameof(BossBattleSequencer.GetSequencerIdForBoss))] private static bool ReplaceGetSequencerId(Opponent.Type bossType, ref string __result) { __result = AllOpponents.First(o => o.Id == bossType).SpecialSequencerId; return false; } - [HarmonyPatch(typeof(BossBattleNodeData), nameof(BossBattleNodeData.PrefabPath), MethodType.Getter)] - [HarmonyPrefix] + [HarmonyPrefix, HarmonyPatch(typeof(BossBattleNodeData), nameof(BossBattleNodeData.PrefabPath), MethodType.Getter)] private static bool ReplacePrefabPath(ref string __result, Opponent.Type ___bossType) { - GameObject obj = ResourceBank.Get("Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType); - if (obj != null) - { - __result = "Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType; - } - else - { - __result = "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss"; - } + string fullPath = "Prefabs/Map/MapNodesPart1/MapNode_" + ___bossType; + GameObject obj = ResourceBank.Get(fullPath); + __result = obj != null ? fullPath : "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss"; return false; } @@ -220,47 +252,20 @@ public static void ProcessBossType(NodeData nodeData) } } - public static List RunStateOpponents + [HarmonyPostfix, HarmonyPatch(typeof(CardDrawPiles), nameof(CardDrawPiles.ExhaustedSequence))] + private static IEnumerator CustomBossExhaustionSequence(IEnumerator enumerator, CardDrawPiles __instance) { - get + if (TurnManager.Instance.Opponent is ICustomExhaustSequence exhaustSeq && exhaustSeq != null && exhaustSeq.RespondsToCustomExhaustSequence(__instance)) { - List previousBosses = new List(); - - string value = ModdedSaveManager.RunState.GetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses"); // 2,0,1 - if (value == null) - { - // Do nothing - } - else if (!value.Contains(',')) - { - // Single boss encounter - previousBosses.Add((Opponent.Type)int.Parse(value)); - } - else - { - // Multiple boss encounters - IEnumerable ids = value.Split(',').Select(static (a) => (Opponent.Type)int.Parse(a)); - previousBosses.AddRange(ids); - } - - return previousBosses; + Singleton.Instance.SwitchToView(View.CardPiles, immediate: false, lockAfter: true); + yield return new WaitForSeconds(1f); + yield return exhaustSeq.DoCustomExhaustSequence(__instance); } - set + else { - string result = ""; // 2,0,1 - for (int i = 0; i < value.Count; i++) - { - if (i > 0) - { - result += ","; - } - result += (int)value[i]; - - } - ModdedSaveManager.RunState.SetValue(InscryptionAPIPlugin.ModGUID, "PreviousBosses", result); + yield return enumerator; } } - #endregion #region Optimization Patches From ac1cc2befce56174eee78a1c0f6771f79d45abe7 Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Mon, 7 Oct 2024 09:52:38 -0700 Subject: [PATCH 4/7] modified --- InscryptionAPI/Encounters/ICustomExhaustSequence.cs | 5 ++++- InscryptionAPI/Encounters/OpponentManager.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/InscryptionAPI/Encounters/ICustomExhaustSequence.cs b/InscryptionAPI/Encounters/ICustomExhaustSequence.cs index 53abf0eb..4ddfb7c0 100644 --- a/InscryptionAPI/Encounters/ICustomExhaustSequence.cs +++ b/InscryptionAPI/Encounters/ICustomExhaustSequence.cs @@ -4,8 +4,11 @@ namespace InscryptionAPI.Encounters; /// -/// An Opponent interface that implements custom logic when the player has exhausted both of their draw piles. +/// An interface that implements custom logic when the player has exhausted both of their draw piles. /// +/// +/// Only for Opponents and SpecialSequences. +/// public interface ICustomExhaustSequence { public bool RespondsToCustomExhaustSequence(CardDrawPiles drawPiles); diff --git a/InscryptionAPI/Encounters/OpponentManager.cs b/InscryptionAPI/Encounters/OpponentManager.cs index 0ea9648c..46909bcb 100644 --- a/InscryptionAPI/Encounters/OpponentManager.cs +++ b/InscryptionAPI/Encounters/OpponentManager.cs @@ -255,7 +255,7 @@ public static void ProcessBossType(NodeData nodeData) [HarmonyPostfix, HarmonyPatch(typeof(CardDrawPiles), nameof(CardDrawPiles.ExhaustedSequence))] private static IEnumerator CustomBossExhaustionSequence(IEnumerator enumerator, CardDrawPiles __instance) { - if (TurnManager.Instance.Opponent is ICustomExhaustSequence exhaustSeq && exhaustSeq != null && exhaustSeq.RespondsToCustomExhaustSequence(__instance)) + if (TurnManager.Instance.Opponent is ICustomExhaustSequence exhaustSeq && exhaustSeq != null) { Singleton.Instance.SwitchToView(View.CardPiles, immediate: false, lockAfter: true); yield return new WaitForSeconds(1f); From f3aa9a1fdf92fbbdc7ec39b5e891f5e348ff34f4 Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Mon, 7 Oct 2024 09:52:49 -0700 Subject: [PATCH 5/7] Renamed to ShieldPrevented, changed BreakShield transpiler to use TriggerBreakShield instead --- CHANGELOG.md | 6 +++ InscryptionAPI/Card/ShieldManager.cs | 20 +++++----- InscryptionAPI/Triggers/Interfaces.cs | 16 ++++---- InscryptionAPI/Triggers/TakeDamagePatches.cs | 41 +++++++++++++++++--- 4 files changed, 60 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73cc8372..cfd0c6dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@
View Changelog +# 2.22.1 +- Added IShieldPreventedDamage and IShieldPreventedDamageInHand ability triggers and interfaces +- Added TriggerBreakShield, wraps BreakShield in an IEnumerator for additional customisation by modders +- Added ICustomExhaustSequence trigger interface for modifying the draw pile exhaustion effect - use with Opponents +- Removed debug logging related to rulebook redirect coordinates + # 2.22.0 - Added FullBoon objects for each vanilla Boon - Added 'AllFullBoons' list to BoonManager diff --git a/InscryptionAPI/Card/ShieldManager.cs b/InscryptionAPI/Card/ShieldManager.cs index aeb28cf2..e1677777 100644 --- a/InscryptionAPI/Card/ShieldManager.cs +++ b/InscryptionAPI/Card/ShieldManager.cs @@ -29,22 +29,22 @@ public static IEnumerator TriggerBreakShield(PlayableCard target, int damage, Pl { BreakShield(target, damage, attacker); - List shieldTriggers = CustomTriggerFinder.FindTriggersOnBoard(false).ToList(); - shieldTriggers.Sort((IShieldPreventDamage a, IShieldPreventDamage b) => b.ShieldPreventDamagePriority(target, damage, attacker) - a.ShieldPreventDamagePriority(target, damage, attacker)); - foreach (IShieldPreventDamage damageTrigger in shieldTriggers) + List shieldTriggers = CustomTriggerFinder.FindTriggersOnBoard(false).ToList(); + shieldTriggers.Sort((IShieldPreventedDamage a, IShieldPreventedDamage b) => b.ShieldPreventedDamagePriority(target, damage, attacker) - a.ShieldPreventedDamagePriority(target, damage, attacker)); + foreach (IShieldPreventedDamage damageTrigger in shieldTriggers) { - if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventDamage(target, damage, attacker)) + if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventedDamage(target, damage, attacker)) { - yield return damageTrigger.OnShieldPreventDamage(target, damage, attacker); + yield return damageTrigger.OnShieldPreventedDamage(target, damage, attacker); } } - List shieldInHandTriggers = CustomTriggerFinder.FindTriggersInHand().ToList(); - shieldInHandTriggers.Sort((IShieldPreventDamageInHand a, IShieldPreventDamageInHand b) => b.ShieldPreventDamageInHandPriority(target, damage, attacker) - a.ShieldPreventDamageInHandPriority(target, damage, attacker)); - foreach (IShieldPreventDamageInHand damageTrigger in shieldInHandTriggers) + List shieldInHandTriggers = CustomTriggerFinder.FindTriggersInHand().ToList(); + shieldInHandTriggers.Sort((IShieldPreventedDamageInHand a, IShieldPreventedDamageInHand b) => b.ShieldPreventedDamageInHandPriority(target, damage, attacker) - a.ShieldPreventedDamageInHandPriority(target, damage, attacker)); + foreach (IShieldPreventedDamageInHand damageTrigger in shieldInHandTriggers) { - if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventDamageInHand(target, damage, attacker)) + if ((damageTrigger as TriggerReceiver) != null && damageTrigger.RespondsToShieldPreventedDamageInHand(target, damage, attacker)) { - yield return damageTrigger.OnShieldPreventDamageInHand(target, damage, attacker); + yield return damageTrigger.OnShieldPreventedDamageInHand(target, damage, attacker); } } } diff --git a/InscryptionAPI/Triggers/Interfaces.cs b/InscryptionAPI/Triggers/Interfaces.cs index f1a31971..30714e18 100644 --- a/InscryptionAPI/Triggers/Interfaces.cs +++ b/InscryptionAPI/Triggers/Interfaces.cs @@ -805,20 +805,20 @@ public interface IOnCardDealtDamageDirectly /// /// Trigger that is called after a shielded card was attacked and lost a shield. /// -public interface IShieldPreventDamage +public interface IShieldPreventedDamage { - public bool RespondsToShieldPreventDamage(PlayableCard target, int damage, PlayableCard attacker); - public IEnumerator OnShieldPreventDamage(PlayableCard target, int damage, PlayableCard attacker); - public int ShieldPreventDamagePriority(PlayableCard target, int damage, PlayableCard attacker); + public bool RespondsToShieldPreventedDamage(PlayableCard target, int damage, PlayableCard attacker); + public IEnumerator OnShieldPreventedDamage(PlayableCard target, int damage, PlayableCard attacker); + public int ShieldPreventedDamagePriority(PlayableCard target, int damage, PlayableCard attacker); } /// /// Variant of IShieldPreventDamage that triggers for cards in the hand. /// -public interface IShieldPreventDamageInHand +public interface IShieldPreventedDamageInHand { - public bool RespondsToShieldPreventDamageInHand(PlayableCard target, int damage, PlayableCard attacker); - public IEnumerator OnShieldPreventDamageInHand(PlayableCard target, int damage, PlayableCard attacker); - public int ShieldPreventDamageInHandPriority(PlayableCard target, int damage, PlayableCard attacker); + public bool RespondsToShieldPreventedDamageInHand(PlayableCard target, int damage, PlayableCard attacker); + public IEnumerator OnShieldPreventedDamageInHand(PlayableCard target, int damage, PlayableCard attacker); + public int ShieldPreventedDamageInHandPriority(PlayableCard target, int damage, PlayableCard attacker); } /*public interface IOnPreTakeDamageFromHammer { diff --git a/InscryptionAPI/Triggers/TakeDamagePatches.cs b/InscryptionAPI/Triggers/TakeDamagePatches.cs index 36397782..3dce8d36 100644 --- a/InscryptionAPI/Triggers/TakeDamagePatches.cs +++ b/InscryptionAPI/Triggers/TakeDamagePatches.cs @@ -94,6 +94,7 @@ private static IEnumerable TakeDamageTranspiler(IEnumerable TakeDamageTranspiler(IEnumerable 0) { + CodeInstruction switch_ = codes.Find(x => x.opcode == OpCodes.Switch); + //switch_.WithLabels(breakShieldLabel); + object state = codes.Find(x => x.opcode == OpCodes.Stfld && x.operand.ToString() == "System.Int32 <>1__state").operand; + object current = codes.Find(x => x.opcode == OpCodes.Stfld && x.operand.ToString() == "System.Object <>2__current").operand; // if (HasShield && damage > 0) - // BreakShield(); + // yield return TriggerBreakShield(); // break; - MethodBase breakShield = AccessTools.Method(typeof(ShieldManager), nameof(ShieldManager.BreakShield), + // TriggerBreakShield + // this.current = TriggerBreakShield + // this.state = 7 + // return true + // this.state = -1 + // yield break (new label) + + MethodBase breakShield = AccessTools.Method(typeof(ShieldManager), nameof(ShieldManager.TriggerBreakShield), new Type[] { typeof(PlayableCard), typeof(int), typeof(PlayableCard) }); codes.RemoveRange(shieldStart, shieldEnd - shieldStart); @@ -145,14 +157,33 @@ private static IEnumerable TakeDamageTranspiler(IEnumerable Date: Wed, 9 Oct 2024 13:50:06 -0700 Subject: [PATCH 6/7] Fix slot effects with rulebook redirects disabling the slot when the effect is reset --- CHANGELOG.md | 1 + InscryptionAPI/Slots/SlotModificationExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfd0c6dd..da931110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Added IShieldPreventedDamage and IShieldPreventedDamageInHand ability triggers and interfaces - Added TriggerBreakShield, wraps BreakShield in an IEnumerator for additional customisation by modders - Added ICustomExhaustSequence trigger interface for modifying the draw pile exhaustion effect - use with Opponents +- Fixed board slots being uninteractable if a slot effect with a rulebook interactable was reset - Removed debug logging related to rulebook redirect coordinates # 2.22.0 diff --git a/InscryptionAPI/Slots/SlotModificationExtensions.cs b/InscryptionAPI/Slots/SlotModificationExtensions.cs index ba829da2..fe6872f8 100644 --- a/InscryptionAPI/Slots/SlotModificationExtensions.cs +++ b/InscryptionAPI/Slots/SlotModificationExtensions.cs @@ -98,7 +98,7 @@ public static IEnumerator SetSlotModification(this CardSlot slot, ModificationTy SlotModificationInteractable interactable = slot.GetComponent(); if (defn == null || modType == ModificationType.NoModification || (defn.SharedRulebook == ModificationType.NoModification && string.IsNullOrEmpty(defn.RulebookName))) { - interactable?.SetEnabled(false); + UnityObject.Destroy(interactable); } else { From 739625c71b515e40c5de38fc1c6734f8b5cb70fb Mon Sep 17 00:00:00 2001 From: WhistleWind Date: Wed, 9 Oct 2024 22:18:37 -0700 Subject: [PATCH 7/7] update project version number --- InscryptionAPI/InscryptionAPI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InscryptionAPI/InscryptionAPI.csproj b/InscryptionAPI/InscryptionAPI.csproj index 5e587714..7b4c34a2 100644 --- a/InscryptionAPI/InscryptionAPI.csproj +++ b/InscryptionAPI/InscryptionAPI.csproj @@ -10,7 +10,7 @@ full false true - 2.22.0 + 2.22.1