Files
tbd-station-14/Content.Client/GameObjects/Components/Body/Scanner/BodyScannerBoundUserInterface.cs
Exp 920f3a999b Communications Console & Medical Scanner now close when too far away (#2175)
-Wire & GasAnalyzer dispose instead of closing only
2020-10-06 10:16:42 +02:00

60 lines
1.6 KiB
C#

using System.Collections.Generic;
using Content.Shared.Body.Scanner;
using JetBrains.Annotations;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Body.Scanner
{
[UsedImplicitly]
public class BodyScannerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private BodyScannerDisplay _display;
[ViewVariables]
private BodyScannerTemplateData _template;
[ViewVariables]
private Dictionary<string, BodyScannerBodyPartData> _parts;
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
protected override void Open()
{
base.Open();
_display = new BodyScannerDisplay(this);
_display.OnClose += Close;
_display.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (!(state is BodyScannerInterfaceState scannerState))
{
return;
}
_template = scannerState.Template;
_parts = scannerState.Parts;
_display.UpdateDisplay(_template, _parts);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_display?.Dispose();
_template = null;
_parts.Clear();
}
}
}
}