Localize makesentient command. Move makesentient method to mind system. (#38565)

* praying pjb doesn't smite me for this 🙏

* requested changes

* Update makesentient-command.ftl

* verin commith and verin taketh away
This commit is contained in:
Kyle Tyo
2025-07-23 08:29:46 -04:00
committed by GitHub
parent eb21b5826a
commit 83b3e9e15a
10 changed files with 60 additions and 69 deletions

View File

@@ -2,7 +2,7 @@
using System.Linq; using System.Linq;
using Content.Server.Ghost.Roles; using Content.Server.Ghost.Roles;
using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind.Commands; using Content.Server.Mind;
using Content.Server.Roles; using Content.Server.Roles;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
@@ -339,7 +339,7 @@ public sealed partial class MindTests
var entMan = server.ResolveDependency<IServerEntityManager>(); var entMan = server.ResolveDependency<IServerEntityManager>();
var playerMan = server.ResolveDependency<IPlayerManager>(); var playerMan = server.ResolveDependency<IPlayerManager>();
var mindSystem = entMan.EntitySysManager.GetEntitySystem<SharedMindSystem>(); var mindSystem = entMan.EntitySysManager.GetEntitySystem<MindSystem>();
EntityUid entity = default!; EntityUid entity = default!;
EntityUid mindId = default!; EntityUid mindId = default!;
@@ -379,7 +379,7 @@ public sealed partial class MindTests
mob = entMan.SpawnEntity(null, new MapCoordinates()); mob = entMan.SpawnEntity(null, new MapCoordinates());
MakeSentientCommand.MakeSentient(mob, entMan); mindSystem.MakeSentient(mob);
mobMindId = mindSystem.CreateMind(player.UserId, "Mindy McThinker the Second"); mobMindId = mindSystem.CreateMind(player.UserId, "Mindy McThinker the Second");
mobMind = entMan.GetComponent<MindComponent>(mobMindId); mobMind = entMan.GetComponent<MindComponent>(mobMindId);

View File

@@ -4,7 +4,6 @@ using Content.Server.Administration.UI;
using Content.Server.Disposal.Tube; using Content.Server.Disposal.Tube;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Server.Ghost.Roles; using Content.Server.Ghost.Roles;
using Content.Server.Mind.Commands;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Prayer; using Content.Server.Prayer;
using Content.Server.Silicons.Laws; using Content.Server.Silicons.Laws;
@@ -16,7 +15,6 @@ using Content.Shared.Configurable;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Hands.Components;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
@@ -458,7 +456,7 @@ namespace Content.Server.Administration.Systems
Text = Loc.GetString("make-sentient-verb-get-data-text"), Text = Loc.GetString("make-sentient-verb-get-data-text"),
Category = VerbCategory.Debug, Category = VerbCategory.Debug,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/sentient.svg.192dpi.png")), 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 Impact = LogImpact.Medium
}; };
args.Verbs.Add(verb); args.Verbs.Add(verb);

View File

@@ -5,7 +5,6 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events; using Content.Server.Ghost.Roles.Events;
using Content.Shared.Ghost.Roles.Raffles; using Content.Shared.Ghost.Roles.Raffles;
using Content.Server.Ghost.Roles.UI; using Content.Server.Ghost.Roles.UI;
using Content.Server.Mind.Commands;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Database; using Content.Shared.Database;
@@ -698,7 +697,7 @@ public sealed class GhostRoleSystem : EntitySystem
RaiseLocalEvent(mob, spawnedEvent); RaiseLocalEvent(mob, spawnedEvent);
if (ghostRole.MakeSentient) if (ghostRole.MakeSentient)
MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech); _mindSystem.MakeSentient(mob, ghostRole.AllowMovement, ghostRole.AllowSpeech);
EnsureComp<MindContainerComponent>(mob); EnsureComp<MindContainerComponent>(mob);
@@ -745,7 +744,7 @@ public sealed class GhostRoleSystem : EntitySystem
} }
if (ghostRole.MakeSentient) if (ghostRole.MakeSentient)
MakeSentientCommand.MakeSentient(uid, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech); _mindSystem.MakeSentient(uid, ghostRole.AllowMovement, ghostRole.AllowSpeech);
GhostRoleInternalCreateMindAndTransfer(args.Player, uid, uid, ghostRole); GhostRoleInternalCreateMindAndTransfer(args.Player, uid, uid, ghostRole);
UnregisterGhostRole((uid, ghostRole)); UnregisterGhostRole((uid, ghostRole));

View File

