forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/_CorvaxNext/Entities/Clothing/Neck/secbadge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Resources/Prototypes/_CorvaxNext/Entities/Objects/Tools/bodycamera.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |