Improve sorting

This commit is contained in:
MSWS
2024-09-18 14:21:54 -07:00
parent 536d8694aa
commit b8a606d5b2

View File

@@ -17,17 +17,18 @@ public class BombIconMenu(IServiceProvider provider, BombPerkData data)
private int CompareBombIcons(BombIcon a, BombIcon b) {
// If the icon is equipped, it should be first
if (a == data.Equipped) return -1;
if (b == data.Equipped) return 1;
// If icon is unlocked, it should be next
// If both are unlocked, sort by cost (highest first)
if (a == data.Unlocked) {
if (b == data.Equipped) return 1;
return b == data.Unlocked ? a.GetCost().CompareTo(b.GetCost()) : -1;
if (data.Unlocked.HasFlag(a)) {
if (data.Unlocked.HasFlag(b)) return a.GetCost().CompareTo(b.GetCost());
return -1;
}
// If both are locked, sort by cost (lowest first)
if (b == data.Equipped) return 1;
return b == data.Unlocked ? 1 : a.GetCost().CompareTo(b.GetCost());
if (data.Unlocked.HasFlag(b)) return 1;
return a.GetCost().CompareTo(b.GetCost());
}
override protected Task<List<BombIcon>> GetItems(PlayerWrapper player) {