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

Merge wizden up to 02/12 - Part 2 #501

Merged
merged 135 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
1f69429
Update submodule to 183.0.0 (#21918)
metalgearsloth Nov 27, 2023
b1ee2d4
Unrevert audio (#21330)
metalgearsloth Nov 27, 2023
a5fad30
Automatic changelog update
PJBot Nov 27, 2023
470f334
Fix ahelps (#21921)
metalgearsloth Nov 27, 2023
d8d049b
Automatic changelog update
PJBot Nov 27, 2023
76ac850
Update buckleable.yml (#21924)
lzk228 Nov 27, 2023
8047d36
allow mothroaches to use VIM (#21886)
Brandon-Huu Nov 27, 2023
bce8cec
Bandaid TEG shutdown (#21876)
metalgearsloth Nov 27, 2023
15ead08
the fridging (#21896)
Ilya246 Nov 27, 2023
670e4c8
Mining things (#21909)
NULL882 Nov 27, 2023
97979d0
Automatic changelog update
PJBot Nov 27, 2023
6733051
Move hardcoded pirates gamerule prototype ids to validated consts (#2…
DrSmugleaf Nov 27, 2023
9c61478
Moth accent (#21910)
lzk228 Nov 27, 2023
e9d7d5d
remove slowdown from parent (#21872)
asperger-sind Nov 27, 2023
fcb83a1
Automatic changelog update
PJBot Nov 27, 2023
fe260b3
Update cargo_armory.yml (#21880)
Tryded Nov 27, 2023
84eb750
Add chameleon functionality to Agent ID (#21878)
Rainfey Nov 27, 2023
d86bb2e
Automatic changelog update
PJBot Nov 27, 2023
c88131b
revenant emag whitelist (#21849)
deltanedas Nov 27, 2023
137f1d3
Automatic changelog update
PJBot Nov 27, 2023
a289350
disables space wind and tile ripping cvars (#21847)
Flareguy Nov 27, 2023
10d9c23
weh (#21855)
VasilisThePikachu Nov 27, 2023
10d32ea
rev roundend shows converted count (#21854)
deltanedas Nov 27, 2023
f0d7879
Automatic changelog update
PJBot Nov 27, 2023
87521b3
Anomaly Synchronizer fixes (#21883)
0x6273 Nov 27, 2023
e064878
Add anti-rot to cold cart (#21923)
IamVelcroboy Nov 27, 2023
720f25d
Fixes jani items not being storable on jani trolley (#21836)
IamVelcroboy Nov 27, 2023
51a08dc
Automatic changelog update
PJBot Nov 27, 2023
dc5f63e
Food/Bev updates and fixes (#21824)
IamVelcroboy Nov 27, 2023
d708bbd
Fix ambient audio (#21933)
metalgearsloth Nov 28, 2023
0f43ed9
Automatic changelog update
PJBot Nov 28, 2023
6c0d522
Guidebook entry for Cyborgs (#21832)
M3739 Nov 28, 2023
a7be183
Automatic changelog update
PJBot Nov 28, 2023
474d717
disable hijack objective (#21928)
Emisse Nov 28, 2023
ec16091
add (#21935)
UbaserB Nov 28, 2023
5bd269d
Automatic changelog update
PJBot Nov 28, 2023
87c482a
Add papercut-proof gloves for the HoP (#21915)
UbaserB Nov 28, 2023
d562ffc
Automatic changelog update
PJBot Nov 28, 2023
8b1247b
Fix riot shield audio and popup spam (#21881)
themias Nov 28, 2023
05a6618
Automatic changelog update
PJBot Nov 28, 2023
50ca42c
add (#21939)
UbaserB Nov 28, 2023
bc4135c
Add metamorphic "Blood" sprite (#21596)
UbaserB Nov 28, 2023
432402e
Automatic changelog update
PJBot Nov 28, 2023
47ce5f8
Update NetMessage to pass in MemoryStream (#21796)
metalgearsloth Nov 28, 2023
878d975
Update submodule to 184.0.0 (#21940)
metalgearsloth Nov 28, 2023
f53354c
Update submodule to 184.0.1 (#21947)
metalgearsloth Nov 28, 2023
db9138c
Automatic changelog update
PJBot Nov 28, 2023
e6737b6
Fix weather audio (#21949)
metalgearsloth Nov 28, 2023
5ccbbd0
Automatic changelog update
PJBot Nov 28, 2023
af3306d
Update submodule to 184.1.0 (#21950)
metalgearsloth Nov 28, 2023
99f9583
Adds a new `AtmosphereSystem.GetTileMixture()` override (#21804)
ElectroJr Nov 28, 2023
b687ac1
Set FTL sounds as grid audio (#21951)
metalgearsloth Nov 28, 2023
b3825b0
Automatic changelog update
PJBot Nov 28, 2023
7bd005e
Make TagComponent networked (#21958)
PixelTheKermit Nov 28, 2023
122d6f0
Update content to new ParallelManager (#21813)
metalgearsloth Nov 29, 2023
28ce21a
Update submodule to 185.0.0 (#21964)
metalgearsloth Nov 29, 2023
a5d30fa
Reduce ChunkingSystem allocations (#21795)
ElectroJr Nov 29, 2023
fa25e1f
Fix GridFill comp skip (#21944)
metalgearsloth Nov 29, 2023
59037cd
Use PoolManager testmap for EntityTest (#21968)
metalgearsloth Nov 29, 2023
65922ef
Disable artifact spam on roundend (#21970)
metalgearsloth Nov 29, 2023
fcb9e5c
Automatic changelog update
PJBot Nov 29, 2023
f2c5fdb
Fix salamander artifact cvar (#21973)
metalgearsloth Nov 29, 2023
6ad995a
Update submodule to 185.1.0 (#21974)
metalgearsloth Nov 29, 2023
7dad2fd
Automatic changelog update
PJBot Nov 29, 2023
82e8da6
Optimise mob movement (#21978)
metalgearsloth Nov 29, 2023
51bbbdf
Update Patrons.yml (#21979)
DrSmugleaf Nov 29, 2023
e8cf316
Fix getting stuck on tables (#21981)
metalgearsloth Nov 29, 2023
de8c894
Automatic changelog update
PJBot Nov 29, 2023
64fda31
Avoid emptying and recreating all UI cards on every update (#21990)
eoineoineoin Nov 29, 2023
5a4eda8
upped the bandolier slots to 14 and made it function like an ammo box…
Boaz1111 Nov 29, 2023
38dd57f
Update submodule to 185.1.1 (#21994)
metalgearsloth Nov 30, 2023
8d9c2b3
Automatic changelog update
PJBot Nov 30, 2023
8ee3266
Mining things [part 2] (#21953)
NULL882 Nov 30, 2023
d8d0add
skele-zombie brrrrr (#21996)
lzk228 Nov 30, 2023
8b6a125
Automatic changelog update
PJBot Nov 30, 2023
0ebc5a2
some lil brrrr (#21955)
lzk228 Nov 30, 2023
dcfbef4
greenified the cap cap (#22013)
MACMAN2003 Nov 30, 2023
1be4172
Automatic changelog update
PJBot Nov 30, 2023
74bb935
Automatic changelog update
PJBot Nov 30, 2023
d63396a
Fix SpawnAndDeleteEntityCountTest heisentest (#21975)
metalgearsloth Nov 30, 2023
4f61aab
Update submodule to 185.2.0 (#22019)
metalgearsloth Nov 30, 2023
8bb4900
Add a debug command for global audio (#22018)
metalgearsloth Nov 30, 2023
b5fbee7
add custom PDA for nukie medic (#22016)
UbaserB Nov 30, 2023
30457a2
Add verb to spawn players on the spot (#22000)
metalgearsloth Nov 30, 2023
90062da
Automatic changelog update
PJBot Nov 30, 2023
3d7376d
Fix chameleon changing ID card metadata (#21998)
Rainfey Nov 30, 2023
eeed1b0
Automatic changelog update
PJBot Nov 30, 2023
ba4c126
New mutation species plant, Lemoon Tree (#22023)
DoubleRiceEddiedd Nov 30, 2023
01964e8
Automatic changelog update
PJBot Nov 30, 2023
c183a6a
centcomm christmas update (#22043)
Emisse Dec 1, 2023
649f9b4
nukieplanet christmas update (#22044)
Emisse Dec 1, 2023
d663746
Cryostasis syringe (#22021)
Boaz1111 Dec 1, 2023
4f1ae31
Add more playaudio debugging (#22047)
metalgearsloth Dec 1, 2023
24816cb
added classic business hair (#22048)
MACMAN2003 Dec 1, 2023
b143558
Add more global audio debugging yipee (#22050)
metalgearsloth Dec 1, 2023
b479622
gave AccessReaderComponent (#22053)
joshepvodka Dec 1, 2023
731b9be
add (#22054)
UbaserB Dec 1, 2023
fce65ec
Update submodule to 186.0.0 (#22056)
metalgearsloth Dec 1, 2023
375aec4
Improve/fix senior physician beret (#22051)
UbaserB Dec 1, 2023
1808f49
Automatic changelog update
PJBot Dec 1, 2023
04315f7
Sort reagent prototypes for solutions (#22049)
enumerate0 Dec 1, 2023
42743fd
Automatic changelog update
PJBot Dec 1, 2023
fbfefe9
Update submodule to 186.1.0 (#22058)
metalgearsloth Dec 1, 2023
2635f4a
Add even more logging to audio debug comm (#22057)
metalgearsloth Dec 1, 2023
59d9183
adds the death acidifier implant and returns the micro-bomb implant t…
QuietlyWhisper Dec 1, 2023
e6da6e9
Automatic changelog update
PJBot Dec 1, 2023
63c1031
Gri​nch's ultimatum (#22067)
crazybrain23 Dec 1, 2023
91b8c4c
Reduced the fuel decay rate of rad collectors (#22063)
chromiumboy Dec 1, 2023
991c92b
Lizards can now have taco tuesdays (#21957)
VasilisThePikachu Dec 1, 2023
0b285a7
Automatic changelog update
PJBot Dec 1, 2023
5df59eb
Remove the awful audio command (#22071)
metalgearsloth Dec 1, 2023
dc4ec07
Borgs can now speak while in Crit (#21802)
Rainbeon Dec 2, 2023
125cfa3
Automatic changelog update
PJBot Dec 2, 2023
cdaa2bb
Update submodule to 187.0.0 (#22080)
metalgearsloth Dec 2, 2023
20b53a9
Automatic changelog update
PJBot Dec 2, 2023
6a3f9e8
Nerf mothroaches slightly + make them not able to pull (#21864)
EEASAS Dec 2, 2023
f79746e
Fix RoundToLevels not working with an even amount of levels if the th…
DrSmugleaf Dec 2, 2023
c9e8655
Automatic changelog update
PJBot Dec 2, 2023
2202782
Research Server Texture (#22092)
Nairodian Dec 2, 2023
1dfeb05
added new chemical called Sodium Polyacrylate (#21833)
Moomoobeef Dec 2, 2023
399d416
Automatic changelog update
PJBot Dec 2, 2023
1f1a722
Refactor NPCRetaliationSystem::Update to fix crash caused by Debug As…
Chronophylos Dec 2, 2023
51fff78
Botany balancing fixes and QoL ('No romerol ambrosia' edition) (#21756)
Doru991 Dec 2, 2023
399feb1
Automatic changelog update
PJBot Dec 2, 2023
bced72b
added Dark Green Jumpsuits and Jumpskirts to the Clothesmate (#21713)
GNF54 Dec 2, 2023
afb1aab
fix anom scanner interact check (#21929)
qwerltaz Dec 2, 2023
671059f
updated Remilia sprite/copyright (#21846)
Dec 2, 2023
8852a19
Automatic changelog update
PJBot Dec 2, 2023
1ab939c
Add New Reaction : Oil (#21737)
Minty642 Dec 2, 2023
7a2d48b
Automatic changelog update
PJBot Dec 2, 2023
dacd620
Add sounds when inserting/missing into a disposal (#22077)
enumerate0 Dec 2, 2023
52c87a6
Automatic changelog update
PJBot Dec 2, 2023
5a29426
Ghetto Mindshield Icon (#20958)
coolmankid12345 Dec 2, 2023
2741a3d
Update drinks-cartons.yml
DebugOk Dec 2, 2023
fb0fcc4
Fixes Electrocuting grabbed targets while insulated (#22087)
tomasalves8 Dec 2, 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