Fix check children
This commit is contained in:
1 parent
6f9097f73d
commit
6e3db26b33
3 files changed
+6
-8
No files matched your search
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"main": "dist-electron/main/index.js",
|
"main": "dist-electron/main/index.js",
|
||||||
"description": "行为树编辑器",
|
"description": "行为树编辑器",
|
||||||
"author": "zhandouxiaojiji & codetypes",
|
"author": "zhandouxiaojiji & codetypes",
|
||||||
|
|||||||
+3
-5
@@ -468,13 +468,11 @@ const checkNodeData = (data: NodeData | null | undefined, printer: ErrorPrinter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.children !== undefined && conf.children !== -1) {
|
if (!isValidChildren(data)) {
|
||||||
const count = data.children?.length || 0;
|
|
||||||
if (conf.children !== count) {
|
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
const count = data.children?.filter((c) => !c.disabled).length || 0;
|
||||||
error(`expect ${conf.children} children, but got ${count}`);
|
error(`expect ${conf.children} children, but got ${count}`);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let hasVaridicInput = false;
|
let hasVaridicInput = false;
|
||||||
if (conf.input) {
|
if (conf.input) {
|
||||||
@@ -700,7 +698,7 @@ const buildStatusFlag = (data: NodeData, childStatus: number) => {
|
|||||||
export const isValidChildren = (data: NodeData) => {
|
export const isValidChildren = (data: NodeData) => {
|
||||||
const def = nodeDefs.get(data.name);
|
const def = nodeDefs.get(data.name);
|
||||||
if (def.children !== undefined && def.children !== -1) {
|
if (def.children !== undefined && def.children !== -1) {
|
||||||
return (data.children?.length || 0) === def.children;
|
return (data.children?.filter((c) => !c.disabled).length || 0) === def.children;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user