Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions SimpleSort/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,19 @@ private static void SortByType(SortType type, Inventory inventory, bool asc, boo
{
int amount = Mathf.Min(items[i].m_shared.m_maxStackSize - items[i].m_stack, items[i + 1].m_stack);
items[i].m_stack += amount;
if (amount == items[i + 1].m_stack)
{
items.RemoveAt(i + 1);
}
else
if (amount == items[i + 1].m_stack) {
items[i + 1].m_stack -= amount;
items.RemoveAt(i+1);

// Dummy call, only using it to remove all items from inventory where stack size <= 0
// This needs to be done because the reference to the original items list gets broken somehow when using EquipmentAndQuickSlots mod
Traverse.Create(inventory).Method("RemoveItem", new object[]{"", 0}).GetValue();
} else {
items[i + 1].m_stack -= amount;
}
}
}

switch (type)
{
case SortType.Name:
Expand Down