Пример #1
0
        private static bool MoveItem(string command, Argument[] args, bool quiet, bool force)
        {
            if (args.Length < 2)
            {
                throw new RunTimeError(null, "Usage: moveitem (serial) (destination) [(x, y, z)] [amount]");
            }

            uint serial      = args[0].AsSerial();
            uint destination = args[1].AsSerial();

            if (args.Length == 2)
            {
                DragDropManager.DragDrop(World.FindItem((uint)serial), World.FindItem((uint)destination));
            }
            else if (args.Length == 5)
            {
                return(true);
            }
            else if (args.Length == 6)
            {
                return(true);
            }

            return(true);
        }
Пример #2
0
        private int Recurse(Item pack, List <Item> items, RestockItem ri, ref int count)
        {
            int num = 0;

            for (int i = 0; count < ri.Amount && i < items.Count; i++)
            {
                Item item = (Item)items[i];

                if (item.ItemID == ri.ItemID)
                {
                    int amt = ri.Amount - count;
                    if (amt > item.Amount)
                    {
                        amt = item.Amount;
                    }

                    DragDropManager.DragDrop(item, amt, pack);
                    count += amt;
                    num++;
                }
                else if (item.Contains.Count > 0)
                {
                    num += Recurse(pack, item.Contains, ri, ref count);
                }
            }

            return(num);
        }
Пример #3
0
        private int OrganizeChildren(Item container, object dest)
        {
            int count = 0;

            for (int i = 0; i < container.Contains.Count; i++)
            {
                Item item = (Item)container.Contains[i];
                if (item.Serial != m_Cont && !item.IsChildOf(dest))
                {
                    count += OrganizeChildren(item, dest);
                    if (Items.Contains(item.ItemID.Value))
                    {
                        if (dest is Item)
                        {
                            DragDropManager.DragDrop(item, (Item)dest);
                        }
                        else if (dest is Mobile)
                        {
                            DragDropManager.DragDrop(item, ((Mobile)dest).Serial);
                        }

                        count++;
                    }
                }
            }

            return(count);
        }
Пример #4
0
        private static void LiftReject(PacketReader p, PacketHandlerEventArgs args)
        {
            Item item = World.FindItem(DragDropManager.m_Holding);

            if (DragDropManager.LiftReject() || item == null)
            {
                return;
            }
            DragDropInfo info = items.Find(i => i.Drag == item.Serial);

            if (info == null)
            {
                return;
            }
            args.Block = true;
            if (World.FindItem(info.Drop) == item.Container)
            {
                return;
            }

            if (info.Layer != Layer.Invalid)
            {
                DragDropManager.DragDrop(item, World.Player, info.Layer);
            }
            else if (info.Position != Point3D.Zero)
            {
                DragDropManager.Drag(item, item.Amount);
                DragDropManager.Drop(item, info.Drop, info.Position);
            }
            else
            {
                DragDropManager.DragDrop(item, info.Drop);
            }
        }
Пример #5
0
 public static void Dress(Item item, Layer layer)
 {
     if (item == null)
     {
         return;
     }
     items.Add(new DragDropInfo(item.Serial, layer));
     DragDropManager.DragDrop(item, World.Player, layer);
 }
Пример #6
0
 public static void Move(Item item, Item to)
 {
     if (item == null || to == null)
     {
         return;
     }
     items.Add(new DragDropInfo(item.Serial, to.Serial));
     DragDropManager.DragDrop(item, to);
 }
Пример #7
0
        private static void OnGrabItem(bool loc, Serial serial, Point3D pt, ushort itemId)
        {
            Item item = World.FindItem(serial);

            if (item != null && item.Serial.IsItem && item.Movable && item.Visible)
            {
                Item hotbag = World.FindItem(_grabHotBag) ?? World.Player.Backpack;

                DragDropManager.DragDrop(item, item.Amount, hotbag);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Error, "Invalid or inaccessible item.", false);
            }
        }
Пример #8
0
        public static bool Equip(Item item, Layer layer)
        {
            if (layer == Layer.Invalid || layer > Layer.LastUserValid || item == null || item.Layer == Layer.Invalid ||
                item.Layer > Layer.LastUserValid)
            {
                return(false);
            }

            if (item != null && World.Player != null && item.IsChildOf(World.Player.Backpack))
            {
                DragDropManager.DragDrop(item, World.Player, layer);
                return(true);
            }

            return(false);
        }
