@esengine/behavior-tree 4.1.2 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1147,9 +1147,64 @@ declare class BehaviorTreeBuilder {
1147
1147
  */
1148
1148
  modifyBlackboardValue(key: string, operation: string, value: number, name?: string): BehaviorTreeBuilder;
1149
1149
  /**
1150
- * 添加执行动作
1150
+ * 添加执行动作(通过黑板函数)
1151
+ *
1152
+ * @zh 使用黑板中的 action_{actionName} 函数执行动作
1153
+ * @en Execute action using action_{actionName} function from blackboard
1154
+ *
1155
+ * @example
1156
+ * ```typescript
1157
+ * BehaviorTreeBuilder.create("AI")
1158
+ * .defineBlackboardVariable("action_Attack", (entity) => TaskStatus.Success)
1159
+ * .selector("Root")
1160
+ * .executeAction("Attack")
1161
+ * .end()
1162
+ * .build();
1163
+ * ```
1151
1164
  */
1152
1165
  executeAction(actionName: string, name?: string): BehaviorTreeBuilder;
1166
+ /**
1167
+ * 添加自定义动作节点
1168
+ *
1169
+ * @zh 直接使用注册的执行器类型(通过 @NodeExecutorMetadata 装饰器注册的类)
1170
+ * @en Use a registered executor type directly (class registered via @NodeExecutorMetadata decorator)
1171
+ *
1172
+ * @param implementationType - 执行器类型名称(@NodeExecutorMetadata 中的 implementationType)
1173
+ * @param name - 节点显示名称
1174
+ * @param config - 节点配置参数
1175
+ *
1176
+ * @example
1177
+ * ```typescript
1178
+ * // 1. 定义自定义执行器
1179
+ * @NodeExecutorMetadata({
1180
+ * implementationType: 'AttackAction',
1181
+ * nodeType: NodeType.Action,
1182
+ * displayName: '攻击动作',
1183
+ * category: 'Action'
1184
+ * })
1185
+ * class AttackAction implements INodeExecutor {
1186
+ * execute(context: NodeExecutionContext): TaskStatus {
1187
+ * console.log("执行攻击!");
1188
+ * return TaskStatus.Success;
1189
+ * }
1190
+ * }
1191
+ *
1192
+ * // 2. 在行为树中使用
1193
+ * BehaviorTreeBuilder.create("AI")
1194
+ * .selector("Root")
1195
+ * .action("AttackAction", "Attack")
1196
+ * .end()
1197
+ * .build();
1198
+ * ```
1199
+ */
1200
+ action(implementationType: string, name?: string, config?: Record<string, any>): BehaviorTreeBuilder;
1201
+ /**
1202
+ * 添加自定义条件节点
1203
+ *
1204
+ * @zh 直接使用注册的条件执行器类型
1205
+ * @en Use a registered condition executor type directly
1206
+ */
1207
+ condition(implementationType: string, name?: string, config?: Record<string, any>): BehaviorTreeBuilder;
1153
1208
  /**
1154
1209
  * 添加黑板比较条件
1155
1210
  */
package/dist/index.js CHANGED
@@ -3218,13 +3218,72 @@ var _BehaviorTreeBuilder = class _BehaviorTreeBuilder {
3218
3218
  });
3219
3219
  }
3220
3220
  /**
3221
- * 添加执行动作
3221
+ * 添加执行动作(通过黑板函数)
3222
+ *
3223
+ * @zh 使用黑板中的 action_{actionName} 函数执行动作
3224
+ * @en Execute action using action_{actionName} function from blackboard
3225
+ *
3226
+ * @example
3227
+ * ```typescript
3228
+ * BehaviorTreeBuilder.create("AI")
3229
+ * .defineBlackboardVariable("action_Attack", (entity) => TaskStatus.Success)
3230
+ * .selector("Root")
3231
+ * .executeAction("Attack")
3232
+ * .end()
3233
+ * .build();
3234
+ * ```
3222
3235
  */
3223
3236
  executeAction(actionName, name) {
3224
3237
  return this.addActionNode("ExecuteAction", name || "ExecuteAction", {
3225
3238
  actionName
3226
3239
  });
3227
3240
  }
3241
+ /**
3242
+ * 添加自定义动作节点
3243
+ *
3244
+ * @zh 直接使用注册的执行器类型(通过 @NodeExecutorMetadata 装饰器注册的类)
3245
+ * @en Use a registered executor type directly (class registered via @NodeExecutorMetadata decorator)
3246
+ *
3247
+ * @param implementationType - 执行器类型名称(@NodeExecutorMetadata 中的 implementationType)
3248
+ * @param name - 节点显示名称
3249
+ * @param config - 节点配置参数
3250
+ *
3251
+ * @example
3252
+ * ```typescript
3253
+ * // 1. 定义自定义执行器
3254
+ * @NodeExecutorMetadata({
3255
+ * implementationType: 'AttackAction',
3256
+ * nodeType: NodeType.Action,
3257
+ * displayName: '攻击动作',
3258
+ * category: 'Action'
3259
+ * })
3260
+ * class AttackAction implements INodeExecutor {
3261
+ * execute(context: NodeExecutionContext): TaskStatus {
3262
+ * console.log("执行攻击!");
3263
+ * return TaskStatus.Success;
3264
+ * }
3265
+ * }
3266
+ *
3267
+ * // 2. 在行为树中使用
3268
+ * BehaviorTreeBuilder.create("AI")
3269
+ * .selector("Root")
3270
+ * .action("AttackAction", "Attack")
3271
+ * .end()
3272
+ * .build();
3273
+ * ```
3274
+ */
3275
+ action(implementationType, name, config) {
3276
+ return this.addActionNode(implementationType, name || implementationType, config || {});
3277
+ }
3278
+ /**
3279
+ * 添加自定义条件节点
3280
+ *
3281
+ * @zh 直接使用注册的条件执行器类型
3282
+ * @en Use a registered condition executor type directly
3283
+ */
3284
+ condition(implementationType, name, config) {
3285
+ return this.addConditionNode(implementationType, name || implementationType, config || {});
3286
+ }
3228
3287
  /**
3229
3288
  * 添加黑板比较条件
3230
3289
  */