@@ -154,51 +154,52 @@ private static bool ShouldShow(Rule rule)
154
154
if ( ! rule . isEnabled || rule . type is Rule . RuleOutcome . HIDE ) return false ;
155
155
return rule . emphasized || ShowAll . Value ;
156
156
}
157
-
158
- private static void Prefix ( GroundItemVisuals __instance , ItemDataUnpacked itemData , GroundItemLabel label , GroundItemRarityVisuals groundItemRarityVisuals )
157
+ private static void ShowOnMap ( GroundItemVisuals visuals , Rule rule , ItemDataUnpacked itemData , GroundItemLabel label , GroundItemRarityVisuals groundItemRarityVisuals )
159
158
{
159
+ if ( rule != null && CustomDropSounds . RuleHasCustomSound ( rule , out string sName ) )
160
+ {
161
+ PlayOneShotSound oneShotComp = groundItemRarityVisuals ? . GetComponent < PlayOneShotSound > ( ) ;
162
+ bool customSound = CustomDropSounds . TryPlaySoundDelayed ( sName , oneShotComp ? . delayDuration ?? 0f , 1f ) ;
163
+ if ( oneShotComp && customSound ) oneShotComp . StopAllCoroutines ( ) ;
164
+ }
165
+ GameObject customMapIcon = Object . Instantiate ( CustomMapIcon , DMMap . Instance . iconContainer . transform ) ;
166
+ customMapIcon . SetActive ( true ) ;
167
+ customMapIcon . GetComponent < CustomIconProcessor > ( ) . Init ( visuals . gameObject , label ) ;
168
+ string path = ItemList . instance . GetBaseTypeName ( itemData . itemType ) . Replace ( " " , "_" ) . ToLower ( ) ;
169
+ string itemName = itemData . BaseNameForTooltipSprite ;
170
+ if ( itemData . isUniqueSetOrLegendary ( ) )
171
+ {
172
+ customMapIcon . GetComponent < CustomIconProcessor > ( ) . ShowLegendaryPotential ( itemData . legendaryPotential , itemData . weaversWill ) ;
173
+ if ( UniqueList . instance . uniques . Count > itemData . uniqueID && UniqueList . instance . uniques . get ( itemData . uniqueID ) is { } entry )
174
+ {
175
+ path = "uniques" ;
176
+ itemName = entry . name . Replace ( " " , "_" ) ;
177
+ }
178
+ }
179
+ string fullPath = $ "gear/{ path } /{ itemName } ";
180
+ if ( ! IconCache . TryGetValue ( fullPath , out var icon ) || ! icon )
181
+ {
182
+ icon = Resources . Load < Sprite > ( fullPath ) ;
183
+ IconCache [ fullPath ] = icon ;
184
+ }
185
+ customMapIcon . GetComponent < Image > ( ) . sprite = ItemList . instance . defaultItemBackgroundSprite ;
186
+ customMapIcon . GetComponent < Image > ( ) . color = GetColorForItemRarity ( itemData ) ;
187
+ customMapIcon . transform . GetChild ( 0 ) . GetComponent < Image > ( ) . sprite = icon ;
188
+ }
189
+ private static void Prefix ( GroundItemVisuals __instance , ItemDataUnpacked itemData , GroundItemLabel label , GroundItemRarityVisuals groundItemRarityVisuals )
190
+ {
191
+ if ( itemData . rarity == 9 )
192
+ {
193
+ ShowOnMap ( __instance , null , itemData , label , groundItemRarityVisuals ) ;
194
+ return ;
195
+ }
160
196
ItemFilter filter = ItemFilterManager . Instance . Filter ;
161
197
if ( filter == null ) return ;
162
198
foreach ( Rule rule in filter . rules )
163
199
{
164
- if ( ! ShouldShow ( rule ) ) continue ;
165
-
166
- if ( rule . Match ( itemData ) || itemData . rarity == 9 )
167
- {
168
- if ( CustomDropSounds . RuleHasCustomSound ( rule , out string sName ) )
169
- {
170
- PlayOneShotSound oneShotComp = groundItemRarityVisuals ? . GetComponent < PlayOneShotSound > ( ) ;
171
- bool customSound = CustomDropSounds . TryPlaySoundDelayed ( sName , oneShotComp ? . delayDuration ?? 0f , 1f ) ;
172
- if ( oneShotComp && customSound ) oneShotComp . StopAllCoroutines ( ) ;
173
- }
174
-
175
- GameObject customMapIcon = Object . Instantiate ( CustomMapIcon , DMMap . Instance . iconContainer . transform ) ;
176
- customMapIcon . SetActive ( true ) ;
177
- customMapIcon . GetComponent < CustomIconProcessor > ( ) . Init ( __instance . gameObject , label ) ;
178
- string path = ItemList . instance . GetBaseTypeName ( itemData . itemType ) . Replace ( " " , "_" ) . ToLower ( ) ;
179
- string itemName = itemData . BaseNameForTooltipSprite ;
180
- if ( itemData . isUniqueSetOrLegendary ( ) )
181
- {
182
- customMapIcon . GetComponent < CustomIconProcessor > ( ) . ShowLegendaryPotential ( itemData . legendaryPotential , itemData . weaversWill ) ;
183
- if ( UniqueList . instance . uniques . Count > itemData . uniqueID && UniqueList . instance . uniques . get ( itemData . uniqueID ) is { } entry )
184
- {
185
- path = "uniques" ;
186
- itemName = entry . name . Replace ( " " , "_" ) ;
187
- }
188
- }
189
- string fullPath = $ "gear/{ path } /{ itemName } ";
190
- if ( ! IconCache . TryGetValue ( fullPath , out var icon ) )
191
- {
192
- MelonLogger . Msg ( $ "Couldn't find icon for { itemName } ({ path } ), loading from resources") ;
193
- icon = Resources . Load < Sprite > ( fullPath ) ;
194
- IconCache [ fullPath ] = icon ;
195
- } else MelonLogger . Msg ( $ "Found icon for { itemName } ({ path } ) in cache") ;
196
- customMapIcon . GetComponent < Image > ( ) . sprite = ItemList . instance . defaultItemBackgroundSprite ;
197
- customMapIcon . GetComponent < Image > ( ) . color = GetColorForItemRarity ( itemData ) ;
198
- customMapIcon . transform . GetChild ( 0 ) . GetComponent < Image > ( ) . sprite = icon ;
199
-
200
- return ;
201
- }
200
+ if ( ! ShouldShow ( rule ) || ! rule . Match ( itemData ) ) continue ;
201
+ ShowOnMap ( __instance , rule , itemData , label , groundItemRarityVisuals ) ;
202
+ return ;
202
203
}
203
204
}
204
205
}
0 commit comments