示例#1
0
        private void PressSlotZone(UIEvent e, UIElement element)
        {
            int  slot    = slotZone.MouseSlot();
            bool changed = false;

            if (!Main.mouseItem.IsAir)
            {
                changed = TryDeposit(Main.mouseItem);
            }
            else if (slot >= 0 && slot < items.Count && !items[slot].IsAir)
            {
                Item item = items[slot].Clone();

                if (item.stack > item.maxStack)
                {
                    item.stack = item.maxStack;
                }

                Main.mouseItem = DoWithdraw(item, ItemSlot.ShiftInUse);

                if (ItemSlot.ShiftInUse)
                {
                    Main.mouseItem = Main.LocalPlayer.GetItem(Main.myPlayer, Main.mouseItem, false, true);
                }

                changed = true;
            }

            if (changed)
            {
                RefreshItems();
                Main.PlaySound(7, -1, -1, 1);
            }
        }
示例#2
0
        private void PressStation(UIEvent _event, UIElement _element)
        {
            int slot = stationZone.MouseSlot();

            if (slot < 0 || slot >= access.stations.Length || (!ItemSlot.ShiftInUse && Main.mouseItem.IsAir && access.stations[slot].IsAir))
            {
                return;
            }

            Player player = Main.LocalPlayer;

            if (ItemSlot.ShiftInUse)
            {
                Item station = player.GetItem(Main.myPlayer, WithdrawStation(slot), false, true);
                if (!station.IsAir)
                {
                    player.QuickSpawnClonedItem(station);
                }
            }
            else if (Main.mouseItem.IsTheSameAs(access.stations[slot]) && Main.mouseItem.stack < Main.mouseItem.maxStack)
            {
                WithdrawStation(slot);
                Main.mouseItem.stack += 1;
            }
            else
            {
                Main.mouseItem = SwapStations(Main.mouseItem, slot);
            }

            RefreshStations();
            RefreshRecipes();

            Main.PlaySound(7, -1, -1, 1);
        }
示例#3
0
        private void PressRecipe(UIEvent _event, UIElement _element)
        {
            int slot = recipeZone.MouseSlot();

            if (slot >= 0 && slot < recipes.Count())
            {
                Recipe recipe = recipes[slot];
                if (!recipe.createItem.IsAir)
                {
                    SelectRecipe(recipe);
                    Main.PlaySound(12, -1, -1, 1);
                }
            }
        }
示例#4
0
        private void PressIngredient(UIEvent _event, UIElement _element)
        {
            if (selectedRecipe == null)
            {
                return;
            }

            int slot = ingredientZone.MouseSlot();

            if (slot >= 0 && slot < selectedRecipe.requiredItem.Length)
            {
                Item ingredient = selectedRecipe.requiredItem[slot];
                foreach (Recipe recipe in Main.recipe)
                {
                    if (recipe.createItem.IsTheSameAs(ingredient))
                    {
                        SelectRecipe(recipe);
                        return;
                    }
                }
            }
        }
示例#5
0
        private void PressResult(UIEvent _event, UIElement _element)
        {
            if (selectedRecipe == null || Main.mouseItem.IsAir && resultItem.IsAir || resultZone.MouseSlot() != 0)
            {
                return;
            }

            if (!Main.mouseItem.IsAir && selectedRecipe.createItem.IsTheSameAs(Main.mouseItem))
            {
                TryDepositResult(Main.mouseItem);
            }
            else if (Main.mouseItem.IsAir && !resultItem.IsAir)
            {
                Item withdraw = resultItem.Clone();
                if (withdraw.stack > withdraw.maxStack)
                {
                    withdraw.stack = withdraw.maxStack;
                }

                Main.mouseItem = WithdrawItem(withdraw);

                if (ItemSlot.ShiftInUse)
                {
                    Main.mouseItem = Main.LocalPlayer.GetItem(Main.myPlayer, Main.mouseItem, false, true);
                }
            }

            Refresh();

            Main.PlaySound(7, -1, -1, 1);
        }