Files
tbd-station-14/Content.Client/GameObjects/Components/Body/Scanner/BodyScannerBoundUserInterface.cs
DrSmugleaf 06b1939a60 Update usages of ! is with is not (#2584)
* Update usages of ! is with is not

* Content.IntegrationTests commit

* Content.Server commit

* Content.Shared commit

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2020-11-27 00:33:31 +11:00

58 lines
1.7 KiB
C#

using System;
using Content.Shared.GameObjects.Components.Body.Scanner;
using JetBrains.Annotations;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Body.Scanner
{
[UsedImplicitly]
public class BodyScannerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private BodyScannerDisplay _display;
[ViewVariables]
private IEntity _entity;
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 not BodyScannerUIState scannerState)
{
return;
}
if (!Owner.Owner.EntityManager.TryGetEntity(scannerState.Uid, out _entity))
{
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner.Uid} at {Owner.Owner.Transform.MapPosition}");
}
_display.UpdateDisplay(_entity);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_display?.Dispose();
}
}
}
}