]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Localize makesentient command. Move makesentient method to mind system. (#38565)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Wed, 23 Jul 2025 12:29:46 +0000 (08:29 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Jul 2025 12:29:46 +0000 (14:29 +0200)
* praying pjb doesn't smite me for this :pray:

* requested changes

* Update makesentient-command.ftl

* verin commith and verin taketh away

Content.IntegrationTests/Tests/Minds/MindTests.cs
Content.Server/Administration/Systems/AdminVerbSystem.cs
Content.Server/Ghost/Roles/GhostRoleSystem.cs
Content.Server/Mind/Commands/MakeSentientCommand.cs
Content.Server/Mind/MindSystem.cs
Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Server/Zombies/ZombieSystem.Transform.cs
Content.Shared/Mind/SharedMindSystem.cs
Resources/Locale/en-US/commands/makesentient-command.ftl [new file with mode: 0644]

index 60e98b69fe25048347ed580653b18e4068f79ba8..48e11e46480747f6367cd21f924e771c0d06df67 100644 (file)
@@ -2,7 +2,7 @@
 using System.Linq;
 using Content.Server.Ghost.Roles;
 using Content.Server.Ghost.Roles.Components;
-using Content.Server.Mind.Commands;
+using Content.Server.Mind;
 using Content.Server.Roles;
 using Content.Shared.Damage;
 using Content.Shared.Damage.Prototypes;
@@ -339,7 +339,7 @@ public sealed partial class MindTests
         var entMan = server.ResolveDependency<IServerEntityManager>();
         var playerMan = server.ResolveDependency<IPlayerManager>();
 
-        var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>();
+        var mindSystem = entMan.EntitySysManager.GetEntitySystem<MindSystem>();
 
         EntityUid entity = default!;
         EntityUid mindId = default!;
@@ -379,7 +379,7 @@ public sealed partial class MindTests
 
             mob = entMan.SpawnEntity(null, new MapCoordinates());
 
-            MakeSentientCommand.MakeSentient(mob, entMan);
+            mindSystem.MakeSentient(mob);
             mobMindId = mindSystem.CreateMind(player.UserId, "Mindy McThinker the Second");
             mobMind = entMan.GetComponent<MindComponent>(mobMindId);
 
index b5ddc4bb1980fd235f47f5aed77da6ae11f7a2bd..19bcfd26f699722bb81a9df260d748da96203983 100644 (file)
@@ -4,7 +4,6 @@ using Content.Server.Administration.UI;
 using Content.Server.Disposal.Tube;
 using Content.Server.EUI;
 using Content.Server.Ghost.Roles;
-using Content.Server.Mind.Commands;
 using Content.Server.Mind;
 using Content.Server.Prayer;
 using Content.Server.Silicons.Laws;
@@ -16,7 +15,6 @@ using Content.Shared.Configurable;
 using Content.Shared.Database;
 using Content.Shared.Examine;
 using Content.Shared.GameTicking;
-using Content.Shared.Hands.Components;
 using Content.Shared.Inventory;
 using Content.Shared.Mind.Components;
 using Content.Shared.Movement.Components;
@@ -458,7 +456,7 @@ namespace Content.Server.Administration.Systems
                     Text = Loc.GetString("make-sentient-verb-get-data-text"),
                     Category = VerbCategory.Debug,
                     Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/sentient.svg.192dpi.png")),
-                    Act = () => MakeSentientCommand.MakeSentient(args.Target, EntityManager),
+                    Act = () => _mindSystem.MakeSentient(args.Target),
                     Impact = LogImpact.Medium
                 };
                 args.Verbs.Add(verb);
index cd0330ded8b5718294a9332884bc2480d10507b5..ec69ebe3c136b0606d26d887b8ac7962c18b5f07 100644 (file)
@@ -5,7 +5,6 @@ using Content.Server.Ghost.Roles.Components;
 using Content.Server.Ghost.Roles.Events;
 using Content.Shared.Ghost.Roles.Raffles;
 using Content.Server.Ghost.Roles.UI;
-using Content.Server.Mind.Commands;
 using Content.Shared.Administration;
 using Content.Shared.CCVar;
 using Content.Shared.Database;
@@ -698,7 +697,7 @@ public sealed class GhostRoleSystem : EntitySystem
         RaiseLocalEvent(mob, spawnedEvent);
 
         if (ghostRole.MakeSentient)
-            MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
+            _mindSystem.MakeSentient(mob, ghostRole.AllowMovement, ghostRole.AllowSpeech);
 
         EnsureComp<MindContainerComponent>(mob);
 
@@ -745,7 +744,7 @@ public sealed class GhostRoleSystem : EntitySystem
         }
 
         if (ghostRole.MakeSentient)
