コード例 #1
0
    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;
    }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
    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);
    }
コード例 #4
0
    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);
    }
コード例 #5
0
 private void OnPowerChanged(EntityUid uid, SurveillanceCameraRouterComponent component, PowerChangedEvent args)
 {
     component.MonitorRoutes.Clear();
     component.Active = args.Powered;
 }