update node define

This commit is contained in:
codetypes committed 2024-07-20 09:48:32 +08:00
1 parent ca9469a915
commit e417f3beba
1 file changed
+66 -36
+66 -36
View File
@@ -1,44 +1,72 @@
# 行为树编辑器 # 行为树编辑器
这是一个直观、可视化、通用的行为树编辑器,行为树的保存格式为json,可以让策划自行去实现AI,技能,buff等复杂的游戏逻辑,从而减少不必要的沟通成本和提升开发效率。
这是一个直观、可视化、通用的行为树编辑器,行为树的保存格式为 json,可以让策划自行去实现 AI,技能,buff 等复杂的游戏逻辑,从而减少不必要的沟通成本和提升开发效率。
![](readme/preview.gif) ![](readme/preview.gif)
## 示例项目 ## 示例项目
+ 工作区: sample/workspace.b3-workspace
+ 节点定义: sample/node-config.b3-setting - 工作区: sample/workspace.b3-workspace
+ 行为树目录: sample/workdir - 节点定义: sample/node-config.b3-setting
+ 批处理脚本: sample/scripts - 行为树目录: sample/workdir
- 批处理脚本: sample/scripts
## 节点定义 ## 节点定义
```typescript ```typescript
interface NodeArgOption { export interface NodeDef {
name: string; name: string;
value: string | number; type: "Action" | "Decorator" | "Condition" | "Composite";
} desc: string;
interface NodeArg { icon?: string;
name: string, // 字段名 color?: string;
// string | string? | boolean | boolean?| int | int? | float | float? | code | code? | enum | enum? input?: string[];
type: string, // 字段类型 output?: string[];
desc: string, // 字段中文描述 args?: {
default?: string; // 默认值 name: string;
options?: NodeArgOption[]; // 枚举类型 type:
} | "boolean"
interface NodeDef { | "boolean?"
name: string; //节点名称 | "int"
type?: string; //节点分类(Composite,Decorator,Condition,Action) | "int?"
desc?: string; //节点说明 | "float"
args?: ArgsDefType[]; //参数列表 | "float?"
input?: string[]; //输入变量名 exp: ["target", "enemy?"] | "enum"
output?: string[]; //输出变量名 exp: ["target", "enemy?"] | "enum?"
doc?: string; //文档说明(markdown格式) | "string"
color?: string; //节点颜色 exp: "#ff00ff" | "string?"
icon?: string; //节点图标 exp: icons/cmp.svg | "code"
| "code?";
desc: string;
default?: unknown;
options?: { name: string; value: unknown }[];
}[];
status?:
| "success"
| "failure"
| "running"
| "!success" !(child_success | child_success...)
| "!failure" !(child_failure | child_failure...)
| "|success" child_success | child_success...
| "|failure" child_failure | child_failure...
| "|running" child_running | child_running...
| "&success" child_success & child_success...
| "&failure"; child_failure & child_failure...
/** Allowed number of children
* + -1: unlimited
* + 0: no children
* + 1: exactly one
* + 3: exactly three child (ifelse)
*/
children?: -1 | 0 | 1 | 3;
doc?: string; //文档说明(markdown格式)
} }
``` ```
节点定义配置在项目创建的时候会自动生成一个配置,参照[sample/node-config.b3-setting](sample/node-config.b3-setting),这是个json的配置文件。编辑器不提供节点定义的编辑,强烈建议节点定义文件由代码生成 (参照示例项目[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua))。
节点定义配置在项目创建的时候会自动生成一个配置,参照[sample/node-config.b3-setting](sample/node-config.b3-setting),这是个 json 的配置文件。编辑器不提供节点定义的编辑,强烈建议节点定义文件由代码生成 (参照示例项目[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua))。
## 编译与构建 ## 编译与构建
```shell ```shell
npm install # 安装依赖 npm install # 安装依赖
npm start # 运行测试 npm start # 运行测试
@@ -46,15 +74,17 @@ npm run build # 编译可执行文件
``` ```
## 技术栈 ## 技术栈
+ react + ts
+ electron - react + ts
+ antd - electron
+ g6 - antd
- g6
## 示例行为树框架 ## 示例行为树框架
+ lua版本 [behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)
+ js/ts版本 [behavior3-ts](https://github.com/zhongfq/behavior3-ts)。
- lua 版本 [behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)
- js/ts 版本 [behavior3-ts](https://github.com/zhongfq/behavior3-ts)。
## About ## About
本项目将长期维护,欢迎各位大佬加群交流(Q群:644761605)
本项目将长期维护,欢迎各位大佬加群交流(Q 群:644761605)