When we use PlaySound() we cannot get the sound instance reference we just created by invoking the function, this makes us unable to perform the stop of a particular sound if needed, what I was thinking was a refactoring of the code in order to return a sound interface object (something like ISound) to handle sound instances for further uses or at least for stopping them, usually sounds are very small in terms of duration, but there are some of them with moderate length, and they are persistent even when you close the editor (this is not a complain post about hearing sounds even after closing the editor, but, I mean, it should not happen).
Imagine a map when you constantly die and respawn and you're continuously hearing the death sound, with a sound interface you could:
- Get the currently playing sound instances in the game world;
- Terminate one sound instance;
- Get the name of the playing sound effect in one particular instance.