[behavior-tree] remove

This commit is contained in:
方而静 2023-11-03 11:49:47 +08:00
parent 126f2d6bfc
commit 57c602e443
Signed by: szTom
GPG Key ID: 072D999D60C6473C
2 changed files with 0 additions and 75 deletions

View File

@ -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)));
}
}

View File

@ -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"
}
}