public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ArrayList list = new ArrayList();

                List <NetState> states = NetState.Instances;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob == null)
                    {
                        continue;
                    }

                    if (!BaseCommand.IsAccessible(from, mob))
                    {
                        continue;
                    }

                    if (ext.IsValid(mob))
                    {
                        list.Add(mob);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #2
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #3
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                ArrayList list = new ArrayList();

                if (items)
                {
                    foreach (Item item in World.Items.Values)
                    {
                        if (ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }

                if (mobiles)
                {
                    foreach (Mobile mob in World.Mobiles.Values)
                    {
                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
예제 #4
0
        public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            try
            {
                object[]    states  = (object[])state;
                BaseCommand command = (BaseCommand)states[0];
                string[]    args    = (string[])states[1];

                Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                IPooledEnumerable eable;

                if (items && mobiles)
                {
                    eable = map.GetObjectsInBounds(rect);
                }
                else if (items)
                {
                    eable = map.GetItemsInBounds(rect);
                }
                else if (mobiles)
                {
                    eable = map.GetMobilesInBounds(rect);
                }
                else
                {
                    return;
                }

                ArrayList objs = new ArrayList();

                foreach (object obj in eable)
                {
                    if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
                    {
                        continue;
                    }

                    if (ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }

                eable.Free();

                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
        public void OnTarget(Mobile from, object targeted, object state)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendMessage("That is not accessible.");
                return;
            }

            object[]    states  = (object[])state;
            BaseCommand command = (BaseCommand)states[0];

            string[] args = (string[])states[1];

            if (command.ObjectTypes == ObjectTypes.Mobiles)
            {
                return; // sanity check
            }
            if (!(targeted is Container))
            {
                from.SendMessage("That is not a container.");
            }
            else
            {
                try
                {
                    Extensions ext = Extensions.Parse(from, ref args);

                    bool items, mobiles;

                    if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                    {
                        return;
                    }

                    if (!items)
                    {
                        from.SendMessage("This command only works on items.");
                        return;
                    }

                    Container cont = (Container)targeted;

                    Item[] found = cont.FindItemsByType(typeof(Item), true);

                    ArrayList list = new ArrayList();

                    for (int i = 0; i < found.Length; ++i)
                    {
                        if (ext.IsValid(found[i]))
                        {
                            list.Add(found[i]);
                        }
                    }

                    ext.Filter(list);

                    RunCommand(from, list, command, args);
                }
                catch (Exception e)
                {
                    from.SendMessage(e.Message);
                }
            }
        }