2020-08-27 18:30:38 -07:00
|
|
|
using Server.Targeting;
|
|
|
|
|
|
|
|
|
|
namespace Server.Commands.Generic
|
|
|
|
|
{
|
|
|
|
|
public class MultiCommandImplementor : BaseCommandImplementor
|
|
|
|
|
{
|
|
|
|
|
public MultiCommandImplementor()
|
|
|
|
|
{
|
|
|
|
|
Accessors = new[] { "Multi", "m" };
|
|
|
|
|
SupportRequirement = CommandSupport.Multi;
|
|
|
|
|
AccessLevel = AccessLevel.Counselor;
|
|
|
|
|
Usage = "Multi <command>";
|
|
|
|
|
Description = "Invokes the command on multiple targeted objects.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Process(Mobile from, BaseCommand command, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
2020-09-13 21:49:46 -07:00
|
|
|
{
|
2020-09-18 18:41:26 -07:00
|
|
|
from.BeginTarget(
|
2020-08-27 18:30:38 -07:00
|
|
|
-1,
|
|
|
|
|
command.ObjectTypes == ObjectTypes.All,
|
|
|
|
|
TargetFlags.None,
|
|
|
|
|
(m, targeted, a) => OnTarget(m, targeted, command, a),
|
|
|
|
|
args
|
|
|
|
|
);
|
2020-09-13 21:49:46 -07:00
|
|
|
}
|
2020-08-27 18:30:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (!BaseCommand.IsAccessible(from, targeted))
|
|
|
|
|
{
|
|
|
|
|
from.SendLocalizedMessage(500447); // That is not accessible.
|
|
|
|
|
from.BeginTarget(
|
|
|
|
|
-1,
|
|
|
|
|
command.ObjectTypes == ObjectTypes.All,
|
|
|
|
|
TargetFlags.None,
|
|
|
|
|
(m, t, a) => OnTarget(m, t, command, a),
|
|
|
|
|
args
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (command.ObjectTypes)
|
|
|
|
|
{
|
|
|
|
|
case ObjectTypes.Both:
|
|
|
|
|
{
|
2021-12-24 15:53:59 -08:00
|
|
|
if (!(targeted is Item or Mobile))
|
2020-08-27 18:30:38 -07:00
|
|
|
{
|
|
|
|
|
from.SendMessage("This command does not work on that.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObjectTypes.Items:
|
|
|
|
|
{
|
2021-12-24 15:53:59 -08:00
|
|
|
if (targeted is not Item)
|
2020-08-27 18:30:38 -07:00
|
|
|
{
|
|
|
|
|
from.SendMessage("This command only works on items.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObjectTypes.Mobiles:
|
|
|
|
|
{
|
2021-12-24 15:53:59 -08:00
|
|
|
if (targeted is not Mobile)
|
2020-08-27 18:30:38 -07:00
|
|
|
{
|
|
|
|
|
from.SendMessage("This command only works on mobiles.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunCommand(from, targeted, command, args);
|
|
|
|
|
|
|
|
|
|
from.BeginTarget(
|
|
|
|
|
-1,
|
|
|
|
|
command.ObjectTypes == ObjectTypes.All,
|
|
|
|
|
TargetFlags.None,
|
|
|
|
|
(m, t, a) => OnTarget(m, t, command, a),
|
|
|
|
|
args
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|