@esengine/blueprint 1.0.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.
@@ -0,0 +1,2298 @@
1
+ import { Entity, IScene } from '@esengine/ecs-framework';
2
+ import { IRuntimePlugin } from '@esengine/engine-core';
3
+
4
+ /**
5
+ * Blueprint Pin Types
6
+ * 蓝图引脚类型
7
+ */
8
+ /**
9
+ * Pin data type for blueprint nodes
10
+ * 蓝图节点的引脚数据类型
11
+ */
12
+ type BlueprintPinType = 'exec' | 'bool' | 'int' | 'float' | 'string' | 'vector2' | 'vector3' | 'color' | 'entity' | 'component' | 'object' | 'array' | 'any';
13
+ /**
14
+ * Pin direction
15
+ * 引脚方向
16
+ */
17
+ type BlueprintPinDirection = 'input' | 'output';
18
+ /**
19
+ * Pin definition for node templates
20
+ * 节点模板的引脚定义
21
+ *
22
+ * Note: direction is determined by whether the pin is in inputs[] or outputs[] array
23
+ * 注意:方向由引脚在 inputs[] 还是 outputs[] 数组中决定
24
+ */
25
+ interface BlueprintPinDefinition {
26
+ /** Unique name within node (节点内唯一名称) */
27
+ name: string;
28
+ /** Pin data type (引脚数据类型) */
29
+ type: BlueprintPinType;
30
+ /** Display name shown in the editor (编辑器中显示的名称) */
31
+ displayName?: string;
32
+ /** Default value when not connected (未连接时的默认值) */
33
+ defaultValue?: unknown;
34
+ /** Allow multiple connections (允许多个连接) */
35
+ allowMultiple?: boolean;
36
+ /** Array element type if type is 'array' (数组元素类型) */
37
+ arrayType?: BlueprintPinType;
38
+ /** Whether this pin is optional (是否可选) */
39
+ optional?: boolean;
40
+ /** Tooltip description (提示描述) */
41
+ tooltip?: string;
42
+ }
43
+ /**
44
+ * Runtime pin with direction - used when processing pins
45
+ * 带方向的运行时引脚 - 处理引脚时使用
46
+ */
47
+ interface BlueprintRuntimePin extends BlueprintPinDefinition {
48
+ /** Pin direction (引脚方向) */
49
+ direction: BlueprintPinDirection;
50
+ }
51
+ /**
52
+ * Pin instance in a node
53
+ * 节点中的引脚实例
54
+ */
55
+ interface BlueprintPin {
56
+ id: string;
57
+ nodeId: string;
58
+ definition: BlueprintPinDefinition;
59
+ value?: unknown;
60
+ }
61
+ /**
62
+ * Gets the color for a pin type
63
+ * 获取引脚类型的颜色
64
+ */
65
+ declare function getPinTypeColor(type: BlueprintPinType): string;
66
+ /**
67
+ * Checks if two pin types are compatible for connection
68
+ * 检查两个引脚类型是否兼容连接
69
+ */
70
+ declare function arePinTypesCompatible(from: BlueprintPinType, to: BlueprintPinType): boolean;
71
+
72
+ /**
73
+ * Blueprint Node Types
74
+ * 蓝图节点类型
75
+ */
76
+
77
+ /**
78
+ * Node category for visual styling and organization
79
+ * 节点类别,用于视觉样式和组织
80
+ */
81
+ type BlueprintNodeCategory = 'event' | 'flow' | 'entity' | 'component' | 'math' | 'logic' | 'variable' | 'input' | 'physics' | 'audio' | 'time' | 'debug' | 'custom';
82
+ /**
83
+ * Node template definition - describes a type of node
84
+ * 节点模板定义 - 描述一种节点类型
85
+ */
86
+ interface BlueprintNodeTemplate {
87
+ /** Unique type identifier (唯一类型标识符) */
88
+ type: string;
89
+ /** Display title (显示标题) */
90
+ title: string;
91
+ /** Node category (节点类别) */
92
+ category: BlueprintNodeCategory;
93
+ /** Optional subtitle (可选副标题) */
94
+ subtitle?: string;
95
+ /** Icon name (图标名称) */
96
+ icon?: string;
97
+ /** Description for documentation (文档描述) */
98
+ description?: string;
99
+ /** Search keywords (搜索关键词) */
100
+ keywords?: string[];
101
+ /** Menu path for node palette (节点面板的菜单路径) */
102
+ menuPath?: string[];
103
+ /** Input pin definitions (输入引脚定义) */
104
+ inputs: BlueprintPinDefinition[];
105
+ /** Output pin definitions (输出引脚定义) */
106
+ outputs: BlueprintPinDefinition[];
107
+ /** Whether this node is pure (no exec pins) (是否是纯节点,无执行引脚) */
108
+ isPure?: boolean;
109
+ /** Whether this node can be collapsed (是否可折叠) */
110
+ collapsible?: boolean;
111
+ /** Custom header color override (自定义头部颜色) */
112
+ headerColor?: string;
113
+ /** Node color for visual distinction (节点颜色用于视觉区分) */
114
+ color?: string;
115
+ }
116
+ /**
117
+ * Node instance in a blueprint graph
118
+ * 蓝图图中的节点实例
119
+ */
120
+ interface BlueprintNode {
121
+ /** Unique instance ID (唯一实例ID) */
122
+ id: string;
123
+ /** Template type reference (模板类型引用) */
124
+ type: string;
125
+ /** Position in graph (图中位置) */
126
+ position: {
127
+ x: number;
128
+ y: number;
129
+ };
130
+ /** Custom data for this instance (此实例的自定义数据) */
131
+ data: Record<string, unknown>;
132
+ /** Comment/note for this node (此节点的注释) */
133
+ comment?: string;
134
+ }
135
+ /**
136
+ * Connection between two pins
137
+ * 两个引脚之间的连接
138
+ */
139
+ interface BlueprintConnection {
140
+ /** Unique connection ID (唯一连接ID) */
141
+ id: string;
142
+ /** Source node ID (源节点ID) */
143
+ fromNodeId: string;
144
+ /** Source pin name (源引脚名称) */
145
+ fromPin: string;
146
+ /** Target node ID (目标节点ID) */
147
+ toNodeId: string;
148
+ /** Target pin name (目标引脚名称) */
149
+ toPin: string;
150
+ }
151
+ /**
152
+ * Gets the header color for a node category
153
+ * 获取节点类别的头部颜色
154
+ */
155
+ declare function getNodeCategoryColor(category: BlueprintNodeCategory): string;
156
+
157
+ /**
158
+ * Blueprint Asset Types
159
+ * 蓝图资产类型
160
+ */
161
+
162
+ /**
163
+ * Variable scope determines lifetime and accessibility
164
+ * 变量作用域决定生命周期和可访问性
165
+ */
166
+ type VariableScope = 'local' | 'instance' | 'global';
167
+ /**
168
+ * Blueprint variable definition
169
+ * 蓝图变量定义
170
+ */
171
+ interface BlueprintVariable {
172
+ /** Variable name (变量名) */
173
+ name: string;
174
+ /** Variable type (变量类型) */
175
+ type: string;
176
+ /** Default value (默认值) */
177
+ defaultValue: unknown;
178
+ /** Variable scope (变量作用域) */
179
+ scope: VariableScope;
180
+ /** Category for organization (分类) */
181
+ category?: string;
182
+ /** Description tooltip (描述提示) */
183
+ tooltip?: string;
184
+ }
185
+ /**
186
+ * Blueprint asset metadata
187
+ * 蓝图资产元数据
188
+ */
189
+ interface BlueprintMetadata {
190
+ /** Blueprint name (蓝图名称) */
191
+ name: string;
192
+ /** Description (描述) */
193
+ description?: string;
194
+ /** Category for organization (分类) */
195
+ category?: string;
196
+ /** Author (作者) */
197
+ author?: string;
198
+ /** Creation timestamp (创建时间戳) */
199
+ createdAt?: number;
200
+ /** Last modified timestamp (最后修改时间戳) */
201
+ modifiedAt?: number;
202
+ }
203
+ /**
204
+ * Blueprint asset format - saved to .bp files
205
+ * 蓝图资产格式 - 保存为 .bp 文件
206
+ */
207
+ interface BlueprintAsset {
208
+ /** Format version (格式版本) */
209
+ version: number;
210
+ /** Asset type identifier (资产类型标识符) */
211
+ type: 'blueprint';
212
+ /** Metadata (元数据) */
213
+ metadata: BlueprintMetadata;
214
+ /** Variable definitions (变量定义) */
215
+ variables: BlueprintVariable[];
216
+ /** Node instances (节点实例) */
217
+ nodes: BlueprintNode[];
218
+ /** Connections between nodes (节点之间的连接) */
219
+ connections: BlueprintConnection[];
220
+ }
221
+ /**
222
+ * Creates an empty blueprint asset
223
+ * 创建空的蓝图资产
224
+ */
225
+ declare function createEmptyBlueprint(name: string): BlueprintAsset;
226
+ /**
227
+ * Validates a blueprint asset structure
228
+ * 验证蓝图资产结构
229
+ */
230
+ declare function validateBlueprintAsset(asset: unknown): asset is BlueprintAsset;
231
+
232
+ /**
233
+ * Execution Context - Runtime context for blueprint execution
234
+ * 执行上下文 - 蓝图执行的运行时上下文
235
+ */
236
+
237
+ /**
238
+ * Result of node execution
239
+ * 节点执行的结果
240
+ */
241
+ interface ExecutionResult {
242
+ /**
243
+ * Next exec pin to follow (null to stop, undefined to continue default)
244
+ * 下一个要执行的引脚(null 停止,undefined 继续默认)
245
+ */
246
+ nextExec?: string | null;
247
+ /**
248
+ * Output values by pin name
249
+ * 按引脚名称的输出值
250
+ */
251
+ outputs?: Record<string, unknown>;
252
+ /**
253
+ * Whether to yield execution (for async operations)
254
+ * 是否暂停执行(用于异步操作)
255
+ */
256
+ yield?: boolean;
257
+ /**
258
+ * Delay before continuing (in seconds)
259
+ * 继续前的延迟(秒)
260
+ */
261
+ delay?: number;
262
+ /**
263
+ * Error message if execution failed
264
+ * 执行失败时的错误消息
265
+ */
266
+ error?: string;
267
+ }
268
+ /**
269
+ * Execution context provides access to runtime services
270
+ * 执行上下文提供对运行时服务的访问
271
+ */
272
+ declare class ExecutionContext {
273
+ /** Current blueprint asset (当前蓝图资产) */
274
+ readonly blueprint: BlueprintAsset;
275
+ /** Owner entity (所有者实体) */
276
+ readonly entity: Entity;
277
+ /** Current scene (当前场景) */
278
+ readonly scene: IScene;
279
+ /** Frame delta time (帧增量时间) */
280
+ deltaTime: number;
281
+ /** Total time since start (开始以来的总时间) */
282
+ time: number;
283
+ /** Instance variables (实例变量) */
284
+ private _instanceVariables;
285
+ /** Local variables (per-execution) (局部变量,每次执行) */
286
+ private _localVariables;
287
+ /** Global variables (shared) (全局变量,共享) */
288
+ private static _globalVariables;
289
+ /** Node output cache for current execution (当前执行的节点输出缓存) */
290
+ private _outputCache;
291
+ /** Connection lookup by target (按目标的连接查找) */
292
+ private _connectionsByTarget;
293
+ /** Connection lookup by source (按源的连接查找) */
294
+ private _connectionsBySource;
295
+ constructor(blueprint: BlueprintAsset, entity: Entity, scene: IScene);
296
+ private _buildConnectionMaps;
297
+ /**
298
+ * Get a node by ID
299
+ * 通过ID获取节点
300
+ */
301
+ getNode(nodeId: string): BlueprintNode | undefined;
302
+ /**
303
+ * Get connections to a target pin
304
+ * 获取到目标引脚的连接
305
+ */
306
+ getConnectionsToPin(nodeId: string, pinName: string): BlueprintConnection[];
307
+ /**
308
+ * Get connections from a source pin
309
+ * 获取从源引脚的连接
310
+ */
311
+ getConnectionsFromPin(nodeId: string, pinName: string): BlueprintConnection[];
312
+ /**
313
+ * Evaluate an input pin value (follows connections or uses default)
314
+ * 计算输入引脚值(跟随连接或使用默认值)
315
+ */
316
+ evaluateInput(nodeId: string, pinName: string, defaultValue?: unknown): unknown;
317
+ /**
318
+ * Set output values for a node (cached for current execution)
319
+ * 设置节点的输出值(为当前执行缓存)
320
+ */
321
+ setOutputs(nodeId: string, outputs: Record<string, unknown>): void;
322
+ /**
323
+ * Get cached outputs for a node
324
+ * 获取节点的缓存输出
325
+ */
326
+ getOutputs(nodeId: string): Record<string, unknown> | undefined;
327
+ /**
328
+ * Clear output cache (call at start of new execution)
329
+ * 清除输出缓存(在新执行开始时调用)
330
+ */
331
+ clearOutputCache(): void;
332
+ /**
333
+ * Get a variable value
334
+ * 获取变量值
335
+ */
336
+ getVariable(name: string): unknown;
337
+ /**
338
+ * Set a variable value
339
+ * 设置变量值
340
+ */
341
+ setVariable(name: string, value: unknown): void;
342
+ /**
343
+ * Get all instance variables (for serialization)
344
+ * 获取所有实例变量(用于序列化)
345
+ */
346
+ getInstanceVariables(): Map<string, unknown>;
347
+ /**
348
+ * Set instance variables (for deserialization)
349
+ * 设置实例变量(用于反序列化)
350
+ */
351
+ setInstanceVariables(variables: Map<string, unknown>): void;
352
+ /**
353
+ * Clear global variables (for scene reset)
354
+ * 清除全局变量(用于场景重置)
355
+ */
356
+ static clearGlobalVariables(): void;
357
+ }
358
+
359
+ /**
360
+ * Node Registry - Manages node templates and executors
361
+ * 节点注册表 - 管理节点模板和执行器
362
+ */
363
+
364
+ /**
365
+ * Node executor interface - implements the logic for a node type
366
+ * 节点执行器接口 - 实现节点类型的逻辑
367
+ */
368
+ interface INodeExecutor {
369
+ /**
370
+ * Execute the node
371
+ * 执行节点
372
+ *
373
+ * @param node - Node instance (节点实例)
374
+ * @param context - Execution context (执行上下文)
375
+ * @returns Execution result (执行结果)
376
+ */
377
+ execute(node: BlueprintNode, context: ExecutionContext): ExecutionResult;
378
+ }
379
+ /**
380
+ * Node definition combines template with executor
381
+ * 节点定义组合模板和执行器
382
+ */
383
+ interface NodeDefinition {
384
+ template: BlueprintNodeTemplate;
385
+ executor: INodeExecutor;
386
+ }
387
+ /**
388
+ * Node Registry - singleton that holds all registered node types
389
+ * 节点注册表 - 持有所有注册节点类型的单例
390
+ */
391
+ declare class NodeRegistry {
392
+ private static _instance;
393
+ private _nodes;
394
+ private constructor();
395
+ static get instance(): NodeRegistry;
396
+ /**
397
+ * Register a node type
398
+ * 注册节点类型
399
+ */
400
+ register(template: BlueprintNodeTemplate, executor: INodeExecutor): void;
401
+ /**
402
+ * Get a node definition by type
403
+ * 通过类型获取节点定义
404
+ */
405
+ get(type: string): NodeDefinition | undefined;
406
+ /**
407
+ * Get node template by type
408
+ * 通过类型获取节点模板
409
+ */
410
+ getTemplate(type: string): BlueprintNodeTemplate | undefined;
411
+ /**
412
+ * Get node executor by type
413
+ * 通过类型获取节点执行器
414
+ */
415
+ getExecutor(type: string): INodeExecutor | undefined;
416
+ /**
417
+ * Check if a node type is registered
418
+ * 检查节点类型是否已注册
419
+ */
420
+ has(type: string): boolean;
421
+ /**
422
+ * Get all registered templates
423
+ * 获取所有注册的模板
424
+ */
425
+ getAllTemplates(): BlueprintNodeTemplate[];
426
+ /**
427
+ * Get templates by category
428
+ * 按类别获取模板
429
+ */
430
+ getTemplatesByCategory(category: string): BlueprintNodeTemplate[];
431
+ /**
432
+ * Search templates by keyword
433
+ * 按关键词搜索模板
434
+ */
435
+ searchTemplates(keyword: string): BlueprintNodeTemplate[];
436
+ /**
437
+ * Clear all registrations (for testing)
438
+ * 清除所有注册(用于测试)
439
+ */
440
+ clear(): void;
441
+ }
442
+ /**
443
+ * Decorator for registering node executors
444
+ * 用于注册节点执行器的装饰器
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * @RegisterNode(EventTickTemplate)
449
+ * class EventTickExecutor implements INodeExecutor {
450
+ * execute(node, context) { ... }
451
+ * }
452
+ * ```
453
+ */
454
+ declare function RegisterNode(template: BlueprintNodeTemplate): <T extends new () => INodeExecutor>(constructor: T) => T;
455
+
456
+ /**
457
+ * Blueprint Virtual Machine - Executes blueprint graphs
458
+ * 蓝图虚拟机 - 执行蓝图图
459
+ */
460
+
461
+ /**
462
+ * Event trigger types
463
+ * 事件触发类型
464
+ */
465
+ type EventType = 'BeginPlay' | 'Tick' | 'EndPlay' | 'Collision' | 'TriggerEnter' | 'TriggerExit' | 'Custom';
466
+ /**
467
+ * Blueprint Virtual Machine
468
+ * 蓝图虚拟机
469
+ */
470
+ declare class BlueprintVM {
471
+ /** Execution context (执行上下文) */
472
+ private _context;
473
+ /** Pending executions (delayed nodes) (待处理的执行) */
474
+ private _pendingExecutions;
475
+ /** Event node cache by type (按类型缓存的事件节点) */
476
+ private _eventNodes;
477
+ /** Whether the VM is running (VM 是否运行中) */
478
+ private _isRunning;
479
+ /** Current execution time (当前执行时间) */
480
+ private _currentTime;
481
+ /** Maximum execution steps per frame (每帧最大执行步骤) */
482
+ private _maxStepsPerFrame;
483
+ /** Debug mode (调试模式) */
484
+ debug: boolean;
485
+ constructor(blueprint: BlueprintAsset, entity: Entity, scene: IScene);
486
+ get context(): ExecutionContext;
487
+ get isRunning(): boolean;
488
+ /**
489
+ * Cache event nodes by type for quick lookup
490
+ * 按类型缓存事件节点以便快速查找
491
+ */
492
+ private _cacheEventNodes;
493
+ /**
494
+ * Start the VM
495
+ * 启动 VM
496
+ */
497
+ start(): void;
498
+ /**
499
+ * Stop the VM
500
+ * 停止 VM
501
+ */
502
+ stop(): void;
503
+ /**
504
+ * Pause the VM
505
+ * 暂停 VM
506
+ */
507
+ pause(): void;
508
+ /**
509
+ * Resume the VM
510
+ * 恢复 VM
511
+ */
512
+ resume(): void;
513
+ /**
514
+ * Update the VM (called every frame)
515
+ * 更新 VM(每帧调用)
516
+ */
517
+ tick(deltaTime: number): void;
518
+ /**
519
+ * Trigger an event by type
520
+ * 按类型触发事件
521
+ */
522
+ triggerEvent(eventType: string, data?: Record<string, unknown>): void;
523
+ /**
524
+ * Trigger a custom event by name
525
+ * 按名称触发自定义事件
526
+ */
527
+ triggerCustomEvent(eventName: string, data?: Record<string, unknown>): void;
528
+ /**
529
+ * Execute from a starting node
530
+ * 从起始节点执行
531
+ */
532
+ private _executeFromNode;
533
+ /**
534
+ * Execute a single node
535
+ * 执行单个节点
536
+ */
537
+ private _executeNode;
538
+ /**
539
+ * Process pending delayed executions
540
+ * 处理待处理的延迟执行
541
+ */
542
+ private _processPendingExecutions;
543
+ /**
544
+ * Get instance variables for serialization
545
+ * 获取实例变量用于序列化
546
+ */
547
+ getInstanceVariables(): Map<string, unknown>;
548
+ /**
549
+ * Set instance variables from serialization
550
+ * 从序列化设置实例变量
551
+ */
552
+ setInstanceVariables(variables: Map<string, unknown>): void;
553
+ }
554
+
555
+ /**
556
+ * Blueprint Component - Attaches a blueprint to an entity
557
+ * 蓝图组件 - 将蓝图附加到实体
558
+ */
559
+
560
+ /**
561
+ * Component interface for ECS integration
562
+ * 用于 ECS 集成的组件接口
563
+ */
564
+ interface IBlueprintComponent {
565
+ /** Entity ID this component belongs to (此组件所属的实体ID) */
566
+ entityId: number | null;
567
+ /** Blueprint asset reference (蓝图资产引用) */
568
+ blueprintAsset: BlueprintAsset | null;
569
+ /** Blueprint asset path for serialization (用于序列化的蓝图资产路径) */
570
+ blueprintPath: string;
571
+ /** Auto-start execution when entity is created (实体创建时自动开始执行) */
572
+ autoStart: boolean;
573
+ /** Enable debug mode for VM (启用 VM 调试模式) */
574
+ debug: boolean;
575
+ /** Runtime VM instance (运行时 VM 实例) */
576
+ vm: BlueprintVM | null;
577
+ /** Whether the blueprint has started (蓝图是否已启动) */
578
+ isStarted: boolean;
579
+ }
580
+ /**
581
+ * Creates a blueprint component data object
582
+ * 创建蓝图组件数据对象
583
+ */
584
+ declare function createBlueprintComponentData(): IBlueprintComponent;
585
+ /**
586
+ * Initialize the VM for a blueprint component
587
+ * 为蓝图组件初始化 VM
588
+ */
589
+ declare function initializeBlueprintVM(component: IBlueprintComponent, entity: Entity, scene: IScene): void;
590
+ /**
591
+ * Start blueprint execution
592
+ * 开始蓝图执行
593
+ */
594
+ declare function startBlueprint(component: IBlueprintComponent): void;
595
+ /**
596
+ * Stop blueprint execution
597
+ * 停止蓝图执行
598
+ */
599
+ declare function stopBlueprint(component: IBlueprintComponent): void;
600
+ /**
601
+ * Update blueprint execution
602
+ * 更新蓝图执行
603
+ */
604
+ declare function tickBlueprint(component: IBlueprintComponent, deltaTime: number): void;
605
+ /**
606
+ * Clean up blueprint resources
607
+ * 清理蓝图资源
608
+ */
609
+ declare function cleanupBlueprint(component: IBlueprintComponent): void;
610
+
611
+ /**
612
+ * Blueprint Execution System - Manages blueprint lifecycle and execution
613
+ * 蓝图执行系统 - 管理蓝图生命周期和执行
614
+ */
615
+
616
+ /**
617
+ * Blueprint system interface for engine integration
618
+ * 用于引擎集成的蓝图系统接口
619
+ */
620
+ interface IBlueprintSystem {
621
+ /** Process entities with blueprint components (处理带有蓝图组件的实体) */
622
+ process(entities: IBlueprintEntity[], deltaTime: number): void;
623
+ /** Called when entity is added to system (实体添加到系统时调用) */
624
+ onEntityAdded(entity: IBlueprintEntity): void;
625
+ /** Called when entity is removed from system (实体从系统移除时调用) */
626
+ onEntityRemoved(entity: IBlueprintEntity): void;
627
+ }
628
+ /**
629
+ * Entity with blueprint component
630
+ * 带有蓝图组件的实体
631
+ */
632
+ interface IBlueprintEntity extends Entity {
633
+ /** Blueprint component data (蓝图组件数据) */
634
+ blueprintComponent: IBlueprintComponent;
635
+ }
636
+ /**
637
+ * Creates a blueprint execution system
638
+ * 创建蓝图执行系统
639
+ */
640
+ declare function createBlueprintSystem(scene: IScene): IBlueprintSystem;
641
+ /**
642
+ * Utility to manually trigger blueprint events
643
+ * 手动触发蓝图事件的工具
644
+ */
645
+ declare function triggerBlueprintEvent(entity: IBlueprintEntity, eventType: string, data?: Record<string, unknown>): void;
646
+ /**
647
+ * Utility to trigger custom events by name
648
+ * 按名称触发自定义事件的工具
649
+ */
650
+ declare function triggerCustomBlueprintEvent(entity: IBlueprintEntity, eventName: string, data?: Record<string, unknown>): void;
651
+
652
+ /**
653
+ * @zh 蓝图触发器类型定义
654
+ * @en Blueprint Trigger Type Definitions
655
+ *
656
+ * @zh 定义触发器的核心类型和接口
657
+ * @en Defines core types and interfaces for triggers
658
+ */
659
+ /**
660
+ * @zh 触发器类型枚举
661
+ * @en Trigger type enumeration
662
+ */
663
+ type TriggerType = 'tick' | 'input' | 'collision' | 'message' | 'timer' | 'stateEnter' | 'stateExit' | 'custom';
664
+ /**
665
+ * @zh 触发器类型常量
666
+ * @en Trigger type constants
667
+ */
668
+ declare const TriggerTypes: {
669
+ readonly TICK: "tick";
670
+ readonly INPUT: "input";
671
+ readonly COLLISION: "collision";
672
+ readonly MESSAGE: "message";
673
+ readonly TIMER: "timer";
674
+ readonly STATE_ENTER: "stateEnter";
675
+ readonly STATE_EXIT: "stateExit";
676
+ readonly CUSTOM: "custom";
677
+ };
678
+ /**
679
+ * @zh 触发器上下文基础接口
680
+ * @en Trigger context base interface
681
+ */
682
+ interface ITriggerContext {
683
+ /**
684
+ * @zh 触发器类型
685
+ * @en Trigger type
686
+ */
687
+ readonly type: TriggerType;
688
+ /**
689
+ * @zh 触发时间戳
690
+ * @en Trigger timestamp
691
+ */
692
+ readonly timestamp: number;
693
+ /**
694
+ * @zh 触发源实体 ID
695
+ * @en Source entity ID
696
+ */
697
+ readonly sourceEntityId?: string;
698
+ /**
699
+ * @zh 附加数据
700
+ * @en Additional data
701
+ */
702
+ readonly data?: Record<string, unknown>;
703
+ }
704
+ /**
705
+ * @zh Tick 触发器上下文
706
+ * @en Tick trigger context
707
+ */
708
+ interface ITickTriggerContext extends ITriggerContext {
709
+ readonly type: 'tick';
710
+ /**
711
+ * @zh 增量时间(秒)
712
+ * @en Delta time (seconds)
713
+ */
714
+ readonly deltaTime: number;
715
+ /**
716
+ * @zh 帧计数
717
+ * @en Frame count
718
+ */
719
+ readonly frameCount: number;
720
+ }
721
+ /**
722
+ * @zh 输入触发器上下文
723
+ * @en Input trigger context
724
+ */
725
+ interface IInputTriggerContext extends ITriggerContext {
726
+ readonly type: 'input';
727
+ /**
728
+ * @zh 输入动作名称
729
+ * @en Input action name
730
+ */
731
+ readonly action: string;
732
+ /**
733
+ * @zh 输入值
734
+ * @en Input value
735
+ */
736
+ readonly value: number | boolean;
737
+ /**
738
+ * @zh 是否刚按下
739
+ * @en Is just pressed
740
+ */
741
+ readonly pressed?: boolean;
742
+ /**
743
+ * @zh 是否刚释放
744
+ * @en Is just released
745
+ */
746
+ readonly released?: boolean;
747
+ }
748
+ /**
749
+ * @zh 碰撞触发器上下文
750
+ * @en Collision trigger context
751
+ */
752
+ interface ICollisionTriggerContext extends ITriggerContext {
753
+ readonly type: 'collision';
754
+ /**
755
+ * @zh 碰撞的另一个实体 ID
756
+ * @en Other entity ID in collision
757
+ */
758
+ readonly otherEntityId: string;
759
+ /**
760
+ * @zh 碰撞点
761
+ * @en Collision point
762
+ */
763
+ readonly point?: {
764
+ x: number;
765
+ y: number;
766
+ };
767
+ /**
768
+ * @zh 碰撞法线
769
+ * @en Collision normal
770
+ */
771
+ readonly normal?: {
772
+ x: number;
773
+ y: number;
774
+ };
775
+ /**
776
+ * @zh 是否开始碰撞
777
+ * @en Is collision start
778
+ */
779
+ readonly isEnter: boolean;
780
+ /**
781
+ * @zh 是否结束碰撞
782
+ * @en Is collision end
783
+ */
784
+ readonly isExit: boolean;
785
+ }
786
+ /**
787
+ * @zh 消息触发器上下文
788
+ * @en Message trigger context
789
+ */
790
+ interface IMessageTriggerContext extends ITriggerContext {
791
+ readonly type: 'message';
792
+ /**
793
+ * @zh 消息名称
794
+ * @en Message name
795
+ */
796
+ readonly messageName: string;
797
+ /**
798
+ * @zh 发送者 ID
799
+ * @en Sender ID
800
+ */
801
+ readonly senderId?: string;
802
+ /**
803
+ * @zh 消息负载
804
+ * @en Message payload
805
+ */
806
+ readonly payload?: unknown;
807
+ }
808
+ /**
809
+ * @zh 定时器触发器上下文
810
+ * @en Timer trigger context
811
+ */
812
+ interface ITimerTriggerContext extends ITriggerContext {
813
+ readonly type: 'timer';
814
+ /**
815
+ * @zh 定时器 ID
816
+ * @en Timer ID
817
+ */
818
+ readonly timerId: string;
819
+ /**
820
+ * @zh 是否循环触发
821
+ * @en Is repeating
822
+ */
823
+ readonly isRepeating: boolean;
824
+ /**
825
+ * @zh 已触发次数
826
+ * @en Times fired
827
+ */
828
+ readonly timesFired: number;
829
+ }
830
+ /**
831
+ * @zh 状态触发器上下文
832
+ * @en State trigger context
833
+ */
834
+ interface IStateTriggerContext extends ITriggerContext {
835
+ readonly type: 'stateEnter' | 'stateExit';
836
+ /**
837
+ * @zh 状态机 ID
838
+ * @en State machine ID
839
+ */
840
+ readonly stateMachineId: string;
841
+ /**
842
+ * @zh 当前状态
843
+ * @en Current state
844
+ */
845
+ readonly currentState: string;
846
+ /**
847
+ * @zh 之前状态
848
+ * @en Previous state
849
+ */
850
+ readonly previousState?: string;
851
+ }
852
+ /**
853
+ * @zh 自定义触发器上下文
854
+ * @en Custom trigger context
855
+ */
856
+ interface ICustomTriggerContext extends ITriggerContext {
857
+ readonly type: 'custom';
858
+ /**
859
+ * @zh 事件名称
860
+ * @en Event name
861
+ */
862
+ readonly eventName: string;
863
+ }
864
+ /**
865
+ * @zh 所有触发器上下文的联合类型
866
+ * @en Union type of all trigger contexts
867
+ */
868
+ type TriggerContext = ITickTriggerContext | IInputTriggerContext | ICollisionTriggerContext | IMessageTriggerContext | ITimerTriggerContext | IStateTriggerContext | ICustomTriggerContext;
869
+ /**
870
+ * @zh 创建 Tick 触发器上下文
871
+ * @en Create tick trigger context
872
+ */
873
+ declare function createTickContext(deltaTime: number, frameCount: number, sourceEntityId?: string): ITickTriggerContext;
874
+ /**
875
+ * @zh 创建输入触发器上下文
876
+ * @en Create input trigger context
877
+ */
878
+ declare function createInputContext(action: string, value: number | boolean, options?: {
879
+ pressed?: boolean;
880
+ released?: boolean;
881
+ sourceEntityId?: string;
882
+ }): IInputTriggerContext;
883
+ /**
884
+ * @zh 创建碰撞触发器上下文
885
+ * @en Create collision trigger context
886
+ */
887
+ declare function createCollisionContext(otherEntityId: string, isEnter: boolean, options?: {
888
+ point?: {
889
+ x: number;
890
+ y: number;
891
+ };
892
+ normal?: {
893
+ x: number;
894
+ y: number;
895
+ };
896
+ sourceEntityId?: string;
897
+ }): ICollisionTriggerContext;
898
+ /**
899
+ * @zh 创建消息触发器上下文
900
+ * @en Create message trigger context
901
+ */
902
+ declare function createMessageContext(messageName: string, payload?: unknown, options?: {
903
+ senderId?: string;
904
+ sourceEntityId?: string;
905
+ }): IMessageTriggerContext;
906
+ /**
907
+ * @zh 创建定时器触发器上下文
908
+ * @en Create timer trigger context
909
+ */
910
+ declare function createTimerContext(timerId: string, isRepeating: boolean, timesFired: number, sourceEntityId?: string): ITimerTriggerContext;
911
+ /**
912
+ * @zh 创建状态触发器上下文
913
+ * @en Create state trigger context
914
+ */
915
+ declare function createStateContext(type: 'stateEnter' | 'stateExit', stateMachineId: string, currentState: string, previousState?: string, sourceEntityId?: string): IStateTriggerContext;
916
+ /**
917
+ * @zh 创建自定义触发器上下文
918
+ * @en Create custom trigger context
919
+ */
920
+ declare function createCustomContext(eventName: string, data?: Record<string, unknown>, sourceEntityId?: string): ICustomTriggerContext;
921
+
922
+ /**
923
+ * @zh 触发器条件系统
924
+ * @en Trigger Condition System
925
+ *
926
+ * @zh 提供触发器触发前的条件检查能力
927
+ * @en Provides condition checking before trigger fires
928
+ */
929
+
930
+ /**
931
+ * @zh 触发器条件接口
932
+ * @en Trigger condition interface
933
+ */
934
+ interface ITriggerCondition {
935
+ /**
936
+ * @zh 条件类型标识
937
+ * @en Condition type identifier
938
+ */
939
+ readonly type: string;
940
+ /**
941
+ * @zh 评估条件是否满足
942
+ * @en Evaluate if condition is met
943
+ *
944
+ * @param context - @zh 触发器上下文 @en Trigger context
945
+ * @returns @zh 条件是否满足 @en Whether condition is met
946
+ */
947
+ evaluate(context: ITriggerContext): boolean;
948
+ }
949
+ /**
950
+ * @zh 条件组合逻辑
951
+ * @en Condition combination logic
952
+ */
953
+ type ConditionLogic = 'and' | 'or';
954
+ /**
955
+ * @zh 复合条件 - 组合多个条件
956
+ * @en Composite condition - combines multiple conditions
957
+ */
958
+ declare class CompositeCondition implements ITriggerCondition {
959
+ private readonly _conditions;
960
+ private readonly _logic;
961
+ readonly type = "composite";
962
+ constructor(_conditions: ITriggerCondition[], _logic?: ConditionLogic);
963
+ evaluate(context: ITriggerContext): boolean;
964
+ }
965
+ /**
966
+ * @zh 非条件 - 取反
967
+ * @en Not condition - negates
968
+ */
969
+ declare class NotCondition implements ITriggerCondition {
970
+ private readonly _condition;
971
+ readonly type = "not";
972
+ constructor(_condition: ITriggerCondition);
973
+ evaluate(context: ITriggerContext): boolean;
974
+ }
975
+ /**
976
+ * @zh 始终为真的条件
977
+ * @en Always true condition
978
+ */
979
+ declare class AlwaysTrueCondition implements ITriggerCondition {
980
+ readonly type = "alwaysTrue";
981
+ evaluate(_context: ITriggerContext): boolean;
982
+ }
983
+ /**
984
+ * @zh 始终为假的条件
985
+ * @en Always false condition
986
+ */
987
+ declare class AlwaysFalseCondition implements ITriggerCondition {
988
+ readonly type = "alwaysFalse";
989
+ evaluate(_context: ITriggerContext): boolean;
990
+ }
991
+ /**
992
+ * @zh 触发器类型条件
993
+ * @en Trigger type condition
994
+ */
995
+ declare class TriggerTypeCondition implements ITriggerCondition {
996
+ private readonly _allowedTypes;
997
+ readonly type = "triggerType";
998
+ constructor(_allowedTypes: TriggerType[]);
999
+ evaluate(context: ITriggerContext): boolean;
1000
+ }
1001
+ /**
1002
+ * @zh 实体 ID 条件
1003
+ * @en Entity ID condition
1004
+ */
1005
+ declare class EntityIdCondition implements ITriggerCondition {
1006
+ private readonly _entityId;
1007
+ private readonly _checkSource;
1008
+ readonly type = "entityId";
1009
+ constructor(_entityId: string, _checkSource?: boolean);
1010
+ evaluate(context: ITriggerContext): boolean;
1011
+ }
1012
+ /**
1013
+ * @zh 自定义函数条件
1014
+ * @en Custom function condition
1015
+ */
1016
+ declare class FunctionCondition implements ITriggerCondition {
1017
+ private readonly _predicate;
1018
+ readonly type = "function";
1019
+ constructor(_predicate: (context: ITriggerContext) => boolean);
1020
+ evaluate(context: ITriggerContext): boolean;
1021
+ }
1022
+ /**
1023
+ * @zh 输入动作条件
1024
+ * @en Input action condition
1025
+ */
1026
+ declare class InputActionCondition implements ITriggerCondition {
1027
+ private readonly _action;
1028
+ private readonly _checkPressed?;
1029
+ private readonly _checkReleased?;
1030
+ readonly type = "inputAction";
1031
+ constructor(_action: string, _checkPressed?: boolean | undefined, _checkReleased?: boolean | undefined);
1032
+ evaluate(context: ITriggerContext): boolean;
1033
+ }
1034
+ /**
1035
+ * @zh 消息名称条件
1036
+ * @en Message name condition
1037
+ */
1038
+ declare class MessageNameCondition implements ITriggerCondition {
1039
+ private readonly _messageName;
1040
+ readonly type = "messageName";
1041
+ constructor(_messageName: string);
1042
+ evaluate(context: ITriggerContext): boolean;
1043
+ }
1044
+ /**
1045
+ * @zh 状态名称条件
1046
+ * @en State name condition
1047
+ */
1048
+ declare class StateNameCondition implements ITriggerCondition {
1049
+ private readonly _stateName;
1050
+ private readonly _checkCurrent;
1051
+ readonly type = "stateName";
1052
+ constructor(_stateName: string, _checkCurrent?: boolean);
1053
+ evaluate(context: ITriggerContext): boolean;
1054
+ }
1055
+ /**
1056
+ * @zh 定时器 ID 条件
1057
+ * @en Timer ID condition
1058
+ */
1059
+ declare class TimerIdCondition implements ITriggerCondition {
1060
+ private readonly _timerId;
1061
+ readonly type = "timerId";
1062
+ constructor(_timerId: string);
1063
+ evaluate(context: ITriggerContext): boolean;
1064
+ }
1065
+ /**
1066
+ * @zh 碰撞实体条件
1067
+ * @en Collision entity condition
1068
+ */
1069
+ declare class CollisionEntityCondition implements ITriggerCondition {
1070
+ private readonly _otherEntityId?;
1071
+ private readonly _checkEnter?;
1072
+ private readonly _checkExit?;
1073
+ readonly type = "collisionEntity";
1074
+ constructor(_otherEntityId?: string | undefined, _checkEnter?: boolean | undefined, _checkExit?: boolean | undefined);
1075
+ evaluate(context: ITriggerContext): boolean;
1076
+ }
1077
+ /**
1078
+ * @zh 自定义事件名称条件
1079
+ * @en Custom event name condition
1080
+ */
1081
+ declare class CustomEventCondition implements ITriggerCondition {
1082
+ private readonly _eventName;
1083
+ readonly type = "customEvent";
1084
+ constructor(_eventName: string);
1085
+ evaluate(context: ITriggerContext): boolean;
1086
+ }
1087
+ /**
1088
+ * @zh 条件构建器 - 链式 API
1089
+ * @en Condition builder - fluent API
1090
+ */
1091
+ declare class ConditionBuilder {
1092
+ private _conditions;
1093
+ private _logic;
1094
+ /**
1095
+ * @zh 设置组合逻辑为 AND
1096
+ * @en Set combination logic to AND
1097
+ */
1098
+ and(): this;
1099
+ /**
1100
+ * @zh 设置组合逻辑为 OR
1101
+ * @en Set combination logic to OR
1102
+ */
1103
+ or(): this;
1104
+ /**
1105
+ * @zh 添加触发器类型条件
1106
+ * @en Add trigger type condition
1107
+ */
1108
+ ofType(...types: TriggerType[]): this;
1109
+ /**
1110
+ * @zh 添加实体 ID 条件
1111
+ * @en Add entity ID condition
1112
+ */
1113
+ fromEntity(entityId: string): this;
1114
+ /**
1115
+ * @zh 添加输入动作条件
1116
+ * @en Add input action condition
1117
+ */
1118
+ onInput(action: string, options?: {
1119
+ pressed?: boolean;
1120
+ released?: boolean;
1121
+ }): this;
1122
+ /**
1123
+ * @zh 添加消息条件
1124
+ * @en Add message condition
1125
+ */
1126
+ onMessage(messageName: string): this;
1127
+ /**
1128
+ * @zh 添加状态条件
1129
+ * @en Add state condition
1130
+ */
1131
+ onState(stateName: string, checkCurrent?: boolean): this;
1132
+ /**
1133
+ * @zh 添加定时器条件
1134
+ * @en Add timer condition
1135
+ */
1136
+ onTimer(timerId: string): this;
1137
+ /**
1138
+ * @zh 添加碰撞条件
1139
+ * @en Add collision condition
1140
+ */
1141
+ onCollision(options?: {
1142
+ entityId?: string;
1143
+ isEnter?: boolean;
1144
+ isExit?: boolean;
1145
+ }): this;
1146
+ /**
1147
+ * @zh 添加自定义事件条件
1148
+ * @en Add custom event condition
1149
+ */
1150
+ onCustomEvent(eventName: string): this;
1151
+ /**
1152
+ * @zh 添加自定义函数条件
1153
+ * @en Add custom function condition
1154
+ */
1155
+ where(predicate: (context: ITriggerContext) => boolean): this;
1156
+ /**
1157
+ * @zh 添加取反条件
1158
+ * @en Add negated condition
1159
+ */
1160
+ not(condition: ITriggerCondition): this;
1161
+ /**
1162
+ * @zh 构建条件
1163
+ * @en Build condition
1164
+ */
1165
+ build(): ITriggerCondition;
1166
+ }
1167
+ /**
1168
+ * @zh 创建条件构建器
1169
+ * @en Create condition builder
1170
+ */
1171
+ declare function condition(): ConditionBuilder;
1172
+
1173
+ /**
1174
+ * @zh 蓝图触发器
1175
+ * @en Blueprint Trigger
1176
+ *
1177
+ * @zh 定义触发器的核心实现
1178
+ * @en Defines core trigger implementation
1179
+ */
1180
+
1181
+ /**
1182
+ * @zh 触发器回调函数类型
1183
+ * @en Trigger callback function type
1184
+ */
1185
+ type TriggerCallback = (context: ITriggerContext) => void;
1186
+ /**
1187
+ * @zh 蓝图触发器接口
1188
+ * @en Blueprint trigger interface
1189
+ */
1190
+ interface IBlueprintTrigger {
1191
+ /**
1192
+ * @zh 触发器唯一标识
1193
+ * @en Trigger unique identifier
1194
+ */
1195
+ readonly id: string;
1196
+ /**
1197
+ * @zh 触发器类型
1198
+ * @en Trigger type
1199
+ */
1200
+ readonly type: TriggerType;
1201
+ /**
1202
+ * @zh 触发器条件
1203
+ * @en Trigger conditions
1204
+ */
1205
+ readonly condition: ITriggerCondition;
1206
+ /**
1207
+ * @zh 是否启用
1208
+ * @en Is enabled
1209
+ */
1210
+ enabled: boolean;
1211
+ /**
1212
+ * @zh 优先级(越高越先执行)
1213
+ * @en Priority (higher executes first)
1214
+ */
1215
+ readonly priority: number;
1216
+ /**
1217
+ * @zh 检查是否应该触发
1218
+ * @en Check if should fire
1219
+ */
1220
+ shouldFire(context: ITriggerContext): boolean;
1221
+ /**
1222
+ * @zh 执行触发器
1223
+ * @en Execute trigger
1224
+ */
1225
+ fire(context: ITriggerContext): void;
1226
+ }
1227
+ /**
1228
+ * @zh 触发器配置
1229
+ * @en Trigger configuration
1230
+ */
1231
+ interface TriggerConfig {
1232
+ /**
1233
+ * @zh 触发器 ID
1234
+ * @en Trigger ID
1235
+ */
1236
+ id?: string;
1237
+ /**
1238
+ * @zh 触发器类型
1239
+ * @en Trigger type
1240
+ */
1241
+ type: TriggerType;
1242
+ /**
1243
+ * @zh 触发条件
1244
+ * @en Trigger condition
1245
+ */
1246
+ condition?: ITriggerCondition;
1247
+ /**
1248
+ * @zh 是否启用
1249
+ * @en Is enabled
1250
+ */
1251
+ enabled?: boolean;
1252
+ /**
1253
+ * @zh 优先级
1254
+ * @en Priority
1255
+ */
1256
+ priority?: number;
1257
+ /**
1258
+ * @zh 回调函数
1259
+ * @en Callback function
1260
+ */
1261
+ callback?: TriggerCallback;
1262
+ }
1263
+ /**
1264
+ * @zh 蓝图触发器实现
1265
+ * @en Blueprint trigger implementation
1266
+ */
1267
+ declare class BlueprintTrigger implements IBlueprintTrigger {
1268
+ readonly id: string;
1269
+ readonly type: TriggerType;
1270
+ readonly condition: ITriggerCondition;
1271
+ readonly priority: number;
1272
+ enabled: boolean;
1273
+ private readonly _callback?;
1274
+ private readonly _callbacks;
1275
+ constructor(config: TriggerConfig);
1276
+ /**
1277
+ * @zh 检查是否应该触发
1278
+ * @en Check if should fire
1279
+ */
1280
+ shouldFire(context: ITriggerContext): boolean;
1281
+ /**
1282
+ * @zh 执行触发器
1283
+ * @en Execute trigger
1284
+ */
1285
+ fire(context: ITriggerContext): void;
1286
+ /**
1287
+ * @zh 添加回调
1288
+ * @en Add callback
1289
+ */
1290
+ addCallback(callback: TriggerCallback): void;
1291
+ /**
1292
+ * @zh 移除回调
1293
+ * @en Remove callback
1294
+ */
1295
+ removeCallback(callback: TriggerCallback): void;
1296
+ /**
1297
+ * @zh 清除所有回调
1298
+ * @en Clear all callbacks
1299
+ */
1300
+ clearCallbacks(): void;
1301
+ }
1302
+ /**
1303
+ * @zh 触发器注册表接口
1304
+ * @en Trigger registry interface
1305
+ */
1306
+ interface ITriggerRegistry {
1307
+ /**
1308
+ * @zh 注册触发器
1309
+ * @en Register trigger
1310
+ */
1311
+ register(trigger: IBlueprintTrigger): void;
1312
+ /**
1313
+ * @zh 注销触发器
1314
+ * @en Unregister trigger
1315
+ */
1316
+ unregister(triggerId: string): boolean;
1317
+ /**
1318
+ * @zh 获取触发器
1319
+ * @en Get trigger
1320
+ */
1321
+ get(triggerId: string): IBlueprintTrigger | undefined;
1322
+ /**
1323
+ * @zh 获取所有触发器
1324
+ * @en Get all triggers
1325
+ */
1326
+ getAll(): IBlueprintTrigger[];
1327
+ /**
1328
+ * @zh 按类型获取触发器
1329
+ * @en Get triggers by type
1330
+ */
1331
+ getByType(type: TriggerType): IBlueprintTrigger[];
1332
+ /**
1333
+ * @zh 清除所有触发器
1334
+ * @en Clear all triggers
1335
+ */
1336
+ clear(): void;
1337
+ }
1338
+ /**
1339
+ * @zh 触发器注册表实现
1340
+ * @en Trigger registry implementation
1341
+ */
1342
+ declare class TriggerRegistry implements ITriggerRegistry {
1343
+ private readonly _triggers;
1344
+ private readonly _triggersByType;
1345
+ /**
1346
+ * @zh 注册触发器
1347
+ * @en Register trigger
1348
+ */
1349
+ register(trigger: IBlueprintTrigger): void;
1350
+ /**
1351
+ * @zh 注销触发器
1352
+ * @en Unregister trigger
1353
+ */
1354
+ unregister(triggerId: string): boolean;
1355
+ /**
1356
+ * @zh 获取触发器
1357
+ * @en Get trigger
1358
+ */
1359
+ get(triggerId: string): IBlueprintTrigger | undefined;
1360
+ /**
1361
+ * @zh 获取所有触发器
1362
+ * @en Get all triggers
1363
+ */
1364
+ getAll(): IBlueprintTrigger[];
1365
+ /**
1366
+ * @zh 按类型获取触发器
1367
+ * @en Get triggers by type
1368
+ */
1369
+ getByType(type: TriggerType): IBlueprintTrigger[];
1370
+ /**
1371
+ * @zh 清除所有触发器
1372
+ * @en Clear all triggers
1373
+ */
1374
+ clear(): void;
1375
+ /**
1376
+ * @zh 获取触发器数量
1377
+ * @en Get trigger count
1378
+ */
1379
+ get count(): number;
1380
+ }
1381
+ /**
1382
+ * @zh 创建触发器
1383
+ * @en Create trigger
1384
+ */
1385
+ declare function createTrigger(config: TriggerConfig): BlueprintTrigger;
1386
+ /**
1387
+ * @zh 创建 Tick 触发器
1388
+ * @en Create tick trigger
1389
+ */
1390
+ declare function createTickTrigger(callback?: TriggerCallback, options?: {
1391
+ id?: string;
1392
+ condition?: ITriggerCondition;
1393
+ priority?: number;
1394
+ }): BlueprintTrigger;
1395
+ /**
1396
+ * @zh 创建输入触发器
1397
+ * @en Create input trigger
1398
+ */
1399
+ declare function createInputTrigger(callback?: TriggerCallback, options?: {
1400
+ id?: string;
1401
+ condition?: ITriggerCondition;
1402
+ priority?: number;
1403
+ }): BlueprintTrigger;
1404
+ /**
1405
+ * @zh 创建碰撞触发器
1406
+ * @en Create collision trigger
1407
+ */
1408
+ declare function createCollisionTrigger(callback?: TriggerCallback, options?: {
1409
+ id?: string;
1410
+ condition?: ITriggerCondition;
1411
+ priority?: number;
1412
+ }): BlueprintTrigger;
1413
+ /**
1414
+ * @zh 创建消息触发器
1415
+ * @en Create message trigger
1416
+ */
1417
+ declare function createMessageTrigger(callback?: TriggerCallback, options?: {
1418
+ id?: string;
1419
+ condition?: ITriggerCondition;
1420
+ priority?: number;
1421
+ }): BlueprintTrigger;
1422
+ /**
1423
+ * @zh 创建定时器触发器
1424
+ * @en Create timer trigger
1425
+ */
1426
+ declare function createTimerTrigger(callback?: TriggerCallback, options?: {
1427
+ id?: string;
1428
+ condition?: ITriggerCondition;
1429
+ priority?: number;
1430
+ }): BlueprintTrigger;
1431
+ /**
1432
+ * @zh 创建状态进入触发器
1433
+ * @en Create state enter trigger
1434
+ */
1435
+ declare function createStateEnterTrigger(callback?: TriggerCallback, options?: {
1436
+ id?: string;
1437
+ condition?: ITriggerCondition;
1438
+ priority?: number;
1439
+ }): BlueprintTrigger;
1440
+ /**
1441
+ * @zh 创建状态退出触发器
1442
+ * @en Create state exit trigger
1443
+ */
1444
+ declare function createStateExitTrigger(callback?: TriggerCallback, options?: {
1445
+ id?: string;
1446
+ condition?: ITriggerCondition;
1447
+ priority?: number;
1448
+ }): BlueprintTrigger;
1449
+ /**
1450
+ * @zh 创建自定义触发器
1451
+ * @en Create custom trigger
1452
+ */
1453
+ declare function createCustomTrigger(callback?: TriggerCallback, options?: {
1454
+ id?: string;
1455
+ condition?: ITriggerCondition;
1456
+ priority?: number;
1457
+ }): BlueprintTrigger;
1458
+
1459
+ /**
1460
+ * @zh 触发器调度器
1461
+ * @en Trigger Dispatcher
1462
+ *
1463
+ * @zh 负责分发触发器事件到订阅者
1464
+ * @en Responsible for dispatching trigger events to subscribers
1465
+ */
1466
+
1467
+ /**
1468
+ * @zh 触发结果
1469
+ * @en Trigger result
1470
+ */
1471
+ interface TriggerResult {
1472
+ /**
1473
+ * @zh 触发器 ID
1474
+ * @en Trigger ID
1475
+ */
1476
+ triggerId: string;
1477
+ /**
1478
+ * @zh 是否成功
1479
+ * @en Is successful
1480
+ */
1481
+ success: boolean;
1482
+ /**
1483
+ * @zh 错误信息
1484
+ * @en Error message
1485
+ */
1486
+ error?: string;
1487
+ }
1488
+ /**
1489
+ * @zh 调度结果
1490
+ * @en Dispatch result
1491
+ */
1492
+ interface DispatchResult {
1493
+ /**
1494
+ * @zh 上下文
1495
+ * @en Context
1496
+ */
1497
+ context: ITriggerContext;
1498
+ /**
1499
+ * @zh 触发的触发器数量
1500
+ * @en Number of triggers fired
1501
+ */
1502
+ triggeredCount: number;
1503
+ /**
1504
+ * @zh 各触发器结果
1505
+ * @en Results of each trigger
1506
+ */
1507
+ results: TriggerResult[];
1508
+ }
1509
+ /**
1510
+ * @zh 触发器调度器接口
1511
+ * @en Trigger dispatcher interface
1512
+ */
1513
+ interface ITriggerDispatcher {
1514
+ /**
1515
+ * @zh 调度触发器
1516
+ * @en Dispatch trigger
1517
+ */
1518
+ dispatch(context: ITriggerContext): DispatchResult;
1519
+ /**
1520
+ * @zh 异步调度触发器
1521
+ * @en Async dispatch trigger
1522
+ */
1523
+ dispatchAsync(context: ITriggerContext): Promise<DispatchResult>;
1524
+ /**
1525
+ * @zh 订阅触发器类型
1526
+ * @en Subscribe to trigger type
1527
+ */
1528
+ subscribe(type: TriggerType, callback: TriggerCallback): () => void;
1529
+ /**
1530
+ * @zh 取消订阅
1531
+ * @en Unsubscribe
1532
+ */
1533
+ unsubscribe(type: TriggerType, callback: TriggerCallback): void;
1534
+ /**
1535
+ * @zh 获取注册表
1536
+ * @en Get registry
1537
+ */
1538
+ readonly registry: ITriggerRegistry;
1539
+ }
1540
+ /**
1541
+ * @zh 触发器调度器实现
1542
+ * @en Trigger dispatcher implementation
1543
+ */
1544
+ declare class TriggerDispatcher implements ITriggerDispatcher {
1545
+ private readonly _registry;
1546
+ private readonly _typeSubscribers;
1547
+ private readonly _globalSubscribers;
1548
+ private _isDispatching;
1549
+ private _pendingContexts;
1550
+ constructor(registry?: ITriggerRegistry);
1551
+ get registry(): ITriggerRegistry;
1552
+ /**
1553
+ * @zh 调度触发器
1554
+ * @en Dispatch trigger
1555
+ */
1556
+ dispatch(context: ITriggerContext): DispatchResult;
1557
+ /**
1558
+ * @zh 执行调度
1559
+ * @en Do dispatch
1560
+ */
1561
+ private _doDispatch;
1562
+ /**
1563
+ * @zh 通知订阅者
1564
+ * @en Notify subscribers
1565
+ */
1566
+ private _notifySubscribers;
1567
+ /**
1568
+ * @zh 异步调度触发器
1569
+ * @en Async dispatch trigger
1570
+ */
1571
+ dispatchAsync(context: ITriggerContext): Promise<DispatchResult>;
1572
+ /**
1573
+ * @zh 订阅触发器类型
1574
+ * @en Subscribe to trigger type
1575
+ */
1576
+ subscribe(type: TriggerType, callback: TriggerCallback): () => void;
1577
+ /**
1578
+ * @zh 取消订阅
1579
+ * @en Unsubscribe
1580
+ */
1581
+ unsubscribe(type: TriggerType, callback: TriggerCallback): void;
1582
+ /**
1583
+ * @zh 订阅所有触发器
1584
+ * @en Subscribe to all triggers
1585
+ */
1586
+ subscribeAll(callback: TriggerCallback): () => void;
1587
+ /**
1588
+ * @zh 取消订阅所有
1589
+ * @en Unsubscribe from all
1590
+ */
1591
+ unsubscribeAll(callback: TriggerCallback): void;
1592
+ /**
1593
+ * @zh 清除所有订阅
1594
+ * @en Clear all subscriptions
1595
+ */
1596
+ clearSubscriptions(): void;
1597
+ }
1598
+ /**
1599
+ * @zh 实体触发器管理器接口
1600
+ * @en Entity trigger manager interface
1601
+ */
1602
+ interface IEntityTriggerManager {
1603
+ /**
1604
+ * @zh 为实体注册触发器
1605
+ * @en Register trigger for entity
1606
+ */
1607
+ registerForEntity(entityId: string, trigger: IBlueprintTrigger): void;
1608
+ /**
1609
+ * @zh 注销实体的触发器
1610
+ * @en Unregister trigger from entity
1611
+ */
1612
+ unregisterFromEntity(entityId: string, triggerId: string): boolean;
1613
+ /**
1614
+ * @zh 获取实体的所有触发器
1615
+ * @en Get all triggers for entity
1616
+ */
1617
+ getEntityTriggers(entityId: string): IBlueprintTrigger[];
1618
+ /**
1619
+ * @zh 清除实体的所有触发器
1620
+ * @en Clear all triggers for entity
1621
+ */
1622
+ clearEntityTriggers(entityId: string): void;
1623
+ /**
1624
+ * @zh 调度器
1625
+ * @en Dispatcher
1626
+ */
1627
+ readonly dispatcher: ITriggerDispatcher;
1628
+ }
1629
+ /**
1630
+ * @zh 实体触发器管理器实现
1631
+ * @en Entity trigger manager implementation
1632
+ */
1633
+ declare class EntityTriggerManager implements IEntityTriggerManager {
1634
+ private readonly _dispatcher;
1635
+ private readonly _entityTriggers;
1636
+ constructor(dispatcher?: ITriggerDispatcher);
1637
+ get dispatcher(): ITriggerDispatcher;
1638
+ /**
1639
+ * @zh 为实体注册触发器
1640
+ * @en Register trigger for entity
1641
+ */
1642
+ registerForEntity(entityId: string, trigger: IBlueprintTrigger): void;
1643
+ /**
1644
+ * @zh 注销实体的触发器
1645
+ * @en Unregister trigger from entity
1646
+ */
1647
+ unregisterFromEntity(entityId: string, triggerId: string): boolean;
1648
+ /**
1649
+ * @zh 获取实体的所有触发器
1650
+ * @en Get all triggers for entity
1651
+ */
1652
+ getEntityTriggers(entityId: string): IBlueprintTrigger[];
1653
+ /**
1654
+ * @zh 清除实体的所有触发器
1655
+ * @en Clear all triggers for entity
1656
+ */
1657
+ clearEntityTriggers(entityId: string): void;
1658
+ /**
1659
+ * @zh 调度触发器到实体
1660
+ * @en Dispatch trigger to entity
1661
+ */
1662
+ dispatchToEntity(entityId: string, context: ITriggerContext): DispatchResult;
1663
+ }
1664
+ /**
1665
+ * @zh 创建触发器调度器
1666
+ * @en Create trigger dispatcher
1667
+ */
1668
+ declare function createTriggerDispatcher(registry?: ITriggerRegistry): TriggerDispatcher;
1669
+ /**
1670
+ * @zh 创建实体触发器管理器
1671
+ * @en Create entity trigger manager
1672
+ */
1673
+ declare function createEntityTriggerManager(dispatcher?: ITriggerDispatcher): EntityTriggerManager;
1674
+
1675
+ /**
1676
+ * @zh 蓝图片段接口和实现
1677
+ * @en Blueprint Fragment Interface and Implementation
1678
+ *
1679
+ * @zh 定义可重用的蓝图片段,用于组合系统
1680
+ * @en Defines reusable blueprint fragments for the composition system
1681
+ */
1682
+
1683
+ /**
1684
+ * @zh 暴露引脚定义
1685
+ * @en Exposed pin definition
1686
+ *
1687
+ * @zh 片段对外暴露的引脚,可与其他片段连接
1688
+ * @en Pins exposed by the fragment that can be connected to other fragments
1689
+ */
1690
+ interface ExposedPin {
1691
+ /**
1692
+ * @zh 引脚名称
1693
+ * @en Pin name
1694
+ */
1695
+ readonly name: string;
1696
+ /**
1697
+ * @zh 显示名称
1698
+ * @en Display name
1699
+ */
1700
+ readonly displayName: string;
1701
+ /**
1702
+ * @zh 引脚类型
1703
+ * @en Pin type
1704
+ */
1705
+ readonly type: BlueprintPinType;
1706
+ /**
1707
+ * @zh 引脚方向
1708
+ * @en Pin direction
1709
+ */
1710
+ readonly direction: 'input' | 'output';
1711
+ /**
1712
+ * @zh 描述
1713
+ * @en Description
1714
+ */
1715
+ readonly description?: string;
1716
+ /**
1717
+ * @zh 默认值(仅输入引脚)
1718
+ * @en Default value (input pins only)
1719
+ */
1720
+ readonly defaultValue?: unknown;
1721
+ /**
1722
+ * @zh 关联的内部节点 ID
1723
+ * @en Associated internal node ID
1724
+ */
1725
+ readonly internalNodeId: string;
1726
+ /**
1727
+ * @zh 关联的内部引脚名称
1728
+ * @en Associated internal pin name
1729
+ */
1730
+ readonly internalPinName: string;
1731
+ }
1732
+ /**
1733
+ * @zh 蓝图片段接口
1734
+ * @en Blueprint fragment interface
1735
+ *
1736
+ * @zh 代表一个可重用的蓝图逻辑单元,如技能、卡牌效果等
1737
+ * @en Represents a reusable unit of blueprint logic, such as skills, card effects, etc.
1738
+ */
1739
+ interface IBlueprintFragment {
1740
+ /**
1741
+ * @zh 片段唯一标识
1742
+ * @en Fragment unique identifier
1743
+ */
1744
+ readonly id: string;
1745
+ /**
1746
+ * @zh 片段名称
1747
+ * @en Fragment name
1748
+ */
1749
+ readonly name: string;
1750
+ /**
1751
+ * @zh 片段描述
1752
+ * @en Fragment description
1753
+ */
1754
+ readonly description?: string;
1755
+ /**
1756
+ * @zh 片段分类
1757
+ * @en Fragment category
1758
+ */
1759
+ readonly category?: string;
1760
+ /**
1761
+ * @zh 片段标签
1762
+ * @en Fragment tags
1763
+ */
1764
+ readonly tags?: string[];
1765
+ /**
1766
+ * @zh 暴露的输入引脚
1767
+ * @en Exposed input pins
1768
+ */
1769
+ readonly inputs: ExposedPin[];
1770
+ /**
1771
+ * @zh 暴露的输出引脚
1772
+ * @en Exposed output pins
1773
+ */
1774
+ readonly outputs: ExposedPin[];
1775
+ /**
1776
+ * @zh 内部蓝图图
1777
+ * @en Internal blueprint graph
1778
+ */
1779
+ readonly graph: BlueprintAsset;
1780
+ /**
1781
+ * @zh 片段版本
1782
+ * @en Fragment version
1783
+ */
1784
+ readonly version?: string;
1785
+ /**
1786
+ * @zh 图标名称
1787
+ * @en Icon name
1788
+ */
1789
+ readonly icon?: string;
1790
+ /**
1791
+ * @zh 颜色(用于可视化)
1792
+ * @en Color (for visualization)
1793
+ */
1794
+ readonly color?: string;
1795
+ }
1796
+ /**
1797
+ * @zh 蓝图片段配置
1798
+ * @en Blueprint fragment configuration
1799
+ */
1800
+ interface BlueprintFragmentConfig {
1801
+ id: string;
1802
+ name: string;
1803
+ description?: string;
1804
+ category?: string;
1805
+ tags?: string[];
1806
+ inputs?: ExposedPin[];
1807
+ outputs?: ExposedPin[];
1808
+ graph: BlueprintAsset;
1809
+ version?: string;
1810
+ icon?: string;
1811
+ color?: string;
1812
+ }
1813
+ /**
1814
+ * @zh 蓝图片段实现
1815
+ * @en Blueprint fragment implementation
1816
+ */
1817
+ declare class BlueprintFragment implements IBlueprintFragment {
1818
+ readonly id: string;
1819
+ readonly name: string;
1820
+ readonly description?: string;
1821
+ readonly category?: string;
1822
+ readonly tags?: string[];
1823
+ readonly inputs: ExposedPin[];
1824
+ readonly outputs: ExposedPin[];
1825
+ readonly graph: BlueprintAsset;
1826
+ readonly version?: string;
1827
+ readonly icon?: string;
1828
+ readonly color?: string;
1829
+ constructor(config: BlueprintFragmentConfig);
1830
+ /**
1831
+ * @zh 获取所有暴露引脚
1832
+ * @en Get all exposed pins
1833
+ */
1834
+ getAllExposedPins(): ExposedPin[];
1835
+ /**
1836
+ * @zh 通过名称查找输入引脚
1837
+ * @en Find input pin by name
1838
+ */
1839
+ findInput(name: string): ExposedPin | undefined;
1840
+ /**
1841
+ * @zh 通过名称查找输出引脚
1842
+ * @en Find output pin by name
1843
+ */
1844
+ findOutput(name: string): ExposedPin | undefined;
1845
+ }
1846
+ /**
1847
+ * @zh 创建暴露引脚
1848
+ * @en Create exposed pin
1849
+ */
1850
+ declare function createExposedPin(name: string, type: BlueprintPinType, direction: 'input' | 'output', internalNodeId: string, internalPinName: string, options?: {
1851
+ displayName?: string;
1852
+ description?: string;
1853
+ defaultValue?: unknown;
1854
+ }): ExposedPin;
1855
+ /**
1856
+ * @zh 创建蓝图片段
1857
+ * @en Create blueprint fragment
1858
+ */
1859
+ declare function createFragment(config: BlueprintFragmentConfig): IBlueprintFragment;
1860
+ /**
1861
+ * @zh 蓝图片段资产格式
1862
+ * @en Blueprint fragment asset format
1863
+ *
1864
+ * @zh 用于序列化和反序列化片段
1865
+ * @en Used for serializing and deserializing fragments
1866
+ */
1867
+ interface BlueprintFragmentAsset {
1868
+ /**
1869
+ * @zh 格式版本
1870
+ * @en Format version
1871
+ */
1872
+ version: number;
1873
+ /**
1874
+ * @zh 资产类型标识
1875
+ * @en Asset type identifier
1876
+ */
1877
+ type: 'blueprint-fragment';
1878
+ /**
1879
+ * @zh 片段数据
1880
+ * @en Fragment data
1881
+ */
1882
+ fragment: {
1883
+ id: string;
1884
+ name: string;
1885
+ description?: string;
1886
+ category?: string;
1887
+ tags?: string[];
1888
+ inputs: ExposedPin[];
1889
+ outputs: ExposedPin[];
1890
+ version?: string;
1891
+ icon?: string;
1892
+ color?: string;
1893
+ };
1894
+ /**
1895
+ * @zh 内部蓝图图
1896
+ * @en Internal blueprint graph
1897
+ */
1898
+ graph: BlueprintAsset;
1899
+ }
1900
+ /**
1901
+ * @zh 从资产创建片段
1902
+ * @en Create fragment from asset
1903
+ */
1904
+ declare function fragmentFromAsset(asset: BlueprintFragmentAsset): IBlueprintFragment;
1905
+ /**
1906
+ * @zh 将片段转为资产
1907
+ * @en Convert fragment to asset
1908
+ */
1909
+ declare function fragmentToAsset(fragment: IBlueprintFragment): BlueprintFragmentAsset;
1910
+
1911
+ /**
1912
+ * @zh 蓝图组合器接口和实现
1913
+ * @en Blueprint Composer Interface and Implementation
1914
+ *
1915
+ * @zh 将多个蓝图片段组合成一个完整的蓝图
1916
+ * @en Composes multiple blueprint fragments into a complete blueprint
1917
+ */
1918
+
1919
+ /**
1920
+ * @zh 片段槽位
1921
+ * @en Fragment slot
1922
+ *
1923
+ * @zh 组合器中放置片段的位置
1924
+ * @en A position in the composer where a fragment is placed
1925
+ */
1926
+ interface FragmentSlot {
1927
+ /**
1928
+ * @zh 槽位 ID
1929
+ * @en Slot ID
1930
+ */
1931
+ readonly id: string;
1932
+ /**
1933
+ * @zh 槽位名称
1934
+ * @en Slot name
1935
+ */
1936
+ readonly name: string;
1937
+ /**
1938
+ * @zh 放置的片段
1939
+ * @en Placed fragment
1940
+ */
1941
+ readonly fragment: IBlueprintFragment;
1942
+ /**
1943
+ * @zh 在组合图中的位置偏移
1944
+ * @en Position offset in the composed graph
1945
+ */
1946
+ readonly position: {
1947
+ x: number;
1948
+ y: number;
1949
+ };
1950
+ }
1951
+ /**
1952
+ * @zh 槽位间连接
1953
+ * @en Connection between slots
1954
+ */
1955
+ interface SlotConnection {
1956
+ /**
1957
+ * @zh 连接 ID
1958
+ * @en Connection ID
1959
+ */
1960
+ readonly id: string;
1961
+ /**
1962
+ * @zh 源槽位 ID
1963
+ * @en Source slot ID
1964
+ */
1965
+ readonly fromSlotId: string;
1966
+ /**
1967
+ * @zh 源引脚名称
1968
+ * @en Source pin name
1969
+ */
1970
+ readonly fromPin: string;
1971
+ /**
1972
+ * @zh 目标槽位 ID
1973
+ * @en Target slot ID
1974
+ */
1975
+ readonly toSlotId: string;
1976
+ /**
1977
+ * @zh 目标引脚名称
1978
+ * @en Target pin name
1979
+ */
1980
+ readonly toPin: string;
1981
+ }
1982
+ /**
1983
+ * @zh 蓝图组合器接口
1984
+ * @en Blueprint composer interface
1985
+ *
1986
+ * @zh 用于将多个蓝图片段组合成一个完整蓝图
1987
+ * @en Used to compose multiple blueprint fragments into a complete blueprint
1988
+ */
1989
+ interface IBlueprintComposer {
1990
+ /**
1991
+ * @zh 组合器名称
1992
+ * @en Composer name
1993
+ */
1994
+ readonly name: string;
1995
+ /**
1996
+ * @zh 获取所有槽位
1997
+ * @en Get all slots
1998
+ */
1999
+ getSlots(): FragmentSlot[];
2000
+ /**
2001
+ * @zh 获取所有连接
2002
+ * @en Get all connections
2003
+ */
2004
+ getConnections(): SlotConnection[];
2005
+ /**
2006
+ * @zh 添加片段到槽位
2007
+ * @en Add fragment to slot
2008
+ *
2009
+ * @param fragment - @zh 蓝图片段 @en Blueprint fragment
2010
+ * @param slotId - @zh 槽位 ID @en Slot ID
2011
+ * @param options - @zh 选项 @en Options
2012
+ */
2013
+ addFragment(fragment: IBlueprintFragment, slotId: string, options?: {
2014
+ name?: string;
2015
+ position?: {
2016
+ x: number;
2017
+ y: number;
2018
+ };
2019
+ }): void;
2020
+ /**
2021
+ * @zh 移除槽位
2022
+ * @en Remove slot
2023
+ *
2024
+ * @param slotId - @zh 槽位 ID @en Slot ID
2025
+ */
2026
+ removeSlot(slotId: string): void;
2027
+ /**
2028
+ * @zh 连接两个槽位的引脚
2029
+ * @en Connect pins between two slots
2030
+ *
2031
+ * @param fromSlotId - @zh 源槽位 ID @en Source slot ID
2032
+ * @param fromPin - @zh 源引脚名称 @en Source pin name
2033
+ * @param toSlotId - @zh 目标槽位 ID @en Target slot ID
2034
+ * @param toPin - @zh 目标引脚名称 @en Target pin name
2035
+ */
2036
+ connect(fromSlotId: string, fromPin: string, toSlotId: string, toPin: string): void;
2037
+ /**
2038
+ * @zh 断开连接
2039
+ * @en Disconnect
2040
+ *
2041
+ * @param connectionId - @zh 连接 ID @en Connection ID
2042
+ */
2043
+ disconnect(connectionId: string): void;
2044
+ /**
2045
+ * @zh 验证组合是否有效
2046
+ * @en Validate if the composition is valid
2047
+ */
2048
+ validate(): CompositionValidationResult;
2049
+ /**
2050
+ * @zh 编译成蓝图资产
2051
+ * @en Compile into blueprint asset
2052
+ */
2053
+ compile(): BlueprintAsset;
2054
+ /**
2055
+ * @zh 清空组合器
2056
+ * @en Clear the composer
2057
+ */
2058
+ clear(): void;
2059
+ }
2060
+ /**
2061
+ * @zh 组合验证结果
2062
+ * @en Composition validation result
2063
+ */
2064
+ interface CompositionValidationResult {
2065
+ /**
2066
+ * @zh 是否有效
2067
+ * @en Whether valid
2068
+ */
2069
+ readonly isValid: boolean;
2070
+ /**
2071
+ * @zh 错误列表
2072
+ * @en Error list
2073
+ */
2074
+ readonly errors: CompositionError[];
2075
+ /**
2076
+ * @zh 警告列表
2077
+ * @en Warning list
2078
+ */
2079
+ readonly warnings: CompositionWarning[];
2080
+ }
2081
+ /**
2082
+ * @zh 组合错误
2083
+ * @en Composition error
2084
+ */
2085
+ interface CompositionError {
2086
+ readonly type: 'missing-connection' | 'type-mismatch' | 'cycle-detected' | 'invalid-slot';
2087
+ readonly message: string;
2088
+ readonly slotId?: string;
2089
+ readonly pinName?: string;
2090
+ }
2091
+ /**
2092
+ * @zh 组合警告
2093
+ * @en Composition warning
2094
+ */
2095
+ interface CompositionWarning {
2096
+ readonly type: 'unused-output' | 'unconnected-input';
2097
+ readonly message: string;
2098
+ readonly slotId?: string;
2099
+ readonly pinName?: string;
2100
+ }
2101
+ /**
2102
+ * @zh 蓝图组合器实现
2103
+ * @en Blueprint composer implementation
2104
+ */
2105
+ declare class BlueprintComposer implements IBlueprintComposer {
2106
+ readonly name: string;
2107
+ private slots;
2108
+ private connections;
2109
+ private connectionIdCounter;
2110
+ constructor(name: string);
2111
+ getSlots(): FragmentSlot[];
2112
+ getConnections(): SlotConnection[];
2113
+ addFragment(fragment: IBlueprintFragment, slotId: string, options?: {
2114
+ name?: string;
2115
+ position?: {
2116
+ x: number;
2117
+ y: number;
2118
+ };
2119
+ }): void;
2120
+ removeSlot(slotId: string): void;
2121
+ connect(fromSlotId: string, fromPin: string, toSlotId: string, toPin: string): void;
2122
+ disconnect(connectionId: string): void;
2123
+ validate(): CompositionValidationResult;
2124
+ compile(): BlueprintAsset;
2125
+ clear(): void;
2126
+ }
2127
+ /**
2128
+ * @zh 创建蓝图组合器
2129
+ * @en Create blueprint composer
2130
+ */
2131
+ declare function createComposer(name: string): IBlueprintComposer;
2132
+ /**
2133
+ * @zh 蓝图组合资产格式
2134
+ * @en Blueprint composition asset format
2135
+ */
2136
+ interface BlueprintCompositionAsset {
2137
+ /**
2138
+ * @zh 格式版本
2139
+ * @en Format version
2140
+ */
2141
+ version: number;
2142
+ /**
2143
+ * @zh 资产类型标识
2144
+ * @en Asset type identifier
2145
+ */
2146
+ type: 'blueprint-composition';
2147
+ /**
2148
+ * @zh 组合名称
2149
+ * @en Composition name
2150
+ */
2151
+ name: string;
2152
+ /**
2153
+ * @zh 槽位数据
2154
+ * @en Slot data
2155
+ */
2156
+ slots: Array<{
2157
+ id: string;
2158
+ name: string;
2159
+ fragmentId: string;
2160
+ position: {
2161
+ x: number;
2162
+ y: number;
2163
+ };
2164
+ }>;
2165
+ /**
2166
+ * @zh 连接数据
2167
+ * @en Connection data
2168
+ */
2169
+ connections: SlotConnection[];
2170
+ }
2171
+
2172
+ /**
2173
+ * @zh 片段注册表
2174
+ * @en Fragment Registry
2175
+ *
2176
+ * @zh 管理和查询蓝图片段
2177
+ * @en Manages and queries blueprint fragments
2178
+ */
2179
+
2180
+ /**
2181
+ * @zh 片段过滤器
2182
+ * @en Fragment filter
2183
+ */
2184
+ interface FragmentFilter {
2185
+ /**
2186
+ * @zh 按分类过滤
2187
+ * @en Filter by category
2188
+ */
2189
+ category?: string;
2190
+ /**
2191
+ * @zh 按标签过滤(任意匹配)
2192
+ * @en Filter by tags (any match)
2193
+ */
2194
+ tags?: string[];
2195
+ /**
2196
+ * @zh 按名称搜索
2197
+ * @en Search by name
2198
+ */
2199
+ search?: string;
2200
+ }
2201
+ /**
2202
+ * @zh 片段注册表接口
2203
+ * @en Fragment registry interface
2204
+ */
2205
+ interface IFragmentRegistry {
2206
+ /**
2207
+ * @zh 注册片段
2208
+ * @en Register fragment
2209
+ */
2210
+ register(fragment: IBlueprintFragment): void;
2211
+ /**
2212
+ * @zh 注销片段
2213
+ * @en Unregister fragment
2214
+ */
2215
+ unregister(id: string): void;
2216
+ /**
2217
+ * @zh 获取片段
2218
+ * @en Get fragment
2219
+ */
2220
+ get(id: string): IBlueprintFragment | undefined;
2221
+ /**
2222
+ * @zh 检查片段是否存在
2223
+ * @en Check if fragment exists
2224
+ */
2225
+ has(id: string): boolean;
2226
+ /**
2227
+ * @zh 获取所有片段
2228
+ * @en Get all fragments
2229
+ */
2230
+ getAll(): IBlueprintFragment[];
2231
+ /**
2232
+ * @zh 按条件过滤片段
2233
+ * @en Filter fragments by criteria
2234
+ */
2235
+ filter(filter: FragmentFilter): IBlueprintFragment[];
2236
+ /**
2237
+ * @zh 获取所有分类
2238
+ * @en Get all categories
2239
+ */
2240
+ getCategories(): string[];
2241
+ /**
2242
+ * @zh 获取所有标签
2243
+ * @en Get all tags
2244
+ */
2245
+ getTags(): string[];
2246
+ /**
2247
+ * @zh 清空注册表
2248
+ * @en Clear registry
2249
+ */
2250
+ clear(): void;
2251
+ }
2252
+ /**
2253
+ * @zh 片段注册表实现
2254
+ * @en Fragment registry implementation
2255
+ */
2256
+ declare class FragmentRegistry implements IFragmentRegistry {
2257
+ private fragments;
2258
+ register(fragment: IBlueprintFragment): void;
2259
+ unregister(id: string): void;
2260
+ get(id: string): IBlueprintFragment | undefined;
2261
+ has(id: string): boolean;
2262
+ getAll(): IBlueprintFragment[];
2263
+ filter(filter: FragmentFilter): IBlueprintFragment[];
2264
+ getCategories(): string[];
2265
+ getTags(): string[];
2266
+ clear(): void;
2267
+ /**
2268
+ * @zh 获取片段数量
2269
+ * @en Get fragment count
2270
+ */
2271
+ get size(): number;
2272
+ }
2273
+ /**
2274
+ * @zh 默认片段注册表实例
2275
+ * @en Default fragment registry instance
2276
+ */
2277
+ declare const defaultFragmentRegistry: FragmentRegistry;
2278
+ /**
2279
+ * @zh 创建片段注册表
2280
+ * @en Create fragment registry
2281
+ */
2282
+ declare function createFragmentRegistry(): IFragmentRegistry;
2283
+
2284
+ /**
2285
+ * Blueprint Plugin for ES Engine.
2286
+ * ES引擎的蓝图插件。
2287
+ *
2288
+ * Provides visual scripting runtime support.
2289
+ * 提供可视化脚本运行时支持。
2290
+ */
2291
+
2292
+ /**
2293
+ * Blueprint Plugin.
2294
+ * 蓝图插件。
2295
+ */
2296
+ declare const BlueprintPlugin: IRuntimePlugin;
2297
+
2298
+ 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, BlueprintPlugin, 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 };