Files
OldThink/Content.Client/CharacterInfo/CharacterInfoSystem.cs
Aviu00 16c8b95da4 Economy (#403)
* nasrano

* Add station budget & salary

* Initial balance

* Vending machine UI

* Pricing for vending machines

* Finish economy

* Eftpos

* Finish eftpos

* Put eftpos into lockers

* Vending machine prices

* Small fixes

* Fix atm UI

* Add atms to maps

* fix

* reset

* Add PDA program

* Maps again

---------

Co-authored-by: Mona Hmiza <>
Co-authored-by: rhailrake <49613070+rhailrake@users.noreply.github.com>
2024-01-24 13:04:22 +03:00

67 lines
1.9 KiB
C#

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<CharacterData>? OnCharacterUpdate;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<CharacterInfoEvent>(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), msg.Memory);
OnCharacterUpdate?.Invoke(data);
}
public List<Control> 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<string, List<ObjectiveInfo>> Objectives,
string? Briefing,
string EntityName,
Dictionary<string, string> Memory
);
/// <summary>
/// Event raised to get additional controls to display in the character info menu.
/// </summary>
[ByRefEvent]
public readonly record struct GetCharacterInfoControlsEvent(EntityUid Entity)
{
public readonly List<Control> Controls = new();
public readonly EntityUid Entity = Entity;
}
}