@esengine/blueprint 4.0.0 → 4.1.0

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
@@ -2280,4 +2280,239 @@ declare const defaultFragmentRegistry: FragmentRegistry;
2280
2280
  */
2281
2281
  declare function createFragmentRegistry(): IFragmentRegistry;
2282
2282
 
2283
- export { AlwaysFalseCondition, AlwaysTrueCondition, type BlueprintAsset, BlueprintComposer, type BlueprintCompositionAsset, type BlueprintConnection, BlueprintFragment, type BlueprintFragmentAsset, type BlueprintFragmentConfig, type BlueprintMetadata, type BlueprintNode, type BlueprintNodeCategory, type BlueprintNodeTemplate, type BlueprintPin, type BlueprintPinDefinition, type BlueprintPinDirection, type BlueprintPinType, type BlueprintRuntimePin, BlueprintTrigger, BlueprintVM, type BlueprintVariable, CollisionEntityCondition, CompositeCondition, type CompositionError, type CompositionValidationResult, type CompositionWarning, ConditionBuilder, type ConditionLogic, CustomEventCondition, type DispatchResult, EntityIdCondition, EntityTriggerManager, type EventType, ExecutionContext, type ExecutionResult, type ExposedPin, type FragmentFilter, FragmentRegistry, type FragmentSlot, FunctionCondition, type IBlueprintComponent, type IBlueprintComposer, type IBlueprintEntity, type IBlueprintFragment, type IBlueprintSystem, type IBlueprintTrigger, type ICollisionTriggerContext, type ICustomTriggerContext, type IEntityTriggerManager, type IFragmentRegistry, type IInputTriggerContext, type IMessageTriggerContext, type INodeExecutor, type IStateTriggerContext, type ITickTriggerContext, type ITimerTriggerContext, type ITriggerCondition, type ITriggerContext, type ITriggerDispatcher, type ITriggerRegistry, InputActionCondition, MessageNameCondition, type NodeDefinition, NodeRegistry, NotCondition, RegisterNode, type SlotConnection, StateNameCondition, TimerIdCondition, type TriggerCallback, type TriggerConfig, type TriggerContext, TriggerDispatcher, TriggerRegistry, type TriggerResult, type TriggerType, TriggerTypeCondition, TriggerTypes, type VariableScope, arePinTypesCompatible, cleanupBlueprint, condition, createBlueprintComponentData, createBlueprintSystem, createCollisionContext, createCollisionTrigger, createComposer, createCustomContext, createCustomTrigger, createEmptyBlueprint, createEntityTriggerManager, createExposedPin, createFragment, createFragmentRegistry, createInputContext, createInputTrigger, createMessageContext, createMessageTrigger, createStateContext, createStateEnterTrigger, createStateExitTrigger, createTickContext, createTickTrigger, createTimerContext, createTimerTrigger, createTrigger, createTriggerDispatcher, defaultFragmentRegistry, fragmentFromAsset, fragmentToAsset, getNodeCategoryColor, getPinTypeColor, initializeBlueprintVM, startBlueprint, stopBlueprint, tickBlueprint, triggerBlueprintEvent, triggerCustomBlueprintEvent, validateBlueprintAsset };
2283
+ /**
2284
+ * @zh 蓝图装饰器 - 用于标记可在蓝图中使用的组件、属性和方法
2285
+ * @en Blueprint Decorators - Mark components, properties and methods for blueprint use
2286
+ *
2287
+ * @example
2288
+ * ```typescript
2289
+ * import { BlueprintExpose, BlueprintProperty, BlueprintMethod } from '@esengine/blueprint';
2290
+ *
2291
+ * @ECSComponent('Health')
2292
+ * @BlueprintExpose({ displayName: '生命值组件', category: 'gameplay' })
2293
+ * export class HealthComponent extends Component {
2294
+ *
2295
+ * @BlueprintProperty({ displayName: '当前生命值', type: 'float' })
2296
+ * current: number = 100;
2297
+ *
2298
+ * @BlueprintProperty({ displayName: '最大生命值', type: 'float', readonly: true })
2299
+ * max: number = 100;
2300
+ *
2301
+ * @BlueprintMethod({
2302
+ * displayName: '治疗',
2303
+ * params: [{ name: 'amount', type: 'float' }]
2304
+ * })
2305
+ * heal(amount: number): void {
2306
+ * this.current = Math.min(this.current + amount, this.max);
2307
+ * }
2308
+ *
2309
+ * @BlueprintMethod({
2310
+ * displayName: '受伤',
2311
+ * params: [{ name: 'amount', type: 'float' }],
2312
+ * returnType: 'bool'
2313
+ * })
2314
+ * takeDamage(amount: number): boolean {
2315
+ * this.current -= amount;
2316
+ * return this.current <= 0;
2317
+ * }
2318
+ * }
2319
+ * ```
2320
+ */
2321
+
2322
+ /**
2323
+ * @zh 参数定义
2324
+ * @en Parameter definition
2325
+ */
2326
+ interface BlueprintParamDef {
2327
+ /** @zh 参数名称 @en Parameter name */
2328
+ name: string;
2329
+ /** @zh 显示名称 @en Display name */
2330
+ displayName?: string;
2331
+ /** @zh 引脚类型 @en Pin type */
2332
+ type?: BlueprintPinType;
2333
+ /** @zh 默认值 @en Default value */
2334
+ defaultValue?: unknown;
2335
+ }
2336
+ /**
2337
+ * @zh 蓝图暴露选项
2338
+ * @en Blueprint expose options
2339
+ */
2340
+ interface BlueprintExposeOptions {
2341
+ /** @zh 组件显示名称 @en Component display name */
2342
+ displayName?: string;
2343
+ /** @zh 组件描述 @en Component description */
2344
+ description?: string;
2345
+ /** @zh 组件分类 @en Component category */
2346
+ category?: string;
2347
+ /** @zh 组件颜色 @en Component color */
2348
+ color?: string;
2349
+ /** @zh 组件图标 @en Component icon */
2350
+ icon?: string;
2351
+ }
2352
+ /**
2353
+ * @zh 蓝图属性选项
2354
+ * @en Blueprint property options
2355
+ */
2356
+ interface BlueprintPropertyOptions {
2357
+ /** @zh 属性显示名称 @en Property display name */
2358
+ displayName?: string;
2359
+ /** @zh 属性描述 @en Property description */
2360
+ description?: string;
2361
+ /** @zh 引脚类型 @en Pin type */
2362
+ type?: BlueprintPinType;
2363
+ /** @zh 是否只读(不生成 Set 节点)@en Readonly (no Set node generated) */
2364
+ readonly?: boolean;
2365
+ /** @zh 默认值 @en Default value */
2366
+ defaultValue?: unknown;
2367
+ }
2368
+ /**
2369
+ * @zh 蓝图方法选项
2370
+ * @en Blueprint method options
2371
+ */
2372
+ interface BlueprintMethodOptions {
2373
+ /** @zh 方法显示名称 @en Method display name */
2374
+ displayName?: string;
2375
+ /** @zh 方法描述 @en Method description */
2376
+ description?: string;
2377
+ /** @zh 是否是纯函数(无副作用)@en Is pure function (no side effects) */
2378
+ isPure?: boolean;
2379
+ /** @zh 参数列表 @en Parameter list */
2380
+ params?: BlueprintParamDef[];
2381
+ /** @zh 返回值类型 @en Return type */
2382
+ returnType?: BlueprintPinType;
2383
+ }
2384
+ /**
2385
+ * @zh 属性元数据
2386
+ * @en Property metadata
2387
+ */
2388
+ interface PropertyMetadata {
2389
+ propertyKey: string;
2390
+ displayName: string;
2391
+ description?: string;
2392
+ pinType: BlueprintPinType;
2393
+ readonly: boolean;
2394
+ defaultValue?: unknown;
2395
+ }
2396
+ /**
2397
+ * @zh 方法元数据
2398
+ * @en Method metadata
2399
+ */
2400
+ interface MethodMetadata {
2401
+ methodKey: string;
2402
+ displayName: string;
2403
+ description?: string;
2404
+ isPure: boolean;
2405
+ params: BlueprintParamDef[];
2406
+ returnType: BlueprintPinType;
2407
+ }
2408
+ /**
2409
+ * @zh 组件蓝图元数据
2410
+ * @en Component blueprint metadata
2411
+ */
2412
+ interface ComponentBlueprintMetadata extends BlueprintExposeOptions {
2413
+ componentName: string;
2414
+ properties: PropertyMetadata[];
2415
+ methods: MethodMetadata[];
2416
+ }
2417
+ /**
2418
+ * @zh 获取所有已注册的蓝图组件
2419
+ * @en Get all registered blueprint components
2420
+ */
2421
+ declare function getRegisteredBlueprintComponents(): Map<Function, ComponentBlueprintMetadata>;
2422
+ /**
2423
+ * @zh 获取组件的蓝图元数据
2424
+ * @en Get blueprint metadata for a component
2425
+ */
2426
+ declare function getBlueprintMetadata(componentClass: Function): ComponentBlueprintMetadata | undefined;
2427
+ /**
2428
+ * @zh 清除所有注册的蓝图组件(用于测试)
2429
+ * @en Clear all registered blueprint components (for testing)
2430
+ */
2431
+ declare function clearRegisteredComponents(): void;
2432
+ /**
2433
+ * @zh 标记组件可在蓝图中使用
2434
+ * @en Mark component as usable in blueprint
2435
+ *
2436
+ * @example
2437
+ * ```typescript
2438
+ * @ECSComponent('Player')
2439
+ * @BlueprintExpose({ displayName: '玩家', category: 'gameplay' })
2440
+ * export class PlayerComponent extends Component { }
2441
+ * ```
2442
+ */
2443
+ declare function BlueprintExpose(options?: BlueprintExposeOptions): ClassDecorator;
2444
+ /**
2445
+ * @zh 标记属性可在蓝图中访问
2446
+ * @en Mark property as accessible in blueprint
2447
+ *
2448
+ * @example
2449
+ * ```typescript
2450
+ * @BlueprintProperty({ displayName: '生命值', type: 'float' })
2451
+ * health: number = 100;
2452
+ *
2453
+ * @BlueprintProperty({ displayName: '名称', type: 'string', readonly: true })
2454
+ * name: string = 'Player';
2455
+ * ```
2456
+ */
2457
+ declare function BlueprintProperty(options?: BlueprintPropertyOptions): PropertyDecorator;
2458
+ /**
2459
+ * @zh 标记方法可在蓝图中调用
2460
+ * @en Mark method as callable in blueprint
2461
+ *
2462
+ * @example
2463
+ * ```typescript
2464
+ * @BlueprintMethod({
2465
+ * displayName: '攻击',
2466
+ * params: [
2467
+ * { name: 'target', type: 'entity' },
2468
+ * { name: 'damage', type: 'float' }
2469
+ * ],
2470
+ * returnType: 'bool'
2471
+ * })
2472
+ * attack(target: Entity, damage: number): boolean { }
2473
+ *
2474
+ * @BlueprintMethod({ displayName: '获取速度', isPure: true, returnType: 'float' })
2475
+ * getSpeed(): number { return this.speed; }
2476
+ * ```
2477
+ */
2478
+ declare function BlueprintMethod(options?: BlueprintMethodOptions): MethodDecorator;
2479
+ /**
2480
+ * @zh 从 TypeScript 类型名推断蓝图引脚类型
2481
+ * @en Infer blueprint pin type from TypeScript type name
2482
+ */
2483
+ declare function inferPinType(typeName: string): BlueprintPinType;
2484
+
2485
+ /**
2486
+ * @zh 组件节点生成器 - 自动为标记的组件生成蓝图节点
2487
+ * @en Component Node Generator - Auto-generate blueprint nodes for marked components
2488
+ *
2489
+ * @zh 根据 @BlueprintExpose、@BlueprintProperty、@BlueprintMethod 装饰器
2490
+ * 自动生成对应的 Get/Set/Call 节点并注册到 NodeRegistry
2491
+ *
2492
+ * @en Based on @BlueprintExpose, @BlueprintProperty, @BlueprintMethod decorators,
2493
+ * auto-generate corresponding Get/Set/Call nodes and register to NodeRegistry
2494
+ */
2495
+
2496
+ /**
2497
+ * @zh 为组件生成所有蓝图节点
2498
+ * @en Generate all blueprint nodes for a component
2499
+ */
2500
+ declare function generateComponentNodes(componentClass: Function, metadata: ComponentBlueprintMetadata): void;
2501
+ /**
2502
+ * @zh 注册所有已标记的组件节点
2503
+ * @en Register all marked component nodes
2504
+ *
2505
+ * @zh 应该在蓝图系统初始化时调用,会扫描所有使用 @BlueprintExpose 装饰的组件
2506
+ * 并自动生成对应的蓝图节点
2507
+ *
2508
+ * @en Should be called during blueprint system initialization, scans all components
2509
+ * decorated with @BlueprintExpose and auto-generates corresponding blueprint nodes
2510
+ */
2511
+ declare function registerAllComponentNodes(): void;
2512
+ /**
2513
+ * @zh 手动注册单个组件
2514
+ * @en Manually register a single component
2515
+ */
2516
+ declare function registerComponentNodes(componentClass: Function): void;
2517
+
2518
+ export { AlwaysFalseCondition, AlwaysTrueCondition, type BlueprintAsset, BlueprintComposer, type BlueprintCompositionAsset, type BlueprintConnection, BlueprintExpose, type BlueprintExposeOptions, BlueprintFragment, type BlueprintFragmentAsset, type BlueprintFragmentConfig, type BlueprintMetadata, BlueprintMethod, type BlueprintMethodOptions, type BlueprintNode, type BlueprintNodeCategory, type BlueprintNodeTemplate, type BlueprintParamDef, type BlueprintPin, type BlueprintPinDefinition, type BlueprintPinDirection, type BlueprintPinType, BlueprintProperty, type BlueprintPropertyOptions, type BlueprintRuntimePin, BlueprintTrigger, BlueprintVM, type BlueprintVariable, CollisionEntityCondition, type ComponentBlueprintMetadata, CompositeCondition, type CompositionError, type CompositionValidationResult, type CompositionWarning, ConditionBuilder, type ConditionLogic, CustomEventCondition, type DispatchResult, EntityIdCondition, EntityTriggerManager, type EventType, ExecutionContext, type ExecutionResult, type ExposedPin, type FragmentFilter, FragmentRegistry, type FragmentSlot, FunctionCondition, type IBlueprintComponent, type IBlueprintComposer, type IBlueprintEntity, type IBlueprintFragment, type IBlueprintSystem, type IBlueprintTrigger, type ICollisionTriggerContext, type ICustomTriggerContext, type IEntityTriggerManager, type IFragmentRegistry, type IInputTriggerContext, type IMessageTriggerContext, type INodeExecutor, type IStateTriggerContext, type ITickTriggerContext, type ITimerTriggerContext, type ITriggerCondition, type ITriggerContext, type ITriggerDispatcher, type ITriggerRegistry, InputActionCondition, MessageNameCondition, type MethodMetadata, type NodeDefinition, NodeRegistry, NotCondition, type PropertyMetadata, RegisterNode, type SlotConnection, StateNameCondition, TimerIdCondition, type TriggerCallback, type TriggerConfig, type TriggerContext, TriggerDispatcher, TriggerRegistry, type TriggerResult, type TriggerType, TriggerTypeCondition, TriggerTypes, type VariableScope, arePinTypesCompatible, cleanupBlueprint, clearRegisteredComponents, condition, createBlueprintComponentData, createBlueprintSystem, createCollisionContext, createCollisionTrigger, createComposer, createCustomContext, createCustomTrigger, createEmptyBlueprint, createEntityTriggerManager, createExposedPin, createFragment, createFragmentRegistry, createInputContext, createInputTrigger, createMessageContext, createMessageTrigger, createStateContext, createStateEnterTrigger, createStateExitTrigger, createTickContext, createTickTrigger, createTimerContext, createTimerTrigger, createTrigger, createTriggerDispatcher, defaultFragmentRegistry, fragmentFromAsset, fragmentToAsset, generateComponentNodes, getBlueprintMetadata, getNodeCategoryColor, getPinTypeColor, getRegisteredBlueprintComponents, inferPinType, initializeBlueprintVM, registerAllComponentNodes, registerComponentNodes, startBlueprint, stopBlueprint, tickBlueprint, triggerBlueprintEvent, triggerCustomBlueprintEvent, validateBlueprintAsset };