diff --git a/Content.Server/Mind/Commands/MakeSentientCommand.cs b/Content.Server/Mind/Commands/MakeSentientCommand.cs index 24bde8032d..ff0ea4ecd4 100644 --- a/Content.Server/Mind/Commands/MakeSentientCommand.cs +++ b/Content.Server/Mind/Commands/MakeSentientCommand.cs @@ -28,40 +28,35 @@ namespace Content.Server.Mind.Commands return; } - if (!int.TryParse(args[0], out var id)) + if (!EntityUid.TryParse(args[0], out var entId)) { shell.WriteLine("Invalid argument."); return; } - var entId = new EntityUid(id); - var entityManager = IoCManager.Resolve(); - if (!entityManager.TryGetEntity(entId, out var entity) || entity.Deleted) + if (!entityManager.EntityExists(entId)) { shell.WriteLine("Invalid entity specified!"); return; } - MakeSentient(entity); + MakeSentient(entId, entityManager); } - public static void MakeSentient(IEntity entity) + public static void MakeSentient(EntityUid uid, IEntityManager entityManager) { - if(entity.HasComponent()) - entity.RemoveComponent(); + if(entityManager.HasComponent(uid)) + entityManager.RemoveComponent(uid); - // Delay spawning these components to avoid race conditions with the deferred removal of AiController. - Timer.Spawn(100, () => - { - entity.EnsureComponent(); - entity.EnsureComponent(); - entity.EnsureComponent(); - entity.EnsureComponent(); - entity.EnsureComponent(); - entity.EnsureComponent(); - }); + + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); } } }