35 lines
1.6 KiB
C#
35 lines
1.6 KiB
C#
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 测试使用,运行时不应调用
|
|
/// (本资产是 flyweight,运行时改它会影响所有引用该配方的敌人)。</summary>
|
|
public void AssignModules(IUnawareModule unaware, IEngagementModule engagement)
|
|
{
|
|
_unaware = unaware; _engagement = engagement;
|
|
InvalidateGraph();
|
|
}
|
|
}
|
|
}
|