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:
DrSmugleaf
2023-08-28 16:53:24 -07:00
committed by GitHub
parent e0ee397af7
commit 15c0211fb2
119 changed files with 1445 additions and 1289 deletions

View File

@@ -1,6 +1,6 @@
using System.Text;
using Content.Server.Administration;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
@@ -10,10 +10,10 @@ namespace Content.Server.Mind.Commands
[AdminCommand(AdminFlags.Admin)]
public sealed class MindInfoCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "mindinfo";
public string Description => "Lists info for the mind of a specific player.";
public string Help => "mindinfo <session ID>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
@@ -25,15 +25,14 @@ namespace Content.Server.Mind.Commands
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetSessionByUsername(args[0], out var data))
if (!mgr.TryGetSessionByUsername(args[0], out var session))
{
shell.WriteLine("Can't find that mind");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
var minds = _entities.System<MindSystem>();
if (!minds.TryGetMind(session, out var mindId, out var mind))
{
shell.WriteLine("Can't find that mind");
return;
@@ -41,7 +40,9 @@ namespace Content.Server.Mind.Commands
var builder = new StringBuilder();
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedEntity);
foreach (var role in mind.AllRoles)
var roles = _entities.System<RoleSystem>();
foreach (var role in roles.MindGetAllRoles(mindId))
{
builder.AppendFormat("{0} ", role.Name);
}