2023-08-28 16:53:24 -07:00
|
|
|
|
using Content.Server.Mind;
|
2021-12-11 15:12:55 -08:00
|
|
|
|
using Content.Server.Roles;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
using Content.Server.Roles.Jobs;
|
2021-12-11 15:12:55 -08:00
|
|
|
|
using Content.Shared.CharacterInfo;
|
|
|
|
|
|
using Content.Shared.Objectives;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.CharacterInfo;
|
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class CharacterInfoSystem : EntitySystem
|
2021-12-11 15:12:55 -08:00
|
|
|
|
{
|
2023-08-28 16:53:24 -07:00
|
|
|
|
[Dependency] private readonly JobSystem _jobs = default!;
|
|
|
|
|
|
[Dependency] private readonly MindSystem _minds = default!;
|
|
|
|
|
|
[Dependency] private readonly RoleSystem _roles = default!;
|
|
|
|
|
|
|
2021-12-11 15:12:55 -08:00
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeNetworkEvent<RequestCharacterInfoEvent>(OnRequestCharacterInfoEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnRequestCharacterInfoEvent(RequestCharacterInfoEvent msg, EntitySessionEventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!args.SenderSession.AttachedEntity.HasValue
|
|
|
|
|
|
|| args.SenderSession.AttachedEntity != msg.EntityUid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var entity = args.SenderSession.AttachedEntity.Value;
|
|
|
|
|
|
|
|
|
|
|
|
var conditions = new Dictionary<string, List<ConditionInfo>>();
|
|
|
|
|
|
var jobTitle = "No Profession";
|
2023-08-31 22:29:45 +01:00
|
|
|
|
string? briefing = null;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (_minds.TryGetMind(entity, out var mindId, out var mind))
|
2021-12-11 15:12:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
// 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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-28 16:53:24 -07:00
|
|
|
|
if (_jobs.MindTryGetJobName(mindId, out var jobName))
|
|
|
|
|
|
jobTitle = jobName;
|
2022-02-16 00:23:23 -07:00
|
|
|
|
|
2022-01-05 00:46:40 -05:00
|
|
|
|
// Get briefing
|
2023-08-31 22:29:45 +01:00
|
|
|
|
briefing = _roles.MindGetBriefing(mindId);
|
2021-12-11 15:12:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-22 13:49:48 +13:00
|
|
|
|
RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession);
|
2021-12-11 15:12:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|