2021-01-10 20:07:54 +01:00
|
|
|
using Content.Server.Administration;
|
|
|
|
|
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;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind.Components;
|
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
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!NetEntity.TryParse(args[0], out var entNet) || !_entManager.TryGetEntity(entNet, 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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!_entManager.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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
MakeSentient(entId.Value, _entManager, 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-06-18 11:33:19 -07:00
|
|
|
entityManager.EnsureComponent<MindContainerComponent>(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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|