utopia-rise / fmod-gdextension

FMOD Studio GDExtension bindings for the Godot game engine
MIT License
438 stars 48 forks source link

Fix OneShot system. #201

Closed CedNaru closed 6 months ago

CedNaru commented 6 months ago

It had previously leftovers from the implementation in Godot 3.x (all events, not only oneshots were managed by the server) so I got rid of them.

A oneshot is actually not something up to the Godot user to decide, it's a property of the Fmod event itself, I removed its setter from the FmodEmitter node.

On top of that, only oneshot events can now be used as such. If not, a warning will be thrown. The reason for this is that one shot events can actually end (unlike the ones designed to loop), otherwise they would continue playing forever without any way to stop them.

The methods to play a one shot won't ask for a Node if not attached.

Because emitters can no longer be set as oneshot, I replaced it with an auto release feature. When the event is done playing, the node will automatically free itself. This way, you can instantiate a scene containing a node with autoplay + autorelease to emulate oneshots.

When it comes to the implementation, I decided to simplify a bit. I removed a bunch of methods called "internal" as they were used only once and remove template parameters that were always the same.

CedNaru commented 6 months ago

Some formatting changes too, it seems some of our files were using tabs instead of space.