Open
Conversation
Owner
|
I probably won't be merging this for a few reasons; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credit: Original approach by cany0udance, adapted for BaseLib as ModAudio.
What it does
Loads .ogg files from your mod’s Godot project using a resource path to the audio folder (the folder that contains sfx and bgm), so you don’t hard-code full paths everywhere.
Folder layout (your audio folder, e.g. res://ThePaladin/audio)
Sound effects: sfx/.ogg
Optional subfolder: sfx//.ogg
Music / ambience: bgm/.ogg
Hook it to your character
On your CustomCharacterModel, override CustomAudioPath and return that audio path (e.g. res://TheCharacter/audio).
Use ModAudio.PlaySfx("Name", volumeDb) etc. from your mod. If you only use one audio root, BaseLib infers it when your character is constructed; you can still call ModAudio.SetRoot to override or when you have multiple roots.
Optional: ModAudio.Register("your_character_id", "res://YourMod/audio") for id-based overloads, or ModAudio.DiscoverPlaceholderCharacters() for PlaceholderCharacterModel discovery.
Playing audio
Use ModAudio (PlaySfx, Play with optional folder, PlayGlobalSfx, PlayMusic, fades, ambience, …). Use SetRoot, a character id, or a CustomCharacterModel reference when you need to pick between multiple roots.
Note: Combat SFX attach to the combat room when it exists; global SFX use the scene tree as implemented in **ModAudio.
Example
If you have an audio file named SFX_Boom.ogg in your res://TheCharacter/audio/sfx folder:
using BaseLib.Utils;
in your customcharacter.cs:
public override string? CustomAudioPath => "res://TheCharacter/audio";
then somewhere in your class e.g. (example from rhythm girl card)
ModAudio.PlaySfx("SFX_JabExhaust", 5f);