Files
zeling_v2/Assets/_Game/Scripts/Enemies/EnemyPoiseComponent.cs
T
joywayer 06048c966a feat: Add HurtBoxOwnerGuard to prevent multiple damage registrations from the same HitBox activation
- Implemented HurtBoxOwnerGuard to ensure that multiple HurtBoxes on the same character do not register damage multiple times during a single HitBox activation.
- Added custom editor for HitBox to facilitate the creation of shape colliders with HitBoxColliderProxy.
- Introduced PhysicsPerceptionSystem for enemy perception, supporting multiple detection modes including RangeCircle, BatchLOS, FanCast, and BoxCast.
- Created EnemyPatrolZone to define patrol and chase areas for enemies, allowing for shared zones among multiple enemies.
- Added BD_IsOutsideZone conditional task for Behavior Designer to check if an enemy or player is outside a defined patrol zone.
2026-06-02 16:10:44 +08:00

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(支持多形状受击区)
foreach (var hurtBox in GetComponentsInChildren<HurtBox>(true))
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;
}
}