- TD-13: IQuestManager.CompleteQuest 改用 IRewardTarget,移除 using BaseGames.Player - TD-14: HurtFlashController 缓存 WaitForSeconds(_waitForFlash 字段) - TD-16: LiquidType 枚举迁移至 BaseGames.Core.Events;LiquidEvent.LiquidType 改为枚举直接比较 - TD-17: DeathScreenController 移除失效的 _onPlayerDied 订阅,改为 OnEnable 直接启动延迟显示 影响文件: IQuestManager.cs / HurtFlashController.cs / LiquidType.cs(迁移) / LiquidEvent.cs / LiquidZone.cs / WaterDangerState.cs / UnderwaterPostProcessingController.cs / UnderwaterAudioController.cs / DeathScreenController.cs 评审文档: Docs/Review/FrameworkReview_2026_May_v11.md(综合评分 9.30/10)
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
// Assets/Scripts/Audio/UnderwaterAudioController.cs
|
||
// 进入 LiquidZone 时切换水下 DSP 处理(Architecture 21_LiquidPuzzleModule §3.4)
|
||
using UnityEngine;
|
||
using UnityEngine.Audio;
|
||
using BaseGames.Core.Events;
|
||
|
||
namespace BaseGames.Audio
|
||
{
|
||
/// <summary>
|
||
/// 挂载于 PlayerController 所在 GameObject。
|
||
/// 订阅 EVT_LiquidEntered / EVT_LiquidExited 事件频道(与 WaterDangerState、UnderwaterPostProcessingController 一致)。
|
||
/// 切换 AudioMixer Snapshot 以应用/解除水下 DSP 处理。
|
||
/// 仅响应 Water 类型液体;Acid / Lava 不切换水下音频。
|
||
/// </summary>
|
||
public class UnderwaterAudioController : MonoBehaviour
|
||
{
|
||
[SerializeField] private AudioMixer _mixer;
|
||
[SerializeField] private float _transitionDuration = 0.3f;
|
||
|
||
[Header("Event Channels")]
|
||
[SerializeField] private LiquidEventChannelSO _onLiquidEntered; // EVT_LiquidEntered
|
||
[SerializeField] private LiquidEventChannelSO _onLiquidExited; // EVT_LiquidExited
|
||
|
||
private readonly CompositeDisposable _subs = new();
|
||
|
||
private void OnEnable()
|
||
{
|
||
_onLiquidEntered?.Subscribe(OnLiquidEntered).AddTo(_subs);
|
||
_onLiquidExited?.Subscribe(OnLiquidExited).AddTo(_subs);
|
||
}
|
||
|
||
private void OnDisable() => _subs.Clear();
|
||
|
||
private void OnLiquidEntered(LiquidEvent evt)
|
||
{
|
||
if (evt.LiquidType == LiquidType.Water)
|
||
EnterWater();
|
||
}
|
||
|
||
private void OnLiquidExited(LiquidEvent evt)
|
||
{
|
||
if (evt.LiquidType == LiquidType.Water)
|
||
ExitWater();
|
||
}
|
||
|
||
/// <summary>切换至水下 AudioMixer Snapshot。</summary>
|
||
public void EnterWater()
|
||
{
|
||
_mixer?.FindSnapshot("Underwater")?.TransitionTo(_transitionDuration);
|
||
}
|
||
|
||
/// <summary>切换回默认 AudioMixer Snapshot。</summary>
|
||
public void ExitWater()
|
||
{
|
||
_mixer?.FindSnapshot("Default")?.TransitionTo(_transitionDuration);
|
||
}
|
||
}
|
||
}
|