@esengine/blueprint 4.1.0 → 4.3.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 +200 -82
- package/dist/index.js +2168 -1443
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, IScene } from '@esengine/ecs-framework';
|
|
1
|
+
import { Entity, IScene, Component, EntitySystem } from '@esengine/ecs-framework';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Blueprint Pin Types
|
|
@@ -218,10 +218,10 @@ interface BlueprintAsset {
|
|
|
218
218
|
connections: BlueprintConnection[];
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
|
-
* Creates an empty blueprint asset
|
|
222
|
-
*
|
|
221
|
+
* Creates an empty blueprint asset with default Event Begin Play node
|
|
222
|
+
* 创建带有默认 Event Begin Play 节点的空蓝图资产
|
|
223
223
|
*/
|
|
224
|
-
declare function createEmptyBlueprint(name: string): BlueprintAsset;
|
|
224
|
+
declare function createEmptyBlueprint(name: string, includeBeginPlay?: boolean): BlueprintAsset;
|
|
225
225
|
/**
|
|
226
226
|
* Validates a blueprint asset structure
|
|
227
227
|
* 验证蓝图资产结构
|
|
@@ -285,6 +285,8 @@ declare class ExecutionContext {
|
|
|
285
285
|
private _localVariables;
|
|
286
286
|
/** Global variables (shared) (全局变量,共享) */
|
|
287
287
|
private static _globalVariables;
|
|
288
|
+
/** Component class registry (组件类注册表) */
|
|
289
|
+
private static _componentRegistry;
|
|
288
290
|
/** Node output cache for current execution (当前执行的节点输出缓存) */
|
|
289
291
|
private _outputCache;
|
|
290
292
|
/** Connection lookup by target (按目标的连接查找) */
|
|
@@ -353,6 +355,29 @@ declare class ExecutionContext {
|
|
|
353
355
|
* 清除全局变量(用于场景重置)
|
|
354
356
|
*/
|
|
355
357
|
static clearGlobalVariables(): void;
|
|
358
|
+
/**
|
|
359
|
+
* Get a component class by name
|
|
360
|
+
* 通过名称获取组件类
|
|
361
|
+
*
|
|
362
|
+
* @zh 首先检查 @BlueprintExpose 装饰的组件,然后检查手动注册的组件
|
|
363
|
+
* @en First checks @BlueprintExpose decorated components, then manually registered ones
|
|
364
|
+
*/
|
|
365
|
+
getComponentClass(typeName: string): (new () => Component) | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* Register a component class for dynamic creation
|
|
368
|
+
* 注册组件类以支持动态创建
|
|
369
|
+
*/
|
|
370
|
+
static registerComponentClass(typeName: string, componentClass: new () => Component): void;
|
|
371
|
+
/**
|
|
372
|
+
* Unregister a component class
|
|
373
|
+
* 取消注册组件类
|
|
374
|
+
*/
|
|
375
|
+
static unregisterComponentClass(typeName: string): void;
|
|
376
|
+
/**
|
|
377
|
+
* Get all registered component classes
|
|
378
|
+
* 获取所有已注册的组件类
|
|
379
|
+
*/
|
|
380
|
+
static getRegisteredComponentClasses(): Map<string, new () => Component>;
|
|
356
381
|
}
|
|
357
382
|
|
|
358
383
|
/**
|
|
@@ -552,101 +577,126 @@ declare class BlueprintVM {
|
|
|
552
577
|
}
|
|
553
578
|
|
|
554
579
|
/**
|
|
555
|
-
*
|
|
556
|
-
*
|
|
580
|
+
* @zh 蓝图组件 - 将蓝图附加到实体
|
|
581
|
+
* @en Blueprint Component - Attaches a blueprint to an entity
|
|
557
582
|
*/
|
|
558
583
|
|
|
559
584
|
/**
|
|
560
|
-
*
|
|
561
|
-
*
|
|
585
|
+
* @zh 蓝图组件,用于将可视化脚本附加到 ECS 实体
|
|
586
|
+
* @en Blueprint component for attaching visual scripts to ECS entities
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```typescript
|
|
590
|
+
* const entity = scene.createEntity('Player');
|
|
591
|
+
* const blueprint = new BlueprintComponent();
|
|
592
|
+
* blueprint.blueprintAsset = await loadBlueprintAsset('player.bp');
|
|
593
|
+
* blueprint.autoStart = true;
|
|
594
|
+
* entity.addComponent(blueprint);
|
|
595
|
+
* ```
|
|
562
596
|
*/
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
|
|
566
|
-
|
|
597
|
+
declare class BlueprintComponent extends Component {
|
|
598
|
+
/**
|
|
599
|
+
* @zh 蓝图资产引用
|
|
600
|
+
* @en Blueprint asset reference
|
|
601
|
+
*/
|
|
567
602
|
blueprintAsset: BlueprintAsset | null;
|
|
568
|
-
/**
|
|
603
|
+
/**
|
|
604
|
+
* @zh 用于序列化的蓝图资产路径
|
|
605
|
+
* @en Blueprint asset path for serialization
|
|
606
|
+
*/
|
|
569
607
|
blueprintPath: string;
|
|
570
|
-
/**
|
|
608
|
+
/**
|
|
609
|
+
* @zh 实体创建时自动开始执行
|
|
610
|
+
* @en Auto-start execution when entity is created
|
|
611
|
+
*/
|
|
571
612
|
autoStart: boolean;
|
|
572
|
-
/**
|
|
613
|
+
/**
|
|
614
|
+
* @zh 启用 VM 调试模式
|
|
615
|
+
* @en Enable debug mode for VM
|
|
616
|
+
*/
|
|
573
617
|
debug: boolean;
|
|
574
|
-
/**
|
|
618
|
+
/**
|
|
619
|
+
* @zh 运行时 VM 实例
|
|
620
|
+
* @en Runtime VM instance
|
|
621
|
+
*/
|
|
575
622
|
vm: BlueprintVM | null;
|
|
576
|
-
/**
|
|
623
|
+
/**
|
|
624
|
+
* @zh 蓝图是否已启动
|
|
625
|
+
* @en Whether the blueprint has started
|
|
626
|
+
*/
|
|
577
627
|
isStarted: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* @zh 初始化蓝图 VM
|
|
630
|
+
* @en Initialize blueprint VM
|
|
631
|
+
*/
|
|
632
|
+
initialize(entity: Entity, scene: IScene): void;
|
|
633
|
+
/**
|
|
634
|
+
* @zh 开始执行蓝图
|
|
635
|
+
* @en Start blueprint execution
|
|
636
|
+
*/
|
|
637
|
+
start(): void;
|
|
638
|
+
/**
|
|
639
|
+
* @zh 停止执行蓝图
|
|
640
|
+
* @en Stop blueprint execution
|
|
641
|
+
*/
|
|
642
|
+
stop(): void;
|
|
643
|
+
/**
|
|
644
|
+
* @zh 更新蓝图
|
|
645
|
+
* @en Update blueprint
|
|
646
|
+
*/
|
|
647
|
+
tick(deltaTime: number): void;
|
|
648
|
+
/**
|
|
649
|
+
* @zh 清理蓝图资源
|
|
650
|
+
* @en Cleanup blueprint resources
|
|
651
|
+
*/
|
|
652
|
+
cleanup(): void;
|
|
578
653
|
}
|
|
579
|
-
/**
|
|
580
|
-
* Creates a blueprint component data object
|
|
581
|
-
* 创建蓝图组件数据对象
|
|
582
|
-
*/
|
|
583
|
-
declare function createBlueprintComponentData(): IBlueprintComponent;
|
|
584
|
-
/**
|
|
585
|
-
* Initialize the VM for a blueprint component
|
|
586
|
-
* 为蓝图组件初始化 VM
|
|
587
|
-
*/
|
|
588
|
-
declare function initializeBlueprintVM(component: IBlueprintComponent, entity: Entity, scene: IScene): void;
|
|
589
|
-
/**
|
|
590
|
-
* Start blueprint execution
|
|
591
|
-
* 开始蓝图执行
|
|
592
|
-
*/
|
|
593
|
-
declare function startBlueprint(component: IBlueprintComponent): void;
|
|
594
|
-
/**
|
|
595
|
-
* Stop blueprint execution
|
|
596
|
-
* 停止蓝图执行
|
|
597
|
-
*/
|
|
598
|
-
declare function stopBlueprint(component: IBlueprintComponent): void;
|
|
599
|
-
/**
|
|
600
|
-
* Update blueprint execution
|
|
601
|
-
* 更新蓝图执行
|
|
602
|
-
*/
|
|
603
|
-
declare function tickBlueprint(component: IBlueprintComponent, deltaTime: number): void;
|
|
604
|
-
/**
|
|
605
|
-
* Clean up blueprint resources
|
|
606
|
-
* 清理蓝图资源
|
|
607
|
-
*/
|
|
608
|
-
declare function cleanupBlueprint(component: IBlueprintComponent): void;
|
|
609
654
|
|
|
610
655
|
/**
|
|
611
|
-
*
|
|
612
|
-
*
|
|
656
|
+
* @zh 蓝图系统 - 处理所有带有 BlueprintComponent 的实体
|
|
657
|
+
* @en Blueprint System - Processes all entities with BlueprintComponent
|
|
613
658
|
*/
|
|
614
659
|
|
|
615
660
|
/**
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
*
|
|
629
|
-
*
|
|
661
|
+
* @zh 蓝图执行系统
|
|
662
|
+
* @en Blueprint execution system
|
|
663
|
+
*
|
|
664
|
+
* @zh 自动处理所有带有 BlueprintComponent 的实体,管理蓝图的初始化、执行和清理
|
|
665
|
+
* @en Automatically processes all entities with BlueprintComponent, manages blueprint initialization, execution and cleanup
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```typescript
|
|
669
|
+
* import { BlueprintSystem } from '@esengine/blueprint';
|
|
670
|
+
*
|
|
671
|
+
* // 添加到场景
|
|
672
|
+
* scene.addSystem(new BlueprintSystem());
|
|
673
|
+
*
|
|
674
|
+
* // 为实体添加蓝图
|
|
675
|
+
* const entity = scene.createEntity('Player');
|
|
676
|
+
* const blueprint = new BlueprintComponent();
|
|
677
|
+
* blueprint.blueprintAsset = await loadBlueprintAsset('player.bp');
|
|
678
|
+
* entity.addComponent(blueprint);
|
|
679
|
+
* ```
|
|
630
680
|
*/
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
681
|
+
declare class BlueprintSystem extends EntitySystem {
|
|
682
|
+
private _componentsRegistered;
|
|
683
|
+
constructor();
|
|
684
|
+
/**
|
|
685
|
+
* @zh 系统初始化时注册所有组件节点
|
|
686
|
+
* @en Register all component nodes when system initializes
|
|
687
|
+
*/
|
|
688
|
+
protected onInitialize(): void;
|
|
689
|
+
/**
|
|
690
|
+
* @zh 处理所有带有蓝图组件的实体
|
|
691
|
+
* @en Process all entities with blueprint components
|
|
692
|
+
*/
|
|
693
|
+
protected process(entities: readonly Entity[]): void;
|
|
694
|
+
/**
|
|
695
|
+
* @zh 实体移除时清理蓝图资源
|
|
696
|
+
* @en Cleanup blueprint resources when entity is removed
|
|
697
|
+
*/
|
|
698
|
+
protected onRemoved(entity: Entity): void;
|
|
634
699
|
}
|
|
635
|
-
/**
|
|
636
|
-
* Creates a blueprint execution system
|
|
637
|
-
* 创建蓝图执行系统
|
|
638
|
-
*/
|
|
639
|
-
declare function createBlueprintSystem(scene: IScene): IBlueprintSystem;
|
|
640
|
-
/**
|
|
641
|
-
* Utility to manually trigger blueprint events
|
|
642
|
-
* 手动触发蓝图事件的工具
|
|
643
|
-
*/
|
|
644
|
-
declare function triggerBlueprintEvent(entity: IBlueprintEntity, eventType: string, data?: Record<string, unknown>): void;
|
|
645
|
-
/**
|
|
646
|
-
* Utility to trigger custom events by name
|
|
647
|
-
* 按名称触发自定义事件的工具
|
|
648
|
-
*/
|
|
649
|
-
declare function triggerCustomBlueprintEvent(entity: IBlueprintEntity, eventName: string, data?: Record<string, unknown>): void;
|
|
650
700
|
|
|
651
701
|
/**
|
|
652
702
|
* @zh 蓝图触发器类型定义
|
|
@@ -2515,4 +2565,72 @@ declare function registerAllComponentNodes(): void;
|
|
|
2515
2565
|
*/
|
|
2516
2566
|
declare function registerComponentNodes(componentClass: Function): void;
|
|
2517
2567
|
|
|
2518
|
-
|
|
2568
|
+
/**
|
|
2569
|
+
* @esengine/blueprint - Visual scripting system for ECS Framework
|
|
2570
|
+
*
|
|
2571
|
+
* @zh 蓝图可视化脚本系统 - 与 ECS 框架深度集成
|
|
2572
|
+
* @en Visual scripting system - Deep integration with ECS framework
|
|
2573
|
+
*
|
|
2574
|
+
* @zh 此包提供完整的可视化脚本功能:
|
|
2575
|
+
* - 内置 ECS 操作节点(Entity、Component、Flow)
|
|
2576
|
+
* - 组件自动节点生成(使用装饰器标记)
|
|
2577
|
+
* - 运行时蓝图执行
|
|
2578
|
+
*
|
|
2579
|
+
* @en This package provides complete visual scripting features:
|
|
2580
|
+
* - Built-in ECS operation nodes (Entity, Component, Flow)
|
|
2581
|
+
* - Auto component node generation (using decorators)
|
|
2582
|
+
* - Runtime blueprint execution
|
|
2583
|
+
*
|
|
2584
|
+
* @example 基础使用 | Basic Usage:
|
|
2585
|
+
* ```typescript
|
|
2586
|
+
* import { BlueprintSystem, BlueprintComponent } from '@esengine/blueprint';
|
|
2587
|
+
* import { Scene, Core } from '@esengine/ecs-framework';
|
|
2588
|
+
*
|
|
2589
|
+
* // 创建场景并添加蓝图系统
|
|
2590
|
+
* const scene = new Scene();
|
|
2591
|
+
* scene.addSystem(new BlueprintSystem());
|
|
2592
|
+
* Core.setScene(scene);
|
|
2593
|
+
*
|
|
2594
|
+
* // 为实体添加蓝图
|
|
2595
|
+
* const entity = scene.createEntity('Player');
|
|
2596
|
+
* const blueprint = new BlueprintComponent();
|
|
2597
|
+
* blueprint.blueprintAsset = await loadBlueprintAsset('player.bp');
|
|
2598
|
+
* entity.addComponent(blueprint);
|
|
2599
|
+
* ```
|
|
2600
|
+
*
|
|
2601
|
+
* @example 标记组件 | Mark Components:
|
|
2602
|
+
* ```typescript
|
|
2603
|
+
* import { BlueprintExpose, BlueprintProperty, BlueprintMethod } from '@esengine/blueprint';
|
|
2604
|
+
* import { Component, ECSComponent } from '@esengine/ecs-framework';
|
|
2605
|
+
*
|
|
2606
|
+
* @ECSComponent('Health')
|
|
2607
|
+
* @BlueprintExpose({ displayName: '生命值' })
|
|
2608
|
+
* export class HealthComponent extends Component {
|
|
2609
|
+
* @BlueprintProperty({ displayName: '当前生命值' })
|
|
2610
|
+
* current: number = 100;
|
|
2611
|
+
*
|
|
2612
|
+
* @BlueprintMethod({ displayName: '治疗' })
|
|
2613
|
+
* heal(amount: number): void {
|
|
2614
|
+
* this.current += amount;
|
|
2615
|
+
* }
|
|
2616
|
+
* }
|
|
2617
|
+
* ```
|
|
2618
|
+
*
|
|
2619
|
+
* @packageDocumentation
|
|
2620
|
+
*/
|
|
2621
|
+
|
|
2622
|
+
/**
|
|
2623
|
+
* @zh 注册组件类以支持在蓝图中动态创建
|
|
2624
|
+
* @en Register a component class for dynamic creation in blueprints
|
|
2625
|
+
*
|
|
2626
|
+
* @example
|
|
2627
|
+
* ```typescript
|
|
2628
|
+
* import { registerComponentClass } from '@esengine/blueprint';
|
|
2629
|
+
* import { MyComponent } from './MyComponent';
|
|
2630
|
+
*
|
|
2631
|
+
* registerComponentClass('MyComponent', MyComponent);
|
|
2632
|
+
* ```
|
|
2633
|
+
*/
|
|
2634
|
+
declare function registerComponentClass(typeName: string, componentClass: new () => Component): void;
|
|
2635
|
+
|
|
2636
|
+
export { AlwaysFalseCondition, AlwaysTrueCondition, type BlueprintAsset, BlueprintComponent, 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, BlueprintSystem, 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 IBlueprintComposer, type IBlueprintFragment, 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, clearRegisteredComponents, condition, 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, registerAllComponentNodes, registerComponentClass, registerComponentNodes, validateBlueprintAsset };
|