blueshell
Version:
A Behavior Tree implementation in modern Javascript
47 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Not = void 0;
const models_1 = require("../../models");
const Decorator_1 = require("../Decorator");
/**
* !Node
* Node returns `FAILURE` when the child returns `SUCCESS`.
* Node returns `SUCCESS` when the child returns `FAILURE`.
* Node returns `RUNNING` when the child returns `RUNNING`.
* 1/12/16
* @author Joshua Chaitin-Pollak
*/
class Not extends Decorator_1.Decorator {
/**
* Can only pass in one child.
* @constructor
* @param name
* @param child
*/
constructor(name, child, latched = true) {
super(name, child, latched);
}
/**
* @override
* @param state The state when the event occured.
* @param event The event to handle.
*/
decorateResult(res) {
switch (res) {
case models_1.rc.SUCCESS:
res = models_1.rc.FAILURE;
break;
case models_1.rc.FAILURE:
res = models_1.rc.SUCCESS;
break;
default:
// no-op
}
return res;
}
get symbol() {
return '∼';
}
}
exports.Not = Not;
//# sourceMappingURL=Not.js.map