mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Cleanup surveillance camera viewer lifecycle (bugfix for mothership core console) (#45928)
* SurveillanceCameraMonitorSystem: add on BUIOpen * AfterOpenUserInterface is kill
This commit is contained in:
parent
b9b794deef
commit
e79071dd58
1 changed files with 6 additions and 23 deletions
|
|
@ -4,10 +4,8 @@ using Content.Shared.DeviceNetwork;
|
|||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.UserInterface;
|
||||
using Content.Shared.SurveillanceCamera;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.SurveillanceCamera;
|
||||
|
|
@ -26,7 +24,6 @@ public sealed partial class SurveillanceCameraMonitorSystem : EntitySystem
|
|||
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, ComponentStartup>(OnComponentStartup);
|
||||
SubscribeLocalEvent<SurveillanceCameraMonitorComponent, AfterActivatableUIOpenEvent>(OnToggleInterface);
|
||||
Subs.BuiEvents<SurveillanceCameraMonitorComponent>(SurveillanceCameraMonitorUiKey.Key, subs =>
|
||||
{
|
||||
subs.Event<SurveillanceCameraRefreshCamerasMessage>(OnRefreshCamerasMessage);
|
||||
|
|
@ -35,6 +32,7 @@ public sealed partial class SurveillanceCameraMonitorSystem : EntitySystem
|
|||
subs.Event<SurveillanceCameraMonitorSubnetRequestMessage>(OnSubnetRequest);
|
||||
subs.Event<SurveillanceCameraMonitorSwitchMessage>(OnSwitchMessage);
|
||||
subs.Event<BoundUIClosedEvent>(OnBoundUiClose);
|
||||
subs.Event<BoundUIOpenedEvent>(OnBoundUiOpen);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -183,19 +181,17 @@ public sealed partial class SurveillanceCameraMonitorSystem : EntitySystem
|
|||
RemoveActiveCamera(uid, component);
|
||||
}
|
||||
|
||||
|
||||
private void OnToggleInterface(EntityUid uid, SurveillanceCameraMonitorComponent component,
|
||||
AfterActivatableUIOpenEvent args)
|
||||
{
|
||||
AfterOpenUserInterface(uid, args.User, component);
|
||||
}
|
||||
|
||||
// This is to ensure that there's no delay in ensuring that a camera is deactivated.
|
||||
private void OnSurveillanceCameraDeactivate(EntityUid uid, SurveillanceCameraMonitorComponent monitor, SurveillanceCameraDeactivateEvent args)
|
||||
{
|
||||
DisconnectCamera(uid, false, monitor);
|
||||
}
|
||||
|
||||
private void OnBoundUiOpen(EntityUid uid, SurveillanceCameraMonitorComponent component, BoundUIOpenedEvent args)
|
||||
{
|
||||
AddViewer(uid, args.Actor, component);
|
||||
}
|
||||
|
||||
private void OnBoundUiClose(EntityUid uid, SurveillanceCameraMonitorComponent component, BoundUIClosedEvent args)
|
||||
{
|
||||
RemoveViewer(uid, args.Actor, component);
|
||||
|
|
@ -445,19 +441,6 @@ public sealed partial class SurveillanceCameraMonitorSystem : EntitySystem
|
|||
UpdateUserInterface(uid, monitor);
|
||||
}
|
||||
|
||||
// This is public primarily because it might be useful to have the ability to
|
||||
// have this component added to any entity, and have them open the BUI (somehow).
|
||||
public void AfterOpenUserInterface(EntityUid uid, EntityUid player, SurveillanceCameraMonitorComponent? monitor = null, ActorComponent? actor = null)
|
||||
{
|
||||
if (!Resolve(uid, ref monitor)
|
||||
|| !Resolve(player, ref actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddViewer(uid, player);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface(EntityUid uid, SurveillanceCameraMonitorComponent? monitor = null, EntityUid? player = null)
|
||||
{
|
||||
if (!Resolve(uid, ref monitor))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue