mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using Content.Client.Implants.UI;
|
|
using Content.Client.Items;
|
|
using Content.Shared.Implants;
|
|
using Content.Shared.Implants.Components;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Implants;
|
|
|
|
public sealed partial class ImplanterSystem : SharedImplanterSystem
|
|
{
|
|
[Dependency] private SharedUserInterfaceSystem _uiSystem = default!;
|
|
[Dependency] private IPrototypeManager _proto = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ImplanterComponent, AfterAutoHandleStateEvent>(OnHandleImplanterState);
|
|
Subs.ItemStatus<ImplanterComponent>(ent => new ImplanterStatusControl(ent));
|
|
}
|
|
|
|
private void OnHandleImplanterState(EntityUid uid, ImplanterComponent component, ref AfterAutoHandleStateEvent args)
|
|
{
|
|
if (_uiSystem.TryGetOpenUi<DeimplantBoundUserInterface>(uid, DeimplantUiKey.Key, out var bui))
|
|
{
|
|
// TODO: Don't use protoId for deimplanting
|
|
// and especially not raw strings!
|
|
Dictionary<string, string> implants = new();
|
|
foreach (var implant in component.DeimplantWhitelist)
|
|
{
|
|
if (_proto.Resolve(implant, out var proto))
|
|
implants.Add(proto.ID, proto.Name);
|
|
}
|
|
|
|
bui.UpdateState(implants, component.DeimplantChosen);
|
|
}
|
|
|
|
component.UiUpdateNeeded = true;
|
|
}
|
|
}
|