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,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Mind;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
@@ -10,39 +10,38 @@ namespace Content.Server.Objectives.Commands
|
||||
[AdminCommand(AdminFlags.Logs)]
|
||||
public sealed class ListObjectivesCommand : LocalizedCommands
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
[Dependency] private readonly IPlayerManager _players = default!;
|
||||
|
||||
public override string Command => "lsobjectives";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
IPlayerData? data;
|
||||
if (args.Length == 0 && player != null)
|
||||
{
|
||||
data = player.Data;
|
||||
}
|
||||
else if (player == null || !IoCManager.Resolve<IPlayerManager>().TryGetPlayerDataByUsername(args[0], out data))
|
||||
if (player == null || !_players.TryGetSessionByUsername(args[0], out player))
|
||||
{
|
||||
shell.WriteError(LocalizationManager.GetString("shell-target-player-does-not-exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = data.ContentData()?.Mind;
|
||||
if (mind == null)
|
||||
var minds = _entities.System<MindSystem>();
|
||||
if (!minds.TryGetMind(player, out _, out var mind))
|
||||
{
|
||||
shell.WriteError(LocalizationManager.GetString("shell-target-entity-does-not-have-message", ("missing", "mind")));
|
||||
return;
|
||||
}
|
||||
|
||||
shell.WriteLine($"Objectives for player {data.UserId}:");
|
||||
shell.WriteLine($"Objectives for player {player.UserId}:");
|
||||
var objectives = mind.AllObjectives.ToList();
|
||||
if (objectives.Count == 0)
|
||||
{
|
||||
shell.WriteLine("None.");
|
||||
}
|
||||
|
||||
for (var i = 0; i < objectives.Count; i++)
|
||||
{
|
||||
shell.WriteLine($"- [{i}] {objectives[i].Conditions[0].Title}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
|
||||
Reference in New Issue
Block a user