Geiger counters can now be heard by everyone nearby (#30463)
* haha geiger counter go brrrrrrr * move hardcoded values to datafields * syntax cleanup
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Shared.Radiation.Systems;
|
|||||||
using Robust.Server.Audio;
|
using Robust.Server.Audio;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
namespace Content.Server.Radiation.Systems;
|
namespace Content.Server.Radiation.Systems;
|
||||||
|
|
||||||
@@ -155,15 +156,16 @@ public sealed class GeigerSystem : SharedGeigerSystem
|
|||||||
if (!component.Sounds.TryGetValue(component.DangerLevel, out var sounds))
|
if (!component.Sounds.TryGetValue(component.DangerLevel, out var sounds))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.User == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_player.TryGetSessionByEntity(component.User.Value, out var session))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var sound = _audio.ResolveSound(sounds);
|
var sound = _audio.ResolveSound(sounds);
|
||||||
var param = sounds.Params.WithLoop(true).WithVolume(-4f);
|
var param = sounds.Params.WithLoop(true).WithVolume(component.Volume);
|
||||||
|
|
||||||
|
if (component.BroadcastAudio)
|
||||||
|
{
|
||||||
|
// For some reason PlayPvs sounds quieter even at distance 0, so we need to boost the volume a bit for consistency
|
||||||
|
param = sounds.Params.WithLoop(true).WithVolume(component.Volume + 1.5f).WithMaxDistance(component.BroadcastRange);
|
||||||
|
component.Stream = _audio.PlayPvs(sound, uid, param)?.Entity;
|
||||||
|
}
|
||||||
|
else if(component.User is not null && _player.TryGetSessionByEntity(component.User.Value, out var session))
|
||||||
component.Stream = _audio.PlayGlobal(sound, session, param)?.Entity;
|
component.Stream = _audio.PlayGlobal(sound, session, param)?.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,24 @@ public sealed partial class GeigerComponent : Component
|
|||||||
/// Played only for current user.
|
/// Played only for current user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityUid? Stream;
|
public EntityUid? Stream;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mark true if the audio should be heard by everyone around the device
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool BroadcastAudio = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The distance within which the broadcast tone can be heard.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float BroadcastRange = 4f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The volume of the warning tone.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float Volume = -4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
- type: Geiger
|
- type: Geiger
|
||||||
showControl: true
|
showControl: true
|
||||||
showExamine: true
|
showExamine: true
|
||||||
|
broadcastAudio: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: GenericVisualizer
|
- type: GenericVisualizer
|
||||||
visuals:
|
visuals:
|
||||||
@@ -34,4 +35,3 @@
|
|||||||
- type: PhysicalComposition
|
- type: PhysicalComposition
|
||||||
materialComposition:
|
materialComposition:
|
||||||
Plastic: 100
|
Plastic: 100
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user