Files
zeling_v2/Assets/_Game/Scripts/Enemies/EnemyPoiseComponent.cs

41 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}
}