@esengine/ecs-framework 2.1.47 → 2.1.49

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @esengine/ecs-framework v2.1.47
2
+ * @esengine/ecs-framework v2.1.49
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -557,7 +557,10 @@ interface IComponent {
557
557
  onEnabled(): void;
558
558
  /** 组件禁用时的回调 */
559
559
  onDisabled(): void;
560
- /** 更新组件 */
560
+ /**
561
+ * 更新组件
562
+ * @deprecated 不符合ECS架构规范,建议使用EntitySystem来处理更新逻辑
563
+ */
561
564
  update(): void;
562
565
  }
563
566
  /**
@@ -1053,6 +1056,8 @@ declare abstract class Component implements IComponent {
1053
1056
  * 更新顺序
1054
1057
  *
1055
1058
  * 决定组件在更新循环中的执行顺序。
1059
+ *
1060
+ * @see EntitySystem
1056
1061
  */
1057
1062
  private _updateOrder;
1058
1063
  /**
@@ -1066,6 +1071,7 @@ declare abstract class Component implements IComponent {
1066
1071
  *
1067
1072
  * 组件的实际启用状态取决于自身状态和所属实体的状态。
1068
1073
  *
1074
+ * @deprecated 不符合ECS架构规范,建议自己实现DisabledComponent标记组件替代
1069
1075
  * @returns 如果组件和所属实体都启用则返回true
1070
1076
  */
1071
1077
  get enabled(): boolean;
