/* *****************************USAGE EXAMPLE******************************
*let wave = SoundSFX(GetCurrentScriptDirectory~"./../sound/wave.wav");
*Above loads the sound effect and returns wave as an object referring to the loaded sound effect.
*Use PlaySFX(wave) to play the sound effect.
*DO NOT LOADSOUND IN INITIALIZE WHEN USING THIS *LIBRARY*
*Note: If a sound is deleted, ALL POINTERS TO IT WILL POINT TO NULL. 
*Make sure that if SetAutoObjectDelete is true, the sfx are reloaded before they are next used.
************************************************************************* */

/* *************************************************************************
*obj SoundSFX(char) -- Loads a sound effect and creates a sound object for the given sound effect
*pre: path is a valid filepath
*post: returns object ID of created sound object, or null if invalid path
************************************************************************* */
function SoundSFX(path){
    let obj = ObjSound_Create();
    ObjSound_Load(obj,path);
    ObjSound_SetSoundDivision(obj, SOUND_SE);
    ObjSound_SetLoopTime(obj, 0,300);
    ObjSound_SetVolumeRate(obj,GetAreaCommonData("Config", "SFXVolume", 95));
    return obj;
}

/* *************************************************************************
*void PlaySFX(obj) -- Plays a sound effect for a given sound object
*pre: obj is a valid Sound Object
************************************************************************* */
function PlaySFX(obj){
    ObjSound_Play(obj);
}

/* *************************************************************************
*void PlaySFXDelay(obj,int) -- Plays a sound effect for a given sound object for a given time
*pre: obj is a valid Sound Object, delay is an integer
************************************************************************* */
function PlaySFXDelay(obj, delay){
    loop(delay){yield;}
    ObjSound_Play(obj);
}