feat: 解耦音频与触感系统

This commit is contained in:
2026-05-15 10:09:55 +08:00
parent 53754cd4b8
commit 51ac57d494
4 changed files with 43 additions and 22 deletions
@@ -0,0 +1,32 @@
using OCES.Haptic;
using UnityEngine;
namespace OCES.Audio
{
public partial class AudioSystem
{
partial void OnAwakeComplete()
{
this.m_sfxSystem.OnSoundStarted += activeSound =>
{
uint hapticId = activeSound.AudioObject.Haptic;
if (hapticId == 0) return;
if (activeSound.AudioObject.ContainerType == ContainerType.Blend && activeSound.AudioObject.Haptic > 0)
{
Debug.LogWarning($"[Haptic System] Blend container {activeSound.AudioObject.Id} should not have haptic feedback!");
return;
}
HapticSystem.Instance.Play(hapticId, isDirectCall: false);
};
this.m_sfxSystem.OnSoundStopped += activeSound =>
{
uint hapticId = activeSound.AudioObject.Haptic;
if (hapticId == 0) return;
HapticSystem.Instance.Stop(hapticId);
};
}
}
}