From b664e788c64c8c42b1b96c7e6fb8b47b562cb117 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:19:58 -0800 Subject: [PATCH 1/5] Fix 3D activated sigil icons not changing colour when moused over and clicked Added event hooks so modders can modify the colours they change to Will need to add a wiki page to explain all this but I'll do that later --- .../Card/ActivatedAbilityHandler3D.cs | 74 +++++---- .../Card/ActivatedAbilityIconFix.cs | 58 ++++++- .../Card/ActivatedAbilityIconInteractable.cs | 157 ++++++++++++++---- 3 files changed, 222 insertions(+), 67 deletions(-) diff --git a/InscryptionCommunityPatch/Card/ActivatedAbilityHandler3D.cs b/InscryptionCommunityPatch/Card/ActivatedAbilityHandler3D.cs index 8ba48712a..cc58d50bb 100644 --- a/InscryptionCommunityPatch/Card/ActivatedAbilityHandler3D.cs +++ b/InscryptionCommunityPatch/Card/ActivatedAbilityHandler3D.cs @@ -1,13 +1,14 @@ using DiskCardGame; using HarmonyLib; +using Sirenix.Utilities; +using UnityEngine; namespace InscryptionCommunityPatch.Card; /// -/// Fixes the Activated Ability handler in 3D Environments. +/// Handles activated abilities outside Act 2 to make them function correctly. /// -public class ActivatedAbilityHandler3D : ManagedBehaviour -{ +public class ActivatedAbilityHandler3D : ManagedBehaviour { /// /// The current Icon Group of . /// @@ -30,41 +31,56 @@ public void AddInteractable(ActivatedAbilityIconInteractable interactable) /// /// Updates the List of to the passed in List. /// - /// The list of Interactable used to replace the current list. - public void UpdateInteractableList(List controllerActiveIcons) - { + /// The list of ability interactables to replace the current list. + /// /// The list of ability interactables used by the game to render ability icons. + public void UpdateInteractableList(List activeIconsCard, List activeIconsRender) { interactables.Clear(); - currentIconGroup = controllerActiveIcons; - controllerActiveIcons - .Where(elem => AbilitiesUtil.GetInfo(elem.Ability).activated) - .Do(abIcon => - { - ActivatedAbilityIconInteractable currentIcon = abIcon.gameObject.GetComponent(); - if (currentIcon) - { - currentIcon.AssignAbility(abIcon.Ability); - AddInteractable(currentIcon); + currentIconGroup = activeIconsCard; + //PatchPlugin.Logger.LogInfo($"{activeIconsCard.Count} {activeIconsRender.Count}"); + for (int i = 0; i < activeIconsCard.Count; i++) { + // if this active icon is for an activated sigil + if (AbilitiesUtil.GetInfo(activeIconsCard[0].Ability).activated) { + ActivatedAbilityIconInteractable currentIcon = activeIconsCard[0].gameObject.GetComponent(); + // if there is no activated interactable, add one + if (currentIcon.SafeIsUnityNull()) { + GameObject obj = activeIconsCard[0].gameObject; + obj.layer = 0; + + currentIcon = obj.AddComponent(); } - else - { - var go = abIcon.gameObject; - go.layer = 0; - var interactable = go.AddComponent(); - interactable.AssignAbility(abIcon.Ability); + currentIcon.AssignAbility(activeIconsCard[0].Ability); - AddInteractable(interactable); + // if there is a corresponding render interactable object, connect it to the active interactable object + if (i >= 0 && i < activeIconsRender.Count && activeIconsRender.Count > 0) { + ActivatedAbilityIconInteractable renderIcon = activeIconsRender[i].gameObject.GetComponent(); + if (renderIcon.SafeIsUnityNull()) { + renderIcon = activeIconsRender[i].gameObject.AddComponent(); + } + renderIcon.AssignAbility(currentIcon.Ability); + + currentIcon.SetRenderIcon(renderIcon); } - }); + AddInteractable(currentIcon); + } + } - if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) + if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) { PatchPlugin.Logger.LogDebug($"[Handler3D] Updated interactable list: [{interactables.Join(interactable => $"GO [{interactable.gameObject}] Ability [{interactable.Ability}]")}]"); + } } - private void OnDestroy() - { - foreach (var interactable in interactables) - { + /// + /// Updates the List of to the passed in List. + /// + /// The list of Interactable used to replace the current list. + [Obsolete("Does not update icon rendering. Use UpdateInteractableList(List, List) instead.")] + public void UpdateInteractableList(List controllerActiveIcons) { + UpdateInteractableList(controllerActiveIcons, new(1)); + } + + private void OnDestroy() { + foreach (var interactable in interactables) { Destroy(interactable); } } diff --git a/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs b/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs index df4d2558c..7a8d0a86b 100644 --- a/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs +++ b/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs @@ -1,11 +1,15 @@ using DiskCardGame; using HarmonyLib; +using InscryptionAPI.Helpers; using Sirenix.Utilities; +using System.Reflection; +using System.Reflection.Emit; +using UnityEngine; namespace InscryptionCommunityPatch.Card; /// -/// Fixes related to Activated Ability Icons. +/// Fixes activated abilities not working outside Act 2. /// [HarmonyPatch] public static class ActivatedAbilityIconFix @@ -35,8 +39,7 @@ private static void FixActivatedAbilitiesOnAnyChange(ref PlayableCard __instance ActivatedAbilityHandler3D abilityHandler3D = __instance.GetComponent(); - if (abilityHandler3D.SafeIsUnityNull()) - { + if (abilityHandler3D.SafeIsUnityNull()) { if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) PatchPlugin.Logger.LogDebug($"[PlayableCard.OnStatsChanged] Adding activated ability handler to card [{__instance.Info.displayedName}]"); @@ -48,7 +51,54 @@ private static void FixActivatedAbilitiesOnAnyChange(ref PlayableCard __instance if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) PatchPlugin.Logger.LogDebug($"[PlayableCard.OnStatsChanged] -> Resetting icon list for [{__instance.Info.displayedName}]"); - abilityHandler3D.UpdateInteractableList(__instance.AbilityIcons.abilityIcons); + abilityHandler3D.UpdateInteractableList( + __instance.AbilityIcons.abilityIcons, + (CardRenderCamera.Instance.cardDisplayer as CardDisplayer3D).AbilityIcons.abilityIcons + ); + } + } + + /// + /// Determines the colour of the given 's icon, while supporting dynamic colouring for 3D activated sigil icons. + /// + /// The whose icon we're colouring. + /// The default ability colour. This will be used if no override conditions are met. + /// Whether the card with this ability is in a conduit circuit. + public static void SetAbilityIconDefaultColour(AbilityIconInteractable abilityIconInteractable, Color color, bool inConduitCircuit) { + AbilityInfo info = AbilitiesUtil.GetInfo(abilityIconInteractable.Ability); + ActivatedAbilityIconInteractable act = abilityIconInteractable.GetComponent(); + + if (info.hasColorOverride && !(info.conduitCell && inConduitCircuit)) { + abilityIconInteractable.SetColor(info.colorOverride); } + else if (act?.CurrentColourOverride != null) { + abilityIconInteractable.SetColor((Color)act.CurrentColourOverride); + } + else { + abilityIconInteractable.SetColor(color); + } + } + + [HarmonyTranspiler, HarmonyPatch(typeof(CardAbilityIcons), nameof(CardAbilityIcons.SetColorOfDefaultIcons))] + private static IEnumerable FixActivatedIconSetColour(IEnumerable instructions) { + List codes = new(instructions); + codes.LogCodeInstructions(); + CodeInstruction startCode = codes.Find(x => x.opcode == OpCodes.Stloc_S && x.operand.ToString() == "DiskCardGame.AbilityIconInteractable (4)"); + object operand = startCode.operand; + int startIndex = codes.FindIndex(x => x.opcode == OpCodes.Stloc_S && x.operand.ToString() == "DiskCardGame.AbilityInfo (5)") - 2; + int endIndex = codes.FindLastIndex(x => x.opcode == OpCodes.Add) - 3; + + MethodBase customMethod = AccessTools.Method( + typeof(ActivatedAbilityIconFix), nameof(ActivatedAbilityIconFix.SetAbilityIconDefaultColour), + new Type[] { typeof(AbilityIconInteractable), typeof(Color), typeof(bool) }); + + codes.RemoveRange(startIndex, endIndex - startIndex + 1); + codes.Insert(startIndex, new(OpCodes.Callvirt, customMethod)); + codes.Insert(startIndex, new(OpCodes.Ldarg_2)); + codes.Insert(startIndex, new(OpCodes.Ldarg_1)); + codes.Insert(startIndex, new(OpCodes.Ldloc_S, operand)); + + codes.LogCodeInstructions("post"); + return codes; } } \ No newline at end of file diff --git a/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs b/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs index c803add9a..e45bb6cf6 100644 --- a/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs +++ b/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs @@ -1,28 +1,57 @@ using DiskCardGame; +using Sirenix.Utilities; using UnityEngine; namespace InscryptionCommunityPatch.Card; /// -/// Fixes related to how Activated Ability Interactable's are rendered on cards. +/// An interactable object attached to activated ability icons to make them function when clicked using main input (default left-click on keyboard). /// -public class ActivatedAbilityIconInteractable : MainInputInteractable -{ - private Material _renderMaterial; +public class ActivatedAbilityIconInteractable : MainInputInteractable { /// - /// The Original Interactable Color. + /// The original colour of the ability icon. /// public Color _originalColor; /// - /// The Color used when the region is entered: ARGB: 178, 178, 178, 178 + /// The Color used when the interactable icon's hitbox is entered. ARGB: 255, 127, 127, 127 + /// + public readonly Color _enterColor = new(0.5f, 0.5f, 0.5f, 1f); + /// + /// The Color used when the interactable icon is selected. ARGB: 255, 191, 191, 191 + /// + public readonly Color _selectedColor = new(0.75f, 0.75f, 0.75f, 1f); + + /// + /// The colour to use when overriding icon colours. If null, does not override icon colours. /// - public readonly Color _enterColor = new(.7f, .7f, .7f, .7f); + public Color? CurrentColourOverride { get; set; } = null; + + /// + /// The Color used when the interactable icon's hitbox is entered. Lerps between and by default. + ///