@@ -1074,18 +1080,23 @@ declare abstract class Component implements IComponent {
1074
1080
  *
1075
1081
  * 当状态改变时会触发相应的生命周期回调。
1076
1082
  *
1083
+ * @deprecated 不符合ECS架构规范,建议自己实现DisabledComponent标记组件替代
1077
1084
  * @param value - 新的启用状态
1078
1085
  */
1079
1086
  set enabled(value: boolean);
1080
1087
  /**
1081
1088
  * 获取更新顺序
1082
1089
  *
1090
+ * @deprecated 不符合ECS架构规范,更新顺序应该由EntitySystem管理
1091
+ * @see EntitySystem
1083
1092
  * @returns 组件的更新顺序值
1084
1093
  */
1085
1094
  get updateOrder(): number;
1086
1095
  /**
1087
1096
  * 设置更新顺序
1088
1097
  *
1098
+ * @deprecated 不符合ECS架构规范,更新顺序应该由EntitySystem管理
1099
+ * @see EntitySystem
1089
1100
  * @param value - 新的更新顺序值
1090
1101
  */
1091
1102
  set updateOrder(value: number);
@@ -1116,8 +1127,7 @@ declare abstract class Component implements IComponent {
1116
1127
  /**
1117
1128
  * 更新组件
1118
1129
  *
1119
- * 每帧调用,用于更新组件的逻辑。
1120
- * 子类应该重写此方法来实现具体的更新逻辑。
1130
+ * @deprecated 不符合ECS架构规范,建议使用EntitySystem来处理更新逻辑
1121
1131
  */
1122
1132
  update(): void;
1123
1133
  }
@@ -1483,6 +1493,7 @@ declare class LoggerManager {
1483
1493
  private static _instance;
1484
1494
  private _loggers;
1485
1495
  private _defaultLogger;
1496
+ private _defaultLevel;
1486
1497
  private constructor();
1487
1498
  /**
1488
1499
  * 获取日志管理器实例
@@ -1827,14 +1838,16 @@ declare class EventBus implements IEventBus {
1827
1838
  * 发射事件
1828
1839
  * @param eventType 事件类型
1829
1840
  * @param data 事件数据
1841
+ * @param enhance 是否增强事件数据(添加timestamp、eventId等),默认false提升性能
1830
1842
  */
1831
- emit<T>(eventType: string, data: T): void;
1843
+ emit<T>(eventType: string, data: T, enhance?: boolean): void;
1832
1844
  /**
1833
1845
  * 异步发射事件
1834
1846
  * @param eventType 事件类型
1835
1847
  * @param data 事件数据
1848
+ * @param enhance 是否增强事件数据(添加timestamp、eventId等),默认false提升性能
1836
1849
  */
1837
- emitAsync<T>(eventType: string, data: T): Promise<void>;
1850
+ emitAsync<T>(eventType: string, data: T, enhance?: boolean): Promise<void>;
1838
1851
  /**
1839
1852
  * 监听事件
1840
1853
  * @param eventType 事件类型
@@ -1986,7 +1999,7 @@ declare class EventBus implements IEventBus {
1986
1999
  */
1987
2000
  onPerformanceWarning(handler: (data: IPerformanceEventData) => void, config?: IEventListenerConfig): string;
1988
2001
  /**
1989
- * 验证事件类型
2002
+ * 验证事件类型(仅在debug模式下执行,提升性能)
1990
2003
  * @param eventType 事件类型
1991
2004
  */
1992
2005
  private validateEventType;
@@ -2042,8 +2055,13 @@ declare class EntityList {
2042
2055
  private _entitiesToAdd;
2043
2056
  private _entitiesToRemove;
2044
2057
  private _isUpdating;
2058
+ private _enableEntityDirectUpdate;
2045
2059
  get count(): number;
2046
2060
  constructor(scene: any);
2061
+ /**
2062
+ * 设置是否启用实体直接更新
2063
+ */
2064
+ setEnableEntityDirectUpdate(enabled: boolean): void;
2047
2065
  /**
2048
2066
  * 添加实体(立即添加或延迟添加)
2049
2067
  * @param entity 要添加的实体
@@ -2073,7 +2091,7 @@ declare class EntityList {
2073
2091
  */
2074
2092
  updateLists(): void;
2075
2093
  /**
2076
- * 更新所有实体
2094
+ * 更新实体列表和实体
2077
2095
  */
2078
2096
  update(): void;
2079
2097
  /**
@@ -2105,7 +2123,7 @@ declare class EntityList {
2105
2123
  * @param componentType 组件类型
2106
2124
  * @returns 找到的所有实体数组
2107
2125
  */
2108
- findEntitiesWithComponent<T extends Component>(componentType: new (...args: unknown[]) => T): Entity[];
2126
+ findEntitiesWithComponent<T extends Component>(componentType: new (...args: any[]) => T): Entity[];
2109
2127
  /**
2110
2128
  * 批量操作:对所有实体执行指定操作
2111
2129
  * @param action 要执行的操作
@@ -2200,7 +2218,7 @@ declare class Matcher {
2200
2218
  */
2201
2219
  static complex(): Matcher;
2202
2220
  /**
2203
- * 创建空匙配器(向后兼容)
2221
+ * 创建空匙配器
2204
2222
  */
2205
2223
  static empty(): Matcher;
2206
2224
  /**
@@ -2499,90 +2517,12 @@ interface Archetype {
2499
2517
  /** 最后更新时间 */
2500
2518
  updatedAt: number;
2501
2519
  }
2502
- /**
2503
- * 原型查询结果
2504
- */
2505
- interface ArchetypeQueryResult {
2506
- /** 匹配的原型列表 */
2507
- archetypes: Archetype[];
2508
- /** 所有匹配实体的总数 */
2509
- totalEntities: number;
2510
- /** 查询执行时间(毫秒) */
2511
- executionTime: number;
2512
- /** 是否使用了缓存 */
2513
- fromCache: boolean;
2514
- }
2515
- /**
2516
- * Archetype系统
2517
- *
2518
- * 根据实体的组件组合将实体分组到不同的原型中,提供高效的查询性能。
2519
- */
2520
- declare class ArchetypeSystem {
2521
- /** 所有原型的映射表 */
2522
- private _archetypes;
2523
- /** 实体到原型的映射 */
2524
- private _entityToArchetype;
2525
- /** 组件类型到原型的映射 */
2526
- private _componentToArchetypes;
2527
- /** 查询缓存 */
2528
- private _queryCache;
2529
- private _cacheTimeout;
2530
- private _maxCacheSize;
2531
- /**
2532
- * 添加实体到原型系统
2533
- */
2534
- addEntity(entity: Entity): void;
2535
- /**
2536
- * 从原型系统中移除实体
2537
- */
2538
- removeEntity(entity: Entity): void;
2539
- /**
2540
- * 查询包含指定组件组合的原型
2541
- */
2542
- queryArchetypes(componentTypes: ComponentType[], operation?: 'AND' | 'OR'): ArchetypeQueryResult;
2543
- /**
2544
- * 获取实体所属的原型
2545
- */
2546
- getEntityArchetype(entity: Entity): Archetype | undefined;
2547
- /**
2548
- * 获取所有原型
2549
- */
2550
- getAllArchetypes(): Archetype[];
2551
- /**
2552
- * 清空所有数据
2553
- */
2554
- clear(): void;
2555
- /**
2556
- * 获取实体的组件类型列表
2557
- */
2558
- private getEntityComponentTypes;
2559
- /**
2560
- * 生成原型ID
2561
- */
2562
- private generateArchetypeId;
2563
- /**
2564
- * 创建新原型
2565
- */
2566
- private createArchetype;
2567
- /**
2568
- * 检查原型是否包含所有指定组件
2569
- */
2570
- private archetypeContainsAllComponents;
2571
- /**
2572
- * 更新组件索引
2573
- */
2574
- private updateComponentIndexes;
2575
- /**
2576
- * 使查询缓存失效
2577
- */
2578
- private invalidateQueryCache;
2579
- }
2580
2520
 
2581
2521
  /**
2582
2522
  * 实体查询结果接口
2583
2523
  */
2584
2524
  interface QueryResult {
2585
- entities: Entity[];
2525
+ entities: readonly Entity[];
2586
2526
  count: number;
2587
2527
  /** 查询执行时间(毫秒) */
2588
2528
  executionTime: number;
@@ -2614,15 +2554,15 @@ declare class QuerySystem {
2614
2554
  private _logger;
2615
2555
  private entities;
2616
2556
  private entityIndex;
2617
- private indexDirty;
2618
2557
  private _version;
2619
2558
  private queryCache;
2620
2559
  private cacheMaxSize;
2621
2560
  private cacheTimeout;
2622
- private componentPoolManager;
2561
+ private componentNameCache;
2562
+ private cacheKeyCache;
2563
+ private componentMaskCache;
2623
2564
  private componentIndexManager;
2624
2565
  private archetypeSystem;
2625
- private dirtyTrackingSystem;
2626
2566
  private queryStats;
2627
2567
  constructor();
2628
2568
  /**
@@ -2671,9 +2611,13 @@ declare class QuerySystem {
2671
2611
  */
2672
2612
  removeEntity(entity: Entity): void;
2673
2613
  /**
2674
- * 将实体添加到各种索引中(优化版本)
2614
+ * 将实体添加到各种索引中
2675
2615
  */
2676
2616
  private addEntityToIndexes;
2617
+ private createAndSetMaskIndex;
2618
+ private createAndSetComponentIndex;
2619
+ private createAndSetTagIndex;
2620
+ private createAndSetNameIndex;
2677
2621
  /**
2678
2622
  * 从各种索引中移除实体
2679
2623
  */
@@ -2811,37 +2755,20 @@ declare class QuerySystem {
2811
2755
  */
2812
2756
  private clearQueryCache;
2813
2757
  /**
2814
- * 公共方法:清理查询缓存
2815
- *
2816
- * 用于外部调用清理缓存,通常在批量操作后使用。
2758
+ * 高效的缓存键生成
2817
2759
  */
2818
- clearCache(): void;
2760
+ private generateCacheKey;
2819
2761
  /**
2820
- * 批量更新实体组件
2821
- *
2822
- * 对大量实体进行批量组件更新操作。
2823
- *
2824
- * @param updates 更新操作列表,包含实体ID和新的组件掩码
2762
+ * 清理查询缓存
2825
2763
  *
2826
- * @example
2827
- * ```typescript
2828
- * // 批量更新实体的组件配置
2829
- * const updates = [
2830
- * { entityId: 1, componentMask: BigInt(0b1011) },
2831
- * { entityId: 2, componentMask: BigInt(0b1101) }
2832
- * ];
2833
- * querySystem.batchUpdateComponents(updates);
2834
- * ```
2764
+ * 用于外部调用清理缓存,通常在批量操作后使用。
2835
2765
  */
2836
- batchUpdateComponents(updates: Array<{
2837
- entityId: number;
2838
- componentMask: bigint;
2839
- }>): void;
2766
+ clearCache(): void;
2840
2767
  /**
2841
2768
  * 创建组件掩码
2842
2769
  *
2843
2770
  * 根据组件类型列表生成对应的位掩码。
2844
- * 使用位掩码优化器进行缓存和预计算。
2771
+ * 使用缓存避免重复计算。
2845
2772
  *
2846
2773
  * @param componentTypes 组件类型列表
2847
2774
  * @returns 生成的位掩码
@@ -2854,7 +2781,7 @@ declare class QuerySystem {
2854
2781
  /**
2855
2782
  * 获取所有实体
2856
2783
  */
2857
- getAllEntities(): Entity[];
2784
+ getAllEntities(): readonly Entity[];
2858
2785
  /**
2859
2786
  * 获取系统统计信息
2860
2787
  *
@@ -2883,39 +2810,12 @@ declare class QuerySystem {
2883
2810
  optimizationStats: {
2884
2811
  componentIndex: any;
2885
2812
  archetypeSystem: any;
2886
- dirtyTracking: any;
2887
2813
  };
2888
2814
  cacheStats: {
2889
2815
  size: number;
2890
2816
  hitRate: string;
2891
2817
  };
2892
2818
  };
2893
- /**
2894
- * 配置脏标记系统
2895
- *
2896
- * @param batchSize 批处理大小
2897
- * @param maxProcessingTime 最大处理时间
2898
- */
2899
- configureDirtyTracking(batchSize: number, maxProcessingTime: number): void;
2900
- /**
2901
- * 手动触发性能优化
2902
- */
2903
- optimizePerformance(): void;
2904
- /**
2905
- * 开始新的帧
2906
- */
2907
- beginFrame(): void;
2908
- /**
2909
- * 结束当前帧
2910
- */
2911
- endFrame(): void;
2912
- /**
2913
- * 标记实体组件已修改(用于脏标记追踪)
2914
- *
2915
- * @param entity 修改的实体
2916
- * @param componentTypes 修改的组件类型
2917
- */
2918
- markEntityDirty(entity: Entity, componentTypes: ComponentType[]): void;
2919
2819
  /**
2920
2820
  * 获取实体所属的原型信息
2921
2821
  *
@@ -3298,7 +3198,7 @@ declare class Scene implements IScene {
3298
3198
  */
3299
3199
  end(): void;
3300
3200
  /**
3301
- * 更新场景,更新实体组件、实体处理器等
3201
+ * 更新场景
3302
3202
  */
3303
3203
  update(): void;
3304
3204
  /**
@@ -3306,6 +3206,11 @@ declare class Scene implements IScene {
3306
3206
  * @param name 实体名称
3307
3207
  */
3308
3208
  createEntity(name: string): Entity;
3209
+ /**
3210
+ * 清除所有EntitySystem的实体缓存
3211
+ * 当实体或组件发生变化时调用
3212
+ */
3213
+ clearSystemEntityCaches(): void;
3309
3214
  /**
3310
3215
  * 在场景的实体列表中添加一个实体
3311
3216
  * @param entity 要添加的实体
@@ -3363,6 +3268,11 @@ declare class Scene implements IScene {
3363
3268
  * @param processor 要删除的处理器
3364
3269
  */
3365
3270
  removeEntityProcessor(processor: EntitySystem): void;
3271
+ /**
3272
+ * 从场景中删除系统(removeEntityProcessor的别名)
3273
+ * @param system 系统
3274
+ */
3275
+ removeSystem(system: EntitySystem): void;
3366
3276
  /**
3367
3277
  * 获取指定类型的EntitySystem处理器
3368
3278
  * @param type 处理器类型
@@ -3412,7 +3322,7 @@ declare class Scene implements IScene {
3412
3322
  * super(Transform, Velocity);
3413
3323
  * }
3414
3324
  *
3415
- * protected process(entities: Entity[]): void {
3325
+ * protected process(entities: readonly Entity[]): void {
3416
3326
  * for (const entity of entities) {
3417
3327
  * const transform = entity.getComponent(Transform);
3418
3328
  * const velocity = entity.getComponent(Velocity);
@@ -3429,9 +3339,20 @@ declare abstract class EntitySystem implements ISystemBase {
3429
3339
  private _systemName;
3430
3340
  private _initialized;
3431
3341
  private _matcher;
3432
- private _trackedEntities;
3342
+ private _eventListeners;
3343
+ private _scene;
3344
+ /**
3345
+ * 实体ID映射缓存
3346
+ */
3347
+ private _entityIdMap;
3348
+ private _entityIdMapVersion;
3349
+ private _entityIdMapSize;
3350
+ /**
3351
+ * 统一的实体缓存管理器
3352
+ */
3353
+ private _entityCache;
3433
3354
  /**
3434
- * 获取系统处理的实体列表(动态查询)
3355
+ * 获取系统处理的实体列表
3435
3356
  */
3436
3357
  get entities(): readonly Entity[];
3437
3358
  /**
@@ -3452,7 +3373,6 @@ declare abstract class EntitySystem implements ISystemBase {
3452
3373
  */
3453
3374
  get systemName(): string;
3454
3375
  constructor(matcher?: Matcher);
3455
- private _scene;
3456
3376
  /**
3457
3377
  * 这个系统所属的场景
3458
3378
  */
@@ -3479,6 +3399,11 @@ declare abstract class EntitySystem implements ISystemBase {
3479
3399
  * 子类可以重写此方法进行初始化操作。
3480
3400
  */
3481
3401
  protected onInitialize(): void;
3402
+ /**
3403
+ * 清除实体缓存(内部使用)
3404
+ * 当Scene中的实体发生变化时调用
3405
+ */
3406
+ clearEntityCache(): void;
3482
3407
  /**
3483
3408
  * 重置系统状态
3484
3409
  *
@@ -3507,20 +3432,22 @@ declare abstract class EntitySystem implements ISystemBase {
3507
3432
  private extractEntityIds;
3508
3433
  /**
3509
3434
  * ID集合交集运算
3510
- *
3511
- * 使用单次扫描算法,选择较小集合进行迭代以提高效率
3512
3435
  */
3513
3436
  private intersectIdSets;
3514
3437
  /**
3515
3438
  * ID集合差集运算
3516
- *
3517
- * 使用单次扫描算法计算setA - setB
3518
3439
  */
3519
3440
  private differenceIdSets;
3441
+ /**
3442
+ * 获取或构建实体ID映射
3443
+ */
3444
+ private getEntityIdMap;
3445
+ /**
3446
+ * 重建实体ID映射
3447
+ */
3448
+ private rebuildEntityIdMap;
3520
3449
  /**
3521
3450
  * 从ID集合构建Entity数组
3522
- *
3523
- * 先构建ID到Entity的映射,然后根据ID集合构建结果数组
3524
3451
  */
3525
3452
  private idSetToEntityArray;
3526
3453
  /**
@@ -3531,14 +3458,10 @@ declare abstract class EntitySystem implements ISystemBase {
3531
3458
  private executeComplexQuery;
3532
3459
  /**
3533
3460
  * 更新系统
3534
- *
3535
- * 在每帧调用,处理系统的主要逻辑。
3536
3461
  */
3537
3462
  update(): void;
3538
3463
  /**
3539
3464
  * 后期更新系统
3540
- *
3541
- * 在所有系统的update方法执行完毕后调用。
3542
3465
  */
3543
3466
  lateUpdate(): void;
3544
3467
  /**
@@ -3554,7 +3477,7 @@ declare abstract class EntitySystem implements ISystemBase {
3554
3477
  *
3555
3478
  * @param entities 要处理的实体列表
3556
3479
  */
3557
- protected process(_entities: Entity[]): void;
3480
+ protected process(entities: readonly Entity[]): void;
3558
3481
  /**
3559
3482
  * 后期处理实体列表
3560
3483
  *
@@ -3562,7 +3485,7 @@ declare abstract class EntitySystem implements ISystemBase {
3562
3485
  *
3563
3486
  * @param entities 要处理的实体列表
3564
3487
  */
3565
- protected lateProcess(_entities: Entity[]): void;
3488
+ protected lateProcess(_entities: readonly Entity[]): void;
3566
3489
  /**
3567
3490
  * 系统处理完毕后调用
3568
3491
  *
@@ -3611,7 +3534,7 @@ declare abstract class EntitySystem implements ISystemBase {
3611
3534
  *
3612
3535
  * @param entity 被添加的实体
3613
3536
  */
3614
- protected onAdded(_entity: Entity): void;
3537
+ protected onAdded(entity: Entity): void;
3615
3538
  /**
3616
3539
  * 当实体从系统中移除时调用
3617
3540
  *
@@ -3619,7 +3542,38 @@ declare abstract class EntitySystem implements ISystemBase {
3619
3542
  *
3620
3543
  * @param entity 被移除的实体
3621
3544
  */
3622
- protected onRemoved(_entity: Entity): void;
3545
+ protected onRemoved(entity: Entity): void;
3546
+ /**
3547
+ * 添加事件监听器
3548
+ *
3549
+ * 推荐使用此方法而不是直接调用eventSystem.on(),
3550
+ * 这样可以确保系统移除时自动清理监听器,避免内存泄漏。
3551
+ *
3552
+ * @param eventType 事件类型
3553
+ * @param handler 事件处理函数
3554
+ * @param config 监听器配置
3555
+ */
3556
+ protected addEventListener<T = any>(eventType: string, handler: EventHandler<T>, config?: EventListenerConfig): void;
3557
+ /**
3558
+ * 移除特定的事件监听器
3559
+ *
3560
+ * @param eventType 事件类型
3561
+ * @param handler 事件处理函数
3562
+ */
3563
+ protected removeEventListener<T = any>(eventType: string, handler: EventHandler<T>): void;
3564
+ /**
3565
+ * 清理所有事件监听器
3566
+ *
3567
+ * 系统移除时自动调用,清理所有通过addEventListener添加的监听器。
3568
+ */
3569
+ private cleanupEventListeners;
3570
+ /**
3571
+ * 系统销毁时的回调
3572
+ *
3573
+ * 当系统从场景中移除时调用,子类可以重写此方法进行清理操作。
3574
+ * 注意:事件监听器会被框架自动清理,无需手动处理。
3575
+ */
3576
+ protected onDestroy(): void;
3623
3577
  }
3624
3578
 
3625
3579
  /**
@@ -3743,6 +3697,10 @@ interface IScene {
3743
3697
  * 创建实体
3744
3698
  */
3745
3699
  createEntity(name: string): Entity;
3700
+ /**
3701
+ * 清除所有EntitySystem的实体缓存
3702
+ */
3703
+ clearSystemEntityCaches(): void;
3746
3704
  /**
3747
3705
  * 添加实体
3748
3706
  */
@@ -3797,6 +3755,11 @@ interface ISceneConfig {
3797
3755
  * 调试配置
3798
3756
  */
3799
3757
  debug?: boolean;
3758
+ /**
3759
+ * 是否启用实体直接更新
3760
+ * @default false
3761
+ */
3762
+ enableEntityDirectUpdate?: boolean;
3800
3763
  }
3801
3764
 
3802
3765
  /**
@@ -4486,11 +4449,11 @@ declare class ECSFluentAPI {
4486
4449
  */
4487
4450
  query(): QueryBuilder;
4488
4451
  /**
4489
- * 查找实体(简化版)
4452
+ * 查找实体
4490
4453
  * @param componentTypes 组件类型
4491
4454
  * @returns 实体数组
4492
4455
  */
4493
- find(...componentTypes: ComponentType[]): Entity[];
4456
+ find(...componentTypes: ComponentType[]): readonly Entity[];
4494
4457
  /**
4495
4458
  * 查找第一个匹配的实体
4496
4459
  * @param componentTypes 组件类型
@@ -5019,8 +4982,16 @@ declare class WorldManager {
5019
4982
  * 实体数据收集器
5020
4983
  */
5021
4984
  declare class EntityDataCollector {
5022
- collectEntityData(): IEntityDebugData;
5023
- getRawEntityList(): Array<{
4985
+ /**
4986
+ * 收集实体数据
4987
+ * @param scene 场景实例
4988
+ */
4989
+ collectEntityData(scene?: IScene | null): IEntityDebugData;
4990
+ /**
4991
+ * 获取原始实体列表
4992
+ * @param scene 场景实例
4993
+ */
4994
+ getRawEntityList(scene?: IScene | null): Array<{
5024
4995
  id: number;
5025
4996
  name: string;
5026
4997
  active: boolean;
@@ -5034,9 +5005,18 @@ declare class EntityDataCollector {
5034
5005
  tag: number;
5035
5006
  updateOrder: number;
5036
5007
  }>;
5037
- getEntityDetails(entityId: number): any;
5008
+ /**
5009
+ * 获取实体详细信息
5010
+ * @param entityId 实体ID
5011
+ * @param scene 场景实例
5012
+ */
5013
+ getEntityDetails(entityId: number, scene?: IScene | null): any;
5038
5014
  private getSceneInfo;
5039
- collectEntityDataWithMemory(): IEntityDebugData;
5015
+ /**
5016
+ * 收集实体数据(包含内存信息)
5017
+ * @param scene 场景实例
5018
+ */
5019
+ collectEntityDataWithMemory(scene?: IScene | null): IEntityDebugData;
5040
5020
  private collectArchetypeData;
5041
5021
  private getArchetypeDistributionFast;
5042
5022
  private getTopEntitiesByComponentsFast;
@@ -5073,8 +5053,11 @@ declare class EntityDataCollector {
5073
5053
  }>;
5074
5054
  /**
5075
5055
  * 获取组件的完整属性信息(仅在需要时调用)
5056
+ * @param entityId 实体ID
5057
+ * @param componentIndex 组件索引
5058
+ * @param scene 场景实例
5076
5059
  */
5077
- getComponentProperties(entityId: number, componentIndex: number): Record<string, any>;
5060
+ getComponentProperties(entityId: number, componentIndex: number, scene?: IScene | null): Record<string, any>;
5078
5061
  /**
5079
5062
  * 格式化属性值
5080
5063
  */
@@ -5097,8 +5080,12 @@ declare class EntityDataCollector {
5097
5080
  private generateObjectId;
5098
5081
  /**
5099
5082
  * 展开懒加载对象(供调试面板调用)
5083
+ * @param entityId 实体ID
5084
+ * @param componentIndex 组件索引
5085
+ * @param propertyPath 属性路径
5086
+ * @param scene 场景实例
5100
5087
  */
5101
- expandLazyObject(entityId: number, componentIndex: number, propertyPath: string): any;
5088
+ expandLazyObject(entityId: number, componentIndex: number, propertyPath: string, scene?: IScene | null): any;
5102
5089
  /**
5103
5090
  * 根据路径获取对象
5104
5091
  */
@@ -5111,8 +5098,10 @@ declare class EntityDataCollector {
5111
5098
  declare class SystemDataCollector {
5112
5099
  /**
5113
5100
  * 收集系统数据
5101
+ * @param performanceMonitor 性能监视器实例
5102
+ * @param scene 场景实例
5114
5103
  */
5115
- collectSystemData(performanceMonitor: any): ISystemDebugData;
5104
+ collectSystemData(performanceMonitor: any, scene?: IScene | null): ISystemDebugData;
5116
5105
  }
5117
5106
 
5118
5107
  /**
@@ -5153,8 +5142,9 @@ declare class ComponentDataCollector {
5153
5142
  private static componentSizeCache;
5154
5143
  /**
5155
5144
  * 收集组件数据(轻量版,不计算实际内存大小)
5145
+ * @param scene 场景实例
5156
5146
  */
5157
- collectComponentData(): IComponentDebugData;
5147
+ collectComponentData(scene?: IScene | null): IComponentDebugData;
5158
5148
  /**
5159
5149
  * 获取组件类型的估算内存大小(基于预设值,不进行实际计算)
5160
5150
  */
@@ -5163,8 +5153,10 @@ declare class ComponentDataCollector {
5163
5153
  /**
5164
5154
  * 为内存快照功能提供的详细内存计算
5165
5155
  * 只在用户主动请求内存快照时调用
5156
+ * @param typeName 组件类型名称
5157
+ * @param scene 场景实例
5166
5158
  */
5167
- calculateDetailedComponentMemory(typeName: string): number;
5159
+ calculateDetailedComponentMemory(typeName: string, scene?: IScene | null): number;
5168
5160
  /**
5169
5161
  * 估算对象内存大小(仅用于内存快照)
5170
5162
  * 优化版本:减少递归深度,提高性能
@@ -5180,8 +5172,9 @@ declare class SceneDataCollector {
5180
5172
  private sceneStartTime;
5181
5173
  /**
5182
5174
  * 收集场景数据
5175
+ * @param scene 场景实例
5183
5176
  */
5184
- collectSceneData(): ISceneDebugData;
5177
+ collectSceneData(scene?: IScene | null): ISceneDebugData;
5185
5178
  /**
5186
5179
  * 设置场景开始时间
5187
5180
  */
@@ -5260,11 +5253,18 @@ declare class DebugManager {
5260
5253
  private performanceCollector;
5261
5254
  private componentCollector;
5262
5255
  private sceneCollector;
5256
+ private sceneProvider;
5257
+ private performanceMonitorProvider;
5263
5258
  private frameCounter;
5264
5259
  private lastSendTime;
5265
5260
  private sendInterval;
5266
5261
  private isRunning;
5267
- constructor(core: Core, config: IECSDebugConfig);
5262
+ /**
5263
+ * 构造调试管理器
5264
+ * @param core Core实例
5265
+ * @param config 调试配置
5266
+ */
5267
+ constructor(core: any, config: IECSDebugConfig);
5268
5268
  /**
5269
5269
  * 启动调试管理器
5270
5270
  */
@@ -6454,669 +6454,6 @@ declare function getComponentInstanceTypeName(component: Component): string;
6454
6454
  */
6455
6455
  declare function getSystemInstanceTypeName(system: EntitySystem): string;
6456
6456
 
6457
- /**
6458
- * 实体查询构建器
6459
- *
6460
- * 提供流式API来构建复杂的实体查询条件。支持组件过滤、标签过滤、状态过滤和自定义条件。
6461
- *
6462
- * @example
6463
- * ```typescript
6464
- * const results = entityManager.query()
6465
- * .withAll(PositionComponent, HealthComponent)
6466
- * .without(VelocityComponent)
6467
- * .withTag(1)
6468
- * .active()
6469
- * .where(entity => entity.name.startsWith("Player"))
6470
- * .execute();
6471
- * ```
6472
- */
6473
- declare class EntityQueryBuilder {
6474
- private entityManager;
6475
- /** 必须包含的组件类型 */
6476
- private _allComponents;
6477
- /** 至少包含一个的组件类型 */
6478
- private _anyComponents;
6479
- /** 不能包含的组件类型 */
6480
- private _withoutComponents;
6481
- /** 必须包含的标签 */
6482
- private _withTags;
6483
- /** 不能包含的标签 */
6484
- private _withoutTags;
6485
- /** 是否只查询激活状态的实体 */
6486
- private _activeOnly;
6487
- /** 是否只查询启用状态的实体 */
6488
- private _enabledOnly;
6489
- /** 自定义过滤条件 */
6490
- private _customPredicates;
6491
- /**
6492
- * 创建查询构建器实例
6493
- * @param entityManager 实体管理器实例
6494
- */
6495
- constructor(entityManager: EntityManager);
6496
- /**
6497
- * 添加必须包含的组件条件
6498
- *
6499
- * 返回的实体必须包含所有指定的组件类型。
6500
- *
6501
- * @param componentTypes 组件类型列表
6502
- * @returns 查询构建器实例,支持链式调用
6503
- */
6504
- withAll(...componentTypes: ComponentType[]): EntityQueryBuilder;
6505
- /**
6506
- * 添加至少包含一个的组件条件
6507
- *
6508
- * 返回的实体必须至少包含其中一个指定的组件类型。
6509
- *
6510
- * @param componentTypes 组件类型列表
6511
- * @returns 查询构建器实例,支持链式调用
6512
- */
6513
- withAny(...componentTypes: ComponentType[]): EntityQueryBuilder;
6514
- /**
6515
- * 添加不能包含的组件条件
6516
- *
6517
- * 返回的实体不能包含任何指定的组件类型。
6518
- *
6519
- * @param componentTypes 组件类型列表
6520
- * @returns 查询构建器实例,支持链式调用
6521
- */
6522
- without(...componentTypes: ComponentType[]): EntityQueryBuilder;
6523
- /**
6524
- * 添加必须包含的标签条件
6525
- *
6526
- * 返回的实体必须具有指定的标签。
6527
- *
6528
- * @param tag 标签值
6529
- * @returns 查询构建器实例,支持链式调用
6530
- */
6531
- withTag(tag: number): EntityQueryBuilder;
6532
- /**
6533
- * 添加不能包含的标签条件
6534
- *
6535
- * 返回的实体不能具有指定的标签。
6536
- *
6537
- * @param tag 标签值
6538
- * @returns 查询构建器实例,支持链式调用
6539
- */
6540
- withoutTag(tag: number): EntityQueryBuilder;
6541
- /**
6542
- * 添加激活状态过滤条件
6543
- *
6544
- * 返回的实体必须处于激活状态(active = true)。
6545
- *
6546
- * @returns 查询构建器实例,支持链式调用
6547
- */
6548
- active(): EntityQueryBuilder;
6549
- /**
6550
- * 添加启用状态过滤条件
6551
- *
6552
- * 返回的实体必须处于启用状态(enabled = true)。
6553
- *
6554
- * @returns 查询构建器实例,支持链式调用
6555
- */
6556
- enabled(): EntityQueryBuilder;
6557
- /**
6558
- * 添加自定义过滤条件
6559
- *
6560
- * 允许用户定义复杂的过滤逻辑。
6561
- *
6562
- * @param predicate 自定义过滤函数,接收实体作为参数,返回布尔值
6563
- * @returns 查询构建器实例,支持链式调用
6564
- *
6565
- * @example
6566
- * ```typescript
6567
- * .where(entity => entity.name.startsWith("Player"))
6568
- * .where(entity => entity.components.length > 5)
6569
- * ```
6570
- */
6571
- where(predicate: (entity: Entity) => boolean): EntityQueryBuilder;
6572
- /**
6573
- * 执行查询并返回所有匹配的实体
6574
- *
6575
- * @returns 符合所有查询条件的实体数组
6576
- */
6577
- execute(): Entity[];
6578
- /**
6579
- * 执行查询并返回第一个匹配的实体
6580
- *
6581
- * @returns 第一个符合查询条件的实体,如果没有找到则返回null
6582
- */
6583
- first(): Entity | null;
6584
- /**
6585
- * 执行查询并返回匹配实体的数量
6586
- *
6587
- * @returns 符合查询条件的实体数量
6588
- */
6589
- count(): number;
6590
- /**
6591
- * 对所有匹配的实体执行指定操作
6592
- *
6593
- * @param action 要执行的操作函数,接收匹配的实体作为参数
6594
- */
6595
- forEach(action: (entity: Entity) => void): void;
6596
- /**
6597
- * 检查实体是否匹配所有查询条件
6598
- *
6599
- * 按优先级顺序检查各种过滤条件,一旦发现不匹配立即返回false。
6600
- *
6601
- * @param entity 要检查的实体
6602
- * @returns 实体是否匹配所有查询条件
6603
- */
6604
- private matchesEntity;
6605
- }
6606
- /**
6607
- * 实体管理器
6608
- *
6609
- * 提供统一的实体管理和查询机制,支持高效的实体操作。
6610
- * 包括实体的创建、销毁、查询和索引管理功能。
6611
- *
6612
- * @example
6613
- * ```typescript
6614
- * const entityManager = new EntityManager();
6615
- *
6616
- * // 创建实体
6617
- * const player = entityManager.createEntity("Player");
6618
- *
6619
- * // 查询实体
6620
- * const playerEntity = entityManager.getEntityByName("Player");
6621
- *
6622
- * // 复杂查询
6623
- * const results = entityManager.query()
6624
- * .withAll(HealthComponent, PositionComponent)
6625
- * .active()
6626
- * .execute();
6627
- * ```
6628
- */
6629
- declare class EntityManager {
6630
- /** 主要实体存储,使用ID作为键 */
6631
- private _entities;
6632
- /** 按名称索引的实体映射 */
6633
- private _entitiesByName;
6634
- /** 按标签索引的实体映射 */
6635
- private _entitiesByTag;
6636
- /** 实体ID分配器 */
6637
- private _identifierPool;
6638
- /** 已销毁实体的ID集合 */
6639
- private _destroyedEntities;
6640
- /** 性能优化系统 */
6641
- private _componentIndexManager;
6642
- private _archetypeSystem;
6643
- private _dirtyTrackingSystem;
6644
- /** 事件总线 */
6645
- private _eventBus;
6646
- /**
6647
- * 创建实体管理器实例
6648
- *
6649
- * 初始化内部数据结构和ID分配器。
6650
- */
6651
- constructor();
6652
- /**
6653
- * 获取实体总数
6654
- *
6655
- * @returns 当前管理的实体总数量
6656
- */
6657
- get entityCount(): number;
6658
- /**
6659
- * 获取激活状态的实体数量
6660
- *
6661
- * 只计算同时满足激活状态且未被销毁的实体。
6662
- *
6663
- * @returns 激活状态的实体数量
6664
- */
6665
- get activeEntityCount(): number;
6666
- /**
6667
- * 创建新实体
6668
- *
6669
- * 分配唯一ID并将实体添加到管理系统中,同时更新相关索引。
6670
- *
6671
- * @param name 实体名称,如果未指定则使用时间戳生成默认名称
6672
- * @returns 创建的实体实例
6673
- *
6674
- * @example
6675
- * ```typescript
6676
- * const player = entityManager.createEntity("Player");
6677
- * const enemy = entityManager.createEntity(); // 使用默认名称
6678
- * ```
6679
- */
6680
- createEntity(name?: string): Entity;
6681
- /**
6682
- * 批量创建实体
6683
- *
6684
- * 为了优化大量实体创建的性能,批量处理索引更新和事件发射。
6685
- * 适用于需要创建大量实体的场景,如子弹、粒子等。
6686
- *
6687
- * @param count 要创建的实体数量
6688
- * @param namePrefix 实体名称前缀,默认为 Entity
6689
- * @param skipEvents 是否跳过事件发射以提升性能,默认为 false
6690
- * @returns 创建的实体数组
6691
- *
6692
- * @example
6693
- * const bullets = entityManager.createEntitiesBatch(100, "Bullet", true);
6694
- * const particles = entityManager.createEntitiesBatch(500, "Particle");
6695
- */
6696
- createEntitiesBatch(count: number, namePrefix?: string, skipEvents?: boolean): Entity[];
6697
- /**
6698
- * 销毁实体
6699
- *
6700
- * 支持通过实体对象、名称或ID来销毁实体。
6701
- * 会清理所有相关索引并回收ID。
6702
- *
6703
- * @param entityOrId 要销毁的实体,可以是实体对象、名称字符串或ID数字
6704
- * @returns 是否成功销毁实体
6705
- *
6706
- * @example
6707
- * ```typescript
6708
- * // 通过实体对象销毁
6709
- * entityManager.destroyEntity(player);
6710
- *
6711
- * // 通过名称销毁
6712
- * entityManager.destroyEntity("Enemy_1");
6713
- *
6714
- * // 通过ID销毁
6715
- * entityManager.destroyEntity(123);
6716
- * ```
6717
- */
6718
- destroyEntity(entityOrId: Entity | string | number): boolean;
6719
- /**
6720
- * 获取所有实体
6721
- *
6722
- * 返回当前管理的所有实体的副本数组。
6723
- *
6724
- * @returns 所有实体的数组
6725
- */
6726
- getAllEntities(): Entity[];
6727
- /**
6728
- * 根据ID获取实体
6729
- *
6730
- * 支持字符串和数字类型的ID。
6731
- *
6732
- * @param id 实体ID,可以是字符串或数字
6733
- * @returns 对应的实体,如果不存在则返回null
6734
- */
6735
- getEntity(id: string | number): Entity | null;
6736
- /**
6737
- * 根据名称获取实体
6738
- *
6739
- * 如果存在多个同名实体,返回第一个找到的实体。
6740
- *
6741
- * @param name 实体名称
6742
- * @returns 匹配的实体,如果不存在则返回null
6743
- */
6744
- getEntityByName(name: string): Entity | null;
6745
- /**
6746
- * 根据标签获取实体列表
6747
- *
6748
- * 返回所有具有指定标签的实体。
6749
- *
6750
- * @param tag 标签值
6751
- * @returns 具有指定标签的实体数组
6752
- */
6753
- getEntitiesByTag(tag: number): Entity[];
6754
- /**
6755
- * 获取包含指定组件的所有实体
6756
- *
6757
- * 遍历所有实体,查找包含指定组件类型的实体。
6758
- *
6759
- * @param componentType 组件类型
6760
- * @returns 包含指定组件的实体数组
6761
- *
6762
- * @example
6763
- * ```typescript
6764
- * const entitiesWithHealth = entityManager.getEntitiesWithComponent(HealthComponent);
6765
- * ```
6766
- */
6767
- getEntitiesWithComponent<T extends Component>(componentType: ComponentType<T>): Entity[];
6768
- /**
6769
- * 创建查询构建器
6770
- *
6771
- * 返回一个新的查询构建器实例,用于构建复杂的实体查询。
6772
- *
6773
- * @returns 新的查询构建器实例
6774
- *
6775
- * @example
6776
- * ```typescript
6777
- * const results = entityManager.query()
6778
- * .withAll(PositionComponent, HealthComponent)
6779
- * .without(VelocityComponent)
6780
- * .active()
6781
- * .execute();
6782
- * ```
6783
- */
6784
- query(): EntityQueryBuilder;
6785
- /**
6786
- * 使用组件索引进行多组件查询
6787
- *
6788
- * @param componentTypes 组件类型数组
6789
- * @param operation 查询操作:'AND' 或 'OR'
6790
- * @returns 匹配的实体集合
6791
- */
6792
- queryWithComponentIndex(componentTypes: ComponentType[], operation: 'AND' | 'OR'): Set<Entity>;
6793
- /**
6794
- * 标记实体组件已修改
6795
- *
6796
- * @param entity 修改的实体
6797
- * @param componentTypes 修改的组件类型
6798
- */
6799
- markEntityDirty(entity: Entity, componentTypes: ComponentType[]): void;
6800
- /**
6801
- * 获取性能优化统计信息
6802
- */
6803
- getOptimizationStats(): any;
6804
- /**
6805
- * 获取事件总线实例
6806
- *
6807
- * 允许外部代码监听和发射ECS相关事件。
6808
- *
6809
- * @returns 事件总线实例
6810
- */
6811
- get eventBus(): EventBus;
6812
- /**
6813
- * 更新名称索引
6814
- *
6815
- * 维护按名称查找实体的索引结构。支持添加和移除操作。
6816
- *
6817
- * @param entity 要更新索引的实体
6818
- * @param isAdd true表示添加到索引,false表示从索引中移除
6819
- */
6820
- private updateNameIndex;
6821
- /**
6822
- * 更新标签索引
6823
- *
6824
- * 维护按标签查找实体的索引结构。支持添加和移除操作。
6825
- *
6826
- * @param entity 要更新索引的实体
6827
- * @param isAdd true表示添加到索引,false表示从索引中移除
6828
- */
6829
- private updateTagIndex;
6830
- }
6831
-
6832
- /**
6833
- * 索引统计信息
6834
- */
6835
- interface IndexStats {
6836
- /** 索引大小 */
6837
- size: number;
6838
- /** 内存使用量(字节) */
6839
- memoryUsage: number;
6840
- /** 查询次数 */
6841
- queryCount: number;
6842
- /** 平均查询时间(毫秒) */
6843
- avgQueryTime: number;
6844
- /** 最后更新时间 */
6845
- lastUpdated: number;
6846
- }
6847
- /**
6848
- * 组件索引接口
6849
- */
6850
- interface IComponentIndex {
6851
- /** 添加实体到索引 */
6852
- addEntity(entity: Entity): void;
6853
- /** 从索引中移除实体 */
6854
- removeEntity(entity: Entity): void;
6855
- /** 查询包含指定组件的实体 */
6856
- query(componentType: ComponentType): Set<Entity>;
6857
- /** 批量查询多个组件 */
6858
- queryMultiple(componentTypes: ComponentType[], operation: 'AND' | 'OR'): Set<Entity>;
6859
- /** 清空索引 */
6860
- clear(): void;
6861
- /** 获取索引统计信息 */
6862
- getStats(): IndexStats;
6863
- }
6864
- /**
6865
- * 通用组件索引实现
6866
- *
6867
- * 基于Sparse Set算法:
6868
- * - O(1)的实体添加、删除、查找
6869
- * - 高效的位运算查询
6870
- * - 内存紧凑的存储结构
6871
- * - 缓存友好的遍历性能
6872
- */
6873
- declare class ComponentIndex implements IComponentIndex {
6874
- /**
6875
- * 组件稀疏集合
6876
- *
6877
- * 核心存储结构,处理所有实体和组件的索引操作。
6878
- */
6879
- private _sparseSet;
6880
- private _queryCount;
6881
- private _totalQueryTime;
6882
- private _lastUpdated;
6883
- constructor();
6884
- addEntity(entity: Entity): void;
6885
- removeEntity(entity: Entity): void;
6886
- query(componentType: ComponentType): Set<Entity>;
6887
- queryMultiple(componentTypes: ComponentType[], operation: 'AND' | 'OR'): Set<Entity>;
6888
- clear(): void;
6889
- getStats(): IndexStats;
6890
- }
6891
- /**
6892
- * 组件索引管理器
6893
- *
6894
- * 使用统一的组件索引实现,自动优化查询性能。
6895
- */
6896
- declare class ComponentIndexManager {
6897
- private _index;
6898
- constructor();
6899
- /**
6900
- * 添加实体到索引
6901
- */
6902
- addEntity(entity: Entity): void;
6903
- /**
6904
- * 从索引中移除实体
6905
- */
6906
- removeEntity(entity: Entity): void;
6907
- /**
6908
- * 查询包含指定组件的实体
6909
- */
6910
- query(componentType: ComponentType): Set<Entity>;
6911
- /**
6912
- * 批量查询多个组件
6913
- */
6914
- queryMultiple(componentTypes: ComponentType[], operation: 'AND' | 'OR'): Set<Entity>;
6915
- /**
6916
- * 获取索引统计信息
6917
- */
6918
- getStats(): IndexStats;
6919
- /**
6920
- * 清空索引
6921
- */
6922
- clear(): void;
6923
- }
6924
-
6925
- /**
6926
- * 脏标记类型
6927
- */
6928
- declare enum DirtyFlag {
6929
- /** 组件数据已修改 */
6930
- COMPONENT_MODIFIED = 1,
6931
- /** 组件已添加 */
6932
- COMPONENT_ADDED = 2,
6933
- /** 组件已移除 */
6934
- COMPONENT_REMOVED = 4,
6935
- /** 实体位置已改变 */
6936
- TRANSFORM_CHANGED = 8,
6937
- /** 实体状态已改变 */
6938
- STATE_CHANGED = 16,
6939
- /** 自定义标记1 */
6940
- CUSTOM_1 = 256,
6941
- /** 自定义标记2 */
6942
- CUSTOM_2 = 512,
6943
- /** 自定义标记3 */
6944
- CUSTOM_3 = 1024,
6945
- /** 所有标记 */
6946
- ALL = 4294967295
6947
- }
6948
- /**
6949
- * 脏标记数据
6950
- */
6951
- interface DirtyData {
6952
- /** 实体引用 */
6953
- entity: Entity;
6954
- /** 脏标记位 */
6955
- flags: number;
6956
- /** 修改的组件类型列表 */
6957
- modifiedComponents: Set<ComponentType>;
6958
- /** 标记时间戳 */
6959
- timestamp: number;
6960
- /** 帧编号 */
6961
- frameNumber: number;
6962
- }
6963
- /**
6964
- * 脏标记监听器
6965
- */
6966
- interface DirtyListener {
6967
- /** 感兴趣的标记类型 */
6968
- flags: number;
6969
- /** 回调函数 */
6970
- callback: (dirtyData: DirtyData) => void;
6971
- /** 监听器优先级(数字越小优先级越高) */
6972
- priority?: number;
6973
- }
6974
- /**
6975
- * 脏标记统计信息
6976
- */
6977
- interface DirtyStats {
6978
- /** 当前脏实体数量 */
6979
- dirtyEntityCount: number;
6980
- /** 总标记次数 */
6981
- totalMarkings: number;
6982
- /** 总清理次数 */
6983
- totalCleanups: number;
6984
- /** 监听器数量 */
6985
- listenerCount: number;
6986
- /** 平均每帧脏实体数量 */
6987
- avgDirtyPerFrame: number;
6988
- /** 内存使用量估算 */
6989
- estimatedMemoryUsage: number;
6990
- }
6991
- /**
6992
- * 脏标记追踪系统
6993
- *
6994
- * 提供高效的组件和实体变更追踪,避免不必要的计算和更新。
6995
- * 支持细粒度的脏标记和批量处理机制。
6996
- *
6997
- * @example
6998
- * ```typescript
6999
- * const dirtySystem = new DirtyTrackingSystem();
7000
- *
7001
- * // 标记实体的位置组件已修改
7002
- * dirtySystem.markDirty(entity, DirtyFlag.TRANSFORM_CHANGED, [PositionComponent]);
7003
- *
7004
- * // 监听位置变化
7005
- * dirtySystem.addListener({
7006
- * flags: DirtyFlag.TRANSFORM_CHANGED,
7007
- * callback: (data) => {
7008
- * logger.debug('Entity position changed:', data.entity.name);
7009
- * }
7010
- * });
7011
- *
7012
- * // 处理所有脏标记
7013
- * dirtySystem.processDirtyEntities();
7014
- * ```
7015
- */
7016
- declare class DirtyTrackingSystem {
7017
- private static readonly _logger;
7018
- /** 脏实体映射表 */
7019
- private _dirtyEntities;
7020
- /** 脏标记监听器 */
7021
- private _listeners;
7022
- /** 性能统计 */
7023
- private _stats;
7024
- /** 当前帧编号 */
7025
- private _currentFrame;
7026
- private _batchSize;
7027
- private _maxProcessingTime;
7028
- /** 延迟处理队列 */
7029
- private _processingQueue;
7030
- private _isProcessing;
7031
- /**
7032
- * 标记实体为脏状态
7033
- *
7034
- * @param entity 要标记的实体
7035
- * @param flags 脏标记位
7036
- * @param modifiedComponents 修改的组件类型列表
7037
- */
7038
- markDirty(entity: Entity, flags: DirtyFlag, modifiedComponents?: ComponentType[]): void;
7039
- /**
7040
- * 检查实体是否有指定的脏标记
7041
- *
7042
- * @param entity 要检查的实体
7043
- * @param flags 要检查的标记位
7044
- * @returns 是否有指定的脏标记
7045
- */
7046
- isDirty(entity: Entity, flags?: DirtyFlag): boolean;
7047
- /**
7048
- * 清除实体的脏标记
7049
- *
7050
- * @param entity 要清除的实体
7051
- * @param flags 要清除的标记位,默认清除所有
7052
- */
7053
- clearDirty(entity: Entity, flags?: DirtyFlag): void;
7054
- /**
7055
- * 获取所有脏实体
7056
- *
7057
- * @param flags 过滤标记位,只返回包含指定标记的实体
7058
- * @returns 脏实体数据数组
7059
- */
7060
- getDirtyEntities(flags?: DirtyFlag): DirtyData[];
7061
- /**
7062
- * 批量处理脏实体
7063
- *
7064
- * 使用时间分片的方式处理脏实体,避免单帧卡顿
7065
- */
7066
- processDirtyEntities(): void;
7067
- /**
7068
- * 添加脏标记监听器
7069
- *
7070
- * @param listener 监听器配置
7071
- */
7072
- addListener(listener: DirtyListener): void;
7073
- /**
7074
- * 移除脏标记监听器
7075
- *
7076
- * @param callback 要移除的回调函数
7077
- */
7078
- removeListener(callback: (dirtyData: DirtyData) => void): void;
7079
- /**
7080
- * 开始新的帧
7081
- */
7082
- beginFrame(): void;
7083
- /**
7084
- * 结束当前帧
7085
- */
7086
- endFrame(): void;
7087
- /**
7088
- * 获取统计信息
7089
- */
7090
- getStats(): DirtyStats;
7091
- /**
7092
- * 清空所有脏标记和统计信息
7093
- */
7094
- clear(): void;
7095
- /**
7096
- * 配置批量处理参数
7097
- *
7098
- * @param batchSize 每次处理的最大实体数量
7099
- * @param maxProcessingTime 每帧最大处理时间(毫秒)
7100
- */
7101
- configureBatchProcessing(batchSize: number, maxProcessingTime: number): void;
7102
- /**
7103
- * 处理单个脏实体
7104
- */
7105
- private processEntity;
7106
- /**
7107
- * 通知监听器
7108
- */
7109
- private notifyListeners;
7110
- /**
7111
- * 帧结束时的统计更新
7112
- */
7113
- private onFrameEnd;
7114
- /**
7115
- * 估算内存使用量
7116
- */
7117
- private estimateMemoryUsage;
7118
- }
7119
-
7120
6457
  /**
7121
6458
  * 组件对象池,用于复用组件实例以减少内存分配
7122
6459
  */
@@ -7277,5 +6614,5 @@ declare class Time {
7277
6614
  static checkEvery(interval: number, lastTime: number): boolean;
7278
6615
  }
7279
6616
 
7280
- export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, Colors, Component, ComponentDataCollector, ComponentIndex, ComponentIndexManager, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSparseSet, ComponentStorage, ComponentTypeManager, ConsoleLogger, Core, DebugManager, DirtyFlag, DirtyTrackingSystem, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, HighPrecision, IdentifierPool, Int32, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SerializeMap, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, WebSocketManager, World, WorldManager, createECSAPI, createLogger, getComponentInstanceTypeName, getComponentTypeName, getSystemInstanceTypeName, getSystemTypeName, resetLoggerColors, setGlobalLogLevel, setLoggerColors };
7281
- export type { Archetype, ArchetypeQueryResult, BitMask64Data, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EventListenerConfig, EventStats, IComponent, IComponentDebugData, IComponentEventData, IComponentIndex, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IWorldConfig, IWorldManagerConfig, IndexStats, LoggerColorConfig, LoggerConfig, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats };
6617
+ export { AsyncEventHandler$1 as AsyncEventHandler, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSparseSet, ComponentStorage, ComponentTypeManager, ConsoleLogger, Core, DebugManager, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityProcessorList, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, HighPrecision, IdentifierPool, Int32, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SerializeMap, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, WebSocketManager, World, WorldManager, createECSAPI, createLogger, getComponentInstanceTypeName, getComponentTypeName, getSystemInstanceTypeName, getSystemTypeName, resetLoggerColors, setGlobalLogLevel, setLoggerColors };
6618
+ export type { BitMask64Data, ComponentType$1 as ComponentType, EventListenerConfig, EventStats, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IWorldConfig, IWorldManagerConfig, LoggerColorConfig, LoggerConfig, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats };