Use Timer.Spawn instead of TimerComp timers when disposing MIDI Renderers.

- Fixes a bug where renderers are not disposed of correctly when the instrument entity is deleted.
This commit is contained in:
Vera Aguilera Puerto
2021-12-18 00:30:20 +01:00
parent 4b6ca8fd93
commit e9c812c29c

View File

@@ -129,7 +129,8 @@ namespace Content.Client.Instruments
var renderer = instrument.Renderer;
// We dispose of the synth two seconds from now to allow the last notes to stop from playing.
instrument.Owner.SpawnTimer(2000, () => { renderer?.Dispose(); });
// Don't use timers bound to the entity in case it is getting deleted.
Timer.Spawn(2000, () => { renderer?.Dispose(); });
instrument.Renderer = null;
instrument.MidiEventBuffer.Clear();