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

AudioSystem should raise a cancellable event to block audio from playing #5611

Open
ElectroJr opened this issue Jan 17, 2025 · 2 comments · May be fixed by #5632
Open

AudioSystem should raise a cancellable event to block audio from playing #5611

ElectroJr opened this issue Jan 17, 2025 · 2 comments · May be fixed by #5632
Labels
Area: Audio Difficulty: 1-Easy Not impossible to figure out for newer coders, and simple for experienced ones. Issue: Feature This issue is a feature request

Comments

@ElectroJr
Copy link
Member

There should be some way for content to prevent entities from making sounds. E.g., admin ghosts shouldn't make noise.
While it could just be implemented in content by ensuring that checks are performed before any audio system methods are called, it'd probably be much easier to just make the audio methods raise an attempt event. I.e., PlayEntity and PlayPvs should raise a cancellable event directed at the entity that the sound is being attached to. For audio being attached to a position rather than entity, I don't think there's an easy fix so that'd be up to content to block the method from being called.

@ElectroJr ElectroJr added Area: Audio Difficulty: 1-Easy Not impossible to figure out for newer coders, and simple for experienced ones. Issue: Feature This issue is a feature request labels Jan 17, 2025
@ElectroJr ElectroJr changed the title Need audio-blocking system/component AudioSystem should raise a cancellable event to block audio from playing Jan 17, 2025
@deltanedas
Copy link
Contributor

isnt most position playing because sounds get deleted when the attached entity is (or used to be deleted maybe it got fixed)

@ElectroJr
Copy link
Member Author

ElectroJr commented Jan 19, 2025

Audio attached to an entity still gets deleted alongside the entity its attached to.

If systems intentionally play the sound at a fixed location because they anticipate that the entity will get deleted, then yeah it wouldn't raise an event. Though I don't think its that common of a problem? The main one I can think of is breaking/smashing sounds from PlaySoundBehavior. But the kind of entities you'd want to force to be silent (like admin ghosts and things they are holding), probably wouldn't be that type of entity.

And like I said, in that case it'd be up to content to block the sound, so there should be some kind of a check within PlaySoundBehavior. I.e., it should raise an event directed at the source of the sound to verify that its not muted for whatever reason.

@JerryImMouse JerryImMouse linked a pull request Jan 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Audio Difficulty: 1-Easy Not impossible to figure out for newer coders, and simple for experienced ones. Issue: Feature This issue is a feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants