From 6ea927e4941d93fdc39a1b23d0ec87ab0339944b Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:48:10 -0700 Subject: [PATCH 1/9] Stop compiling causing the bin folder to fill with local lock assemblies i do NOT need seventy million copies of unity asms on my pc --- InscryptionAPI/InscryptionAPI.csproj | 9 +++++---- .../InscryptionCommunityPatch.csproj | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/InscryptionAPI/InscryptionAPI.csproj b/InscryptionAPI/InscryptionAPI.csproj index 27de0776..6756c9ba 100644 --- a/InscryptionAPI/InscryptionAPI.csproj +++ b/InscryptionAPI/InscryptionAPI.csproj @@ -10,6 +10,7 @@ full false true + false 2.24.1 @@ -35,9 +36,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj index 611bf61a..8404ec98 100644 --- a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj +++ b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj @@ -9,6 +9,7 @@ true full false + false 2.24.0 @@ -17,11 +18,11 @@ - + - + @@ -29,10 +30,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + From 9fb52252c9ed3a52321117e6f5ec6ddadb081d74 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:50:00 -0700 Subject: [PATCH 2/9] Add way to easily patch and modify the default bone gain when a player's card dies --- CHANGELOG.md | 10 +- InscryptionAPI/Card/DefaultBoneGainOnDeath.cs | 142 ++++++++++++++++++ InscryptionAPI/InscryptionAPIPlugin.cs | 2 +- 3 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 InscryptionAPI/Card/DefaultBoneGainOnDeath.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index d4bddb22..079ce4d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ +# 2.24.2 +- Added way to easily patch and modify the default bone gain when a player's card dies +- Added class `DefaultBoneGainOnDeath` and methods `DefaultBoneGainOnDeath.ShouldDoDefaultBoneGain` and `DefaultBoneGainOnDeeath.DoDefaultBoneGain` + # 2.24.1 -* Added Extensions for setting the IconTexture of a Starter Deck. -* Added 2 Alternate Constructors for making a StarterDeck with a Display Name different from its Internal Name. -* Added Getters and Setters for Starter Deck Unlock Level. +- Added Extensions for setting the IconTexture of a Starter Deck. +- Added 2 Alternate Constructors for making a StarterDeck with a Display Name different from its Internal Name. +- Added Getters and Setters for Starter Deck Unlock Level. # 2.24.0 - Fixed Part2CardCostRender.UpdatePlayableCardCost not being invoked diff --git a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs new file mode 100644 index 00000000..1e82976b --- /dev/null +++ b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs @@ -0,0 +1,142 @@ +using DiskCardGame; +using GBC; +using HarmonyLib; +using InscryptionAPI.Guid; +using InscryptionAPI.Helpers; +using InscryptionAPI.Saves; +using MonoMod.Cil; +using System.Collections; +using System.Collections.ObjectModel; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using UnityEngine; + +namespace InscryptionAPI.Card; + +[HarmonyPatch] +public class DefaultBoneGainOnDeath { + + [HarmonyTranspiler, ] + [HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.Die), MethodType.Enumerator)] + private static IEnumerable InsertBoneMethodHook(IEnumerable instructions) + { + // === We want to turn this + + // if (!HasAbility(Ability.QuadrupleBones) && slotBeforeDeath.IsPlayerSlot) { + // yield return Singleton.Instance.AddBones(1, slotBeforeDeath); + // } + + // === Into this + + // if (ShouldDoDefaultBoneGain(base.Card, slotBeforeDeath) { + // yield return DoDefaultBoneGain(base.Card, slotBeforeDeath, 1); + // } + + // === + List codes = new(instructions); + codes.LogCodeInscryptions(); + + for (int i = 0; i < codes.Count; i++) { + // there are two instances where this is true, but we only care about the first instance + // the second instance will be ignored + if (codes[i].opcode == OpCodes.Ldc_I4_S && codes[i].operand.ToString() == "12") { + /* + * // if (!playableCard.HasAbility(Ability.QuadrupleBones) && 5__2.IsPlayerSlot) + * ldloc.1 + * ldc.i4.s 12 + * call instance bool DiskCardGame.PlayableCard::HasAbility(valuetype DiskCardGame.Ability) + * brtrue.s IL_022f + * + * ldarg.0 + * ldfld class DiskCardGame.CardSlot DiskCardGame.PlayableCard/'d__98'::'5__2' + * callvirt instance bool DiskCardGame.CardSlot::get_IsPlayerSlot() + * brfalse.s IL_022f + * + * = + * + * // if (ShouldDoDefaultBoneGain(playableCard, 5__2) + * ldloc.1 + * ldarg.0 + * ldfld class DiskCardGame.CardSlot DiskCardGame.PlayableCard/'d__98'::'5__2' + * callvirt ShouldDo... + * brfalse.s IL_022f + */ + MethodInfo validationMethod = AccessTools.Method( + typeof(DefaultBoneGainOnDeath), nameof(ShouldDoDefaultBoneGain), + new Type[] { typeof(PlayableCard), typeof(CardSlot) }); + + codes.RemoveAt(i); + codes.RemoveAt(i); + codes.RemoveAt(i); + i += 2; + codes[i] = new CodeInstruction(OpCodes.Callvirt, validationMethod); + + /* + * // <>2__current = Singleton.Instance.AddBones(1, 5__2); + * ldarg.0 + * call !0 class Singleton`1::get_Instance() + * ldc.i4.1 + * ldarg.0 + * ldfld class DiskCardGame.CardSlot DiskCardGame.PlayableCard/'d__98'::'5__2' + * callvirt instance class [netstandard]System.Collections.IEnumerator DiskCardGame.ResourcesManager::AddBones(int32, class DiskCardGame.CardSlot) + * stfld object DiskCardGame.PlayableCard/'d__98'::'<>2__current' + * + * = + * + * // <>2__current = DoDefaultBoneGain(playableCard, slotBeforeDeath, 1); + * ldarg.0 + * ldloc.1 + * ldarg.0 + * ldfld class DiskCardGame.CardSlot DiskCardGame.PlayableCard/'d__98'::'5__2' + * ldc.i4.1 + * callvirt DoDefaultBoneGain + * stfld object DiskCardGame.PlayableCard/'d__98'::'<>2__current' + */ + + MethodInfo executionMethod = AccessTools.Method( + typeof(DefaultBoneGainOnDeath), nameof(DoDefaultBoneGain), + new Type[] { typeof(PlayableCard), typeof(CardSlot), typeof(int) }); + + i += 3; + codes[i] = new CodeInstruction(OpCodes.Ldloc_1); + i++; + + // since codes are taken from the top of the stack, we need to move the ldc.i4.1 to be AFTER we call slotBeforeDeath + codes.RemoveAt(i); + + i += 2; + + codes.Insert(i, new CodeInstruction(OpCodes.Ldc_I4_1)); + i++; + + codes[i] = new CodeInstruction(OpCodes.Callvirt, executionMethod); + break; + } + } + + codes.LogCodeInscryptions("after"); + return codes; + } + + public static bool ShouldDoDefaultBoneGain(PlayableCard card, CardSlot slotBeforeDeath) { + return slotBeforeDeath.IsPlayerSlot && !card.HasAbility(Ability.QuadrupleBones); + } + /// + /// A simple call to ResourcesManager.AddBones, intended to give modders some more flexibility over the default death behaviour of player cards giving 1 Bone. + /// + /// The PlayableCard that has died. + /// The CardSlot of card. + /// How many Bones to drop whenever a player's card dies (default is 1). + public static IEnumerator DoDefaultBoneGain(PlayableCard card, CardSlot slotBeforeDeath, int amount) { + yield return Singleton.Instance.AddBones(amount, slotBeforeDeath); + } + + public static CardInfo LogCardInfo(CardInfo info, string cardInfoName) + { + if (info == null) + InscryptionAPIPlugin.Logger.LogError("[CardLoader] Could not find CardInfo with name '" + cardInfoName + "'"); + + return info; + } +} diff --git a/InscryptionAPI/InscryptionAPIPlugin.cs b/InscryptionAPI/InscryptionAPIPlugin.cs index fc46d62d..03d3d72d 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.24.1"; + public const string ModVer = "2.24.2"; public static string Directory = ""; From 2736595c312d5c51888aad35403e513084c871d4 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:58:54 -0700 Subject: [PATCH 3/9] Remove debug logging --- InscryptionAPI/Card/DefaultBoneGainOnDeath.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs index 1e82976b..0f09db34 100644 --- a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs +++ b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs @@ -17,7 +17,7 @@ namespace InscryptionAPI.Card; [HarmonyPatch] public class DefaultBoneGainOnDeath { - [HarmonyTranspiler, ] + [HarmonyTranspiler] [HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.Die), MethodType.Enumerator)] private static IEnumerable InsertBoneMethodHook(IEnumerable instructions) { @@ -35,7 +35,6 @@ private static IEnumerable InsertBoneMethodHook(IEnumerable codes = new(instructions); - codes.LogCodeInscryptions(); for (int i = 0; i < codes.Count; i++) { // there are two instances where this is true, but we only care about the first instance @@ -115,7 +114,6 @@ private static IEnumerable InsertBoneMethodHook(IEnumerable Date: Thu, 29 Oct 2026 21:40:34 -0700 Subject: [PATCH 4/9] Remove erroneously copied-over method --- InscryptionAPI/Card/DefaultBoneGainOnDeath.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs index 0f09db34..b244f304 100644 --- a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs +++ b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs @@ -129,12 +129,4 @@ public static bool ShouldDoDefaultBoneGain(PlayableCard card, CardSlot slotBefor public static IEnumerator DoDefaultBoneGain(PlayableCard card, CardSlot slotBeforeDeath, int amount) { yield return Singleton.Instance.AddBones(amount, slotBeforeDeath); } - - public static CardInfo LogCardInfo(CardInfo info, string cardInfoName) - { - if (info == null) - InscryptionAPIPlugin.Logger.LogError("[CardLoader] Could not find CardInfo with name '" + cardInfoName + "'"); - - return info; - } } From 59846b9903f2732fefa7ab884e1b57714756ac47 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:40:44 -0700 Subject: [PATCH 5/9] Remove changelog to avoid merge conflict --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 079ce4d9..550c47d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -# 2.24.2 -- Added way to easily patch and modify the default bone gain when a player's card dies -- Added class `DefaultBoneGainOnDeath` and methods `DefaultBoneGainOnDeath.ShouldDoDefaultBoneGain` and `DefaultBoneGainOnDeeath.DoDefaultBoneGain` - # 2.24.1 - Added Extensions for setting the IconTexture of a Starter Deck. - Added 2 Alternate Constructors for making a StarterDeck with a Display Name different from its Internal Name. From 100d9b753f3286aced0ba1401a0797b7970e329d Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:40:51 -0700 Subject: [PATCH 6/9] Add XML documentation --- InscryptionAPI/Card/DefaultBoneGainOnDeath.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs index b244f304..e2369749 100644 --- a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs +++ b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs @@ -14,9 +14,14 @@ namespace InscryptionAPI.Card; +/// +/// Class for handling exposing the bone-on-death behaviour present in the vanilla PlayableCard.Die method. +/// Allows for modifying the default behaviour through Harmony patches. +/// [HarmonyPatch] public class DefaultBoneGainOnDeath { - + // this method does not need XML documentation since it's purely internal to make the other two methods work. + // I also don't want to explain how transpilers work. [HarmonyTranspiler] [HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.Die), MethodType.Enumerator)] private static IEnumerable InsertBoneMethodHook(IEnumerable instructions) @@ -117,6 +122,12 @@ private static IEnumerable InsertBoneMethodHook(IEnumerable + /// Simple boolean check that by default replicates the vanilla check for whether a card should award a Bone on death. + /// + /// The PlayableCard that has died. + /// The CardSlot of card. + /// True if card should give a Bone (calls DoDefaultBoneGain). public static bool ShouldDoDefaultBoneGain(PlayableCard card, CardSlot slotBeforeDeath) { return slotBeforeDeath.IsPlayerSlot && !card.HasAbility(Ability.QuadrupleBones); } From b511fdcde15ac3be1da144696856246baf40489f Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:41:13 -0700 Subject: [PATCH 7/9] Remove unneeded usings --- InscryptionAPI/Card/DefaultBoneGainOnDeath.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs index e2369749..fc40bb0b 100644 --- a/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs +++ b/InscryptionAPI/Card/DefaultBoneGainOnDeath.cs @@ -1,16 +1,8 @@ using DiskCardGame; -using GBC; using HarmonyLib; -using InscryptionAPI.Guid; -using InscryptionAPI.Helpers; -using InscryptionAPI.Saves; -using MonoMod.Cil; using System.Collections; -using System.Collections.ObjectModel; using System.Reflection; using System.Reflection.Emit; -using System.Runtime.CompilerServices; -using UnityEngine; namespace InscryptionAPI.Card; From f806ecd98a6e8746143b67040faf5d15e87d3634 Mon Sep 17 00:00:00 2001 From: WhistleWind <69230920+HumabHatterZed@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:47:21 -0700 Subject: [PATCH 8/9] (Hopefully) revert changes to csproj files in lieu of changes in #339 --- InscryptionAPI/InscryptionAPI.csproj | 13 ++++++------ .../InscryptionCommunityPatch.csproj | 21 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/InscryptionAPI/InscryptionAPI.csproj b/InscryptionAPI/InscryptionAPI.csproj index 6756c9ba..3f261c9d 100644 --- a/InscryptionAPI/InscryptionAPI.csproj +++ b/InscryptionAPI/InscryptionAPI.csproj @@ -10,7 +10,6 @@ full false true - false 2.24.1 @@ -22,7 +21,7 @@ - + @@ -36,9 +35,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + - + \ No newline at end of file diff --git a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj index 8404ec98..5559ff05 100644 --- a/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj +++ b/InscryptionCommunityPatch/InscryptionCommunityPatch.csproj @@ -9,14 +9,13 @@ true full false - false 2.24.0 $(NoWarn);AD0001;CS0612;CS8604;CS0252;CS0618;Harmony003;Publicizer001 - + @@ -26,14 +25,14 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + - + \ No newline at end of file From 8b31c7fb071fa2ba0912daf0597205ebafeea5fd Mon Sep 17 00:00:00 2001 From: Chaosyr Date: Fri, 30 Oct 2026 01:13:06 -0400 Subject: [PATCH 9/9] Update CHANGELOG.md Implement PR Changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54270347..238714d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - This comes with 5 new Dictionaries `BaseGameCustomAppearances` (Internal), `BaseGameCustomAppearancesPublic`, `ModdedCustomAppearancesDictionary` (Internal), `ModdedCustomAppearancesDictionaryPublic`, `CombinedCustomAppearancesDictionaryPublic`. - This system is stored under the `TextureHelper` class. * Improved In-Code Documentation via XML Comments. +* Added a way to easily patch and modify the default bone gain when a player's card dies. +* Added the following class: `DefaultBoneGainOnDeath` and the following methods within that class: `DefaultBoneGainOnDeath.ShouldDoDefaultBoneGain` and `DefaultBoneGainOnDeeath.DoDefaultBoneGain` # 2.24.1 - Added Extensions for setting the IconTexture of a Starter Deck. @@ -792,4 +794,4 @@ - Custom cards are added via the **CustomCard** constructor rather than through the **AddCard** method. # v1.1 -- Hooked into a much more sensible method to load the cards into the card pool. \ No newline at end of file +- Hooked into a much more sensible method to load the cards into the card pool.