Surveillance cameras (#8246)
* cameras but i didn't feel like git stashing them
* Adds more functionality server-side for surveillance cameras
* rider moment
* Adds skeleton for SurveillanceCameraMonitorBoundUi on client
* whoops
* makes surveillance camera monitor UI more defined
* removes tree from SurveillanceCameraMonitorWindow
* surveillance camera active flag, other routing things
* actually sets how SurveillanceCameraMonitorSystem sends camera info to clients
* adds entity yaml, changes field
* adds the camera/monitor entities, makes the UI open
* SurveillanceCameraRouters (not implemented fully)
* subnets for cameras, server-side
* it works!
* fixes rotation in cameras
* whoops
restores surveillance cameras to ignored components
makes it so that switching cameras now lerps the other camera
* makes the UI work
* makes it so that cameras actually refresh now
* cleanup
* adds camera.rsi
* cleans up prototypes a bit
* adds camera subnet frequencies, cameras in subnets
* adds surveillance camera router subnets
* might fix testing errors
* adds the circuit board to the surveillance camera monitor
* fixes up the camera monitor (the detective will get his tv soon)
* adds heartbeat, ensures subnet data is passed into cameras to send
* fixes up a few things
* whoops
* changes to UI internals
* fixes subnet selection issue
* localized strings for UI
* changes 'test' id to 'camera' for cameras
* whoops
* missing s
* camera static!
* adds a delay to camera switching
* adjusts a few things in camera timing
* adds setup for cameras/routers, localization for frequency names
* adds setup ui for routers, makes subnet names in monitor window follow frequency name in prototype
* localization, some cleanup
* ui adjustments
* adds surveillance camera visuals
* fixes a bug when closing the UI for monitors
* adds disconnect message to UI
* adds construction graph to cameras
* adds the camera to the construction menu
* fixes network selection for setup, tweak to assembly
* adds surveillance camera router construction, fixes up surveillance camera wire cutting
* adds disconnect button to monitor UI
* switches around the status text
* tweaks monitor UI
* makes the address actually show
* might make tests pass
* UI adjustments, hard name limit
* ok, that didn't work
* adds wireless cameras
* makes the television work/look nicer
* adds tripod cameras in addition to mobile cameras
* makes wireless cameras constructable
* fixes up those prototypes
* reorganization in C#, small cleanup
* ensures that power changes deactivate some devices
* adds a component to the television, comments out a function
* actually, never mind, i forgot that wireless cameras existed/are creatable for a second
* tweaks to router construction, removes SubnetTest from prototypes
* removes it from frequencies too
* Apply suggestions from code review
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
* type serializers into components
* setup window opens centered, enum is now byte
* replaces active monitor list with ActiveSurveillanceCameraMonitorComponent
* adds paused/deleted entity checks, changes how verbs are given
* removes EntitySystem.Get<T>() references
* fixes bug related to selecting network from setup, alphabet-orders network listing in setup
* rider moment
* adds minwidth to surveillance camera setup window
* addresses reviews
* should fix the issue with camera visuals not updating properly
* addresses some reviews
* addresses further review
* addresses reviews related to RSIs
* never needed a key there anyways
* changes a few things with routers to ensure that they're active
* whoops
* ensurecomp over addcomp
* whoops
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-05-31 01:44:57 -07:00
|
|
|
using Content.Server.Administration.Managers;
|
|
|
|
|
using Content.Server.DeviceNetwork;
|
|
|
|
|
using Content.Server.DeviceNetwork.Components;
|
|
|
|
|
using Content.Server.DeviceNetwork.Systems;
|
|
|
|
|
using Content.Server.Ghost.Components;
|
|
|
|
|
using Content.Server.Power.Components;
|
|
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
using Content.Shared.DeviceNetwork;
|
|
|
|
|
using Content.Shared.SurveillanceCamera;
|
|
|
|
|
using Content.Shared.Verbs;
|
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.SurveillanceCamera;
|
|
|
|
|
|
|
|
|
|
public sealed class SurveillanceCameraRouterSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
|
|
|
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
SubscribeLocalEvent<SurveillanceCameraRouterComponent, ComponentInit>(OnInitialize);
|
|
|
|
|
SubscribeLocalEvent<SurveillanceCameraRouterComponent, DeviceNetworkPacketEvent>(OnPacketReceive);
|
|
|
|
|
SubscribeLocalEvent<SurveillanceCameraRouterComponent, SurveillanceCameraSetupSetNetwork>(OnSetNetwork);
|
|
|
|
|
SubscribeLocalEvent<SurveillanceCameraRouterComponent, GetVerbsEvent<AlternativeVerb>>(AddVerbs);
|
|
|
|
|
SubscribeLocalEvent<SurveillanceCameraRouterComponent, PowerChangedEvent>(OnPowerChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInitialize(EntityUid uid, SurveillanceCameraRouterComponent router, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
if (router.SubnetFrequencyId == null ||
|
|
|
|
|
!_prototypeManager.TryIndex(router.SubnetFrequencyId, out DeviceFrequencyPrototype? subnetFrequency))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
router.SubnetFrequency = subnetFrequency.Frequency;
|
|
|
|
|
router.Active = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPacketReceive(EntityUid uid, SurveillanceCameraRouterComponent router, DeviceNetworkPacketEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!router.Active
|
|
|
|
|
|| string.IsNullOrEmpty(args.SenderAddress)
|
|
|
|
|
|| !args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? command))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (command)
|
|
|
|
|
{
|
|
|
|
|
case SurveillanceCameraSystem.CameraConnectMessage:
|
|
|
|
|
if (!args.Data.TryGetValue(SurveillanceCameraSystem.CameraAddressData, out string? address))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConnectCamera(uid, args.SenderAddress, address, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraHeartbeatMessage:
|
|
|
|
|
if (!args.Data.TryGetValue(SurveillanceCameraSystem.CameraAddressData, out string? camera))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SendHeartbeat(uid, args.SenderAddress, camera, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraSubnetConnectMessage:
|
|
|
|
|
AddMonitorToRoute(uid, args.SenderAddress, router);
|
|
|
|
|
PingSubnet(uid, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraSubnetDisconnectMessage:
|
|
|
|
|
RemoveMonitorFromRoute(uid, args.SenderAddress, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraPingSubnetMessage:
|
|
|
|
|
PingSubnet(uid, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraPingMessage:
|
|
|
|
|
SubnetPingResponse(uid, args.SenderAddress, router);
|
|
|
|
|
break;
|
|
|
|
|
case SurveillanceCameraSystem.CameraDataMessage:
|
|
|
|
|
SendCameraInfo(uid, args.Data, router);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-15 15:08:15 +11:00
|
|
|
private void OnPowerChanged(EntityUid uid, SurveillanceCameraRouterComponent component, ref PowerChangedEvent args)
|
Surveillance cameras (#8246)
* cameras but i didn't feel like git stashing them
* Adds more functionality server-side for surveillance cameras
* rider moment
* Adds skeleton for SurveillanceCameraMonitorBoundUi on client
* whoops
* makes surveillance camera monitor UI more defined
* removes tree from SurveillanceCameraMonitorWindow
* surveillance camera active flag, other routing things
* actually sets how SurveillanceCameraMonitorSystem sends camera info to clients
* adds entity yaml, changes field
* adds the camera/monitor entities, makes the UI open
* SurveillanceCameraRouters (not implemented fully)
* subnets for cameras, server-side
* it works!
* fixes rotation in cameras
* whoops
restores surveillance cameras to ignored components
makes it so that switching cameras now lerps the other camera
* makes the UI work
* makes it so that cameras actually refresh now
* cleanup
* adds camera.rsi
* cleans up prototypes a bit
* adds camera subnet frequencies, cameras in subnets
* adds surveillance camera router subnets
* might fix testing errors
* adds the circuit board to the surveillance camera monitor
* fixes up the camera monitor (the detective will get his tv soon)
* adds heartbeat, ensures subnet data is passed into cameras to send
* fixes up a few things
* whoops
* changes to UI internals
* fixes subnet selection issue
* localized strings for UI
* changes 'test' id to 'camera' for cameras
* whoops
* missing s
* camera static!
* adds a delay to camera switching
* adjusts a few things in camera timing
* adds setup for cameras/routers, localization for frequency names
* adds setup ui for routers, makes subnet names in monitor window follow frequency name in prototype
* localization, some cleanup
* ui adjustments
* adds surveillance camera visuals
* fixes a bug when closing the UI for monitors
* adds disconnect message to UI
* adds construction graph to cameras
* adds the camera to the construction menu
* fixes network selection for setup, tweak to assembly
* adds surveillance camera router construction, fixes up surveillance camera wire cutting
* adds disconnect button to monitor UI
* switches around the status text
* tweaks monitor UI
* makes the address actually show
* might make tests pass
* UI adjustments, hard name limit
* ok, that didn't work
* adds wireless cameras
* makes the television work/look nicer
* adds tripod cameras in addition to mobile cameras
* makes wireless cameras constructable
* fixes up those prototypes
* reorganization in C#, small cleanup
* ensures that power changes deactivate some devices
* adds a component to the television, comments out a function
* actually, never mind, i forgot that wireless cameras existed/are creatable for a second
* tweaks to router construction, removes SubnetTest from prototypes
* removes it from frequencies too
* Apply suggestions from code review
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
* type serializers into components
* setup window opens centered, enum is now byte
* replaces active monitor list with ActiveSurveillanceCameraMonitorComponent
* adds paused/deleted entity checks, changes how verbs are given
* removes EntitySystem.Get<T>() references
* fixes bug related to selecting network from setup, alphabet-orders network listing in setup
* rider moment
* adds minwidth to surveillance camera setup window
* addresses reviews
* should fix the issue with camera visuals not updating properly
* addresses some reviews
* addresses further review
* addresses reviews related to RSIs
* never needed a key there anyways
* changes a few things with routers to ensure that they're active
* whoops
* ensurecomp over addcomp
* whoops
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-05-31 01:44:57 -07:00
|
|
|
{
|
|
|
|
|
component.MonitorRoutes.Clear();
|
|
|
|
|
component.Active = args.Powered;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddVerbs(EntityUid uid, SurveillanceCameraRouterComponent component, GetVerbsEvent<AlternativeVerb> verbs)
|
|
|
|
|
{
|
|
|
|
|
if (!_actionBlocker.CanInteract(verbs.User, uid))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (component.SubnetFrequencyId != null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AlternativeVerb verb = new();
|
|
|
|
|
verb.Text = Loc.GetString("surveillance-camera-setup");
|
|
|
|
|
verb.Act = () => OpenSetupInterface(uid, verbs.User, component);
|
|
|
|
|
verbs.Verbs.Add(verb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSetNetwork(EntityUid uid, SurveillanceCameraRouterComponent component,
|
|
|
|
|
SurveillanceCameraSetupSetNetwork args)
|
|
|
|
|
{
|
|
|
|
|
if (args.UiKey is not SurveillanceCameraSetupUiKey key
|
|
|
|
|
|| key != SurveillanceCameraSetupUiKey.Router)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (args.Network < 0 || args.Network >= component.AvailableNetworks.Count)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_prototypeManager.TryIndex<DeviceFrequencyPrototype>(component.AvailableNetworks[args.Network],
|
|
|
|
|
out var frequency))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
component.SubnetFrequencyId = component.AvailableNetworks[args.Network];
|
|
|
|
|
component.SubnetFrequency = frequency.Frequency;
|
|
|
|
|
component.Active = true;
|
|
|
|
|
UpdateSetupInterface(uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenSetupInterface(EntityUid uid, EntityUid player, SurveillanceCameraRouterComponent? camera = null, ActorComponent? actor = null)
|
|
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
if (!Resolve(uid, ref camera) || !Resolve(player, ref actor))
|
|
|
|
|
return;
|
|
|
|
|
if (!_userInterface.TryGetUi(uid, SurveillanceCameraSetupUiKey.Router, out var bui))
|
Surveillance cameras (#8246)
* cameras but i didn't feel like git stashing them
* Adds more functionality server-side for surveillance cameras
* rider moment
* Adds skeleton for SurveillanceCameraMonitorBoundUi on client
* whoops
* makes surveillance camera monitor UI more defined
* removes tree from SurveillanceCameraMonitorWindow
* surveillance camera active flag, other routing things
* actually sets how SurveillanceCameraMonitorSystem sends camera info to clients
* adds entity yaml, changes field
* adds the camera/monitor entities, makes the UI open
* SurveillanceCameraRouters (not implemented fully)
* subnets for cameras, server-side
* it works!
* fixes rotation in cameras
* whoops
restores surveillance cameras to ignored components
makes it so that switching cameras now lerps the other camera
* makes the UI work
* makes it so that cameras actually refresh now
* cleanup
* adds camera.rsi
* cleans up prototypes a bit
* adds camera subnet frequencies, cameras in subnets
* adds surveillance camera router subnets
* might fix testing errors
* adds the circuit board to the surveillance camera monitor
* fixes up the camera monitor (the detective will get his tv soon)
* adds heartbeat, ensures subnet data is passed into cameras to send
* fixes up a few things
* whoops
* changes to UI internals
* fixes subnet selection issue
* localized strings for UI
* changes 'test' id to 'camera' for cameras
* whoops
* missing s
* camera static!
* adds a delay to camera switching
* adjusts a few things in camera timing
* adds setup for cameras/routers, localization for frequency names
* adds setup ui for routers, makes subnet names in monitor window follow frequency name in prototype
* localization, some cleanup
* ui adjustments
* adds surveillance camera visuals
* fixes a bug when closing the UI for monitors
* adds disconnect message to UI
* adds construction graph to cameras
* adds the camera to the construction menu
* fixes network selection for setup, tweak to assembly
* adds surveillance camera router construction, fixes up surveillance camera wire cutting
* adds disconnect button to monitor UI
* switches around the status text
* tweaks monitor UI
* makes the address actually show
* might make tests pass
* UI adjustments, hard name limit
* ok, that didn't work
* adds wireless cameras
* makes the television work/look nicer
* adds tripod cameras in addition to mobile cameras
* makes wireless cameras constructable
* fixes up those prototypes
* reorganization in C#, small cleanup
* ensures that power changes deactivate some devices
* adds a component to the television, comments out a function
* actually, never mind, i forgot that wireless cameras existed/are creatable for a second
* tweaks to router construction, removes SubnetTest from prototypes
* removes it from frequencies too
* Apply suggestions from code review
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
* type serializers into components
* setup window opens centered, enum is now byte
* replaces active monitor list with ActiveSurveillanceCameraMonitorComponent
* adds paused/deleted entity checks, changes how verbs are given
* removes EntitySystem.Get<T>() references
* fixes bug related to selecting network from setup, alphabet-orders network listing in setup
* rider moment
* adds minwidth to surveillance camera setup window
* addresses reviews
* should fix the issue with camera visuals not updating properly
* addresses some reviews
* addresses further review
* addresses reviews related to RSIs
* never needed a key there anyways
* changes a few things with routers to ensure that they're active
* whoops
* ensurecomp over addcomp
* whoops
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-05-31 01:44:57 -07:00
|
|
|
return;
|
|
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
_userInterface.OpenUi(bui, actor.PlayerSession);
|
Surveillance cameras (#8246)
* cameras but i didn't feel like git stashing them
* Adds more functionality server-side for surveillance cameras
* rider moment
* Adds skeleton for SurveillanceCameraMonitorBoundUi on client
* whoops
* makes surveillance camera monitor UI more defined
* removes tree from SurveillanceCameraMonitorWindow
* surveillance camera active flag, other routing things
* actually sets how SurveillanceCameraMonitorSystem sends camera info to clients
* adds entity yaml, changes field
* adds the camera/monitor entities, makes the UI open
* SurveillanceCameraRouters (not implemented fully)
* subnets for cameras, server-side
* it works!
* fixes rotation in cameras
* whoops
restores surveillance cameras to ignored components
makes it so that switching cameras now lerps the other camera
* makes the UI work
* makes it so that cameras actually refresh now
* cleanup
* adds camera.rsi
* cleans up prototypes a bit
* adds camera subnet frequencies, cameras in subnets
* adds surveillance camera router subnets
* might fix testing errors
* adds the circuit board to the surveillance camera monitor
* fixes up the camera monitor (the detective will get his tv soon)
* adds heartbeat, ensures subnet data is passed into cameras to send
* fixes up a few things
* whoops
* changes to UI internals
* fixes subnet selection issue
* localized strings for UI
* changes 'test' id to 'camera' for cameras
* whoops
* missing s
* camera static!
* adds a delay to camera switching
* adjusts a few things in camera timing
* adds setup for cameras/routers, localization for frequency names
* adds setup ui for routers, makes subnet names in monitor window follow frequency name in prototype
* localization, some cleanup
* ui adjustments
* adds surveillance camera visuals
* fixes a bug when closing the UI for monitors
* adds disconnect message to UI
* adds construction graph to cameras
* adds the camera to the construction menu
* fixes network selection for setup, tweak to assembly
* adds surveillance camera router construction, fixes up surveillance camera wire cutting
* adds disconnect button to monitor UI
* switches around the status text
* tweaks monitor UI
* makes the address actually show
* might make tests pass
* UI adjustments, hard name limit
* ok, that didn't work
* adds wireless cameras
* makes the television work/look nicer
* adds tripod cameras in addition to mobile cameras
* makes wireless cameras constructable
* fixes up those prototypes
* reorganization in C#, small cleanup
* ensures that power changes deactivate some devices
* adds a component to the television, comments out a function
* actually, never mind, i forgot that wireless cameras existed/are creatable for a second
* tweaks to router construction, removes SubnetTest from prototypes
* removes it from frequencies too
* Apply suggestions from code review
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
* type serializers into components
* setup window opens centered, enum is now byte
* replaces active monitor list with ActiveSurveillanceCameraMonitorComponent
* adds paused/deleted entity checks, changes how verbs are given
* removes EntitySystem.Get<T>() references
* fixes bug related to selecting network from setup, alphabet-orders network listing in setup
* rider moment
* adds minwidth to surveillance camera setup window
* addresses reviews
* should fix the issue with camera visuals not updating properly
* addresses some reviews
* addresses further review
* addresses reviews related to RSIs
* never needed a key there anyways
* changes a few things with routers to ensure that they're active
* whoops
* ensurecomp over addcomp
* whoops
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-05-31 01:44:57 -07:00
|
|
|
UpdateSetupInterface(uid, camera);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSetupInterface(EntityUid uid, SurveillanceCameraRouterComponent? router = null, DeviceNetworkComponent? deviceNet = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router, ref deviceNet))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (router.AvailableNetworks.Count == 0 || router.SubnetFrequencyId != null)
|
|
|
|
|
{
|
|
|
|
|
_userInterface.TryCloseAll(uid, SurveillanceCameraSetupUiKey.Router);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var state = new SurveillanceCameraSetupBoundUiState(router.SubnetName, deviceNet.ReceiveFrequency ?? 0,
|
|
|
|
|
router.AvailableNetworks, true, router.SubnetFrequencyId != null);
|
|
|
|
|
_userInterface.TrySetUiState(uid, SurveillanceCameraSetupUiKey.Router, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SendHeartbeat(EntityUid uid, string origin, string destination,
|
|
|
|
|
SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new NetworkPayload()
|
|
|
|
|
{
|
|
|
|
|
{ DeviceNetworkConstants.Command, SurveillanceCameraSystem.CameraHeartbeatMessage },
|
|
|
|
|
{ SurveillanceCameraSystem.CameraAddressData, origin }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_deviceNetworkSystem.QueuePacket(uid, destination, payload, router.SubnetFrequency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SubnetPingResponse(EntityUid uid, string origin, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router) || router.SubnetFrequencyId == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new NetworkPayload()
|
|
|
|
|
{
|
|
|
|
|
{ DeviceNetworkConstants.Command, SurveillanceCameraSystem.CameraSubnetData },
|
|
|
|
|
{ SurveillanceCameraSystem.CameraSubnetData, router.SubnetFrequencyId }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_deviceNetworkSystem.QueuePacket(uid, origin, payload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConnectCamera(EntityUid uid, string origin, string address, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new NetworkPayload()
|
|
|
|
|
{
|
|
|
|
|
{ DeviceNetworkConstants.Command, SurveillanceCameraSystem.CameraConnectMessage },
|
|
|
|
|
{ SurveillanceCameraSystem.CameraAddressData, origin }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_deviceNetworkSystem.QueuePacket(uid, address, payload, router.SubnetFrequency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Adds a monitor to the set of routes.
|
|
|
|
|
private void AddMonitorToRoute(EntityUid uid, string address, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
router.MonitorRoutes.Add(address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveMonitorFromRoute(EntityUid uid, string address, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
router.MonitorRoutes.Remove(address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Pings a subnet to get all camera information.
|
|
|
|
|
private void PingSubnet(EntityUid uid, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new NetworkPayload()
|
|
|
|
|
{
|
|
|
|
|
{ DeviceNetworkConstants.Command, SurveillanceCameraSystem.CameraPingMessage },
|
|
|
|
|
{ SurveillanceCameraSystem.CameraSubnetData, router.SubnetName }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_deviceNetworkSystem.QueuePacket(uid, null, payload, router.SubnetFrequency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sends camera information to all monitors currently interested.
|
|
|
|
|
private void SendCameraInfo(EntityUid uid, NetworkPayload payload, SurveillanceCameraRouterComponent? router = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref router))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var address in router.MonitorRoutes)
|
|
|
|
|
{
|
|
|
|
|
_deviceNetworkSystem.QueuePacket(uid, address, payload);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|