Files
wwdpublic/Content.Client/_CorvaxNext/CrewMedal/CrewMedalSystem.cs
Kill_Me_I_Noobs c26ae6423e [Port] End Screen Medals (#216)
* Medals

* Fixes

(cherry picked from commit f5ac77ab3edee4a2c7d377a8be4f44c44d8a487a)
2025-03-29 16:14:08 +03:00

35 lines
1.2 KiB
C#

using Content.Client._CorvaxNext.CrewMedal.UI;
using Content.Shared._CorvaxNext.CrewMedal;
namespace Content.Client._CorvaxNext.CrewMedal;
/// <summary>
/// Handles the client-side logic for the Crew Medal system.
/// </summary>
public sealed class CrewMedalSystem : SharedCrewMedalSystem
{
[Dependency] private readonly SharedUserInterfaceSystem _userInterfaceSystem = default!;
public override void Initialize()
{
base.Initialize();
// Subscribes to the event triggered after the state is automatically handled.
SubscribeLocalEvent<CrewMedalComponent, AfterAutoHandleStateEvent>(OnCrewMedalAfterState);
}
/// <summary>
/// When an updated state is received on the client, refresh the UI to display the latest data.
/// </summary>
private void OnCrewMedalAfterState(Entity<CrewMedalComponent> entity, ref AfterAutoHandleStateEvent args)
{
// Checks if the Crew Medal UI is open for the given entity and reloads it with updated data.
if (_userInterfaceSystem.TryGetOpenUi<CrewMedalBoundUserInterface>(
entity.Owner,
CrewMedalUiKey.Key,
out var medalUi))
{
medalUi.Reload();
}
}
}