v11 全量评审:修复 TD-13 至 TD-17
- 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)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using BaseGames.Core.Events;
|
||||
using BaseGames.World.Liquid;
|
||||
|
||||
namespace BaseGames.Audio
|
||||
{
|
||||
@@ -34,13 +33,13 @@ namespace BaseGames.Audio
|
||||
|
||||
private void OnLiquidEntered(LiquidEvent evt)
|
||||
{
|
||||
if (evt.LiquidType == nameof(LiquidType.Water))
|
||||
if (evt.LiquidType == LiquidType.Water)
|
||||
EnterWater();
|
||||
}
|
||||
|
||||
private void OnLiquidExited(LiquidEvent evt)
|
||||
{
|
||||
if (evt.LiquidType == nameof(LiquidType.Water))
|
||||
if (evt.LiquidType == LiquidType.Water)
|
||||
ExitWater();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ namespace BaseGames.Core.Events
|
||||
{
|
||||
/// <summary>液体区域标识符(对应 LiquidZone SO 的 zoneId)。</summary>
|
||||
public readonly string ZoneId;
|
||||
/// <summary>液体类型(如 "Water" / "Acid" / "Lava")。</summary>
|
||||
public readonly string LiquidType;
|
||||
/// <summary>液体类型(枚举直接比较,无字符串转换)。</summary>
|
||||
public readonly LiquidType LiquidType;
|
||||
|
||||
public LiquidEvent(string zoneId, string liquidType)
|
||||
public LiquidEvent(string zoneId, LiquidType liquidType)
|
||||
{
|
||||
ZoneId = zoneId;
|
||||
LiquidType = liquidType;
|
||||
|
||||
14
Assets/Scripts/Core/Events/LiquidType.cs
Normal file
14
Assets/Scripts/Core/Events/LiquidType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
// Assets/Scripts/Core/Events/LiquidType.cs
|
||||
// LiquidType 属于事件载荷定义层(与 LiquidEvent 同程序集),
|
||||
// 以消除 Core.Events → World.Liquid 的反向依赖。
|
||||
namespace BaseGames.Core.Events
|
||||
{
|
||||
public enum LiquidType
|
||||
{
|
||||
Water, // 可游泳(需 Swim 能力)
|
||||
ShallowWater, // 浅水(水中慢走,无需游泳能力,速度 ×0.65)
|
||||
Mud, // 泥水(移动极慢,无需游泳能力,速度 ×0.50)
|
||||
Acid, // 接触即死(HazardZone 处理)
|
||||
Lava, // 接触即死(HazardZone 处理)
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Core/Events/LiquidType.cs.meta
Normal file
11
Assets/Scripts/Core/Events/LiquidType.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cb1f6ef04d8c734ea4870b74030d4ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
using BaseGames.Player;
|
||||
using QuestStateEnum = BaseGames.Core.Events.QuestState;
|
||||
|
||||
namespace BaseGames.Quest
|
||||
@@ -12,8 +11,8 @@ namespace BaseGames.Quest
|
||||
/// <summary>接取任务(幂等)。</summary>
|
||||
void AcceptQuest(string questId);
|
||||
|
||||
/// <summary>完成任务并发放奖励。</summary>
|
||||
void CompleteQuest(string questId, PlayerStats player);
|
||||
/// <summary>完成任务并发放奖励。rewardTarget 接收奖励(如玩家)。</summary>
|
||||
void CompleteQuest(string questId, IRewardTarget rewardTarget);
|
||||
|
||||
/// <summary>返回当前任务状态。未知 questId 返回 Unavailable。</summary>
|
||||
QuestStateEnum GetState(string questId);
|
||||
|
||||
@@ -12,15 +12,20 @@ namespace BaseGames.UI.Menus
|
||||
[SerializeField] private Button _btnRespawn;
|
||||
|
||||
[Header("Event Channels")]
|
||||
[SerializeField] private VoidEventChannelSO _onPlayerDied;
|
||||
[SerializeField] private VoidEventChannelSO _onDeathScreenConfirmed;
|
||||
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
private void OnEnable()
|
||||
{
|
||||
// 死亡界面由 UIManager 在游戏状态变为 Dead 时通过 SetActive(true) 激活。
|
||||
// _onPlayerDied 事件此时已经触发完毕,订阅它不会收到回调。
|
||||
// 直接在 OnEnable 启动延迟显示协程即可保证 1.5s 缓冲。
|
||||
StartCoroutine(ShowAfterDelay(1.5f));
|
||||
}
|
||||
|
||||
private void OnEnable() => _onPlayerDied?.Subscribe(OnPlayerDied).AddTo(_subs);
|
||||
private void OnDisable() => _subs.Clear();
|
||||
|
||||
private void OnPlayerDied() => StartCoroutine(ShowAfterDelay(1.5f));
|
||||
private void OnDisable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
private IEnumerator ShowAfterDelay(float delay)
|
||||
{
|
||||
@@ -30,7 +35,6 @@ namespace BaseGames.UI.Menus
|
||||
|
||||
private void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
if (_btnRespawn != null)
|
||||
{
|
||||
_btnRespawn.onClick.RemoveAllListeners();
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace BaseGames.VFX
|
||||
|
||||
private MaterialPropertyBlock _block;
|
||||
private Coroutine _flashCoroutine;
|
||||
private WaitForSeconds _waitForFlash;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -27,6 +28,8 @@ namespace BaseGames.VFX
|
||||
if (_renderer == null)
|
||||
_renderer = GetComponent<SpriteRenderer>();
|
||||
_block = new MaterialPropertyBlock();
|
||||
if (_config != null)
|
||||
_waitForFlash = new WaitForSeconds(_config.HurtFlashDuration);
|
||||
}
|
||||
|
||||
/// <summary>触发一次闪白动画。若上一次闪白未结束则重置计时器。</summary>
|
||||
@@ -40,7 +43,7 @@ namespace BaseGames.VFX
|
||||
private IEnumerator FlashCoroutine()
|
||||
{
|
||||
SetFlash(1f);
|
||||
yield return new WaitForSeconds(_config.HurtFlashDuration);
|
||||
yield return _waitForFlash ?? new WaitForSeconds(_config.HurtFlashDuration);
|
||||
SetFlash(0f);
|
||||
_flashCoroutine = null;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
// Assets/Scripts/World/Liquid/LiquidType.cs
|
||||
namespace BaseGames.World.Liquid
|
||||
{
|
||||
public enum LiquidType
|
||||
{
|
||||
Water, // 可游泳(需 Swim 能力)
|
||||
ShallowWater, // 浅水(水中慢走,无需游泳能力,速度 ×0.65)
|
||||
Mud, // 泥水(移动极慢,无需游泳能力,速度 ×0.50)
|
||||
Acid, // 接触即死(HazardZone 处理)
|
||||
Lava, // 接触即死(HazardZone 处理)
|
||||
}
|
||||
}
|
||||
// LiquidType 已迁移至 BaseGames.Core.Events.LiquidType(同程序集的 LiquidEvent)。
|
||||
// 此文件保留以保持 .meta 文件对应,请勿在此添加代码。
|
||||
// 所有引用请使用 using BaseGames.Core.Events; 后直接写 LiquidType。
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@ namespace BaseGames.World.Liquid
|
||||
{
|
||||
if (!other.CompareTag("Player")) return;
|
||||
_splashEnterFeedback?.PlayFeedbacks();
|
||||
_onPlayerEntered?.Raise(new LiquidEvent(_zoneId, _liquidType.ToString()));
|
||||
_onPlayerEntered?.Raise(new LiquidEvent(_zoneId, _liquidType));
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag("Player")) return;
|
||||
_splashExitFeedback?.PlayFeedbacks();
|
||||
_onPlayerExited?.Raise(new LiquidEvent(_zoneId, _liquidType.ToString()));
|
||||
_onPlayerExited?.Raise(new LiquidEvent(_zoneId, _liquidType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BaseGames.World.Liquid
|
||||
|
||||
private void OnLiquidEntered(LiquidEvent evt)
|
||||
{
|
||||
if (evt.LiquidType != nameof(LiquidType.Water)) return;
|
||||
if (evt.LiquidType != LiquidType.Water) return;
|
||||
BlendVolume(1f, _blendInDuration);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BaseGames.World.Liquid
|
||||
|
||||
public void OnEnterLiquid(LiquidEvent evt)
|
||||
{
|
||||
if (evt.LiquidType != nameof(LiquidType.Water)) return;
|
||||
if (evt.LiquidType != LiquidType.Water) return;
|
||||
if (_playerStats != null && _playerStats.HasAbility(AbilityType.Swim)) return;
|
||||
_isActive = true;
|
||||
_drownTimer = _config.DrownTime;
|
||||
|
||||
Reference in New Issue
Block a user