implement expression validation and build script setup in workspace
This commit is contained in:
1 parent
d595ce4a3a
commit
2483606ef4
24 files changed
+573
-318
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/* 批处理脚本 */
|
||||
/*
|
||||
如果有processTree,则先运行prcessTree,如果有返回,则进行后面的针对每个节点运行processNode
|
||||
如果没有定义processTree,则直接针对每个节点运行processNode
|
||||
|
||||
export interface TreeModel {
|
||||
version: string;
|
||||
name: string;
|
||||
desc?: string;
|
||||
export?: boolean;
|
||||
firstid: number;
|
||||
group: string[];
|
||||
import: string[];
|
||||
declvar: VarDef[];
|
||||
root: NodeModel;
|
||||
}
|
||||
|
||||
export interface NodeModel {
|
||||
id: number;
|
||||
name: string;
|
||||
desc?: string;
|
||||
args?: { [key: string]: any };
|
||||
input?: string[];
|
||||
output?: string[];
|
||||
children?: NodeModel[];
|
||||
debug?: boolean;
|
||||
disabled?: boolean;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
interface BuildScript {
|
||||
processTree?(tree: TreeModel, path: string): TreeModel | null;
|
||||
|
||||
processNode?(node: NodeModel, tree: TreeModel): NodeModel | null;
|
||||
|
||||
writeFile?(path: string, tree: TreeModel): void;
|
||||
}
|
||||
*/
|
||||
({
|
||||
processTree: (tree) => {
|
||||
console.log(`processTree ${tree.name}`);
|
||||
return tree;
|
||||
},
|
||||
processNode: (node, tree) => {
|
||||
console.log(`processNode ${tree.name} ${node.name}#${node.id}`);
|
||||
return node;
|
||||
},
|
||||
});
|
||||
+19
-14
@@ -4,23 +4,28 @@
|
||||
如果没有定义processTree,则直接针对每个节点运行processNode
|
||||
|
||||
export interface TreeModel {
|
||||
name: string;
|
||||
desc?: string;
|
||||
export?: boolean;
|
||||
root: NodeModel;
|
||||
version: string;
|
||||
name: string;
|
||||
desc?: string;
|
||||
export?: boolean;
|
||||
firstid: number;
|
||||
group: string[];
|
||||
import: string[];
|
||||
declvar: VarDef[];
|
||||
root: NodeModel;
|
||||
}
|
||||
|
||||
export interface NodeModel {
|
||||
id: number;
|
||||
name: string;
|
||||
desc?: string;
|
||||
args?: { [key: string]: any };
|
||||
input?: string[];
|
||||
output?: string[];
|
||||
children?: NodeModel[];
|
||||
debug?: boolean;
|
||||
disabled?: boolean;
|
||||
path?: string;
|
||||
id: number;
|
||||
name: string;
|
||||
desc?: string;
|
||||
args?: { [key: string]: any };
|
||||
input?: string[];
|
||||
output?: string[];
|
||||
children?: NodeModel[];
|
||||
debug?: boolean;
|
||||
disabled?: boolean;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
interface BatchScript {
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"id": 6,
|
||||
"name": "Check",
|
||||
"args": {
|
||||
"value": "target1.x > 0"
|
||||
"value": "target[0].x > 0 |"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+115
-50
@@ -1,55 +1,120 @@
|
||||
{
|
||||
"name": "hero",
|
||||
"root": {
|
||||
"id": 1,
|
||||
"name": "Selector",
|
||||
"desc": "英雄测试AI",
|
||||
"name": "hero",
|
||||
"root": {
|
||||
"id": 1,
|
||||
"name": "Selector",
|
||||
"desc": "英雄测试AI",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Sequence",
|
||||
"desc": "攻击",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Sequence",
|
||||
"desc": "攻击",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 3,
|
||||
"name": "FindEnemy",
|
||||
"args": { "x": 0, "y": 0, "w": 100, "h": 50 },
|
||||
"output": ["enemy"]
|
||||
},
|
||||
{ "id": 4, "name": "Attack", "args": {}, "input": ["enemy"] },
|
||||
{ "id": 5, "name": "Wait", "args": { "time": 10 } }
|
||||
]
|
||||
{
|
||||
"id": 3,
|
||||
"name": "FindEnemy",
|
||||
"args": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 100,
|
||||
"h": 50
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Sequence",
|
||||
"desc": "移动",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 7,
|
||||
"name": "FindEnemy",
|
||||
"args": { "w": 1000, "h": 500, "x": 0, "y": 0 },
|
||||
"output": ["enemy"]
|
||||
},
|
||||
{ "id": 8, "name": "MoveToTarget", "args": {}, "input": ["enemy"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Sequence",
|
||||
"desc": "逃跑",
|
||||
"args": {},
|
||||
"children": [
|
||||
{ "id": 10, "name": "GetHp", "args": {}, "output": ["hp"] },
|
||||
{ "id": 11, "name": "Cmp", "args": { "lt": 50 }, "input": ["hp"] },
|
||||
{ "id": 12, "name": "MoveToPos", "args": { "x": 0, "y": 0 } }
|
||||
]
|
||||
},
|
||||
{ "id": 13, "name": "Idle" }
|
||||
"output": [
|
||||
"enemy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Attack",
|
||||
"args": {},
|
||||
"input": [
|
||||
"enemy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Wait",
|
||||
"args": {
|
||||
"time": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"desc": "英雄测试AI"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Sequence",
|
||||
"desc": "移动",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 7,
|
||||
"name": "FindEnemy",
|
||||
"args": {
|
||||
"w": 1000,
|
||||
"h": 500,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"output": [
|
||||
"enemy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "MoveToTarget",
|
||||
"args": {},
|
||||
"input": [
|
||||
"enemy"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Sequence",
|
||||
"desc": "逃跑",
|
||||
"args": {},
|
||||
"children": [
|
||||
{
|
||||
"id": 10,
|
||||
"name": "GetHp",
|
||||
"args": {},
|
||||
"output": [
|
||||
"hp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Cmp",
|
||||
"args": {
|
||||
"lt": 50
|
||||
},
|
||||
"input": [
|
||||
"hp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "MoveToPos",
|
||||
"args": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "Idle"
|
||||
}
|
||||
]
|
||||
},
|
||||
"desc": "英雄测试AI",
|
||||
"version": "1.8.0",
|
||||
"firstid": 1,
|
||||
"group": [],
|
||||
"import": [],
|
||||
"declvar": []
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"version": "1.8.0",
|
||||
"name": "subtree1",
|
||||
"desc": "子树1",
|
||||
"firstid": 1,
|
||||
"group": [],
|
||||
"import": [],
|
||||
"declvar": [],
|
||||
"root": {
|
||||
"id": 1,
|
||||
"name": "Sequence",
|
||||
@@ -9,7 +15,7 @@
|
||||
"id": 2,
|
||||
"name": "Log",
|
||||
"args": {
|
||||
"str": "hello"
|
||||
"message": "d"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -17,15 +23,8 @@
|
||||
"name": "Wait",
|
||||
"args": {
|
||||
"time": 1
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": 4,
|
||||
"name": "unknow"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"desc": "子树1"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"version": "1.8.0",
|
||||
"name": "subtree2",
|
||||
"desc": "子树2",
|
||||
"firstid": 1,
|
||||
"group": [],
|
||||
"import": [],
|
||||
"declvar": [],
|
||||
"root": {
|
||||
"id": 1,
|
||||
"name": "Sequence",
|
||||
@@ -8,9 +14,8 @@
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Cmp",
|
||||
"args": {},
|
||||
"input": [
|
||||
""
|
||||
"d"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -21,6 +26,5 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"desc": "子树2"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"version": "1.8.0",
|
||||
"name": "subtree2",
|
||||
"desc": "子树2",
|
||||
"firstid": 1,
|
||||
"group": [],
|
||||
"import": [],
|
||||
"declvar": [],
|
||||
"root": {
|
||||
"id": 1,
|
||||
"name": "Sequence",
|
||||
@@ -10,14 +16,9 @@
|
||||
"name": "Cmp",
|
||||
"args": {},
|
||||
"input": [
|
||||
""
|
||||
"x"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "unknow"
|
||||
}
|
||||
]
|
||||
},
|
||||
"desc": "子树2"
|
||||
}
|
||||
}
|
||||
@@ -40,5 +40,9 @@
|
||||
"path": "workdir/subtree2.json",
|
||||
"desc": "子树2"
|
||||
}
|
||||
]
|
||||
],
|
||||
"settings": {
|
||||
"checkExpr": true,
|
||||
"buildScript": "scripts/build.js"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user