From 6e3db26b33e37de6151d0f69a1de8f28b7738134 Mon Sep 17 00:00:00 2001 From: codetypes Date: Fri, 6 Feb 2026 15:25:30 +0800 Subject: [PATCH] Fix check children --- package-lock.json | 4 ++-- package.json | 2 +- src/misc/b3util.ts | 12 +++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b4b5e4..1d8c9e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "behavior3editor", - "version": "1.9.0", + "version": "1.9.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "behavior3editor", - "version": "1.9.0", + "version": "1.9.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index cd9abf7..bb6d778 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "behavior3editor", - "version": "1.9.0", + "version": "1.9.1", "main": "dist-electron/main/index.js", "description": "行为树编辑器", "author": "zhandouxiaojiji & codetypes", diff --git a/src/misc/b3util.ts b/src/misc/b3util.ts index 20806a7..241057d 100644 --- a/src/misc/b3util.ts +++ b/src/misc/b3util.ts @@ -468,12 +468,10 @@ const checkNodeData = (data: NodeData | null | undefined, printer: ErrorPrinter) } } - if (conf.children !== undefined && conf.children !== -1) { - const count = data.children?.length || 0; - if (conf.children !== count) { - hasError = true; - error(`expect ${conf.children} children, but got ${count}`); - } + if (!isValidChildren(data)) { + hasError = true; + const count = data.children?.filter((c) => !c.disabled).length || 0; + error(`expect ${conf.children} children, but got ${count}`); } let hasVaridicInput = false; @@ -700,7 +698,7 @@ const buildStatusFlag = (data: NodeData, childStatus: number) => { export const isValidChildren = (data: NodeData) => { const def = nodeDefs.get(data.name); 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; };