* fixe * Save work. * Rune-aware parser. * oogh * pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests * Publicizes a lot of common generic commands, so custom toolshed envs can include them. * i think i might implode * Tests. * a * b * awa --------- Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Toolshed;
|
|
using Robust.Shared.Toolshed.Syntax;
|
|
using Robust.Shared.Toolshed.TypeParsers;
|
|
|
|
namespace Content.Server.Toolshed.Commands.Verbs;
|
|
|
|
[ToolshedCommand, AdminCommand(AdminFlags.Admin)]
|
|
public sealed class RunVerbAsCommand : ToolshedCommand
|
|
{
|
|
private SharedVerbSystem? _verb;
|
|
|
|
[CommandImplementation]
|
|
public IEnumerable<EntityUid> RunVerbAs(
|
|
[CommandInvocationContext] IInvocationContext ctx,
|
|
[PipedArgument] IEnumerable<EntityUid> input,
|
|
[CommandArgument] ValueRef<EntityUid> runner,
|
|
[CommandArgument] string verb
|
|
)
|
|
{
|
|
_verb ??= GetSys<SharedVerbSystem>();
|
|
verb = verb.ToLowerInvariant();
|
|
|
|
foreach (var i in input)
|
|
{
|
|
var runnerEid = runner.Evaluate(ctx);
|
|
|
|
|
|
if (EntityManager.Deleted(runnerEid) && runnerEid != default)
|
|
ctx.ReportError(new DeadEntity(runnerEid));
|
|
|
|
if (ctx.GetErrors().Any())
|
|
yield break;
|
|
|
|
var verbs = _verb.GetLocalVerbs(i, runnerEid, Verb.VerbTypes, true);
|
|
|
|
// if the "verb name" is actually a verb-type, try run any verb of that type.
|
|
var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verb);
|
|
if (verbType != null)
|
|
{
|
|
var verbTy = verbs.FirstOrDefault(v => v.GetType() == verbType);
|
|
if (verbTy != null)
|
|
{
|
|
_verb.ExecuteVerb(verbTy, runnerEid, i, forced: true);
|
|
yield return i;
|
|
}
|
|
}
|
|
|
|
foreach (var verbTy in verbs)
|
|
{
|
|
if (verbTy.Text.ToLowerInvariant() == verb)
|
|
{
|
|
_verb.ExecuteVerb(verbTy, runnerEid, i, forced: true);
|
|
yield return i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|