diff --git a/Content.Server/Shuttles/Components/FTLComponent.cs b/Content.Server/Shuttles/Components/FTLComponent.cs index edcf25981b..0a01bb7636 100644 --- a/Content.Server/Shuttles/Components/FTLComponent.cs +++ b/Content.Server/Shuttles/Components/FTLComponent.cs @@ -50,6 +50,9 @@ public sealed partial class FTLComponent : Component Params = AudioParams.Default.WithVolume(-3f).WithLoop(true) }; + [DataField] + public EntityUid? StartupStream; + [DataField] public EntityUid? TravelStream; } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 11cc16e0cd..28f784f1dd 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -24,6 +24,7 @@ using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; +using Robust.Shared.Player; using Robust.Shared.Utility; using FTLMapComponent = Content.Shared.Shuttles.Components.FTLMapComponent; @@ -343,12 +344,8 @@ public sealed partial class ShuttleSystem component = AddComp(uid); component.State = FTLState.Starting; var audio = _audio.PlayPvs(_startupSound, uid); - audio.Value.Component.Flags |= AudioFlags.GridAudio; - - if (_physicsQuery.TryGetComponent(uid, out var gridPhysics)) - { - _transform.SetLocalPosition(audio.Value.Entity, gridPhysics.LocalCenter); - } + _audio.SetGridAudio(audio); + component.StartupStream = audio?.Entity; // TODO: Play previs here for docking arrival. @@ -377,6 +374,17 @@ public sealed partial class ShuttleSystem var body = _physicsQuery.GetComponent(entity); var shuttleCenter = body.LocalCenter; + // Leave audio at the old spot + // Just so we don't clip + if (fromMapUid != null && TryComp(comp.StartupStream, out AudioComponent? startupAudio)) + { + var clippedAudio = _audio.PlayStatic(_startupSound, Filter.Broadcast(), + new EntityCoordinates(fromMapUid.Value, _maps.GetGridPosition(entity.Owner)), true, startupAudio.Params); + + _audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime); + clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion; + } + // Offset the start by buffer range just to avoid overlap. var ftlStart = new EntityCoordinates(ftlMap, new Vector2(_index + width / 2f, 0f) - shuttleCenter); @@ -402,15 +410,7 @@ public sealed partial class ShuttleSystem // Audio var wowdio = _audio.PlayPvs(comp.TravelSound, uid); comp.TravelStream = wowdio?.Entity; - if (wowdio?.Component != null) - { - wowdio.Value.Component.Flags |= AudioFlags.GridAudio; - - if (_physicsQuery.TryGetComponent(uid, out var gridPhysics)) - { - _transform.SetLocalPosition(wowdio.Value.Entity, gridPhysics.LocalCenter); - } - } + _audio.SetGridAudio(wowdio); } /// @@ -509,13 +509,7 @@ public sealed partial class ShuttleSystem comp.TravelStream = _audio.Stop(comp.TravelStream); var audio = _audio.PlayPvs(_arrivalSound, uid); - audio.Value.Component.Flags |= AudioFlags.GridAudio; - // TODO: Shitcode til engine fix - - if (_physicsQuery.TryGetComponent(uid, out var gridPhysics)) - { - _transform.SetLocalPosition(audio.Value.Entity, gridPhysics.LocalCenter); - } + _audio.SetGridAudio(audio); if (TryComp(uid, out var dest)) { diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs index 6fe2324d51..bbafef022c 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs @@ -41,6 +41,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem [Dependency] private readonly MapLoaderSystem _loader = default!; [Dependency] private readonly MetaDataSystem _metadata = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedMapSystem _maps = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly ShuttleConsoleSystem _console = default!;