@esengine/ecs-framework 2.1.25 → 2.1.27
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/README.md +1 -0
- package/index.cjs +2 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +550 -115
- package/index.mjs +2 -0
- package/index.mjs.map +1 -0
- package/package.json +9 -9
- package/index.js +0 -2
- package/index.js.map +0 -1
- package/index.umd.js +0 -2
- package/index.umd.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @esengine/ecs-framework v2.1.
|
|
2
|
+
* @esengine/ecs-framework v2.1.27
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -1493,37 +1493,6 @@ declare class EntityComparer {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
compare(self: Entity, other: Entity): number;
|
|
1495
1495
|
}
|
|
1496
|
-
/**
|
|
1497
|
-
* 组件缓存配置
|
|
1498
|
-
*/
|
|
1499
|
-
interface ComponentCacheConfig {
|
|
1500
|
-
maxSize: number;
|
|
1501
|
-
ttl: number;
|
|
1502
|
-
enableLRU: boolean;
|
|
1503
|
-
}
|
|
1504
|
-
/**
|
|
1505
|
-
* 高性能组件缓存
|
|
1506
|
-
*/
|
|
1507
|
-
declare class ComponentCache {
|
|
1508
|
-
private cache;
|
|
1509
|
-
private accessOrder;
|
|
1510
|
-
private config;
|
|
1511
|
-
constructor(config?: ComponentCacheConfig);
|
|
1512
|
-
get<T extends Component>(type: ComponentType<T>): T | null;
|
|
1513
|
-
set<T extends Component>(type: ComponentType<T>, component: T): void;
|
|
1514
|
-
delete(type: ComponentType): boolean;
|
|
1515
|
-
clear(): void;
|
|
1516
|
-
has(type: ComponentType): boolean;
|
|
1517
|
-
private evictLeastRecentlyUsed;
|
|
1518
|
-
private updateAccessOrder;
|
|
1519
|
-
private removeFromAccessOrder;
|
|
1520
|
-
getStats(): {
|
|
1521
|
-
size: number;
|
|
1522
|
-
maxSize: number;
|
|
1523
|
-
hitRate: number;
|
|
1524
|
-
averageAccessCount: number;
|
|
1525
|
-
};
|
|
1526
|
-
}
|
|
1527
1496
|
/**
|
|
1528
1497
|
* 游戏实体类
|
|
1529
1498
|
*
|
|
@@ -1644,18 +1613,6 @@ declare class Entity {
|
|
|
1644
1613
|
* 用于快速定位组件在数组中的位置。
|
|
1645
1614
|
*/
|
|
1646
1615
|
private _componentTypeToIndex;
|
|
1647
|
-
/**
|
|
1648
|
-
* 组件缓存
|
|
1649
|
-
*
|
|
1650
|
-
* 高性能组件访问缓存。
|
|
1651
|
-
*/
|
|
1652
|
-
private _componentCache;
|
|
1653
|
-
/**
|
|
1654
|
-
* 组件访问统计
|
|
1655
|
-
*
|
|
1656
|
-
* 记录组件访问的性能统计信息。
|
|
1657
|
-
*/
|
|
1658
|
-
private _componentAccessStats;
|
|
1659
1616
|
/**
|
|
1660
1617
|
* 构造函数
|
|
1661
1618
|
*
|
|
@@ -1781,24 +1738,6 @@ declare class Entity {
|
|
|
1781
1738
|
* @returns 组件实例或null
|
|
1782
1739
|
*/
|
|
1783
1740
|
getComponent<T extends Component>(type: ComponentType<T>): T | null;
|
|
1784
|
-
/**
|
|
1785
|
-
* 更新组件访问统计
|
|
1786
|
-
*
|
|
1787
|
-
* @param type - 组件类型
|
|
1788
|
-
*/
|
|
1789
|
-
private updateComponentAccessStats;
|
|
1790
|
-
/**
|
|
1791
|
-
* 记录缓存命中
|
|
1792
|
-
*
|
|
1793
|
-
* @param type - 组件类型
|
|
1794
|
-
*/
|
|
1795
|
-
private recordCacheHit;
|
|
1796
|
-
/**
|
|
1797
|
-
* 记录缓存未命中
|
|
1798
|
-
*
|
|
1799
|
-
* @param type - 组件类型
|
|
1800
|
-
*/
|
|
1801
|
-
private recordCacheMiss;
|
|
1802
1741
|
/**
|
|
1803
1742
|
* 重建组件索引映射
|
|
1804
1743
|
*/
|
|
@@ -1849,35 +1788,6 @@ declare class Entity {
|
|
|
1849
1788
|
* @returns 被移除的组件数组
|
|
1850
1789
|
*/
|
|
1851
1790
|
removeComponentsByTypes<T extends Component>(componentTypes: ComponentType<T>[]): (T | null)[];
|
|
1852
|
-
/**
|
|
1853
|
-
* 获取组件缓存统计信息
|
|
1854
|
-
*
|
|
1855
|
-
* @returns 缓存统计信息
|
|
1856
|
-
*/
|
|
1857
|
-
getComponentCacheStats(): {
|
|
1858
|
-
cacheStats: ReturnType<ComponentCache['getStats']>;
|
|
1859
|
-
accessStats: Map<string, {
|
|
1860
|
-
accessCount: number;
|
|
1861
|
-
lastAccessed: number;
|
|
1862
|
-
cacheHits: number;
|
|
1863
|
-
cacheMisses: number;
|
|
1864
|
-
hitRate: number;
|
|
1865
|
-
}>;
|
|
1866
|
-
indexMappingSize: number;
|
|
1867
|
-
totalComponents: number;
|
|
1868
|
-
};
|
|
1869
|
-
/**
|
|
1870
|
-
* 预热组件缓存
|
|
1871
|
-
*
|
|
1872
|
-
* 将所有组件添加到缓存中,提升后续访问性能
|
|
1873
|
-
*/
|
|
1874
|
-
warmUpComponentCache(): void;
|
|
1875
|
-
/**
|
|
1876
|
-
* 清理组件缓存
|
|
1877
|
-
*
|
|
1878
|
-
* 清除过期的缓存项,释放内存
|
|
1879
|
-
*/
|
|
1880
|
-
cleanupComponentCache(): void;
|
|
1881
1791
|
/**
|
|
1882
1792
|
* 获取所有指定类型的组件
|
|
1883
1793
|
*
|
|
@@ -2000,20 +1910,6 @@ declare class Entity {
|
|
|
2000
1910
|
childCount: number;
|
|
2001
1911
|
childIds: number[];
|
|
2002
1912
|
depth: number;
|
|
2003
|
-
componentCache: {
|
|
2004
|
-
size: number;
|
|
2005
|
-
maxSize: number;
|
|
2006
|
-
hitRate: number;
|
|
2007
|
-
averageAccessCount: number;
|
|
2008
|
-
};
|
|
2009
|
-
componentAccessStats: Array<{
|
|
2010
|
-
componentType: string;
|
|
2011
|
-
accessCount: number;
|
|
2012
|
-
cacheHits: number;
|
|
2013
|
-
cacheMisses: number;
|
|
2014
|
-
hitRate: number;
|
|
2015
|
-
lastAccessed: string;
|
|
2016
|
-
}>;
|
|
2017
1913
|
indexMappingSize: number;
|
|
2018
1914
|
};
|
|
2019
1915
|
}
|
|
@@ -2348,8 +2244,8 @@ declare abstract class EntitySystem implements ISystemBase {
|
|
|
2348
2244
|
/**
|
|
2349
2245
|
* 这个系统所属的场景
|
|
2350
2246
|
*/
|
|
2351
|
-
get scene(): Scene;
|
|
2352
|
-
set scene(value: Scene);
|
|
2247
|
+
get scene(): Scene | null;
|
|
2248
|
+
set scene(value: Scene | null);
|
|
2353
2249
|
private _matcher;
|
|
2354
2250
|
/**
|
|
2355
2251
|
* 获取实体匹配器
|
|
@@ -2529,21 +2425,206 @@ declare class EntityProcessorList {
|
|
|
2529
2425
|
}
|
|
2530
2426
|
|
|
2531
2427
|
/**
|
|
2532
|
-
* ID池管理器
|
|
2533
|
-
*
|
|
2428
|
+
* 世代式ID池管理器
|
|
2429
|
+
*
|
|
2430
|
+
* 用于管理实体ID的分配和回收,支持世代版本控制以防止悬空引用问题。
|
|
2431
|
+
* 世代式ID由索引和版本组成,当ID被回收时版本会递增,确保旧引用失效。
|
|
2432
|
+
*
|
|
2433
|
+
* 支持动态扩展,理论上可以支持到65535个索引(16位),每个索引65535个版本(16位)。
|
|
2434
|
+
* 总计可以处理超过42亿个独特的ID组合,完全满足ECS大规模实体需求。
|
|
2435
|
+
*
|
|
2436
|
+
* @example
|
|
2437
|
+
* ```typescript
|
|
2438
|
+
* const pool = new IdentifierPool();
|
|
2439
|
+
*
|
|
2440
|
+
* // 分配ID
|
|
2441
|
+
* const id = pool.checkOut(); // 例如: 65536 (版本1,索引0)
|
|
2442
|
+
*
|
|
2443
|
+
* // 回收ID
|
|
2444
|
+
* pool.checkIn(id);
|
|
2445
|
+
*
|
|
2446
|
+
* // 验证ID是否有效
|
|
2447
|
+
* const isValid = pool.isValid(id); // false,因为版本已递增
|
|
2448
|
+
* ```
|
|
2534
2449
|
*/
|
|
2535
2450
|
declare class IdentifierPool {
|
|
2536
|
-
|
|
2537
|
-
|
|
2451
|
+
/**
|
|
2452
|
+
* 下一个可用的索引
|
|
2453
|
+
*/
|
|
2454
|
+
private _nextAvailableIndex;
|
|
2455
|
+
/**
|
|
2456
|
+
* 空闲的索引列表
|
|
2457
|
+
*/
|
|
2458
|
+
private _freeIndices;
|
|
2459
|
+
/**
|
|
2460
|
+
* 每个索引对应的世代版本
|
|
2461
|
+
* 动态扩展的Map,按需分配内存
|
|
2462
|
+
*/
|
|
2463
|
+
private _generations;
|
|
2464
|
+
/**
|
|
2465
|
+
* 延迟回收队列
|
|
2466
|
+
* 防止在同一帧内立即重用ID,避免时序问题
|
|
2467
|
+
*/
|
|
2468
|
+
private _pendingRecycle;
|
|
2469
|
+
/**
|
|
2470
|
+
* 延迟回收时间(毫秒)
|
|
2471
|
+
*/
|
|
2472
|
+
private _recycleDelay;
|
|
2473
|
+
/**
|
|
2474
|
+
* 最大索引限制(16位)
|
|
2475
|
+
* 这是框架设计选择:16位索引 + 16位版本 = 32位ID,确保高效位操作
|
|
2476
|
+
* 不是硬件限制,而是性能和内存效率的权衡
|
|
2477
|
+
*/
|
|
2478
|
+
private static readonly MAX_INDEX;
|
|
2479
|
+
/**
|
|
2480
|
+
* 最大世代限制(16位)
|
|
2481
|
+
*/
|
|
2482
|
+
private static readonly MAX_GENERATION;
|
|
2483
|
+
/**
|
|
2484
|
+
* 内存扩展块大小
|
|
2485
|
+
* 当需要更多内存时,一次性预分配的索引数量
|
|
2486
|
+
*/
|
|
2487
|
+
private _expansionBlockSize;
|
|
2488
|
+
/**
|
|
2489
|
+
* 统计信息
|
|
2490
|
+
*/
|
|
2491
|
+
private _stats;
|
|
2492
|
+
/**
|
|
2493
|
+
* 构造函数
|
|
2494
|
+
*
|
|
2495
|
+
* @param recycleDelay 延迟回收时间(毫秒),默认为100ms
|
|
2496
|
+
* @param expansionBlockSize 内存扩展块大小,默认为1024
|
|
2497
|
+
*/
|
|
2498
|
+
constructor(recycleDelay?: number, expansionBlockSize?: number);
|
|
2538
2499
|
/**
|
|
2539
2500
|
* 获取一个可用的ID
|
|
2501
|
+
*
|
|
2502
|
+
* 返回一个32位ID,高16位为世代版本,低16位为索引。
|
|
2503
|
+
*
|
|
2504
|
+
* @returns 新分配的实体ID
|
|
2505
|
+
* @throws {Error} 当达到索引限制时抛出错误
|
|
2540
2506
|
*/
|
|
2541
2507
|
checkOut(): number;
|
|
2542
2508
|
/**
|
|
2543
2509
|
* 回收一个ID
|
|
2544
|
-
*
|
|
2510
|
+
*
|
|
2511
|
+
* 验证ID的有效性后,将其加入延迟回收队列。
|
|
2512
|
+
* ID不会立即可重用,而是在延迟时间后才真正回收。
|
|
2513
|
+
*
|
|
2514
|
+
* @param id 要回收的实体ID
|
|
2515
|
+
* @returns 是否成功回收(ID是否有效且未被重复回收)
|
|
2516
|
+
*/
|
|
2517
|
+
checkIn(id: number): boolean;
|
|
2518
|
+
/**
|
|
2519
|
+
* 验证ID是否有效
|
|
2520
|
+
*
|
|
2521
|
+
* 检查ID的索引和世代版本是否匹配当前状态。
|
|
2522
|
+
*
|
|
2523
|
+
* @param id 要验证的实体ID
|
|
2524
|
+
* @returns ID是否有效
|
|
2525
|
+
*/
|
|
2526
|
+
isValid(id: number): boolean;
|
|
2527
|
+
/**
|
|
2528
|
+
* 获取统计信息
|
|
2529
|
+
*
|
|
2530
|
+
* @returns 池的当前状态统计
|
|
2531
|
+
*/
|
|
2532
|
+
getStats(): {
|
|
2533
|
+
/** 已分配的总索引数 */
|
|
2534
|
+
totalAllocated: number;
|
|
2535
|
+
/** 总计回收次数 */
|
|
2536
|
+
totalRecycled: number;
|
|
2537
|
+
/** 当前活跃实体数 */
|
|
2538
|
+
currentActive: number;
|
|
2539
|
+
/** 当前空闲的索引数 */
|
|
2540
|
+
currentlyFree: number;
|
|
2541
|
+
/** 等待回收的ID数 */
|
|
2542
|
+
pendingRecycle: number;
|
|
2543
|
+
/** 理论最大实体数(设计限制) */
|
|
2544
|
+
maxPossibleEntities: number;
|
|
2545
|
+
/** 当前使用的最大索引 */
|
|
2546
|
+
maxUsedIndex: number;
|
|
2547
|
+
/** 内存使用(字节) */
|
|
2548
|
+
memoryUsage: number;
|
|
2549
|
+
/** 内存扩展次数 */
|
|
2550
|
+
memoryExpansions: number;
|
|
2551
|
+
/** 平均世代版本 */
|
|
2552
|
+
averageGeneration: number;
|
|
2553
|
+
/** 世代存储大小 */
|
|
2554
|
+
generationStorageSize: number;
|
|
2555
|
+
};
|
|
2556
|
+
/**
|
|
2557
|
+
* 强制执行延迟回收处理
|
|
2558
|
+
*
|
|
2559
|
+
* 在某些情况下可能需要立即处理延迟回收队列,
|
|
2560
|
+
* 比如内存压力大或者需要精确的统计信息时。
|
|
2561
|
+
*/
|
|
2562
|
+
forceProcessDelayedRecycle(): void;
|
|
2563
|
+
/**
|
|
2564
|
+
* 清理过期的延迟回收项
|
|
2565
|
+
*
|
|
2566
|
+
* 将超过延迟时间的回收项真正回收到空闲列表中。
|
|
2567
|
+
*
|
|
2568
|
+
* @param forceAll 是否强制处理所有延迟回收项
|
|
2569
|
+
* @private
|
|
2570
|
+
*/
|
|
2571
|
+
private _processDelayedRecycle;
|
|
2572
|
+
/**
|
|
2573
|
+
* 预分配世代信息
|
|
2574
|
+
*
|
|
2575
|
+
* @param startIndex 起始索引
|
|
2576
|
+
* @param count 分配数量
|
|
2577
|
+
* @private
|
|
2545
2578
|
*/
|
|
2546
|
-
|
|
2579
|
+
private _preAllocateGenerations;
|
|
2580
|
+
/**
|
|
2581
|
+
* 确保指定索引的世代信息存在
|
|
2582
|
+
*
|
|
2583
|
+
* @param index 索引
|
|
2584
|
+
* @private
|
|
2585
|
+
*/
|
|
2586
|
+
private _ensureGenerationCapacity;
|
|
2587
|
+
/**
|
|
2588
|
+
* 计算内存使用量
|
|
2589
|
+
*
|
|
2590
|
+
* @returns 内存使用字节数
|
|
2591
|
+
* @private
|
|
2592
|
+
*/
|
|
2593
|
+
private _calculateMemoryUsage;
|
|
2594
|
+
/**
|
|
2595
|
+
* 打包索引和世代为32位ID
|
|
2596
|
+
*
|
|
2597
|
+
* @param index 索引(16位)
|
|
2598
|
+
* @param generation 世代版本(16位)
|
|
2599
|
+
* @returns 打包后的32位ID
|
|
2600
|
+
* @private
|
|
2601
|
+
*/
|
|
2602
|
+
private _packId;
|
|
2603
|
+
/**
|
|
2604
|
+
* 从ID中解包索引
|
|
2605
|
+
*
|
|
2606
|
+
* @param id 32位ID
|
|
2607
|
+
* @returns 索引部分(16位)
|
|
2608
|
+
* @private
|
|
2609
|
+
*/
|
|
2610
|
+
private _unpackIndex;
|
|
2611
|
+
/**
|
|
2612
|
+
* 从ID中解包世代版本
|
|
2613
|
+
*
|
|
2614
|
+
* @param id 32位ID
|
|
2615
|
+
* @returns 世代版本部分(16位)
|
|
2616
|
+
* @private
|
|
2617
|
+
*/
|
|
2618
|
+
private _unpackGeneration;
|
|
2619
|
+
/**
|
|
2620
|
+
* 内部ID有效性检查
|
|
2621
|
+
*
|
|
2622
|
+
* @param index 索引
|
|
2623
|
+
* @param generation 世代版本
|
|
2624
|
+
* @returns 是否有效
|
|
2625
|
+
* @private
|
|
2626
|
+
*/
|
|
2627
|
+
private _isValidId;
|
|
2547
2628
|
}
|
|
2548
2629
|
|
|
2549
2630
|
/**
|
|
@@ -5654,6 +5735,10 @@ declare class ComponentPoolManager {
|
|
|
5654
5735
|
* 清空所有池
|
|
5655
5736
|
*/
|
|
5656
5737
|
clearAll(): void;
|
|
5738
|
+
/**
|
|
5739
|
+
* 重置管理器,移除所有注册的池
|
|
5740
|
+
*/
|
|
5741
|
+
reset(): void;
|
|
5657
5742
|
/**
|
|
5658
5743
|
* 获取池统计信息
|
|
5659
5744
|
*/
|
|
@@ -5748,5 +5833,355 @@ declare class Time {
|
|
|
5748
5833
|
static checkEvery(interval: number, lastTime: number): boolean;
|
|
5749
5834
|
}
|
|
5750
5835
|
|
|
5751
|
-
|
|
5752
|
-
|
|
5836
|
+
/**
|
|
5837
|
+
* 可序列化接口
|
|
5838
|
+
*
|
|
5839
|
+
* 实现此接口的类可以被快照系统序列化和反序列化
|
|
5840
|
+
*/
|
|
5841
|
+
interface ISnapshotable {
|
|
5842
|
+
/**
|
|
5843
|
+
* 序列化对象到可传输的数据格式
|
|
5844
|
+
*
|
|
5845
|
+
* @returns 序列化后的数据
|
|
5846
|
+
*/
|
|
5847
|
+
serialize(): any;
|
|
5848
|
+
/**
|
|
5849
|
+
* 从序列化数据恢复对象状态
|
|
5850
|
+
*
|
|
5851
|
+
* @param data - 序列化数据
|
|
5852
|
+
*/
|
|
5853
|
+
deserialize(data: any): void;
|
|
5854
|
+
}
|
|
5855
|
+
/**
|
|
5856
|
+
* 快照配置接口
|
|
5857
|
+
*/
|
|
5858
|
+
interface SnapshotConfig {
|
|
5859
|
+
/** 是否包含在快照中 */
|
|
5860
|
+
includeInSnapshot: boolean;
|
|
5861
|
+
/** 压缩级别 (0-9) */
|
|
5862
|
+
compressionLevel: number;
|
|
5863
|
+
/** 同步优先级 (数字越大优先级越高) */
|
|
5864
|
+
syncPriority: number;
|
|
5865
|
+
/** 是否启用增量快照 */
|
|
5866
|
+
enableIncremental: boolean;
|
|
5867
|
+
}
|
|
5868
|
+
/**
|
|
5869
|
+
* 组件快照数据
|
|
5870
|
+
*/
|
|
5871
|
+
interface ComponentSnapshot {
|
|
5872
|
+
/** 组件类型名称 */
|
|
5873
|
+
type: string;
|
|
5874
|
+
/** 组件ID */
|
|
5875
|
+
id: number;
|
|
5876
|
+
/** 序列化数据 */
|
|
5877
|
+
data: any;
|
|
5878
|
+
/** 是否启用 */
|
|
5879
|
+
enabled: boolean;
|
|
5880
|
+
/** 快照配置 */
|
|
5881
|
+
config?: SnapshotConfig;
|
|
5882
|
+
}
|
|
5883
|
+
/**
|
|
5884
|
+
* 实体快照数据
|
|
5885
|
+
*/
|
|
5886
|
+
interface EntitySnapshot {
|
|
5887
|
+
/** 实体ID */
|
|
5888
|
+
id: number;
|
|
5889
|
+
/** 实体名称 */
|
|
5890
|
+
name: string;
|
|
5891
|
+
/** 是否启用 */
|
|
5892
|
+
enabled: boolean;
|
|
5893
|
+
/** 是否激活 */
|
|
5894
|
+
active: boolean;
|
|
5895
|
+
/** 标签 */
|
|
5896
|
+
tag: number;
|
|
5897
|
+
/** 更新顺序 */
|
|
5898
|
+
updateOrder: number;
|
|
5899
|
+
/** 组件快照列表 */
|
|
5900
|
+
components: ComponentSnapshot[];
|
|
5901
|
+
/** 子实体ID列表 */
|
|
5902
|
+
children: number[];
|
|
5903
|
+
/** 父实体ID */
|
|
5904
|
+
parent?: number;
|
|
5905
|
+
/** 快照时间戳 */
|
|
5906
|
+
timestamp: number;
|
|
5907
|
+
}
|
|
5908
|
+
/**
|
|
5909
|
+
* 场景快照数据
|
|
5910
|
+
*/
|
|
5911
|
+
interface SceneSnapshot {
|
|
5912
|
+
/** 实体快照列表 */
|
|
5913
|
+
entities: EntitySnapshot[];
|
|
5914
|
+
/** 快照时间戳 */
|
|
5915
|
+
timestamp: number;
|
|
5916
|
+
/** 框架版本 */
|
|
5917
|
+
version: string;
|
|
5918
|
+
/** 快照类型 */
|
|
5919
|
+
type: 'full' | 'incremental';
|
|
5920
|
+
/** 基础快照ID(增量快照使用) */
|
|
5921
|
+
baseSnapshotId?: string;
|
|
5922
|
+
}
|
|
5923
|
+
|
|
5924
|
+
/**
|
|
5925
|
+
* 快照管理器
|
|
5926
|
+
*
|
|
5927
|
+
* 负责创建和管理ECS系统的快照,支持完整快照和增量快照
|
|
5928
|
+
*/
|
|
5929
|
+
declare class SnapshotManager {
|
|
5930
|
+
/** 默认快照配置 */
|
|
5931
|
+
private static readonly DEFAULT_CONFIG;
|
|
5932
|
+
/** 框架版本 */
|
|
5933
|
+
private readonly version;
|
|
5934
|
+
/** 最后快照时间戳 */
|
|
5935
|
+
private lastSnapshotTime;
|
|
5936
|
+
/** 快照缓存 */
|
|
5937
|
+
private snapshotCache;
|
|
5938
|
+
/** 最大缓存数量 */
|
|
5939
|
+
private maxCacheSize;
|
|
5940
|
+
/**
|
|
5941
|
+
* 创建场景快照
|
|
5942
|
+
*
|
|
5943
|
+
* @param entities - 实体列表
|
|
5944
|
+
* @param type - 快照类型
|
|
5945
|
+
* @returns 场景快照
|
|
5946
|
+
*/
|
|
5947
|
+
createSceneSnapshot(entities: Entity[], type?: 'full' | 'incremental'): SceneSnapshot;
|
|
5948
|
+
/**
|
|
5949
|
+
* 从快照恢复场景
|
|
5950
|
+
*
|
|
5951
|
+
* @param snapshot - 场景快照
|
|
5952
|
+
* @param targetEntities - 目标实体列表(用于增量恢复)
|
|
5953
|
+
* @param createMissingEntities - 是否创建缺失的实体
|
|
5954
|
+
*/
|
|
5955
|
+
restoreFromSnapshot(snapshot: SceneSnapshot, targetEntities?: Entity[], createMissingEntities?: boolean): Entity[];
|
|
5956
|
+
/**
|
|
5957
|
+
* 从快照恢复实体列表
|
|
5958
|
+
*
|
|
5959
|
+
* @param snapshot - 场景快照
|
|
5960
|
+
* @param targetEntities - 目标实体列表
|
|
5961
|
+
* @param createMissingEntities - 是否创建缺失的实体
|
|
5962
|
+
*/
|
|
5963
|
+
restoreEntitiesFromSnapshot(snapshot: SceneSnapshot, targetEntities: Entity[], createMissingEntities?: boolean): Entity[];
|
|
5964
|
+
/**
|
|
5965
|
+
* 从快照创建实体
|
|
5966
|
+
*/
|
|
5967
|
+
private createEntityFromSnapshot;
|
|
5968
|
+
/**
|
|
5969
|
+
* 从快照创建组件
|
|
5970
|
+
*/
|
|
5971
|
+
private createComponentFromSnapshot;
|
|
5972
|
+
/**
|
|
5973
|
+
* 获取组件类型
|
|
5974
|
+
*/
|
|
5975
|
+
private getComponentType;
|
|
5976
|
+
/**
|
|
5977
|
+
* 创建快速快照(跳过变化检测)
|
|
5978
|
+
*
|
|
5979
|
+
* @param entities - 实体列表
|
|
5980
|
+
* @returns 场景快照
|
|
5981
|
+
*/
|
|
5982
|
+
createQuickSnapshot(entities: Entity[]): SceneSnapshot;
|
|
5983
|
+
/**
|
|
5984
|
+
* 创建增量快照
|
|
5985
|
+
*
|
|
5986
|
+
* @param entities - 实体列表
|
|
5987
|
+
* @param baseSnapshot - 基础快照
|
|
5988
|
+
* @param enableChangeDetection - 是否启用变化检测
|
|
5989
|
+
* @returns 增量快照
|
|
5990
|
+
*/
|
|
5991
|
+
createIncrementalSnapshot(entities: Entity[], baseSnapshot: SceneSnapshot, enableChangeDetection?: boolean): SceneSnapshot;
|
|
5992
|
+
/**
|
|
5993
|
+
* 缓存快照
|
|
5994
|
+
*
|
|
5995
|
+
* @param id - 快照ID
|
|
5996
|
+
* @param snapshot - 快照数据
|
|
5997
|
+
*/
|
|
5998
|
+
cacheSnapshot(id: string, snapshot: SceneSnapshot): void;
|
|
5999
|
+
/**
|
|
6000
|
+
* 获取缓存的快照
|
|
6001
|
+
*
|
|
6002
|
+
* @param id - 快照ID
|
|
6003
|
+
* @returns 快照数据或undefined
|
|
6004
|
+
*/
|
|
6005
|
+
getCachedSnapshot(id: string): SceneSnapshot | undefined;
|
|
6006
|
+
/**
|
|
6007
|
+
* 清空快照缓存
|
|
6008
|
+
*/
|
|
6009
|
+
clearCache(): void;
|
|
6010
|
+
/**
|
|
6011
|
+
* 清空所有缓存
|
|
6012
|
+
*/
|
|
6013
|
+
clearAllCaches(): void;
|
|
6014
|
+
/**
|
|
6015
|
+
* 获取缓存统计信息
|
|
6016
|
+
*/
|
|
6017
|
+
getCacheStats(): {
|
|
6018
|
+
snapshotCacheSize: number;
|
|
6019
|
+
};
|
|
6020
|
+
/**
|
|
6021
|
+
* 创建实体快照
|
|
6022
|
+
*/
|
|
6023
|
+
private createEntitySnapshot;
|
|
6024
|
+
/**
|
|
6025
|
+
* 创建组件快照
|
|
6026
|
+
*/
|
|
6027
|
+
private createComponentSnapshot;
|
|
6028
|
+
/**
|
|
6029
|
+
* 默认组件序列化
|
|
6030
|
+
*/
|
|
6031
|
+
private defaultSerializeComponent;
|
|
6032
|
+
/**
|
|
6033
|
+
* 检查值是否可序列化
|
|
6034
|
+
*/
|
|
6035
|
+
private isSerializableValue;
|
|
6036
|
+
/**
|
|
6037
|
+
* 检查组件是否支持快照
|
|
6038
|
+
*/
|
|
6039
|
+
private isComponentSnapshotable;
|
|
6040
|
+
/**
|
|
6041
|
+
* 获取组件快照配置
|
|
6042
|
+
*/
|
|
6043
|
+
private getComponentSnapshotConfig;
|
|
6044
|
+
/**
|
|
6045
|
+
* 检查组件是否有序列化方法
|
|
6046
|
+
*/
|
|
6047
|
+
private hasSerializeMethod;
|
|
6048
|
+
/**
|
|
6049
|
+
* 恢复完整快照
|
|
6050
|
+
*/
|
|
6051
|
+
private restoreFullSnapshot;
|
|
6052
|
+
/**
|
|
6053
|
+
* 恢复增量快照
|
|
6054
|
+
*/
|
|
6055
|
+
private restoreIncrementalSnapshot;
|
|
6056
|
+
/**
|
|
6057
|
+
* 从快照恢复实体
|
|
6058
|
+
*/
|
|
6059
|
+
private restoreEntityFromSnapshot;
|
|
6060
|
+
/**
|
|
6061
|
+
* 从快照恢复组件
|
|
6062
|
+
*/
|
|
6063
|
+
private restoreComponentFromSnapshot;
|
|
6064
|
+
/**
|
|
6065
|
+
* 默认组件反序列化
|
|
6066
|
+
*/
|
|
6067
|
+
private defaultDeserializeComponent;
|
|
6068
|
+
/**
|
|
6069
|
+
* 检查实体结构是否发生变化(组件数量、类型等)
|
|
6070
|
+
*/
|
|
6071
|
+
private hasEntityStructureChanged;
|
|
6072
|
+
/**
|
|
6073
|
+
* 获取发生变化的组件列表
|
|
6074
|
+
*/
|
|
6075
|
+
private getChangedComponents;
|
|
6076
|
+
/**
|
|
6077
|
+
* 检查组件数据是否发生变化
|
|
6078
|
+
*/
|
|
6079
|
+
private hasComponentDataChanged;
|
|
6080
|
+
/**
|
|
6081
|
+
* 检查组件是否有变化检测方法
|
|
6082
|
+
*/
|
|
6083
|
+
private hasChangeDetectionMethod;
|
|
6084
|
+
/**
|
|
6085
|
+
* 创建增量实体快照(只包含变化的组件)
|
|
6086
|
+
*/
|
|
6087
|
+
private createIncrementalEntitySnapshot;
|
|
6088
|
+
/**
|
|
6089
|
+
* 生成快照ID
|
|
6090
|
+
*/
|
|
6091
|
+
private generateSnapshotId;
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6094
|
+
/**
|
|
6095
|
+
* 快照扩展接口
|
|
6096
|
+
*
|
|
6097
|
+
* 为Component基类提供快照功能的扩展接口
|
|
6098
|
+
*/
|
|
6099
|
+
interface ISnapshotExtension {
|
|
6100
|
+
/** 快照配置 */
|
|
6101
|
+
snapshotConfig?: SnapshotConfig;
|
|
6102
|
+
/** 序列化方法 */
|
|
6103
|
+
serialize?(): any;
|
|
6104
|
+
/** 反序列化方法 */
|
|
6105
|
+
deserialize?(data: any): void;
|
|
6106
|
+
/** 变化检测方法 */
|
|
6107
|
+
hasChanged?(baseData: any): boolean;
|
|
6108
|
+
}
|
|
6109
|
+
/**
|
|
6110
|
+
* 快照装饰器
|
|
6111
|
+
*
|
|
6112
|
+
* 用于标记组件属性为可序列化
|
|
6113
|
+
*/
|
|
6114
|
+
declare function Serializable(config?: Partial<SnapshotConfig>): (target: any, propertyKey: string) => void;
|
|
6115
|
+
/**
|
|
6116
|
+
* 快照配置装饰器
|
|
6117
|
+
*
|
|
6118
|
+
* 用于配置组件的快照行为
|
|
6119
|
+
*/
|
|
6120
|
+
declare function SnapshotConfigDecorator(config: SnapshotConfig): (target: any) => void;
|
|
6121
|
+
/**
|
|
6122
|
+
* 快照扩展工具类
|
|
6123
|
+
*/
|
|
6124
|
+
declare class SnapshotExtension {
|
|
6125
|
+
/**
|
|
6126
|
+
* 为组件添加快照支持
|
|
6127
|
+
*
|
|
6128
|
+
* @param component - 目标组件
|
|
6129
|
+
* @param config - 快照配置
|
|
6130
|
+
*/
|
|
6131
|
+
static enableSnapshot(component: Component, config?: Partial<SnapshotConfig>): void;
|
|
6132
|
+
/**
|
|
6133
|
+
* 禁用组件的快照功能
|
|
6134
|
+
*
|
|
6135
|
+
* @param component - 目标组件
|
|
6136
|
+
*/
|
|
6137
|
+
static disableSnapshot(component: Component): void;
|
|
6138
|
+
/**
|
|
6139
|
+
* 检查组件是否支持快照
|
|
6140
|
+
*
|
|
6141
|
+
* @param component - 目标组件
|
|
6142
|
+
* @returns 是否支持快照
|
|
6143
|
+
*/
|
|
6144
|
+
static isSnapshotable(component: Component): boolean;
|
|
6145
|
+
/**
|
|
6146
|
+
* 获取组件的可序列化属性
|
|
6147
|
+
*
|
|
6148
|
+
* @param component - 目标组件
|
|
6149
|
+
* @returns 可序列化属性列表
|
|
6150
|
+
*/
|
|
6151
|
+
static getSerializableProperties(component: Component): string[];
|
|
6152
|
+
/**
|
|
6153
|
+
* 创建组件的默认序列化方法
|
|
6154
|
+
*
|
|
6155
|
+
* @param component - 目标组件
|
|
6156
|
+
* @returns 序列化数据
|
|
6157
|
+
*/
|
|
6158
|
+
static createDefaultSerializer(component: Component): () => any;
|
|
6159
|
+
/**
|
|
6160
|
+
* 创建组件的默认反序列化方法
|
|
6161
|
+
*
|
|
6162
|
+
* @param component - 目标组件
|
|
6163
|
+
* @returns 反序列化函数
|
|
6164
|
+
*/
|
|
6165
|
+
static createDefaultDeserializer(component: Component): (data: any) => void;
|
|
6166
|
+
/**
|
|
6167
|
+
* 创建简单的变化检测方法
|
|
6168
|
+
*
|
|
6169
|
+
* @param component - 目标组件
|
|
6170
|
+
* @returns 变化检测函数
|
|
6171
|
+
*/
|
|
6172
|
+
static createSimpleChangeDetector(component: Component): (baseData: any) => boolean;
|
|
6173
|
+
/**
|
|
6174
|
+
* 创建深度变化检测方法
|
|
6175
|
+
*
|
|
6176
|
+
* @param component - 目标组件
|
|
6177
|
+
* @returns 变化检测函数
|
|
6178
|
+
*/
|
|
6179
|
+
static createDeepChangeDetector(component: Component): (baseData: any) => boolean;
|
|
6180
|
+
/**
|
|
6181
|
+
* 深度比较两个值
|
|
6182
|
+
*/
|
|
6183
|
+
private static deepCompare;
|
|
6184
|
+
}
|
|
6185
|
+
|
|
6186
|
+
export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentDataCollector, ComponentIndexManager, ComponentPool, ComponentPoolManager, ComponentStorage, ComponentTypeManager, Core, DebugManager, DirtyFlag, DirtyTrackingSystem, ECSEventType, ECSFluentAPI, EVENT_TYPES, Emitter, Entity, EntityDataCollector, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, FuncPack, GlobalEventBus, GlobalManager, HashComponentIndex, IdentifierPool, IndexType, IndexUpdateBatcher, IntervalSystem, Matcher, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, SceneDataCollector, Serializable, SnapshotConfigDecorator, SnapshotExtension, SnapshotManager, SystemDataCollector, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, WebSocketManager, createECSAPI };
|
|
6187
|
+
export type { Archetype, ArchetypeQueryResult, ComponentSnapshot, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EntitySnapshot, EventListenerConfig, EventStats, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEventBus, IEventData, IEventListenerConfig, IEventStats, IPerformanceDebugData, IPerformanceEventData, IPoolable, ISceneDebugData, ISceneEventData, ISnapshotExtension, ISnapshotable, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats, SceneSnapshot, SnapshotConfig };
|