* ogh

* i should save my work

* ogh

* hhcdfhjbghshbxdfhghshc
- lots of bugs in parsing still
- invocation is a stub

* expr parsing works

* awawa

* Saving work

* Improve APIs a bit all around, add shortcuts.

* awa

* awa

* AAAAAA

* save work

* Move shit to engine

* lord

* bql is kill

* forgot the fucking bike rack

* bql is kill for real

* pjb will kill me

* aughfhbdj

* adgddf

* gdsgvfvxshngfgh

* b

* hfsjhghj

* a

* tf you mean i have to document it

* follow C# standards

* Assorted cleanup and documentation pass, minor bugfix in ValueRefParser.

* Start porting old commands, remove that pesky prefix in favor of integrating with the shell.

* bw

* Fix valueref up a bit, improve autocomplete for it.

* awa

* fix tests

* git shut up

* Arithmetic commands.

* parse improvements

* Update engine.

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
This commit is contained in:
Moony
2023-08-02 16:09:08 -05:00
committed by GitHub
parent ad61c21c01
commit e2b22a4cd8
48 changed files with 1204 additions and 793 deletions

View File

@@ -0,0 +1,34 @@
using Content.Server.Administration;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Syntax;
namespace Content.Server.NewCon.Commands.AdminDebug;
[ToolshedCommand, AdminCommand(AdminFlags.Debug)]
public sealed class ACmdCommand : ToolshedCommand
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[CommandImplementation("perms")]
public AdminFlags[]? Perms([PipedArgument] CommandSpec command)
{
var res = _adminManager.TryGetCommandFlags(command, out var flags);
if (res)
flags ??= Array.Empty<AdminFlags>();
return flags;
}
[CommandImplementation("caninvoke")]
public bool CanInvoke(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] CommandSpec command,
[CommandArgument] ValueRef<IPlayerSession> player
)
{
// Deliberately discard the error.
return ((IPermissionController) _adminManager).CheckInvokable(command, player.Evaluate(ctx), out var err);
}
}

View File

@@ -0,0 +1,62 @@
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.NewCon.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;
}
}
}
}
}

View File

@@ -0,0 +1,51 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.EUI;
using Content.Shared.Administration;
using Content.Shared.Bql;
using Content.Shared.Eui;
using Robust.Server.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
namespace Content.Server.NewCon.Commands;
[ToolshedCommand, AdminCommand(AdminFlags.Admin)]
public sealed class VisualizeCommand : ToolshedCommand
{
[Dependency] private readonly EuiManager _euiManager = default!;
[CommandImplementation]
public void VisualizeEntities(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input
)
{
if (ctx.Session is null)
{
ctx.ReportError(new NotForServerConsoleError());
return;
}
var ui = new ToolshedVisualizeEui(
input.Select(e => (EntName(e), e)).ToArray()
);
_euiManager.OpenEui(ui, (IPlayerSession) ctx.Session);
_euiManager.QueueStateUpdate(ui);
}
}
internal sealed class ToolshedVisualizeEui : BaseEui
{
private readonly (string name, EntityUid entity)[] _entities;
public ToolshedVisualizeEui((string name, EntityUid entity)[] entities)
{
_entities = entities;
}
public override EuiStateBase GetNewState()
{
return new ToolshedVisualizeEuiState(_entities);
}
}