2022-11-20 01:49:37 -05:00
|
|
|
|
using Content.Client.Implants.UI;
|
|
|
|
|
|
using Content.Client.Items;
|
|
|
|
|
|
using Content.Shared.Implants;
|
|
|
|
|
|
using Content.Shared.Implants.Components;
|
2025-02-27 18:57:28 +01:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2022-11-20 01:49:37 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Implants;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed class ImplanterSystem : SharedImplanterSystem
|
|
|
|
|
|
{
|
2025-02-27 18:57:28 +01:00
|
|
|
|
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
|
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
|
|
|
|
|
2022-11-20 01:49:37 -05:00
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
SubscribeLocalEvent<ImplanterComponent, AfterAutoHandleStateEvent>(OnHandleImplanterState);
|
2024-01-12 01:14:13 +01:00
|
|
|
|
Subs.ItemStatus<ImplanterComponent>(ent => new ImplanterStatusControl(ent));
|
2022-11-20 01:49:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
|
private void OnHandleImplanterState(EntityUid uid, ImplanterComponent component, ref AfterAutoHandleStateEvent args)
|
2022-11-20 01:49:37 -05:00
|
|
|
|
{
|
2025-02-27 18:57:28 +01:00
|
|
|
|
if (_uiSystem.TryGetOpenUi<DeimplantBoundUserInterface>(uid, DeimplantUiKey.Key, out var bui))
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<string, string> implants = new();
|
|
|
|
|
|
foreach (var implant in component.DeimplantWhitelist)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_proto.TryIndex(implant, out var proto))
|
|
|
|
|
|
implants.Add(proto.ID, proto.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bui.UpdateState(implants, component.DeimplantChosen);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-20 01:49:37 -05:00
|
|
|
|
component.UiUpdateNeeded = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|