Files
crystall-punk-14/Content.Server/GlobalVerbs/MakeSentientVerb.cs
Acruid 8b5d66050a Console Unify API Changes (#3059)
* Remove unused IChatCommand.

* Lots of refactoring into a shared context.

* Removed ICommonSession from server concmd Execute.

* Added argStr parameter to concmd execute.

* The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands.

* Finally move shells and commands into shared.

* Console commands can now be registered directly without a class in a shared context.

* Engine API Changes.

* Repair rebase damage.

* Update Submodule.
2021-02-01 16:49:43 -08:00

53 lines
1.8 KiB
C#

using Content.Server.Commands;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Verbs;
using Robust.Server.Console;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.GlobalVerbs
{
[GlobalVerb]
public class MakeSentientVerb : GlobalVerb
{
public override bool RequireInteractionRange => false;
public override bool BlockedByContainers => false;
public override void GetData(IEntity user, IEntity target, VerbData data)
{
data.Visibility = VerbVisibility.Invisible;
var groupController = IoCManager.Resolve<IConGroupController>();
if (user == target || target.HasComponent<MindComponent>())
return;
var player = user.GetComponent<IActorComponent>().playerSession;
if (groupController.CanCommand(player, "makesentient"))
{
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("Make Sentient");
data.CategoryData = VerbCategories.Debug;
}
}
public override void Activate(IEntity user, IEntity target)
{
var groupController = IoCManager.Resolve<IConGroupController>();
var player = user.GetComponent<IActorComponent>().playerSession;
if (!groupController.CanCommand(player, "makesentient"))
return;
var host = IoCManager.Resolve<IServerConsoleHost>();
var cmd = new MakeSentientCommand();
var uidStr = target.Uid.ToString();
cmd.Execute(new ConsoleShell(host, player), $"{cmd.Command} {uidStr}",
new[] {uidStr});
}
}
}