2021-01-10 20:07:54 +01:00
|
|
|
using Content.Server.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Mind.Components;
|
2022-09-06 00:28:23 +10:00
|
|
|
using Content.Server.NPC.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
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Mind.Commands
|
2021-01-10 20:07:54 +01:00
|
|
|
{
|
2022-09-14 17:02:38 -07:00
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 20:46:49 -07:00
|
|
|
MakeSentient(entId, entityManager, true, true);
|
2021-02-14 13:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 20:46:49 -07:00
|
|
|
public static void MakeSentient(EntityUid uid, IEntityManager entityManager, bool allowMovement = true, bool allowSpeech = true)
|
2021-02-14 13:34:02 +01:00
|
|
|
{
|
2023-03-27 10:24:00 +13:00
|
|
|
entityManager.EnsureComponent<MindComponent>(uid);
|
2022-09-13 20:46:49 -07:00
|
|
|
if (allowMovement)
|
|
|
|
|
{
|
|
|
|
|
entityManager.EnsureComponent<InputMoverComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<MobMoverComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<MovementSpeedModifierComponent>(uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allowSpeech)
|
|
|
|
|
{
|
2022-12-28 04:03:25 +11:00
|
|
|
entityManager.EnsureComponent<SpeechComponent>(uid);
|
|
|
|
|
entityManager.EnsureComponent<EmotingComponent>(uid);
|
2022-09-13 20:46:49 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-09 15:44:07 +01:00
|
|
|
entityManager.EnsureComponent<ExaminerComponent>(uid);
|
2021-01-10 20:07:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|