Refactor minds to be entities with components, make roles components (#19591)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
@@ -11,7 +10,7 @@ namespace Content.Server.Objectives.Commands
|
||||
public sealed class RemoveObjectiveCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
|
||||
public string Command => "rmobjective";
|
||||
public string Description => "Removes an objective from the player's mind.";
|
||||
public string Help => "rmobjective <username> <index>";
|
||||
@@ -24,30 +23,29 @@ namespace Content.Server.Objectives.Commands
|
||||
}
|
||||
|
||||
var mgr = IoCManager.Resolve<IPlayerManager>();
|
||||
if (mgr.TryGetPlayerDataByUsername(args[0], out var data))
|
||||
var minds = _entityManager.System<MindSystem>();
|
||||
if (!mgr.TryGetSessionByUsername(args[0], out var session))
|
||||
{
|
||||
var mind = data.ContentData()?.Mind;
|
||||
if (mind == null)
|
||||
{
|
||||
shell.WriteLine("Can't find the mind.");
|
||||
return;
|
||||
}
|
||||
shell.WriteLine("Can't find the playerdata.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(args[1], out var i))
|
||||
{
|
||||
var mindSystem = _entityManager.System<MindSystem>();
|
||||
shell.WriteLine(mindSystem.TryRemoveObjective(mind, i)
|
||||
? "Objective successfully removed!"
|
||||
: "Objective removing failed. Maybe the index is out of bounds? Check lsobjectives!");
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteLine($"Invalid index {args[1]}!");
|
||||
}
|
||||
if (!minds.TryGetMind(session, out _, out var mind))
|
||||
{
|
||||
shell.WriteLine("Can't find the mind.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(args[1], out var i))
|
||||
{
|
||||
var mindSystem = _entityManager.System<MindSystem>();
|
||||
shell.WriteLine(mindSystem.TryRemoveObjective(mind, i)
|
||||
? "Objective successfully removed!"
|
||||
: "Objective removing failed. Maybe the index is out of bounds? Check lsobjectives!");
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteLine("Can't find the playerdata.");
|
||||
shell.WriteLine($"Invalid index {args[1]}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user