Skip to content

Commit

Permalink
SecCam
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant committed Dec 23, 2024
1 parent 32b28f7 commit 4ac46ee
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Content.Server/_CorvaxNext/BodyCam/BodyCameraComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.GameObjects;

namespace Content.Server.Camera
{
/// <summary>
/// A marker component for cameras that should only be active when worn.
/// </summary>
[RegisterComponent]
public sealed partial class BodyCameraComponent : Component
{
}
}
62 changes: 62 additions & 0 deletions Content.Server/_CorvaxNext/BodyCam/BodyCameraSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Content.Server.SurveillanceCamera;
using Content.Shared.Clothing;
using Content.Shared.Clothing.Components;
using Robust.Shared.GameObjects;

namespace Content.Server.Camera
{
/// <summary>
/// A system that automatically enables or disables a camera
/// depending on whether the item is currently equipped in a clothing slot.
/// </summary>
public sealed class BodyCameraSystem : EntitySystem
{
[Dependency] private readonly SurveillanceCameraSystem _surveillanceSystem = default!;

public override void Initialize()
{
base.Initialize();

// When the BodyCameraComponent is added, ensure the camera starts off.
SubscribeLocalEvent<BodyCameraComponent, ComponentStartup>(OnStartup);

// Turn camera on/off when the clothing item is equipped/unequipped.
SubscribeLocalEvent<BodyCameraComponent, ClothingGotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<BodyCameraComponent, ClothingGotUnequippedEvent>(OnUnequipped);
}

/// <summary>
/// On component startup, forcibly disable the camera (if found).
/// </summary>
private void OnStartup(EntityUid uid, BodyCameraComponent component, ComponentStartup args)
{
// If there's a SurveillanceCameraComponent, turn it off immediately.
if (TryComp<SurveillanceCameraComponent>(uid, out var camComp))
{
_surveillanceSystem.SetActive(uid, false, camComp);
}
}

/// <summary>
/// When the item is equipped, turn the camera on.
/// </summary>
private void OnEquipped(EntityUid uid, BodyCameraComponent component, ref ClothingGotEquippedEvent args)
{
if (TryComp<SurveillanceCameraComponent>(uid, out var camComp))
{
_surveillanceSystem.SetActive(uid, true, camComp);
}
}

/// <summary>
/// When the item is unequipped, turn the camera off.
/// </summary>
private void OnUnequipped(EntityUid uid, BodyCameraComponent component, ref ClothingGotUnequippedEvent args)
{
if (TryComp<SurveillanceCameraComponent>(uid, out var camComp))
{
_surveillanceSystem.SetActive(uid, false, camComp);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- type: entity
parent: ClothingNeckBase
parent: [ClothingNeckBase, BaseBodyCamera]
id: ClothingNeckSecBadgeBase
name: badge
description: Respect my authority!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
- type: entity
abstract: true
parent: BaseItem
id: BaseBodyCamera
components:
- type: Eye
- type: WirelessNetworkConnection
- type: UserInterface
interfaces:
enum.SurveillanceCameraSetupUiKey.Camera:
type: SurveillanceCameraSetupBoundUi
- type: DeviceNetwork
deviceNetId: Wired
receiveFrequencyId: SurveillanceCameraSecurity
transmitFrequencyId: SurveillanceCamera
- type: SurveillanceCamera
setupAvailableNetworks:
- SurveillanceCameraSecurity
isOffable: true
isOffableVisuals: true
networkSet: true
id: "Нагрудная камера"
- type: SurveillanceCameraMicrophone
- type: ActiveListener
range: 6
- type: BodyCamera

0 comments on commit 4ac46ee

Please sign in to comment.