Objectives ecs rework (#19967)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-16 07:18:10 +01:00
committed by GitHub
parent e8c58d1574
commit f7711edbe3
106 changed files with 2121 additions and 1779 deletions

View File

@@ -3,6 +3,8 @@ using Content.Server.Roles;
using Content.Server.Roles.Jobs;
using Content.Shared.CharacterInfo;
using Content.Shared.Objectives;
using Content.Shared.Objectives.Components;
using Content.Shared.Objectives.Systems;
namespace Content.Server.CharacterInfo;
@@ -11,6 +13,7 @@ public sealed class CharacterInfoSystem : EntitySystem
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly RoleSystem _roles = default!;
[Dependency] private readonly SharedObjectivesSystem _objectives = default!;
public override void Initialize()
{
@@ -27,7 +30,7 @@ public sealed class CharacterInfoSystem : EntitySystem
var entity = args.SenderSession.AttachedEntity.Value;
var conditions = new Dictionary<string, List<ConditionInfo>>();
var objectives = new Dictionary<string, List<ObjectiveInfo>>();
var jobTitle = "No Profession";
string? briefing = null;
if (_minds.TryGetMind(entity, out var mindId, out var mind))
@@ -35,13 +38,15 @@ public sealed class CharacterInfoSystem : EntitySystem
// Get objectives
foreach (var objective in mind.AllObjectives)
{
if (!conditions.ContainsKey(objective.Prototype.Issuer))
conditions[objective.Prototype.Issuer] = new List<ConditionInfo>();
foreach (var condition in objective.Conditions)
{
conditions[objective.Prototype.Issuer].Add(new ConditionInfo(condition.Title,
condition.Description, condition.Icon, condition.Progress));
}
var info = _objectives.GetInfo(objective, mindId, mind);
if (info == null)
continue;
// group objectives by their issuer
var issuer = Comp<ObjectiveComponent>(objective).Issuer;
if (!objectives.ContainsKey(issuer))
objectives[issuer] = new List<ObjectiveInfo>();
objectives[issuer].Add(info.Value);
}
if (_jobs.MindTryGetJobName(mindId, out var jobName))
@@ -51,6 +56,6 @@ public sealed class CharacterInfoSystem : EntitySystem
briefing = _roles.MindGetBriefing(mindId);
}
RaiseNetworkEvent(new CharacterInfoEvent(GetNetEntity(entity), jobTitle, conditions, briefing), args.SenderSession);
RaiseNetworkEvent(new CharacterInfoEvent(GetNetEntity(entity), jobTitle, objectives, briefing), args.SenderSession);
}
}