Skip to content

Commit

Permalink
консоль пикает
Browse files Browse the repository at this point in the history
Signed-off-by: pacable <[email protected]>
  • Loading branch information
pxc1984 committed Dec 1, 2024
1 parent 5f806f3 commit 0e82381
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Content.Server/Atmos/Consoles/AtmosAlertsComputerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
using Robust.Shared.Timing;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;

namespace Content.Server.Atmos.Monitor.Systems;

Expand All @@ -31,6 +34,7 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
[Dependency] private readonly NavMapSystem _navMapSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly DeviceListSystem _deviceListSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

private const float UpdateTime = 1.0f;

Expand All @@ -54,7 +58,7 @@ public override void Initialize()
SubscribeLocalEvent<AtmosAlertsDeviceComponent, AnchorStateChangedEvent>(OnDeviceAnchorChanged);
}

#region Event handling
#region Event handling

private void OnConsoleInit(EntityUid uid, AtmosAlertsComputerComponent component, ComponentInit args)
{
Expand Down Expand Up @@ -194,6 +198,14 @@ public override void Update(float frameTime)
if (TryComp<AppearanceComponent>(ent, out var entAppearance))
_appearance.SetData(ent, AtmosAlertsComputerVisuals.ComputerLayerScreen, (int) highestAlert, entAppearance);

// Sunrise-start
if (entConsole.NextBeep < _gameTiming.CurTime && highestAlert == AtmosAlarmType.Danger && entConsole.BeepSound != null)
{
_audio.PlayPvs(entConsole.BeepSound, ent);
entConsole.NextBeep = _gameTiming.CurTime + entConsole.Timer;
}
// Sunrise-end

// If the console UI is open, send UI data to each subscribed session
UpdateUIState(ent, airAlarmEntries, fireAlarmEntries, entConsole, entXform);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Atmos.Consoles;
using Content.Shared.Atmos.Monitor;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
Expand Down Expand Up @@ -27,6 +28,17 @@ public sealed partial class AtmosAlertsComputerComponent : Component
/// </summary>
[ViewVariables, AutoNetworkedField]
public HashSet<NetEntity> SilencedDevices = new();

// Sunrise-start
[DataField]
public SoundSpecifier? BeepSound;

[DataField]
public TimeSpan Timer = TimeSpan.FromSeconds(5);

[DataField]
public TimeSpan NextBeep = TimeSpan.Zero;
// Sunrise-end
}

[Serializable, NetSerializable]
Expand Down Expand Up @@ -77,7 +89,7 @@ public struct AtmosAlertsFocusDeviceData
public (float, AtmosAlarmType) PressureData;

/// <summary>
/// Moles, percentage, and related alert state, for all detected gases
/// Moles, percentage, and related alert state, for all detected gases
/// </summary>
public Dictionary<Gas, (float, float, AtmosAlarmType)> GasData;

Expand Down Expand Up @@ -200,7 +212,7 @@ public sealed class AtmosAlertsComputerDeviceSilencedMessage : BoundUserInterfac
public bool SilenceDevice = true;

/// <summary>
/// Used to inform the server that the client has silenced alerts from the specified device to this atmos monitoring console
/// Used to inform the server that the client has silenced alerts from the specified device to this atmos monitoring console
/// </summary>
public AtmosAlertsComputerDeviceSilencedMessage(NetEntity atmosDevice, bool silenceDevice = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@
visible: true
map: [ "enum.PowerDeviceVisualLayers.Powered" ]
- type: AtmosAlertsComputer
beepSound:
path: /Audio/Effects/beeps.ogg
params:
volume: -6
- type: ActivatableUI
singleUser: true
key: enum.AtmosAlertsComputerUiKey.Key
Expand Down

0 comments on commit 0e82381

Please sign in to comment.