41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using UnityEngine;
|
||
using BaseGames.Combat;
|
||
|
||
namespace BaseGames.Enemies
|
||
{
|
||
/// <summary>
|
||
/// 敌人霸体组件(架构 06_CombatModule §13)。
|
||
/// Awake 时自动注入到同节点 HurtBox(无需手动 Inspector 赋值)。
|
||
/// EnemyBase 或 BehaviorDesigner 任务可调用 SetPoiseLevel / ResetPoiseLevel 切换超甲状态。
|
||
/// </summary>
|
||
[RequireComponent(typeof(EnemyBase))]
|
||
public class EnemyPoiseComponent : MonoBehaviour, IPoiseSource
|
||
{
|
||
[SerializeField] private PoiseLevel _defaultPoiseLevel = PoiseLevel.None;
|
||
|
||
private PoiseLevel _currentPoiseLevel;
|
||
|
||
private void Awake()
|
||
{
|
||
_currentPoiseLevel = _defaultPoiseLevel;
|
||
|
||
// 自动注入到同节点 HurtBox(架构 06 §13)
|
||
if (TryGetComponent<HurtBox>(out var hurtBox))
|
||
hurtBox.SetPoiseSource(this);
|
||
}
|
||
|
||
// ── IPoiseSource ──────────────────────────────────────────────────────
|
||
|
||
/// <summary>返回当前帧的霸体等级(供 HurtBox.ReceiveDamage 步骤 3 比较)。</summary>
|
||
public PoiseLevel GetCurrentPoiseLevel() => _currentPoiseLevel;
|
||
|
||
// ── 外部 API ──────────────────────────────────────────────────────────
|
||
|
||
/// <summary>进入/退出超甲时由 EnemyBase 或 BehaviorDesigner 任务调用。</summary>
|
||
public void SetPoiseLevel(PoiseLevel level) => _currentPoiseLevel = level;
|
||
|
||
/// <summary>恢复到默认霸体等级(超甲结束时调用)。</summary>
|
||
public void ResetPoiseLevel() => _currentPoiseLevel = _defaultPoiseLevel;
|
||
}
|
||
}
|