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];

				ObjectConditional cond = ObjectConditional.Parse(from, ref args);

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

				bool items, mobiles;

				if (!CheckObjectTypes(command, cond, 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 (cond.CheckCondition(obj))
						objs.Add(obj);
				}

				eable.Free();

				RunCommand(from, objs, command, args);
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
				from.SendMessage(ex.Message);
			}
		}
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                bool items, mobiles;

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

                ArrayList list = new ArrayList();

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

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

                obj = list;
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                from.SendMessage(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                bool items, mobiles;

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

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

                ArrayList list = new ArrayList();

                //ArrayList states = NetState.Instances;
                List <NetState> states = NetState.Instances;

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

                    if (mob != null && cond.CheckCondition(mob))
                    {
                        list.Add(mob);
                    }
                }

                obj = list;
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                from.SendMessage(ex.Message);
            }
        }
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                bool items, mobiles;

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

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.Mobiles.Values)
                    {
                        if (cond.CheckCondition(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support mobiles.");
                    return;
                }

                obj = list;
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                from.SendMessage(ex.Message);
            }
        }
Ejemplo n.º 5
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
                {
                    ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                    bool items, mobiles;

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

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

                    Container cont = (Container)targeted;

                    Item[] found;

                    if (cond.Type == null)
                    {
                        found = cont.FindItemsByType(typeof(Item), true);
                    }
                    else
                    {
                        found = cont.FindItemsByType(cond.Type, true);
                    }

                    ArrayList list = new ArrayList();

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

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