Skip to content

Commit 1c82ac2

Browse files
committed
1.3.7 release
1 parent 9b59f06 commit 1c82ac2

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

Diff for: kg_LastEpoch_Improvements/kg_LastEpoch_Improvements.cs

+41-40
Original file line numberDiff line numberDiff line change
@@ -154,51 +154,52 @@ private static bool ShouldShow(Rule rule)
154154
if (!rule.isEnabled || rule.type is Rule.RuleOutcome.HIDE) return false;
155155
return rule.emphasized || ShowAll.Value;
156156
}
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)
159158
{
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+
}
160196
ItemFilter filter = ItemFilterManager.Instance.Filter;
161197
if (filter == null) return;
162198
foreach (Rule rule in filter.rules)
163199
{
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;
202203
}
203204
}
204205
}

0 commit comments

Comments
 (0)