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,12 +1,11 @@
using Content.Server.Administration;
using Content.Server.Players;
using Content.Server.Roles.Jobs;
using Content.Shared.Administration;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
using System.Linq;
using Content.Server.Mind;
namespace Content.Server.Roles
{
@@ -14,7 +13,7 @@ namespace Content.Server.Roles
public sealed class AddRoleCommand : IConsoleCommand
{
[Dependency] private readonly EntityManager _entityManager = default!;
public string Command => "addrole";
public string Description => "Adds a role to a player's mind.";
@@ -50,15 +49,14 @@ namespace Content.Server.Roles
return;
}
if (mind.AllRoles.Any(r => r.Name == jobPrototype.Name))
var jobs = _entityManager.System<JobSystem>();
if (jobs.MindHasJobWithId(mind, jobPrototype.Name))
{
shell.WriteLine("Mind already has that role");
return;
}
var role = new Job(mind, jobPrototype);
var mindSystem = _entityManager.System<MindSystem>();
mindSystem.AddRole(mind, role);
jobs.MindAddJob(mind.Value, args[1]);
}
}
}