Skip to content

Commit

Permalink
Create AICameraListBoundUserInterface.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Nov 21, 2023
1 parent a2bb727 commit c7fa3f5
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Content.Shared.ADT.StationAI.Events;

namespace Content.Client.ADT.StationAI.UI;

/// <summary>
/// Initializes a <see cref="AICameraList"/> and updates it when new server messages are received.
/// </summary>
public sealed class AICameraListBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private AICameraList _window = new AICameraList();

Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'AICameraList' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'AICameraList' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'AICameraList' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'AICameraList' could not be found (are you missing a using directive or an assembly reference?)

public AICameraListBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
var netId = _entityManager.GetNetEntity(owner);
_window.TryUpdateCameraList += () => SendMessage(new AICameraListMessage(netId));
_window.WarpToCamera += (uid) => SendMessage(new AICameraWarpMessage(netId, _entityManager.GetNetEntity(uid)));
}

protected override void Open()
{
base.Open();

if (State != null) UpdateState(State);

_window.OpenCentered();
}

/// <summary>
/// Update the UI state based on server-sent info
/// </summary>
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (_window == null || state is not AIBoundUserInterfaceState cast)
return;

_window.UpdateCameraList(_entityManager.GetEntityList(cast.Cameras));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_window.Dispose();
}
}

0 comments on commit c7fa3f5

Please sign in to comment.