diff --git a/sample/node-config.b3-setting b/sample/node-config.b3-setting
index 352de2f..1fa1356 100644
--- a/sample/node-config.b3-setting
+++ b/sample/node-config.b3-setting
@@ -357,7 +357,7 @@
},
{
"name": "TestB3",
- "type": "Action",
+ "type": "Action (Client|Server|Test)",
"args": [
{
"name": "time",
diff --git a/sample/vars/test-vars.json b/sample/vars/test-vars.json
index 44648f7..6e0028e 100644
--- a/sample/vars/test-vars.json
+++ b/sample/vars/test-vars.json
@@ -3,8 +3,13 @@
"desc": "",
"firstid": 1,
"export": true,
- "group": ["Client"],
- "import": ["vars/declare-core.json", "vars/declare-vars.json"],
+ "group": [
+ "Client"
+ ],
+ "import": [
+ "vars/declare-core.json",
+ "vars/declare-vars.json"
+ ],
"declvar": [
{
"name": "target",
@@ -28,12 +33,16 @@
"id": 4,
"name": "FindEnemy",
"args": {},
- "output": ["target1"]
+ "output": [
+ "target1"
+ ]
},
{
"id": 5,
"name": "Attack",
- "input": ["target1"]
+ "input": [
+ "target1"
+ ]
},
{
"id": 6,
@@ -45,19 +54,46 @@
{
"id": 7,
"name": "MoveToTarget",
- "input": ["target"]
+ "input": [
+ "target"
+ ]
},
{
"id": 8,
"name": "Clear",
- "output": ["test"],
+ "output": [
+ "test"
+ ],
"children": [
{
"id": 9,
"name": "Idle"
}
]
+ },
+ {
+ "id": 10,
+ "name": "TestB3",
+ "args": {
+ "time": 1,
+ "open": true,
+ "check": "1",
+ "name": "1",
+ "status": "FAILURE"
+ }
+ },
+ {
+ "id": 11,
+ "name": "TestB3",
+ "args": {
+ "time": 1,
+ "open": true,
+ "check": "1",
+ "name": "1",
+ "status": "RUNNING"
+ }
}
]
- }
-}
+ },
+ "version": "1.8.0"
+}
\ No newline at end of file
diff --git a/src/components/explorer.tsx b/src/components/explorer.tsx
index f693634..ba0c268 100644
--- a/src/components/explorer.tsx
+++ b/src/components/explorer.tsx
@@ -324,44 +324,47 @@ export const Explorer: FC = () => {
},
};
workspace.nodeDefs.forEach((nodeDef) => {
- let catalog = data.children?.find((nt) => nt.title === nodeDef.type);
- if (!catalog) {
- const type = getNodeType(nodeDef);
- catalog = {
- title: nodeDef.type,
- path: `nodeTree.catalog.${nodeDef.type}`,
- children: [],
- icon: (
+ (nodeDef.group || []).forEach((g, idx) => {
+ const typeGroup = !g ? nodeDef.type : nodeDef.type.replace(/\(([\w|]+)\)/, `(${g})`);
+ let catalog = data.children?.find((nt) => nt.title === typeGroup);
+ if (!catalog) {
+ const type = getNodeType(nodeDef);
+ catalog = {
+ title: typeGroup,
+ path: `nodeTree.catalog.${typeGroup}`,
+ children: [],
+ icon: (
+
+
+
+ ),
+ };
+ data.children?.push(catalog);
+ }
+ catalog.children?.push({
+ title: `${nodeDef.name}(${nodeDef.desc})`,
+ isLeaf: true,
+ def: nodeDef,
+ path: `${nodeDef.name} ${idx}`,
+ icon: nodeDef.icon ? (
+ ) : (
+
+ {" "}
+
),
- };
- data.children?.push(catalog);
- }
- catalog.children?.push({
- title: `${nodeDef.name}(${nodeDef.desc})`,
- isLeaf: true,
- def: nodeDef,
- path: `${nodeDef.name}`,
- icon: nodeDef.icon ? (
-
-
-
- ) : (
-
- {" "}
-
- ),
+ });
});
});
data.children?.sort((a, b) => a.title.localeCompare(b.title));
diff --git a/src/components/inspector.tsx b/src/components/inspector.tsx
index 69a70e8..c109c70 100644
--- a/src/components/inspector.tsx
+++ b/src/components/inspector.tsx
@@ -765,7 +765,7 @@ const NodeInspector: FC = () => {
rules={[
{
validator() {
- if (def.group && !usingGroups[def.group]) {
+ if (def.group && !def.group.some((g) => usingGroups[g])) {
return Promise.reject(new Error(t("node.invalidGroup", { group: def.group })));
}
return Promise.resolve();
diff --git a/src/components/register-node.ts b/src/components/register-node.ts
index 13c62e2..4792749 100644
--- a/src/components/register-node.ts
+++ b/src/components/register-node.ts
@@ -150,7 +150,7 @@ G6.registerNode(
!nodeDefs.has(data.name) ||
(data.path && !data.children?.length) ||
!checkTreeData(data) ||
- (nodeDef.group && !usingGroups[nodeDef.group]) ||
+ (nodeDef.group && !nodeDef.group.some((g) => usingGroups[g])) ||
(usingVars &&
(data.input?.some((v) => v && usingVars?.[v] === undefined) ||
data.output?.some((v) => v && usingVars?.[v] === undefined) ||
diff --git a/src/misc/b3type.ts b/src/misc/b3type.ts
index 430cc90..3c9fd93 100644
--- a/src/misc/b3type.ts
+++ b/src/misc/b3type.ts
@@ -3,7 +3,7 @@ import { NodeDef } from "../behavior3/src/behavior3";
declare module "../behavior3/src/behavior3" {
interface NodeDef {
- group?: string;
+ group?: string[];
}
}
diff --git a/src/misc/b3util.ts b/src/misc/b3util.ts
index 3bcacd2..4b54fa7 100644
--- a/src/misc/b3util.ts
+++ b/src/misc/b3util.ts
@@ -52,10 +52,10 @@ export const initWorkdir = (path: string, handler: typeof alertError) => {
for (const v of nodeDefData) {
nodeDefs.set(v.name, v);
- const group = v.type.match(/\((\w+)\)/)?.[1];
+ const group = v.type.match(/\(([\w|]+)\)/)?.[1];
if (group) {
- v.group = group;
- groups.add(group);
+ v.group = group.split("|");
+ v.group.forEach((g) => groups.add(g));
}
}
groupDefs = Array.from(groups).sort();
@@ -299,7 +299,7 @@ export const checkNodeData = (data: NodeModel | null | undefined) => {
let hasError = false;
if (conf.group) {
- if (!usingGroups[conf.group]) {
+ if (!conf.group.some((g) => usingGroups[g])) {
error(data, `node group '${conf.group}' is not enabled`);
hasError = true;
}