Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream merge 40 #542

Merged
merged 126 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
855ab4d
Update submodule to 182.1.0 (#21900)
metalgearsloth Nov 26, 2023
64343c2
Revert Arch testmerge 2 (#21901)
metalgearsloth Nov 26, 2023
14b8762
Add round ID to status HTTP API (#21904)
Simyon264 Nov 26, 2023
a8ea676
Admin Respawn Verb now works as intended (#21840)
nikthechampiongr Nov 26, 2023
dbb3da9
Panic bunker message is clearer now (#21908)
VasilisThePikachu Nov 27, 2023
8bf807a
Basic rate limiting for chat messages (#21907)
PJB3005 Nov 27, 2023
89204b1
Add component query benchmarks (#21891)
ElectroJr Nov 27, 2023
d3486d3
Revert "Add component query benchmarks (#21891)" (#21912)
DrSmugleaf Nov 27, 2023
269c932
Unrevert audio (#21330)
metalgearsloth Nov 27, 2023
1e50051
Update submodule to 183.0.0 (#21918)
metalgearsloth Nov 27, 2023
d8baa3f
Automatic changelog update
PJBot Nov 27, 2023
3423f11
Fix ahelps (#21921)
metalgearsloth Nov 27, 2023
417aa2c
Automatic changelog update
PJBot Nov 27, 2023
7f40908
Merge remote-tracking branch 'upstream/master' into upstream-merge-40
Werzet Nov 27, 2023
b4b4dd2
fix after merge
Werzet Nov 27, 2023
71800e2
Update buckleable.yml (#21924)
lzk228 Nov 27, 2023
ecf976b
allow mothroaches to use VIM (#21886)
Brandon-Huu Nov 27, 2023
78b76ee
Bandaid TEG shutdown (#21876)
metalgearsloth Nov 27, 2023
dc36eca
the fridging (#21896)
Ilya246 Nov 27, 2023
f268e62
Mining things (#21909)
NULL882 Nov 27, 2023
29aed88
Automatic changelog update
PJBot Nov 27, 2023
be53e16
Move hardcoded pirates gamerule prototype ids to validated consts (#2…
DrSmugleaf Nov 27, 2023
440de19
Moth accent (#21910)
lzk228 Nov 27, 2023
a8f9fd8
remove slowdown from parent (#21872)
asperger-sind Nov 27, 2023
9cd335c
Automatic changelog update
PJBot Nov 27, 2023
e9518e4
spaceacilling doesn't exist (#21875)
Brandon-Huu Nov 27, 2023
99b2ac2
Update cargo_armory.yml (#21880)
Tryded Nov 27, 2023
ca81cfb
Add chameleon functionality to Agent ID (#21878)
Rainfey Nov 27, 2023
f09b5f3
Automatic changelog update
PJBot Nov 27, 2023
ab645fb
revenant emag whitelist (#21849)
deltanedas Nov 27, 2023
89ba82f
Automatic changelog update
PJBot Nov 27, 2023
c7f4294
disables space wind and tile ripping cvars (#21847)
Flareguy Nov 27, 2023
94f67f8
weh (#21855)
VasilisThePikachu Nov 27, 2023
2447672
rev roundend shows converted count (#21854)
deltanedas Nov 27, 2023
a646c57
Automatic changelog update
PJBot Nov 27, 2023
5aa3c55
Anomaly Synchronizer fixes (#21883)
0x6273 Nov 27, 2023
da2e99c
Add anti-rot to cold cart (#21923)
IamVelcroboy Nov 27, 2023
b509a17
Fixes jani items not being storable on jani trolley (#21836)
IamVelcroboy Nov 27, 2023
45d191f
Automatic changelog update
PJBot Nov 27, 2023
e0dd5e1
Food/Bev updates and fixes (#21824)
IamVelcroboy Nov 27, 2023
c172e66
Fix ambient audio (#21933)
metalgearsloth Nov 28, 2023
2f1a553
Automatic changelog update
PJBot Nov 28, 2023
a844607
Guidebook entry for Cyborgs (#21832)
M3739 Nov 28, 2023
28f7aa3
Automatic changelog update
PJBot Nov 28, 2023
0a26fe1
disable hijack objective (#21928)
Emisse Nov 28, 2023
0357e41
add (#21935)
UbaserB Nov 28, 2023
0427bb2
Automatic changelog update
PJBot Nov 28, 2023
8b666fa
Add papercut-proof gloves for the HoP (#21915)
UbaserB Nov 28, 2023
0f5fe35
Automatic changelog update
PJBot Nov 28, 2023
79c59a4
detective is no longer useless (#21773)
Brandon-Huu Nov 28, 2023
ed2d59a
Fix riot shield audio and popup spam (#21881)
themias Nov 28, 2023
d1b6cfa
Automatic changelog update
PJBot Nov 28, 2023
89d94a3
add (#21939)
UbaserB Nov 28, 2023
de60120
Add metamorphic "Blood" sprite (#21596)
UbaserB Nov 28, 2023
eeebb3f
Automatic changelog update
PJBot Nov 28, 2023
d783b32
Update NetMessage to pass in MemoryStream (#21796)
metalgearsloth Nov 28, 2023
2aa2100
Update submodule to 184.0.0 (#21940)
metalgearsloth Nov 28, 2023
390a170
Merge remote-tracking branch 'upstream/master' into upstream-merge-40
Werzet Nov 28, 2023
1749538
fix after merge
Werzet Nov 28, 2023
44abae6
Update submodule to 184.0.1 (#21947)
metalgearsloth Nov 28, 2023
6c5a7bf
Automatic changelog update
PJBot Nov 28, 2023
4ed3cd3
remove old changelogs
Werzet Nov 28, 2023
1b79c7b
fix maps
Werzet Nov 28, 2023
0d728b9
Fix weather audio (#21949)
metalgearsloth Nov 28, 2023
6115290
Automatic changelog update
PJBot Nov 28, 2023
c60205f
Update submodule to 184.1.0 (#21950)
metalgearsloth Nov 28, 2023
c4e3bb3
Merge branch 'master' of https://github.com/space-wizards/space-stati…
TheArturZh Nov 28, 2023
fc48628
sync avrit
TheArturZh Nov 28, 2023
21b8563
resave delta emergency shuttle
TheArturZh Nov 28, 2023
b80f857
avrit fix
TheArturZh Nov 28, 2023
44d12d1
Fix docked shuttle breaking tests
TheArturZh Nov 28, 2023
918d8c2
Adds a new `AtmosphereSystem.GetTileMixture()` override (#21804)
ElectroJr Nov 28, 2023
6840c22
Merge branch 'master' into upstream-merge-40
TheArturZh Nov 28, 2023
b2aefde
Set FTL sounds as grid audio (#21951)
metalgearsloth Nov 28, 2023
3dd8f66
Automatic changelog update
PJBot Nov 28, 2023
03ed3ff
Make TagComponent networked (#21958)
PixelTheKermit Nov 28, 2023
7ada1c6
Update content to new ParallelManager (#21813)
metalgearsloth Nov 29, 2023
97b22ec
Update submodule to 185.0.0 (#21964)
metalgearsloth Nov 29, 2023
f9e4f5e
Reduce ChunkingSystem allocations (#21795)
ElectroJr Nov 29, 2023
cebf082
Fix GridFill comp skip (#21944)
metalgearsloth Nov 29, 2023
0ded865
Use PoolManager testmap for EntityTest (#21968)
metalgearsloth Nov 29, 2023
7838799
Disable artifact spam on roundend (#21970)
metalgearsloth Nov 29, 2023
8dc3117
Automatic changelog update
PJBot Nov 29, 2023
6ed2557
Fix salamander artifact cvar (#21973)
metalgearsloth Nov 29, 2023
0f9f926
Update submodule to 185.1.0 (#21974)
metalgearsloth Nov 29, 2023
6f19854
Automatic changelog update
PJBot Nov 29, 2023
acf60db
Optimise mob movement (#21978)
metalgearsloth Nov 29, 2023
0996680
Update Patrons.yml (#21979)
DrSmugleaf Nov 29, 2023
b08c4ed
Fix getting stuck on tables (#21981)
metalgearsloth Nov 29, 2023
b8a25d9
Automatic changelog update
PJBot Nov 29, 2023
be0de53
No more stacked RoboDrobe (#21988)
Aexxie Nov 29, 2023
c3f8571
Avoid emptying and recreating all UI cards on every update (#21990)
eoineoineoin Nov 29, 2023
eebbdeb
Merge branch 'master' of https://github.com/space-wizards/space-stati…
TheArturZh Nov 29, 2023
2a10433
Merge branch 'upstream-merge-40' of https://github.com/Werzet/space-s…
TheArturZh Nov 29, 2023
4ed0913
upped the bandolier slots to 14 and made it function like an ammo box…
Boaz1111 Nov 29, 2023
5d728a3
Update submodule to 185.1.1 (#21994)
metalgearsloth Nov 30, 2023
3a5b3b5
Automatic changelog update
PJBot Nov 30, 2023
bb6091a
Mining things [part 2] (#21953)
NULL882 Nov 30, 2023
1ff83ee
skele-zombie brrrrr (#21996)
lzk228 Nov 30, 2023
3d6e9e1
Automatic changelog update
PJBot Nov 30, 2023
76d091d
some lil brrrr (#21955)
lzk228 Nov 30, 2023
0c7fc2c
removes the biomass-reclaimer on saltern (#22007)
Brandon-Huu Nov 30, 2023
9d30e2c
removes the biomass-reclaimer on origin (#22008)
Brandon-Huu Nov 30, 2023
26d63e7
removes the biomass-reclaimer on kettle (#22009)
Brandon-Huu Nov 30, 2023
be622ca
removes the biomass-reclaimer on cluster (#22010)
Brandon-Huu Nov 30, 2023
665baaa
removes the biomass-reclaimer on box (#22011)
Brandon-Huu Nov 30, 2023
4b3fcd9
removes the biomass-reclaimer on aspid (#22012)
Brandon-Huu Nov 30, 2023
ca3e09b
greenified the cap cap (#22013)
MACMAN2003 Nov 30, 2023
8cee39c
Automatic changelog update
PJBot Nov 30, 2023
9f2fc76
bagel update (#22014)
Emisse Nov 30, 2023
645b528
Core v2: Full revamp (#21892)
UbaserB Nov 30, 2023
af1130e
Automatic changelog update
PJBot Nov 30, 2023
30f4a3c
Fix SpawnAndDeleteEntityCountTest heisentest (#21975)
metalgearsloth Nov 30, 2023
d844d79
Update submodule to 185.2.0 (#22019)
metalgearsloth Nov 30, 2023
8e5f53a
Add a debug command for global audio (#22018)
metalgearsloth Nov 30, 2023
13cef16
Merge branch 'master' of https://github.com/space-wizards/space-stati…
TheArturZh Nov 30, 2023
16df3c8
Waist bag nerf (#22026)
Boaz1111 Nov 30, 2023
1aa07db
add custom PDA for nukie medic (#22016)
UbaserB Nov 30, 2023
d795729
Add verb to spawn players on the spot (#22000)
metalgearsloth Nov 30, 2023
5ac84e6
Automatic changelog update
PJBot Nov 30, 2023
bf2bdd6
Fix chameleon changing ID card metadata (#21998)
Rainfey Nov 30, 2023
9ba3a3e
Automatic changelog update
PJBot Nov 30, 2023
33fb768
New mutation species plant, Lemoon Tree (#22023)
DoubleRiceEddiedd Nov 30, 2023
a00d825
Automatic changelog update
PJBot Nov 30, 2023
55ede6d
Merge branch 'master' into upstream-merge-40
TheArturZh Nov 30, 2023
0607169
Merge branch 'master' of https://github.com/space-wizards/space-stati…
TheArturZh Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 31 additions & 27 deletions Content.Client/Audio/AmbientSoundSystem.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
using System.Linq;
using System.Numerics;
using Content.Shared.Audio;
using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Audio;
using Robust.Shared.Log;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Shared.Audio.Effects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;

namespace Content.Client.Audio;
//TODO: This is using a incomplete version of the whole "only play nearest sounds" algo, that breaks down a bit should the ambient sound cap get hit.
Expand Down Expand Up @@ -41,14 +46,18 @@ protected override void QueueUpdate(EntityUid uid, AmbientSoundComponent ambienc
private TimeSpan _targetTime = TimeSpan.Zero;
private float _ambienceVolume = 0.0f;

private static AudioParams _params = AudioParams.Default.WithVariation(0.01f).WithLoop(true).WithAttenuation(Attenuation.LinearDistance);
private static AudioParams _params = AudioParams.Default
.WithVariation(0.01f)
.WithLoop(true)
.WithAttenuation(Attenuation.LinearDistance)
.WithMaxDistance(7f);

/// <summary>
/// How many times we can be playing 1 particular sound at once.
/// </summary>
private int MaxSingleSound => (int) (_maxAmbientCount / (16.0f / 6.0f));

private readonly Dictionary<Entity<AmbientSoundComponent>, (IPlayingAudioStream? Stream, SoundSpecifier Sound, string Path)> _playingSounds = new();
private readonly Dictionary<AmbientSoundComponent, (EntityUid? Stream, SoundSpecifier Sound, string Path)> _playingSounds = new();
private readonly Dictionary<string, int> _playingCount = new();

public bool OverlayEnabled
Expand Down Expand Up @@ -98,10 +107,10 @@ public override void Initialize()

private void OnShutdown(EntityUid uid, AmbientSoundComponent component, ComponentShutdown args)
{
if (!_playingSounds.Remove((uid, component), out var sound))
if (!_playingSounds.Remove(component, out var sound))
return;

sound.Stream?.Stop();
_audio.Stop(sound.Stream);
_playingCount[sound.Path] -= 1;
if (_playingCount[sound.Path] == 0)
_playingCount.Remove(sound.Path);
Expand All @@ -111,13 +120,13 @@ private void SetAmbienceVolume(float value)
{
_ambienceVolume = value;

foreach (var ((_, comp), values) in _playingSounds)
foreach (var (comp, values) in _playingSounds)
{
if (values.Stream == null)
continue;

var stream = (AudioSystem.PlayingStream) values.Stream;
stream.Volume = _params.Volume + comp.Volume + _ambienceVolume;
var stream = values.Stream;
_audio.SetVolume(stream, _params.Volume + comp.Volume + _ambienceVolume);
}
}
private void SetCooldown(float value) => _cooldown = value;
Expand Down Expand Up @@ -177,7 +186,7 @@ private void ClearSounds()
{
foreach (var (stream, _, _) in _playingSounds.Values)
{
stream?.Stop();
_audio.Stop(stream);
}

_playingSounds.Clear();
Expand All @@ -186,7 +195,7 @@ private void ClearSounds()

private readonly struct QueryState
{
public readonly Dictionary<string, List<(float Importance, Entity<AmbientSoundComponent>)>> SourceDict = new();
public readonly Dictionary<string, List<(float Importance, AmbientSoundComponent)>> SourceDict = new();
public readonly Vector2 MapPos;
public readonly TransformComponent Player;
public readonly EntityQuery<TransformComponent> Query;
Expand Down Expand Up @@ -224,7 +233,7 @@ private static bool Callback(

// Prioritize far away & loud sounds.
var importance = range * (ambientComp.Volume + 32);
state.SourceDict.GetOrNew(key).Add((importance, (ambientComp.Owner, ambientComp)));
state.SourceDict.GetOrNew(key).Add((importance, ambientComp));
return true;
}

Expand All @@ -238,10 +247,9 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
var mapPos = playerXform.MapPosition;

// Remove out-of-range ambiences
foreach (var (ent, sound) in _playingSounds)
foreach (var (comp, sound) in _playingSounds)
{
var entity = ent.Owner;
var comp = ent.Comp;
var entity = comp.Owner;

if (comp.Enabled &&
// Don't keep playing sounds that have changed since.
Expand All @@ -258,8 +266,8 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
continue;
}

sound.Stream?.Stop();
_playingSounds.Remove((entity, comp));
_audio.Stop(sound.Stream);
_playingSounds.Remove(comp);
_playingCount[sound.Path] -= 1;
if (_playingCount[sound.Path] == 0)
_playingCount.Remove(sound.Path);
Expand All @@ -284,12 +292,11 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)

sources.Sort(static (a, b) => b.Importance.CompareTo(a.Importance));

foreach (var (_, ent) in sources)
foreach (var (_, comp) in sources)
{
var uid = ent.Owner;
var comp = ent.Comp;
var uid = comp.Owner;

if (_playingSounds.ContainsKey(ent) ||
if (_playingSounds.ContainsKey(comp) ||
metaQuery.GetComponent(uid).EntityPaused)
continue;

Expand All @@ -299,11 +306,8 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
.WithPlayOffset(_random.NextFloat(0.0f, 100.0f))
.WithMaxDistance(comp.Range);

var stream = _audio.PlayPvs(comp.Sound, uid, audioParams);
if (stream == null)
continue;

_playingSounds[ent] = (stream, comp.Sound, key);
var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams);
_playingSounds[comp] = (stream.Value.Entity, comp.Sound, key);
playingCount++;

if (_playingSounds.Count >= _maxAmbientCount)
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Audio/BackgroundAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Client;
using Robust.Client.State;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

Expand All @@ -21,7 +22,7 @@ public sealed class BackgroundAudioSystem : EntitySystem

private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);

private IPlayingAudioStream? _lobbyStream;
private EntityUid? _lobbyStream;

public override void Initialize()
{
Expand Down Expand Up @@ -118,12 +119,11 @@ public void StartLobbyMusic()
}

_lobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
_lobbyParams.WithVolume(_lobbyParams.Volume + _configManager.GetCVar(CCVars.LobbyMusicVolume)));
_lobbyParams.WithVolume(_lobbyParams.Volume + _configManager.GetCVar(CCVars.LobbyMusicVolume)))?.Entity;
}

private void EndLobbyMusic()
{
_lobbyStream?.Stop();
_lobbyStream = null;
_lobbyStream = _audio.Stop(_lobbyStream);
}
}
25 changes: 14 additions & 11 deletions Content.Client/Audio/ClientGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

Expand All @@ -14,11 +15,11 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem

// Admin music
private bool _adminAudioEnabled = true;
private List<IPlayingAudioStream?> _adminAudio = new(1);
private List<EntityUid?> _adminAudio = new(1);

// Event sounds (e.g. nuke timer)
private bool _eventAudioEnabled = true;
private Dictionary<StationEventMusicType, IPlayingAudioStream?> _eventAudio = new(1);
private Dictionary<StationEventMusicType, EntityUid?> _eventAudio = new(1);

public override void Initialize()
{
Expand Down Expand Up @@ -49,13 +50,13 @@ private void ClearAudio()
{
foreach (var stream in _adminAudio)
{
stream?.Stop();
_audio.Stop(stream);
}
_adminAudio.Clear();

foreach (var (_, stream) in _eventAudio)
foreach (var stream in _eventAudio.Values)
{
stream?.Stop();
_audio.Stop(stream);
}

_eventAudio.Clear();
Expand All @@ -66,7 +67,7 @@ private void PlayAdminSound(AdminSoundEvent soundEvent)
if(!_adminAudioEnabled) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_adminAudio.Add(stream);
_adminAudio.Add(stream.Value.Entity);
}

private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
Expand All @@ -75,7 +76,7 @@ private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream);
_eventAudio.Add(soundEvent.Type, stream.Value.Entity);
}

private void PlayGameSound(GameGlobalSoundEvent soundEvent)
Expand All @@ -85,8 +86,10 @@ private void PlayGameSound(GameGlobalSoundEvent soundEvent)

private void StopStationEventMusic(StopStationEventMusic soundEvent)
{
if (!_eventAudio.TryGetValue(soundEvent.Type, out var stream)) return;
stream?.Stop();
if (!_eventAudio.TryGetValue(soundEvent.Type, out var stream))
return;

_audio.Stop(stream);
_eventAudio.Remove(soundEvent.Type);
}

Expand All @@ -96,7 +99,7 @@ private void ToggleAdminSound(bool enabled)
if (_adminAudioEnabled) return;
foreach (var stream in _adminAudio)
{
stream?.Stop();
_audio.Stop(stream);
}
_adminAudio.Clear();
}
Expand All @@ -107,7 +110,7 @@ private void ToggleStationEventMusic(bool enabled)
if (_eventAudioEnabled) return;
foreach (var stream in _eventAudio)
{
stream.Value?.Stop();
_audio.Stop(stream.Value);
}
_eventAudio.Clear();
}
Expand Down
39 changes: 18 additions & 21 deletions Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Robust.Client.ResourceManagement;
using Robust.Client.State;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -39,7 +41,7 @@ public sealed partial class ContentAudioSystem
// Don't need to worry about this being serializable or pauseable as it doesn't affect the sim.
private TimeSpan _nextAudio;

private AudioSystem.PlayingStream? _ambientMusicStream;
private EntityUid? _ambientMusicStream;
private AmbientMusicPrototype? _musicProto;

/// <summary>
Expand All @@ -58,12 +60,6 @@ public sealed partial class ContentAudioSystem

private void InitializeAmbientMusic()
{
// TODO: Shitty preload
foreach (var audio in _proto.Index<SoundCollectionPrototype>("AmbienceSpace").PickFiles)
{
_resource.GetResource<AudioResource>(audio.ToString());
}

_configManager.OnValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("audio.ambience");

Expand All @@ -83,7 +79,7 @@ private void AmbienceCVarChanged(float obj)

if (_ambientMusicStream != null && _musicProto != null)
{
_ambientMusicStream.Volume = _musicProto.Sound.Params.Volume + _volumeSlider;
_audio.SetVolume(_ambientMusicStream, _musicProto.Sound.Params.Volume + _volumeSlider);
}
}

Expand All @@ -92,7 +88,7 @@ private void ShutdownAmbientMusic()
_configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
_proto.PrototypesReloaded -= OnProtoReload;
_state.OnStateChanged -= OnStateChange;
_ambientMusicStream?.Stop();
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
}

private void OnProtoReload(PrototypesReloadedEventArgs obj)
Expand Down Expand Up @@ -129,8 +125,7 @@ private void SetupAmbientSounds()
private void OnRoundEndMessage(RoundEndMessageEvent ev)
{
// If scoreboard shows then just stop the music
_ambientMusicStream?.Stop();
_ambientMusicStream = null;
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
_nextAudio = TimeSpan.FromMinutes(3);
}

Expand Down Expand Up @@ -170,15 +165,20 @@ private void UpdateAmbientMusic()
return;
}

var isDone = _ambientMusicStream?.Done;
bool? isDone = null;

if (TryComp(_ambientMusicStream, out AudioComponent? audioComp))
{
isDone = !audioComp.Playing;
}

if (_interruptable)
{
var player = _player.LocalPlayer?.ControlledEntity;
var player = _player.LocalSession?.AttachedEntity;

if (player == null || _musicProto == null || !_rules.IsTrue(player.Value, _proto.Index<RulesPrototype>(_musicProto.Rules)))
{
FadeOut(_ambientMusicStream, AmbientMusicFadeTime);
FadeOut(_ambientMusicStream, duration: AmbientMusicFadeTime);
_musicProto = null;
_interruptable = false;
isDone = true;
Expand Down Expand Up @@ -221,14 +221,11 @@ private void UpdateAmbientMusic()
false,
AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider));

if (strim != null)
{
_ambientMusicStream = (AudioSystem.PlayingStream) strim;
_ambientMusicStream = strim.Value.Entity;

if (_musicProto.FadeIn)
{
FadeIn(_ambientMusicStream, AmbientMusicFadeTime);
}
if (_musicProto.FadeIn)
{
FadeIn(_ambientMusicStream, strim.Value.Component, AmbientMusicFadeTime);
}

// Refresh the list
Expand Down
Loading
Loading