Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -6,18 +6,19 @@ namespace Content.Client.SurveillanceCamera.UI;
public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly EyeLerpingSystem _eyeLerpingSystem;
private readonly SurveillanceCameraMonitorSystem _surveillanceCameraMonitorSystem;
[ViewVariables]
private SurveillanceCameraMonitorWindow? _window;
[ViewVariables]
private EntityUid? _currentCamera;
public SurveillanceCameraMonitorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
public SurveillanceCameraMonitorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_eyeLerpingSystem = _entityManager.EntitySysManager.GetEntitySystem<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = _entityManager.EntitySysManager.GetEntitySystem<SurveillanceCameraMonitorSystem>();
_eyeLerpingSystem = EntMan.System<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = EntMan.System<SurveillanceCameraMonitorSystem>();
}
protected override void Open()
@@ -54,7 +55,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
private void OnCameraSwitchTimer()
{
_surveillanceCameraMonitorSystem.AddTimer(Owner.Owner, _window!.OnSwitchTimerComplete);
_surveillanceCameraMonitorSystem.AddTimer(Owner, _window!.OnSwitchTimerComplete);
}
private void OnCameraRefresh()
@@ -85,7 +86,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
if (_currentCamera != null)
{
_surveillanceCameraMonitorSystem.RemoveTimer(Owner.Owner);
_surveillanceCameraMonitorSystem.RemoveTimer(Owner);
_eyeLerpingSystem.RemoveEye(_currentCamera.Value);
_currentCamera = null;
}
@@ -104,7 +105,7 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter
_currentCamera = cast.ActiveCamera;
}
if (_entityManager.TryGetComponent(cast.ActiveCamera, out EyeComponent? eye))
if (EntMan.TryGetComponent<EyeComponent>(cast.ActiveCamera, out var eye))
{
_window.UpdateState(eye.Eye, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras);
}

View File

@@ -5,15 +5,16 @@ namespace Content.Client.SurveillanceCamera.UI;
public sealed class SurveillanceCameraSetupBoundUi : BoundUserInterface
{
private SurveillanceCameraSetupWindow? _window;
private SurveillanceCameraSetupUiKey _type;
[ViewVariables]
private readonly SurveillanceCameraSetupUiKey _type;
public SurveillanceCameraSetupBoundUi(ClientUserInterfaceComponent component, Enum uiKey) : base(component, uiKey)
[ViewVariables]
private SurveillanceCameraSetupWindow? _window;
public SurveillanceCameraSetupBoundUi(EntityUid component, Enum uiKey) : base(component, uiKey)
{
if (uiKey is not SurveillanceCameraSetupUiKey key)
{
return;
}
_type = key;
}