@@ -1,63 +1,30 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.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; 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)] [Dependency] private readonly MindSystem _mindSystem = default!;
public sealed class MakeSentientCommand : IConsoleCommand
public override string Command => "makesentient";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
[Dependency] private readonly IEntityManager _entManager = default!; if (args.Length != 1)
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 void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 1) shell.WriteLine(Loc.GetString("shell-need-exactly-one-argument"));
{ return;
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);
} }
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); shell.WriteLine(Loc.GetString("shell-could-not-find-entity-with-uid", ("uid", args[0])));
if (allowMovement) return;
{
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);
} }
_mindSystem.MakeSentient(entId.Value);
} }
} }

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Ghost; using Content.Server.Ghost;
using Content.Server.Mind.Commands;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
@@ -349,7 +348,7 @@ public sealed class MindSystem : SharedMindSystem
return; return;
} }
MakeSentientCommand.MakeSentient(target, EntityManager); MakeSentient(target);
TransferTo(mindId, target, ghostCheckOverride: true, mind: mind); TransferTo(mindId, target, ghostCheckOverride: true, mind: mind);
} }
} }

View File

@@ -1,10 +1,7 @@
using Content.Server.Actions; using Content.Server.Actions;
using Content.Server.Humanoid; using Content.Server.Humanoid;
using Content.Server.Inventory; using Content.Server.Inventory;
using Content.Server.Mind.Commands;
using Content.Server.Polymorph.Components; using Content.Server.Polymorph.Components;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Content.Shared.Buckle; using Content.Shared.Buckle;
using Content.Shared.Coordinates; using Content.Shared.Coordinates;
using Content.Shared.Damage; using Content.Shared.Damage;
@@ -210,7 +207,7 @@ public sealed partial class PolymorphSystem : EntitySystem
("child", Identity.Entity(child, EntityManager))), ("child", Identity.Entity(child, EntityManager))),
child); child);
MakeSentientCommand.MakeSentient(child, EntityManager); _mindSystem.MakeSentient(child);
var polymorphedComp = Factory.GetComponent<PolymorphedEntityComponent>(); var polymorphedComp = Factory.GetComponent<PolymorphedEntityComponent>();
polymorphedComp.Parent = uid; polymorphedComp.Parent = uid;

View File

@@ -1,7 +1,7 @@
using Content.Server.Access.Systems; using Content.Server.Access.Systems;
using Content.Server.Humanoid; using Content.Server.Humanoid;
using Content.Server.IdentityManagement; using Content.Server.IdentityManagement;
using Content.Server.Mind.Commands; using Content.Server.Mind;
using Content.Server.PDA; using Content.Server.PDA;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Shared.Access.Components; using Content.Shared.Access.Components;
@@ -41,6 +41,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
[Dependency] private readonly MetaDataSystem _metaSystem = default!; [Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly PdaSystem _pdaSystem = default!; [Dependency] private readonly PdaSystem _pdaSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
/// <summary> /// <summary>
/// Attempts to spawn a player character onto the given station. /// Attempts to spawn a player character onto the given station.
@@ -110,7 +111,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
{ {
DebugTools.Assert(entity is null); DebugTools.Assert(entity is null);
var jobEntity = Spawn(prototype.JobEntity, coordinates); 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. // Make sure custom names get handled, what is gameticker control flow whoopy.
if (loadout != null) if (loadout != null)

View File

@@ -7,7 +7,6 @@ using Content.Server.Humanoid;
using Content.Server.IdentityManagement; using Content.Server.IdentityManagement;
using Content.Server.Inventory; using Content.Server.Inventory;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Mind.Commands;
using Content.Server.NPC; using Content.Server.NPC;
using Content.Server.NPC.HTN; using Content.Server.NPC.HTN;
using Content.Server.NPC.Systems; 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); _popup.PopupEntity(Loc.GetString("zombie-transform", ("target", target)), target, PopupType.LargeCaution);
//Make it sentient if it's an animal or something //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 //Make the zombie not die in the cold. Good for space zombies
if (TryComp<TemperatureComponent>(target, out var tempComp)) if (TryComp<TemperatureComponent>(target, out var tempComp))

View File

@@ -2,15 +2,19 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Emoting;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Humanoid; using Content.Shared.Humanoid;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Movement.Components;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Objectives.Systems; using Content.Shared.Objectives.Systems;
using Content.Shared.Players; using Content.Shared.Players;
using Content.Shared.Speech;
using Content.Shared.Whitelist; using Content.Shared.Whitelist;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -632,6 +636,31 @@ public abstract partial class SharedMindSystem : EntitySystem
return allHumans; 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> /// <summary>

View File

@@ -0,0 +1,2 @@
cmd-makesentient-desc = Makes an entity sentient (able to be controlled by a player).
cmd-makesentient-help = Usage: makesentient <entityUid>