Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bodycams #241

Merged
merged 14 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server._NF.Bodycam;
using Content.Shared.DeviceNetwork;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

Expand Down Expand Up @@ -34,10 +35,17 @@ public sealed class SurveillanceCameraComponent : Component
[DataField("id")]
public string CameraId { get; set; } = "camera";

[ViewVariables]
public EntityUid? CameraIdUser = null;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("nameSet")]
public bool NameSet { get; set; }

[ViewVariables(VVAccess.ReadWrite)]
[DataField("nameSetUser")]
public bool NameSetUser { get; set; }

[ViewVariables(VVAccess.ReadWrite)]
[DataField("networkSet")]
public bool NetworkSet { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
using Content.Server.Power.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.DeviceNetwork;
using Content.Shared.Inventory.Events;
using Content.Shared.SurveillanceCamera;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Content.Server.Access.Systems;


namespace Content.Server.SurveillanceCamera;

Expand All @@ -21,6 +24,8 @@ public sealed class SurveillanceCameraSystem : EntitySystem
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

[Dependency] private readonly IdCardSystem _idCardSystem = default!;

// Pings a surveillance camera subnet. All cameras will always respond
// with a data message if they are on the same subnet.
public const string CameraPingSubnetMessage = "surveillance_camera_ping_subnet";
Expand Down Expand Up @@ -61,6 +66,8 @@ public override void Initialize()

SubscribeLocalEvent<SurveillanceCameraComponent, EmpPulseEvent>(OnEmpPulse);
SubscribeLocalEvent<SurveillanceCameraComponent, EmpDisabledRemoved>(OnEmpDisabledRemoved);

SubscribeLocalEvent<SurveillanceCameraComponent, GotEquippedEvent>(OnEquipped);
}

private void OnPacketReceived(EntityUid uid, SurveillanceCameraComponent component, DeviceNetworkPacketEvent args)
Expand Down Expand Up @@ -206,6 +213,11 @@ private void OpenSetupInterface(EntityUid uid, EntityUid player, SurveillanceCam
UpdateSetupInterface(uid, camera);
}

private void OnEquipped(EntityUid uid, SurveillanceCameraComponent component, GotEquippedEvent args)
{
component.CameraIdUser = args.Equipee;
}

private void UpdateSetupInterface(EntityUid uid, SurveillanceCameraComponent? camera = null, DeviceNetworkComponent? deviceNet = null)
{
if (!Resolve(uid, ref camera, ref deviceNet))
Expand All @@ -232,6 +244,21 @@ private void UpdateSetupInterface(EntityUid uid, SurveillanceCameraComponent? ca
}
}

if (camera.NameSetUser)
{
var userName = Loc.GetString("bodycam-component-unknown-name");
var userJob = Loc.GetString("bodycam-component-unknown-job");
if (_idCardSystem.TryFindIdCard(camera.CameraIdUser!.Value, out var card))
{
if (card.FullName != null)
userName = card.FullName;
if (card.JobTitle != null)
userJob = card.JobTitle;
}
string cameraName = userJob + " - " + userName;
camera.CameraId = cameraName;
}

var state = new SurveillanceCameraSetupBoundUiState(camera.CameraId, deviceNet.ReceiveFrequency ?? 0,
camera.AvailableNetworks, camera.NameSet, camera.NetworkSet);
_userInterface.TrySetUiState(uid, SurveillanceCameraSetupUiKey.Camera, state);
Expand Down
70 changes: 70 additions & 0 deletions Content.Server/_NF/Bodycam/BodycamComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Content.Shared._NF.Bodycam;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Content.Server._NF.Bodycam;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.DeviceNetwork;
using Content.Server.SurveillanceCamera;

namespace Content.Shared._NF.Bodycam
{
[RegisterComponent]
[Access(typeof(BodycamSystem), typeof(SurveillanceCameraSystem))]
public sealed class BodycamComponent : Component
{
[DataField("turnOnSound")]
public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_on.ogg");

[DataField("turnOffSound")]
public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_off.ogg");

/// <summary>
/// Choose a random camera mode when item is spawned.
/// </summary>
[DataField("randomMode")]
public bool RandomMode = false;

/// <summary>
/// If true user can't change camera mode
/// </summary>
[DataField("controlsLocked")]
public bool ControlsLocked = false;

/// <summary>
/// Current camera mode. Can be switched by user verbs.
/// </summary>
[DataField("mode")]
public BodycamMode Mode = BodycamMode.CameraOff;

/// <summary>
/// Activate camera if user wear it in this slot.
/// </summary>
[DataField("activationSlot")]
public string ActivationSlot = "neck";

/// <summary>
/// Activate camera if user has this in a camera-compatible container.
/// </summary>
[DataField("activationContainer")]
public string? ActivationContainer;

/// <summary>
/// How often does camera update its owners status (in seconds). Limited by the system update rate.
/// </summary>
[DataField("updateRate")]
public TimeSpan UpdateRate = TimeSpan.FromSeconds(2f);

/// <summary>
/// Current user that wears camera. Null if nobody wearing it.
/// </summary>
[ViewVariables]
public EntityUid? User = null;

/// <summary>
/// Next time when camera updated owners status
/// </summary>
[DataField("nextUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextUpdate = TimeSpan.Zero;
}
}
Loading
Loading