示例#1
0
 /// performs the most appropriate clean action
 public static void CleanStacks()
 {
     if (Main.localPlayer.chest == -1)
     {
         IHOrganizer.ConsolidateStacks(Main.localPlayer.inventory, 0, 50);
     }
     else
     {
         DoChestUpdateAction(
             () => IHOrganizer.ConsolidateStacks(Main.localPlayer.chestItems));
     }
 }
示例#2
0
 /// performs the most appropriate sort action
 public static void Sort(bool reverse = false)
 {
     // NOTE: this used to check player.chestItems==null, but I once got a
     // "object reference not set to instance of object" or whatever kind of error
     // with that check elsewhere in the code. This should be safer and have the exact same result.
     if (Main.localPlayer.chest == -1)   // no valid chest open, sort player inventory
     // shift-pressed XOR Reverse-sort-mod-option:
     //   this will reverse the sort IFF exactly one of these two bools is true
     {
         IHOrganizer.SortPlayerInv(Main.localPlayer,
                                   reverse ^ IHBase.ModOptions["ReverseSortPlayer"]);
     }
     else
     {
         // call sort on the Item[] array returned by chestItems
         DoChestUpdateAction(() =>
                             IHOrganizer.SortChest(Main.localPlayer.chestItems,
                                                   reverse ^ IHBase.ModOptions["ReverseSortChest"])
                             );
     }
 }