Sentry turrets - Part 6: Sentry turret control panels (#35235)

This commit is contained in:
chromiumboy
2025-05-26 08:00:50 -05:00
committed by GitHub
parent 32ffbbfb0f
commit f99850e1fb
18 changed files with 1511 additions and 66 deletions

View File

@@ -0,0 +1,44 @@
using Content.Shared.Access;
using Content.Shared.TurretController;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
namespace Content.Client.TurretController;
public sealed class TurretControllerWindowBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[ViewVariables]
private TurretControllerWindow? _window;
protected override void Open()
{
base.Open();
_window = this.CreateWindow<TurretControllerWindow>();
_window.SetOwner(Owner);
_window.OpenCentered();
_window.OnAccessLevelsChangedEvent += OnAccessLevelChanged;
_window.OnArmamentSettingChangedEvent += OnArmamentSettingChanged;
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not DeployableTurretControllerBoundInterfaceState { } castState)
return;
_window?.UpdateState(castState);
}
private void OnAccessLevelChanged(HashSet<ProtoId<AccessLevelPrototype>> accessLevels, bool enabled)
{
SendPredictedMessage(new DeployableTurretExemptAccessLevelChangedMessage(accessLevels, enabled));
}
private void OnArmamentSettingChanged(TurretControllerWindow.TurretArmamentSetting setting)
{
SendPredictedMessage(new DeployableTurretArmamentSettingChangedMessage((int)setting));
}
}