コード例 #1
0
        public static void DrawItemInPipe(ItemNetworkPath path, SpriteBatch spriteBatch)
        {
            //We need to emulate drawing items in the world, but shrinked into the bounds of a pipe
            Item item = ItemIO.Load(path.itemData);

            var offset = MiscUtils.GetLightingDrawOffset();

            spriteBatch.DrawItemInWorld(item, path.worldCenter - Main.screenPosition + offset, new Vector2(3.85f * 2));
        }
コード例 #2
0
        public void InputItemFromNetwork(ItemNetworkPath incoming, out bool sendBack)
        {
            Item data = ItemIO.Load(incoming.itemData);

            sendBack = true;

            if (!CanBeInput(data))
            {
                return;
            }

            int[] inputSlots = GetInputSlots();

            foreach (int slot in inputSlots)
            {
                Item slotItem = this.RetrieveItem(slot);
                if (slotItem.IsAir || slotItem.type == data.type)
                {
                    if (slotItem.IsAir)
                    {
                        slots[slot] = data.Clone();

                        if (ParentState?.Active ?? false)
                        {
                            ParentState.LoadToSlots(slots);
                        }

                        slotItem       = this.RetrieveItem(slot);
                        slotItem.stack = 0;
                    }

                    if (slotItem.stack + data.stack > slotItem.maxStack)
                    {
                        data.stack    -= slotItem.maxStack - slotItem.stack;
                        slotItem.stack = slotItem.maxStack;
                    }
                    else
                    {
                        slotItem.stack += data.stack;
                        data.stack      = 0;

                        sendBack = false;
                        break;
                    }
                }
            }

            if (sendBack)
            {
                incoming.itemData = ItemIO.Save(data);
            }
        }