-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create AICameraListBoundUserInterface.cs
- Loading branch information
1 parent
a2bb727
commit c7fa3f5
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / build (ubuntu-latest)
Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs GitHub Actions / YAML Linter
Check failure on line 11 in Content.Client/ADT/Content.Client/Backmen/StationAI/UI/AICameraListBoundUserInterface.cs GitHub Actions / YAML Linter
|
||
|
||
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(); | ||
} | ||
} |