AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

executeSubgoals

本方法是Yuka js库中CompositeGoal(复合目标)的一个公共方法,用于执行复合目标的子目标。具体实现时,该方法会循环执行所有子目标的process()方法,并在满足某个目标成功/失败的条件后,返回相应的状态。

语法

CompositeGoal.executeSubgoals()

参数

无。

返回值

  • 成功:返回GoalStatus.SUCCESS(1)。
  • 失败:返回GoalStatus.FAILURE(0)。
  • 执行中:返回GoalStatus.ACTIVE(2)。

示例

const myCompositeGoal = new CompositeGoal(myOwner)
myCompositeGoal.addSubgoal(goal1)
myCompositeGoal.addSubgoal(goal2)
myCompositeGoal.addSubgoal(goal3)

myCompositeGoal.executeSubgoals()

备注

  • 子目标的执行顺序同addSubgoal()方法添加的顺序相同。
  • 如果某个子目标返回了GoalStatus.FAILUREGoalStatus.SUCCESS,则对应状态会向上级目标传递,终止后续子目标的执行。