多轮审查和修复
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# 20 · 护盾模块(Shield Module)
|
||||
|
||||
> **命名空间** `BaseGames.Player.Shield`
|
||||
> **程序集** `BaseGames.Player`(并入玩家程序集)
|
||||
> **命名空间** `BaseGames.Combat`
|
||||
> **程序集** `BaseGames.Combat`(`Assets/Scripts/Combat/`)
|
||||
> **依赖** `BaseGames.Core.Events` · `BaseGames.Combat`(DamageInfo · HurtBox)· `BaseGames.UI`(HUDController)
|
||||
> **Design 来源** [30_ShieldMechanicsSystem](../Design/30_ShieldMechanicsSystem.md)
|
||||
|
||||
@@ -86,7 +86,7 @@ _hurtBox.SetShieldable(_shieldComponent);
|
||||
## 3. ShieldConfigSO
|
||||
|
||||
```csharp
|
||||
namespace BaseGames.Player.Shield
|
||||
namespace BaseGames.Combat
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Player/ShieldConfig")]
|
||||
public class ShieldConfigSO : ScriptableObject
|
||||
@@ -122,20 +122,19 @@ namespace BaseGames.Player.Shield
|
||||
## 4. ShieldComponent
|
||||
|
||||
```csharp
|
||||
namespace BaseGames.Player.Shield
|
||||
namespace BaseGames.Combat
|
||||
{
|
||||
/// <summary>
|
||||
/// 挂在 PlayerController 子节点 [Shield] 上。
|
||||
/// 在 HurtBox 和 IDamageable(PlayerStats)之间担当拦截层。
|
||||
/// </summary>
|
||||
[DefaultExecutionOrder(-40)]
|
||||
public class ShieldComponent : MonoBehaviour, IShieldable
|
||||
{
|
||||
// ── Inspector ───────────────────────────────────────
|
||||
[SerializeField] ShieldConfigSO _config;
|
||||
[SerializeField] IntEventChannelSO _onShieldHPChanged; // 广播当前耐久整数
|
||||
[SerializeField] VoidEventChannelSO _onShieldBroken;
|
||||
[SerializeField] VoidEventChannelSO _onShieldRestored;
|
||||
[SerializeField] IntEventChannelSO _onShieldHPChanged; // 广播当前耐久整数
|
||||
[SerializeField] VoidEventChannelSO _onShieldBrokenChannel;
|
||||
[SerializeField] VoidEventChannelSO _onShieldRestoredChannel;
|
||||
[SerializeField] DifficultyChangedEventChannel _onDifficultyChanged;
|
||||
|
||||
// ── Runtime State ────────────────────────────────────
|
||||
@@ -208,7 +207,7 @@ namespace BaseGames.Player.Shield
|
||||
_currentShieldHP = 0;
|
||||
_isBroken = true;
|
||||
_brokenTimer = 0f;
|
||||
_onShieldBroken.Raise();
|
||||
_onShieldBrokenChannel.Raise();
|
||||
}
|
||||
|
||||
_onShieldHPChanged.Raise(_currentShieldHP); // 更新 ShieldBarUI
|
||||
@@ -223,7 +222,7 @@ namespace BaseGames.Player.Shield
|
||||
_currentShieldHP = _config.MaxShieldHP;
|
||||
_isBroken = false;
|
||||
_brokenTimer = 0f;
|
||||
_onShieldRestored.Raise();
|
||||
_onShieldRestoredChannel.Raise();
|
||||
}
|
||||
|
||||
/// <summary>存档加载时恢复护盾状态。由 PlayerController.LoadFromSaveData() 调用。</summary>
|
||||
@@ -255,7 +254,7 @@ namespace BaseGames.Player.Shield
|
||||
## 5. IShieldable 接口
|
||||
|
||||
```csharp
|
||||
namespace BaseGames.Player.Shield
|
||||
namespace BaseGames.Combat
|
||||
{
|
||||
/// <summary>
|
||||
/// 可拥有护盾的实体接口。HurtBox 持有此接口引用,在受击时优先检查护盾。
|
||||
@@ -301,21 +300,21 @@ public class ShieldBarUI : MonoBehaviour
|
||||
|
||||
[Header("Event Channels")]
|
||||
[SerializeField] IntEventChannelSO _onShieldHPChanged; // 订阅耐久变化
|
||||
[SerializeField] VoidEventChannelSO _onShieldBroken;
|
||||
[SerializeField] VoidEventChannelSO _onShieldRestored;
|
||||
[SerializeField] VoidEventChannelSO _onShieldBrokenChannel;
|
||||
[SerializeField] VoidEventChannelSO _onShieldRestoredChannel;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_onShieldHPChanged.OnEventRaised += RefreshFill;
|
||||
_onShieldBroken.OnEventRaised += ShowBroken;
|
||||
_onShieldRestored.OnEventRaised += HideBroken;
|
||||
_onShieldHPChanged.OnEventRaised += RefreshFill;
|
||||
_onShieldBrokenChannel.OnEventRaised += ShowBroken;
|
||||
_onShieldRestoredChannel.OnEventRaised += HideBroken;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_onShieldHPChanged.OnEventRaised -= RefreshFill;
|
||||
_onShieldBroken.OnEventRaised -= ShowBroken;
|
||||
_onShieldRestored.OnEventRaised -= HideBroken;
|
||||
_onShieldHPChanged.OnEventRaised -= RefreshFill;
|
||||
_onShieldBrokenChannel.OnEventRaised -= ShowBroken;
|
||||
_onShieldRestoredChannel.OnEventRaised -= HideBroken;
|
||||
}
|
||||
|
||||
private void RefreshFill(int currentHP)
|
||||
|
||||
Reference in New Issue
Block a user