-            MakeSentientCommand.MakeSentient(uid, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
+            _mindSystem.MakeSentient(uid, ghostRole.AllowMovement, ghostRole.AllowSpeech);
 
         GhostRoleInternalCreateMindAndTransfer(args.Player, uid, uid, ghostRole);
         UnregisterGhostRole((uid, ghostRole));
index 5e19d135b6fd7b7ca057f666509b1de2310c480e..dad5126a31efd4b7ae98bb15d55b8cff69e85417 100644 (file)
@@ -1,63 +1,30 @@
 using Content.Server.Administration;
 using Content.Shared.Administration;
-using Content.Shared.Emoting;
-using Content.Shared.Examine;
-using Content.Shared.Mind.Components;
-using Content.Shared.Movement.Components;
-using Content.Shared.Speech;
 using Robust.Shared.Console;
 
-namespace Content.Server.Mind.Commands
+namespace Content.Server.Mind.Commands;
+
+[AdminCommand(AdminFlags.Admin)]
+public sealed class MakeSentientCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Admin)]
-    public sealed class MakeSentientCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _entManager = default!;
+    [Dependency] private readonly MindSystem _mindSystem = default!;
 
-        public string Command => "makesentient";
-        public string Description => "Makes an entity sentient (able to be controlled by a player)";
-        public string Help => "makesentient <entity id>";
+    public override string Command => "makesentient";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (args.Length != 1)
         {
-            if (args.Length != 1)
-            {
-                shell.WriteLine("Wrong number of arguments.");
-                return;
-            }
-
-            if (!NetEntity.TryParse(args[0], out var entNet) || !_entManager.TryGetEntity(entNet, out var entId))
-            {
-                shell.WriteLine("Invalid argument.");
-                return;
-            }
-
-            if (!_entManager.EntityExists(entId))
-            {
-                shell.WriteLine("Invalid entity specified!");
-                return;
-            }
-
-            MakeSentient(entId.Value, _entManager, true, true);
+            shell.WriteLine(Loc.GetString("shell-need-exactly-one-argument"));
+            return;
         }
 
-        public static void MakeSentient(EntityUid uid, IEntityManager entityManager, bool allowMovement = true, bool allowSpeech = true)
+        if (!NetEntity.TryParse(args[0], out var entNet) || !EntityManager.TryGetEntity(entNet, out var entId) || !EntityManager.EntityExists(entId))
         {
-            entityManager.EnsureComponent<MindContainerComponent>(uid);
-            if (allowMovement)
-            {
-                entityManager.EnsureComponent<InputMoverComponent>(uid);
-                entityManager.EnsureComponent<MobMoverComponent>(uid);
-                entityManager.EnsureComponent<MovementSpeedModifierComponent>(uid);
-            }
-
-            if (allowSpeech)
-            {
-                entityManager.EnsureComponent<SpeechComponent>(uid);
-                entityManager.EnsureComponent<EmotingComponent>(uid);
-            }
-
-            entityManager.EnsureComponent<ExaminerComponent>(uid);
+            shell.WriteLine(Loc.GetString("shell-could-not-find-entity-with-uid", ("uid", args[0])));
+            return;
         }
+
+        _mindSystem.MakeSentient(entId.Value);
     }
 }
index 71d38c688be3702ae7a2137982f5f43776e5bff3..a7547e87e4c4c7a7573ff0ca34ab57cd928cf33f 100644 (file)
@@ -1,7 +1,6 @@
 using Content.Server.Administration.Logs;
 using Content.Server.GameTicking;
 using Content.Server.Ghost;
-using Content.Server.Mind.Commands;
 using Content.Shared.Database;
 using Content.Shared.Ghost;
 using Content.Shared.Mind;
@@ -349,7 +348,7 @@ public sealed class MindSystem : SharedMindSystem
             return;
         }
 
-        MakeSentientCommand.MakeSentient(target, EntityManager);
+        MakeSentient(target);
         TransferTo(mindId, target, ghostCheckOverride: true, mind: mind);
     }
 }
index c134eca114be3675f3b67b3815ddc24d121a3c4f..696b19199e7bda87153f7ea83b4bd32edb3ef2a1 100644 (file)
@@ -1,10 +1,7 @@
 using Content.Server.Actions;
 using Content.Server.Humanoid;
 using Content.Server.Inventory;
-using Content.Server.Mind.Commands;
 using Content.Server.Polymorph.Components;
-using Content.Shared.Actions;
-using Content.Shared.Actions.Components;
 using Content.Shared.Buckle;
 using Content.Shared.Coordinates;
 using Content.Shared.Damage;
@@ -210,7 +207,7 @@ public sealed partial class PolymorphSystem : EntitySystem
                 ("child", Identity.Entity(child, EntityManager))),
                 child);
 
