Toolshed part 2 (#18997)
* 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>
This commit is contained in:
62
Content.Server/Mind/Toolshed/MindCommand.cs
Normal file
62
Content.Server/Mind/Toolshed/MindCommand.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Toolshed;
|
||||
using Robust.Shared.Toolshed.Errors;
|
||||
using Robust.Shared.Toolshed.Syntax;
|
||||
|
||||
namespace Content.Server.Mind.Toolshed;
|
||||
|
||||
/// <summary>
|
||||
/// Contains various mind-manipulation commands like getting minds, controlling mobs, etc.
|
||||
/// </summary>
|
||||
[ToolshedCommand]
|
||||
public sealed class MindCommand : ToolshedCommand
|
||||
{
|
||||
private MindSystem? _mind;
|
||||
|
||||
[CommandImplementation("get")]
|
||||
public Mind? Get([PipedArgument] IPlayerSession session)
|
||||
{
|
||||
return session.ContentData()?.Mind;
|
||||
}
|
||||
|
||||
[CommandImplementation("get")]
|
||||
public Mind? Get([PipedArgument] EntityUid ent)
|
||||
{
|
||||
if (!TryComp<MindContainerComponent>(ent, out var container))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return container.Mind;
|
||||
}
|
||||
|
||||
[CommandImplementation("control")]
|
||||
public EntityUid Control(
|
||||
[CommandInvocationContext] IInvocationContext ctx,
|
||||
[PipedArgument] EntityUid target,
|
||||
[CommandArgument] ValueRef<IPlayerSession> playerRef)
|
||||
{
|
||||
_mind ??= GetSys<MindSystem>();
|
||||
|
||||
var player = playerRef.Evaluate(ctx);
|
||||
if (player is null)
|
||||
{
|
||||
ctx.ReportError(new NotForServerConsoleError());
|
||||
return target;
|
||||
}
|
||||
|
||||
var mind = player.ContentData()?.Mind;
|
||||
|
||||
if (mind is null)
|
||||
{
|
||||
ctx.ReportError(new SessionHasNoEntityError(player));
|
||||
return target;
|
||||
}
|
||||
|
||||
_mind.TransferTo(mind, target);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user