@@ -23,10 +23,9 @@ public static class ShieldManager
2323 public static List < FullAbility > AllShieldAbilities { get ; internal set ; } = new ( AllAbilities ) ;
2424 public static List < AbilityInfo > AllShieldInfos { get ; internal set ; } = AllShieldAbilities . Select ( x => x . Info ) . ToList ( ) ;
2525
26-
2726 public static IEnumerator TriggerBreakShield ( PlayableCard target , int damage , PlayableCard attacker )
2827 {
29- InscryptionAPIPlugin . Logger . LogDebug ( "[TriggerBreakShield] Begin" ) ;
28+ // InscryptionAPIPlugin.Logger.LogDebug("[TriggerBreakShield] Begin");
3029 BreakShield ( target , damage , attacker ) ;
3130
3231 List < IShieldPreventedDamage > shieldTriggers = CustomTriggerFinder . FindTriggersOnBoard < IShieldPreventedDamage > ( false ) . ToList ( ) ;
@@ -57,11 +56,11 @@ public static void BreakShield(PlayableCard target, int damage, PlayableCard att
5756 DamageShieldBehaviour shield = Array . Find ( target . GetComponents < DamageShieldBehaviour > ( ) , x => x . HasShields ( ) ) ;
5857 if ( shield != null )
5958 {
60- InscryptionAPIPlugin . Logger . LogDebug ( "[BreakShield] Found DamageShieldBehaviour" ) ;
59+ // InscryptionAPIPlugin.Logger.LogDebug("[BreakShield] Found DamageShieldBehaviour");
6160 CardModificationInfo info = target . TemporaryMods . Find ( x => x . abilities != null && x . abilities . Contains ( shield . Ability ) ) ;
6261 if ( info != null )
6362 {
64- InscryptionAPIPlugin . Logger . LogDebug ( "[BreakShield] CardModInfo found for behaviour" ) ;
63+ // InscryptionAPIPlugin.Logger.LogDebug("[BreakShield] CardModInfo found for behaviour");
6564 target . RemoveTemporaryMod ( info , false ) ; // RemoveShields is called here in a patch
6665 info . abilities . Remove ( shield . Ability ) ;
6766 target . AddTemporaryMod ( info ) ;
@@ -74,7 +73,7 @@ public static void BreakShield(PlayableCard target, int damage, PlayableCard att
7473 target . Anim . StrongNegationEffect ( ) ;
7574 if ( target . GetTotalShields ( ) == 0 ) // if we removed the last shield
7675 {
77- InscryptionAPIPlugin . Logger . LogDebug ( "[BreakShield] TotalShields == 0" ) ;
76+ // InscryptionAPIPlugin.Logger.LogDebug("[BreakShield] TotalShields == 0");
7877 target . Status . lostShield = true ;
7978 if ( target . Info . HasBrokenShieldPortrait ( ) )
8079 target . SwitchToPortrait ( target . Info . BrokenShieldPortrait ( ) ) ;
@@ -89,76 +88,37 @@ private static void PreventShieldReset(Latch __instance, ref bool __result, Play
8988 if ( __instance is LatchDeathShield && card . HasShield ( ) )
9089 __result = true ;
9190 }
91+
9292 [ HarmonyPrefix , HarmonyPatch ( typeof ( LatchDeathShield ) , nameof ( LatchDeathShield . OnSuccessfullyLatched ) ) ]
9393 private static bool PreventShieldReset ( PlayableCard target )
9494 {
95- target . UpdateFaceUpOnBoardEffects ( ) ;
96- return false ; // latch death shield doesn't reset shields
95+ target . UpdateFaceUpOnBoardEffects ( ) ; // latch death shield doesn't reset shields
96+ return false ;
9797 }
9898
9999 /// <summary>
100- /// The new version of PlayableCard.HasShield implementing the new shield logic .
100+ /// Modified version of PlayableCard.HasShield that replaces the original method's result .
101101 /// </summary>
102102 public static bool NewHasShield ( PlayableCard instance )
103103 {
104104 return instance . GetTotalShields ( ) > 0 && ! instance . Status . lostShield ;
105105 }
106106
107107 [ HarmonyPostfix , HarmonyPatch ( typeof ( PlayableCard ) , nameof ( PlayableCard . HasShield ) ) ]
108- private static void ReplaceHasShieldBool ( PlayableCard __instance , ref bool __result ) => __result = NewHasShield ( __instance ) ;
108+ private static void ReplaceHasShieldBool ( PlayableCard __instance , ref bool __result )
109+ {
110+ __result = NewHasShield ( __instance ) ;
111+ }
109112
110113 [ HarmonyPrefix , HarmonyPatch ( typeof ( PlayableCard ) , nameof ( PlayableCard . ResetShield ) , new Type [ ] { } ) ]
111114 private static void ResetModShields ( PlayableCard __instance ) // runs before the base ResetShield logic
112115 {
113116 foreach ( DamageShieldBehaviour com in __instance . GetComponents < DamageShieldBehaviour > ( ) )
114117 com . ResetShields ( false ) ;
115118
116- // if we're using the broken shield portrait, reset to the default portrait - if we're MudTurtle
119+ // if we're using the broken shield portrait, reset to the default portrait
117120 if ( __instance . Info . name == "MudTurtle" || ( __instance . Info . BrokenShieldPortrait ( ) != null && __instance . RenderInfo . portraitOverride == __instance . Info . BrokenShieldPortrait ( ) ) )
118121 __instance . SwitchToDefaultPortrait ( ) ;
119-
120- __instance . Status . lostShield = false ;
121- }
122-
123- [ HarmonyTranspiler , HarmonyPatch ( typeof ( ShieldGeneratorItem ) , nameof ( ShieldGeneratorItem . ActivateSequence ) , MethodType . Enumerator ) ]
124- private static IEnumerable < CodeInstruction > DontResetOnActivate ( IEnumerable < CodeInstruction > instructions )
125- {
126- List < CodeInstruction > codes = new ( instructions ) ;
127- int index = codes . FindIndex ( x => x . operand ? . ToString ( ) == "DiskCardGame.BoardManager get_Instance()" ) ;
128- if ( index > 0 )
129- {
130- MethodBase method = AccessTools . Method ( typeof ( ShieldManager ) , nameof ( ShieldManager . EmptyList ) ) ;
131- codes . RemoveRange ( index , 2 ) ;
132- codes . Insert ( index , new ( OpCodes . Callvirt , method ) ) ;
133- }
134- return codes ;
135- }
136- [ HarmonyTranspiler , HarmonyPatch ( typeof ( ShieldGems ) , nameof ( ShieldGems . OnResolveOnBoard ) , MethodType . Enumerator ) ]
137- private static IEnumerable < CodeInstruction > DontResetOnResolve ( IEnumerable < CodeInstruction > instructions )
138- {
139- List < CodeInstruction > codes = new ( instructions ) ;
140- int index = codes . FindLastIndex ( x => x . operand ? . ToString ( ) == "0.25" ) - 4 ;
141- if ( index > 0 )
142- {
143- MethodBase method = AccessTools . Method ( typeof ( ShieldManager ) , nameof ( ShieldManager . EmptyList ) ) ;
144- codes . RemoveRange ( index , 2 ) ;
145- codes . Insert ( index , new ( OpCodes . Callvirt , method ) ) ;
146- }
147- return codes ;
148- }
149-
150- [ HarmonyTranspiler , HarmonyPatch ( typeof ( RandomCardGainsShieldEffect ) , nameof ( RandomCardGainsShieldEffect . Execute ) , MethodType . Enumerator ) ]
151- private static IEnumerable < CodeInstruction > DontResetOnExecute ( IEnumerable < CodeInstruction > instructions )
152- {
153- List < CodeInstruction > codes = new ( instructions ) ;
154- int index = codes . FindLastIndex ( x => x . opcode == OpCodes . Newobj ) ;
155- if ( index > 0 )
156- {
157- MethodBase method = AccessTools . Method ( typeof ( ShieldManager ) , nameof ( ShieldManager . EmptyList ) ) ;
158- codes . RemoveRange ( index , 4 ) ;
159- codes . Insert ( index , new ( OpCodes . Callvirt , method ) ) ;
160- }
161- return codes ;
162122 }
163123
164124 [ HarmonyTranspiler , HarmonyPatch ( typeof ( PlayableCard ) , nameof ( PlayableCard . UpdateFaceUpOnBoardEffects ) ) ]
@@ -216,7 +176,7 @@ private static IEnumerable<CodeInstruction> RemoveSingleHiddenStacks(IEnumerable
216176 return codes ;
217177 }
218178
219- private static List < CardSlot > EmptyList ( ) => new ( ) ; // for transpiler logic (why can't i just pass an empty list?)
179+ private static List < CardSlot > EmptyList ( ) => new ( ) ; // for transpiler logic
220180
221181 private static List < Ability > HiddensOnlyRemoveStacks ( List < Ability > abilities , List < Ability > hiddenAbilities )
222182 {
@@ -229,48 +189,42 @@ private static List<Ability> HiddensOnlyRemoveStacks(List<Ability> abilities, Li
229189 }
230190 private static void CorrectHiddenAbilityRender ( PlayableCard card )
231191 {
232- foreach ( DamageShieldBehaviour com in card . GetComponents < DamageShieldBehaviour > ( ) . Where ( x => x . initialised ) )
233- {
234- if ( com . HasShields ( ) )
235- {
236- if ( com . Ability . GetHideSingleStacks ( ) )
237- {
238- // if there are more hidden shields than there should be
239- if ( card . Status . hiddenAbilities . Count ( x => x == com . Ability ) >= com . NumShields )
240- {
241- for ( int i = 0 ; i < com . NumShields ; i ++ )
242- {
243- card . Status . hiddenAbilities . Remove ( com . Ability ) ;
244- }
245- }
246- }
247- else
248- {
249- card . Status . hiddenAbilities . Remove ( com . Ability ) ;
250- }
251- break ;
252- }
253- else
254- {
255- if ( com . Ability . GetHideSingleStacks ( ) )
256- {
257- int shieldsLost = com . StartingNumShields - com . NumShields ;
258- if ( card . Status . hiddenAbilities . Count ( x => x == com . Ability ) < shieldsLost )
259- {
260- for ( int i = 0 ; i < shieldsLost ; i ++ )
261- {
262- //Debug.Log($"{com.StartingNumShields} {com.NumShields} {shieldsLost} Add hidden");
263- card . Status . hiddenAbilities . Add ( com . Ability ) ;
264- }
265- }
266- }
267- else if ( ! card . Status . hiddenAbilities . Contains ( com . Ability ) )
268- {
269- card . Status . hiddenAbilities . Add ( com . Ability ) ;
270- }
271- break ;
272- }
273- }
192+ //foreach (DamageShieldBehaviour com in card.GetComponents<DamageShieldBehaviour>().Where(x => x.initialised))
193+ //{
194+ // if (com.HasShields())
195+ // {
196+ // if (com.Ability.GetHideSingleStacks())
197+ // {
198+ // // if there are more hidden shields than there should be
199+ // while (card.Status.hiddenAbilities.Count(x => x == com.Ability) > com.NumShields)
200+ // {
201+ // card.Status.hiddenAbilities.Remove(com.Ability);
202+ // }
203+ // }
204+ // else
205+ // {
206+ // card.Status.hiddenAbilities.RemoveAll(x => x == com.Ability);
207+ // }
208+ // break;
209+ // }
210+ // else
211+ // {
212+ // if (com.Ability.GetHideSingleStacks())
213+ // {
214+ // int shieldsLost = com.StartingNumShields - com.NumShields;
215+ // while (card.Status.hiddenAbilities.Count(x => x == com.Ability) < shieldsLost)
216+ // {
217+ // //Debug.Log($"{com.StartingNumShields} {com.NumShields} {shieldsLost} Add hidden");
218+ // card.Status.hiddenAbilities.Add(com.Ability);
219+ // }
220+ // }
221+ // else if (!card.Status.hiddenAbilities.Contains(com.Ability))
222+ // {
223+ // card.Status.hiddenAbilities.Add(com.Ability);
224+ // }
225+ // break;
226+ // }
227+ //}
274228
275229 if ( card . Info . HasBrokenShieldPortrait ( ) && card . RenderInfo . portraitOverride == card . Info . BrokenShieldPortrait ( ) && card . HasShield ( ) )
276230 {
0 commit comments