@@ -22,10 +22,11 @@ private static bool DontPlaceCardModIcons_IfShowOnBottom(CardAbilityIcons __inst
2222 {
2323 // If we are showing card modifications sigils on the bottom, we don't allow the
2424 // AppyAbilitiesToIcons method to do anything
25- if ( iconMat == __instance . emissiveIconMat && PatchPlugin . configMergeOnBottom . Value && PatchPlugin . configRemovePatches . Value )
25+ if ( PatchPlugin . configMergeOnBottom . Value && PatchPlugin . configRemovePatches . Value && iconMat == __instance . emissiveIconMat )
2626 {
27- foreach ( var icon in icons )
27+ foreach ( AbilityIconInteractable icon in icons ) {
2828 icon . gameObject . SetActive ( false ) ;
29+ }
2930 return false ;
3031 }
3132
@@ -39,13 +40,11 @@ private static void MoveMergeIconsToDefaultGroup_IfShowOnBottom(List<Ability> de
3940 // This is the first time that the default abilities list is used once it has been built
4041 // What we want to do is take all of the abilities from the merge group and move them to the default group
4142 // if the "show merged icons on bottom" setting is active.
42-
43- if ( PatchPlugin . configMergeOnBottom . Value )
44- {
43+ if ( PatchPlugin . configMergeOnBottom . Value ) {
4544 defaultAbilities . AddRange ( mergeAbilities ) ;
46-
47- if ( PatchPlugin . configRemovePatches . Value )
45+ if ( PatchPlugin . configRemovePatches . Value ) {
4846 mergeAbilities . Clear ( ) ;
47+ }
4948 }
5049 }
5150
@@ -54,55 +53,43 @@ private static void MoveMergeIconsToDefaultGroup_IfShowOnBottom(List<Ability> de
5453 [ HarmonyPostfix ]
5554 private static void RepositionAndRetextureMergedIcons_IfShowOnBottom ( ref CardInfo info , ref AbilityInfo ability , ref AbilityIconInteractable __instance )
5655 {
57- if ( ! PatchPlugin . configMergeOnBottom . Value )
58- return ;
56+ if ( PatchPlugin . configMergeOnBottom . Value && info != null && info . Mods . Count > 0 ) {
57+ List < CardModificationInfo > MergeSigils = info . Mods . FindAll ( x => x . fromCardMerge ) ;
5958
60- if ( info != null )
61- {
62- if ( info . Mods . Count > 0 )
63- {
64- List < CardModificationInfo > MergeSigils = info . Mods . FindAll ( x => x . fromCardMerge ) ;
59+ if ( MergeSigils . Count > 0 ) {
60+ foreach ( CardModificationInfo mod in MergeSigils ) {
61+ // if ability whose icon we're loading came from a card merge mod
62+ if ( mod . abilities . Contains ( ability . ability ) && ( __instance . name == "AbilityIcon" || __instance . name == "DefaultIcons_1Ability" ) ) {
63+ if ( PatchPlugin . configRemovePatches . Value ) {
64+ __instance . SetMaterial ( Singleton < CardAbilityIcons > . Instance . totemIconMat ) ;
65+ if ( __instance . GetComponentInParent < MeshRenderer > ( ) != null )
66+ __instance . GetComponentInParent < MeshRenderer > ( ) . enabled = true ;
6567
66- if ( MergeSigils . Count > 0 )
67- {
68- foreach ( CardModificationInfo mod in MergeSigils )
69- {
70- if ( mod . abilities . Contains ( ability . ability ) && ( __instance . name == "AbilityIcon" || __instance . name == "DefaultIcons_1Ability" ) )
71- {
72- if ( PatchPlugin . configRemovePatches . Value )
73- {
74- __instance . SetMaterial ( Singleton < CardAbilityIcons > . Instance . totemIconMat ) ;
75- if ( __instance . GetComponentInParent < MeshRenderer > ( ) != null )
76- __instance . GetComponentInParent < MeshRenderer > ( ) . enabled = true ;
68+ __instance . SetColor ( Color . white ) ;
69+ return ;
70+ }
71+ int sigils = ( info . DefaultAbilities . Count + MergeSigils . Count ) ;
72+ if ( sigils <= 8 ) {
73+ //Plugin.Log.LogInfo(sigils + " " + ability.ToString() + " " + info.name);
7774
78- __instance . SetColor ( Color . white ) ;
79- return ;
75+ Transform [ ] allChildren ;
76+ //Plugin.Log.LogInfo(__instance.name);
77+ if ( __instance . name == "DefaultIcons_1Ability" ) {
78+ allChildren = __instance . transform . parent . GetComponentsInChildren < Transform > ( ) ;
8079 }
81- int sigils = ( info . DefaultAbilities . Count + MergeSigils . Count ) ;
82- if ( sigils <= 8 )
83- {
84- //Plugin.Log.LogInfo(sigils + " " + ability.ToString() + " " + info.name);
85-
86- Transform [ ] allChildren = __instance . transform . parent . transform . parent . GetComponentsInChildren < Transform > ( ) ;
87- //Plugin.Log.LogInfo(__instance.name);
88- if ( __instance . name == "DefaultIcons_1Ability" )
89- allChildren = __instance . transform . parent . GetComponentsInChildren < Transform > ( ) ;
80+ else {
81+ allChildren = __instance . transform . parent . transform . parent . GetComponentsInChildren < Transform > ( ) ;
82+ }
9083
91- foreach ( Transform child in allChildren )
92- {
93- if ( child . gameObject . activeSelf && child . gameObject . name . StartsWith ( "CardMergeIcon_" ) )
94- {
95- if ( child . gameObject . GetComponent < AbilityIconInteractable > ( ) . Ability == __instance . Ability )
96- {
97- child . gameObject . transform . localPosition = __instance . transform . localPosition ;
98- child . gameObject . transform . localScale = __instance . transform . localScale ;
99- }
100- }
84+ foreach ( Transform child in allChildren ) {
85+ if ( child . gameObject . activeSelf && child . gameObject . name . StartsWith ( "CardMergeIcon_" ) &&
86+ child . gameObject . GetComponent < AbilityIconInteractable > ( ) . Ability == __instance . Ability ) {
87+ child . gameObject . transform . localPosition = __instance . transform . localPosition ;
88+ child . gameObject . transform . localScale = __instance . transform . localScale ;
10189 }
10290 }
10391 }
10492 }
105- return ;
10693 }
10794 }
10895 }
0 commit comments