[behavior-tree] remove
This commit is contained in:
parent
126f2d6bfc
commit
57c602e443
@ -1,65 +0,0 @@
|
||||
|
||||
export class BehaviorTree {
|
||||
constructor(root) {
|
||||
this.root = root;
|
||||
}
|
||||
};
|
||||
|
||||
export class Node {
|
||||
constructor() {}
|
||||
};
|
||||
|
||||
export class ExecutionNode extends Node {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
isLeaf() { return true; }
|
||||
};
|
||||
|
||||
export class ControlNode extends Node {
|
||||
constructor() {
|
||||
super();
|
||||
this.children = [];
|
||||
}
|
||||
|
||||
isLeaf() { return false; }
|
||||
appendChild(child) {
|
||||
this.children.push(child);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
export class SequenceNode extends ControlNode {
|
||||
constructor() { super(); }
|
||||
|
||||
async tick(blackboard) {
|
||||
for (let child of this.children) {
|
||||
await child.tick(blackboard);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export class FallbackNode extends ControlNode {
|
||||
constructor() { super(); }
|
||||
|
||||
async tick(blackboard) {
|
||||
for (let i = 0; i < this.children.length; i += 1) {
|
||||
let child = this.children[i];
|
||||
try {
|
||||
await child.tick(blackboard);
|
||||
break;
|
||||
} catch(err) {
|
||||
if (i == this.children.length - 1) { throw err; }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export class ParallelNode extends ControlNode {
|
||||
constructor() { super(); }
|
||||
|
||||
tick(blackboard) {
|
||||
return Promise.all(this.children.map(child => child(blackboard)));
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "compass-behavior-tree",
|
||||
"description": "Behavior Tree Library",
|
||||
"type": "module",
|
||||
"main": "index.mjs",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
"compass-utils": "file:../utils"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user