FMOD功能迁移

This commit is contained in:
2025-03-07 22:28:12 +08:00
parent 99a2e78466
commit dad6c087fd
336 changed files with 1597 additions and 3230 deletions
@@ -89,36 +89,36 @@ namespace AibisDream.Kit
#region
public void PlayMusic(string eventName)
public void PlayMusic(string eventName, string audioKey = null)
{
var eventPath = FormatEventPath(eventName);
if (_musicDict.TryGetValue(eventPath, out var oldMusic))
var key = string.IsNullOrEmpty(audioKey) ? eventName : audioKey;
if (_musicDict.TryGetValue(key, out var oldMusic))
{
oldMusic.start();
}
else
{
var newMusic = RuntimeManager.CreateInstance(eventPath);
_musicDict[eventPath] = newMusic;
newMusic.start();
oldMusic.stop(STOP_MODE.IMMEDIATE);
oldMusic.release();
_musicDict.Remove(key);
}
var newMusic = RuntimeManager.CreateInstance(eventPath);
_musicDict[key] = newMusic;
newMusic.start();
}
public void StopMusic(string eventName, STOP_MODE stopMode)
public void StopMusic(string key, STOP_MODE stopMode)
{
var eventPath = FormatEventPath(eventName);
if (_musicDict.TryGetValue(eventPath, out var oldMusic))
if (_musicDict.TryGetValue(key, out var oldMusic))
{
oldMusic.stop(stopMode);
oldMusic.release();
_musicDict.Remove(eventPath);
_musicDict.Remove(key);
}
}
public void SetMusicParam(string eventName, string param, float paramValue)
public void SetMusicParam(string key, string param, float paramValue)
{
var eventPath = FormatEventPath(eventName);
if (_musicDict.TryGetValue(eventPath, out var music))
if (_musicDict.TryGetValue(key, out var music))
{
music.setParameterByName(param, paramValue);
}
@@ -152,40 +152,39 @@ namespace AibisDream.Kit
}
}
public void PlaySfx(string eventName)
public void PlaySfx(string eventName, string audioKey = null)
{
var eventPath = FormatEventPath(eventName);
if (_sfxDict.TryGetValue(eventPath, out var oldSfx))
var key = string.IsNullOrEmpty(audioKey) ? eventName : audioKey;
if (_sfxDict.TryGetValue(key, out var oldSfx))
{
oldSfx.start();
oldSfx.stop(STOP_MODE.IMMEDIATE);
oldSfx.release();
_sfxDict.Remove(key);
}
else
var newSfx = RuntimeManager.CreateInstance(eventPath);
if (newSfx.GetDescription().isOneshot(out var isOneshot) != RESULT.OK || !isOneshot)
{
var newSfx = RuntimeManager.CreateInstance(eventPath);
if (newSfx.GetDescription().isOneshot(out var isOneshot) != RESULT.OK || !isOneshot)
{
_sfxDict[eventPath] = newSfx;
}
_sfxDict[key] = newSfx;
}
newSfx.start();
}
newSfx.start();
}
public void StopSfx(string eventName, STOP_MODE stopMode)
public void StopSfx(string key, STOP_MODE stopMode)
{
var eventPath = FormatEventPath(eventName);
if (_sfxDict.TryGetValue(eventPath, out var oldSfx))
if (_sfxDict.TryGetValue(key, out var oldSfx))
{
oldSfx.stop(stopMode);
oldSfx.release();
_musicDict.Remove(eventPath);
_musicDict.Remove(key);
}
}
public void SetSfxParam(string eventName, string paramName, float paramValue)
public void SetSfxParam(string key, string paramName, float paramValue)
{
var eventPath = FormatEventPath(eventName);
if (_sfxDict.TryGetValue(eventPath, out var sfx))
if (_sfxDict.TryGetValue(key, out var sfx))
{
sfx.setParameterByName(paramName, paramValue);
}
@@ -195,7 +194,7 @@ namespace AibisDream.Kit
private static string FormatEventPath(string eventName)
{
return $"event:/{eventName}";
return eventName.StartsWith("event:/") ? eventName : $"event:/{eventName}";
}
private static AmbState MatchAmbState(string key)
@@ -234,7 +233,7 @@ namespace AibisDream.Kit
public interface IAudioManager
{
// Yarn音频接口
public void PlayMusic(string eventName);
public void PlayMusic(string eventName, string audioKey);
public void StopMusic(string eventName, STOP_MODE stopMode);
public void SetMusicParam(string eventName, string paramName, float paramValue);
@@ -247,7 +246,7 @@ namespace AibisDream.Kit
public void OnLineShown();
// 交互相关
public void PlaySfx(string eventName);
public void PlaySfx(string eventName, string audioKey);
public void StopSfx(string eventName, STOP_MODE stopMode);
public void SetSfxParam(string eventName, string paramName, float paramValue);
}