2025-10-03 00:31:34 +08:00
|
|
|
using Data;
|
|
|
|
|
|
|
|
|
|
namespace AI
|
|
|
|
|
{
|
|
|
|
|
public enum Status
|
|
|
|
|
{
|
|
|
|
|
Ready,
|
|
|
|
|
Running, // 节点正在执行中
|
|
|
|
|
Success, // 节点成功完成
|
|
|
|
|
Failure // 节点失败
|
|
|
|
|
}
|
2025-10-10 14:08:23 +08:00
|
|
|
|
2025-10-03 00:31:34 +08:00
|
|
|
public abstract class BehaviorTreeBase
|
|
|
|
|
{
|
|
|
|
|
// 所有行为树节点通用的核心成员
|
|
|
|
|
public Status CurrentStatus = Status.Ready;
|
|
|
|
|
public Entity.Entity SelfEntity { get; private set; }
|
|
|
|
|
|
|
|
|
|
public virtual void Init(BehaviorTreeDef def, Entity.Entity selfEntity)
|
|
|
|
|
{
|
|
|
|
|
SelfEntity = selfEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有行为树节点都必须实现的执行逻辑
|
|
|
|
|
public abstract Status Tick();
|
2025-10-10 14:08:23 +08:00
|
|
|
|
2025-10-03 00:31:34 +08:00
|
|
|
public virtual void Reset()
|
|
|
|
|
{
|
|
|
|
|
CurrentStatus = Status.Ready;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-10 14:08:23 +08:00
|
|
|
}
|