completed
是 CompositeGoal 类的一个方法,用于判断该 CompositeGoal 实例是否完成。完成指所有的子目标都完成了。
无参数。
boolean
类型,表示该 CompositeGoal 实例是否完成。const { CompositeGoal, Goal } = require('yuka');
const goal1 = new Goal();
goal1.activate = function() {
this.status = Goal.STATUS.COMPLETED;
};
const goal2 = new Goal();
goal2.activate = function() {
this.status = Goal.STATUS.COMPLETED;
};
const compositeGoal = new CompositeGoal();
compositeGoal.addSubGoal(goal1);
compositeGoal.addSubGoal(goal2);
// 输出 true
console.log(compositeGoal.completed());
无异常。
false
。