Files
wwdpublic/Content.Shared/Radiation/Components/GeigerComponent.cs
VMSolidus 7d92c3e69f Soft-Refactor Geiger Counters (#615)
# Description

This refactors Geiger Counters so that their behavior of "Only making
sound to a person holding them" is no longer hardcoded. The
GeigerCounterComponent now can define how loud it ticks, how far away
people can hear the ticks, and whether it plays only for the person
holding it or for anyone nearby. This PR partially fulfills one of the
"Nice To Have" features requested for
https://github.com/Simple-Station/Einstein-Engines/pull/341 by making it
possible to create stationary radiation alarm objects. It also serves as
a substantial quality of life improvement for Engineering and Science
crew, since it's now possible to place an active Geiger counter in the
artifact lab, and then be able to audibly hear if the lab becomes
radioactive due to an artifact.

<details><summary><h1>Media</h1></summary>
<p>



https://github.com/user-attachments/assets/74122135-7345-4995-bb0e-d1216e1d53b6



https://github.com/user-attachments/assets/de79db6f-e1c1-471f-88b5-0a47ff4bfa16


</p>
</details>

# Changelog

🆑
- add: Geiger Counters other than ones installed in Hardsuits now
generate an audible sound when active and exposed to radiation.
- add: Wall mounted geiger counters have been added to the game.

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
2024-08-09 12:13:13 +01:00

119 lines
3.5 KiB
C#

using Content.Shared.Radiation.Systems;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Radiation.Components;
/// <summary>
/// Geiger counter that shows current radiation level.
/// Can be added as a component to clothes.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(SharedGeigerSystem))]
public sealed partial class GeigerComponent : Component
{
/// <summary>
/// If true it will be active only when player equipped it.
/// </summary>
[DataField]
public bool AttachedToSuit;
/// <summary>
/// Is geiger counter currently active?
/// If false attached entity will ignore any radiation rays.
/// </summary>
[DataField, AutoNetworkedField]
public bool IsEnabled;
/// <summary>
/// Should it shows examine message with current radiation level?
/// </summary>
[DataField]
public bool ShowExamine;
/// <summary>
/// Should it shows item control when equipped by player?
/// </summary>
[DataField]
public bool ShowControl;
/// <summary>
/// Map of sounds that should be play on loop for different radiation levels.
/// </summary>
[DataField]
public Dictionary<GeigerDangerLevel, SoundSpecifier> Sounds = new()
{
{GeigerDangerLevel.Low, new SoundPathSpecifier("/Audio/Items/Geiger/low.ogg")},
{GeigerDangerLevel.Med, new SoundPathSpecifier("/Audio/Items/Geiger/med.ogg")},
{GeigerDangerLevel.High, new SoundPathSpecifier("/Audio/Items/Geiger/high.ogg")},
{GeigerDangerLevel.Extreme, new SoundPathSpecifier("/Audio/Items/Geiger/ext.ogg")}
};
/// <summary>
/// Current radiation level in rad per second.
/// </summary>
[DataField, AutoNetworkedField]
public float CurrentRadiation;
/// <summary>
/// Estimated radiation danger level.
/// </summary>
[ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
public GeigerDangerLevel DangerLevel = GeigerDangerLevel.None;
/// <summary>
/// Current player that equipped geiger counter.
/// </summary>
[ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
public EntityUid? User;
/// <summary>
/// Marked true if control needs to update UI with latest component state.
/// </summary>
[Access(typeof(SharedGeigerSystem), Other = AccessPermissions.ReadWrite)]
public bool UiUpdateNeeded;
/// <summary>
/// Current stream of geiger counter audio.
/// Played only for current user.
/// </summary>
public EntityUid? Stream;
/// <summary>
/// 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.
/// </summary>
[DataField]
public bool LocalSoundOnly = false;
/// <summary>
/// Used for all geiger counter audio controls, allowing entities to override default audio parameters.
/// </summary>
[DataField]
public AudioParams AudioParameters;
}
[Serializable, NetSerializable]
public enum GeigerDangerLevel : byte
{
None,
Low,
Med,
High,
Extreme
}
[Serializable, NetSerializable]
public enum GeigerLayers : byte
{
Screen
}
[Serializable, NetSerializable]
public enum GeigerVisuals : byte
{
DangerLevel,
IsEnabled
}