using Content.Shared.CharacterInfo; using Content.Shared.Objectives; using Robust.Client.Player; using Robust.Client.UserInterface; namespace Content.Client.CharacterInfo; public sealed class CharacterInfoSystem : EntitySystem { [Dependency] private readonly IPlayerManager _players = default!; public event Action? OnCharacterUpdate; public override void Initialize() { base.Initialize(); SubscribeNetworkEvent(OnCharacterInfoEvent); } public void RequestCharacterInfo() { var entity = _players.LocalPlayer?.ControlledEntity; if (entity == null) { return; } RaiseNetworkEvent(new RequestCharacterInfoEvent(GetNetEntity(entity.Value))); } private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args) { var entity = GetEntity(msg.NetEntity); var data = new CharacterData(entity, msg.JobTitle, msg.Objectives, msg.Briefing, Name(entity)); OnCharacterUpdate?.Invoke(data); } public List GetCharacterInfoControls(EntityUid uid) { var ev = new GetCharacterInfoControlsEvent(uid); RaiseLocalEvent(uid, ref ev, true); return ev.Controls; } public readonly record struct CharacterData( EntityUid Entity, string Job, Dictionary> Objectives, string? Briefing, string EntityName ); /// /// Event raised to get additional controls to display in the character info menu. /// [ByRefEvent] public readonly record struct GetCharacterInfoControlsEvent(EntityUid Entity) { public readonly List Controls = new(); public readonly EntityUid Entity = Entity; } }