feat(enemy): PerceptionRecipeSO 配方资产 + SubclassSelector 模块下拉
未发现层/交战层各用 [SerializeReference]+[SubclassSelector] 下拉挑选模块, 新增模块类自动出现在下拉里,无需改枚举或已有文件。默认交战模块仍为 RushEngagement——未配能力时建图必须显式报错,而非静默产出打不出手的图。
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.AI;
|
||||
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>
|
||||
/// 感知型 AI 配方:一个 SO 类型覆盖所有走「未发现 → 警觉 → 交战」规则的敌人。
|
||||
/// 两个下拉各选一个模块即可,无需写代码。有独门机制的敌人改写 AiScript 子类。
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "BaseGames/AI/感知型 AI 配方", fileName = "ENM_")]
|
||||
public sealed class PerceptionRecipeSO : AiRecipeSO
|
||||
{
|
||||
[Tooltip("未发现层:玩家尚未被发现时的行为形状")]
|
||||
[SerializeReference, SubclassSelector] IUnawareModule _unaware = new SinglePost();
|
||||
|
||||
[Tooltip("交战层:发现玩家之后怎么打")]
|
||||
[SerializeReference, SubclassSelector] IEngagementModule _engagement = new RushEngagement();
|
||||
|
||||
// 无「死亡层」字段:死亡归物理层,骨架自己声明 Death 终态。
|
||||
// PerformDeath 先 ForceState(Dead) 再发 Died 信号,此后 IsControllable 永久为假,
|
||||
// 死亡链里的条件边永不被求值——所以死亡不能做成可插拔层。
|
||||
|
||||
protected override void Build(BrainBuilder b)
|
||||
=> PerceptionSkeleton.Add(b, _unaware, _engagement);
|
||||
|
||||
/// <summary>仅供 EditMode 测试与脚手架向导装配模块,运行时不使用。</summary>
|
||||
public void SetModulesForTests(IUnawareModule unaware, IEngagementModule engagement)
|
||||
{
|
||||
_unaware = unaware; _engagement = engagement;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user