mirror of
https://gitee.com/sli97/behavior-eden-coco-plugin.git
synced 2025-10-09 08:36:25 +00:00
init
This commit is contained in:
17
dist/runtime/node/action/ActionCommon.js
vendored
Normal file
17
dist/runtime/node/action/ActionCommon.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ActionCommon = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let ActionCommon = class ActionCommon extends index_1.Action {
|
||||
};
|
||||
ActionCommon = __decorate([
|
||||
(0, decorator_1.btclass)("ActionCommon")
|
||||
], ActionCommon);
|
||||
exports.ActionCommon = ActionCommon;
|
26
dist/runtime/node/action/Log.js
vendored
Normal file
26
dist/runtime/node/action/Log.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Log = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Log = class Log extends index_1.Action {
|
||||
constructor(text = "log") {
|
||||
super();
|
||||
this.text = "log";
|
||||
this.text = text;
|
||||
}
|
||||
onUpdate() {
|
||||
console.log(this.text);
|
||||
return index_1.NodeStatus.Success;
|
||||
}
|
||||
};
|
||||
Log = __decorate([
|
||||
(0, decorator_1.btclass)("Log")
|
||||
], Log);
|
||||
exports.Log = Log;
|
35
dist/runtime/node/action/Wait.js
vendored
Normal file
35
dist/runtime/node/action/Wait.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Wait = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Wait = class Wait extends index_1.Action {
|
||||
constructor(duration = 4000) {
|
||||
super();
|
||||
this.startTime = 0;
|
||||
this.duration = 2000;
|
||||
this.duration = duration;
|
||||
}
|
||||
onUpdate() {
|
||||
return index_1.NodeStatus.Success;
|
||||
return index_1.NodeStatus.Running;
|
||||
}
|
||||
onStart() {
|
||||
super.onStart();
|
||||
console.log("Wait onStart");
|
||||
}
|
||||
onEnd() {
|
||||
super.onEnd();
|
||||
console.log("Wait onEnd");
|
||||
}
|
||||
};
|
||||
Wait = __decorate([
|
||||
(0, decorator_1.btclass)("Wait")
|
||||
], Wait);
|
||||
exports.Wait = Wait;
|
17
dist/runtime/node/action/index.js
vendored
Normal file
17
dist/runtime/node/action/index.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./ActionCommon"), exports);
|
7
dist/runtime/node/base/Action.js
vendored
Normal file
7
dist/runtime/node/base/Action.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Action = void 0;
|
||||
const Node_1 = require("./Node");
|
||||
class Action extends Node_1.Node {
|
||||
}
|
||||
exports.Action = Action;
|
12
dist/runtime/node/base/Composite.js
vendored
Normal file
12
dist/runtime/node/base/Composite.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Composite = void 0;
|
||||
const enum_1 = require("../enum");
|
||||
const ParentNode_1 = require("./ParentNode");
|
||||
class Composite extends ParentNode_1.ParentNode {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.abortType = enum_1.AbortType.None;
|
||||
}
|
||||
}
|
||||
exports.Composite = Composite;
|
7
dist/runtime/node/base/Condition.js
vendored
Normal file
7
dist/runtime/node/base/Condition.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Condition = void 0;
|
||||
const Node_1 = require("./Node");
|
||||
class Condition extends Node_1.Node {
|
||||
}
|
||||
exports.Condition = Condition;
|
7
dist/runtime/node/base/Decorator.js
vendored
Normal file
7
dist/runtime/node/base/Decorator.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Decorator = void 0;
|
||||
const ParentNode_1 = require("./ParentNode");
|
||||
class Decorator extends ParentNode_1.ParentNode {
|
||||
}
|
||||
exports.Decorator = Decorator;
|
27
dist/runtime/node/base/Node.js
vendored
Normal file
27
dist/runtime/node/base/Node.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Node = void 0;
|
||||
const enum_1 = require("../enum");
|
||||
class Node {
|
||||
constructor() {
|
||||
// 从json文件得到的节点数据
|
||||
this.data = {};
|
||||
this._status = enum_1.NodeStatus.Inactive;
|
||||
}
|
||||
get status() {
|
||||
return this._status;
|
||||
}
|
||||
set status(newStatus) {
|
||||
this._status = newStatus;
|
||||
}
|
||||
onStart() {
|
||||
this.status = enum_1.NodeStatus.Running;
|
||||
}
|
||||
onUpdate() {
|
||||
return enum_1.NodeStatus.Failure;
|
||||
}
|
||||
onEnd() {
|
||||
this.status = enum_1.NodeStatus.Inactive;
|
||||
}
|
||||
}
|
||||
exports.Node = Node;
|
34
dist/runtime/node/base/ParentNode.js
vendored
Normal file
34
dist/runtime/node/base/ParentNode.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ParentNode = void 0;
|
||||
const Node_1 = require("./Node");
|
||||
class ParentNode extends Node_1.Node {
|
||||
get index() {
|
||||
return this._index;
|
||||
}
|
||||
set index(data) {
|
||||
this._index = data;
|
||||
}
|
||||
constructor(children) {
|
||||
super();
|
||||
this.children = [];
|
||||
this._index = 0;
|
||||
this.children = children;
|
||||
}
|
||||
setChildren(children) {
|
||||
this.children = children;
|
||||
}
|
||||
onConditionalAbort(childIndex) { }
|
||||
decorate(status) {
|
||||
return status;
|
||||
}
|
||||
//并行节点的状态不由某个子节点状态决定,而是由多个共同决定,所以重新计算status
|
||||
overrideStatus(status) {
|
||||
return status;
|
||||
}
|
||||
canRunParallelChildren() {
|
||||
return false;
|
||||
}
|
||||
onChildStarted() { }
|
||||
}
|
||||
exports.ParentNode = ParentNode;
|
22
dist/runtime/node/base/index.js
vendored
Normal file
22
dist/runtime/node/base/index.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./Node"), exports);
|
||||
__exportStar(require("./Action"), exports);
|
||||
__exportStar(require("./Composite"), exports);
|
||||
__exportStar(require("./Condition"), exports);
|
||||
__exportStar(require("./Decorator"), exports);
|
||||
__exportStar(require("./ParentNode"), exports);
|
54
dist/runtime/node/composite/Parallel.js
vendored
Normal file
54
dist/runtime/node/composite/Parallel.js
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Parallel = class Parallel extends index_1.Composite {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.executionStatus = [];
|
||||
}
|
||||
onStart() {
|
||||
super.onStart();
|
||||
this.index = 0;
|
||||
this.executionStatus = this.children.map(() => index_1.NodeStatus.Inactive);
|
||||
}
|
||||
canRunParallelChildren() {
|
||||
return true;
|
||||
}
|
||||
onChildStarted() {
|
||||
this.executionStatus[this.index] = index_1.NodeStatus.Running;
|
||||
this.index++;
|
||||
}
|
||||
canExecute() {
|
||||
return this.index < this.children.length;
|
||||
}
|
||||
onChildExecuted(status, index) {
|
||||
this.executionStatus[index] = status;
|
||||
}
|
||||
overrideStatus(_) {
|
||||
let childrenComplete = true;
|
||||
for (let i = 0; i < this.executionStatus.length; i++) {
|
||||
if (this.executionStatus[i] == index_1.NodeStatus.Running) {
|
||||
childrenComplete = false;
|
||||
}
|
||||
else if (this.executionStatus[i] == index_1.NodeStatus.Failure) {
|
||||
return index_1.NodeStatus.Failure;
|
||||
}
|
||||
}
|
||||
return childrenComplete ? index_1.NodeStatus.Success : index_1.NodeStatus.Running;
|
||||
}
|
||||
onConditionalAbort(childIndex) {
|
||||
this.index = 0;
|
||||
this.executionStatus = this.executionStatus.map(() => index_1.NodeStatus.Inactive);
|
||||
}
|
||||
};
|
||||
Parallel = __decorate([
|
||||
(0, decorator_1.btclass)("Parallel")
|
||||
], Parallel);
|
||||
exports.default = Parallel;
|
64
dist/runtime/node/composite/RandomSequence.js
vendored
Normal file
64
dist/runtime/node/composite/RandomSequence.js
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let RandomSequence = class RandomSequence extends index_1.Composite {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.executionOrder = [];
|
||||
}
|
||||
get index() {
|
||||
return this.executionOrder[this.executionOrder.length - 1];
|
||||
}
|
||||
onStart() {
|
||||
super.onStart();
|
||||
this.shuffle();
|
||||
}
|
||||
canExecute() {
|
||||
return Boolean(this.executionOrder.length) && this.status !== index_1.NodeStatus.Failure;
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
switch (status) {
|
||||
case index_1.NodeStatus.Success:
|
||||
this.executionOrder.pop();
|
||||
if (this.executionOrder.length <= 0) {
|
||||
this.status = index_1.NodeStatus.Success;
|
||||
}
|
||||
else {
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
}
|
||||
break;
|
||||
case index_1.NodeStatus.Failure:
|
||||
this.status = index_1.NodeStatus.Failure;
|
||||
break;
|
||||
case index_1.NodeStatus.Running:
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
onConditionalAbort() {
|
||||
this.executionOrder = [];
|
||||
this.status = index_1.NodeStatus.Inactive;
|
||||
this.shuffle();
|
||||
}
|
||||
shuffle() {
|
||||
this.executionOrder = [];
|
||||
const indexList = Array.from({ length: this.children.length }, (e, i) => i);
|
||||
for (let i = indexList.length - 1; i >= 0; i--) {
|
||||
const num = Math.floor(Math.random() * indexList.length);
|
||||
this.executionOrder.push(indexList.splice(num, 1)[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
RandomSequence = __decorate([
|
||||
(0, decorator_1.btclass)("RandomSequence")
|
||||
], RandomSequence);
|
||||
exports.default = RandomSequence;
|
48
dist/runtime/node/composite/Selector.js
vendored
Normal file
48
dist/runtime/node/composite/Selector.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Selector = class Selector extends index_1.Composite {
|
||||
onStart() {
|
||||
super.onStart();
|
||||
this.index = 0;
|
||||
}
|
||||
canExecute() {
|
||||
return this.index < this.children.length && this.status !== index_1.NodeStatus.Success;
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
switch (status) {
|
||||
case index_1.NodeStatus.Success:
|
||||
this.status = index_1.NodeStatus.Success;
|
||||
break;
|
||||
case index_1.NodeStatus.Failure:
|
||||
this.index++;
|
||||
if (this.index >= this.children.length) {
|
||||
this.status = index_1.NodeStatus.Failure;
|
||||
}
|
||||
else {
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
}
|
||||
break;
|
||||
case index_1.NodeStatus.Running:
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
onConditionalAbort(index) {
|
||||
this.index = index;
|
||||
this.status = index_1.NodeStatus.Inactive;
|
||||
}
|
||||
};
|
||||
Selector = __decorate([
|
||||
(0, decorator_1.btclass)("Selector")
|
||||
], Selector);
|
||||
exports.default = Selector;
|
48
dist/runtime/node/composite/Sequence.js
vendored
Normal file
48
dist/runtime/node/composite/Sequence.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Sequence = class Sequence extends index_1.Composite {
|
||||
onStart() {
|
||||
super.onStart();
|
||||
this.index = 0;
|
||||
}
|
||||
canExecute() {
|
||||
return this.index < this.children.length && this.status !== index_1.NodeStatus.Failure;
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
switch (status) {
|
||||
case index_1.NodeStatus.Success:
|
||||
this.index++;
|
||||
if (this.index >= this.children.length) {
|
||||
this.status = index_1.NodeStatus.Success;
|
||||
}
|
||||
else {
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
}
|
||||
break;
|
||||
case index_1.NodeStatus.Failure:
|
||||
this.status = index_1.NodeStatus.Failure;
|
||||
break;
|
||||
case index_1.NodeStatus.Running:
|
||||
this.status = index_1.NodeStatus.Running;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
onConditionalAbort(index) {
|
||||
this.index = index;
|
||||
this.status = index_1.NodeStatus.Inactive;
|
||||
}
|
||||
};
|
||||
Sequence = __decorate([
|
||||
(0, decorator_1.btclass)("Sequence")
|
||||
], Sequence);
|
||||
exports.default = Sequence;
|
20
dist/runtime/node/composite/index.js
vendored
Normal file
20
dist/runtime/node/composite/index.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./Sequence"), exports);
|
||||
__exportStar(require("./Selector"), exports);
|
||||
__exportStar(require("./Parallel"), exports);
|
||||
__exportStar(require("./RandomSequence"), exports);
|
16
dist/runtime/node/condition/ConditionCommon.js
vendored
Normal file
16
dist/runtime/node/condition/ConditionCommon.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let ConditionCommon = class ConditionCommon extends index_1.Condition {
|
||||
};
|
||||
ConditionCommon = __decorate([
|
||||
(0, decorator_1.btclass)("ConditionCommon")
|
||||
], ConditionCommon);
|
||||
exports.default = ConditionCommon;
|
23
dist/runtime/node/condition/ConditionHP.js
vendored
Normal file
23
dist/runtime/node/condition/ConditionHP.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let ConditionHP = class ConditionHP extends index_1.Condition {
|
||||
onUpdate() {
|
||||
// console.log("Blackboard.Instance.hp", Blackboard.Instance.hp, ",ConditionHP", Blackboard.Instance.hp >= 100);
|
||||
// if (Blackboard.Instance.hp >= 100) {
|
||||
// return NodeStatus.Success;
|
||||
// }
|
||||
return index_1.NodeStatus.Success;
|
||||
}
|
||||
};
|
||||
ConditionHP = __decorate([
|
||||
(0, decorator_1.btclass)("ConditionHP")
|
||||
], ConditionHP);
|
||||
exports.default = ConditionHP;
|
17
dist/runtime/node/condition/index.js
vendored
Normal file
17
dist/runtime/node/condition/index.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./ConditionCommon"), exports);
|
33
dist/runtime/node/decorator/Inverter.js
vendored
Normal file
33
dist/runtime/node/decorator/Inverter.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Inverter = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Inverter = class Inverter extends index_1.Decorator {
|
||||
canExecute() {
|
||||
return this.status === index_1.NodeStatus.Inactive || this.status === index_1.NodeStatus.Running;
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
this.status = status;
|
||||
}
|
||||
decorate(status) {
|
||||
switch (status) {
|
||||
case index_1.NodeStatus.Success:
|
||||
return index_1.NodeStatus.Failure;
|
||||
case index_1.NodeStatus.Failure:
|
||||
return index_1.NodeStatus.Success;
|
||||
default:
|
||||
return status;
|
||||
}
|
||||
}
|
||||
};
|
||||
Inverter = __decorate([
|
||||
(0, decorator_1.btclass)("Inverter")
|
||||
], Inverter);
|
||||
exports.Inverter = Inverter;
|
43
dist/runtime/node/decorator/Repeater.js
vendored
Normal file
43
dist/runtime/node/decorator/Repeater.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Repeater = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let Repeater = class Repeater extends index_1.Decorator {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.repeatCount = Infinity;
|
||||
this.curCount = 0;
|
||||
this.endOnFailure = true;
|
||||
}
|
||||
/***
|
||||
* 参数未来可以通过Shared Variable,这期就不做了
|
||||
*/
|
||||
// constructor(children: Array<Node>, repeatCount = Infinity, endOnFailure = false) {
|
||||
// super(children);
|
||||
// this.repeatCount = repeatCount;
|
||||
// this.endOnFailure = endOnFailure;
|
||||
// }
|
||||
canExecute() {
|
||||
return (this.curCount < this.repeatCount &&
|
||||
(!this.endOnFailure || (this.endOnFailure && this.status !== index_1.NodeStatus.Failure)));
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
this.curCount++;
|
||||
this.status = status;
|
||||
}
|
||||
onStart() {
|
||||
super.onStart();
|
||||
this.curCount = 0;
|
||||
}
|
||||
};
|
||||
Repeater = __decorate([
|
||||
(0, decorator_1.btclass)("Repeater")
|
||||
], Repeater);
|
||||
exports.Repeater = Repeater;
|
23
dist/runtime/node/decorator/UntilSuccess.js
vendored
Normal file
23
dist/runtime/node/decorator/UntilSuccess.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UntilSuccess = void 0;
|
||||
const index_1 = require("../index");
|
||||
const decorator_1 = require("../../core/decorator");
|
||||
let UntilSuccess = class UntilSuccess extends index_1.Decorator {
|
||||
canExecute() {
|
||||
return this.status == index_1.NodeStatus.Inactive || this.status == index_1.NodeStatus.Failure;
|
||||
}
|
||||
onChildExecuted(status, _) {
|
||||
this.status = status;
|
||||
}
|
||||
};
|
||||
UntilSuccess = __decorate([
|
||||
(0, decorator_1.btclass)("UntilSuccess")
|
||||
], UntilSuccess);
|
||||
exports.UntilSuccess = UntilSuccess;
|
19
dist/runtime/node/decorator/index.js
vendored
Normal file
19
dist/runtime/node/decorator/index.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./Inverter"), exports);
|
||||
__exportStar(require("./Repeater"), exports);
|
||||
__exportStar(require("./UntilSuccess"), exports);
|
17
dist/runtime/node/enum/index.js
vendored
Normal file
17
dist/runtime/node/enum/index.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AbortType = exports.NodeStatus = void 0;
|
||||
var NodeStatus;
|
||||
(function (NodeStatus) {
|
||||
NodeStatus[NodeStatus["Inactive"] = 0] = "Inactive";
|
||||
NodeStatus[NodeStatus["Running"] = 1] = "Running";
|
||||
NodeStatus[NodeStatus["Success"] = 2] = "Success";
|
||||
NodeStatus[NodeStatus["Failure"] = 3] = "Failure";
|
||||
})(NodeStatus = exports.NodeStatus || (exports.NodeStatus = {}));
|
||||
var AbortType;
|
||||
(function (AbortType) {
|
||||
AbortType[AbortType["None"] = 0] = "None";
|
||||
AbortType[AbortType["LowerPriority"] = 1] = "LowerPriority";
|
||||
AbortType[AbortType["Self"] = 2] = "Self";
|
||||
AbortType[AbortType["Both"] = 3] = "Both";
|
||||
})(AbortType = exports.AbortType || (exports.AbortType = {}));
|
22
dist/runtime/node/index.js
vendored
Normal file
22
dist/runtime/node/index.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./base"), exports);
|
||||
__exportStar(require("./enum"), exports);
|
||||
__exportStar(require("./action"), exports);
|
||||
__exportStar(require("./composite"), exports);
|
||||
__exportStar(require("./decorator"), exports);
|
||||
__exportStar(require("./condition"), exports);
|
Reference in New Issue
Block a user