+ /// Also incorporates so modders can modify this if desired. + ///
+ public Color EnterColour { + get { + Color enterCol = ModifyOnEnterColour?.Invoke(_enterColor, _playableCard) ?? _enterColor; + return Color.Lerp(_originalColor, enterCol, 0.5f); + } + } /// - /// The Color used when the region is selected: ARGB: 102, 102, 102, 102 + /// The Color used when the interactable icon is selected. Lerps between and by default. + ///

+ /// Also incorporates so modders can modify this if desired. ///
- public readonly Color _selectedColor = new(.4f, .4f, .4f, .4f); + public Color SelectedColour { + get { + Color selectCol = ModifyOnEnterColour?.Invoke(_selectedColor, _playableCard) ?? _selectedColor; + return Color.Lerp(_originalColor, selectCol, 0.5f); + } + } + private Material _renderMaterial; private PlayableCard _playableCard; + private ActivatedAbilityIconInteractable _renderIcon; private bool CanActivate => TurnManager.Instance @@ -32,12 +61,7 @@ public class ActivatedAbilityIconInteractable : MainInputInteractable && !BoardManager.Instance.ChoosingSlot && GlobalTriggerHandler.Instance.StackSize == 0; - private void Start() - { - _playableCard = GetComponentInParent(); - } - - private bool IsValidPlayableCard => _playableCard && _playableCard.OnBoard && !_playableCard.OpponentCard; + private bool IsValidPlayableCard => _playableCard != null && _playableCard.OnBoard && !_playableCard.OpponentCard; /// /// Whether or not an Ability has been assigned, this is done by checking if the Ability is greater than . @@ -50,16 +74,43 @@ private void Start() public Ability Ability { get; private set; } /// - /// Assigns our new interactable to the passed in Ability. + /// Event that's called whenever the game gets . Allows modders to modify said colour. + /// + /// + /// + /// Arguments: + /// defaultEnterColThe default 'on enter' colour used by the API. + /// cardThe card this ability icon's attached to. Can be null. + /// + /// Returns a . + /// + public static event Func ModifyOnEnterColour; + + /// + /// Event that's called whenever the game gets . Allows modders to modify said colour. + /// + /// + /// + /// Arguments: + /// defaultSelectColThe default 'on select' colour used by the API. + /// cardThe card this ability icon's attached to. Can be null. + /// + /// Returns a . + /// + public static event Func ModifyOnSelectColour; + + /// + /// Assigns our new interactable to the passed-in Ability. /// /// The ability we want to update the Interactable of. - public void AssignAbility(Ability ability) - { - if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) + public void AssignAbility(Ability ability) { + if (PatchPlugin.configDisplayCompleteDebugLogsInConsole.Value) { PatchPlugin.Logger.LogDebug($"Icon was previously {Ability} - asking to change to a {ability}"); + } + Ability = ability; _renderMaterial = GetComponent().material; - _originalColor = _renderMaterial.color; + CursorSelectEnded = (Action)Delegate.Combine( CursorSelectEnded, (Action)delegate @@ -69,38 +120,76 @@ public void AssignAbility(Ability ability) ); } + internal void SetRenderIcon(ActivatedAbilityIconInteractable icon) { + AbilityInfo info = AbilitiesUtil.GetInfo(Ability); + + _renderIcon = icon; + + // get the original colour of the icon when first initialising this icon + if (info.hasColorOverride) { + _originalColor = info.colorOverride; + } + else if (_playableCard?.RenderInfo != null) { + _originalColor = _playableCard.RenderInfo.defaultAbilityColor; + } + else { + _originalColor = _renderMaterial.color; + } + _originalColor = info.hasColorOverride ? info.colorOverride : _renderMaterial.color; + } private void OnButtonPressed() { - if (CanActivate) - { + if (CanActivate) { CustomCoroutine.Instance.StartCoroutine(_playableCard.TriggerHandler.OnTrigger(Trigger.ActivatedAbility, Ability)); } } /// - /// Set's the color of the Rendering Material related to the Activated Ability. + /// Sets the color of the Rendering Material related to the Activated Ability. /// /// - public void SetColor(Color color) => _renderMaterial.color = color; + public void SetColor(Color? color) { + // don't change colours if the activated ability cannot be interacted with + if (!CanActivate) { + return; + } + + //Debug.Log($"SetColour {_playableCard != null}"); + // update the colour override for this icon + // if there is a corresponding render icon (which controls the actual colour change) + // then update that as well + CurrentColourOverride = color; + if (!_renderIcon.SafeIsUnityNull()) { + // if _renderIcon is null then the icon colour won't actually update + _renderIcon.CurrentColourOverride = color; + } + + // re-render the card so the colour updates properly + _playableCard?.RenderCard(); + } /// - /// Set's the color to using when the cursor enters the region. + /// Sets to when the cursor enters the icon's hitbox. /// - public override void OnCursorEnter() => SetColor(_enterColor); + public override void OnCursorEnter() => SetColor(EnterColour); /// - /// Set's the color to using when the cursor exits the region. + /// Resets when the cursor exits the icon's hitbox. /// - public override void OnCursorExit() => SetColor(_originalColor); + public override void OnCursorExit() => SetColor(null); /// - /// Set's the color to using when the cursor selects the region. + /// Sets to when clicking on the icon. /// - public override void OnCursorSelectStart() => SetColor(_selectedColor); + public override void OnCursorSelectStart() => SetColor(SelectedColour); /// - /// Set's the color to using when the cursor unselects the region. + /// Resets when the cursor selection ends. /// - public override void OnCursorSelectEnd() => SetColor(_originalColor); + public override void OnCursorSelectEnd() => SetColor(null); /// - /// Set's the color to using when the cursor drags the region. + /// Resets when the cursor drags the icon. /// - public override void OnCursorDrag() => SetColor(_originalColor); + public override void OnCursorDrag() => SetColor(null); + + private void Start() { + _playableCard = GetComponentInParent(); + } } \ No newline at end of file From 703d497cd5eab6dcef9047b0b5687f6a61470ce1 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:14:56 -0800 Subject: [PATCH 2/5] Change event hooks to also include the current ability since that's probably important information to pass on to potential modders --- .../Card/ActivatedAbilityIconInteractable.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs b/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs index e45bb6cf6..b85283f16 100644 --- a/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs +++ b/InscryptionCommunityPatch/Card/ActivatedAbilityIconInteractable.cs @@ -33,7 +33,7 @@ public class ActivatedAbilityIconInteractable : MainInputInteractable { /// public Color EnterColour { get { - Color enterCol = ModifyOnEnterColour?.Invoke(_enterColor, _playableCard) ?? _enterColor; + Color enterCol = ModifyOnEnterColour?.Invoke(_enterColor, Ability, _playableCard) ?? _enterColor; return Color.Lerp(_originalColor, enterCol, 0.5f); } } @@ -44,7 +44,7 @@ public Color EnterColour { /// public Color SelectedColour { get { - Color selectCol = ModifyOnEnterColour?.Invoke(_selectedColor, _playableCard) ?? _selectedColor; + Color selectCol = ModifyOnEnterColour?.Invoke(_selectedColor, Ability, _playableCard) ?? _selectedColor; return Color.Lerp(_originalColor, selectCol, 0.5f); } } @@ -80,11 +80,12 @@ public Color SelectedColour { /// /// Arguments: /// defaultEnterColThe default 'on enter' colour used by the API. + /// abilityThe ability for the activated icon being coloured. /// cardThe card this ability icon's attached to. Can be null. /// /// Returns a . /// - public static event Func ModifyOnEnterColour; + public static event Func ModifyOnEnterColour; /// /// Event that's called whenever the game gets . Allows modders to modify said colour. @@ -93,11 +94,12 @@ public Color SelectedColour { /// /// Arguments: /// defaultSelectColThe default 'on select' colour used by the API. + /// abilityThe ability for the activated icon being coloured. /// cardThe card this ability icon's attached to. Can be null. /// /// Returns a . /// - public static event Func ModifyOnSelectColour; + public static event Func ModifyOnSelectColour; /// /// Assigns our new interactable to the passed-in Ability. From 17d24e3084acdbe430ca60cac7d1be1b2143ad7c Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:53:05 -0800 Subject: [PATCH 3/5] Remove debug logging --- InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs b/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs index 7a8d0a86b..e114db982 100644 --- a/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs +++ b/InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs @@ -82,7 +82,7 @@ public static void SetAbilityIconDefaultColour(AbilityIconInteractable abilityIc [HarmonyTranspiler, HarmonyPatch(typeof(CardAbilityIcons), nameof(CardAbilityIcons.SetColorOfDefaultIcons))] private static IEnumerable FixActivatedIconSetColour(IEnumerable instructions) { List codes = new(instructions); - codes.LogCodeInstructions(); + CodeInstruction startCode = codes.Find(x => x.opcode == OpCodes.Stloc_S && x.operand.ToString() == "DiskCardGame.AbilityIconInteractable (4)"); object operand = startCode.operand; int startIndex = codes.FindIndex(x => x.opcode == OpCodes.Stloc_S && x.operand.ToString() == "DiskCardGame.AbilityInfo (5)") - 2; @@ -98,7 +98,6 @@ private static IEnumerable FixActivatedIconSetColour(IEnumerabl codes.Insert(startIndex, new(OpCodes.Ldarg_1)); codes.Insert(startIndex, new(OpCodes.Ldloc_S, operand)); - codes.LogCodeInstructions("post"); return codes; } } \ No newline at end of file From ddc8f0e7e48c4919fcc0fd541adebeaec283c9c8 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:29:34 -0800 Subject: [PATCH 4/5] Fix error when trying to render pixel talking cards --- .../Card/DisableTalkingCardRenderingAct2.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 InscryptionCommunityPatch/Card/DisableTalkingCardRenderingAct2.cs diff --git a/InscryptionCommunityPatch/Card/DisableTalkingCardRenderingAct2.cs b/InscryptionCommunityPatch/Card/DisableTalkingCardRenderingAct2.cs new file mode 100644 index 000000000..ad5599980 --- /dev/null +++ b/InscryptionCommunityPatch/Card/DisableTalkingCardRenderingAct2.cs @@ -0,0 +1,20 @@ +using DiskCardGame; +using GBC; +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace InscryptionCommunityPatch.Card; +[HarmonyPatch] +internal class DisableTalkingCardRenderingAct2 { + [HarmonyPrefix, HarmonyPatch(typeof(TalkingCard), nameof(TalkingCard.Start))] + private static bool DisableRenderIfPixelCard(TalkingCard __instance) { + if (CardRenderCamera.Instance == null) { + return false; + } + return true; + } +} From 9663bbcb08fec5ec489dcd00f61458c199f027df Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Sat, 21 Nov 2026 08:43:28 -0800 Subject: [PATCH 5/5] Update changelog regarding activated sigil changes --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4994339a8..3266f6997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ * Add `OverrideQueuedBackground` to the `PixelCardBehaviours`. * This is used for overriding the Queued Background of a card. * Upgraded the API's `.csproj`'s, and TCLI Build system. -* Publicized the `_originalColor`, `_enterColor`, and `_selectedColor` used within `ActivatedAbilityIconInteractable` of the Community Patch. +* Fixed activated abilities outside Act 2 not updating their icon colours to indicate interactability +* Added `ModifyOnEnterColour` and `ModifyOnSelectColour` event hooks to community patch's `ActivatedAbilityIconInteractable` class * Update the API to use Latest BepInEx. # 2.24.1