public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, BaseCommand command, string[] args)
        {
            try
            {
                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);

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

                if (!(items || mobiles))
                {
                    return;
                }

                IPooledEnumerable <IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles);

                List <object> objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj))
                                     .Where(obj => ext.IsValid(obj)).Cast <object>().ToList();

                eable.Free();
                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
        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 e)
            {
                from.SendMessage(e.Message);
                Diagnostics.ExceptionLogging.LogException(e);
            }
        }
Пример #3
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

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

                List <object> list = new List <object>();

                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);
            }
        }
        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 e)
            {
                from.SendMessage(e.Message);
                Diagnostics.ExceptionLogging.LogException(e);
            }
        }
        public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendLocalizedMessage(500447); // That is not accessible.
                return;
            }

            if (command.ObjectTypes == ObjectTypes.Mobiles)
            {
                return; // sanity check
            }
            if (!(targeted is Container cont))
            {
                from.SendMessage("That is not a container.");
                return;
            }

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

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

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

                List <object> list = new List <object>();

                foreach (Item item in cont.FindItemsByType <Item>())
                {
                    if (ext.IsValid(item))
                    {
                        list.Add(item);
                    }
                }

                ext.Filter(list);

                RunCommand(from, list, command, args);
            }
            catch (Exception e)
            {
                from.SendMessage(e.Message);
            }
        }
Пример #6
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

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

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

                List <object> list = new List <object>();

                HashSet <NetState> states = TcpServer.Instances;

                foreach (var ns in states)
                {
                    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);
            }
        }
Пример #7
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);
                Server.Diagnostics.ExceptionLogging.LogException(ex);
            }
        }
Пример #8
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;
                }

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

                ArrayList list      = new ArrayList();
                ArrayList addresses = new ArrayList();

                System.Collections.Generic.List <NetState> states = NetState.Instances;

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

                    if (mob != null && !addresses.Contains(ns.Address) && ext.IsValid(mob))
                    {
                        list.Add(mob);
                        addresses.Add(ns.Address);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #9
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);
                Diagnostics.ExceptionLogging.LogException(ex);
            }
        }
Пример #10
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 if (items)
                {
                    foreach (Item item in reg.GetItems())
                    {
                        if (!BaseCommand.IsAccessible(from, item))
                        {
                            continue;
                        }

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


                else
                {
                    command.LogFailure("Could not find item or mobile with property in region.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #11
0
        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);
                }
            }
        }
Пример #12
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("Global...compiling\t");
                }
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("1\t");
                }
                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                ArrayList list = new ArrayList();

                if (items)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("2\t");
                    }
                    foreach (Item item in World.Items.Values)
                    {
                        if (ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }

                if (mobiles)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("3\t");
                    }
                    foreach (Mobile mob in World.Mobiles.Values)
                    {
                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("startfilter:list with " + list.Count + " in it\t");
                }
                ext.Filter(list);
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("4\t");
                }
                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }