2021-01-10 20:07:54 +01:00
|
|
|
using Content.Server.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.AI.Components;
|
|
|
|
|
using Content.Server.Mind.Components;
|
2021-01-10 20:07:54 +01:00
|
|
|
using Content.Shared.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Emoting;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Shared.Examine;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Movement.Components;
|
|
|
|
|
using Content.Shared.Speech;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2021-01-10 20:07:54 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2021-02-18 20:45:45 -08:00
|
|
|
using Timer = Robust.Shared.Timing.Timer;
|
2021-01-10 20:07:54 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Mind.Commands
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class MakeSentientCommand : IConsoleCommand
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
|
|
|
|
public string Command => "makesentient";
|
|
|
|
|
public string Description => "Makes an entity sentient (able to be controlled by a player)";
|
|
|
|
|
public string Help => "makesentient <entity id>";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Wrong number of arguments.");
|
2021-01-10 20:07:54 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
if (!EntityUid.TryParse(args[0], out var entId))
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Invalid argument.");
|
2021-01-10 20:07:54 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
if (!entityManager.EntityExists(entId))
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Invalid entity specified!");
|
2021-01-10 20:07:54 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
MakeSentient(entId, entityManager);
|
2021-02-14 13:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
public static void MakeSentient(EntityUid uid, IEntityManager entityManager)
|
2021-02-14 13:34:02 +01:00
|
|
|
{
|
2021-11-09 15:44:07 +01:00
|
|
|
if(entityManager.HasComponent<AiControllerComponent>(uid))
|
|
|
|
|
entityManager.RemoveComponent<AiControllerComponent>(uid);
|
2021-01-10 20:07:54 +01:00
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
|
|
|
|
|
entityManager.EnsureComponent<MindComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<SharedPlayerInputMoverComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<SharedPlayerMobMoverComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<SharedSpeechComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<SharedEmotingComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<ExaminerComponent>(uid);
|
2021-01-10 20:07:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|