]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Content fixes for engine PR (#39086)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Tue, 22 Jul 2025 10:25:28 +0000 (12:25 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Jul 2025 10:25:28 +0000 (12:25 +0200)
* content changes for engine PR

* rerun tests

14 files changed:
Content.Shared/Sound/Components/BaseEmitSoundComponent.cs
Content.Shared/Sound/Components/EmitSoundOnActivateComponent.cs
Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs
Content.Shared/Sound/Components/EmitSoundOnDropComponent.cs
Content.Shared/Sound/Components/EmitSoundOnInteractUsingComponent.cs
Content.Shared/Sound/Components/EmitSoundOnLandComponent.cs
Content.Shared/Sound/Components/EmitSoundOnPickupComponent.cs
Content.Shared/Sound/Components/EmitSoundOnSpawnComponent.cs
Content.Shared/Sound/Components/EmitSoundOnThrowComponent.cs
Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs
Content.Shared/Sound/Components/EmitSoundOnUseComponent.cs
Content.Shared/Sound/SharedEmitSoundSystem.cs
Content.Shared/Weapons/Misc/ForceGunComponent.cs
Content.Shared/Weapons/Misc/TetherGunComponent.cs

index 7011f72ef0bf9fd23fdaf3df4b51d5b16758f948..576374c5868e9483fe298cb983d736db48cad6a7 100644 (file)
@@ -1,6 +1,4 @@
 using Robust.Shared.Audio;
-using Robust.Shared.GameStates;
-using Robust.Shared.Serialization;
 
 namespace Content.Shared.Sound.Components;
 
@@ -13,25 +11,13 @@ public abstract partial class BaseEmitSoundComponent : Component
     /// <summary>
     /// The <see cref="SoundSpecifier"/> to play.
     /// </summary>
-    [DataField(required: true)]
+    [DataField(required: true), AutoNetworkedField]
     public SoundSpecifier? Sound;
 
     /// <summary>
     /// Play the sound at the position instead of parented to the source entity.
     /// Useful if the entity is deleted after.
     /// </summary>
-    [DataField]
+    [DataField, AutoNetworkedField]
     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;
-}
index d6aa42177e82d0c1ca03bcd2a61f8e87b1807517..0cf51a4ee384550a6d8e27d62ad3ed50967dae7c 100644 (file)
@@ -5,7 +5,7 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on ActivateInWorld
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnActivateComponent : BaseEmitSoundComponent
 {
     /// <summary>
index 4cdea05220c7c1f841d55406178426589d2e1182..ce01ecb87c47f1665fa53ccaf9b54a460325d172 100644 (file)
@@ -3,7 +3,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
 
 namespace Content.Shared.Sound.Components;
 
-[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnCollideComponent : BaseEmitSoundComponent
 {
     public static readonly TimeSpan CollideCooldown = TimeSpan.FromSeconds(0.2);
index 64ed5e60dc94e4406aec857752199f701fcb1814..52a352a81699ac766f946d342c7784d3fb7ede88 100644 (file)
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on entity drop
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnDropComponent : BaseEmitSoundComponent;
index d0b16fcec801314bfbada768f2793b33ca8d6d3e..f196d1ca184e59233c15fa344f3f77484ddc4fc4 100644 (file)
@@ -6,7 +6,7 @@ namespace Content.Shared.Sound.Components;
 /// <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
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnInteractUsingComponent : BaseEmitSoundComponent
 {
     /// <summary>
index d3fceb85dd90b485007a3a7aaaf1848ba5670eca..2154ec89fccb606ea669b209af7c8f2374e72857 100644 (file)
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on LandEvent
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnLandComponent : BaseEmitSoundComponent;
index dcf73b7ac2605b78c5a4a838b6bb693f8587c229..b9f8708c6f7883f60a6197e6f891483e17c84afb 100644 (file)
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on entity pickup
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnPickupComponent : BaseEmitSoundComponent;
index 20d39b34600c28c440a674d09363d86207f7e6eb..b9d66ba2699e51a92116807c98762577dce5c450 100644 (file)
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 ///     Simple sound emitter that emits sound on entity spawn.
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnSpawnComponent : BaseEmitSoundComponent;
index f8c0d1181b6c2fbb22c845a2caf5195862921986..76e9f080768e4f0c07dd61693d425a74b2291672 100644 (file)
@@ -5,5 +5,5 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on ThrowEvent
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnThrowComponent : BaseEmitSoundComponent;
index 65848cb5e57d5cb94de4746c519b66eed378dde8..69f3757b2219e439bc2f9b81439555d6cb6ecdcd 100644 (file)
@@ -6,7 +6,7 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
 {
     /// <summary>
index ec7a277e92448b10a47bfaea7dc14a864b30cefa..a0a51f3234392566876036e1bbfd018fade53c68 100644 (file)
@@ -5,7 +5,7 @@ namespace Content.Shared.Sound.Components;
 /// <summary>
 /// Simple sound emitter that emits sound on UseInHand
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class EmitSoundOnUseComponent : BaseEmitSoundComponent
 {
     /// <summary>
index 38af0677fafc0d1c84964587d431e4e6cb2c9db3..0e758ba0f11f352281e5dd005463f2248be6d698 100644 (file)
@@ -55,47 +55,6 @@ public abstract class SharedEmitSoundSystem : EntitySystem
         SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
 
         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)
index f3aca0d4d08ef31a615a1a9fba8aa704b77e0577..dc2481cb62ea28a8111bbd284d06786f82eee061 100644 (file)
@@ -9,19 +9,13 @@ public sealed partial class ForceGunComponent : BaseForceGunComponent
     /// <summary>
     /// Maximum distance to throw entities.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("throwDistance"), AutoNetworkedField]
+    [DataField, AutoNetworkedField]
     public float ThrowDistance = 15f;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("throwForce"), AutoNetworkedField]
+    [DataField, AutoNetworkedField]
     public float ThrowForce = 30f;
 
-    /// <summary>
-    /// The entity currently tethered.
-    /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("tethered"), AutoNetworkedField]
-    public override EntityUid? Tethered { get; set; }
-
-    [ViewVariables(VVAccess.ReadWrite), DataField("soundLaunch")]
+    [DataField("soundLaunch")]
     public SoundSpecifier? LaunchSound = new SoundPathSpecifier("/Audio/Weapons/soup.ogg")
     {
         Params = AudioParams.Default.WithVolume(5f),
index fcc5494154397a5145840a1b1a0198886a1d82e4..bb9ebd4e435c594521eda7dde594aa25080fa0e6 100644 (file)
@@ -5,18 +5,6 @@ namespace Content.Shared.Weapons.Misc;
 [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
 public sealed partial class TetherGunComponent : BaseForceGunComponent
 {
-    [ViewVariables(VVAccess.ReadWrite), DataField("maxDistance"), AutoNetworkedField]
+    [DataField, AutoNetworkedField]
     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; }
 }