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,5 +1,6 @@
using Content.Server.Mind.Components;
using Content.Server.Mind;
using Content.Server.Roles;
using Content.Server.Roles.Jobs;
using Content.Shared.CharacterInfo;
using Content.Shared.Objectives;
@@ -7,6 +8,10 @@ namespace Content.Server.CharacterInfo;
public sealed class CharacterInfoSystem : EntitySystem
{
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly RoleSystem _roles = default!;
public override void Initialize()
{
base.Initialize();
@@ -25,10 +30,8 @@ public sealed class CharacterInfoSystem : EntitySystem
var conditions = new Dictionary<string, List<ConditionInfo>>();
var jobTitle = "No Profession";
var briefing = "!!ERROR: No Briefing!!"; //should never show on the UI unless there's an issue
if (TryComp<MindContainerComponent>(entity, out var mindContainerComponent) && mindContainerComponent.Mind != null)
if (_minds.TryGetMind(entity, out var mindId, out var mind))
{
var mind = mindContainerComponent.Mind;
// Get objectives
foreach (var objective in mind.AllObjectives)
{
@@ -41,17 +44,11 @@ public sealed class CharacterInfoSystem : EntitySystem
}
}
// Get job title
foreach (var role in mind.AllRoles)
{
if (role.GetType() != typeof(Job)) continue;
jobTitle = role.Name;
break;
}
if (_jobs.MindTryGetJobName(mindId, out var jobName))
jobTitle = jobName;
// Get briefing
briefing = mind.Briefing;
briefing = _roles.MindGetBriefing(mindId) ?? string.Empty;
}
RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession);