use manual component state for BaseEmitSoundComponent (#35030)

* why

* cursed
This commit is contained in:
Milon
2025-03-30 15:41:11 +02:00
committed by GitHub
parent 47f8aefc25
commit 89e59b391d
13 changed files with 75 additions and 30 deletions

View File

@@ -1,4 +1,6 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Sound.Components;
@@ -8,10 +10,9 @@ namespace Content.Shared.Sound.Components;
/// </summary>
public abstract partial class BaseEmitSoundComponent : Component
{
public static readonly AudioParams DefaultParams = AudioParams.Default.WithVolume(-2f);
[AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
/// <summary>
/// The <see cref="SoundSpecifier"/> to play.
/// </summary>
[DataField(required: true)]
public SoundSpecifier? Sound;
@@ -22,3 +23,15 @@ public abstract partial class BaseEmitSoundComponent : Component
[DataField]
public bool Positional;
}
/// <summary>
/// Represents the state of <see cref="BaseEmitSoundComponent"/>.
/// </summary>
/// <remarks>This is obviously very cursed, but since the BaseEmitSoundComponent is abstract, we cannot network it.
/// AutoGenerateComponentState attribute won't work here, and since everything revolves around inheritance for some fucking reason,
/// there's no better way of doing this.</remarks>
[Serializable, NetSerializable]
public struct EmitSoundComponentState(SoundSpecifier? sound) : IComponentState
{
public SoundSpecifier? Sound { get; } = sound;
}