コード例 #1
0
 public ItemStackMoveOperation(IWorldAccessor world, EnumMouseButton mouseButton, EnumModifierKey modifiers, EnumMergePriority currentPriority, int requestedQuantity = 0)
 {
     World             = world;
     MouseButton       = mouseButton;
     Modifiers         = modifiers;
     CurrentPriority   = currentPriority;
     RequestedQuantity = requestedQuantity;
 }
コード例 #2
0
        public virtual void SlotClick(ICoreClientAPI api, int slotId, EnumMouseButton mouseButton, bool shiftPressed, bool ctrlPressed, bool altPressed)
        {
            //Console.WriteLine("client side slot click on " + slotId);

            List <IInventory> inventories    = api.World.Player.InventoryManager.OpenedInventories;
            IInventory        mouseCursorInv = api.World.Player.InventoryManager.GetOwnInventory(GlobalConstants.mousecursorInvClassName);
            object            packet;

            EnumModifierKey modifiers =
                (shiftPressed ? EnumModifierKey.SHIFT : 0) |
                (ctrlPressed ? EnumModifierKey.CTRL : 0) |
                (altPressed ? EnumModifierKey.ALT : 0)
            ;

            ItemStackMoveOperation op = new ItemStackMoveOperation(api.World, mouseButton, modifiers, EnumMergePriority.AutoMerge);

            op.ActingPlayer = api.World.Player;

            if (shiftPressed)
            {
                ItemSlot sourceSlot = inventory[slotId];
                op.RequestedQuantity = sourceSlot.StackSize;
                packet = inventory.ActivateSlot(slotId, sourceSlot, ref op);
            }
            else
            {
                op.CurrentPriority = EnumMergePriority.DirectMerge;
                packet             = inventory.ActivateSlot(slotId, mouseCursorInv[0], ref op);
            }

            if (packet != null)
            {
                if (packet is object[] packets)
                {
                    for (int i = 0; i < packets.Length; i++)
                    {
                        SendPacketHandler(packets[i]);
                    }
                }
                else
                {
                    SendPacketHandler?.Invoke(packet);
                }
            }

            api.Input.TriggerOnMouseClickSlot(inventory[slotId]);
        }
コード例 #3
0
 public ItemStackMergeOperation(IWorldAccessor world, EnumMouseButton mouseButton, EnumModifierKey modifiers, EnumMergePriority currentPriority, int requestedQuantity) : base(world, mouseButton, modifiers, currentPriority, requestedQuantity)
 {
 }