Files
crystall-punk-14/Content.Shared/Audio/AmbientSoundComponent.cs

55 lines
1.7 KiB
C#
Raw Permalink Normal View History

using System.Numerics;
2022-07-29 14:13:12 +12:00
using Robust.Shared.Audio;
using Robust.Shared.ComponentTrees;
using Robust.Shared.GameStates;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
2023-05-29 10:44:11 +10:00
namespace Content.Shared.Audio;
[RegisterComponent]
[NetworkedComponent]
[Access(typeof(SharedAmbientSoundSystem))]
public sealed partial class AmbientSoundComponent : Component, IComponentTreeEntry<AmbientSoundComponent>
2023-05-29 10:44:11 +10:00
{
[DataField("enabled", readOnly: true)]
2023-05-29 10:44:11 +10:00
[ViewVariables(VVAccess.ReadWrite)] // only for map editing
public bool Enabled { get; set; } = true;
[DataField("sound", required: true), ViewVariables(VVAccess.ReadWrite)] // only for map editing
public SoundSpecifier Sound = default!;
/// <summary>
/// How far away this ambient sound can potentially be heard.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] // only for map editing
[DataField("range")]
public float Range = 2f;
public Vector2 RangeVector => new Vector2(Range, Range);
2023-05-29 10:44:11 +10:00
/// <summary>
/// Applies this volume to the sound being played.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] // only for map editing
[DataField("volume")]
public float Volume = -10f;
public EntityUid? TreeUid { get; set; }
public DynamicTree<ComponentTreeEntry<AmbientSoundComponent>>? Tree { get; set; }
public bool AddToTree => Enabled;
public bool TreeUpdateQueued { get; set; }
}
[Serializable, NetSerializable]
public sealed class AmbientSoundComponentState : ComponentState
{
2023-05-29 10:44:11 +10:00
public bool Enabled { get; init; }
public float Range { get; init; }
public float Volume { get; init; }
public SoundSpecifier Sound { get; init; } = default!;
}