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,16 +156,17 @@ 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);
|
||||||
|
|
||||||
component.Stream = _audio.PlayGlobal(sound, session, param)?.Entity;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GeigerDangerLevel RadsToLevel(float rads)
|
public static GeigerDangerLevel RadsToLevel(float rads)
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -4,34 +4,34 @@
|
|||||||
name: Geiger counter
|
name: Geiger counter
|
||||||
description: A handheld device used for detecting and measuring radiation pulses.
|
description: A handheld device used for detecting and measuring radiation pulses.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Tools/geiger.rsi
|
sprite: Objects/Tools/geiger.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: geiger_base
|
- state: geiger_base
|
||||||
- state: geiger_on_idle
|
- state: geiger_on_idle
|
||||||
map: ["enum.GeigerLayers.Screen"]
|
map: ["enum.GeigerLayers.Screen"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/geiger.rsi
|
sprite: Objects/Tools/geiger.rsi
|
||||||
- type: Geiger
|
- type: Geiger
|
||||||
showControl: true
|
showControl: true
|
||||||
showExamine: true
|
showExamine: true
|
||||||
- type: Appearance
|
broadcastAudio: true
|
||||||
- type: GenericVisualizer
|
- type: Appearance
|
||||||
visuals:
|
- type: GenericVisualizer
|
||||||
enum.GeigerVisuals.IsEnabled:
|
visuals:
|
||||||
GeigerLayers.Screen:
|
enum.GeigerVisuals.IsEnabled:
|
||||||
True: { visible: True }
|
GeigerLayers.Screen:
|
||||||
False: { visible: False }
|
True: { visible: True }
|
||||||
enum.GeigerVisuals.DangerLevel:
|
False: { visible: False }
|
||||||
GeigerLayers.Screen:
|
enum.GeigerVisuals.DangerLevel:
|
||||||
None: {state: geiger_on_idle}
|
GeigerLayers.Screen:
|
||||||
Low: {state: geiger_on_low}
|
None: {state: geiger_on_idle}
|
||||||
Med: {state: geiger_on_med}
|
Low: {state: geiger_on_low}
|
||||||
High: {state: geiger_on_high}
|
Med: {state: geiger_on_med}
|
||||||
Extreme: {state: geiger_on_ext}
|
High: {state: geiger_on_high}
|
||||||
- type: PhysicalComposition
|
Extreme: {state: geiger_on_ext}
|
||||||
materialComposition:
|
- type: PhysicalComposition
|
||||||
Plastic: 100
|
materialComposition:
|
||||||
|
Plastic: 100
|
||||||
|
|||||||
Reference in New Issue
Block a user