Don't spawn midi timer for inactive instruments (#14300)

This commit is contained in:
metalgearsloth
2023-03-24 13:47:38 +11:00
committed by GitHub
parent 6f87b0f81b
commit a0332c2f2e

View File

@@ -87,7 +87,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem
if (!Resolve(uid, ref instrument) || instrument.Renderer == null)
return;
instrument.Renderer.TrackingEntity = instrument.Owner;
instrument.Renderer.TrackingEntity = uid;
instrument.Renderer.DisablePercussionChannel = !instrument.AllowPercussion;
instrument.Renderer.DisableProgramChangeEvent = !instrument.AllowProgramChange;
@@ -127,7 +127,9 @@ public sealed class InstrumentSystem : SharedInstrumentSystem
// We dispose of the synth two seconds from now to allow the last notes to stop from playing.
// Don't use timers bound to the entity in case it is getting deleted.
Timer.Spawn(2000, () => { renderer?.Dispose(); });
if (renderer != null)
Timer.Spawn(2000, () => { renderer.Dispose(); });
instrument.Renderer = null;
instrument.MidiEventBuffer.Clear();