public static void DoDepositAll(Player player) { //this shouldn't happen if method is called correctly if (player.chest == -1) { return; } bool sendNetMsg = player.chest > -1; if (IHPlayer.ActionLocked(TIH.DepositAll)) { for (int i = R_START; i >= R_END; i--) { if (IHPlayer.SlotLocked(i) || player.inventory[i].IsBlank()) { continue; } MoveItemToChest(i, sendNetMsg); } Recipe.FindRecipes(); // !ref:Main:#22640.36# return; } for (int i = R_START; i >= R_END; i--) { if (!player.inventory[i].IsBlank()) { MoveItemToChest(i, sendNetMsg); } } Recipe.FindRecipes(); // !ref:Main:#22640.36# } //\DoDepositAll()
private void OnWorldLoad() { isLocked = IHPlayer.ActionLocked(Client.Action); if (isLocked) { Client.Hooks.PostDraw += PostDraw; // draw lock indicator // Client.Label = lockedLabel; } else { // List<>.Remove() doesn't fail on missing keys, // so this is safe Client.Hooks.PostDraw -= PostDraw; // Client.Label = initialLabel; } }
public static void DoQuickStack(Player player) { if (player.chest == -1) { return; } var inventory = player.inventory; var container = player.chestItems; bool sendMessage = player.chest > -1; var checkLocks = IHPlayer.ActionLocked(TIH.QuickStack); //boolean for (int iC = 0; iC < Chest.maxItems; iC++) // go through entire chest inventory. { //if chest item is not blank && not a full stack, then if (!container[iC].IsBlank() && container[iC].stack < container[iC].maxStack) { //for each item in inventory (including coins, ammo, hotbar), for (int iP = 0; iP < 58; iP++) { if (checkLocks && IHPlayer.SlotLocked(iP)) { continue; // if we're checking locks ignore the locked ones } if (container[iC].IsTheSameAs(inventory[iP])) //if chest item matches inv. item... { // RingBell(); //...play "item-moved" sound and... Sound.ItemMoved.Play(); // ...merge inv. item stack to chest item stack if (StackMerge(ref inventory[iP], container, iC)) { // do merge & check return (inv stack empty) status inventory[iP] = new Item(); // reset slot if all inv stack moved } else if (container[iC].IsBlank()) { // else, inv stack not empty after merge, but (because of DoCoins() call), // chest stack could be. container[iC] = inventory[iP].Clone(); // move inv item to chest slot inventory[iP] = new Item(); // and reset inv slot } // if (sendMessage) SendNetMessage(iC); //send net message if regular chest } } } } Recipe.FindRecipes(); // !ref:Main:#22640.36# }
private bool PreDraw(SpriteBatch sb) { // don't run unless there's a change to avoid adding/removing // the event every frame if (IHPlayer.ActionLocked(Client.Action) != isLocked) { isLocked = !isLocked; if (isLocked) { Client.Hooks.PostDraw += PostDraw; // Client.Label = lockedLabel; } else { Client.Hooks.PostDraw -= PostDraw; // Client.Label = initialLabel; } } return(true); }