UNPKG

owl-bt

Version:

owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.

27 lines (23 loc) 538 B
'use strict'; (function() { /** * Common tree functions */ class Tree { /** * executes given callback on each node * @param {node} rootNode * @param {Function} callback - fun(node) */ forEachNode(rootNode, callback){ callback(rootNode); if (rootNode.childNodes) { for (let i = 0; i < rootNode.childNodes.length; i++) { this.forEachNode(rootNode.childNodes[i], callback); } } } } angular.module('editorApp') .service('Tree', Tree); })();