@esengine/ecs-framework 2.1.26 → 2.1.28
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 +1 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +411 -130
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @esengine/ecs-framework v2.1.
|
|
2
|
+
* @esengine/ecs-framework v2.1.28
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -1119,6 +1119,106 @@ declare abstract class Component implements IComponent {
|
|
|
1119
1119
|
update(): void;
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* BigInt兼容性抽象层
|
|
1124
|
+
*
|
|
1125
|
+
* 为不支持BigInt的环境提供兼容实现,确保ECS框架在所有平台上都能正常运行。
|
|
1126
|
+
* 自动检测运行时环境的BigInt支持情况,并提供统一的接口。
|
|
1127
|
+
*
|
|
1128
|
+
* @example
|
|
1129
|
+
* ```typescript
|
|
1130
|
+
* // 创建兼容的BigInt值
|
|
1131
|
+
* const value = BigIntFactory.create(123);
|
|
1132
|
+
*
|
|
1133
|
+
* // 位运算
|
|
1134
|
+
* const result = value.or(BigIntFactory.create(456));
|
|
1135
|
+
*
|
|
1136
|
+
* // 检查兼容性
|
|
1137
|
+
* console.log(BigIntFactory.isNativeSupported()); // true/false
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
/**
|
|
1141
|
+
* BigInt兼容接口
|
|
1142
|
+
*
|
|
1143
|
+
* 定义了BigInt的基本操作接口,支持原生BigInt和兼容实现的统一调用。
|
|
1144
|
+
*/
|
|
1145
|
+
interface IBigIntLike {
|
|
1146
|
+
/**
|
|
1147
|
+
* 获取数值表示
|
|
1148
|
+
* @returns 数值
|
|
1149
|
+
*/
|
|
1150
|
+
valueOf(): number;
|
|
1151
|
+
/**
|
|
1152
|
+
* 转换为字符串
|
|
1153
|
+
* @param radix 进制,支持2、10、16
|
|
1154
|
+
* @returns 字符串表示
|
|
1155
|
+
*/
|
|
1156
|
+
toString(radix?: number): string;
|
|
1157
|
+
/**
|
|
1158
|
+
* 位运算:与
|
|
1159
|
+
* @param other 另一个BigInt值
|
|
1160
|
+
* @returns 运算结果
|
|
1161
|
+
*/
|
|
1162
|
+
and(other: IBigIntLike): IBigIntLike;
|
|
1163
|
+
/**
|
|
1164
|
+
* 位运算:或
|
|
1165
|
+
* @param other 另一个BigInt值
|
|
1166
|
+
* @returns 运算结果
|
|
1167
|
+
*/
|
|
1168
|
+
or(other: IBigIntLike): IBigIntLike;
|
|
1169
|
+
/**
|
|
1170
|
+
* 位运算:异或
|
|
1171
|
+
* @param other 另一个BigInt值
|
|
1172
|
+
* @returns 运算结果
|
|
1173
|
+
*/
|
|
1174
|
+
xor(other: IBigIntLike): IBigIntLike;
|
|
1175
|
+
/**
|
|
1176
|
+
* 位运算:非
|
|
1177
|
+
* @param maxBits 最大位数限制
|
|
1178
|
+
* @returns 运算结果
|
|
1179
|
+
*/
|
|
1180
|
+
not(maxBits?: number): IBigIntLike;
|
|
1181
|
+
/**
|
|
1182
|
+
* 左移位运算
|
|
1183
|
+
* @param bits 移位数
|
|
1184
|
+
* @returns 运算结果
|
|
1185
|
+
*/
|
|
1186
|
+
shiftLeft(bits: number): IBigIntLike;
|
|
1187
|
+
/**
|
|
1188
|
+
* 右移位运算
|
|
1189
|
+
* @param bits 移位数
|
|
1190
|
+
* @returns 运算结果
|
|
1191
|
+
*/
|
|
1192
|
+
shiftRight(bits: number): IBigIntLike;
|
|
1193
|
+
/**
|
|
1194
|
+
* 相等比较
|
|
1195
|
+
* @param other 另一个BigInt值
|
|
1196
|
+
* @returns 是否相等
|
|
1197
|
+
*/
|
|
1198
|
+
equals(other: IBigIntLike): boolean;
|
|
1199
|
+
/**
|
|
1200
|
+
* 检查是否为零
|
|
1201
|
+
* @returns 是否为零
|
|
1202
|
+
*/
|
|
1203
|
+
isZero(): boolean;
|
|
1204
|
+
/**
|
|
1205
|
+
* 创建副本
|
|
1206
|
+
* @returns 新的实例
|
|
1207
|
+
*/
|
|
1208
|
+
clone(): IBigIntLike;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* 环境信息接口
|
|
1212
|
+
*/
|
|
1213
|
+
interface EnvironmentInfo {
|
|
1214
|
+
/** 是否支持BigInt */
|
|
1215
|
+
supportsBigInt: boolean;
|
|
1216
|
+
/** 运行环境 */
|
|
1217
|
+
environment: string;
|
|
1218
|
+
/** JavaScript引擎 */
|
|
1219
|
+
jsEngine: string;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1122
1222
|
/**
|
|
1123
1223
|
* 组件类型定义
|
|
1124
1224
|
*/
|
|
@@ -1247,7 +1347,7 @@ declare class ComponentStorageManager {
|
|
|
1247
1347
|
* @param entityId 实体ID
|
|
1248
1348
|
* @returns 组件位掩码
|
|
1249
1349
|
*/
|
|
1250
|
-
getComponentMask(entityId: number):
|
|
1350
|
+
getComponentMask(entityId: number): IBigIntLike;
|
|
1251
1351
|
/**
|
|
1252
1352
|
* 压缩所有存储器
|
|
1253
1353
|
*/
|
|
@@ -1493,37 +1593,6 @@ declare class EntityComparer {
|
|
|
1493
1593
|
*/
|
|
1494
1594
|
compare(self: Entity, other: Entity): number;
|
|
1495
1595
|
}
|
|
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
1596
|
/**
|
|
1528
1597
|
* 游戏实体类
|
|
1529
1598
|
*
|
|
@@ -1644,18 +1713,6 @@ declare class Entity {
|
|
|
1644
1713
|
* 用于快速定位组件在数组中的位置。
|
|
1645
1714
|
*/
|
|
1646
1715
|
private _componentTypeToIndex;
|
|
1647
|
-
/**
|
|
1648
|
-
* 组件缓存
|
|
1649
|
-
*
|
|
1650
|
-
* 高性能组件访问缓存。
|
|
1651
|
-
*/
|
|
1652
|
-
private _componentCache;
|
|
1653
|
-
/**
|
|
1654
|
-
* 组件访问统计
|
|
1655
|
-
*
|
|
1656
|
-
* 记录组件访问的性能统计信息。
|
|
1657
|
-
*/
|
|
1658
|
-
private _componentAccessStats;
|
|
1659
1716
|
/**
|
|
1660
1717
|
* 构造函数
|
|
1661
1718
|
*
|
|
@@ -1750,7 +1807,7 @@ declare class Entity {
|
|
|
1750
1807
|
*
|
|
1751
1808
|
* @returns 实体的组件位掩码
|
|
1752
1809
|
*/
|
|
1753
|
-
get componentMask():
|
|
1810
|
+
get componentMask(): IBigIntLike;
|
|
1754
1811
|
/**
|
|
1755
1812
|
* 创建并添加组件
|
|
1756
1813
|
*
|
|
@@ -1781,24 +1838,6 @@ declare class Entity {
|
|
|
1781
1838
|
* @returns 组件实例或null
|
|
1782
1839
|
*/
|
|
1783
1840
|
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
1841
|
/**
|
|
1803
1842
|
* 重建组件索引映射
|
|
1804
1843
|
*/
|
|
@@ -1849,35 +1888,6 @@ declare class Entity {
|
|
|
1849
1888
|
* @returns 被移除的组件数组
|
|
1850
1889
|
*/
|
|
1851
1890
|
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
1891
|
/**
|
|
1882
1892
|
* 获取所有指定类型的组件
|
|
1883
1893
|
*
|
|
@@ -2000,20 +2010,6 @@ declare class Entity {
|
|
|
2000
2010
|
childCount: number;
|
|
2001
2011
|
childIds: number[];
|
|
2002
2012
|
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
2013
|
indexMappingSize: number;
|
|
2018
2014
|
};
|
|
2019
2015
|
}
|
|
@@ -2126,33 +2122,60 @@ declare class EntityList {
|
|
|
2126
2122
|
|
|
2127
2123
|
/**
|
|
2128
2124
|
* 高性能位操作类
|
|
2129
|
-
*
|
|
2125
|
+
*
|
|
2126
|
+
* 基于BigInt实现,支持任意数量的位操作。
|
|
2127
|
+
* 自动适配运行环境,在不支持BigInt的环境中使用兼容实现。
|
|
2128
|
+
*
|
|
2129
|
+
* @example
|
|
2130
|
+
* ```typescript
|
|
2131
|
+
* const bits = new Bits();
|
|
2132
|
+
* bits.set(0);
|
|
2133
|
+
* bits.set(5);
|
|
2134
|
+
* console.log(bits.get(0)); // true
|
|
2135
|
+
* console.log(bits.get(1)); // false
|
|
2136
|
+
* ```
|
|
2130
2137
|
*/
|
|
2131
2138
|
declare class Bits {
|
|
2132
2139
|
private _value;
|
|
2133
|
-
|
|
2140
|
+
/**
|
|
2141
|
+
* 构造函数
|
|
2142
|
+
* @param initialValue 初始值,可以是IBigIntLike或数值
|
|
2143
|
+
*/
|
|
2144
|
+
constructor(initialValue?: IBigIntLike | number | string);
|
|
2134
2145
|
/**
|
|
2135
2146
|
* 设置指定位置的位为1
|
|
2147
|
+
* @param index 位索引(从0开始)
|
|
2148
|
+
* @throws {Error} 当索引为负数时抛出错误
|
|
2136
2149
|
*/
|
|
2137
2150
|
set(index: number): void;
|
|
2138
2151
|
/**
|
|
2139
2152
|
* 清除指定位置的位(设为0)
|
|
2153
|
+
* @param index 位索引(从0开始)
|
|
2154
|
+
* @throws {Error} 当索引为负数时抛出错误
|
|
2140
2155
|
*/
|
|
2141
2156
|
clear(index: number): void;
|
|
2142
2157
|
/**
|
|
2143
2158
|
* 获取指定位置的位值
|
|
2159
|
+
* @param index 位索引(从0开始)
|
|
2160
|
+
* @returns 位值(true表示1,false表示0)
|
|
2144
2161
|
*/
|
|
2145
2162
|
get(index: number): boolean;
|
|
2146
2163
|
/**
|
|
2147
2164
|
* 检查是否包含所有指定的位
|
|
2165
|
+
* @param other 另一个Bits对象
|
|
2166
|
+
* @returns 是否包含所有指定的位
|
|
2148
2167
|
*/
|
|
2149
2168
|
containsAll(other: Bits): boolean;
|
|
2150
2169
|
/**
|
|
2151
2170
|
* 检查是否包含任意一个指定的位
|
|
2171
|
+
* @param other 另一个Bits对象
|
|
2172
|
+
* @returns 是否包含任意一个指定的位
|
|
2152
2173
|
*/
|
|
2153
2174
|
intersects(other: Bits): boolean;
|
|
2154
2175
|
/**
|
|
2155
2176
|
* 检查是否不包含任何指定的位
|
|
2177
|
+
* @param other 另一个Bits对象
|
|
2178
|
+
* @returns 是否不包含任何指定的位
|
|
2156
2179
|
*/
|
|
2157
2180
|
excludes(other: Bits): boolean;
|
|
2158
2181
|
/**
|
|
@@ -2161,74 +2184,100 @@ declare class Bits {
|
|
|
2161
2184
|
clearAll(): void;
|
|
2162
2185
|
/**
|
|
2163
2186
|
* 检查是否为空(没有设置任何位)
|
|
2187
|
+
* @returns 是否为空
|
|
2164
2188
|
*/
|
|
2165
2189
|
isEmpty(): boolean;
|
|
2166
2190
|
/**
|
|
2167
2191
|
* 获取设置的位数量
|
|
2192
|
+
* @returns 设置为1的位数量
|
|
2168
2193
|
*/
|
|
2169
2194
|
cardinality(): number;
|
|
2170
2195
|
/**
|
|
2171
2196
|
* 位运算:与
|
|
2197
|
+
* @param other 另一个Bits对象
|
|
2198
|
+
* @returns 新的Bits对象,包含与运算结果
|
|
2172
2199
|
*/
|
|
2173
2200
|
and(other: Bits): Bits;
|
|
2174
2201
|
/**
|
|
2175
2202
|
* 位运算:或
|
|
2203
|
+
* @param other 另一个Bits对象
|
|
2204
|
+
* @returns 新的Bits对象,包含或运算结果
|
|
2176
2205
|
*/
|
|
2177
2206
|
or(other: Bits): Bits;
|
|
2178
2207
|
/**
|
|
2179
2208
|
* 位运算:异或
|
|
2209
|
+
* @param other 另一个Bits对象
|
|
2210
|
+
* @returns 新的Bits对象,包含异或运算结果
|
|
2180
2211
|
*/
|
|
2181
2212
|
xor(other: Bits): Bits;
|
|
2182
2213
|
/**
|
|
2183
2214
|
* 位运算:非
|
|
2215
|
+
* @param maxBits 最大位数限制,默认64位
|
|
2216
|
+
* @returns 新的Bits对象,包含非运算结果
|
|
2184
2217
|
*/
|
|
2185
2218
|
not(maxBits?: number): Bits;
|
|
2186
2219
|
/**
|
|
2187
2220
|
* 复制另一个Bits对象
|
|
2221
|
+
* @param other 要复制的Bits对象
|
|
2188
2222
|
*/
|
|
2189
2223
|
copyFrom(other: Bits): void;
|
|
2190
2224
|
/**
|
|
2191
2225
|
* 创建当前Bits的副本
|
|
2226
|
+
* @returns 新的Bits对象副本
|
|
2192
2227
|
*/
|
|
2193
2228
|
clone(): Bits;
|
|
2194
2229
|
/**
|
|
2195
|
-
*
|
|
2230
|
+
* 获取原始值
|
|
2231
|
+
* @returns 原始的IBigIntLike值
|
|
2196
2232
|
*/
|
|
2197
|
-
getValue():
|
|
2233
|
+
getValue(): IBigIntLike;
|
|
2198
2234
|
/**
|
|
2199
|
-
*
|
|
2235
|
+
* 设置原始值
|
|
2236
|
+
* @param value 新的值,可以是IBigIntLike或数值
|
|
2200
2237
|
*/
|
|
2201
|
-
setValue(value:
|
|
2238
|
+
setValue(value: IBigIntLike | number | string): void;
|
|
2202
2239
|
/**
|
|
2203
2240
|
* 获取调试信息
|
|
2241
|
+
* @returns 返回显示设置位索引的字符串
|
|
2204
2242
|
*/
|
|
2205
2243
|
toString(): string;
|
|
2206
2244
|
/**
|
|
2207
2245
|
* 获取二进制表示
|
|
2246
|
+
* @param maxBits 最大位数,默认64位
|
|
2247
|
+
* @returns 二进制字符串表示
|
|
2208
2248
|
*/
|
|
2209
2249
|
toBinaryString(maxBits?: number): string;
|
|
2210
2250
|
/**
|
|
2211
2251
|
* 获取十六进制表示
|
|
2252
|
+
* @returns 十六进制字符串表示
|
|
2212
2253
|
*/
|
|
2213
2254
|
toHexString(): string;
|
|
2214
2255
|
/**
|
|
2215
2256
|
* 从二进制字符串创建Bits
|
|
2257
|
+
* @param binaryString 二进制字符串
|
|
2258
|
+
* @returns 新的Bits对象
|
|
2216
2259
|
*/
|
|
2217
2260
|
static fromBinaryString(binaryString: string): Bits;
|
|
2218
2261
|
/**
|
|
2219
2262
|
* 从十六进制字符串创建Bits
|
|
2263
|
+
* @param hexString 十六进制字符串
|
|
2264
|
+
* @returns 新的Bits对象
|
|
2220
2265
|
*/
|
|
2221
2266
|
static fromHexString(hexString: string): Bits;
|
|
2222
2267
|
/**
|
|
2223
2268
|
* 比较两个Bits对象是否相等
|
|
2269
|
+
* @param other 另一个Bits对象
|
|
2270
|
+
* @returns 是否相等
|
|
2224
2271
|
*/
|
|
2225
2272
|
equals(other: Bits): boolean;
|
|
2226
2273
|
/**
|
|
2227
2274
|
* 获取最高位的索引
|
|
2275
|
+
* @returns 最高位的索引,如果为空则返回-1
|
|
2228
2276
|
*/
|
|
2229
2277
|
getHighestBitIndex(): number;
|
|
2230
2278
|
/**
|
|
2231
2279
|
* 获取最低位的索引
|
|
2280
|
+
* @returns 最低位的索引,如果为空则返回-1
|
|
2232
2281
|
*/
|
|
2233
2282
|
getLowestBitIndex(): number;
|
|
2234
2283
|
}
|
|
@@ -2348,8 +2397,8 @@ declare abstract class EntitySystem implements ISystemBase {
|
|
|
2348
2397
|
/**
|
|
2349
2398
|
* 这个系统所属的场景
|
|
2350
2399
|
*/
|
|
2351
|
-
get scene(): Scene;
|
|
2352
|
-
set scene(value: Scene);
|
|
2400
|
+
get scene(): Scene | null;
|
|
2401
|
+
set scene(value: Scene | null);
|
|
2353
2402
|
private _matcher;
|
|
2354
2403
|
/**
|
|
2355
2404
|
* 获取实体匹配器
|
|
@@ -2529,21 +2578,206 @@ declare class EntityProcessorList {
|
|
|
2529
2578
|
}
|
|
2530
2579
|
|
|
2531
2580
|
/**
|
|
2532
|
-
* ID池管理器
|
|
2533
|
-
*
|
|
2581
|
+
* 世代式ID池管理器
|
|
2582
|
+
*
|
|
2583
|
+
* 用于管理实体ID的分配和回收,支持世代版本控制以防止悬空引用问题。
|
|
2584
|
+
* 世代式ID由索引和版本组成,当ID被回收时版本会递增,确保旧引用失效。
|
|
2585
|
+
*
|
|
2586
|
+
* 支持动态扩展,理论上可以支持到65535个索引(16位),每个索引65535个版本(16位)。
|
|
2587
|
+
* 总计可以处理超过42亿个独特的ID组合,完全满足ECS大规模实体需求。
|
|
2588
|
+
*
|
|
2589
|
+
* @example
|
|
2590
|
+
* ```typescript
|
|
2591
|
+
* const pool = new IdentifierPool();
|
|
2592
|
+
*
|
|
2593
|
+
* // 分配ID
|
|
2594
|
+
* const id = pool.checkOut(); // 例如: 65536 (版本1,索引0)
|
|
2595
|
+
*
|
|
2596
|
+
* // 回收ID
|
|
2597
|
+
* pool.checkIn(id);
|
|
2598
|
+
*
|
|
2599
|
+
* // 验证ID是否有效
|
|
2600
|
+
* const isValid = pool.isValid(id); // false,因为版本已递增
|
|
2601
|
+
* ```
|
|
2534
2602
|
*/
|
|
2535
2603
|
declare class IdentifierPool {
|
|
2536
|
-
|
|
2537
|
-
|
|
2604
|
+
/**
|
|
2605
|
+
* 下一个可用的索引
|
|
2606
|
+
*/
|
|
2607
|
+
private _nextAvailableIndex;
|
|
2608
|
+
/**
|
|
2609
|
+
* 空闲的索引列表
|
|
2610
|
+
*/
|
|
2611
|
+
private _freeIndices;
|
|
2612
|
+
/**
|
|
2613
|
+
* 每个索引对应的世代版本
|
|
2614
|
+
* 动态扩展的Map,按需分配内存
|
|
2615
|
+
*/
|
|
2616
|
+
private _generations;
|
|
2617
|
+
/**
|
|
2618
|
+
* 延迟回收队列
|
|
2619
|
+
* 防止在同一帧内立即重用ID,避免时序问题
|
|
2620
|
+
*/
|
|
2621
|
+
private _pendingRecycle;
|
|
2622
|
+
/**
|
|
2623
|
+
* 延迟回收时间(毫秒)
|
|
2624
|
+
*/
|
|
2625
|
+
private _recycleDelay;
|
|
2626
|
+
/**
|
|
2627
|
+
* 最大索引限制(16位)
|
|
2628
|
+
* 这是框架设计选择:16位索引 + 16位版本 = 32位ID,确保高效位操作
|
|
2629
|
+
* 不是硬件限制,而是性能和内存效率的权衡
|
|
2630
|
+
*/
|
|
2631
|
+
private static readonly MAX_INDEX;
|
|
2632
|
+
/**
|
|
2633
|
+
* 最大世代限制(16位)
|
|
2634
|
+
*/
|
|
2635
|
+
private static readonly MAX_GENERATION;
|
|
2636
|
+
/**
|
|
2637
|
+
* 内存扩展块大小
|
|
2638
|
+
* 当需要更多内存时,一次性预分配的索引数量
|
|
2639
|
+
*/
|
|
2640
|
+
private _expansionBlockSize;
|
|
2641
|
+
/**
|
|
2642
|
+
* 统计信息
|
|
2643
|
+
*/
|
|
2644
|
+
private _stats;
|
|
2645
|
+
/**
|
|
2646
|
+
* 构造函数
|
|
2647
|
+
*
|
|
2648
|
+
* @param recycleDelay 延迟回收时间(毫秒),默认为100ms
|
|
2649
|
+
* @param expansionBlockSize 内存扩展块大小,默认为1024
|
|
2650
|
+
*/
|
|
2651
|
+
constructor(recycleDelay?: number, expansionBlockSize?: number);
|
|
2538
2652
|
/**
|
|
2539
2653
|
* 获取一个可用的ID
|
|
2654
|
+
*
|
|
2655
|
+
* 返回一个32位ID,高16位为世代版本,低16位为索引。
|
|
2656
|
+
*
|
|
2657
|
+
* @returns 新分配的实体ID
|
|
2658
|
+
* @throws {Error} 当达到索引限制时抛出错误
|
|
2540
2659
|
*/
|
|
2541
2660
|
checkOut(): number;
|
|
2542
2661
|
/**
|
|
2543
2662
|
* 回收一个ID
|
|
2544
|
-
*
|
|
2663
|
+
*
|
|
2664
|
+
* 验证ID的有效性后,将其加入延迟回收队列。
|
|
2665
|
+
* ID不会立即可重用,而是在延迟时间后才真正回收。
|
|
2666
|
+
*
|
|
2667
|
+
* @param id 要回收的实体ID
|
|
2668
|
+
* @returns 是否成功回收(ID是否有效且未被重复回收)
|
|
2669
|
+
*/
|
|
2670
|
+
checkIn(id: number): boolean;
|
|
2671
|
+
/**
|
|
2672
|
+
* 验证ID是否有效
|
|
2673
|
+
*
|
|
2674
|
+
* 检查ID的索引和世代版本是否匹配当前状态。
|
|
2675
|
+
*
|
|
2676
|
+
* @param id 要验证的实体ID
|
|
2677
|
+
* @returns ID是否有效
|
|
2545
2678
|
*/
|
|
2546
|
-
|
|
2679
|
+
isValid(id: number): boolean;
|
|
2680
|
+
/**
|
|
2681
|
+
* 获取统计信息
|
|
2682
|
+
*
|
|
2683
|
+
* @returns 池的当前状态统计
|
|
2684
|
+
*/
|
|
2685
|
+
getStats(): {
|
|
2686
|
+
/** 已分配的总索引数 */
|
|
2687
|
+
totalAllocated: number;
|
|
2688
|
+
/** 总计回收次数 */
|
|
2689
|
+
totalRecycled: number;
|
|
2690
|
+
/** 当前活跃实体数 */
|
|
2691
|
+
currentActive: number;
|
|
2692
|
+
/** 当前空闲的索引数 */
|
|
2693
|
+
currentlyFree: number;
|
|
2694
|
+
/** 等待回收的ID数 */
|
|
2695
|
+
pendingRecycle: number;
|
|
2696
|
+
/** 理论最大实体数(设计限制) */
|
|
2697
|
+
maxPossibleEntities: number;
|
|
2698
|
+
/** 当前使用的最大索引 */
|
|
2699
|
+
maxUsedIndex: number;
|
|
2700
|
+
/** 内存使用(字节) */
|
|
2701
|
+
memoryUsage: number;
|
|
2702
|
+
/** 内存扩展次数 */
|
|
2703
|
+
memoryExpansions: number;
|
|
2704
|
+
/** 平均世代版本 */
|
|
2705
|
+
averageGeneration: number;
|
|
2706
|
+
/** 世代存储大小 */
|
|
2707
|
+
generationStorageSize: number;
|
|
2708
|
+
};
|
|
2709
|
+
/**
|
|
2710
|
+
* 强制执行延迟回收处理
|
|
2711
|
+
*
|
|
2712
|
+
* 在某些情况下可能需要立即处理延迟回收队列,
|
|
2713
|
+
* 比如内存压力大或者需要精确的统计信息时。
|
|
2714
|
+
*/
|
|
2715
|
+
forceProcessDelayedRecycle(): void;
|
|
2716
|
+
/**
|
|
2717
|
+
* 清理过期的延迟回收项
|
|
2718
|
+
*
|
|
2719
|
+
* 将超过延迟时间的回收项真正回收到空闲列表中。
|
|
2720
|
+
*
|
|
2721
|
+
* @param forceAll 是否强制处理所有延迟回收项
|
|
2722
|
+
* @private
|
|
2723
|
+
*/
|
|
2724
|
+
private _processDelayedRecycle;
|
|
2725
|
+
/**
|
|
2726
|
+
* 预分配世代信息
|
|
2727
|
+
*
|
|
2728
|
+
* @param startIndex 起始索引
|
|
2729
|
+
* @param count 分配数量
|
|
2730
|
+
* @private
|
|
2731
|
+
*/
|
|
2732
|
+
private _preAllocateGenerations;
|
|
2733
|
+
/**
|
|
2734
|
+
* 确保指定索引的世代信息存在
|
|
2735
|
+
*
|
|
2736
|
+
* @param index 索引
|
|
2737
|
+
* @private
|
|
2738
|
+
*/
|
|
2739
|
+
private _ensureGenerationCapacity;
|
|
2740
|
+
/**
|
|
2741
|
+
* 计算内存使用量
|
|
2742
|
+
*
|
|
2743
|
+
* @returns 内存使用字节数
|
|
2744
|
+
* @private
|
|
2745
|
+
*/
|
|
2746
|
+
private _calculateMemoryUsage;
|
|
2747
|
+
/**
|
|
2748
|
+
* 打包索引和世代为32位ID
|
|
2749
|
+
*
|
|
2750
|
+
* @param index 索引(16位)
|
|
2751
|
+
* @param generation 世代版本(16位)
|
|
2752
|
+
* @returns 打包后的32位ID
|
|
2753
|
+
* @private
|
|
2754
|
+
*/
|
|
2755
|
+
private _packId;
|
|
2756
|
+
/**
|
|
2757
|
+
* 从ID中解包索引
|
|
2758
|
+
*
|
|
2759
|
+
* @param id 32位ID
|
|
2760
|
+
* @returns 索引部分(16位)
|
|
2761
|
+
* @private
|
|
2762
|
+
*/
|
|
2763
|
+
private _unpackIndex;
|
|
2764
|
+
/**
|
|
2765
|
+
* 从ID中解包世代版本
|
|
2766
|
+
*
|
|
2767
|
+
* @param id 32位ID
|
|
2768
|
+
* @returns 世代版本部分(16位)
|
|
2769
|
+
* @private
|
|
2770
|
+
*/
|
|
2771
|
+
private _unpackGeneration;
|
|
2772
|
+
/**
|
|
2773
|
+
* 内部ID有效性检查
|
|
2774
|
+
*
|
|
2775
|
+
* @param index 索引
|
|
2776
|
+
* @param generation 世代版本
|
|
2777
|
+
* @returns 是否有效
|
|
2778
|
+
* @private
|
|
2779
|
+
*/
|
|
2780
|
+
private _isValidId;
|
|
2547
2781
|
}
|
|
2548
2782
|
|
|
2549
2783
|
/**
|
|
@@ -4429,6 +4663,10 @@ declare class Core {
|
|
|
4429
4663
|
* Core配置
|
|
4430
4664
|
*/
|
|
4431
4665
|
private _config;
|
|
4666
|
+
/**
|
|
4667
|
+
* 兼容性信息
|
|
4668
|
+
*/
|
|
4669
|
+
private _environmentInfo;
|
|
4432
4670
|
/**
|
|
4433
4671
|
* 创建核心实例
|
|
4434
4672
|
*
|
|
@@ -4552,6 +4790,18 @@ declare class Core {
|
|
|
4552
4790
|
* @returns 调试状态
|
|
4553
4791
|
*/
|
|
4554
4792
|
static get isDebugEnabled(): boolean;
|
|
4793
|
+
/**
|
|
4794
|
+
* 获取环境兼容性信息
|
|
4795
|
+
*
|
|
4796
|
+
* @returns 环境兼容性信息
|
|
4797
|
+
*/
|
|
4798
|
+
static getEnvironmentInfo(): EnvironmentInfo | null;
|
|
4799
|
+
/**
|
|
4800
|
+
* 检查BigInt是否支持
|
|
4801
|
+
*
|
|
4802
|
+
* @returns 是否支持BigInt
|
|
4803
|
+
*/
|
|
4804
|
+
static get supportsBigInt(): boolean;
|
|
4555
4805
|
/**
|
|
4556
4806
|
* 场景切换回调
|
|
4557
4807
|
*
|
|
@@ -4564,6 +4814,12 @@ declare class Core {
|
|
|
4564
4814
|
* 执行核心系统的初始化逻辑。
|
|
4565
4815
|
*/
|
|
4566
4816
|
protected initialize(): void;
|
|
4817
|
+
/**
|
|
4818
|
+
* 记录兼容性信息
|
|
4819
|
+
*
|
|
4820
|
+
* 在控制台输出当前环境的兼容性信息和建议。
|
|
4821
|
+
*/
|
|
4822
|
+
private logCompatibilityInfo;
|
|
4567
4823
|
/**
|
|
4568
4824
|
* 内部更新方法
|
|
4569
4825
|
*
|
|
@@ -5519,6 +5775,8 @@ declare class IndexUpdateBatcher {
|
|
|
5519
5775
|
|
|
5520
5776
|
/**
|
|
5521
5777
|
* 位掩码优化器,用于预计算和缓存常用的组件掩码
|
|
5778
|
+
*
|
|
5779
|
+
* 使用BigInt兼容层确保在所有平台上的正常运行。
|
|
5522
5780
|
*/
|
|
5523
5781
|
declare class BitMaskOptimizer {
|
|
5524
5782
|
private static instance;
|
|
@@ -5537,32 +5795,51 @@ declare class BitMaskOptimizer {
|
|
|
5537
5795
|
getComponentTypeId(componentName: string): number | undefined;
|
|
5538
5796
|
/**
|
|
5539
5797
|
* 创建单个组件的掩码
|
|
5798
|
+
* @param componentName 组件名称
|
|
5799
|
+
* @returns 组件掩码
|
|
5540
5800
|
*/
|
|
5541
|
-
createSingleComponentMask(componentName: string):
|
|
5801
|
+
createSingleComponentMask(componentName: string): IBigIntLike;
|
|
5542
5802
|
/**
|
|
5543
5803
|
* 创建多个组件的组合掩码
|
|
5804
|
+
* @param componentNames 组件名称数组
|
|
5805
|
+
* @returns 组合掩码
|
|
5544
5806
|
*/
|
|
5545
|
-
createCombinedMask(componentNames: string[]):
|
|
5807
|
+
createCombinedMask(componentNames: string[]): IBigIntLike;
|
|
5546
5808
|
/**
|
|
5547
5809
|
* 检查掩码是否包含指定组件
|
|
5810
|
+
* @param mask 要检查的掩码
|
|
5811
|
+
* @param componentName 组件名称
|
|
5812
|
+
* @returns 是否包含指定组件
|
|
5548
5813
|
*/
|
|
5549
|
-
maskContainsComponent(mask:
|
|
5814
|
+
maskContainsComponent(mask: IBigIntLike, componentName: string): boolean;
|
|
5550
5815
|
/**
|
|
5551
5816
|
* 检查掩码是否包含所有指定组件
|
|
5817
|
+
* @param mask 要检查的掩码
|
|
5818
|
+
* @param componentNames 组件名称数组
|
|
5819
|
+
* @returns 是否包含所有指定组件
|
|
5552
5820
|
*/
|
|
5553
|
-
maskContainsAllComponents(mask:
|
|
5821
|
+
maskContainsAllComponents(mask: IBigIntLike, componentNames: string[]): boolean;
|
|
5554
5822
|
/**
|
|
5555
5823
|
* 检查掩码是否包含任一指定组件
|
|
5824
|
+
* @param mask 要检查的掩码
|
|
5825
|
+
* @param componentNames 组件名称数组
|
|
5826
|
+
* @returns 是否包含任一指定组件
|
|
5556
5827
|
*/
|
|
5557
|
-
maskContainsAnyComponent(mask:
|
|
5828
|
+
maskContainsAnyComponent(mask: IBigIntLike, componentNames: string[]): boolean;
|
|
5558
5829
|
/**
|
|
5559
5830
|
* 添加组件到掩码
|
|
5831
|
+
* @param mask 原始掩码
|
|
5832
|
+
* @param componentName 要添加的组件名称
|
|
5833
|
+
* @returns 新的掩码
|
|
5560
5834
|
*/
|
|
5561
|
-
addComponentToMask(mask:
|
|
5835
|
+
addComponentToMask(mask: IBigIntLike, componentName: string): IBigIntLike;
|
|
5562
5836
|
/**
|
|
5563
5837
|
* 从掩码中移除组件
|
|
5838
|
+
* @param mask 原始掩码
|
|
5839
|
+
* @param componentName 要移除的组件名称
|
|
5840
|
+
* @returns 新的掩码
|
|
5564
5841
|
*/
|
|
5565
|
-
removeComponentFromMask(mask:
|
|
5842
|
+
removeComponentFromMask(mask: IBigIntLike, componentName: string): IBigIntLike;
|
|
5566
5843
|
/**
|
|
5567
5844
|
* 预计算常用掩码组合
|
|
5568
5845
|
*/
|
|
@@ -5585,11 +5862,11 @@ declare class BitMaskOptimizer {
|
|
|
5585
5862
|
/**
|
|
5586
5863
|
* 将掩码转换为组件名称数组
|
|
5587
5864
|
*/
|
|
5588
|
-
maskToComponentNames(mask:
|
|
5865
|
+
maskToComponentNames(mask: IBigIntLike): string[];
|
|
5589
5866
|
/**
|
|
5590
5867
|
* 获取掩码中组件的数量
|
|
5591
5868
|
*/
|
|
5592
|
-
getComponentCount(mask:
|
|
5869
|
+
getComponentCount(mask: IBigIntLike): number;
|
|
5593
5870
|
}
|
|
5594
5871
|
|
|
5595
5872
|
/**
|
|
@@ -5654,6 +5931,10 @@ declare class ComponentPoolManager {
|
|
|
5654
5931
|
* 清空所有池
|
|
5655
5932
|
*/
|
|
5656
5933
|
clearAll(): void;
|
|
5934
|
+
/**
|
|
5935
|
+
* 重置管理器,移除所有注册的池
|
|
5936
|
+
*/
|
|
5937
|
+
reset(): void;
|
|
5657
5938
|
/**
|
|
5658
5939
|
* 获取池统计信息
|
|
5659
5940
|
*/
|