diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.cs b/Content.IntegrationTests/Tests/Minds/MindTests.cs index 60e98b69fe..48e11e4648 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.cs @@ -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(); var playerMan = server.ResolveDependency(); - var mindSystem = entMan.EntitySysManager.GetEntitySystem(); + var mindSystem = entMan.EntitySysManager.GetEntitySystem(); 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(mobMindId); diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index b5ddc4bb19..19bcfd26f6 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -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); diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index cd0330ded8..ec69ebe3c1 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -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(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)); diff --git a/Content.Server/Mind/Commands/MakeSentientCommand.cs b/Content.Server/Mind/Commands/MakeSentientCommand.cs index 5e19d135b6..dad5126a31 100644 --- a/Content.Server/Mind/Commands/MakeSentientCommand.cs +++ b/Content.Server/Mind/Commands/MakeSentientCommand.cs @@ -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 MindSystem _mindSystem = default!; + + public override string Command => "makesentient"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - [Dependency] private readonly IEntityManager _entManager = default!; - - public string Command => "makesentient"; - public string Description => "Makes an entity sentient (able to be controlled by a player)"; - public string Help => "makesentient "; - - public 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(uid); - if (allowMovement) - { - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - } - - if (allowSpeech) - { - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - } - - entityManager.EnsureComponent(uid); + shell.WriteLine(Loc.GetString("shell-could-not-find-entity-with-uid", ("uid", args[0]))); + return; } + + _mindSystem.MakeSentient(entId.Value); } } diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index 71d38c688b..a7547e87e4 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -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); } } diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index c134eca114..696b19199e 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -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(); polymorphedComp.Parent = uid; diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 7b9abee5d2..46d2e308d0 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -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!; /// /// 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) diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index cf0dac30b2..a256d7159f 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -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(target, out var tempComp)) diff --git a/Content.Shared/Mind/SharedMindSystem.cs b/Content.Shared/Mind/SharedMindSystem.cs index de8d4f0567..271639725f 100644 --- a/Content.Shared/Mind/SharedMindSystem.cs +++ b/Content.Shared/Mind/SharedMindSystem.cs @@ -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; } + + /// + /// Give sentience to a target entity by attaching necessary components. + /// + /// Uid of the target entity. + /// Whether the target entity should be able to move. + /// Whether the target entity should be able to talk. + public void MakeSentient(EntityUid uid, bool allowMovement = true, bool allowSpeech = true) + { + EnsureComp(uid); + if (allowMovement) + { + EnsureComp(uid); + EnsureComp(uid); + EnsureComp(uid); + } + + if (allowSpeech) + { + EnsureComp(uid); + EnsureComp(uid); + } + + EnsureComp(uid); + } } /// diff --git a/Resources/Locale/en-US/commands/makesentient-command.ftl b/Resources/Locale/en-US/commands/makesentient-command.ftl new file mode 100644 index 0000000000..2d972b8e60 --- /dev/null +++ b/Resources/Locale/en-US/commands/makesentient-command.ftl @@ -0,0 +1,2 @@ +cmd-makesentient-desc = Makes an entity sentient (able to be controlled by a player). +cmd-makesentient-help = Usage: makesentient