feat(enemy): EnemyBase 经接口发现并暴露 Locomotion(IEnemyLocomotion)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using Animancer;
|
||||
using BaseGames.AI;
|
||||
using BaseGames.Combat;
|
||||
using BaseGames.Core.Events;
|
||||
using BaseGames.Core.Pool;
|
||||
@@ -58,6 +59,9 @@ namespace BaseGames.Enemies
|
||||
// 通过接口引用,避免对 Navigation 程序集的直接依赖。
|
||||
// 由子类 / Inspector 注入,或者运行时 GetComponent<IPathAgent>() 获取。
|
||||
protected IPathAgent _nav;
|
||||
|
||||
// 移动执行器(IEnemyLocomotion;由 EnemyLocomotion 在 Navigation 程序集实现,运行时发现)
|
||||
protected IEnemyLocomotion _locomotion;
|
||||
// 霸体来源(由 EnemyPoiseComponent.Awake() 自动注入,TakeDamage 时读取)
|
||||
private IPoiseSource _poiseSource;
|
||||
protected readonly CompositeDisposable _subs = new();
|
||||
@@ -214,6 +218,7 @@ namespace BaseGames.Enemies
|
||||
|
||||
// BD 任务访问接口(公共只读属性)────────────────────────────────
|
||||
public IPathAgent Nav => _nav;
|
||||
public IEnemyLocomotion Locomotion => _locomotion;
|
||||
public EnemyMovement Movement => _movement;
|
||||
public EnemyStats Stats => _stats;
|
||||
/// <summary>敌人配置 SO,供 BD Task / 状态对象读取配置数据(如 knockUpDuration)。</summary>
|
||||
@@ -566,6 +571,7 @@ namespace BaseGames.Enemies
|
||||
_stateObjs[EnemyStateType.Dead] = new EnemyDeadState();
|
||||
|
||||
_nav = GetComponent<IPathAgent>() ?? new NullPathAgent();
|
||||
_locomotion = GetComponentInChildren<IEnemyLocomotion>(true);
|
||||
if (_movement == null) _movement = GetComponent<EnemyMovement>();
|
||||
_poiseSource = GetComponent<IPoiseSource>();
|
||||
_sensorHub = GetComponentInChildren<Perception.IPerceptionSystem>();
|
||||
|
||||
Reference in New Issue
Block a user