-        MakeSentientCommand.MakeSentient(child, EntityManager);
+        _mindSystem.MakeSentient(child);
 
         var polymorphedComp = Factory.GetComponent<PolymorphedEntityComponent>();
         polymorphedComp.Parent = uid;
index 7b9abee5d2b8d76da8b6d097b118ff6d0b343329..46d2e308d06c40926dbb8010f3ee3247b86c590b 100644 (file)
@@ -1,7 +1,7 @@
 using Content.Server.Access.Systems;
 using Content.Server.Humanoid;
 using Content.Server.IdentityManagement;
-using Content.Server.Mind.Commands;
+using Content.Server.Mind;
 using Content.Server.PDA;
 using Content.Server.Station.Components;
 using Content.Shared.Access.Components;
@@ -41,6 +41,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
     [Dependency] private readonly MetaDataSystem _metaSystem = default!;
     [Dependency] private readonly PdaSystem _pdaSystem = default!;
     [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+    [Dependency] private readonly MindSystem _mindSystem = default!;
 
     /// <summary>
     /// Attempts to spawn a player character onto the given station.
@@ -110,7 +111,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
         {
             DebugTools.Assert(entity is null);
             var jobEntity = Spawn(prototype.JobEntity, coordinates);
-            MakeSentientCommand.MakeSentient(jobEntity, EntityManager);
+            _mindSystem.MakeSentient(jobEntity);
 
             // Make sure custom names get handled, what is gameticker control flow whoopy.
             if (loadout != null)
index cf0dac30b26755cc3b355dd50cc40be682106998..a256d7159fb2aa4109a8bc9e738058d84743097c 100644 (file)
@@ -7,7 +7,6 @@ using Content.Server.Humanoid;
 using Content.Server.IdentityManagement;
 using Content.Server.Inventory;
 using Content.Server.Mind;
-using Content.Server.Mind.Commands;
 using Content.Server.NPC;
 using Content.Server.NPC.HTN;
 using Content.Server.NPC.Systems;
@@ -215,7 +214,7 @@ public sealed partial class ZombieSystem
         _popup.PopupEntity(Loc.GetString("zombie-transform", ("target", target)), target, PopupType.LargeCaution);
 
         //Make it sentient if it's an animal or something
-        MakeSentientCommand.MakeSentient(target, EntityManager);
+        _mind.MakeSentient(target);
 
         //Make the zombie not die in the cold. Good for space zombies
         if (TryComp<TemperatureComponent>(target, out var tempComp))
index de8d4f0567f278aded89594ac17f4f43d8fc1a30..271639725fb61e60e9acde8afaff56ce3787e12f 100644 (file)
@@ -2,15 +2,19 @@ using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Database;
+using Content.Shared.Emoting;
 using Content.Shared.Examine;
 using Content.Shared.GameTicking;
 using Content.Shared.Humanoid;
 using Content.Shared.Interaction.Events;
+using Content.Shared.Movement.Components;
 using Content.Shared.Mind.Components;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Objectives.Systems;
 using Content.Shared.Players;
+using Content.Shared.Speech;
+
 using Content.Shared.Whitelist;
 using Robust.Shared.Map;
 using Robust.Shared.Network;
@@ -632,6 +636,31 @@ public abstract partial class SharedMindSystem : EntitySystem
 
         return allHumans;
     }
+
+    /// <summary>
+    /// Give sentience to a target entity by attaching necessary components.
+    /// </summary>
+    /// <param name="uid">Uid of the target entity.</param>
+    /// <param name="allowMovement">Whether the target entity should be able to move.</param>
+    /// <param name="allowSpeech">Whether the target entity should be able to talk.</param>
+    public void MakeSentient(EntityUid uid, bool allowMovement = true, bool allowSpeech = true)
+    {
+        EnsureComp<MindContainerComponent>(uid);
+        if (allowMovement)
+        {
+            EnsureComp<InputMoverComponent>(uid);
+            EnsureComp<MobMoverComponent>(uid);
+            EnsureComp<MovementSpeedModifierComponent>(uid);
+        }
+
+        if (allowSpeech)
+        {
+            EnsureComp<SpeechComponent>(uid);
+            EnsureComp<EmotingComponent>(uid);
+        }
+
+        EnsureComp<ExaminerComponent>(uid);
+    }
 }
 
 /// <summary>
diff --git a/Resources/Locale/en-US/commands/makesentient-command.ftl b/Resources/Locale/en-US/commands/makesentient-command.ftl
new file mode 100644 (file)
index 0000000..2d972b8
--- /dev/null
@@ -0,0 +1,2 @@
+cmd-makesentient-desc = Makes an entity sentient (able to be controlled by a player).
+cmd-makesentient-help = Usage: makesentient <entityUid>