Content fixes for engine PR (#39086)
* content changes for engine PR * rerun tests
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.Sound.Components;
|
namespace Content.Shared.Sound.Components;
|
||||||
|
|
||||||
@@ -13,25 +11,13 @@ public abstract partial class BaseEmitSoundComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="SoundSpecifier"/> to play.
|
/// The <see cref="SoundSpecifier"/> to play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField(required: true)]
|
[DataField(required: true), AutoNetworkedField]
|
||||||
public SoundSpecifier? Sound;
|
public SoundSpecifier? Sound;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Play the sound at the position instead of parented to the source entity.
|
/// Play the sound at the position instead of parented to the source entity.
|
||||||
/// Useful if the entity is deleted after.
|
/// Useful if the entity is deleted after.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField]
|
[DataField, AutoNetworkedField]
|
||||||
public bool Positional;
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on ActivateInWorld
|
/// Simple sound emitter that emits sound on ActivateInWorld
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnActivateComponent : BaseEmitSoundComponent
|
public sealed partial class EmitSoundOnActivateComponent : BaseEmitSoundComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|||||||
|
|
||||||
namespace Content.Shared.Sound.Components;
|
namespace Content.Shared.Sound.Components;
|
||||||
|
|
||||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnCollideComponent : BaseEmitSoundComponent
|
public sealed partial class EmitSoundOnCollideComponent : BaseEmitSoundComponent
|
||||||
{
|
{
|
||||||
public static readonly TimeSpan CollideCooldown = TimeSpan.FromSeconds(0.2);
|
public static readonly TimeSpan CollideCooldown = TimeSpan.FromSeconds(0.2);
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on entity drop
|
/// Simple sound emitter that emits sound on entity drop
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnDropComponent : BaseEmitSoundComponent;
|
public sealed partial class EmitSoundOnDropComponent : BaseEmitSoundComponent;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whenever this item is used upon by an entity, with a tag or component within a whitelist, in the hand of a user, play a sound
|
/// Whenever this item is used upon by an entity, with a tag or component within a whitelist, in the hand of a user, play a sound
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnInteractUsingComponent : BaseEmitSoundComponent
|
public sealed partial class EmitSoundOnInteractUsingComponent : BaseEmitSoundComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on LandEvent
|
/// Simple sound emitter that emits sound on LandEvent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnLandComponent : BaseEmitSoundComponent;
|
public sealed partial class EmitSoundOnLandComponent : BaseEmitSoundComponent;
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on entity pickup
|
/// Simple sound emitter that emits sound on entity pickup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnPickupComponent : BaseEmitSoundComponent;
|
public sealed partial class EmitSoundOnPickupComponent : BaseEmitSoundComponent;
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on entity spawn.
|
/// Simple sound emitter that emits sound on entity spawn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnSpawnComponent : BaseEmitSoundComponent;
|
public sealed partial class EmitSoundOnSpawnComponent : BaseEmitSoundComponent;
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on ThrowEvent
|
/// Simple sound emitter that emits sound on ThrowEvent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnThrowComponent : BaseEmitSoundComponent;
|
public sealed partial class EmitSoundOnThrowComponent : BaseEmitSoundComponent;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
|
/// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
|
public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Content.Shared.Sound.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple sound emitter that emits sound on UseInHand
|
/// Simple sound emitter that emits sound on UseInHand
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class EmitSoundOnUseComponent : BaseEmitSoundComponent
|
public sealed partial class EmitSoundOnUseComponent : BaseEmitSoundComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -55,47 +55,6 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
|
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
|
||||||
|
|
||||||
SubscribeLocalEvent<SoundWhileAliveComponent, MobStateChangedEvent>(OnMobState);
|
SubscribeLocalEvent<SoundWhileAliveComponent, MobStateChangedEvent>(OnMobState);
|
||||||
|
|
||||||
// We need to handle state manually here
|
|
||||||
// BaseEmitSoundComponent isn't registered so we have to subscribe to each one
|
|
||||||
// TODO: Make it use autonetworking instead of relying on inheritance
|
|
||||||
SubscribeEmitComponent<EmitSoundOnActivateComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnCollideComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnDropComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnInteractUsingComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnLandComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnPickupComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnSpawnComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnThrowComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnUIOpenComponent>();
|
|
||||||
SubscribeEmitComponent<EmitSoundOnUseComponent>();
|
|
||||||
|
|
||||||
// Helper method so it's a little less ugly
|
|
||||||
void SubscribeEmitComponent<T>() where T : BaseEmitSoundComponent
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<T, ComponentGetState>(GetBaseEmitState);
|
|
||||||
SubscribeLocalEvent<T, ComponentHandleState>(HandleBaseEmitState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void GetBaseEmitState<T>(Entity<T> ent, ref ComponentGetState args) where T : BaseEmitSoundComponent
|
|
||||||
{
|
|
||||||
args.State = new EmitSoundComponentState(ent.Comp.Sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleBaseEmitState<T>(Entity<T> ent, ref ComponentHandleState args) where T : BaseEmitSoundComponent
|
|
||||||
{
|
|
||||||
if (args.Current is not EmitSoundComponentState state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ent.Comp.Sound = state.Sound switch
|
|
||||||
{
|
|
||||||
SoundPathSpecifier pathSpec => new SoundPathSpecifier(pathSpec.Path, pathSpec.Params),
|
|
||||||
SoundCollectionSpecifier collectionSpec => collectionSpec.Collection != null
|
|
||||||
? new SoundCollectionSpecifier(collectionSpec.Collection, collectionSpec.Params)
|
|
||||||
: null,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
|
private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
|
||||||
|
|||||||
@@ -9,19 +9,13 @@ public sealed partial class ForceGunComponent : BaseForceGunComponent
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum distance to throw entities.
|
/// Maximum distance to throw entities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("throwDistance"), AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public float ThrowDistance = 15f;
|
public float ThrowDistance = 15f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("throwForce"), AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public float ThrowForce = 30f;
|
public float ThrowForce = 30f;
|
||||||
|
|
||||||
/// <summary>
|
[DataField("soundLaunch")]
|
||||||
/// The entity currently tethered.
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("tethered"), AutoNetworkedField]
|
|
||||||
public override EntityUid? Tethered { get; set; }
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("soundLaunch")]
|
|
||||||
public SoundSpecifier? LaunchSound = new SoundPathSpecifier("/Audio/Weapons/soup.ogg")
|
public SoundSpecifier? LaunchSound = new SoundPathSpecifier("/Audio/Weapons/soup.ogg")
|
||||||
{
|
{
|
||||||
Params = AudioParams.Default.WithVolume(5f),
|
Params = AudioParams.Default.WithVolume(5f),
|
||||||
|
|||||||
@@ -5,18 +5,6 @@ namespace Content.Shared.Weapons.Misc;
|
|||||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||||
public sealed partial class TetherGunComponent : BaseForceGunComponent
|
public sealed partial class TetherGunComponent : BaseForceGunComponent
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("maxDistance"), AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public float MaxDistance = 10f;
|
public float MaxDistance = 10f;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The entity the tethered target has a joint to.
|
|
||||||
/// </summary>
|
|
||||||
[DataField("tetherEntity"), AutoNetworkedField]
|
|
||||||
public override EntityUid? TetherEntity { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The entity currently tethered.
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("tethered"), AutoNetworkedField]
|
|
||||||
public override EntityUid? Tethered { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user