Пример #9
0
        public static void ToggleRight()
        {
            if (World.Player == null)
            {
                return;
            }

            Item item = World.Player.GetItemOnLayer(Layer.RightHand);

            if (item == null)
            {
                if (m_Right != null)
                {
                    m_Right = World.FindItem(m_Right.Serial);
                }

                if (m_Right != null && m_Right.IsChildOf(World.Player.Backpack))
                {
                    // try to also undress conflicting hand(s)
                    Item conflict = World.Player.GetItemOnLayer(Layer.LeftHand);
                    if (conflict != null && (conflict.IsTwoHanded || m_Right.IsTwoHanded))
                    {
                        Item ub = DressList.FindUndressBag(conflict);
                        if (ub != null)
                        {
                            DragDropManager.DragDrop(conflict, ub);
                        }
                    }

                    DragDropManager.DragDrop(m_Right, World.Player, DressList.GetLayerFor(m_Right));
                }
                else
                {
                    World.Player.SendMessage(MsgLevel.Force, LocString.MustDisarm);
                }
            }
            else
            {
                Item ub = DressList.FindUndressBag(item);
                if (ub != null)
                {
                    DragDropManager.DragDrop(item, ub);
                }
                m_Right = item;
            }
        }
Пример #10
0
        public static void OnUndressAll()
        {
            for (int i = 0; i < World.Player.Contains.Count; i++)
            {
                Item item = (Item)World.Player.Contains[i];
                if (item.Layer <= Layer.LastUserValid && item.Layer != Layer.Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair)
                {
                    Item pack = DressList.FindUndressBag(item);
                    if (pack != null)
                    {
                        DragDropManager.DragDrop(item, pack);
                    }
                }
            }

            //if ( Macros.MacroManager.AcceptActions )
            //	MacroManager.Action( new Macros.UnDressAction( (byte)0 ) );
        }
Пример #11
0
        public void Scavenge(Item item)
        {
            DebugLog("Checking WorldItem {0} ...", item);
            if (!m_Enabled || !m_Items.Contains(item.ItemID) || World.Player.Backpack == null || World.Player.IsGhost ||
                World.Player.Weight >= World.Player.MaxWeight)
            {
                DebugLog("... skipped.");
                return;
            }

            if (m_Cache == null)
            {
                m_Cache = new List <Serial>();
            }
            else if (m_Cache.Count >= 190)
            {
                m_Cache.RemoveRange(0, 50);
            }

            if (m_Cache.Contains(item.Serial))
            {
                DebugLog("Item was cached.");
                return;
            }

            Item bag = m_BagRef;

            if (bag == null || bag.Deleted)
            {
                bag = m_BagRef = World.FindItem(m_Bag);
            }

            if (bag == null || bag.Deleted || !bag.IsChildOf(World.Player.Backpack))
            {
                bag = World.Player.Backpack;
            }

            m_Cache.Add(item.Serial);
            DragDropManager.DragDrop(item, bag);
            DebugLog("Dragging to {0}!", bag);
        }
Пример #12
0
        public static bool Unequip(Layer layer)
        {
            if (layer == Layer.Invalid || layer > Layer.LastUserValid)
            {
                return(false);
            }

            Item item = World.Player.GetItemOnLayer(layer);

            if (item != null)
            {
                Item pack = DressList.FindUndressBag(item);
                if (pack != null)
                {
                    DragDropManager.DragDrop(item, pack);
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        public static bool Unequip(Layer layer)
        {
            if (layer == Layer.Invalid || layer > Layer.LastUserValid)
            {
                return(false);
            }

            //if ( Macros.MacroManager.AcceptActions )
            //	MacroManager.Action( new Macros.UnDressAction( (byte)Layer ) );

            Item item = World.Player.GetItemOnLayer(layer);

            if (item != null)
            {
                Item pack = DressList.FindUndressBag(item);
                if (pack != null)
                {
                    DragDropManager.DragDrop(item, pack);
                    return(true);
                }
            }
            return(false);
        }