This commit is contained in:
sli97
2023-09-21 01:32:11 +08:00
commit 47104caa6e
964 changed files with 62409 additions and 0 deletions

25
dist/runtime/core/biz/Action/Log.js vendored Normal file
View File

@@ -0,0 +1,25 @@
"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");
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, index_1.btclass)("Log")
], Log);
exports.Log = Log;

34
dist/runtime/core/biz/Action/Wait.js vendored Normal file
View File

@@ -0,0 +1,34 @@
"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");
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, index_1.btclass)("Wait")
], Wait);
exports.Wait = Wait;

18
dist/runtime/core/biz/Action/index.js vendored Normal file
View File

@@ -0,0 +1,18 @@
"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("./Log"), exports);
__exportStar(require("./Wait"), exports);

View File

@@ -0,0 +1,59 @@
"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");
let Parallel = class Parallel extends index_1.Composite {
constructor() {
super(...arguments);
this.executionStatus = [];
}
get status() {
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;
}
set status(_) { }
onConditionalAbort(childIndex) {
this.index = 0;
for (let i = 0; i < this.executionStatus.length; i++) {
this.executionStatus[i] = index_1.NodeStatus.Inactive;
}
}
onStart() {
super.onStart();
this.executionStatus = new Array(this.children.length);
this.index = 0;
for (let i = 0; i < this.executionStatus.length; i++) {
this.executionStatus[i] = 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;
}
};
Parallel = __decorate([
(0, index_1.btclass)("Parallel")
], Parallel);
exports.default = Parallel;

View File

@@ -0,0 +1,84 @@
"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");
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() { }
// onUpdate(): NodeStatus {
// if (this.status === NodeStatus.Failure) {
// return NodeStatus.Failure
// }
//
// if (!this.executionOrder.length) {
// this.status = NodeStatus.Success
// return NodeStatus.Success
// }
//
// const node = this.children[this.index]
//
// const res = node.run()
//
// if (res === NodeStatus.Failure) {
// this.status = NodeStatus.Failure
// return NodeStatus.Failure
// }
//
// if (res === NodeStatus.Success) {
// this.executionOrder.pop()
// }
//
// return NodeStatus.Running
// }
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, index_1.btclass)("RandomSequence")
], RandomSequence);
exports.default = RandomSequence;

View File

@@ -0,0 +1,47 @@
"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");
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, index_1.btclass)("Selector")
], Selector);
exports.default = Selector;

View File

@@ -0,0 +1,47 @@
"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");
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, index_1.btclass)("Sequence")
], Sequence);
exports.default = Sequence;

View 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);

View File

@@ -0,0 +1,22 @@
"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");
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, index_1.btclass)("ConditionHP")
], ConditionHP);
exports.default = ConditionHP;

View 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("./ConditionHP"), exports);

View File

@@ -0,0 +1,32 @@
"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");
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, index_1.btclass)("Inverter")
], Inverter);
exports.Inverter = Inverter;

View File

@@ -0,0 +1,36 @@
"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");
let Repeater = class Repeater extends index_1.Decorator {
constructor(children, repeatCount = Infinity, endOnFailure = false) {
super(children);
this.repeatCount = Infinity;
this.curCount = 0;
this.endOnFailure = false;
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, index_1.btclass)("Repeater")
], Repeater);
exports.Repeater = Repeater;

View File

@@ -0,0 +1,30 @@
"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");
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 = this.decorate(status);
}
onUpdate() {
// let status: NodeStatus = (this.children[0] as Action | BTCondition).run();
// if (status === NodeStatus.Failure) {
// status = NodeStatus.Running;
// }
// return this.decorate(status);
return index_1.NodeStatus.Success;
}
};
UntilSuccess = __decorate([
(0, index_1.btclass)("UntilSuccess")
], UntilSuccess);
exports.UntilSuccess = UntilSuccess;

View 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);

20
dist/runtime/core/biz/index.js vendored Normal file
View 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("./action"), exports);
__exportStar(require("./composite"), exports);
__exportStar(require("./decorator"), exports);
__exportStar(require("./condition"), exports);