Beispiel #1
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            base.ProcessTriggers(triggersSet);

            if (DepositAll.JustPressed)
            {
                ChestUI.DepositAll();
            }
            if (LootAll.JustPressed)
            {
                ChestUI.LootAll();
            }
            if (QuickStack.JustPressed)
            {
                player.QuickStackAllChests();
                ChestUI.QuickStack();
            }
            if (Restock.JustPressed)
            {
                ChestUI.Restock();
            }
            if (SortChest.JustPressed)
            {
                ItemSorting.SortChest();
            }
            if (SortInventory.JustPressed)
            {
                ItemSorting.SortInventory();
            }
        }
Beispiel #2
0
        private static void OpenLootConfirmation()
        {
            var ui = new ConfirmationUI
            {
                buttonID  = ChestUI.ButtonID.LootAll,
                topOffset = 30,
                onclick   = (evt, elm) =>
                {
                    ChestUI.LootAll();
                    ConfirmationUI.visible = false;
                }
            };

            BetterChests.instance.ConfirmationUserInterface.SetState(ui);
            ConfirmationUI.visible = true;
        }
Beispiel #3
0
        private int slot      = 1;    //inventory row #. 1-4.

        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            if (PressF11.SwitchSlots.JustPressed && player.whoAmI == Main.myPlayer)
            {
                //inventory row swap with #0 and #slot
                for (int i = 0; i < 10; i++)
                {
                    Item tmp = player.inventory[slot * 10 + i];
                    player.inventory[slot * 10 + i] = player.inventory[i];
                    player.inventory[i]             = tmp;
                    Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(i), (float)Main.player[Main.myPlayer].inventory[i].prefix, 0f, 0, 0, 0);
                        NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(slot * 10 + i), (float)Main.player[Main.myPlayer].inventory[slot * 10 + i].prefix, 0f, 0, 0, 0);
                    }
                }
                slot++;
                if (slot > 4)
                {
                    slot = 1;
                }
            }
            if (PressF11.SwapVertical.JustPressed && player.whoAmI == Main.myPlayer)
            {
                //swap with selected item and next row item(same column. 0 and 10, 1 and 11, ... , 9 and 19)
                Item tmp = player.inventory[player.selectedItem];
                player.inventory[player.selectedItem]      = player.inventory[player.selectedItem + 10];
                player.inventory[player.selectedItem + 10] = tmp;
                Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem), (float)Main.player[Main.myPlayer].inventory[player.selectedItem].prefix, 0f, 0, 0, 0);
                    NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem + 10), (float)Main.player[Main.myPlayer].inventory[player.selectedItem + 10].prefix, 0f, 0, 0, 0);
                }
            }
            if (PressF11.SwapHorizontal.JustPressed && player.whoAmI == Main.myPlayer)
            {
                //swap with selected item and next column item(0 and 1, 1 and 2, ... , 9 and 0)
                Item tmp = player.inventory[player.selectedItem];
                player.inventory[player.selectedItem]            = player.inventory[(player.selectedItem + 1) % 10];
                player.inventory[(player.selectedItem + 1) % 10] = tmp;
                Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)(player.selectedItem), (float)Main.player[Main.myPlayer].inventory[player.selectedItem].prefix, 0f, 0, 0, 0);
                    NetMessage.SendData(5, -1, -1, null, Main.myPlayer, (float)((player.selectedItem + 1) % 10), (float)Main.player[Main.myPlayer].inventory[(player.selectedItem + 1) % 10].prefix, 0f, 0, 0, 0);
                }
            }
            if (PressF11.LootAll.JustPressed && player.whoAmI == Main.myPlayer)
            {
                if (player.chest != -1)
                {
                    ChestUI.LootAll();
                }
            }
            //random craft
            if (PressF11.CraftRandom.JustPressed && player.whoAmI == Main.myPlayer)
            {
                Recipe.FindRecipes();
                if (Main.numAvailableRecipes >= 1)
                {
                    Main.focusRecipe = Main.rand.Next(Main.numAvailableRecipes);
                    Recipe r = Main.recipe[Main.availableRecipe[Main.focusRecipe]];
                    r.Create();
                    Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                    Item.NewItem(player.position + player.Size / 2, r.createItem.type, r.createItem.stack, false, r.createItem.prefix, true);
                }
            }
        }