diff --git a/Content.Server/Radiation/Systems/GeigerSystem.cs b/Content.Server/Radiation/Systems/GeigerSystem.cs index f889336a068..06e5911cb7c 100644 --- a/Content.Server/Radiation/Systems/GeigerSystem.cs +++ b/Content.Server/Radiation/Systems/GeigerSystem.cs @@ -6,8 +6,8 @@ using Content.Shared.Radiation.Components; using Content.Shared.Radiation.Systems; using Robust.Server.Audio; -using Robust.Server.GameObjects; using Robust.Server.Player; +using Robust.Shared.Player; namespace Content.Server.Radiation.Systems; @@ -152,19 +152,19 @@ private void UpdateSound(EntityUid uid, GeigerComponent? component = null) component.Stream = _audio.Stop(component.Stream); - if (!component.Sounds.TryGetValue(component.DangerLevel, out var sounds)) - return; - - if (component.User == null) - return; - - if (!_player.TryGetSessionByEntity(component.User.Value, out var session)) - return; - - var sound = _audio.GetSound(sounds); - var param = sounds.Params.WithLoop(true).WithVolume(-4f); - - component.Stream = _audio.PlayGlobal(sound, session, param)?.Entity; + if (component.Sounds.TryGetValue(component.DangerLevel, out var sounds)) + { + var sound = _audio.GetSound(sounds); + + if (component.LocalSoundOnly + && component.User is not null + && _player.TryGetSessionByEntity(component.User.Value, out var session)) + { + component.Stream = _audio.PlayGlobal(sound, session, component.AudioParameters)?.Entity; + return; + } + component.Stream = _audio.PlayEntity(sound, Filter.Pvs(uid), uid, true, component.AudioParameters)?.Entity; + } } public static GeigerDangerLevel RadsToLevel(float rads) diff --git a/Content.Shared/Radiation/Components/GeigerComponent.cs b/Content.Shared/Radiation/Components/GeigerComponent.cs index 71edb70b37c..710d74d9b38 100644 --- a/Content.Shared/Radiation/Components/GeigerComponent.cs +++ b/Content.Shared/Radiation/Components/GeigerComponent.cs @@ -29,14 +29,12 @@ public sealed partial class GeigerComponent : Component /// /// Should it shows examine message with current radiation level? /// - [ViewVariables(VVAccess.ReadWrite)] [DataField] public bool ShowExamine; /// /// Should it shows item control when equipped by player? /// - [ViewVariables(VVAccess.ReadWrite)] [DataField] public bool ShowControl; @@ -55,7 +53,7 @@ public sealed partial class GeigerComponent : Component /// /// Current radiation level in rad per second. /// - [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField] + [DataField, AutoNetworkedField] public float CurrentRadiation; /// @@ -66,8 +64,6 @@ public sealed partial class GeigerComponent : Component /// /// Current player that equipped geiger counter. - /// Because sound is annoying, geiger counter clicks will play - /// only for player that equipped it. /// [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField] public EntityUid? User; @@ -83,6 +79,19 @@ public sealed partial class GeigerComponent : Component /// Played only for current user. /// public EntityUid? Stream; + + /// + /// Controls whether the geiger counter plays only for the local player, or plays for everyone nearby. + /// Useful for things like hardsuits with integrated geigers. Alternatively, to create stationary radiation alarm objects. + /// + [DataField] + public bool LocalSoundOnly = false; + + /// + /// Used for all geiger counter audio controls, allowing entities to override default audio parameters. + /// + [DataField] + public AudioParams AudioParameters; } [Serializable, NetSerializable] diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml index d6a2cd446be..358f91d2971 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml @@ -142,6 +142,9 @@ - type: Clothing equipDelay: 2.5 # Hardsuits are heavy and take a while to put on/off. unequipDelay: 2.5 + - type: Geiger + attachedToSuit: true + localSoundOnly: true - type: StaminaDamageResistance coefficient: 0.75 # 25% diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/radalarm.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/radalarm.yml new file mode 100644 index 00000000000..44bbe3e6170 --- /dev/null +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/radalarm.yml @@ -0,0 +1,51 @@ +- type: entity + id: GeigerCounterWallMount + name: wall-mounted Geiger counter + description: A stationary device that emits a warning tone when it detects radiation pulses. + placement: + mode: SnapgridCenter + snap: + - Wallmount + components: + - type: InteractionOutline + - type: Clickable + - type: Rotatable + rotateWhileAnchored: false + rotateWhilePulling: true + - type: WallMount + - type: Transform + noRot: false + anchored: true + - type: Sprite + noRot: true + drawdepth: WallMountedItems + sprite: Structures/Wallmounts/radalarm.rsi + layers: + - state: geiger_base + - state: geiger_on_idle + map: ["enum.GeigerLayers.Screen"] + shader: unshaded + visible: false + - type: Geiger + showControl: true + showExamine: true + localSoundOnly: false + audioParameters: + volume: -4 + maxDistance: 10 + rolloffFactor: 4 + - type: Appearance + - type: GenericVisualizer + visuals: + enum.GeigerVisuals.IsEnabled: + GeigerLayers.Screen: + True: { visible: True } + False: { visible: False } + enum.GeigerVisuals.DangerLevel: + GeigerLayers.Screen: + None: {state: geiger_on_idle} + Low: {state: geiger_on_low} + Med: {state: geiger_on_med} + High: {state: geiger_on_high} + Extreme: {state: geiger_on_ext} + diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_base.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_base.png new file mode 100644 index 00000000000..778c4277350 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_base.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_ext.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_ext.png new file mode 100644 index 00000000000..7b7f3f4e767 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_ext.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_high.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_high.png new file mode 100644 index 00000000000..7b7f3f4e767 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_high.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_idle.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_idle.png new file mode 100644 index 00000000000..4038e100886 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_idle.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_low.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_low.png new file mode 100644 index 00000000000..a09613ad524 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_low.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_med.png b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_med.png new file mode 100644 index 00000000000..33d354a6a6e Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/geiger_on_med.png differ diff --git a/Resources/Textures/Structures/Wallmounts/radalarm.rsi/meta.json b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/meta.json new file mode 100644 index 00000000000..2ef22994bc0 --- /dev/null +++ b/Resources/Textures/Structures/Wallmounts/radalarm.rsi/meta.json @@ -0,0 +1,35 @@ +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "CC-BY-SA-3.0", + "copyright": "Made by @dootythefrooty (Discord)", + "states": [ + { + "name": "geiger_base", + "directions": 4 + }, + { + "name": "geiger_on_idle", + "directions": 4 + }, + { + "name": "geiger_on_low", + "directions": 4 + }, + { + "name": "geiger_on_med", + "directions": 4 + }, + { + "name": "geiger_on_high", + "directions": 4 + }, + { + "name": "geiger_on_ext", + "directions": 4 + } + ] +}