@esengine/ecs-framework 2.2.17 → 2.2.18
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.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +2463 -1607
- package/index.es5.js +2 -2
- package/index.es5.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/index.umd.js +2 -2
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @esengine/ecs-framework v2.2.
|
|
2
|
+
* @esengine/ecs-framework v2.2.18
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -468,8 +468,6 @@ interface IECSDebugConfig {
|
|
|
468
468
|
interface ICoreConfig {
|
|
469
469
|
/** 是否启用调试模式 */
|
|
470
470
|
debug?: boolean;
|
|
471
|
-
/** 是否启用实体系统 */
|
|
472
|
-
enableEntitySystems?: boolean;
|
|
473
471
|
/** 调试配置 */
|
|
474
472
|
debugConfig?: IECSDebugConfig;
|
|
475
473
|
/** WorldManager配置 */
|
|
@@ -4349,6 +4347,147 @@ declare class ComponentSerializer {
|
|
|
4349
4347
|
} | null;
|
|
4350
4348
|
}
|
|
4351
4349
|
|
|
4350
|
+
/**
|
|
4351
|
+
* 层级关系系统 - 管理实体间的父子关系
|
|
4352
|
+
*
|
|
4353
|
+
* 提供层级操作的统一 API,维护层级缓存(depth、activeInHierarchy)。
|
|
4354
|
+
* 所有层级操作应通过此系统进行,而非直接修改 HierarchyComponent。
|
|
4355
|
+
*
|
|
4356
|
+
* @example
|
|
4357
|
+
* ```typescript
|
|
4358
|
+
* const hierarchySystem = scene.getSystem(HierarchySystem);
|
|
4359
|
+
*
|
|
4360
|
+
* // 设置父子关系
|
|
4361
|
+
* hierarchySystem.setParent(child, parent);
|
|
4362
|
+
*
|
|
4363
|
+
* // 查询层级
|
|
4364
|
+
* const parent = hierarchySystem.getParent(entity);
|
|
4365
|
+
* const children = hierarchySystem.getChildren(entity);
|
|
4366
|
+
* const depth = hierarchySystem.getDepth(entity);
|
|
4367
|
+
* ```
|
|
4368
|
+
*/
|
|
4369
|
+
declare class HierarchySystem extends EntitySystem {
|
|
4370
|
+
private static readonly MAX_DEPTH;
|
|
4371
|
+
constructor();
|
|
4372
|
+
/**
|
|
4373
|
+
* 系统优先级,确保在其他系统之前更新层级缓存
|
|
4374
|
+
*/
|
|
4375
|
+
get updateOrder(): number;
|
|
4376
|
+
protected process(): void;
|
|
4377
|
+
/**
|
|
4378
|
+
* 设置实体的父级
|
|
4379
|
+
*
|
|
4380
|
+
* @param child - 子实体
|
|
4381
|
+
* @param parent - 父实体,null 表示移动到根级
|
|
4382
|
+
*/
|
|
4383
|
+
setParent(child: Entity, parent: Entity | null): void;
|
|
4384
|
+
/**
|
|
4385
|
+
* 在指定位置插入子实体
|
|
4386
|
+
*
|
|
4387
|
+
* @param parent - 父实体
|
|
4388
|
+
* @param child - 子实体
|
|
4389
|
+
* @param index - 插入位置索引,-1 表示追加到末尾
|
|
4390
|
+
*/
|
|
4391
|
+
insertChildAt(parent: Entity, child: Entity, index: number): void;
|
|
4392
|
+
/**
|
|
4393
|
+
* 移除子实体(将其移动到根级)
|
|
4394
|
+
*/
|
|
4395
|
+
removeChild(parent: Entity, child: Entity): boolean;
|
|
4396
|
+
/**
|
|
4397
|
+
* 移除所有子实体
|
|
4398
|
+
*/
|
|
4399
|
+
removeAllChildren(parent: Entity): void;
|
|
4400
|
+
/**
|
|
4401
|
+
* 获取实体的父级
|
|
4402
|
+
*/
|
|
4403
|
+
getParent(entity: Entity): Entity | null;
|
|
4404
|
+
/**
|
|
4405
|
+
* 获取实体的子级列表
|
|
4406
|
+
*/
|
|
4407
|
+
getChildren(entity: Entity): Entity[];
|
|
4408
|
+
/**
|
|
4409
|
+
* 获取子级数量
|
|
4410
|
+
*/
|
|
4411
|
+
getChildCount(entity: Entity): number;
|
|
4412
|
+
/**
|
|
4413
|
+
* 检查实体是否有子级
|
|
4414
|
+
*/
|
|
4415
|
+
hasChildren(entity: Entity): boolean;
|
|
4416
|
+
/**
|
|
4417
|
+
* 检查 ancestor 是否是 entity 的祖先
|
|
4418
|
+
*/
|
|
4419
|
+
isAncestorOf(ancestor: Entity, entity: Entity): boolean;
|
|
4420
|
+
/**
|
|
4421
|
+
* 检查 descendant 是否是 entity 的后代
|
|
4422
|
+
*/
|
|
4423
|
+
isDescendantOf(descendant: Entity, entity: Entity): boolean;
|
|
4424
|
+
/**
|
|
4425
|
+
* 获取根实体
|
|
4426
|
+
*/
|
|
4427
|
+
getRoot(entity: Entity): Entity;
|
|
4428
|
+
/**
|
|
4429
|
+
* 获取实体在层级中的深度
|
|
4430
|
+
*/
|
|
4431
|
+
getDepth(entity: Entity): number;
|
|
4432
|
+
/**
|
|
4433
|
+
* 检查实体在层级中是否激活
|
|
4434
|
+
*/
|
|
4435
|
+
isActiveInHierarchy(entity: Entity): boolean;
|
|
4436
|
+
/**
|
|
4437
|
+
* 获取所有根实体(没有父级的实体)
|
|
4438
|
+
*/
|
|
4439
|
+
getRootEntities(): Entity[];
|
|
4440
|
+
/**
|
|
4441
|
+
* 根据名称查找子实体
|
|
4442
|
+
*
|
|
4443
|
+
* @param entity - 父实体
|
|
4444
|
+
* @param name - 子实体名称
|
|
4445
|
+
* @param bRecursive - 是否递归查找
|
|
4446
|
+
*/
|
|
4447
|
+
findChild(entity: Entity, name: string, bRecursive?: boolean): Entity | null;
|
|
4448
|
+
/**
|
|
4449
|
+
* 根据标签查找子实体
|
|
4450
|
+
*
|
|
4451
|
+
* @param entity - 父实体
|
|
4452
|
+
* @param tag - 标签值
|
|
4453
|
+
* @param bRecursive - 是否递归查找
|
|
4454
|
+
*/
|
|
4455
|
+
findChildrenByTag(entity: Entity, tag: number, bRecursive?: boolean): Entity[];
|
|
4456
|
+
/**
|
|
4457
|
+
* 遍历所有子级
|
|
4458
|
+
*
|
|
4459
|
+
* @param entity - 父实体
|
|
4460
|
+
* @param callback - 回调函数
|
|
4461
|
+
* @param bRecursive - 是否递归遍历
|
|
4462
|
+
*/
|
|
4463
|
+
forEachChild(entity: Entity, callback: (child: Entity) => void, bRecursive?: boolean): void;
|
|
4464
|
+
/**
|
|
4465
|
+
* 扁平化层级树(用于虚拟化渲染)
|
|
4466
|
+
*
|
|
4467
|
+
* @param expandedIds - 展开的实体 ID 集合
|
|
4468
|
+
* @returns 扁平化的节点列表
|
|
4469
|
+
*/
|
|
4470
|
+
flattenHierarchy(expandedIds: Set<number>): Array<{
|
|
4471
|
+
entity: Entity;
|
|
4472
|
+
depth: number;
|
|
4473
|
+
bHasChildren: boolean;
|
|
4474
|
+
bIsExpanded: boolean;
|
|
4475
|
+
}>;
|
|
4476
|
+
/**
|
|
4477
|
+
* 标记缓存为脏
|
|
4478
|
+
*/
|
|
4479
|
+
private markCacheDirty;
|
|
4480
|
+
/**
|
|
4481
|
+
* 更新层级缓存
|
|
4482
|
+
*/
|
|
4483
|
+
private updateHierarchyCache;
|
|
4484
|
+
/**
|
|
4485
|
+
* 当实体被移除时清理层级关系
|
|
4486
|
+
*/
|
|
4487
|
+
protected onEntityRemoved(entity: Entity): void;
|
|
4488
|
+
dispose(): void;
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4352
4491
|
/**
|
|
4353
4492
|
* 实体序列化器
|
|
4354
4493
|
*
|
|
@@ -4405,9 +4544,10 @@ declare class EntitySerializer {
|
|
|
4405
4544
|
*
|
|
4406
4545
|
* @param entity 要序列化的实体
|
|
4407
4546
|
* @param includeChildren 是否包含子实体(默认true)
|
|
4547
|
+
* @param hierarchySystem 层级系统(可选,用于获取层级信息)
|
|
4408
4548
|
* @returns 序列化后的实体数据
|
|
4409
4549
|
*/
|
|
4410
|
-
static serialize(entity: Entity, includeChildren?: boolean): SerializedEntity;
|
|
4550
|
+
static serialize(entity: Entity, includeChildren?: boolean, hierarchySystem?: HierarchySystem): SerializedEntity;
|
|
4411
4551
|
/**
|
|
4412
4552
|
* 反序列化实体
|
|
4413
4553
|
*
|
|
@@ -4416,17 +4556,19 @@ declare class EntitySerializer {
|
|
|
4416
4556
|
* @param idGenerator 实体ID生成器(用于生成新ID或保持原ID)
|
|
4417
4557
|
* @param preserveIds 是否保持原始ID(默认false)
|
|
4418
4558
|
* @param scene 目标场景(可选,用于设置entity.scene以支持添加组件)
|
|
4559
|
+
* @param hierarchySystem 层级系统(可选,用于建立层级关系)
|
|
4419
4560
|
* @returns 反序列化后的实体
|
|
4420
4561
|
*/
|
|
4421
|
-
static deserialize(serializedEntity: SerializedEntity, componentRegistry: Map<string, ComponentType>, idGenerator: () => number, preserveIds?: boolean, scene?: IScene): Entity;
|
|
4562
|
+
static deserialize(serializedEntity: SerializedEntity, componentRegistry: Map<string, ComponentType>, idGenerator: () => number, preserveIds?: boolean, scene?: IScene, hierarchySystem?: HierarchySystem | null, allEntities?: Map<number, Entity>): Entity;
|
|
4422
4563
|
/**
|
|
4423
4564
|
* 批量序列化实体
|
|
4424
4565
|
*
|
|
4425
4566
|
* @param entities 实体数组
|
|
4426
4567
|
* @param includeChildren 是否包含子实体
|
|
4568
|
+
* @param hierarchySystem 层级系统(可选,用于获取层级信息)
|
|
4427
4569
|
* @returns 序列化后的实体数据数组
|
|
4428
4570
|
*/
|
|
4429
|
-
static serializeEntities(entities: Entity[], includeChildren?: boolean): SerializedEntity[];
|
|
4571
|
+
static serializeEntities(entities: Entity[], includeChildren?: boolean, hierarchySystem?: HierarchySystem): SerializedEntity[];
|
|
4430
4572
|
/**
|
|
4431
4573
|
* 批量反序列化实体
|
|
4432
4574
|
*
|
|
@@ -4435,9 +4577,13 @@ declare class EntitySerializer {
|
|
|
4435
4577
|
* @param idGenerator 实体ID生成器
|
|
4436
4578
|
* @param preserveIds 是否保持原始ID
|
|
4437
4579
|
* @param scene 目标场景(可选,用于设置entity.scene以支持添加组件)
|
|
4580
|
+
* @param hierarchySystem 层级系统(可选,用于建立层级关系)
|
|
4438
4581
|
* @returns 反序列化后的实体数组
|
|
4439
4582
|
*/
|
|
4440
|
-
static deserializeEntities(serializedEntities: SerializedEntity[], componentRegistry: Map<string, ComponentType>, idGenerator: () => number, preserveIds?: boolean, scene?: IScene):
|
|
4583
|
+
static deserializeEntities(serializedEntities: SerializedEntity[], componentRegistry: Map<string, ComponentType>, idGenerator: () => number, preserveIds?: boolean, scene?: IScene, hierarchySystem?: HierarchySystem | null): {
|
|
4584
|
+
rootEntities: Entity[];
|
|
4585
|
+
allEntities: Map<number, Entity>;
|
|
4586
|
+
};
|
|
4441
4587
|
/**
|
|
4442
4588
|
* 创建实体的深拷贝
|
|
4443
4589
|
*
|
|
@@ -4584,9 +4730,9 @@ declare class SceneSerializer {
|
|
|
4584
4730
|
*/
|
|
4585
4731
|
static deserialize(scene: IScene, saveData: string | Uint8Array, options?: SceneDeserializationOptions): void;
|
|
4586
4732
|
/**
|
|
4587
|
-
*
|
|
4733
|
+
* 调用实体所有组件的 onDeserialized 方法(不递归)
|
|
4588
4734
|
*/
|
|
4589
|
-
private static
|
|
4735
|
+
private static callOnDeserializedForEntity;
|
|
4590
4736
|
/**
|
|
4591
4737
|
* 递归添加实体的所有子实体到场景
|
|
4592
4738
|
*
|
|
@@ -4597,6 +4743,7 @@ declare class SceneSerializer {
|
|
|
4597
4743
|
*
|
|
4598
4744
|
* @param entity 父实体
|
|
4599
4745
|
* @param scene 目标场景
|
|
4746
|
+
* @param hierarchySystem 层级系统
|
|
4600
4747
|
*/
|
|
4601
4748
|
private static addChildrenRecursively;
|
|
4602
4749
|
/**
|
|
@@ -6323,12 +6470,14 @@ declare class EntityComparer {
|
|
|
6323
6470
|
*
|
|
6324
6471
|
* ECS架构中的实体(Entity),作为组件的容器。
|
|
6325
6472
|
* 实体本身不包含游戏逻辑,所有功能都通过组件来实现。
|
|
6326
|
-
*
|
|
6473
|
+
*
|
|
6474
|
+
* 层级关系通过 HierarchyComponent 和 HierarchySystem 管理,
|
|
6475
|
+
* 而非 Entity 内置属性,符合 ECS 组合原则。
|
|
6327
6476
|
*
|
|
6328
6477
|
* @example
|
|
6329
6478
|
* ```typescript
|
|
6330
6479
|
* // 创建实体
|
|
6331
|
-
* const entity =
|
|
6480
|
+
* const entity = scene.createEntity("Player");
|
|
6332
6481
|
*
|
|
6333
6482
|
* // 添加组件
|
|
6334
6483
|
* const healthComponent = entity.addComponent(new HealthComponent(100));
|
|
@@ -6336,12 +6485,9 @@ declare class EntityComparer {
|
|
|
6336
6485
|
* // 获取组件
|
|
6337
6486
|
* const health = entity.getComponent(HealthComponent);
|
|
6338
6487
|
*
|
|
6339
|
-
* //
|
|
6340
|
-
*
|
|
6341
|
-
*
|
|
6342
|
-
* // 添加子实体
|
|
6343
|
-
* const weapon = new Entity("Weapon", 2);
|
|
6344
|
-
* entity.addChild(weapon);
|
|
6488
|
+
* // 层级关系使用 HierarchySystem
|
|
6489
|
+
* const hierarchySystem = scene.getSystem(HierarchySystem);
|
|
6490
|
+
* hierarchySystem.setParent(childEntity, parentEntity);
|
|
6345
6491
|
* ```
|
|
6346
6492
|
*/
|
|
6347
6493
|
declare class Entity {
|
|
@@ -6369,14 +6515,6 @@ declare class Entity {
|
|
|
6369
6515
|
* 销毁状态标志
|
|
6370
6516
|
*/
|
|
6371
6517
|
private _isDestroyed;
|
|
6372
|
-
/**
|
|
6373
|
-
* 父实体引用
|
|
6374
|
-
*/
|
|
6375
|
-
private _parent;
|
|
6376
|
-
/**
|
|
6377
|
-
* 子实体集合
|
|
6378
|
-
*/
|
|
6379
|
-
private _children;
|
|
6380
6518
|
/**
|
|
6381
6519
|
* 激活状态
|
|
6382
6520
|
*/
|
|
@@ -6431,23 +6569,6 @@ declare class Entity {
|
|
|
6431
6569
|
* 从存储重建组件缓存
|
|
6432
6570
|
*/
|
|
6433
6571
|
private _rebuildComponentCache;
|
|
6434
|
-
/**
|
|
6435
|
-
* 获取父实体
|
|
6436
|
-
* @returns 父实体,如果没有父实体则返回null
|
|
6437
|
-
*/
|
|
6438
|
-
get parent(): Entity | null;
|
|
6439
|
-
/**
|
|
6440
|
-
* 获取子实体数组的只读副本
|
|
6441
|
-
*
|
|
6442
|
-
* @returns 子实体数组的副本
|
|
6443
|
-
*/
|
|
6444
|
-
get children(): readonly Entity[];
|
|
6445
|
-
/**
|
|
6446
|
-
* 获取子实体数量
|
|
6447
|
-
*
|
|
6448
|
-
* @returns 子实体的数量
|
|
6449
|
-
*/
|
|
6450
|
-
get childCount(): number;
|
|
6451
6572
|
/**
|
|
6452
6573
|
* 获取活跃状态
|
|
6453
6574
|
*
|
|
@@ -6457,19 +6578,9 @@ declare class Entity {
|
|
|
6457
6578
|
/**
|
|
6458
6579
|
* 设置活跃状态
|
|
6459
6580
|
*
|
|
6460
|
-
* 设置实体的活跃状态,会影响子实体的有效活跃状态。
|
|
6461
|
-
*
|
|
6462
6581
|
* @param value - 新的活跃状态
|
|
6463
6582
|
*/
|
|
6464
6583
|
set active(value: boolean);
|
|
6465
|
-
/**
|
|
6466
|
-
* 获取实体的有效活跃状态
|
|
6467
|
-
*
|
|
6468
|
-
* 考虑父实体的活跃状态,只有当实体本身和所有父实体都处于活跃状态时才返回true。
|
|
6469
|
-
*
|
|
6470
|
-
* @returns 有效的活跃状态
|
|
6471
|
-
*/
|
|
6472
|
-
get activeInHierarchy(): boolean;
|
|
6473
6584
|
/**
|
|
6474
6585
|
* 获取实体标签
|
|
6475
6586
|
*
|
|
@@ -6656,73 +6767,6 @@ declare class Entity {
|
|
|
6656
6767
|
* ```
|
|
6657
6768
|
*/
|
|
6658
6769
|
getComponentByType<T extends Component>(baseType: ComponentType<T>): T | null;
|
|
6659
|
-
/**
|
|
6660
|
-
* 添加子实体
|
|
6661
|
-
*
|
|
6662
|
-
* @param child - 要添加的子实体
|
|
6663
|
-
* @returns 添加的子实体
|
|
6664
|
-
*/
|
|
6665
|
-
addChild(child: Entity): Entity;
|
|
6666
|
-
/**
|
|
6667
|
-
* 移除子实体
|
|
6668
|
-
*
|
|
6669
|
-
* @param child - 要移除的子实体
|
|
6670
|
-
* @returns 是否成功移除
|
|
6671
|
-
*/
|
|
6672
|
-
removeChild(child: Entity): boolean;
|
|
6673
|
-
/**
|
|
6674
|
-
* 移除所有子实体
|
|
6675
|
-
*/
|
|
6676
|
-
removeAllChildren(): void;
|
|
6677
|
-
/**
|
|
6678
|
-
* 根据名称查找子实体
|
|
6679
|
-
*
|
|
6680
|
-
* @param name - 子实体名称
|
|
6681
|
-
* @param recursive - 是否递归查找
|
|
6682
|
-
* @returns 找到的子实体或null
|
|
6683
|
-
*/
|
|
6684
|
-
findChild(name: string, recursive?: boolean): Entity | null;
|
|
6685
|
-
/**
|
|
6686
|
-
* 根据标签查找子实体
|
|
6687
|
-
*
|
|
6688
|
-
* @param tag - 标签
|
|
6689
|
-
* @param recursive - 是否递归查找
|
|
6690
|
-
* @returns 找到的子实体数组
|
|
6691
|
-
*/
|
|
6692
|
-
findChildrenByTag(tag: number, recursive?: boolean): Entity[];
|
|
6693
|
-
/**
|
|
6694
|
-
* 获取根实体
|
|
6695
|
-
*
|
|
6696
|
-
* @returns 层次结构的根实体
|
|
6697
|
-
*/
|
|
6698
|
-
getRoot(): Entity;
|
|
6699
|
-
/**
|
|
6700
|
-
* 检查是否是指定实体的祖先
|
|
6701
|
-
*
|
|
6702
|
-
* @param entity - 要检查的实体
|
|
6703
|
-
* @returns 如果是祖先则返回true
|
|
6704
|
-
*/
|
|
6705
|
-
isAncestorOf(entity: Entity): boolean;
|
|
6706
|
-
/**
|
|
6707
|
-
* 检查是否是指定实体的后代
|
|
6708
|
-
*
|
|
6709
|
-
* @param entity - 要检查的实体
|
|
6710
|
-
* @returns 如果是后代则返回true
|
|
6711
|
-
*/
|
|
6712
|
-
isDescendantOf(entity: Entity): boolean;
|
|
6713
|
-
/**
|
|
6714
|
-
* 获取层次深度
|
|
6715
|
-
*
|
|
6716
|
-
* @returns 在层次结构中的深度(根实体为0)
|
|
6717
|
-
*/
|
|
6718
|
-
getDepth(): number;
|
|
6719
|
-
/**
|
|
6720
|
-
* 遍历所有子实体(深度优先)
|
|
6721
|
-
*
|
|
6722
|
-
* @param callback - 对每个子实体执行的回调函数
|
|
6723
|
-
* @param recursive - 是否递归遍历
|
|
6724
|
-
*/
|
|
6725
|
-
forEachChild(callback: (child: Entity, index: number) => void, recursive?: boolean): void;
|
|
6726
6770
|
/**
|
|
6727
6771
|
* 活跃状态改变时的回调
|
|
6728
6772
|
*/
|
|
@@ -6730,13 +6774,10 @@ declare class Entity {
|
|
|
6730
6774
|
/**
|
|
6731
6775
|
* 销毁实体
|
|
6732
6776
|
*
|
|
6733
|
-
*
|
|
6777
|
+
* 移除所有组件并标记为已销毁。
|
|
6778
|
+
* 层级关系的清理由 HierarchySystem 处理。
|
|
6734
6779
|
*/
|
|
6735
6780
|
destroy(): void;
|
|
6736
|
-
/**
|
|
6737
|
-
* 批量销毁所有子实体
|
|
6738
|
-
*/
|
|
6739
|
-
destroyAllChildren(): void;
|
|
6740
6781
|
/**
|
|
6741
6782
|
* 比较实体
|
|
6742
6783
|
*
|
|
@@ -6760,15 +6801,10 @@ declare class Entity {
|
|
|
6760
6801
|
id: number;
|
|
6761
6802
|
enabled: boolean;
|
|
6762
6803
|
active: boolean;
|
|
6763
|
-
activeInHierarchy: boolean;
|
|
6764
6804
|
destroyed: boolean;
|
|
6765
6805
|
componentCount: number;
|
|
6766
6806
|
componentTypes: string[];
|
|
6767
6807
|
componentMask: string;
|
|
6768
|
-
parentId: number | null;
|
|
6769
|
-
childCount: number;
|
|
6770
|
-
childIds: number[];
|
|
6771
|
-
depth: number;
|
|
6772
6808
|
cacheBuilt: boolean;
|
|
6773
6809
|
};
|
|
6774
6810
|
}
|
|
@@ -7935,7 +7971,7 @@ declare global {
|
|
|
7935
7971
|
}
|
|
7936
7972
|
}
|
|
7937
7973
|
|
|
7938
|
-
type PropertyType = 'number' | 'integer' | 'string' | 'boolean' | 'color' | 'vector2' | 'vector3' | 'enum' | 'asset' | 'animationClips';
|
|
7974
|
+
type PropertyType = 'number' | 'integer' | 'string' | 'boolean' | 'color' | 'vector2' | 'vector3' | 'enum' | 'asset' | 'animationClips' | 'collisionLayer' | 'collisionMask';
|
|
7939
7975
|
/**
|
|
7940
7976
|
* 资源类型
|
|
7941
7977
|
* Asset type for asset properties
|
|
@@ -8056,11 +8092,25 @@ interface AssetPropertyOptions extends PropertyOptionsBase {
|
|
|
8056
8092
|
interface AnimationClipsPropertyOptions extends PropertyOptionsBase {
|
|
8057
8093
|
type: 'animationClips';
|
|
8058
8094
|
}
|
|
8095
|
+
/**
|
|
8096
|
+
* 碰撞层属性选项
|
|
8097
|
+
* Collision layer property options
|
|
8098
|
+
*/
|
|
8099
|
+
interface CollisionLayerPropertyOptions extends PropertyOptionsBase {
|
|
8100
|
+
type: 'collisionLayer';
|
|
8101
|
+
}
|
|
8102
|
+
/**
|
|
8103
|
+
* 碰撞掩码属性选项
|
|
8104
|
+
* Collision mask property options
|
|
8105
|
+
*/
|
|
8106
|
+
interface CollisionMaskPropertyOptions extends PropertyOptionsBase {
|
|
8107
|
+
type: 'collisionMask';
|
|
8108
|
+
}
|
|
8059
8109
|
/**
|
|
8060
8110
|
* 属性选项联合类型
|
|
8061
8111
|
* Property options union type
|
|
8062
8112
|
*/
|
|
8063
|
-
type PropertyOptions = NumberPropertyOptions | StringPropertyOptions | BooleanPropertyOptions | ColorPropertyOptions | VectorPropertyOptions | EnumPropertyOptions | AssetPropertyOptions | AnimationClipsPropertyOptions;
|
|
8113
|
+
type PropertyOptions = NumberPropertyOptions | StringPropertyOptions | BooleanPropertyOptions | ColorPropertyOptions | VectorPropertyOptions | EnumPropertyOptions | AssetPropertyOptions | AnimationClipsPropertyOptions | CollisionLayerPropertyOptions | CollisionMaskPropertyOptions;
|
|
8064
8114
|
declare const PROPERTY_METADATA: unique symbol;
|
|
8065
8115
|
/**
|
|
8066
8116
|
* 属性装饰器 - 声明组件属性的编辑器元数据
|
|
@@ -8087,6 +8137,51 @@ declare function getPropertyMetadata(target: Function): Record<string, PropertyO
|
|
|
8087
8137
|
*/
|
|
8088
8138
|
declare function hasPropertyMetadata(target: Function): boolean;
|
|
8089
8139
|
|
|
8140
|
+
/**
|
|
8141
|
+
* 层级关系组件 - 用于建立实体间的父子关系
|
|
8142
|
+
*
|
|
8143
|
+
* 只有需要层级关系的实体才添加此组件,遵循 ECS 组合原则。
|
|
8144
|
+
* 层级操作应通过 HierarchySystem 进行,而非直接修改此组件。
|
|
8145
|
+
*
|
|
8146
|
+
* @example
|
|
8147
|
+
* ```typescript
|
|
8148
|
+
* // 通过 HierarchySystem 设置父子关系
|
|
8149
|
+
* const hierarchySystem = scene.getSystem(HierarchySystem);
|
|
8150
|
+
* hierarchySystem.setParent(childEntity, parentEntity);
|
|
8151
|
+
*
|
|
8152
|
+
* // 查询层级信息
|
|
8153
|
+
* const parent = hierarchySystem.getParent(entity);
|
|
8154
|
+
* const children = hierarchySystem.getChildren(entity);
|
|
8155
|
+
* ```
|
|
8156
|
+
*/
|
|
8157
|
+
declare class HierarchyComponent extends Component {
|
|
8158
|
+
/**
|
|
8159
|
+
* 父实体 ID
|
|
8160
|
+
* null 表示根实体(无父级)
|
|
8161
|
+
*/
|
|
8162
|
+
parentId: number | null;
|
|
8163
|
+
/**
|
|
8164
|
+
* 子实体 ID 列表
|
|
8165
|
+
* 顺序即为子级的排列顺序
|
|
8166
|
+
*/
|
|
8167
|
+
childIds: number[];
|
|
8168
|
+
/**
|
|
8169
|
+
* 在层级中的深度
|
|
8170
|
+
* 根实体深度为 0,由 HierarchySystem 维护
|
|
8171
|
+
*/
|
|
8172
|
+
depth: number;
|
|
8173
|
+
/**
|
|
8174
|
+
* 层级中是否激活
|
|
8175
|
+
* 考虑所有祖先的激活状态,由 HierarchySystem 维护
|
|
8176
|
+
*/
|
|
8177
|
+
bActiveInHierarchy: boolean;
|
|
8178
|
+
/**
|
|
8179
|
+
* 层级缓存是否脏
|
|
8180
|
+
* 用于优化缓存更新
|
|
8181
|
+
*/
|
|
8182
|
+
bCacheDirty: boolean;
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8090
8185
|
/**
|
|
8091
8186
|
* 实体构建器 - 提供流式API创建和配置实体
|
|
8092
8187
|
*/
|
|
@@ -9722,6 +9817,77 @@ declare class MigrationBuilder {
|
|
|
9722
9817
|
migrate(migration: ComponentMigrationFunction | SceneMigrationFunction): void;
|
|
9723
9818
|
}
|
|
9724
9819
|
|
|
9820
|
+
/**
|
|
9821
|
+
* 实体标签常量
|
|
9822
|
+
*
|
|
9823
|
+
* 用于标识特殊类型的实体,如文件夹、摄像机等。
|
|
9824
|
+
* 使用位掩码实现,支持多标签组合。
|
|
9825
|
+
*
|
|
9826
|
+
* @example
|
|
9827
|
+
* ```typescript
|
|
9828
|
+
* // 创建文件夹实体
|
|
9829
|
+
* entity.tag = EntityTags.FOLDER;
|
|
9830
|
+
*
|
|
9831
|
+
* // 检查是否是文件夹
|
|
9832
|
+
* if ((entity.tag & EntityTags.FOLDER) !== 0) {
|
|
9833
|
+
* // 是文件夹
|
|
9834
|
+
* }
|
|
9835
|
+
*
|
|
9836
|
+
* // 组合多个标签
|
|
9837
|
+
* entity.tag = EntityTags.FOLDER | EntityTags.HIDDEN;
|
|
9838
|
+
* ```
|
|
9839
|
+
*/
|
|
9840
|
+
declare const EntityTags: {
|
|
9841
|
+
/** 无标签 */
|
|
9842
|
+
readonly NONE: 0;
|
|
9843
|
+
/** 文件夹实体 - 用于场景层级中的组织分类 */
|
|
9844
|
+
readonly FOLDER: 4096;
|
|
9845
|
+
/** 隐藏实体 - 在编辑器层级中不显示 */
|
|
9846
|
+
readonly HIDDEN: 8192;
|
|
9847
|
+
/** 锁定实体 - 在编辑器中不可选择/编辑 */
|
|
9848
|
+
readonly LOCKED: 16384;
|
|
9849
|
+
/** 编辑器专用实体 - 仅在编辑器中存在,不导出到运行时 */
|
|
9850
|
+
readonly EDITOR_ONLY: 32768;
|
|
9851
|
+
/** 预制件实例 */
|
|
9852
|
+
readonly PREFAB_INSTANCE: 256;
|
|
9853
|
+
/** 预制件根节点 */
|
|
9854
|
+
readonly PREFAB_ROOT: 512;
|
|
9855
|
+
};
|
|
9856
|
+
type EntityTagValue = (typeof EntityTags)[keyof typeof EntityTags];
|
|
9857
|
+
/**
|
|
9858
|
+
* 检查实体是否具有指定标签
|
|
9859
|
+
*
|
|
9860
|
+
* @param entityTag - 实体的 tag 值
|
|
9861
|
+
* @param tag - 要检查的标签
|
|
9862
|
+
*/
|
|
9863
|
+
declare function hasEntityTag(entityTag: number, tag: EntityTagValue): boolean;
|
|
9864
|
+
/**
|
|
9865
|
+
* 添加标签到实体
|
|
9866
|
+
*
|
|
9867
|
+
* @param entityTag - 当前 tag 值
|
|
9868
|
+
* @param tag - 要添加的标签
|
|
9869
|
+
*/
|
|
9870
|
+
declare function addEntityTag(entityTag: number, tag: EntityTagValue): number;
|
|
9871
|
+
/**
|
|
9872
|
+
* 从实体移除标签
|
|
9873
|
+
*
|
|
9874
|
+
* @param entityTag - 当前 tag 值
|
|
9875
|
+
* @param tag - 要移除的标签
|
|
9876
|
+
*/
|
|
9877
|
+
declare function removeEntityTag(entityTag: number, tag: EntityTagValue): number;
|
|
9878
|
+
/**
|
|
9879
|
+
* 检查实体是否是文件夹
|
|
9880
|
+
*/
|
|
9881
|
+
declare function isFolder(entityTag: number): boolean;
|
|
9882
|
+
/**
|
|
9883
|
+
* 检查实体是否隐藏
|
|
9884
|
+
*/
|
|
9885
|
+
declare function isHidden(entityTag: number): boolean;
|
|
9886
|
+
/**
|
|
9887
|
+
* 检查实体是否锁定
|
|
9888
|
+
*/
|
|
9889
|
+
declare function isLocked(entityTag: number): boolean;
|
|
9890
|
+
|
|
9725
9891
|
interface ITimer<TContext = unknown> {
|
|
9726
9892
|
context: TContext;
|
|
9727
9893
|
/**
|
|
@@ -9743,11 +9909,11 @@ interface ITimer<TContext = unknown> {
|
|
|
9743
9909
|
*/
|
|
9744
9910
|
declare class Timer<TContext = unknown> implements ITimer<TContext> {
|
|
9745
9911
|
context: TContext;
|
|
9746
|
-
_timeInSeconds
|
|
9747
|
-
_repeats
|
|
9748
|
-
_onTime
|
|
9749
|
-
_isDone
|
|
9750
|
-
_elapsedTime
|
|
9912
|
+
private _timeInSeconds;
|
|
9913
|
+
private _repeats;
|
|
9914
|
+
private _onTime;
|
|
9915
|
+
private _isDone;
|
|
9916
|
+
private _elapsedTime;
|
|
9751
9917
|
getContext<T>(): T;
|
|
9752
9918
|
/**
|
|
9753
9919
|
* 定时器是否已完成
|
|
@@ -9768,1978 +9934,2668 @@ declare class Timer<TContext = unknown> implements ITimer<TContext> {
|
|
|
9768
9934
|
}
|
|
9769
9935
|
|
|
9770
9936
|
/**
|
|
9771
|
-
*
|
|
9772
|
-
*
|
|
9773
|
-
* 允许动作的延迟和重复执行
|
|
9937
|
+
* 插件状态
|
|
9774
9938
|
*/
|
|
9775
|
-
declare
|
|
9776
|
-
_timers: Array<Timer<unknown>>;
|
|
9777
|
-
update(): void;
|
|
9939
|
+
declare enum PluginState {
|
|
9778
9940
|
/**
|
|
9779
|
-
*
|
|
9780
|
-
* @param timeInSeconds
|
|
9781
|
-
* @param repeats
|
|
9782
|
-
* @param context
|
|
9783
|
-
* @param onTime
|
|
9941
|
+
* 未安装
|
|
9784
9942
|
*/
|
|
9785
|
-
|
|
9943
|
+
NotInstalled = "not_installed",
|
|
9786
9944
|
/**
|
|
9787
|
-
*
|
|
9945
|
+
* 已安装
|
|
9788
9946
|
*/
|
|
9789
|
-
|
|
9790
|
-
}
|
|
9791
|
-
|
|
9792
|
-
/**
|
|
9793
|
-
* 可池化对象接口
|
|
9794
|
-
*/
|
|
9795
|
-
interface IPoolable {
|
|
9947
|
+
Installed = "installed",
|
|
9796
9948
|
/**
|
|
9797
|
-
*
|
|
9949
|
+
* 安装失败
|
|
9798
9950
|
*/
|
|
9799
|
-
|
|
9951
|
+
Failed = "failed"
|
|
9800
9952
|
}
|
|
9801
9953
|
/**
|
|
9802
|
-
*
|
|
9954
|
+
* 插件接口
|
|
9955
|
+
*
|
|
9956
|
+
* 所有插件都必须实现此接口。
|
|
9957
|
+
* 插件提供了一种扩展框架功能的标准方式。
|
|
9958
|
+
*
|
|
9959
|
+
* @example
|
|
9960
|
+
* ```typescript
|
|
9961
|
+
* class MyPlugin implements IPlugin {
|
|
9962
|
+
* readonly name = 'my-plugin';
|
|
9963
|
+
* readonly version = '1.0.0';
|
|
9964
|
+
* readonly dependencies = ['other-plugin'];
|
|
9965
|
+
*
|
|
9966
|
+
* async install(core: Core, services: ServiceContainer) {
|
|
9967
|
+
* // 注册服务
|
|
9968
|
+
* services.registerSingleton(MyService);
|
|
9969
|
+
*
|
|
9970
|
+
* // 添加系统
|
|
9971
|
+
* const world = core.getWorld();
|
|
9972
|
+
* if (world) {
|
|
9973
|
+
* world.addSystem(new MySystem());
|
|
9974
|
+
* }
|
|
9975
|
+
* }
|
|
9976
|
+
*
|
|
9977
|
+
* async uninstall() {
|
|
9978
|
+
* // 清理资源
|
|
9979
|
+
* }
|
|
9980
|
+
* }
|
|
9981
|
+
* ```
|
|
9803
9982
|
*/
|
|
9804
|
-
interface
|
|
9805
|
-
/** 池中对象数量 */
|
|
9806
|
-
size: number;
|
|
9807
|
-
/** 池的最大大小 */
|
|
9808
|
-
maxSize: number;
|
|
9809
|
-
/** 总共创建的对象数量 */
|
|
9810
|
-
totalCreated: number;
|
|
9811
|
-
/** 总共获取的次数 */
|
|
9812
|
-
totalObtained: number;
|
|
9813
|
-
/** 总共释放的次数 */
|
|
9814
|
-
totalReleased: number;
|
|
9815
|
-
/** 命中率(从池中获取的比例) */
|
|
9816
|
-
hitRate: number;
|
|
9817
|
-
/** 内存使用估算(字节) */
|
|
9818
|
-
estimatedMemoryUsage: number;
|
|
9819
|
-
}
|
|
9820
|
-
|
|
9821
|
-
/**
|
|
9822
|
-
* 高性能通用对象池
|
|
9823
|
-
* 支持任意类型的对象池化,包含详细的统计信息
|
|
9824
|
-
*/
|
|
9825
|
-
declare class Pool<T extends IPoolable> {
|
|
9826
|
-
private static _pools;
|
|
9827
|
-
private _objects;
|
|
9828
|
-
private _createFn;
|
|
9829
|
-
private _maxSize;
|
|
9830
|
-
private _stats;
|
|
9831
|
-
private _objectSize;
|
|
9832
|
-
/**
|
|
9833
|
-
* 构造函数
|
|
9834
|
-
* @param createFn 创建对象的函数
|
|
9835
|
-
* @param maxSize 池的最大大小,默认100
|
|
9836
|
-
* @param estimatedObjectSize 估算的单个对象大小(字节),默认1024
|
|
9837
|
-
*/
|
|
9838
|
-
constructor(createFn: () => T, maxSize?: number, estimatedObjectSize?: number);
|
|
9839
|
-
/**
|
|
9840
|
-
* 获取指定类型的对象池
|
|
9841
|
-
* @param type 对象类型
|
|
9842
|
-
* @param maxSize 池的最大大小
|
|
9843
|
-
* @param estimatedObjectSize 估算的单个对象大小
|
|
9844
|
-
* @returns 对象池实例
|
|
9845
|
-
*/
|
|
9846
|
-
static getPool<T extends IPoolable>(type: new (...args: unknown[]) => T, maxSize?: number, estimatedObjectSize?: number): Pool<T>;
|
|
9847
|
-
/**
|
|
9848
|
-
* 从池中获取对象
|
|
9849
|
-
* @returns 对象实例
|
|
9850
|
-
*/
|
|
9851
|
-
obtain(): T;
|
|
9852
|
-
/**
|
|
9853
|
-
* 释放对象回池中
|
|
9854
|
-
* @param obj 要释放的对象
|
|
9855
|
-
*/
|
|
9856
|
-
release(obj: T): void;
|
|
9857
|
-
/**
|
|
9858
|
-
* 获取池统计信息
|
|
9859
|
-
* @returns 统计信息对象
|
|
9860
|
-
*/
|
|
9861
|
-
getStats(): Readonly<PoolStats>;
|
|
9862
|
-
/**
|
|
9863
|
-
* 清空池
|
|
9864
|
-
*/
|
|
9865
|
-
clear(): void;
|
|
9866
|
-
/**
|
|
9867
|
-
* 压缩池(移除多余的对象)
|
|
9868
|
-
* @param targetSize 目标大小,默认为当前大小的一半
|
|
9869
|
-
*/
|
|
9870
|
-
compact(targetSize?: number): void;
|
|
9871
|
-
/**
|
|
9872
|
-
* 预填充池
|
|
9873
|
-
* @param count 预填充的对象数量
|
|
9874
|
-
*/
|
|
9875
|
-
prewarm(count: number): void;
|
|
9876
|
-
/**
|
|
9877
|
-
* 设置最大池大小
|
|
9878
|
-
* @param maxSize 新的最大大小
|
|
9879
|
-
*/
|
|
9880
|
-
setMaxSize(maxSize: number): void;
|
|
9983
|
+
interface IPlugin {
|
|
9881
9984
|
/**
|
|
9882
|
-
*
|
|
9883
|
-
*
|
|
9985
|
+
* 插件唯一名称
|
|
9986
|
+
*
|
|
9987
|
+
* 用于依赖解析和插件管理。
|
|
9884
9988
|
*/
|
|
9885
|
-
|
|
9989
|
+
readonly name: string;
|
|
9886
9990
|
/**
|
|
9887
|
-
*
|
|
9888
|
-
*
|
|
9991
|
+
* 插件版本
|
|
9992
|
+
*
|
|
9993
|
+
* 遵循语义化版本规范 (semver)。
|
|
9889
9994
|
*/
|
|
9890
|
-
|
|
9995
|
+
readonly version: string;
|
|
9891
9996
|
/**
|
|
9892
|
-
*
|
|
9893
|
-
*
|
|
9997
|
+
* 依赖的其他插件名称列表
|
|
9998
|
+
*
|
|
9999
|
+
* 这些插件必须在当前插件之前安装。
|
|
9894
10000
|
*/
|
|
9895
|
-
|
|
10001
|
+
readonly dependencies?: readonly string[];
|
|
9896
10002
|
/**
|
|
9897
|
-
*
|
|
9898
|
-
*
|
|
10003
|
+
* 安装插件
|
|
10004
|
+
*
|
|
10005
|
+
* 在此方法中初始化插件,注册服务、系统等。
|
|
10006
|
+
* 可以是同步或异步的。
|
|
10007
|
+
*
|
|
10008
|
+
* @param core - Core实例,用于访问World等
|
|
10009
|
+
* @param services - 服务容器,用于注册服务
|
|
9899
10010
|
*/
|
|
9900
|
-
|
|
10011
|
+
install(core: Core, services: ServiceContainer): void | Promise<void>;
|
|
9901
10012
|
/**
|
|
9902
|
-
*
|
|
9903
|
-
*
|
|
10013
|
+
* 卸载插件
|
|
10014
|
+
*
|
|
10015
|
+
* 清理插件占用的资源。
|
|
10016
|
+
* 可以是同步或异步的。
|
|
9904
10017
|
*/
|
|
9905
|
-
|
|
10018
|
+
uninstall(): void | Promise<void>;
|
|
10019
|
+
}
|
|
10020
|
+
/**
|
|
10021
|
+
* 插件元数据
|
|
10022
|
+
*/
|
|
10023
|
+
interface IPluginMetadata {
|
|
9906
10024
|
/**
|
|
9907
|
-
*
|
|
10025
|
+
* 插件名称
|
|
9908
10026
|
*/
|
|
9909
|
-
|
|
10027
|
+
name: string;
|
|
9910
10028
|
/**
|
|
9911
|
-
*
|
|
10029
|
+
* 插件版本
|
|
9912
10030
|
*/
|
|
9913
|
-
|
|
10031
|
+
version: string;
|
|
9914
10032
|
/**
|
|
9915
|
-
*
|
|
9916
|
-
* @returns 格式化的统计信息字符串
|
|
10033
|
+
* 插件状态
|
|
9917
10034
|
*/
|
|
9918
|
-
|
|
10035
|
+
state: PluginState;
|
|
9919
10036
|
/**
|
|
9920
|
-
*
|
|
10037
|
+
* 安装时间戳
|
|
9921
10038
|
*/
|
|
9922
|
-
|
|
10039
|
+
installedAt?: number;
|
|
9923
10040
|
/**
|
|
9924
|
-
*
|
|
10041
|
+
* 错误信息(如果安装失败)
|
|
9925
10042
|
*/
|
|
9926
|
-
|
|
10043
|
+
error?: string;
|
|
9927
10044
|
}
|
|
9928
10045
|
|
|
9929
10046
|
/**
|
|
9930
|
-
*
|
|
9931
|
-
*
|
|
10047
|
+
* 游戏引擎核心类
|
|
10048
|
+
*
|
|
10049
|
+
* 职责:
|
|
10050
|
+
* - 提供全局服务(Timer、Performance、Pool等)
|
|
10051
|
+
* - 管理场景生命周期(内置SceneManager)
|
|
10052
|
+
* - 管理全局管理器的生命周期
|
|
10053
|
+
* - 提供统一的游戏循环更新入口
|
|
10054
|
+
*
|
|
10055
|
+
* @example
|
|
10056
|
+
* ```typescript
|
|
10057
|
+
* // 初始化并设置场景
|
|
10058
|
+
* Core.create({ debug: true });
|
|
10059
|
+
* Core.setScene(new GameScene());
|
|
10060
|
+
*
|
|
10061
|
+
* // 游戏循环(自动更新全局服务和场景)
|
|
10062
|
+
* function gameLoop(deltaTime: number) {
|
|
10063
|
+
* Core.update(deltaTime);
|
|
10064
|
+
* }
|
|
10065
|
+
*
|
|
10066
|
+
* // 使用定时器
|
|
10067
|
+
* Core.schedule(1.0, false, null, (timer) => {
|
|
10068
|
+
* console.log("1秒后执行");
|
|
10069
|
+
* });
|
|
10070
|
+
*
|
|
10071
|
+
* // 切换场景
|
|
10072
|
+
* Core.loadScene(new MenuScene()); // 延迟切换
|
|
10073
|
+
* Core.setScene(new GameScene()); // 立即切换
|
|
10074
|
+
*
|
|
10075
|
+
* // 获取当前场景
|
|
10076
|
+
* const currentScene = Core.scene;
|
|
10077
|
+
* ```
|
|
9932
10078
|
*/
|
|
9933
|
-
declare class
|
|
9934
|
-
private pools;
|
|
9935
|
-
private autoCompactInterval;
|
|
9936
|
-
private lastCompactTime;
|
|
9937
|
-
constructor();
|
|
10079
|
+
declare class Core {
|
|
9938
10080
|
/**
|
|
9939
|
-
*
|
|
9940
|
-
*
|
|
9941
|
-
*
|
|
10081
|
+
* 游戏暂停状态
|
|
10082
|
+
*
|
|
10083
|
+
* 当设置为true时,游戏循环将暂停执行。
|
|
9942
10084
|
*/
|
|
9943
|
-
|
|
10085
|
+
static paused: boolean;
|
|
9944
10086
|
/**
|
|
9945
|
-
*
|
|
9946
|
-
*
|
|
9947
|
-
*
|
|
10087
|
+
* 全局核心实例
|
|
10088
|
+
*
|
|
10089
|
+
* 可能为null表示Core尚未初始化或已被销毁
|
|
9948
10090
|
*/
|
|
9949
|
-
|
|
10091
|
+
private static _instance;
|
|
9950
10092
|
/**
|
|
9951
|
-
*
|
|
10093
|
+
* Core专用日志器
|
|
9952
10094
|
*/
|
|
9953
|
-
|
|
10095
|
+
private static _logger;
|
|
9954
10096
|
/**
|
|
9955
|
-
*
|
|
9956
|
-
*
|
|
9957
|
-
*
|
|
9958
|
-
* @param maxSize 最大大小
|
|
9959
|
-
* @param estimatedObjectSize 估算对象大小
|
|
9960
|
-
* @returns 池实例
|
|
10097
|
+
* 调试模式标志
|
|
10098
|
+
*
|
|
10099
|
+
* 在调试模式下会启用额外的性能监控和错误检查。
|
|
9961
10100
|
*/
|
|
9962
|
-
|
|
10101
|
+
readonly debug: boolean;
|
|
9963
10102
|
/**
|
|
9964
|
-
*
|
|
9965
|
-
*
|
|
9966
|
-
*
|
|
10103
|
+
* 服务容器
|
|
10104
|
+
*
|
|
10105
|
+
* 管理所有服务的注册、解析和生命周期。
|
|
9967
10106
|
*/
|
|
9968
|
-
|
|
10107
|
+
private _serviceContainer;
|
|
10108
|
+
private _timerManager;
|
|
10109
|
+
private _performanceMonitor;
|
|
10110
|
+
private _poolManager;
|
|
10111
|
+
private _debugManager?;
|
|
9969
10112
|
/**
|
|
9970
|
-
*
|
|
9971
|
-
*
|
|
10113
|
+
* 场景管理器
|
|
10114
|
+
*
|
|
10115
|
+
* 管理当前场景的生命周期。
|
|
9972
10116
|
*/
|
|
9973
|
-
|
|
10117
|
+
private _sceneManager;
|
|
9974
10118
|
/**
|
|
9975
|
-
*
|
|
9976
|
-
*
|
|
10119
|
+
* World管理器
|
|
10120
|
+
*
|
|
10121
|
+
* 管理多个独立的World实例(可选)。
|
|
9977
10122
|
*/
|
|
9978
|
-
|
|
10123
|
+
private _worldManager;
|
|
9979
10124
|
/**
|
|
9980
|
-
*
|
|
10125
|
+
* 插件管理器
|
|
10126
|
+
*
|
|
10127
|
+
* 管理所有插件的生命周期。
|
|
9981
10128
|
*/
|
|
9982
|
-
|
|
10129
|
+
private _pluginManager;
|
|
9983
10130
|
/**
|
|
9984
|
-
*
|
|
10131
|
+
* Core配置
|
|
9985
10132
|
*/
|
|
9986
|
-
|
|
10133
|
+
private _config;
|
|
9987
10134
|
/**
|
|
9988
|
-
*
|
|
9989
|
-
*
|
|
10135
|
+
* 创建核心实例
|
|
10136
|
+
*
|
|
10137
|
+
* @param config - Core配置对象
|
|
9990
10138
|
*/
|
|
9991
|
-
|
|
10139
|
+
private constructor();
|
|
9992
10140
|
/**
|
|
9993
|
-
*
|
|
9994
|
-
*
|
|
10141
|
+
* 获取核心实例
|
|
10142
|
+
*
|
|
10143
|
+
* @returns 全局核心实例
|
|
9995
10144
|
*/
|
|
9996
|
-
|
|
10145
|
+
static get Instance(): Core | null;
|
|
9997
10146
|
/**
|
|
9998
|
-
*
|
|
9999
|
-
*
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
*
|
|
10004
|
-
*
|
|
10147
|
+
* 获取服务容器
|
|
10148
|
+
*
|
|
10149
|
+
* 用于注册和解析自定义服务。
|
|
10150
|
+
*
|
|
10151
|
+
* @returns 服务容器实例
|
|
10152
|
+
* @throws 如果Core实例未创建
|
|
10153
|
+
*
|
|
10154
|
+
* @example
|
|
10155
|
+
* ```typescript
|
|
10156
|
+
* // 注册自定义服务
|
|
10157
|
+
* Core.services.registerSingleton(MyService);
|
|
10158
|
+
*
|
|
10159
|
+
* // 解析服务
|
|
10160
|
+
* const myService = Core.services.resolve(MyService);
|
|
10161
|
+
* ```
|
|
10005
10162
|
*/
|
|
10006
|
-
|
|
10163
|
+
static get services(): ServiceContainer;
|
|
10007
10164
|
/**
|
|
10008
|
-
*
|
|
10165
|
+
* 获取World管理器
|
|
10166
|
+
*
|
|
10167
|
+
* 用于管理多个独立的World实例(高级用户)。
|
|
10168
|
+
*
|
|
10169
|
+
* @returns WorldManager实例
|
|
10170
|
+
* @throws 如果Core实例未创建
|
|
10171
|
+
*
|
|
10172
|
+
* @example
|
|
10173
|
+
* ```typescript
|
|
10174
|
+
* // 创建多个游戏房间
|
|
10175
|
+
* const wm = Core.worldManager;
|
|
10176
|
+
* const room1 = wm.createWorld('room_001');
|
|
10177
|
+
* room1.createScene('game', new GameScene());
|
|
10178
|
+
* room1.start();
|
|
10179
|
+
* ```
|
|
10009
10180
|
*/
|
|
10010
|
-
|
|
10181
|
+
static get worldManager(): WorldManager;
|
|
10011
10182
|
/**
|
|
10012
|
-
*
|
|
10183
|
+
* 创建Core实例
|
|
10184
|
+
*
|
|
10185
|
+
* 如果实例已存在,则返回现有实例。
|
|
10186
|
+
*
|
|
10187
|
+
* @param config - Core配置,也可以直接传入boolean表示debug模式(向后兼容)
|
|
10188
|
+
* @returns Core实例
|
|
10189
|
+
*
|
|
10190
|
+
* @example
|
|
10191
|
+
* ```typescript
|
|
10192
|
+
* // 方式1:使用配置对象
|
|
10193
|
+
* Core.create({
|
|
10194
|
+
* debug: true,
|
|
10195
|
+
* debugConfig: {
|
|
10196
|
+
* enabled: true,
|
|
10197
|
+
* websocketUrl: 'ws://localhost:9229'
|
|
10198
|
+
* }
|
|
10199
|
+
* });
|
|
10200
|
+
*
|
|
10201
|
+
* // 方式2:简单模式(向后兼容)
|
|
10202
|
+
* Core.create(true); // debug = true
|
|
10203
|
+
* ```
|
|
10013
10204
|
*/
|
|
10014
|
-
|
|
10205
|
+
static create(config?: ICoreConfig | boolean): Core;
|
|
10015
10206
|
/**
|
|
10016
|
-
*
|
|
10017
|
-
*
|
|
10207
|
+
* 设置当前场景
|
|
10208
|
+
*
|
|
10209
|
+
* @param scene - 要设置的场景
|
|
10210
|
+
* @returns 设置的场景实例
|
|
10211
|
+
*
|
|
10212
|
+
* @example
|
|
10213
|
+
* ```typescript
|
|
10214
|
+
* Core.create({ debug: true });
|
|
10215
|
+
*
|
|
10216
|
+
* // 创建并设置场景
|
|
10217
|
+
* const gameScene = new GameScene();
|
|
10218
|
+
* Core.setScene(gameScene);
|
|
10219
|
+
* ```
|
|
10018
10220
|
*/
|
|
10019
|
-
|
|
10020
|
-
}
|
|
10021
|
-
|
|
10022
|
-
/**
|
|
10023
|
-
* 实体数据收集器
|
|
10024
|
-
*/
|
|
10025
|
-
declare class EntityDataCollector {
|
|
10221
|
+
static setScene<T extends IScene>(scene: T): T;
|
|
10026
10222
|
/**
|
|
10027
|
-
*
|
|
10028
|
-
*
|
|
10223
|
+
* 获取当前场景
|
|
10224
|
+
*
|
|
10225
|
+
* @returns 当前场景,如果没有场景则返回null
|
|
10029
10226
|
*/
|
|
10030
|
-
|
|
10227
|
+
static get scene(): IScene | null;
|
|
10031
10228
|
/**
|
|
10032
|
-
*
|
|
10033
|
-
*
|
|
10229
|
+
* 获取ECS流式API
|
|
10230
|
+
*
|
|
10231
|
+
* @returns ECS API实例,如果当前没有场景则返回null
|
|
10232
|
+
*
|
|
10233
|
+
* @example
|
|
10234
|
+
* ```typescript
|
|
10235
|
+
* // 使用流式API创建实体
|
|
10236
|
+
* const player = Core.ecsAPI?.createEntity('Player')
|
|
10237
|
+
* .addComponent(Position, 100, 100)
|
|
10238
|
+
* .addComponent(Velocity, 50, 0);
|
|
10239
|
+
*
|
|
10240
|
+
* // 查询实体
|
|
10241
|
+
* const enemies = Core.ecsAPI?.query(Enemy, Transform);
|
|
10242
|
+
*
|
|
10243
|
+
* // 发射事件
|
|
10244
|
+
* Core.ecsAPI?.emit('game:start', { level: 1 });
|
|
10245
|
+
* ```
|
|
10034
10246
|
*/
|
|
10035
|
-
|
|
10036
|
-
id: number;
|
|
10037
|
-
name: string;
|
|
10038
|
-
active: boolean;
|
|
10039
|
-
enabled: boolean;
|
|
10040
|
-
activeInHierarchy: boolean;
|
|
10041
|
-
componentCount: number;
|
|
10042
|
-
componentTypes: string[];
|
|
10043
|
-
parentId: number | null;
|
|
10044
|
-
childIds: number[];
|
|
10045
|
-
depth: number;
|
|
10046
|
-
tag: number;
|
|
10047
|
-
updateOrder: number;
|
|
10048
|
-
}>;
|
|
10247
|
+
static get ecsAPI(): ECSFluentAPI | null;
|
|
10049
10248
|
/**
|
|
10050
|
-
*
|
|
10051
|
-
*
|
|
10052
|
-
* @param scene
|
|
10249
|
+
* 延迟加载场景(下一帧切换)
|
|
10250
|
+
*
|
|
10251
|
+
* @param scene - 要加载的场景
|
|
10252
|
+
*
|
|
10253
|
+
* @example
|
|
10254
|
+
* ```typescript
|
|
10255
|
+
* // 延迟切换场景(在下一帧生效)
|
|
10256
|
+
* Core.loadScene(new MenuScene());
|
|
10257
|
+
* ```
|
|
10053
10258
|
*/
|
|
10054
|
-
|
|
10055
|
-
private getSceneInfo;
|
|
10259
|
+
static loadScene<T extends IScene>(scene: T): void;
|
|
10056
10260
|
/**
|
|
10057
|
-
*
|
|
10058
|
-
*
|
|
10261
|
+
* 更新游戏逻辑
|
|
10262
|
+
*
|
|
10263
|
+
* 此方法应该在游戏引擎的更新循环中调用。
|
|
10264
|
+
* 会自动更新全局服务和当前场景。
|
|
10265
|
+
*
|
|
10266
|
+
* @param deltaTime - 外部引擎提供的帧时间间隔(秒)
|
|
10267
|
+
*
|
|
10268
|
+
* @example
|
|
10269
|
+
* ```typescript
|
|
10270
|
+
* // 初始化
|
|
10271
|
+
* Core.create({ debug: true });
|
|
10272
|
+
* Core.setScene(new GameScene());
|
|
10273
|
+
*
|
|
10274
|
+
* // Laya引擎集成
|
|
10275
|
+
* Laya.timer.frameLoop(1, this, () => {
|
|
10276
|
+
* const deltaTime = Laya.timer.delta / 1000;
|
|
10277
|
+
* Core.update(deltaTime); // 自动更新全局服务和场景
|
|
10278
|
+
* });
|
|
10279
|
+
*
|
|
10280
|
+
* // Cocos Creator集成
|
|
10281
|
+
* update(deltaTime: number) {
|
|
10282
|
+
* Core.update(deltaTime); // 自动更新全局服务和场景
|
|
10283
|
+
* }
|
|
10284
|
+
* ```
|
|
10059
10285
|
*/
|
|
10060
|
-
|
|
10061
|
-
private collectArchetypeData;
|
|
10062
|
-
private getArchetypeDistributionFast;
|
|
10063
|
-
private getTopEntitiesByComponentsFast;
|
|
10064
|
-
private collectArchetypeDataWithMemory;
|
|
10065
|
-
private extractArchetypeStatistics;
|
|
10066
|
-
private extractArchetypeStatisticsWithMemory;
|
|
10067
|
-
private getArchetypeDistributionWithMemory;
|
|
10068
|
-
private getTopEntitiesByComponentsWithMemory;
|
|
10069
|
-
private getEmptyEntityDebugData;
|
|
10070
|
-
private calculateFallbackEntityStats;
|
|
10071
|
-
estimateEntityMemoryUsage(entity: any): number;
|
|
10072
|
-
calculateObjectSize(obj: any, excludeKeys?: string[]): number;
|
|
10073
|
-
private buildEntityHierarchyTree;
|
|
10286
|
+
static update(deltaTime: number): void;
|
|
10074
10287
|
/**
|
|
10075
|
-
*
|
|
10288
|
+
* 调度定时器
|
|
10289
|
+
*
|
|
10290
|
+
* 创建一个定时器,在指定时间后执行回调函数。
|
|
10291
|
+
*
|
|
10292
|
+
* @param timeInSeconds - 延迟时间(秒)
|
|
10293
|
+
* @param repeats - 是否重复执行,默认为false
|
|
10294
|
+
* @param context - 回调函数的上下文,默认为null
|
|
10295
|
+
* @param onTime - 定时器触发时的回调函数
|
|
10296
|
+
* @returns 创建的定时器实例
|
|
10297
|
+
* @throws 如果Core实例未创建或onTime回调未提供
|
|
10298
|
+
*
|
|
10299
|
+
* @example
|
|
10300
|
+
* ```typescript
|
|
10301
|
+
* // 一次性定时器
|
|
10302
|
+
* Core.schedule(1.0, false, null, (timer) => {
|
|
10303
|
+
* console.log("1秒后执行一次");
|
|
10304
|
+
* });
|
|
10305
|
+
*
|
|
10306
|
+
* // 重复定时器
|
|
10307
|
+
* Core.schedule(0.5, true, null, (timer) => {
|
|
10308
|
+
* console.log("每0.5秒执行一次");
|
|
10309
|
+
* });
|
|
10310
|
+
* ```
|
|
10076
10311
|
*/
|
|
10077
|
-
|
|
10312
|
+
static schedule<TContext = unknown>(timeInSeconds: number, repeats?: boolean, context?: TContext, onTime?: (timer: ITimer<TContext>) => void): Timer<TContext>;
|
|
10078
10313
|
/**
|
|
10079
|
-
*
|
|
10314
|
+
* 启用调试功能
|
|
10315
|
+
*
|
|
10316
|
+
* @param config 调试配置
|
|
10080
10317
|
*/
|
|
10081
|
-
|
|
10318
|
+
static enableDebug(config: IECSDebugConfig): void;
|
|
10082
10319
|
/**
|
|
10083
|
-
*
|
|
10320
|
+
* 禁用调试功能
|
|
10084
10321
|
*/
|
|
10085
|
-
|
|
10322
|
+
static disableDebug(): void;
|
|
10086
10323
|
/**
|
|
10087
|
-
*
|
|
10324
|
+
* 获取调试数据
|
|
10325
|
+
*
|
|
10326
|
+
* @returns 当前调试数据,如果调试未启用则返回null
|
|
10088
10327
|
*/
|
|
10089
|
-
|
|
10090
|
-
typeName: string;
|
|
10091
|
-
properties: Record<string, any>;
|
|
10092
|
-
}>;
|
|
10328
|
+
static getDebugData(): unknown;
|
|
10093
10329
|
/**
|
|
10094
|
-
*
|
|
10095
|
-
*
|
|
10096
|
-
* @
|
|
10097
|
-
* @param scene 场景实例
|
|
10330
|
+
* 检查调试是否启用
|
|
10331
|
+
*
|
|
10332
|
+
* @returns 调试状态
|
|
10098
10333
|
*/
|
|
10099
|
-
|
|
10334
|
+
static get isDebugEnabled(): boolean;
|
|
10100
10335
|
/**
|
|
10101
|
-
*
|
|
10336
|
+
* 获取性能监视器实例
|
|
10337
|
+
*
|
|
10338
|
+
* @returns 性能监视器,如果Core未初始化则返回null
|
|
10102
10339
|
*/
|
|
10103
|
-
|
|
10340
|
+
static get performanceMonitor(): PerformanceMonitor | null;
|
|
10104
10341
|
/**
|
|
10105
|
-
*
|
|
10342
|
+
* 安装插件
|
|
10343
|
+
*
|
|
10344
|
+
* @param plugin - 插件实例
|
|
10345
|
+
* @throws 如果Core实例未创建或插件安装失败
|
|
10346
|
+
*
|
|
10347
|
+
* @example
|
|
10348
|
+
* ```typescript
|
|
10349
|
+
* Core.create({ debug: true });
|
|
10350
|
+
*
|
|
10351
|
+
* // 安装插件
|
|
10352
|
+
* await Core.installPlugin(new MyPlugin());
|
|
10353
|
+
* ```
|
|
10106
10354
|
*/
|
|
10107
|
-
|
|
10355
|
+
static installPlugin(plugin: IPlugin): Promise<void>;
|
|
10108
10356
|
/**
|
|
10109
|
-
*
|
|
10110
|
-
|
|
10111
|
-
|
|
10357
|
+
* 卸载插件
|
|
10358
|
+
*
|
|
10359
|
+
* @param name - 插件名称
|
|
10360
|
+
* @throws 如果Core实例未创建或插件卸载失败
|
|
10361
|
+
*
|
|
10362
|
+
* @example
|
|
10363
|
+
* ```typescript
|
|
10364
|
+
* await Core.uninstallPlugin('my-plugin');
|
|
10365
|
+
* ```
|
|
10366
|
+
*/
|
|
10367
|
+
static uninstallPlugin(name: string): Promise<void>;
|
|
10112
10368
|
/**
|
|
10113
|
-
*
|
|
10369
|
+
* 获取插件实例
|
|
10370
|
+
*
|
|
10371
|
+
* @param name - 插件名称
|
|
10372
|
+
* @returns 插件实例,如果未安装则返回undefined
|
|
10373
|
+
*
|
|
10374
|
+
* @example
|
|
10375
|
+
* ```typescript
|
|
10376
|
+
* const myPlugin = Core.getPlugin('my-plugin');
|
|
10377
|
+
* if (myPlugin) {
|
|
10378
|
+
* console.log(myPlugin.version);
|
|
10379
|
+
* }
|
|
10380
|
+
* ```
|
|
10114
10381
|
*/
|
|
10115
|
-
|
|
10382
|
+
static getPlugin(name: string): IPlugin | undefined;
|
|
10116
10383
|
/**
|
|
10117
|
-
*
|
|
10384
|
+
* 检查插件是否已安装
|
|
10385
|
+
*
|
|
10386
|
+
* @param name - 插件名称
|
|
10387
|
+
* @returns 是否已安装
|
|
10388
|
+
*
|
|
10389
|
+
* @example
|
|
10390
|
+
* ```typescript
|
|
10391
|
+
* if (Core.isPluginInstalled('my-plugin')) {
|
|
10392
|
+
* console.log('Plugin is installed');
|
|
10393
|
+
* }
|
|
10394
|
+
* ```
|
|
10118
10395
|
*/
|
|
10119
|
-
|
|
10396
|
+
static isPluginInstalled(name: string): boolean;
|
|
10120
10397
|
/**
|
|
10121
|
-
*
|
|
10122
|
-
*
|
|
10123
|
-
*
|
|
10124
|
-
* @param propertyPath 属性路径
|
|
10125
|
-
* @param scene 场景实例
|
|
10398
|
+
* 初始化核心系统
|
|
10399
|
+
*
|
|
10400
|
+
* 执行核心系统的初始化逻辑。
|
|
10126
10401
|
*/
|
|
10127
|
-
|
|
10402
|
+
protected initialize(): void;
|
|
10128
10403
|
/**
|
|
10129
|
-
*
|
|
10404
|
+
* 内部更新方法
|
|
10405
|
+
*
|
|
10406
|
+
* @param deltaTime - 帧时间间隔(秒)
|
|
10130
10407
|
*/
|
|
10131
|
-
private
|
|
10132
|
-
}
|
|
10133
|
-
|
|
10134
|
-
/**
|
|
10135
|
-
* 系统数据收集器
|
|
10136
|
-
*/
|
|
10137
|
-
declare class SystemDataCollector {
|
|
10408
|
+
private updateInternal;
|
|
10138
10409
|
/**
|
|
10139
|
-
*
|
|
10140
|
-
*
|
|
10141
|
-
*
|
|
10410
|
+
* 销毁Core实例
|
|
10411
|
+
*
|
|
10412
|
+
* 清理所有资源,通常在应用程序关闭时调用。
|
|
10142
10413
|
*/
|
|
10143
|
-
|
|
10414
|
+
static destroy(): void;
|
|
10144
10415
|
}
|
|
10145
10416
|
|
|
10146
10417
|
/**
|
|
10147
|
-
*
|
|
10418
|
+
* 插件管理器
|
|
10419
|
+
*
|
|
10420
|
+
* 负责插件的注册、安装、卸载和生命周期管理。
|
|
10421
|
+
* 支持依赖检查和异步加载。
|
|
10422
|
+
*
|
|
10423
|
+
* @example
|
|
10424
|
+
* ```typescript
|
|
10425
|
+
* const core = Core.create();
|
|
10426
|
+
* const pluginManager = core.getService(PluginManager);
|
|
10427
|
+
*
|
|
10428
|
+
* // 注册插件
|
|
10429
|
+
* await pluginManager.install(new MyPlugin());
|
|
10430
|
+
*
|
|
10431
|
+
* // 查询插件
|
|
10432
|
+
* const plugin = pluginManager.getPlugin('my-plugin');
|
|
10433
|
+
*
|
|
10434
|
+
* // 卸载插件
|
|
10435
|
+
* await pluginManager.uninstall('my-plugin');
|
|
10436
|
+
* ```
|
|
10148
10437
|
*/
|
|
10149
|
-
declare class
|
|
10150
|
-
private frameTimeHistory;
|
|
10151
|
-
private maxHistoryLength;
|
|
10152
|
-
private gcCollections;
|
|
10153
|
-
private lastMemoryCheck;
|
|
10154
|
-
/**
|
|
10155
|
-
* 收集性能数据
|
|
10156
|
-
*/
|
|
10157
|
-
collectPerformanceData(performanceMonitor: any): IPerformanceDebugData;
|
|
10158
|
-
/**
|
|
10159
|
-
* 获取ECS框架整体性能数据
|
|
10160
|
-
*/
|
|
10161
|
-
private getECSPerformanceData;
|
|
10162
|
-
/**
|
|
10163
|
-
* 获取系统性能数据
|
|
10164
|
-
*/
|
|
10165
|
-
private getSystemPerformance;
|
|
10166
|
-
/**
|
|
10167
|
-
* 获取内存详情
|
|
10168
|
-
*/
|
|
10169
|
-
private getMemoryDetails;
|
|
10438
|
+
declare class PluginManager implements IService {
|
|
10170
10439
|
/**
|
|
10171
|
-
*
|
|
10440
|
+
* 已安装的插件
|
|
10172
10441
|
*/
|
|
10173
|
-
private
|
|
10174
|
-
}
|
|
10175
|
-
|
|
10176
|
-
/**
|
|
10177
|
-
* 组件数据收集器
|
|
10178
|
-
*/
|
|
10179
|
-
declare class ComponentDataCollector {
|
|
10180
|
-
private static componentSizeCache;
|
|
10442
|
+
private _plugins;
|
|
10181
10443
|
/**
|
|
10182
|
-
*
|
|
10183
|
-
* @param scene 场景实例
|
|
10444
|
+
* 插件元数据
|
|
10184
10445
|
*/
|
|
10185
|
-
|
|
10446
|
+
private _metadata;
|
|
10186
10447
|
/**
|
|
10187
|
-
*
|
|
10448
|
+
* Core实例引用
|
|
10188
10449
|
*/
|
|
10189
|
-
private
|
|
10190
|
-
private calculateQuickObjectSize;
|
|
10450
|
+
private _core;
|
|
10191
10451
|
/**
|
|
10192
|
-
*
|
|
10193
|
-
* 只在用户主动请求内存快照时调用
|
|
10194
|
-
* @param typeName 组件类型名称
|
|
10195
|
-
* @param scene 场景实例
|
|
10452
|
+
* 服务容器引用
|
|
10196
10453
|
*/
|
|
10197
|
-
|
|
10454
|
+
private _services;
|
|
10198
10455
|
/**
|
|
10199
|
-
*
|
|
10200
|
-
*
|
|
10456
|
+
* 初始化插件管理器
|
|
10457
|
+
*
|
|
10458
|
+
* @param core - Core实例
|
|
10459
|
+
* @param services - 服务容器
|
|
10201
10460
|
*/
|
|
10202
|
-
|
|
10203
|
-
static clearCache(): void;
|
|
10204
|
-
}
|
|
10205
|
-
|
|
10206
|
-
/**
|
|
10207
|
-
* 场景数据收集器
|
|
10208
|
-
*/
|
|
10209
|
-
declare class SceneDataCollector {
|
|
10210
|
-
private sceneStartTime;
|
|
10461
|
+
initialize(core: Core, services: ServiceContainer): void;
|
|
10211
10462
|
/**
|
|
10212
|
-
*
|
|
10213
|
-
*
|
|
10463
|
+
* 安装插件
|
|
10464
|
+
*
|
|
10465
|
+
* 会自动检查依赖并按正确顺序安装。
|
|
10466
|
+
*
|
|
10467
|
+
* @param plugin - 插件实例
|
|
10468
|
+
* @throws 如果依赖检查失败或安装失败
|
|
10214
10469
|
*/
|
|
10215
|
-
|
|
10470
|
+
install(plugin: IPlugin): Promise<void>;
|
|
10216
10471
|
/**
|
|
10217
|
-
*
|
|
10472
|
+
* 卸载插件
|
|
10473
|
+
*
|
|
10474
|
+
* @param name - 插件名称
|
|
10475
|
+
* @throws 如果插件未安装或卸载失败
|
|
10218
10476
|
*/
|
|
10219
|
-
|
|
10220
|
-
}
|
|
10221
|
-
|
|
10222
|
-
/**
|
|
10223
|
-
* WebSocket连接管理器
|
|
10224
|
-
*/
|
|
10225
|
-
declare class WebSocketManager {
|
|
10226
|
-
private ws?;
|
|
10227
|
-
private isConnected;
|
|
10228
|
-
private reconnectAttempts;
|
|
10229
|
-
private maxReconnectAttempts;
|
|
10230
|
-
private url;
|
|
10231
|
-
private autoReconnect;
|
|
10232
|
-
private reconnectTimer?;
|
|
10233
|
-
private onOpen?;
|
|
10234
|
-
private onClose?;
|
|
10235
|
-
private onError?;
|
|
10236
|
-
private messageHandler?;
|
|
10237
|
-
constructor(url: string, autoReconnect?: boolean);
|
|
10477
|
+
uninstall(name: string): Promise<void>;
|
|
10238
10478
|
/**
|
|
10239
|
-
*
|
|
10479
|
+
* 获取插件实例
|
|
10480
|
+
*
|
|
10481
|
+
* @param name - 插件名称
|
|
10482
|
+
* @returns 插件实例,如果未安装则返回undefined
|
|
10240
10483
|
*/
|
|
10241
|
-
|
|
10484
|
+
getPlugin(name: string): IPlugin | undefined;
|
|
10242
10485
|
/**
|
|
10243
|
-
*
|
|
10486
|
+
* 获取插件元数据
|
|
10487
|
+
*
|
|
10488
|
+
* @param name - 插件名称
|
|
10489
|
+
* @returns 插件元数据,如果未安装则返回undefined
|
|
10244
10490
|
*/
|
|
10245
|
-
|
|
10491
|
+
getMetadata(name: string): IPluginMetadata | undefined;
|
|
10246
10492
|
/**
|
|
10247
|
-
*
|
|
10493
|
+
* 获取所有已安装的插件
|
|
10494
|
+
*
|
|
10495
|
+
* @returns 插件列表
|
|
10248
10496
|
*/
|
|
10249
|
-
|
|
10497
|
+
getAllPlugins(): IPlugin[];
|
|
10250
10498
|
/**
|
|
10251
|
-
*
|
|
10499
|
+
* 获取所有插件元数据
|
|
10500
|
+
*
|
|
10501
|
+
* @returns 元数据列表
|
|
10252
10502
|
*/
|
|
10253
|
-
|
|
10503
|
+
getAllMetadata(): IPluginMetadata[];
|
|
10254
10504
|
/**
|
|
10255
|
-
*
|
|
10505
|
+
* 检查插件是否已安装
|
|
10506
|
+
*
|
|
10507
|
+
* @param name - 插件名称
|
|
10508
|
+
* @returns 是否已安装
|
|
10256
10509
|
*/
|
|
10257
|
-
|
|
10510
|
+
isInstalled(name: string): boolean;
|
|
10258
10511
|
/**
|
|
10259
|
-
*
|
|
10512
|
+
* 检查插件依赖
|
|
10513
|
+
*
|
|
10514
|
+
* @param plugin - 插件实例
|
|
10515
|
+
* @throws 如果依赖未满足
|
|
10260
10516
|
*/
|
|
10261
|
-
|
|
10517
|
+
private _checkDependencies;
|
|
10262
10518
|
/**
|
|
10263
|
-
*
|
|
10519
|
+
* 检查是否有其他插件依赖指定插件
|
|
10520
|
+
*
|
|
10521
|
+
* @param name - 插件名称
|
|
10522
|
+
* @throws 如果有其他插件依赖此插件
|
|
10264
10523
|
*/
|
|
10265
|
-
private
|
|
10524
|
+
private _checkDependents;
|
|
10266
10525
|
/**
|
|
10267
|
-
*
|
|
10526
|
+
* 释放资源
|
|
10268
10527
|
*/
|
|
10269
|
-
|
|
10270
|
-
private handleOpen;
|
|
10271
|
-
private handleClose;
|
|
10272
|
-
private handleError;
|
|
10273
|
-
private handleConnectionFailure;
|
|
10528
|
+
dispose(): void;
|
|
10274
10529
|
}
|
|
10275
10530
|
|
|
10276
10531
|
/**
|
|
10277
|
-
*
|
|
10278
|
-
*
|
|
10279
|
-
* 整合所有调试数据收集器,负责收集和发送调试数据
|
|
10532
|
+
* ECS 调试插件统计信息
|
|
10280
10533
|
*/
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10534
|
+
interface ECSDebugStats {
|
|
10535
|
+
scenes: SceneDebugInfo[];
|
|
10536
|
+
totalEntities: number;
|
|
10537
|
+
totalSystems: number;
|
|
10538
|
+
timestamp: number;
|
|
10539
|
+
}
|
|
10540
|
+
/**
|
|
10541
|
+
* 场景调试信息
|
|
10542
|
+
*/
|
|
10543
|
+
interface SceneDebugInfo {
|
|
10544
|
+
name: string;
|
|
10545
|
+
entityCount: number;
|
|
10546
|
+
systems: SystemDebugInfo[];
|
|
10547
|
+
entities: EntityDebugInfo[];
|
|
10548
|
+
}
|
|
10549
|
+
/**
|
|
10550
|
+
* 系统调试信息
|
|
10551
|
+
*/
|
|
10552
|
+
interface SystemDebugInfo {
|
|
10553
|
+
name: string;
|
|
10554
|
+
enabled: boolean;
|
|
10555
|
+
updateOrder: number;
|
|
10556
|
+
entityCount: number;
|
|
10557
|
+
performance?: {
|
|
10558
|
+
avgExecutionTime: number;
|
|
10559
|
+
maxExecutionTime: number;
|
|
10560
|
+
totalCalls: number;
|
|
10561
|
+
};
|
|
10562
|
+
}
|
|
10563
|
+
/**
|
|
10564
|
+
* 实体调试信息
|
|
10565
|
+
*/
|
|
10566
|
+
interface EntityDebugInfo {
|
|
10567
|
+
id: number;
|
|
10568
|
+
name: string;
|
|
10569
|
+
enabled: boolean;
|
|
10570
|
+
tag: number;
|
|
10571
|
+
componentCount: number;
|
|
10572
|
+
components: ComponentDebugInfo[];
|
|
10573
|
+
}
|
|
10574
|
+
/**
|
|
10575
|
+
* 组件调试信息
|
|
10576
|
+
*/
|
|
10577
|
+
interface ComponentDebugInfo {
|
|
10578
|
+
type: string;
|
|
10579
|
+
data: any;
|
|
10580
|
+
}
|
|
10581
|
+
/**
|
|
10582
|
+
* ECS 调试插件
|
|
10583
|
+
*
|
|
10584
|
+
* 提供运行时调试功能:
|
|
10585
|
+
* - 实时查看实体和组件信息
|
|
10586
|
+
* - System 执行统计
|
|
10587
|
+
* - 性能监控
|
|
10588
|
+
* - 实体查询
|
|
10589
|
+
*
|
|
10590
|
+
* @example
|
|
10591
|
+
* ```typescript
|
|
10592
|
+
* const core = Core.create();
|
|
10593
|
+
* const debugPlugin = new DebugPlugin({ autoStart: true, updateInterval: 1000 });
|
|
10594
|
+
* await core.pluginManager.install(debugPlugin);
|
|
10595
|
+
*
|
|
10596
|
+
* // 获取调试信息
|
|
10597
|
+
* const stats = debugPlugin.getStats();
|
|
10598
|
+
* console.log('Total entities:', stats.totalEntities);
|
|
10599
|
+
*
|
|
10600
|
+
* // 查询实体
|
|
10601
|
+
* const entities = debugPlugin.queryEntities({ tag: 1 });
|
|
10602
|
+
* ```
|
|
10603
|
+
*/
|
|
10604
|
+
declare class DebugPlugin implements IPlugin, IService {
|
|
10605
|
+
readonly name = "@esengine/debug-plugin";
|
|
10606
|
+
readonly version = "1.0.0";
|
|
10607
|
+
private worldManager;
|
|
10608
|
+
private updateInterval;
|
|
10609
|
+
private updateTimer;
|
|
10610
|
+
private autoStart;
|
|
10335
10611
|
/**
|
|
10336
|
-
*
|
|
10612
|
+
* 创建调试插件实例
|
|
10613
|
+
*
|
|
10614
|
+
* @param options - 配置选项
|
|
10337
10615
|
*/
|
|
10338
|
-
|
|
10616
|
+
constructor(options?: {
|
|
10617
|
+
autoStart?: boolean;
|
|
10618
|
+
updateInterval?: number;
|
|
10619
|
+
});
|
|
10339
10620
|
/**
|
|
10340
|
-
*
|
|
10621
|
+
* 安装插件
|
|
10341
10622
|
*/
|
|
10342
|
-
|
|
10623
|
+
install(_core: Core, services: ServiceContainer): Promise<void>;
|
|
10343
10624
|
/**
|
|
10344
|
-
*
|
|
10625
|
+
* 卸载插件
|
|
10345
10626
|
*/
|
|
10346
|
-
|
|
10627
|
+
uninstall(): Promise<void>;
|
|
10347
10628
|
/**
|
|
10348
|
-
*
|
|
10629
|
+
* 实现 IService 接口
|
|
10349
10630
|
*/
|
|
10350
|
-
|
|
10631
|
+
dispose(): void;
|
|
10351
10632
|
/**
|
|
10352
|
-
*
|
|
10633
|
+
* 启动调试监控
|
|
10353
10634
|
*/
|
|
10354
|
-
|
|
10635
|
+
start(): void;
|
|
10355
10636
|
/**
|
|
10356
|
-
*
|
|
10637
|
+
* 停止调试监控
|
|
10357
10638
|
*/
|
|
10358
|
-
|
|
10639
|
+
stop(): void;
|
|
10359
10640
|
/**
|
|
10360
|
-
*
|
|
10641
|
+
* 获取当前 ECS 统计信息
|
|
10361
10642
|
*/
|
|
10362
|
-
|
|
10643
|
+
getStats(): ECSDebugStats;
|
|
10363
10644
|
/**
|
|
10364
|
-
*
|
|
10645
|
+
* 获取场景调试信息
|
|
10365
10646
|
*/
|
|
10366
|
-
|
|
10367
|
-
private collectSystemMemoryStats;
|
|
10368
|
-
private calculateQuickSystemSize;
|
|
10647
|
+
getSceneInfo(scene: IScene): SceneDebugInfo;
|
|
10369
10648
|
/**
|
|
10370
|
-
*
|
|
10649
|
+
* 获取系统调试信息
|
|
10371
10650
|
*/
|
|
10372
|
-
private
|
|
10651
|
+
private getSystemInfo;
|
|
10373
10652
|
/**
|
|
10374
|
-
*
|
|
10653
|
+
* 获取实体调试信息
|
|
10375
10654
|
*/
|
|
10376
|
-
|
|
10655
|
+
getEntityInfo(entity: Entity): EntityDebugInfo;
|
|
10377
10656
|
/**
|
|
10378
|
-
*
|
|
10657
|
+
* 获取组件调试信息
|
|
10379
10658
|
*/
|
|
10380
|
-
|
|
10659
|
+
private getComponentInfo;
|
|
10381
10660
|
/**
|
|
10382
|
-
*
|
|
10661
|
+
* 查询实体
|
|
10662
|
+
*
|
|
10663
|
+
* @param filter - 查询过滤器
|
|
10383
10664
|
*/
|
|
10384
|
-
|
|
10665
|
+
queryEntities(filter: {
|
|
10666
|
+
sceneName?: string;
|
|
10667
|
+
tag?: number;
|
|
10668
|
+
name?: string;
|
|
10669
|
+
hasComponent?: string;
|
|
10670
|
+
}): EntityDebugInfo[];
|
|
10385
10671
|
/**
|
|
10386
|
-
*
|
|
10672
|
+
* 打印统计信息到日志
|
|
10387
10673
|
*/
|
|
10388
|
-
private
|
|
10674
|
+
private logStats;
|
|
10389
10675
|
/**
|
|
10390
|
-
*
|
|
10676
|
+
* 导出调试数据为 JSON
|
|
10391
10677
|
*/
|
|
10392
|
-
|
|
10678
|
+
exportJSON(): string;
|
|
10393
10679
|
}
|
|
10394
10680
|
|
|
10395
10681
|
/**
|
|
10396
|
-
*
|
|
10682
|
+
* 依赖注入装饰器
|
|
10397
10683
|
*
|
|
10398
|
-
*
|
|
10684
|
+
* 提供 @Injectable、@InjectProperty 和 @Updatable 装饰器,用于标记可注入的类和依赖注入点
|
|
10399
10685
|
*/
|
|
10400
|
-
declare class DebugConfigService implements IService {
|
|
10401
|
-
private _config;
|
|
10402
|
-
constructor();
|
|
10403
|
-
setConfig(config: IECSDebugConfig): void;
|
|
10404
|
-
getConfig(): IECSDebugConfig;
|
|
10405
|
-
isEnabled(): boolean;
|
|
10406
|
-
dispose(): void;
|
|
10407
|
-
}
|
|
10408
10686
|
|
|
10409
10687
|
/**
|
|
10410
|
-
*
|
|
10688
|
+
* 依赖注入元数据存储
|
|
10411
10689
|
*/
|
|
10412
|
-
|
|
10690
|
+
type Constructor = abstract new (...args: unknown[]) => unknown;
|
|
10691
|
+
/**
|
|
10692
|
+
* 可注入元数据接口
|
|
10693
|
+
*/
|
|
10694
|
+
interface InjectableMetadata {
|
|
10413
10695
|
/**
|
|
10414
|
-
*
|
|
10696
|
+
* 是否可注入
|
|
10415
10697
|
*/
|
|
10416
|
-
|
|
10698
|
+
injectable: boolean;
|
|
10417
10699
|
/**
|
|
10418
|
-
*
|
|
10700
|
+
* 依赖列表
|
|
10419
10701
|
*/
|
|
10420
|
-
|
|
10702
|
+
dependencies: Array<ServiceType<IService> | string | symbol>;
|
|
10421
10703
|
/**
|
|
10422
|
-
*
|
|
10704
|
+
* 属性注入映射
|
|
10705
|
+
* key: 属性名, value: 服务类型
|
|
10423
10706
|
*/
|
|
10424
|
-
|
|
10707
|
+
properties?: Map<string | symbol, ServiceType<IService>>;
|
|
10425
10708
|
}
|
|
10426
10709
|
/**
|
|
10427
|
-
*
|
|
10710
|
+
* 可更新元数据接口
|
|
10711
|
+
*/
|
|
10712
|
+
interface UpdatableMetadata {
|
|
10713
|
+
/**
|
|
10714
|
+
* 是否可更新
|
|
10715
|
+
*/
|
|
10716
|
+
updatable: boolean;
|
|
10717
|
+
/**
|
|
10718
|
+
* 更新优先级(数值越小越先执行,默认0)
|
|
10719
|
+
*/
|
|
10720
|
+
priority: number;
|
|
10721
|
+
}
|
|
10722
|
+
/**
|
|
10723
|
+
* @Injectable() 装饰器
|
|
10428
10724
|
*
|
|
10429
|
-
*
|
|
10430
|
-
* 插件提供了一种扩展框架功能的标准方式。
|
|
10725
|
+
* 标记类为可注入的服务,使其可以通过ServiceContainer进行依赖注入
|
|
10431
10726
|
*
|
|
10432
10727
|
* @example
|
|
10433
10728
|
* ```typescript
|
|
10434
|
-
*
|
|
10435
|
-
*
|
|
10436
|
-
*
|
|
10437
|
-
*
|
|
10729
|
+
* @Injectable()
|
|
10730
|
+
* class TimeService implements IService {
|
|
10731
|
+
* constructor() {}
|
|
10732
|
+
* dispose() {}
|
|
10733
|
+
* }
|
|
10438
10734
|
*
|
|
10439
|
-
*
|
|
10440
|
-
*
|
|
10441
|
-
*
|
|
10735
|
+
* @Injectable()
|
|
10736
|
+
* class PhysicsSystem extends EntitySystem {
|
|
10737
|
+
* @InjectProperty(TimeService)
|
|
10738
|
+
* private timeService!: TimeService;
|
|
10442
10739
|
*
|
|
10443
|
-
*
|
|
10444
|
-
*
|
|
10445
|
-
* if (world) {
|
|
10446
|
-
* world.addSystem(new MySystem());
|
|
10447
|
-
* }
|
|
10740
|
+
* constructor() {
|
|
10741
|
+
* super(Matcher.empty());
|
|
10448
10742
|
* }
|
|
10743
|
+
* }
|
|
10744
|
+
* ```
|
|
10745
|
+
*/
|
|
10746
|
+
declare function Injectable(): ClassDecorator;
|
|
10747
|
+
/**
|
|
10748
|
+
* @Updatable() 装饰器
|
|
10449
10749
|
*
|
|
10450
|
-
*
|
|
10451
|
-
*
|
|
10750
|
+
* 标记服务类为可更新的,使其在每帧自动被ServiceContainer调用update方法。
|
|
10751
|
+
* 使用此装饰器的类必须实现IUpdatable接口(包含update方法)。
|
|
10752
|
+
*
|
|
10753
|
+
* @param priority - 更新优先级(数值越小越先执行,默认0)
|
|
10754
|
+
* @throws 如果类没有实现update方法,将在运行时抛出错误
|
|
10755
|
+
*
|
|
10756
|
+
* @example
|
|
10757
|
+
* ```typescript
|
|
10758
|
+
* @Injectable()
|
|
10759
|
+
* @Updatable()
|
|
10760
|
+
* class TimerManager implements IService, IUpdatable {
|
|
10761
|
+
* update(deltaTime?: number) {
|
|
10762
|
+
* // 每帧更新逻辑
|
|
10452
10763
|
* }
|
|
10764
|
+
* dispose() {}
|
|
10765
|
+
* }
|
|
10766
|
+
*
|
|
10767
|
+
* // 指定优先级
|
|
10768
|
+
* @Injectable()
|
|
10769
|
+
* @Updatable(10)
|
|
10770
|
+
* class PhysicsManager implements IService, IUpdatable {
|
|
10771
|
+
* update() { }
|
|
10772
|
+
* dispose() {}
|
|
10453
10773
|
* }
|
|
10454
10774
|
* ```
|
|
10455
10775
|
*/
|
|
10456
|
-
|
|
10776
|
+
declare function Updatable(priority?: number): ClassDecorator;
|
|
10777
|
+
/**
|
|
10778
|
+
* @InjectProperty() 装饰器
|
|
10779
|
+
*
|
|
10780
|
+
* 通过属性装饰器注入依赖
|
|
10781
|
+
*
|
|
10782
|
+
* 注入时机:在构造函数执行后、onInitialize() 调用前完成
|
|
10783
|
+
*
|
|
10784
|
+
* @param serviceType 服务类型
|
|
10785
|
+
*
|
|
10786
|
+
* @example
|
|
10787
|
+
* ```typescript
|
|
10788
|
+
* @Injectable()
|
|
10789
|
+
* class PhysicsSystem extends EntitySystem {
|
|
10790
|
+
* @InjectProperty(TimeService)
|
|
10791
|
+
* private timeService!: TimeService;
|
|
10792
|
+
*
|
|
10793
|
+
* @InjectProperty(CollisionService)
|
|
10794
|
+
* private collision!: CollisionService;
|
|
10795
|
+
*
|
|
10796
|
+
* constructor() {
|
|
10797
|
+
* super(Matcher.empty());
|
|
10798
|
+
* }
|
|
10799
|
+
*
|
|
10800
|
+
* public onInitialize(): void {
|
|
10801
|
+
* // 此时属性已注入完成,可以安全使用
|
|
10802
|
+
* console.log(this.timeService.getDeltaTime());
|
|
10803
|
+
* }
|
|
10804
|
+
* }
|
|
10805
|
+
* ```
|
|
10806
|
+
*/
|
|
10807
|
+
declare function InjectProperty(serviceType: ServiceType<IService>): PropertyDecorator;
|
|
10808
|
+
/**
|
|
10809
|
+
* 获取属性注入元数据
|
|
10810
|
+
*
|
|
10811
|
+
* @param target 目标类
|
|
10812
|
+
* @returns 属性名到服务类型的映射
|
|
10813
|
+
*/
|
|
10814
|
+
declare function getPropertyInjectMetadata(target: Constructor): Map<string | symbol, ServiceType<IService>>;
|
|
10815
|
+
/**
|
|
10816
|
+
* 创建实例并自动注入依赖
|
|
10817
|
+
*
|
|
10818
|
+
* @param constructor 构造函数
|
|
10819
|
+
* @param container 服务容器
|
|
10820
|
+
* @returns 创建的实例
|
|
10821
|
+
*
|
|
10822
|
+
* @example
|
|
10823
|
+
* ```typescript
|
|
10824
|
+
* const instance = createInstance(MySystem, container);
|
|
10825
|
+
* ```
|
|
10826
|
+
*/
|
|
10827
|
+
declare function createInstance<T>(constructor: new (...args: any[]) => T, container: ServiceContainer): T;
|
|
10828
|
+
/**
|
|
10829
|
+
* 为实例注入属性依赖
|
|
10830
|
+
*
|
|
10831
|
+
* @param instance 目标实例
|
|
10832
|
+
* @param container 服务容器
|
|
10833
|
+
*/
|
|
10834
|
+
declare function injectProperties<T extends object>(instance: T, container: ServiceContainer): void;
|
|
10835
|
+
/**
|
|
10836
|
+
* 检查类是否标记为可更新
|
|
10837
|
+
*
|
|
10838
|
+
* @param target 目标类
|
|
10839
|
+
* @returns 是否可更新
|
|
10840
|
+
*/
|
|
10841
|
+
declare function isUpdatable(target: Constructor): boolean;
|
|
10842
|
+
/**
|
|
10843
|
+
* 获取类的可更新元数据
|
|
10844
|
+
*
|
|
10845
|
+
* @param target 目标类
|
|
10846
|
+
* @returns 可更新元数据
|
|
10847
|
+
*/
|
|
10848
|
+
declare function getUpdatableMetadata(target: Constructor): UpdatableMetadata | undefined;
|
|
10849
|
+
/**
|
|
10850
|
+
* 注册可注入的服务到容器
|
|
10851
|
+
*
|
|
10852
|
+
* 自动检测@Injectable装饰器并注册服务
|
|
10853
|
+
*
|
|
10854
|
+
* @param container 服务容器
|
|
10855
|
+
* @param serviceType 服务类型
|
|
10856
|
+
* @param singleton 是否注册为单例(默认true)
|
|
10857
|
+
*
|
|
10858
|
+
* @example
|
|
10859
|
+
* ```typescript
|
|
10860
|
+
* @Injectable()
|
|
10861
|
+
* class MyService implements IService {
|
|
10862
|
+
* dispose() {}
|
|
10863
|
+
* }
|
|
10864
|
+
*
|
|
10865
|
+
* // 自动注册
|
|
10866
|
+
* registerInjectable(Core.services, MyService);
|
|
10867
|
+
* ```
|
|
10868
|
+
*/
|
|
10869
|
+
declare function registerInjectable<T extends IService>(container: ServiceContainer, serviceType: ServiceType<T>, singleton?: boolean): void;
|
|
10870
|
+
|
|
10871
|
+
/**
|
|
10872
|
+
* 用于包装事件的一个小类
|
|
10873
|
+
*/
|
|
10874
|
+
declare class FuncPack<TContext = unknown> {
|
|
10875
|
+
/** 函数 */
|
|
10876
|
+
func: Function;
|
|
10877
|
+
/** 上下文 */
|
|
10878
|
+
context: TContext;
|
|
10879
|
+
constructor(func: Function, context: TContext);
|
|
10880
|
+
}
|
|
10881
|
+
/**
|
|
10882
|
+
* 用于事件管理
|
|
10883
|
+
*/
|
|
10884
|
+
declare class Emitter<T, TContext = unknown> {
|
|
10885
|
+
private _messageTable;
|
|
10886
|
+
constructor();
|
|
10457
10887
|
/**
|
|
10458
|
-
*
|
|
10459
|
-
*
|
|
10460
|
-
*
|
|
10888
|
+
* 开始监听项
|
|
10889
|
+
* @param eventType 监听类型
|
|
10890
|
+
* @param handler 监听函数
|
|
10891
|
+
* @param context 监听上下文
|
|
10461
10892
|
*/
|
|
10462
|
-
|
|
10893
|
+
addObserver(eventType: T, handler: Function, context: TContext): void;
|
|
10463
10894
|
/**
|
|
10464
|
-
*
|
|
10465
|
-
*
|
|
10466
|
-
*
|
|
10895
|
+
* 移除监听项
|
|
10896
|
+
* @param eventType 事件类型
|
|
10897
|
+
* @param handler 事件函数
|
|
10467
10898
|
*/
|
|
10468
|
-
|
|
10899
|
+
removeObserver(eventType: T, handler: Function): void;
|
|
10469
10900
|
/**
|
|
10470
|
-
*
|
|
10471
|
-
*
|
|
10472
|
-
*
|
|
10901
|
+
* 触发该事件
|
|
10902
|
+
* @param eventType 事件类型
|
|
10903
|
+
* @param data 事件数据
|
|
10473
10904
|
*/
|
|
10474
|
-
|
|
10905
|
+
emit<TData = unknown>(eventType: T, ...data: TData[]): void;
|
|
10475
10906
|
/**
|
|
10476
|
-
*
|
|
10477
|
-
*
|
|
10478
|
-
*
|
|
10479
|
-
* 可以是同步或异步的。
|
|
10480
|
-
*
|
|
10481
|
-
* @param core - Core实例,用于访问World等
|
|
10482
|
-
* @param services - 服务容器,用于注册服务
|
|
10907
|
+
* 判断是否存在该类型的观察者
|
|
10908
|
+
* @param eventType 事件类型
|
|
10909
|
+
* @param handler 事件函数
|
|
10483
10910
|
*/
|
|
10484
|
-
|
|
10911
|
+
hasObserver(eventType: T, handler: Function): boolean;
|
|
10485
10912
|
/**
|
|
10486
|
-
*
|
|
10487
|
-
*
|
|
10488
|
-
* 清理插件占用的资源。
|
|
10489
|
-
* 可以是同步或异步的。
|
|
10913
|
+
* 移除指定事件类型的所有监听器
|
|
10914
|
+
* @param eventType 事件类型
|
|
10490
10915
|
*/
|
|
10491
|
-
|
|
10916
|
+
removeAllObservers(eventType?: T): void;
|
|
10917
|
+
/**
|
|
10918
|
+
* 释放所有资源,清理所有监听器
|
|
10919
|
+
*/
|
|
10920
|
+
dispose(): void;
|
|
10921
|
+
/**
|
|
10922
|
+
* 获取事件类型数量
|
|
10923
|
+
*/
|
|
10924
|
+
getEventTypeCount(): number;
|
|
10925
|
+
/**
|
|
10926
|
+
* 获取指定事件类型的监听器数量
|
|
10927
|
+
* @param eventType 事件类型
|
|
10928
|
+
*/
|
|
10929
|
+
getObserverCount(eventType: T): number;
|
|
10492
10930
|
}
|
|
10931
|
+
|
|
10493
10932
|
/**
|
|
10494
|
-
*
|
|
10933
|
+
* 全局管理器的基类。所有全局管理器都应该从此类继承。
|
|
10495
10934
|
*/
|
|
10496
|
-
|
|
10935
|
+
declare class GlobalManager {
|
|
10936
|
+
private _enabled;
|
|
10497
10937
|
/**
|
|
10498
|
-
*
|
|
10938
|
+
* 获取或设置管理器是否启用
|
|
10499
10939
|
*/
|
|
10500
|
-
|
|
10940
|
+
get enabled(): boolean;
|
|
10941
|
+
set enabled(value: boolean);
|
|
10501
10942
|
/**
|
|
10502
|
-
*
|
|
10943
|
+
* 设置管理器是否启用
|
|
10944
|
+
* @param isEnabled 如果为true,则启用管理器;否则禁用管理器
|
|
10503
10945
|
*/
|
|
10504
|
-
|
|
10946
|
+
setEnabled(isEnabled: boolean): void;
|
|
10505
10947
|
/**
|
|
10506
|
-
*
|
|
10948
|
+
* 在启用管理器时调用的回调方法
|
|
10507
10949
|
*/
|
|
10508
|
-
|
|
10950
|
+
protected onEnabled(): void;
|
|
10509
10951
|
/**
|
|
10510
|
-
*
|
|
10952
|
+
* 在禁用管理器时调用的回调方法
|
|
10511
10953
|
*/
|
|
10512
|
-
|
|
10954
|
+
protected onDisabled(): void;
|
|
10513
10955
|
/**
|
|
10514
|
-
*
|
|
10956
|
+
* 更新管理器状态的方法
|
|
10515
10957
|
*/
|
|
10516
|
-
|
|
10958
|
+
update(): void;
|
|
10517
10959
|
}
|
|
10518
10960
|
|
|
10519
10961
|
/**
|
|
10520
|
-
*
|
|
10521
|
-
*
|
|
10522
|
-
* 职责:
|
|
10523
|
-
* - 提供全局服务(Timer、Performance、Pool等)
|
|
10524
|
-
* - 管理场景生命周期(内置SceneManager)
|
|
10525
|
-
* - 管理全局管理器的生命周期
|
|
10526
|
-
* - 提供统一的游戏循环更新入口
|
|
10527
|
-
*
|
|
10528
|
-
* @example
|
|
10529
|
-
* ```typescript
|
|
10530
|
-
* // 初始化并设置场景
|
|
10531
|
-
* Core.create({ debug: true });
|
|
10532
|
-
* Core.setScene(new GameScene());
|
|
10962
|
+
* 定时器管理器
|
|
10533
10963
|
*
|
|
10534
|
-
*
|
|
10535
|
-
|
|
10536
|
-
|
|
10964
|
+
* 允许动作的延迟和重复执行
|
|
10965
|
+
*/
|
|
10966
|
+
declare class TimerManager implements IService, IUpdatable {
|
|
10967
|
+
private _timers;
|
|
10968
|
+
update(): void;
|
|
10969
|
+
/**
|
|
10970
|
+
* 调度一个一次性或重复的计时器,该计时器将调用已传递的动作
|
|
10971
|
+
* @param timeInSeconds
|
|
10972
|
+
* @param repeats
|
|
10973
|
+
* @param context
|
|
10974
|
+
* @param onTime
|
|
10975
|
+
*/
|
|
10976
|
+
schedule<TContext = unknown>(timeInSeconds: number, repeats: boolean, context: TContext, onTime: (timer: ITimer<TContext>) => void): Timer<TContext>;
|
|
10977
|
+
/**
|
|
10978
|
+
* 释放资源
|
|
10979
|
+
*/
|
|
10980
|
+
dispose(): void;
|
|
10981
|
+
}
|
|
10982
|
+
|
|
10983
|
+
/**
|
|
10984
|
+
* Entity类型安全工具函数
|
|
10985
|
+
*
|
|
10986
|
+
* 提供类型安全的组件操作工具函数,无需修改Entity类
|
|
10987
|
+
*/
|
|
10988
|
+
|
|
10989
|
+
/**
|
|
10990
|
+
* 获取组件,如果不存在则抛出错误
|
|
10991
|
+
*
|
|
10992
|
+
* @param entity - 实体实例
|
|
10993
|
+
* @param componentType - 组件类型构造函数
|
|
10994
|
+
* @returns 组件实例(保证非空)
|
|
10995
|
+
* @throws {Error} 如果组件不存在
|
|
10996
|
+
*
|
|
10997
|
+
* @example
|
|
10998
|
+
* ```typescript
|
|
10999
|
+
* const position = requireComponent(entity, Position);
|
|
11000
|
+
* position.x += 10;
|
|
11001
|
+
* ```
|
|
11002
|
+
*/
|
|
11003
|
+
declare function requireComponent<T extends ComponentConstructor>(entity: Entity, componentType: T): ComponentInstance<T>;
|
|
11004
|
+
/**
|
|
11005
|
+
* 尝试获取组件
|
|
11006
|
+
*
|
|
11007
|
+
* @param entity - 实体实例
|
|
11008
|
+
* @param componentType - 组件类型构造函数
|
|
11009
|
+
* @returns 组件实例或undefined
|
|
11010
|
+
*
|
|
11011
|
+
* @example
|
|
11012
|
+
* ```typescript
|
|
11013
|
+
* const health = tryGetComponent(entity, Health);
|
|
11014
|
+
* if (health) {
|
|
11015
|
+
* health.value -= 10;
|
|
10537
11016
|
* }
|
|
11017
|
+
* ```
|
|
11018
|
+
*/
|
|
11019
|
+
declare function tryGetComponent<T extends ComponentConstructor>(entity: Entity, componentType: T): ComponentInstance<T> | undefined;
|
|
11020
|
+
/**
|
|
11021
|
+
* 批量获取组件
|
|
10538
11022
|
*
|
|
10539
|
-
*
|
|
10540
|
-
*
|
|
10541
|
-
*
|
|
11023
|
+
* @param entity - 实体实例
|
|
11024
|
+
* @param types - 组件类型构造函数数组
|
|
11025
|
+
* @returns 组件实例元组,每个元素可能为null
|
|
11026
|
+
*
|
|
11027
|
+
* @example
|
|
11028
|
+
* ```typescript
|
|
11029
|
+
* const [pos, vel, health] = getComponents(entity, Position, Velocity, Health);
|
|
11030
|
+
* if (pos && vel && health) {
|
|
11031
|
+
* pos.x += vel.dx;
|
|
11032
|
+
* }
|
|
11033
|
+
* ```
|
|
11034
|
+
*/
|
|
11035
|
+
declare function getComponents<T extends readonly ComponentConstructor[]>(entity: Entity, ...types: T): {
|
|
11036
|
+
[K in keyof T]: ComponentInstance<T[K]> | null;
|
|
11037
|
+
};
|
|
11038
|
+
/**
|
|
11039
|
+
* 检查实体是否拥有所有指定的组件
|
|
11040
|
+
*
|
|
11041
|
+
* @param entity - 实体实例
|
|
11042
|
+
* @param types - 组件类型构造函数数组
|
|
11043
|
+
* @returns 如果拥有所有组件返回true,否则返回false
|
|
11044
|
+
*
|
|
11045
|
+
* @example
|
|
11046
|
+
* ```typescript
|
|
11047
|
+
* if (hasComponents(entity, Position, Velocity)) {
|
|
11048
|
+
* const pos = entity.getComponent(Position)!;
|
|
11049
|
+
* const vel = entity.getComponent(Velocity)!;
|
|
11050
|
+
* }
|
|
11051
|
+
* ```
|
|
11052
|
+
*/
|
|
11053
|
+
declare function hasComponents(entity: Entity, ...types: ComponentConstructor[]): boolean;
|
|
11054
|
+
/**
|
|
11055
|
+
* 检查实体是否拥有至少一个指定的组件
|
|
11056
|
+
*
|
|
11057
|
+
* @param entity - 实体实例
|
|
11058
|
+
* @param types - 组件类型构造函数数组
|
|
11059
|
+
* @returns 如果拥有任意一个组件返回true,否则返回false
|
|
11060
|
+
*/
|
|
11061
|
+
declare function hasAnyComponent(entity: Entity, ...types: ComponentConstructor[]): boolean;
|
|
11062
|
+
/**
|
|
11063
|
+
* 添加组件并立即配置
|
|
11064
|
+
*
|
|
11065
|
+
* @param entity - 实体实例
|
|
11066
|
+
* @param component - 组件实例
|
|
11067
|
+
* @param configure - 配置回调函数
|
|
11068
|
+
* @returns 实体实例(支持链式调用)
|
|
11069
|
+
*
|
|
11070
|
+
* @example
|
|
11071
|
+
* ```typescript
|
|
11072
|
+
* addAndConfigure(entity, new Health(), health => {
|
|
11073
|
+
* health.maxValue = 100;
|
|
11074
|
+
* health.value = 50;
|
|
10542
11075
|
* });
|
|
11076
|
+
* ```
|
|
11077
|
+
*/
|
|
11078
|
+
declare function addAndConfigure<T extends Component>(entity: Entity, component: T, configure: (component: T) => void): Entity;
|
|
11079
|
+
/**
|
|
11080
|
+
* 获取或添加组件
|
|
10543
11081
|
*
|
|
10544
|
-
*
|
|
10545
|
-
* Core.loadScene(new MenuScene()); // 延迟切换
|
|
10546
|
-
* Core.setScene(new GameScene()); // 立即切换
|
|
11082
|
+
* 如果组件已存在则返回现有组件,否则通过工厂函数创建并添加
|
|
10547
11083
|
*
|
|
10548
|
-
*
|
|
10549
|
-
*
|
|
11084
|
+
* @param entity - 实体实例
|
|
11085
|
+
* @param componentType - 组件类型构造函数
|
|
11086
|
+
* @param factory - 组件工厂函数(仅在组件不存在时调用)
|
|
11087
|
+
* @returns 组件实例
|
|
11088
|
+
*
|
|
11089
|
+
* @example
|
|
11090
|
+
* ```typescript
|
|
11091
|
+
* const health = getOrAddComponent(entity, Health, () => new Health(100));
|
|
10550
11092
|
* ```
|
|
10551
11093
|
*/
|
|
10552
|
-
declare
|
|
11094
|
+
declare function getOrAddComponent<T extends ComponentConstructor>(entity: Entity, componentType: T, factory: () => ComponentInstance<T>): ComponentInstance<T>;
|
|
11095
|
+
/**
|
|
11096
|
+
* 更新组件的部分字段
|
|
11097
|
+
*
|
|
11098
|
+
* @param entity - 实体实例
|
|
11099
|
+
* @param componentType - 组件类型构造函数
|
|
11100
|
+
* @param data - 要更新的部分数据
|
|
11101
|
+
* @returns 如果更新成功返回true,组件不存在返回false
|
|
11102
|
+
*
|
|
11103
|
+
* @example
|
|
11104
|
+
* ```typescript
|
|
11105
|
+
* updateComponent(entity, Position, { x: 100 });
|
|
11106
|
+
* ```
|
|
11107
|
+
*/
|
|
11108
|
+
declare function updateComponent<T extends ComponentConstructor>(entity: Entity, componentType: T, data: Partial<ComponentInstance<T>>): boolean;
|
|
11109
|
+
/**
|
|
11110
|
+
* 类型安全的实体构建器
|
|
11111
|
+
*
|
|
11112
|
+
* @example
|
|
11113
|
+
* ```typescript
|
|
11114
|
+
* const player = buildEntity(scene.createEntity("Player"))
|
|
11115
|
+
* .with(new Position(100, 100))
|
|
11116
|
+
* .with(new Velocity(0, 0))
|
|
11117
|
+
* .withTag(1)
|
|
11118
|
+
* .build();
|
|
11119
|
+
* ```
|
|
11120
|
+
*/
|
|
11121
|
+
declare class TypedEntityBuilder {
|
|
11122
|
+
private _entity;
|
|
11123
|
+
constructor(entity: Entity);
|
|
10553
11124
|
/**
|
|
10554
|
-
*
|
|
10555
|
-
*
|
|
10556
|
-
* 当设置为true时,游戏循环将暂停执行。
|
|
11125
|
+
* 添加组件
|
|
10557
11126
|
*/
|
|
10558
|
-
|
|
11127
|
+
with<T extends Component>(component: T): this;
|
|
10559
11128
|
/**
|
|
10560
|
-
*
|
|
10561
|
-
*
|
|
10562
|
-
* 可能为null表示Core尚未初始化或已被销毁
|
|
11129
|
+
* 添加并配置组件
|
|
10563
11130
|
*/
|
|
10564
|
-
|
|
11131
|
+
withConfigured<T extends Component>(component: T, configure: (component: T) => void): this;
|
|
10565
11132
|
/**
|
|
10566
|
-
*
|
|
11133
|
+
* 设置标签
|
|
10567
11134
|
*/
|
|
10568
|
-
|
|
11135
|
+
withTag(tag: number): this;
|
|
10569
11136
|
/**
|
|
10570
|
-
*
|
|
10571
|
-
*
|
|
10572
|
-
* 控制是否启用ECS实体系统功能。
|
|
11137
|
+
* 设置名称
|
|
10573
11138
|
*/
|
|
10574
|
-
|
|
11139
|
+
withName(name: string): this;
|
|
10575
11140
|
/**
|
|
10576
|
-
*
|
|
10577
|
-
*
|
|
10578
|
-
* 在调试模式下会启用额外的性能监控和错误检查。
|
|
11141
|
+
* 设置激活状态
|
|
10579
11142
|
*/
|
|
10580
|
-
|
|
11143
|
+
withActive(active: boolean): this;
|
|
10581
11144
|
/**
|
|
10582
|
-
*
|
|
10583
|
-
*
|
|
10584
|
-
* 管理所有服务的注册、解析和生命周期。
|
|
11145
|
+
* 设置启用状态
|
|
10585
11146
|
*/
|
|
10586
|
-
|
|
11147
|
+
withEnabled(enabled: boolean): this;
|
|
10587
11148
|
/**
|
|
10588
|
-
*
|
|
10589
|
-
*
|
|
10590
|
-
* 负责管理所有的游戏定时器。
|
|
11149
|
+
* 设置更新顺序
|
|
10591
11150
|
*/
|
|
10592
|
-
|
|
11151
|
+
withUpdateOrder(order: number): this;
|
|
10593
11152
|
/**
|
|
10594
|
-
*
|
|
10595
|
-
*
|
|
10596
|
-
* 监控游戏性能并提供优化建议。
|
|
11153
|
+
* 添加子实体
|
|
10597
11154
|
*/
|
|
10598
|
-
|
|
11155
|
+
withChild(child: Entity): this;
|
|
10599
11156
|
/**
|
|
10600
|
-
*
|
|
10601
|
-
*
|
|
10602
|
-
* 管理所有对象池的生命周期。
|
|
11157
|
+
* 完成构建
|
|
10603
11158
|
*/
|
|
10604
|
-
|
|
11159
|
+
build(): Entity;
|
|
10605
11160
|
/**
|
|
10606
|
-
*
|
|
10607
|
-
*
|
|
10608
|
-
* 负责收集和发送调试数据。
|
|
11161
|
+
* 获取正在构建的实体
|
|
10609
11162
|
*/
|
|
10610
|
-
|
|
11163
|
+
get entity(): Entity;
|
|
11164
|
+
}
|
|
11165
|
+
/**
|
|
11166
|
+
* 创建类型安全的实体构建器
|
|
11167
|
+
*
|
|
11168
|
+
* @param entity - 要包装的实体
|
|
11169
|
+
* @returns 实体构建器
|
|
11170
|
+
*/
|
|
11171
|
+
declare function buildEntity(entity: Entity): TypedEntityBuilder;
|
|
11172
|
+
|
|
11173
|
+
/**
|
|
11174
|
+
* 类型工具类
|
|
11175
|
+
* 提供类型相关的实用方法
|
|
11176
|
+
*/
|
|
11177
|
+
declare class TypeUtils {
|
|
10611
11178
|
/**
|
|
10612
|
-
*
|
|
10613
|
-
*
|
|
10614
|
-
*
|
|
11179
|
+
* 获取对象的类型
|
|
11180
|
+
* @param obj 对象
|
|
11181
|
+
* @returns 对象的构造函数
|
|
10615
11182
|
*/
|
|
10616
|
-
|
|
11183
|
+
static getType(obj: any): any;
|
|
11184
|
+
}
|
|
11185
|
+
|
|
11186
|
+
/**
|
|
11187
|
+
* 数字扩展工具类
|
|
11188
|
+
* 提供数字转换的实用方法
|
|
11189
|
+
*/
|
|
11190
|
+
declare class NumberExtension {
|
|
10617
11191
|
/**
|
|
10618
|
-
*
|
|
10619
|
-
*
|
|
10620
|
-
*
|
|
11192
|
+
* 将值转换为数字
|
|
11193
|
+
* @param value 要转换的值
|
|
11194
|
+
* @returns 转换后的数字,如果值为undefined则返回0
|
|
10621
11195
|
*/
|
|
10622
|
-
|
|
11196
|
+
static toNumber(value: unknown): number;
|
|
11197
|
+
}
|
|
11198
|
+
|
|
11199
|
+
/**
|
|
11200
|
+
* 可池化对象接口
|
|
11201
|
+
*/
|
|
11202
|
+
interface IPoolable {
|
|
10623
11203
|
/**
|
|
10624
|
-
*
|
|
10625
|
-
*
|
|
10626
|
-
* 管理所有插件的生命周期。
|
|
11204
|
+
* 重置对象状态,准备重用
|
|
10627
11205
|
*/
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
11206
|
+
reset(): void;
|
|
11207
|
+
}
|
|
11208
|
+
/**
|
|
11209
|
+
* 对象池统计信息
|
|
11210
|
+
*/
|
|
11211
|
+
interface PoolStats {
|
|
11212
|
+
/** 池中对象数量 */
|
|
11213
|
+
size: number;
|
|
11214
|
+
/** 池的最大大小 */
|
|
11215
|
+
maxSize: number;
|
|
11216
|
+
/** 总共创建的对象数量 */
|
|
11217
|
+
totalCreated: number;
|
|
11218
|
+
/** 总共获取的次数 */
|
|
11219
|
+
totalObtained: number;
|
|
11220
|
+
/** 总共释放的次数 */
|
|
11221
|
+
totalReleased: number;
|
|
11222
|
+
/** 命中率(从池中获取的比例) */
|
|
11223
|
+
hitRate: number;
|
|
11224
|
+
/** 内存使用估算(字节) */
|
|
11225
|
+
estimatedMemoryUsage: number;
|
|
11226
|
+
}
|
|
11227
|
+
|
|
11228
|
+
/**
|
|
11229
|
+
* 高性能通用对象池
|
|
11230
|
+
* 支持任意类型的对象池化,包含详细的统计信息
|
|
11231
|
+
*/
|
|
11232
|
+
declare class Pool<T extends IPoolable> {
|
|
11233
|
+
private static _pools;
|
|
11234
|
+
private _objects;
|
|
11235
|
+
private _createFn;
|
|
11236
|
+
private _maxSize;
|
|
11237
|
+
private _stats;
|
|
11238
|
+
private _objectSize;
|
|
10633
11239
|
/**
|
|
10634
|
-
*
|
|
10635
|
-
*
|
|
10636
|
-
* @param
|
|
11240
|
+
* 构造函数
|
|
11241
|
+
* @param createFn 创建对象的函数
|
|
11242
|
+
* @param maxSize 池的最大大小,默认100
|
|
11243
|
+
* @param estimatedObjectSize 估算的单个对象大小(字节),默认1024
|
|
10637
11244
|
*/
|
|
10638
|
-
|
|
11245
|
+
constructor(createFn: () => T, maxSize?: number, estimatedObjectSize?: number);
|
|
10639
11246
|
/**
|
|
10640
|
-
*
|
|
10641
|
-
*
|
|
10642
|
-
* @
|
|
11247
|
+
* 获取指定类型的对象池
|
|
11248
|
+
* @param type 对象类型
|
|
11249
|
+
* @param maxSize 池的最大大小
|
|
11250
|
+
* @param estimatedObjectSize 估算的单个对象大小
|
|
11251
|
+
* @returns 对象池实例
|
|
10643
11252
|
*/
|
|
10644
|
-
static
|
|
11253
|
+
static getPool<T extends IPoolable>(type: new (...args: unknown[]) => T, maxSize?: number, estimatedObjectSize?: number): Pool<T>;
|
|
10645
11254
|
/**
|
|
10646
|
-
*
|
|
10647
|
-
*
|
|
10648
|
-
* 用于注册和解析自定义服务。
|
|
10649
|
-
*
|
|
10650
|
-
* @returns 服务容器实例
|
|
10651
|
-
* @throws 如果Core实例未创建
|
|
10652
|
-
*
|
|
10653
|
-
* @example
|
|
10654
|
-
* ```typescript
|
|
10655
|
-
* // 注册自定义服务
|
|
10656
|
-
* Core.services.registerSingleton(MyService);
|
|
10657
|
-
*
|
|
10658
|
-
* // 解析服务
|
|
10659
|
-
* const myService = Core.services.resolve(MyService);
|
|
10660
|
-
* ```
|
|
11255
|
+
* 从池中获取对象
|
|
11256
|
+
* @returns 对象实例
|
|
10661
11257
|
*/
|
|
10662
|
-
|
|
11258
|
+
obtain(): T;
|
|
10663
11259
|
/**
|
|
10664
|
-
*
|
|
10665
|
-
*
|
|
10666
|
-
* 用于管理多个独立的World实例(高级用户)。
|
|
10667
|
-
*
|
|
10668
|
-
* @returns WorldManager实例
|
|
10669
|
-
* @throws 如果Core实例未创建
|
|
10670
|
-
*
|
|
10671
|
-
* @example
|
|
10672
|
-
* ```typescript
|
|
10673
|
-
* // 创建多个游戏房间
|
|
10674
|
-
* const wm = Core.worldManager;
|
|
10675
|
-
* const room1 = wm.createWorld('room_001');
|
|
10676
|
-
* room1.createScene('game', new GameScene());
|
|
10677
|
-
* room1.start();
|
|
10678
|
-
* ```
|
|
11260
|
+
* 释放对象回池中
|
|
11261
|
+
* @param obj 要释放的对象
|
|
10679
11262
|
*/
|
|
10680
|
-
|
|
11263
|
+
release(obj: T): void;
|
|
10681
11264
|
/**
|
|
10682
|
-
*
|
|
10683
|
-
*
|
|
10684
|
-
* 如果实例已存在,则返回现有实例。
|
|
10685
|
-
*
|
|
10686
|
-
* @param config - Core配置,也可以直接传入boolean表示debug模式(向后兼容)
|
|
10687
|
-
* @returns Core实例
|
|
10688
|
-
*
|
|
10689
|
-
* @example
|
|
10690
|
-
* ```typescript
|
|
10691
|
-
* // 方式1:使用配置对象
|
|
10692
|
-
* Core.create({
|
|
10693
|
-
* debug: true,
|
|
10694
|
-
* enableEntitySystems: true,
|
|
10695
|
-
* debugConfig: {
|
|
10696
|
-
* enabled: true,
|
|
10697
|
-
* websocketUrl: 'ws://localhost:9229'
|
|
10698
|
-
* }
|
|
10699
|
-
* });
|
|
10700
|
-
*
|
|
10701
|
-
* // 方式2:简单模式(向后兼容)
|
|
10702
|
-
* Core.create(true); // debug = true
|
|
10703
|
-
* ```
|
|
11265
|
+
* 获取池统计信息
|
|
11266
|
+
* @returns 统计信息对象
|
|
10704
11267
|
*/
|
|
10705
|
-
|
|
11268
|
+
getStats(): Readonly<PoolStats>;
|
|
10706
11269
|
/**
|
|
10707
|
-
*
|
|
10708
|
-
*
|
|
10709
|
-
* @param scene - 要设置的场景
|
|
10710
|
-
* @returns 设置的场景实例
|
|
10711
|
-
*
|
|
10712
|
-
* @example
|
|
10713
|
-
* ```typescript
|
|
10714
|
-
* Core.create({ debug: true });
|
|
10715
|
-
*
|
|
10716
|
-
* // 创建并设置场景
|
|
10717
|
-
* const gameScene = new GameScene();
|
|
10718
|
-
* Core.setScene(gameScene);
|
|
10719
|
-
* ```
|
|
11270
|
+
* 清空池
|
|
10720
11271
|
*/
|
|
10721
|
-
|
|
11272
|
+
clear(): void;
|
|
10722
11273
|
/**
|
|
10723
|
-
*
|
|
10724
|
-
*
|
|
10725
|
-
* @returns 当前场景,如果没有场景则返回null
|
|
11274
|
+
* 压缩池(移除多余的对象)
|
|
11275
|
+
* @param targetSize 目标大小,默认为当前大小的一半
|
|
10726
11276
|
*/
|
|
10727
|
-
|
|
11277
|
+
compact(targetSize?: number): void;
|
|
10728
11278
|
/**
|
|
10729
|
-
*
|
|
10730
|
-
*
|
|
10731
|
-
* @returns ECS API实例,如果当前没有场景则返回null
|
|
10732
|
-
*
|
|
10733
|
-
* @example
|
|
10734
|
-
* ```typescript
|
|
10735
|
-
* // 使用流式API创建实体
|
|
10736
|
-
* const player = Core.ecsAPI?.createEntity('Player')
|
|
10737
|
-
* .addComponent(Position, 100, 100)
|
|
10738
|
-
* .addComponent(Velocity, 50, 0);
|
|
10739
|
-
*
|
|
10740
|
-
* // 查询实体
|
|
10741
|
-
* const enemies = Core.ecsAPI?.query(Enemy, Transform);
|
|
10742
|
-
*
|
|
10743
|
-
* // 发射事件
|
|
10744
|
-
* Core.ecsAPI?.emit('game:start', { level: 1 });
|
|
10745
|
-
* ```
|
|
11279
|
+
* 预填充池
|
|
11280
|
+
* @param count 预填充的对象数量
|
|
10746
11281
|
*/
|
|
10747
|
-
|
|
11282
|
+
prewarm(count: number): void;
|
|
10748
11283
|
/**
|
|
10749
|
-
*
|
|
10750
|
-
*
|
|
10751
|
-
* @param scene - 要加载的场景
|
|
10752
|
-
*
|
|
10753
|
-
* @example
|
|
10754
|
-
* ```typescript
|
|
10755
|
-
* // 延迟切换场景(在下一帧生效)
|
|
10756
|
-
* Core.loadScene(new MenuScene());
|
|
10757
|
-
* ```
|
|
11284
|
+
* 设置最大池大小
|
|
11285
|
+
* @param maxSize 新的最大大小
|
|
10758
11286
|
*/
|
|
10759
|
-
|
|
11287
|
+
setMaxSize(maxSize: number): void;
|
|
10760
11288
|
/**
|
|
10761
|
-
*
|
|
10762
|
-
*
|
|
10763
|
-
* 此方法应该在游戏引擎的更新循环中调用。
|
|
10764
|
-
* 会自动更新全局服务和当前场景。
|
|
10765
|
-
*
|
|
10766
|
-
* @param deltaTime - 外部引擎提供的帧时间间隔(秒)
|
|
10767
|
-
*
|
|
10768
|
-
* @example
|
|
10769
|
-
* ```typescript
|
|
10770
|
-
* // 初始化
|
|
10771
|
-
* Core.create({ debug: true });
|
|
10772
|
-
* Core.setScene(new GameScene());
|
|
10773
|
-
*
|
|
10774
|
-
* // Laya引擎集成
|
|
10775
|
-
* Laya.timer.frameLoop(1, this, () => {
|
|
10776
|
-
* const deltaTime = Laya.timer.delta / 1000;
|
|
10777
|
-
* Core.update(deltaTime); // 自动更新全局服务和场景
|
|
10778
|
-
* });
|
|
10779
|
-
*
|
|
10780
|
-
* // Cocos Creator集成
|
|
10781
|
-
* update(deltaTime: number) {
|
|
10782
|
-
* Core.update(deltaTime); // 自动更新全局服务和场景
|
|
10783
|
-
* }
|
|
10784
|
-
* ```
|
|
11289
|
+
* 获取池中可用对象数量
|
|
11290
|
+
* @returns 可用对象数量
|
|
10785
11291
|
*/
|
|
10786
|
-
|
|
11292
|
+
getAvailableCount(): number;
|
|
10787
11293
|
/**
|
|
10788
|
-
*
|
|
10789
|
-
*
|
|
10790
|
-
* 创建一个定时器,在指定时间后执行回调函数。
|
|
10791
|
-
*
|
|
10792
|
-
* @param timeInSeconds - 延迟时间(秒)
|
|
10793
|
-
* @param repeats - 是否重复执行,默认为false
|
|
10794
|
-
* @param context - 回调函数的上下文,默认为null
|
|
10795
|
-
* @param onTime - 定时器触发时的回调函数
|
|
10796
|
-
* @returns 创建的定时器实例
|
|
10797
|
-
* @throws 如果Core实例未创建或onTime回调未提供
|
|
10798
|
-
*
|
|
10799
|
-
* @example
|
|
10800
|
-
* ```typescript
|
|
10801
|
-
* // 一次性定时器
|
|
10802
|
-
* Core.schedule(1.0, false, null, (timer) => {
|
|
10803
|
-
* console.log("1秒后执行一次");
|
|
10804
|
-
* });
|
|
10805
|
-
*
|
|
10806
|
-
* // 重复定时器
|
|
10807
|
-
* Core.schedule(0.5, true, null, (timer) => {
|
|
10808
|
-
* console.log("每0.5秒执行一次");
|
|
10809
|
-
* });
|
|
10810
|
-
* ```
|
|
11294
|
+
* 检查池是否为空
|
|
11295
|
+
* @returns 如果池为空返回true
|
|
10811
11296
|
*/
|
|
10812
|
-
|
|
11297
|
+
isEmpty(): boolean;
|
|
10813
11298
|
/**
|
|
10814
|
-
*
|
|
10815
|
-
*
|
|
10816
|
-
* @param config 调试配置
|
|
11299
|
+
* 检查池是否已满
|
|
11300
|
+
* @returns 如果池已满返回true
|
|
10817
11301
|
*/
|
|
10818
|
-
|
|
11302
|
+
isFull(): boolean;
|
|
10819
11303
|
/**
|
|
10820
|
-
*
|
|
11304
|
+
* 获取所有已注册的池类型
|
|
11305
|
+
* @returns 所有池类型的数组
|
|
10821
11306
|
*/
|
|
10822
|
-
static
|
|
11307
|
+
static getAllPoolTypes(): Function[];
|
|
10823
11308
|
/**
|
|
10824
|
-
*
|
|
10825
|
-
*
|
|
10826
|
-
* @returns 当前调试数据,如果调试未启用则返回null
|
|
11309
|
+
* 获取所有池的统计信息
|
|
11310
|
+
* @returns 包含所有池统计信息的对象
|
|
10827
11311
|
*/
|
|
10828
|
-
static
|
|
11312
|
+
static getAllPoolStats(): Record<string, PoolStats>;
|
|
10829
11313
|
/**
|
|
10830
|
-
*
|
|
10831
|
-
*
|
|
10832
|
-
* @returns 调试状态
|
|
11314
|
+
* 压缩所有池
|
|
10833
11315
|
*/
|
|
10834
|
-
static
|
|
11316
|
+
static compactAllPools(): void;
|
|
10835
11317
|
/**
|
|
10836
|
-
*
|
|
10837
|
-
*
|
|
10838
|
-
* @param plugin - 插件实例
|
|
10839
|
-
* @throws 如果Core实例未创建或插件安装失败
|
|
10840
|
-
*
|
|
10841
|
-
* @example
|
|
10842
|
-
* ```typescript
|
|
10843
|
-
* Core.create({ debug: true });
|
|
10844
|
-
*
|
|
10845
|
-
* // 安装插件
|
|
10846
|
-
* await Core.installPlugin(new MyPlugin());
|
|
10847
|
-
* ```
|
|
10848
|
-
*/
|
|
10849
|
-
static installPlugin(plugin: IPlugin): Promise<void>;
|
|
10850
|
-
/**
|
|
10851
|
-
* 卸载插件
|
|
10852
|
-
*
|
|
10853
|
-
* @param name - 插件名称
|
|
10854
|
-
* @throws 如果Core实例未创建或插件卸载失败
|
|
10855
|
-
*
|
|
10856
|
-
* @example
|
|
10857
|
-
* ```typescript
|
|
10858
|
-
* await Core.uninstallPlugin('my-plugin');
|
|
10859
|
-
* ```
|
|
10860
|
-
*/
|
|
10861
|
-
static uninstallPlugin(name: string): Promise<void>;
|
|
10862
|
-
/**
|
|
10863
|
-
* 获取插件实例
|
|
10864
|
-
*
|
|
10865
|
-
* @param name - 插件名称
|
|
10866
|
-
* @returns 插件实例,如果未安装则返回undefined
|
|
10867
|
-
*
|
|
10868
|
-
* @example
|
|
10869
|
-
* ```typescript
|
|
10870
|
-
* const myPlugin = Core.getPlugin('my-plugin');
|
|
10871
|
-
* if (myPlugin) {
|
|
10872
|
-
* console.log(myPlugin.version);
|
|
10873
|
-
* }
|
|
10874
|
-
* ```
|
|
10875
|
-
*/
|
|
10876
|
-
static getPlugin(name: string): IPlugin | undefined;
|
|
10877
|
-
/**
|
|
10878
|
-
* 检查插件是否已安装
|
|
10879
|
-
*
|
|
10880
|
-
* @param name - 插件名称
|
|
10881
|
-
* @returns 是否已安装
|
|
10882
|
-
*
|
|
10883
|
-
* @example
|
|
10884
|
-
* ```typescript
|
|
10885
|
-
* if (Core.isPluginInstalled('my-plugin')) {
|
|
10886
|
-
* console.log('Plugin is installed');
|
|
10887
|
-
* }
|
|
10888
|
-
* ```
|
|
11318
|
+
* 清空所有池
|
|
10889
11319
|
*/
|
|
10890
|
-
static
|
|
11320
|
+
static clearAllPools(): void;
|
|
10891
11321
|
/**
|
|
10892
|
-
*
|
|
10893
|
-
*
|
|
10894
|
-
* 执行核心系统的初始化逻辑。
|
|
11322
|
+
* 获取全局池统计信息的格式化字符串
|
|
11323
|
+
* @returns 格式化的统计信息字符串
|
|
10895
11324
|
*/
|
|
10896
|
-
|
|
11325
|
+
static getGlobalStatsString(): string;
|
|
10897
11326
|
/**
|
|
10898
|
-
*
|
|
10899
|
-
*
|
|
10900
|
-
* @param deltaTime - 帧时间间隔(秒)
|
|
11327
|
+
* 更新命中率
|
|
10901
11328
|
*/
|
|
10902
|
-
private
|
|
11329
|
+
private _updateHitRate;
|
|
10903
11330
|
/**
|
|
10904
|
-
*
|
|
10905
|
-
*
|
|
10906
|
-
* 清理所有资源,通常在应用程序关闭时调用。
|
|
11331
|
+
* 更新内存使用估算
|
|
10907
11332
|
*/
|
|
10908
|
-
|
|
11333
|
+
private _updateMemoryUsage;
|
|
10909
11334
|
}
|
|
10910
11335
|
|
|
10911
11336
|
/**
|
|
10912
|
-
*
|
|
10913
|
-
*
|
|
10914
|
-
* 负责插件的注册、安装、卸载和生命周期管理。
|
|
10915
|
-
* 支持依赖检查和异步加载。
|
|
10916
|
-
*
|
|
10917
|
-
* @example
|
|
10918
|
-
* ```typescript
|
|
10919
|
-
* const core = Core.create();
|
|
10920
|
-
* const pluginManager = core.getService(PluginManager);
|
|
10921
|
-
*
|
|
10922
|
-
* // 注册插件
|
|
10923
|
-
* await pluginManager.install(new MyPlugin());
|
|
10924
|
-
*
|
|
10925
|
-
* // 查询插件
|
|
10926
|
-
* const plugin = pluginManager.getPlugin('my-plugin');
|
|
10927
|
-
*
|
|
10928
|
-
* // 卸载插件
|
|
10929
|
-
* await pluginManager.uninstall('my-plugin');
|
|
10930
|
-
* ```
|
|
11337
|
+
* 池管理器
|
|
11338
|
+
* 统一管理所有对象池
|
|
10931
11339
|
*/
|
|
10932
|
-
declare class
|
|
11340
|
+
declare class PoolManager implements IService {
|
|
11341
|
+
private pools;
|
|
11342
|
+
private autoCompactInterval;
|
|
11343
|
+
private lastCompactTime;
|
|
11344
|
+
constructor();
|
|
10933
11345
|
/**
|
|
10934
|
-
*
|
|
11346
|
+
* 注册池
|
|
11347
|
+
* @param name 池名称
|
|
11348
|
+
* @param pool 池实例
|
|
10935
11349
|
*/
|
|
10936
|
-
|
|
11350
|
+
registerPool<T extends IPoolable>(name: string, pool: Pool<T>): void;
|
|
10937
11351
|
/**
|
|
10938
|
-
*
|
|
11352
|
+
* 获取池
|
|
11353
|
+
* @param name 池名称
|
|
11354
|
+
* @returns 池实例
|
|
10939
11355
|
*/
|
|
10940
|
-
|
|
11356
|
+
getPool<T extends IPoolable>(name: string): Pool<T> | null;
|
|
10941
11357
|
/**
|
|
10942
|
-
*
|
|
11358
|
+
* 更新池管理器(应在游戏循环中调用)
|
|
10943
11359
|
*/
|
|
10944
|
-
|
|
11360
|
+
update(): void;
|
|
10945
11361
|
/**
|
|
10946
|
-
*
|
|
11362
|
+
* 创建或获取标准池
|
|
11363
|
+
* @param name 池名称
|
|
11364
|
+
* @param createFn 创建函数
|
|
11365
|
+
* @param maxSize 最大大小
|
|
11366
|
+
* @param estimatedObjectSize 估算对象大小
|
|
11367
|
+
* @returns 池实例
|
|
10947
11368
|
*/
|
|
10948
|
-
|
|
11369
|
+
createPool<T extends IPoolable>(name: string, createFn: () => T, maxSize?: number, estimatedObjectSize?: number): Pool<T>;
|
|
10949
11370
|
/**
|
|
10950
|
-
*
|
|
10951
|
-
*
|
|
10952
|
-
* @
|
|
10953
|
-
* @param services - 服务容器
|
|
11371
|
+
* 移除池
|
|
11372
|
+
* @param name 池名称
|
|
11373
|
+
* @returns 是否成功移除
|
|
10954
11374
|
*/
|
|
10955
|
-
|
|
11375
|
+
removePool(name: string): boolean;
|
|
10956
11376
|
/**
|
|
10957
|
-
*
|
|
10958
|
-
*
|
|
10959
|
-
* 会自动检查依赖并按正确顺序安装。
|
|
10960
|
-
*
|
|
10961
|
-
* @param plugin - 插件实例
|
|
10962
|
-
* @throws 如果依赖检查失败或安装失败
|
|
11377
|
+
* 获取所有池名称
|
|
11378
|
+
* @returns 池名称数组
|
|
10963
11379
|
*/
|
|
10964
|
-
|
|
11380
|
+
getPoolNames(): string[];
|
|
10965
11381
|
/**
|
|
10966
|
-
*
|
|
10967
|
-
*
|
|
10968
|
-
* @param name - 插件名称
|
|
10969
|
-
* @throws 如果插件未安装或卸载失败
|
|
11382
|
+
* 获取池数量
|
|
11383
|
+
* @returns 池数量
|
|
10970
11384
|
*/
|
|
10971
|
-
|
|
11385
|
+
getPoolCount(): number;
|
|
10972
11386
|
/**
|
|
10973
|
-
*
|
|
10974
|
-
*
|
|
10975
|
-
* @param name - 插件名称
|
|
10976
|
-
* @returns 插件实例,如果未安装则返回undefined
|
|
11387
|
+
* 压缩所有池
|
|
10977
11388
|
*/
|
|
10978
|
-
|
|
11389
|
+
compactAllPools(): void;
|
|
10979
11390
|
/**
|
|
10980
|
-
*
|
|
10981
|
-
*
|
|
10982
|
-
* @param name - 插件名称
|
|
10983
|
-
* @returns 插件元数据,如果未安装则返回undefined
|
|
11391
|
+
* 清空所有池
|
|
10984
11392
|
*/
|
|
10985
|
-
|
|
11393
|
+
clearAllPools(): void;
|
|
10986
11394
|
/**
|
|
10987
|
-
*
|
|
10988
|
-
*
|
|
10989
|
-
* @returns 插件列表
|
|
11395
|
+
* 获取所有池的统计信息
|
|
11396
|
+
* @returns 统计信息映射
|
|
10990
11397
|
*/
|
|
10991
|
-
|
|
11398
|
+
getAllStats(): Map<string, PoolStats>;
|
|
10992
11399
|
/**
|
|
10993
|
-
*
|
|
10994
|
-
*
|
|
10995
|
-
* @returns 元数据列表
|
|
11400
|
+
* 获取总体统计信息
|
|
11401
|
+
* @returns 总体统计信息
|
|
10996
11402
|
*/
|
|
10997
|
-
|
|
11403
|
+
getGlobalStats(): PoolStats;
|
|
10998
11404
|
/**
|
|
10999
|
-
*
|
|
11000
|
-
*
|
|
11001
|
-
* @param name - 插件名称
|
|
11002
|
-
* @returns 是否已安装
|
|
11405
|
+
* 获取格式化的统计信息字符串
|
|
11406
|
+
* @returns 格式化字符串
|
|
11003
11407
|
*/
|
|
11004
|
-
|
|
11408
|
+
getStatsString(): string;
|
|
11005
11409
|
/**
|
|
11006
|
-
*
|
|
11007
|
-
*
|
|
11008
|
-
* @param plugin - 插件实例
|
|
11009
|
-
* @throws 如果依赖未满足
|
|
11410
|
+
* 设置自动压缩间隔
|
|
11411
|
+
* @param intervalMs 间隔毫秒数
|
|
11010
11412
|
*/
|
|
11011
|
-
|
|
11413
|
+
setAutoCompactInterval(intervalMs: number): void;
|
|
11012
11414
|
/**
|
|
11013
|
-
*
|
|
11014
|
-
*
|
|
11015
|
-
* @param name - 插件名称
|
|
11016
|
-
* @throws 如果有其他插件依赖此插件
|
|
11415
|
+
* 预填充所有池
|
|
11017
11416
|
*/
|
|
11018
|
-
|
|
11417
|
+
prewarmAllPools(): void;
|
|
11418
|
+
/**
|
|
11419
|
+
* 重置池管理器
|
|
11420
|
+
*/
|
|
11421
|
+
reset(): void;
|
|
11019
11422
|
/**
|
|
11020
11423
|
* 释放资源
|
|
11424
|
+
* 实现 IService 接口
|
|
11021
11425
|
*/
|
|
11022
11426
|
dispose(): void;
|
|
11023
11427
|
}
|
|
11024
11428
|
|
|
11025
11429
|
/**
|
|
11026
|
-
*
|
|
11027
|
-
|
|
11028
|
-
interface ECSDebugStats {
|
|
11029
|
-
scenes: SceneDebugInfo[];
|
|
11030
|
-
totalEntities: number;
|
|
11031
|
-
totalSystems: number;
|
|
11032
|
-
timestamp: number;
|
|
11033
|
-
}
|
|
11034
|
-
/**
|
|
11035
|
-
* 场景调试信息
|
|
11036
|
-
*/
|
|
11037
|
-
interface SceneDebugInfo {
|
|
11038
|
-
name: string;
|
|
11039
|
-
entityCount: number;
|
|
11040
|
-
systems: SystemDebugInfo[];
|
|
11041
|
-
entities: EntityDebugInfo[];
|
|
11042
|
-
}
|
|
11043
|
-
/**
|
|
11044
|
-
* 系统调试信息
|
|
11045
|
-
*/
|
|
11046
|
-
interface SystemDebugInfo {
|
|
11047
|
-
name: string;
|
|
11048
|
-
enabled: boolean;
|
|
11049
|
-
updateOrder: number;
|
|
11050
|
-
entityCount: number;
|
|
11051
|
-
performance?: {
|
|
11052
|
-
avgExecutionTime: number;
|
|
11053
|
-
maxExecutionTime: number;
|
|
11054
|
-
totalCalls: number;
|
|
11055
|
-
};
|
|
11056
|
-
}
|
|
11057
|
-
/**
|
|
11058
|
-
* 实体调试信息
|
|
11059
|
-
*/
|
|
11060
|
-
interface EntityDebugInfo {
|
|
11061
|
-
id: number;
|
|
11062
|
-
name: string;
|
|
11063
|
-
enabled: boolean;
|
|
11064
|
-
tag: number;
|
|
11065
|
-
componentCount: number;
|
|
11066
|
-
components: ComponentDebugInfo[];
|
|
11067
|
-
}
|
|
11068
|
-
/**
|
|
11069
|
-
* 组件调试信息
|
|
11430
|
+
* 时间管理工具类
|
|
11431
|
+
* 提供游戏时间相关的功能,包括帧时间、总时间、时间缩放等
|
|
11070
11432
|
*/
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
|
|
11433
|
+
declare class Time {
|
|
11434
|
+
/**
|
|
11435
|
+
* 上一帧到当前帧的时间间隔(秒)
|
|
11436
|
+
*/
|
|
11437
|
+
static deltaTime: number;
|
|
11438
|
+
/**
|
|
11439
|
+
* 未缩放的帧时间间隔(秒)
|
|
11440
|
+
*/
|
|
11441
|
+
static unscaledDeltaTime: number;
|
|
11442
|
+
/**
|
|
11443
|
+
* 游戏开始以来的总时间(秒)
|
|
11444
|
+
*/
|
|
11445
|
+
static totalTime: number;
|
|
11446
|
+
/**
|
|
11447
|
+
* 未缩放的总时间(秒)
|
|
11448
|
+
*/
|
|
11449
|
+
static unscaledTotalTime: number;
|
|
11450
|
+
/**
|
|
11451
|
+
* 时间缩放比例
|
|
11452
|
+
*/
|
|
11453
|
+
static timeScale: number;
|
|
11454
|
+
/**
|
|
11455
|
+
* 当前帧数
|
|
11456
|
+
*/
|
|
11457
|
+
static frameCount: number;
|
|
11458
|
+
/**
|
|
11459
|
+
* 使用外部引擎提供的deltaTime更新时间信息
|
|
11460
|
+
* @param deltaTime 外部引擎提供的帧时间间隔(秒)
|
|
11461
|
+
*/
|
|
11462
|
+
static update(deltaTime: number): void;
|
|
11463
|
+
/**
|
|
11464
|
+
* 场景改变时重置时间
|
|
11465
|
+
*/
|
|
11466
|
+
static sceneChanged(): void;
|
|
11467
|
+
/**
|
|
11468
|
+
* 检查指定的时间间隔是否已经过去
|
|
11469
|
+
* @param interval 时间间隔(秒)
|
|
11470
|
+
* @param lastTime 上次检查的时间
|
|
11471
|
+
* @returns 是否已经过去指定时间
|
|
11472
|
+
*/
|
|
11473
|
+
static checkEvery(interval: number, lastTime: number): boolean;
|
|
11074
11474
|
}
|
|
11475
|
+
|
|
11075
11476
|
/**
|
|
11076
|
-
*
|
|
11077
|
-
*
|
|
11078
|
-
* 提供运行时调试功能:
|
|
11079
|
-
* - 实时查看实体和组件信息
|
|
11080
|
-
* - System 执行统计
|
|
11081
|
-
* - 性能监控
|
|
11082
|
-
* - 实体查询
|
|
11083
|
-
*
|
|
11084
|
-
* @example
|
|
11085
|
-
* ```typescript
|
|
11086
|
-
* const core = Core.create();
|
|
11087
|
-
* const debugPlugin = new DebugPlugin({ autoStart: true, updateInterval: 1000 });
|
|
11088
|
-
* await core.pluginManager.install(debugPlugin);
|
|
11089
|
-
*
|
|
11090
|
-
* // 获取调试信息
|
|
11091
|
-
* const stats = debugPlugin.getStats();
|
|
11092
|
-
* console.log('Total entities:', stats.totalEntities);
|
|
11093
|
-
*
|
|
11094
|
-
* // 查询实体
|
|
11095
|
-
* const entities = debugPlugin.queryEntities({ tag: 1 });
|
|
11096
|
-
* ```
|
|
11477
|
+
* 实体数据收集器
|
|
11097
11478
|
*/
|
|
11098
|
-
declare class
|
|
11099
|
-
readonly name = "@esengine/debug-plugin";
|
|
11100
|
-
readonly version = "1.0.0";
|
|
11101
|
-
private worldManager;
|
|
11102
|
-
private updateInterval;
|
|
11103
|
-
private updateTimer;
|
|
11104
|
-
private autoStart;
|
|
11479
|
+
declare class EntityDataCollector {
|
|
11105
11480
|
/**
|
|
11106
|
-
*
|
|
11107
|
-
*
|
|
11108
|
-
* @param options - 配置选项
|
|
11481
|
+
* 收集实体数据
|
|
11482
|
+
* @param scene 场景实例
|
|
11109
11483
|
*/
|
|
11110
|
-
|
|
11111
|
-
autoStart?: boolean;
|
|
11112
|
-
updateInterval?: number;
|
|
11113
|
-
});
|
|
11484
|
+
collectEntityData(scene?: IScene | null): IEntityDebugData;
|
|
11114
11485
|
/**
|
|
11115
|
-
*
|
|
11486
|
+
* 获取原始实体列表
|
|
11487
|
+
* @param scene 场景实例
|
|
11116
11488
|
*/
|
|
11117
|
-
|
|
11489
|
+
getRawEntityList(scene?: IScene | null): Array<{
|
|
11490
|
+
id: number;
|
|
11491
|
+
name: string;
|
|
11492
|
+
active: boolean;
|
|
11493
|
+
enabled: boolean;
|
|
11494
|
+
activeInHierarchy: boolean;
|
|
11495
|
+
componentCount: number;
|
|
11496
|
+
componentTypes: string[];
|
|
11497
|
+
parentId: number | null;
|
|
11498
|
+
childIds: number[];
|
|
11499
|
+
depth: number;
|
|
11500
|
+
tag: number;
|
|
11501
|
+
updateOrder: number;
|
|
11502
|
+
}>;
|
|
11118
11503
|
/**
|
|
11119
|
-
*
|
|
11504
|
+
* 获取实体详细信息
|
|
11505
|
+
* @param entityId 实体ID
|
|
11506
|
+
* @param scene 场景实例
|
|
11120
11507
|
*/
|
|
11121
|
-
|
|
11508
|
+
getEntityDetails(entityId: number, scene?: IScene | null): any;
|
|
11509
|
+
private getSceneInfo;
|
|
11122
11510
|
/**
|
|
11123
|
-
*
|
|
11511
|
+
* 收集实体数据(包含内存信息)
|
|
11512
|
+
* @param scene 场景实例
|
|
11124
11513
|
*/
|
|
11125
|
-
|
|
11514
|
+
collectEntityDataWithMemory(scene?: IScene | null): IEntityDebugData;
|
|
11515
|
+
private collectArchetypeData;
|
|
11516
|
+
private getArchetypeDistributionFast;
|
|
11517
|
+
private getTopEntitiesByComponentsFast;
|
|
11518
|
+
private collectArchetypeDataWithMemory;
|
|
11519
|
+
private extractArchetypeStatistics;
|
|
11520
|
+
private extractArchetypeStatisticsWithMemory;
|
|
11521
|
+
private getArchetypeDistributionWithMemory;
|
|
11522
|
+
private getTopEntitiesByComponentsWithMemory;
|
|
11523
|
+
private getEmptyEntityDebugData;
|
|
11524
|
+
private calculateFallbackEntityStats;
|
|
11525
|
+
estimateEntityMemoryUsage(entity: any): number;
|
|
11526
|
+
calculateObjectSize(obj: any, excludeKeys?: string[]): number;
|
|
11527
|
+
private buildEntityHierarchyTree;
|
|
11126
11528
|
/**
|
|
11127
|
-
*
|
|
11529
|
+
* 构建实体层次结构节点
|
|
11128
11530
|
*/
|
|
11129
|
-
|
|
11531
|
+
private buildEntityHierarchyNode;
|
|
11130
11532
|
/**
|
|
11131
|
-
*
|
|
11533
|
+
* 构建实体详情映射
|
|
11132
11534
|
*/
|
|
11133
|
-
|
|
11535
|
+
private buildEntityDetailsMap;
|
|
11134
11536
|
/**
|
|
11135
|
-
*
|
|
11537
|
+
* 构建实体基础信息
|
|
11136
11538
|
*/
|
|
11137
|
-
|
|
11539
|
+
private buildFallbackEntityInfo;
|
|
11138
11540
|
/**
|
|
11139
|
-
*
|
|
11541
|
+
* 提取组件详细信息
|
|
11140
11542
|
*/
|
|
11141
|
-
|
|
11543
|
+
extractComponentDetails(components: readonly Component[]): Array<{
|
|
11544
|
+
typeName: string;
|
|
11545
|
+
properties: Record<string, any>;
|
|
11546
|
+
}>;
|
|
11142
11547
|
/**
|
|
11143
|
-
*
|
|
11548
|
+
* 获取组件的完整属性信息(仅在需要时调用)
|
|
11549
|
+
* @param entityId 实体ID
|
|
11550
|
+
* @param componentIndex 组件索引
|
|
11551
|
+
* @param scene 场景实例
|
|
11144
11552
|
*/
|
|
11145
|
-
|
|
11553
|
+
getComponentProperties(entityId: number, componentIndex: number, scene?: IScene | null): Record<string, any>;
|
|
11146
11554
|
/**
|
|
11147
|
-
*
|
|
11555
|
+
* 格式化属性值
|
|
11148
11556
|
*/
|
|
11149
|
-
|
|
11557
|
+
private formatPropertyValue;
|
|
11150
11558
|
/**
|
|
11151
|
-
*
|
|
11559
|
+
* 格式化对象第一层
|
|
11152
11560
|
*/
|
|
11153
|
-
private
|
|
11561
|
+
private formatObjectFirstLevel;
|
|
11154
11562
|
/**
|
|
11155
|
-
*
|
|
11156
|
-
*
|
|
11157
|
-
* @param filter - 查询过滤器
|
|
11563
|
+
* 创建懒加载占位符
|
|
11158
11564
|
*/
|
|
11159
|
-
|
|
11160
|
-
sceneName?: string;
|
|
11161
|
-
tag?: number;
|
|
11162
|
-
name?: string;
|
|
11163
|
-
hasComponent?: string;
|
|
11164
|
-
}): EntityDebugInfo[];
|
|
11565
|
+
private createLazyLoadPlaceholder;
|
|
11165
11566
|
/**
|
|
11166
|
-
*
|
|
11567
|
+
* 获取对象摘要信息
|
|
11167
11568
|
*/
|
|
11168
|
-
private
|
|
11569
|
+
private getObjectSummary;
|
|
11169
11570
|
/**
|
|
11170
|
-
*
|
|
11571
|
+
* 生成对象ID
|
|
11171
11572
|
*/
|
|
11172
|
-
|
|
11573
|
+
private generateObjectId;
|
|
11574
|
+
/**
|
|
11575
|
+
* 展开懒加载对象(供调试面板调用)
|
|
11576
|
+
* @param entityId 实体ID
|
|
11577
|
+
* @param componentIndex 组件索引
|
|
11578
|
+
* @param propertyPath 属性路径
|
|
11579
|
+
* @param scene 场景实例
|
|
11580
|
+
*/
|
|
11581
|
+
expandLazyObject(entityId: number, componentIndex: number, propertyPath: string, scene?: IScene | null): any;
|
|
11582
|
+
/**
|
|
11583
|
+
* 根据路径获取对象
|
|
11584
|
+
*/
|
|
11585
|
+
private getObjectByPath;
|
|
11173
11586
|
}
|
|
11174
11587
|
|
|
11175
11588
|
/**
|
|
11176
|
-
*
|
|
11177
|
-
*
|
|
11178
|
-
* 提供 @Injectable、@InjectProperty 和 @Updatable 装饰器,用于标记可注入的类和依赖注入点
|
|
11589
|
+
* 系统数据收集器
|
|
11179
11590
|
*/
|
|
11591
|
+
declare class SystemDataCollector {
|
|
11592
|
+
/**
|
|
11593
|
+
* 收集系统数据
|
|
11594
|
+
* @param performanceMonitor 性能监视器实例
|
|
11595
|
+
* @param scene 场景实例
|
|
11596
|
+
*/
|
|
11597
|
+
collectSystemData(performanceMonitor: any, scene?: IScene | null): ISystemDebugData;
|
|
11598
|
+
}
|
|
11180
11599
|
|
|
11181
11600
|
/**
|
|
11182
|
-
*
|
|
11183
|
-
*/
|
|
11184
|
-
type Constructor = abstract new (...args: unknown[]) => unknown;
|
|
11185
|
-
/**
|
|
11186
|
-
* 可注入元数据接口
|
|
11601
|
+
* 性能数据收集器
|
|
11187
11602
|
*/
|
|
11188
|
-
|
|
11603
|
+
declare class PerformanceDataCollector {
|
|
11604
|
+
private frameTimeHistory;
|
|
11605
|
+
private maxHistoryLength;
|
|
11606
|
+
private gcCollections;
|
|
11607
|
+
private lastMemoryCheck;
|
|
11189
11608
|
/**
|
|
11190
|
-
*
|
|
11609
|
+
* 收集性能数据
|
|
11191
11610
|
*/
|
|
11192
|
-
|
|
11611
|
+
collectPerformanceData(performanceMonitor: any): IPerformanceDebugData;
|
|
11193
11612
|
/**
|
|
11194
|
-
*
|
|
11613
|
+
* 获取ECS框架整体性能数据
|
|
11195
11614
|
*/
|
|
11196
|
-
|
|
11615
|
+
private getECSPerformanceData;
|
|
11197
11616
|
/**
|
|
11198
|
-
*
|
|
11199
|
-
* key: 属性名, value: 服务类型
|
|
11617
|
+
* 获取系统性能数据
|
|
11200
11618
|
*/
|
|
11201
|
-
|
|
11619
|
+
private getSystemPerformance;
|
|
11620
|
+
/**
|
|
11621
|
+
* 获取内存详情
|
|
11622
|
+
*/
|
|
11623
|
+
private getMemoryDetails;
|
|
11624
|
+
/**
|
|
11625
|
+
* 更新GC计数
|
|
11626
|
+
*/
|
|
11627
|
+
private updateGCCount;
|
|
11202
11628
|
}
|
|
11629
|
+
|
|
11203
11630
|
/**
|
|
11204
|
-
*
|
|
11631
|
+
* 组件数据收集器
|
|
11205
11632
|
*/
|
|
11206
|
-
|
|
11633
|
+
declare class ComponentDataCollector {
|
|
11634
|
+
private static componentSizeCache;
|
|
11207
11635
|
/**
|
|
11208
|
-
*
|
|
11636
|
+
* 收集组件数据(轻量版,不计算实际内存大小)
|
|
11637
|
+
* @param scene 场景实例
|
|
11209
11638
|
*/
|
|
11210
|
-
|
|
11639
|
+
collectComponentData(scene?: IScene | null): IComponentDebugData;
|
|
11211
11640
|
/**
|
|
11212
|
-
*
|
|
11641
|
+
* 获取组件类型的估算内存大小(基于预设值,不进行实际计算)
|
|
11213
11642
|
*/
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
/**
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
* @InjectProperty(TimeService)
|
|
11232
|
-
* private timeService!: TimeService;
|
|
11233
|
-
*
|
|
11234
|
-
* constructor() {
|
|
11235
|
-
* super(Matcher.empty());
|
|
11236
|
-
* }
|
|
11237
|
-
* }
|
|
11238
|
-
* ```
|
|
11239
|
-
*/
|
|
11240
|
-
declare function Injectable(): ClassDecorator;
|
|
11241
|
-
/**
|
|
11242
|
-
* @Updatable() 装饰器
|
|
11243
|
-
*
|
|
11244
|
-
* 标记服务类为可更新的,使其在每帧自动被ServiceContainer调用update方法。
|
|
11245
|
-
* 使用此装饰器的类必须实现IUpdatable接口(包含update方法)。
|
|
11246
|
-
*
|
|
11247
|
-
* @param priority - 更新优先级(数值越小越先执行,默认0)
|
|
11248
|
-
* @throws 如果类没有实现update方法,将在运行时抛出错误
|
|
11249
|
-
*
|
|
11250
|
-
* @example
|
|
11251
|
-
* ```typescript
|
|
11252
|
-
* @Injectable()
|
|
11253
|
-
* @Updatable()
|
|
11254
|
-
* class TimerManager implements IService, IUpdatable {
|
|
11255
|
-
* update(deltaTime?: number) {
|
|
11256
|
-
* // 每帧更新逻辑
|
|
11257
|
-
* }
|
|
11258
|
-
* dispose() {}
|
|
11259
|
-
* }
|
|
11260
|
-
*
|
|
11261
|
-
* // 指定优先级
|
|
11262
|
-
* @Injectable()
|
|
11263
|
-
* @Updatable(10)
|
|
11264
|
-
* class PhysicsManager implements IService, IUpdatable {
|
|
11265
|
-
* update() { }
|
|
11266
|
-
* dispose() {}
|
|
11267
|
-
* }
|
|
11268
|
-
* ```
|
|
11269
|
-
*/
|
|
11270
|
-
declare function Updatable(priority?: number): ClassDecorator;
|
|
11271
|
-
/**
|
|
11272
|
-
* @InjectProperty() 装饰器
|
|
11273
|
-
*
|
|
11274
|
-
* 通过属性装饰器注入依赖
|
|
11275
|
-
*
|
|
11276
|
-
* 注入时机:在构造函数执行后、onInitialize() 调用前完成
|
|
11277
|
-
*
|
|
11278
|
-
* @param serviceType 服务类型
|
|
11279
|
-
*
|
|
11280
|
-
* @example
|
|
11281
|
-
* ```typescript
|
|
11282
|
-
* @Injectable()
|
|
11283
|
-
* class PhysicsSystem extends EntitySystem {
|
|
11284
|
-
* @InjectProperty(TimeService)
|
|
11285
|
-
* private timeService!: TimeService;
|
|
11286
|
-
*
|
|
11287
|
-
* @InjectProperty(CollisionService)
|
|
11288
|
-
* private collision!: CollisionService;
|
|
11289
|
-
*
|
|
11290
|
-
* constructor() {
|
|
11291
|
-
* super(Matcher.empty());
|
|
11292
|
-
* }
|
|
11293
|
-
*
|
|
11294
|
-
* public onInitialize(): void {
|
|
11295
|
-
* // 此时属性已注入完成,可以安全使用
|
|
11296
|
-
* console.log(this.timeService.getDeltaTime());
|
|
11297
|
-
* }
|
|
11298
|
-
* }
|
|
11299
|
-
* ```
|
|
11300
|
-
*/
|
|
11301
|
-
declare function InjectProperty(serviceType: ServiceType<IService>): PropertyDecorator;
|
|
11302
|
-
/**
|
|
11303
|
-
* 获取属性注入元数据
|
|
11304
|
-
*
|
|
11305
|
-
* @param target 目标类
|
|
11306
|
-
* @returns 属性名到服务类型的映射
|
|
11307
|
-
*/
|
|
11308
|
-
declare function getPropertyInjectMetadata(target: Constructor): Map<string | symbol, ServiceType<IService>>;
|
|
11309
|
-
/**
|
|
11310
|
-
* 创建实例并自动注入依赖
|
|
11311
|
-
*
|
|
11312
|
-
* @param constructor 构造函数
|
|
11313
|
-
* @param container 服务容器
|
|
11314
|
-
* @returns 创建的实例
|
|
11315
|
-
*
|
|
11316
|
-
* @example
|
|
11317
|
-
* ```typescript
|
|
11318
|
-
* const instance = createInstance(MySystem, container);
|
|
11319
|
-
* ```
|
|
11320
|
-
*/
|
|
11321
|
-
declare function createInstance<T>(constructor: new (...args: any[]) => T, container: ServiceContainer): T;
|
|
11322
|
-
/**
|
|
11323
|
-
* 为实例注入属性依赖
|
|
11324
|
-
*
|
|
11325
|
-
* @param instance 目标实例
|
|
11326
|
-
* @param container 服务容器
|
|
11327
|
-
*/
|
|
11328
|
-
declare function injectProperties<T extends object>(instance: T, container: ServiceContainer): void;
|
|
11329
|
-
/**
|
|
11330
|
-
* 检查类是否标记为可更新
|
|
11331
|
-
*
|
|
11332
|
-
* @param target 目标类
|
|
11333
|
-
* @returns 是否可更新
|
|
11334
|
-
*/
|
|
11335
|
-
declare function isUpdatable(target: Constructor): boolean;
|
|
11336
|
-
/**
|
|
11337
|
-
* 获取类的可更新元数据
|
|
11338
|
-
*
|
|
11339
|
-
* @param target 目标类
|
|
11340
|
-
* @returns 可更新元数据
|
|
11341
|
-
*/
|
|
11342
|
-
declare function getUpdatableMetadata(target: Constructor): UpdatableMetadata | undefined;
|
|
11643
|
+
private getEstimatedComponentSize;
|
|
11644
|
+
private calculateQuickObjectSize;
|
|
11645
|
+
/**
|
|
11646
|
+
* 为内存快照功能提供的详细内存计算
|
|
11647
|
+
* 只在用户主动请求内存快照时调用
|
|
11648
|
+
* @param typeName 组件类型名称
|
|
11649
|
+
* @param scene 场景实例
|
|
11650
|
+
*/
|
|
11651
|
+
calculateDetailedComponentMemory(typeName: string, scene?: IScene | null): number;
|
|
11652
|
+
/**
|
|
11653
|
+
* 估算对象内存大小(仅用于内存快照)
|
|
11654
|
+
* 优化版本:减少递归深度,提高性能
|
|
11655
|
+
*/
|
|
11656
|
+
private estimateObjectSize;
|
|
11657
|
+
static clearCache(): void;
|
|
11658
|
+
}
|
|
11659
|
+
|
|
11343
11660
|
/**
|
|
11344
|
-
*
|
|
11345
|
-
*
|
|
11346
|
-
* 自动检测@Injectable装饰器并注册服务
|
|
11347
|
-
*
|
|
11348
|
-
* @param container 服务容器
|
|
11349
|
-
* @param serviceType 服务类型
|
|
11350
|
-
* @param singleton 是否注册为单例(默认true)
|
|
11351
|
-
*
|
|
11352
|
-
* @example
|
|
11353
|
-
* ```typescript
|
|
11354
|
-
* @Injectable()
|
|
11355
|
-
* class MyService implements IService {
|
|
11356
|
-
* dispose() {}
|
|
11357
|
-
* }
|
|
11358
|
-
*
|
|
11359
|
-
* // 自动注册
|
|
11360
|
-
* registerInjectable(Core.services, MyService);
|
|
11361
|
-
* ```
|
|
11661
|
+
* 场景数据收集器
|
|
11362
11662
|
*/
|
|
11363
|
-
declare
|
|
11663
|
+
declare class SceneDataCollector {
|
|
11664
|
+
private sceneStartTime;
|
|
11665
|
+
/**
|
|
11666
|
+
* 收集场景数据
|
|
11667
|
+
* @param scene 场景实例
|
|
11668
|
+
*/
|
|
11669
|
+
collectSceneData(scene?: IScene | null): ISceneDebugData;
|
|
11670
|
+
/**
|
|
11671
|
+
* 设置场景开始时间
|
|
11672
|
+
*/
|
|
11673
|
+
setSceneStartTime(time: number): void;
|
|
11674
|
+
}
|
|
11364
11675
|
|
|
11365
11676
|
/**
|
|
11366
|
-
*
|
|
11677
|
+
* WebSocket连接管理器
|
|
11367
11678
|
*/
|
|
11368
|
-
declare class
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11679
|
+
declare class WebSocketManager {
|
|
11680
|
+
private ws?;
|
|
11681
|
+
private isConnected;
|
|
11682
|
+
private reconnectAttempts;
|
|
11683
|
+
private maxReconnectAttempts;
|
|
11684
|
+
private url;
|
|
11685
|
+
private autoReconnect;
|
|
11686
|
+
private reconnectTimer?;
|
|
11687
|
+
private onOpen?;
|
|
11688
|
+
private onClose?;
|
|
11689
|
+
private onError?;
|
|
11690
|
+
private messageHandler?;
|
|
11691
|
+
constructor(url: string, autoReconnect?: boolean);
|
|
11692
|
+
/**
|
|
11693
|
+
* 设置消息处理回调
|
|
11694
|
+
*/
|
|
11695
|
+
setMessageHandler(handler: (message: any) => void): void;
|
|
11696
|
+
/**
|
|
11697
|
+
* 连接WebSocket
|
|
11698
|
+
*/
|
|
11699
|
+
connect(): Promise<void>;
|
|
11700
|
+
/**
|
|
11701
|
+
* 断开连接
|
|
11702
|
+
*/
|
|
11703
|
+
disconnect(): void;
|
|
11704
|
+
/**
|
|
11705
|
+
* 发送数据
|
|
11706
|
+
*/
|
|
11707
|
+
send(data: any): void;
|
|
11708
|
+
/**
|
|
11709
|
+
* 获取连接状态
|
|
11710
|
+
*/
|
|
11711
|
+
getConnectionStatus(): boolean;
|
|
11712
|
+
/**
|
|
11713
|
+
* 设置最大重连次数
|
|
11714
|
+
*/
|
|
11715
|
+
setMaxReconnectAttempts(attempts: number): void;
|
|
11716
|
+
/**
|
|
11717
|
+
* 计划重连
|
|
11718
|
+
*/
|
|
11719
|
+
private scheduleReconnect;
|
|
11720
|
+
/**
|
|
11721
|
+
* 处理接收到的消息
|
|
11722
|
+
*/
|
|
11723
|
+
private handleMessage;
|
|
11724
|
+
private handleOpen;
|
|
11725
|
+
private handleClose;
|
|
11726
|
+
private handleError;
|
|
11727
|
+
private handleConnectionFailure;
|
|
11374
11728
|
}
|
|
11729
|
+
|
|
11375
11730
|
/**
|
|
11376
|
-
*
|
|
11731
|
+
* 调试管理器
|
|
11732
|
+
*
|
|
11733
|
+
* 整合所有调试数据收集器,负责收集和发送调试数据
|
|
11377
11734
|
*/
|
|
11378
|
-
declare class
|
|
11379
|
-
private
|
|
11380
|
-
|
|
11735
|
+
declare class DebugManager implements IService, IUpdatable {
|
|
11736
|
+
private config;
|
|
11737
|
+
private webSocketManager;
|
|
11738
|
+
private entityCollector;
|
|
11739
|
+
private systemCollector;
|
|
11740
|
+
private performanceCollector;
|
|
11741
|
+
private componentCollector;
|
|
11742
|
+
private sceneCollector;
|
|
11743
|
+
private advancedProfilerCollector;
|
|
11744
|
+
private sceneManager;
|
|
11745
|
+
private performanceMonitor;
|
|
11746
|
+
private configService;
|
|
11747
|
+
private frameCounter;
|
|
11748
|
+
private lastSendTime;
|
|
11749
|
+
private sendInterval;
|
|
11750
|
+
private isRunning;
|
|
11751
|
+
private originalConsole;
|
|
11752
|
+
onInitialize(): void;
|
|
11753
|
+
/**
|
|
11754
|
+
* 启动调试管理器
|
|
11755
|
+
*/
|
|
11756
|
+
start(): void;
|
|
11757
|
+
/**
|
|
11758
|
+
* 停止调试管理器
|
|
11759
|
+
*/
|
|
11760
|
+
stop(): void;
|
|
11761
|
+
/**
|
|
11762
|
+
* 拦截 console 日志并转发到编辑器
|
|
11763
|
+
*/
|
|
11764
|
+
private interceptConsole;
|
|
11765
|
+
/**
|
|
11766
|
+
* 格式化日志消息
|
|
11767
|
+
*/
|
|
11768
|
+
private formatLogMessage;
|
|
11769
|
+
/**
|
|
11770
|
+
* 安全的 JSON 序列化,支持循环引用和深度限制
|
|
11771
|
+
*/
|
|
11772
|
+
private safeStringify;
|
|
11773
|
+
/**
|
|
11774
|
+
* 发送日志到编辑器
|
|
11775
|
+
*/
|
|
11776
|
+
private sendLog;
|
|
11381
11777
|
/**
|
|
11382
|
-
*
|
|
11383
|
-
* @param eventType 监听类型
|
|
11384
|
-
* @param handler 监听函数
|
|
11385
|
-
* @param context 监听上下文
|
|
11778
|
+
* 更新配置
|
|
11386
11779
|
*/
|
|
11387
|
-
|
|
11780
|
+
updateConfig(config: IECSDebugConfig): void;
|
|
11781
|
+
update(_deltaTime?: number): void;
|
|
11388
11782
|
/**
|
|
11389
|
-
*
|
|
11390
|
-
* @param eventType 事件类型
|
|
11391
|
-
* @param handler 事件函数
|
|
11783
|
+
* 场景变更回调
|
|
11392
11784
|
*/
|
|
11393
|
-
|
|
11785
|
+
onSceneChanged(): void;
|
|
11394
11786
|
/**
|
|
11395
|
-
*
|
|
11396
|
-
* @param eventType 事件类型
|
|
11397
|
-
* @param data 事件数据
|
|
11787
|
+
* 处理来自调试面板的消息
|
|
11398
11788
|
*/
|
|
11399
|
-
|
|
11789
|
+
private handleMessage;
|
|
11400
11790
|
/**
|
|
11401
|
-
*
|
|
11402
|
-
* @param eventType 事件类型
|
|
11403
|
-
* @param handler 事件函数
|
|
11791
|
+
* 处理展开懒加载对象请求
|
|
11404
11792
|
*/
|
|
11405
|
-
|
|
11793
|
+
private handleExpandLazyObjectRequest;
|
|
11406
11794
|
/**
|
|
11407
|
-
*
|
|
11408
|
-
* @param eventType 事件类型
|
|
11795
|
+
* 处理获取组件属性请求
|
|
11409
11796
|
*/
|
|
11410
|
-
|
|
11797
|
+
private handleGetComponentPropertiesRequest;
|
|
11411
11798
|
/**
|
|
11412
|
-
*
|
|
11799
|
+
* 处理获取原始实体列表请求
|
|
11413
11800
|
*/
|
|
11414
|
-
|
|
11801
|
+
private handleGetRawEntityListRequest;
|
|
11415
11802
|
/**
|
|
11416
|
-
*
|
|
11803
|
+
* 处理获取实体详情请求
|
|
11417
11804
|
*/
|
|
11418
|
-
|
|
11805
|
+
private handleGetEntityDetailsRequest;
|
|
11419
11806
|
/**
|
|
11420
|
-
*
|
|
11421
|
-
* @param eventType 事件类型
|
|
11807
|
+
* 处理获取高级性能分析数据请求
|
|
11422
11808
|
*/
|
|
11423
|
-
|
|
11424
|
-
}
|
|
11425
|
-
|
|
11426
|
-
/**
|
|
11427
|
-
* 全局管理器的基类。所有全局管理器都应该从此类继承。
|
|
11428
|
-
*/
|
|
11429
|
-
declare class GlobalManager {
|
|
11809
|
+
private handleGetAdvancedProfilerDataRequest;
|
|
11430
11810
|
/**
|
|
11431
|
-
*
|
|
11811
|
+
* 处理设置性能分析器选中函数请求
|
|
11432
11812
|
*/
|
|
11433
|
-
|
|
11813
|
+
private handleSetProfilerSelectedFunction;
|
|
11434
11814
|
/**
|
|
11435
|
-
*
|
|
11815
|
+
* 处理内存快照请求
|
|
11436
11816
|
*/
|
|
11437
|
-
|
|
11438
|
-
set enabled(value: boolean);
|
|
11817
|
+
private handleMemorySnapshotRequest;
|
|
11439
11818
|
/**
|
|
11440
|
-
*
|
|
11441
|
-
* @param isEnabled 如果为true,则启用管理器;否则禁用管理器
|
|
11819
|
+
* 捕获内存快照
|
|
11442
11820
|
*/
|
|
11443
|
-
|
|
11821
|
+
private captureMemorySnapshot;
|
|
11444
11822
|
/**
|
|
11445
|
-
*
|
|
11823
|
+
* 收集基础内存信息
|
|
11446
11824
|
*/
|
|
11447
|
-
|
|
11825
|
+
private collectBaseMemoryInfo;
|
|
11448
11826
|
/**
|
|
11449
|
-
*
|
|
11827
|
+
* 收集组件内存统计(仅用于内存快照)
|
|
11450
11828
|
*/
|
|
11451
|
-
|
|
11829
|
+
private collectComponentMemoryStats;
|
|
11830
|
+
private collectSystemMemoryStats;
|
|
11831
|
+
private calculateQuickSystemSize;
|
|
11452
11832
|
/**
|
|
11453
|
-
*
|
|
11833
|
+
* 收集对象池内存统计
|
|
11454
11834
|
*/
|
|
11455
|
-
|
|
11835
|
+
private collectPoolMemoryStats;
|
|
11836
|
+
/**
|
|
11837
|
+
* 收集性能统计信息
|
|
11838
|
+
*/
|
|
11839
|
+
private collectPerformanceStats;
|
|
11840
|
+
/**
|
|
11841
|
+
* 获取调试数据
|
|
11842
|
+
*/
|
|
11843
|
+
getDebugData(): IECSDebugData;
|
|
11844
|
+
/**
|
|
11845
|
+
* 连接WebSocket
|
|
11846
|
+
*/
|
|
11847
|
+
private connectWebSocket;
|
|
11848
|
+
/**
|
|
11849
|
+
* 发送调试数据
|
|
11850
|
+
*/
|
|
11851
|
+
private sendDebugData;
|
|
11852
|
+
/**
|
|
11853
|
+
* 释放资源
|
|
11854
|
+
*/
|
|
11855
|
+
dispose(): void;
|
|
11456
11856
|
}
|
|
11457
11857
|
|
|
11458
11858
|
/**
|
|
11459
|
-
*
|
|
11859
|
+
* 调试配置服务
|
|
11460
11860
|
*
|
|
11461
|
-
*
|
|
11861
|
+
* 管理调试系统的配置信息
|
|
11462
11862
|
*/
|
|
11863
|
+
declare class DebugConfigService implements IService {
|
|
11864
|
+
private _config;
|
|
11865
|
+
constructor();
|
|
11866
|
+
setConfig(config: IECSDebugConfig): void;
|
|
11867
|
+
getConfig(): IECSDebugConfig;
|
|
11868
|
+
isEnabled(): boolean;
|
|
11869
|
+
dispose(): void;
|
|
11870
|
+
}
|
|
11463
11871
|
|
|
11464
11872
|
/**
|
|
11465
|
-
*
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
*
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11873
|
+
* 性能分析器类型定义
|
|
11874
|
+
*/
|
|
11875
|
+
/**
|
|
11876
|
+
* 性能分析类别
|
|
11877
|
+
*/
|
|
11878
|
+
declare enum ProfileCategory {
|
|
11879
|
+
/** ECS 系统 */
|
|
11880
|
+
ECS = "ECS",
|
|
11881
|
+
/** 渲染相关 */
|
|
11882
|
+
Rendering = "Rendering",
|
|
11883
|
+
/** 物理系统 */
|
|
11884
|
+
Physics = "Physics",
|
|
11885
|
+
/** 音频系统 */
|
|
11886
|
+
Audio = "Audio",
|
|
11887
|
+
/** 网络相关 */
|
|
11888
|
+
Network = "Network",
|
|
11889
|
+
/** 用户脚本 */
|
|
11890
|
+
Script = "Script",
|
|
11891
|
+
/** 内存相关 */
|
|
11892
|
+
Memory = "Memory",
|
|
11893
|
+
/** 动画系统 */
|
|
11894
|
+
Animation = "Animation",
|
|
11895
|
+
/** AI/行为树 */
|
|
11896
|
+
AI = "AI",
|
|
11897
|
+
/** 输入处理 */
|
|
11898
|
+
Input = "Input",
|
|
11899
|
+
/** 资源加载 */
|
|
11900
|
+
Loading = "Loading",
|
|
11901
|
+
/** 自定义 */
|
|
11902
|
+
Custom = "Custom"
|
|
11903
|
+
}
|
|
11904
|
+
/**
|
|
11905
|
+
* 采样句柄
|
|
11906
|
+
*/
|
|
11907
|
+
interface SampleHandle {
|
|
11908
|
+
id: string;
|
|
11909
|
+
name: string;
|
|
11910
|
+
category: ProfileCategory;
|
|
11911
|
+
startTime: number;
|
|
11912
|
+
depth: number;
|
|
11913
|
+
parentId?: string | undefined;
|
|
11914
|
+
}
|
|
11915
|
+
/**
|
|
11916
|
+
* 性能采样数据
|
|
11477
11917
|
*/
|
|
11478
|
-
|
|
11918
|
+
interface ProfileSample {
|
|
11919
|
+
id: string;
|
|
11920
|
+
name: string;
|
|
11921
|
+
category: ProfileCategory;
|
|
11922
|
+
startTime: number;
|
|
11923
|
+
endTime: number;
|
|
11924
|
+
duration: number;
|
|
11925
|
+
selfTime: number;
|
|
11926
|
+
parentId?: string | undefined;
|
|
11927
|
+
/** 父级采样的名称(用于构建调用图) */
|
|
11928
|
+
parentName?: string | undefined;
|
|
11929
|
+
depth: number;
|
|
11930
|
+
callCount: number;
|
|
11931
|
+
metadata?: Record<string, unknown>;
|
|
11932
|
+
}
|
|
11479
11933
|
/**
|
|
11480
|
-
*
|
|
11481
|
-
*
|
|
11482
|
-
* @param entity - 实体实例
|
|
11483
|
-
* @param componentType - 组件类型构造函数
|
|
11484
|
-
* @returns 组件实例或undefined
|
|
11485
|
-
*
|
|
11486
|
-
* @example
|
|
11487
|
-
* ```typescript
|
|
11488
|
-
* const health = tryGetComponent(entity, Health);
|
|
11489
|
-
* if (health) {
|
|
11490
|
-
* health.value -= 10;
|
|
11491
|
-
* }
|
|
11492
|
-
* ```
|
|
11934
|
+
* 聚合后的采样统计
|
|
11493
11935
|
*/
|
|
11494
|
-
|
|
11936
|
+
interface ProfileSampleStats {
|
|
11937
|
+
name: string;
|
|
11938
|
+
category: ProfileCategory;
|
|
11939
|
+
/** 包含时间(包含子调用) */
|
|
11940
|
+
inclusiveTime: number;
|
|
11941
|
+
/** 独占时间(不包含子调用) */
|
|
11942
|
+
exclusiveTime: number;
|
|
11943
|
+
/** 调用次数 */
|
|
11944
|
+
callCount: number;
|
|
11945
|
+
/** 平均时间 */
|
|
11946
|
+
averageTime: number;
|
|
11947
|
+
/** 最小时间 */
|
|
11948
|
+
minTime: number;
|
|
11949
|
+
/** 最大时间 */
|
|
11950
|
+
maxTime: number;
|
|
11951
|
+
/** 占总帧时间百分比 */
|
|
11952
|
+
percentOfFrame: number;
|
|
11953
|
+
/** 占父级时间百分比 */
|
|
11954
|
+
percentOfParent: number;
|
|
11955
|
+
/** 子采样 */
|
|
11956
|
+
children: ProfileSampleStats[];
|
|
11957
|
+
/** 深度 */
|
|
11958
|
+
depth: number;
|
|
11959
|
+
}
|
|
11495
11960
|
/**
|
|
11496
|
-
*
|
|
11497
|
-
*
|
|
11498
|
-
* @param entity - 实体实例
|
|
11499
|
-
* @param types - 组件类型构造函数数组
|
|
11500
|
-
* @returns 组件实例元组,每个元素可能为null
|
|
11501
|
-
*
|
|
11502
|
-
* @example
|
|
11503
|
-
* ```typescript
|
|
11504
|
-
* const [pos, vel, health] = getComponents(entity, Position, Velocity, Health);
|
|
11505
|
-
* if (pos && vel && health) {
|
|
11506
|
-
* pos.x += vel.dx;
|
|
11507
|
-
* }
|
|
11508
|
-
* ```
|
|
11961
|
+
* 内存快照
|
|
11509
11962
|
*/
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11963
|
+
interface MemorySnapshot {
|
|
11964
|
+
timestamp: number;
|
|
11965
|
+
/** 已使用堆内存 (bytes) */
|
|
11966
|
+
usedHeapSize: number;
|
|
11967
|
+
/** 总堆内存 (bytes) */
|
|
11968
|
+
totalHeapSize: number;
|
|
11969
|
+
/** 堆内存限制 (bytes) */
|
|
11970
|
+
heapSizeLimit: number;
|
|
11971
|
+
/** 使用率 (0-100) */
|
|
11972
|
+
utilizationPercent: number;
|
|
11973
|
+
/** 检测到的 GC 次数 */
|
|
11974
|
+
gcCount: number;
|
|
11975
|
+
}
|
|
11513
11976
|
/**
|
|
11514
|
-
*
|
|
11515
|
-
*
|
|
11516
|
-
* @param entity - 实体实例
|
|
11517
|
-
* @param types - 组件类型构造函数数组
|
|
11518
|
-
* @returns 如果拥有所有组件返回true,否则返回false
|
|
11519
|
-
*
|
|
11520
|
-
* @example
|
|
11521
|
-
* ```typescript
|
|
11522
|
-
* if (hasComponents(entity, Position, Velocity)) {
|
|
11523
|
-
* const pos = entity.getComponent(Position)!;
|
|
11524
|
-
* const vel = entity.getComponent(Velocity)!;
|
|
11525
|
-
* }
|
|
11526
|
-
* ```
|
|
11977
|
+
* 计数器数据
|
|
11527
11978
|
*/
|
|
11528
|
-
|
|
11979
|
+
interface ProfileCounter {
|
|
11980
|
+
name: string;
|
|
11981
|
+
category: ProfileCategory;
|
|
11982
|
+
value: number;
|
|
11983
|
+
type: 'counter' | 'gauge';
|
|
11984
|
+
history: Array<{
|
|
11985
|
+
time: number;
|
|
11986
|
+
value: number;
|
|
11987
|
+
}>;
|
|
11988
|
+
}
|
|
11529
11989
|
/**
|
|
11530
|
-
*
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11990
|
+
* 单帧性能数据
|
|
11991
|
+
*/
|
|
11992
|
+
interface ProfileFrame {
|
|
11993
|
+
frameNumber: number;
|
|
11994
|
+
startTime: number;
|
|
11995
|
+
endTime: number;
|
|
11996
|
+
duration: number;
|
|
11997
|
+
samples: ProfileSample[];
|
|
11998
|
+
sampleStats: ProfileSampleStats[];
|
|
11999
|
+
counters: Map<string, ProfileCounter>;
|
|
12000
|
+
memory: MemorySnapshot;
|
|
12001
|
+
/** 按类别分组的统计 */
|
|
12002
|
+
categoryStats: Map<ProfileCategory, {
|
|
12003
|
+
totalTime: number;
|
|
12004
|
+
sampleCount: number;
|
|
12005
|
+
percentOfFrame: number;
|
|
12006
|
+
}>;
|
|
12007
|
+
}
|
|
12008
|
+
/**
|
|
12009
|
+
* 分析器配置
|
|
11535
12010
|
*/
|
|
11536
|
-
|
|
12011
|
+
interface ProfilerConfig {
|
|
12012
|
+
/** 是否启用 */
|
|
12013
|
+
enabled: boolean;
|
|
12014
|
+
/** 最大历史帧数 */
|
|
12015
|
+
maxFrameHistory: number;
|
|
12016
|
+
/** 采样深度限制 */
|
|
12017
|
+
maxSampleDepth: number;
|
|
12018
|
+
/** 是否收集内存数据 */
|
|
12019
|
+
collectMemory: boolean;
|
|
12020
|
+
/** 内存采样间隔 (ms) */
|
|
12021
|
+
memorySampleInterval: number;
|
|
12022
|
+
/** 是否检测长任务 */
|
|
12023
|
+
detectLongTasks: boolean;
|
|
12024
|
+
/** 长任务阈值 (ms) */
|
|
12025
|
+
longTaskThreshold: number;
|
|
12026
|
+
/** 启用的类别 */
|
|
12027
|
+
enabledCategories: Set<ProfileCategory>;
|
|
12028
|
+
}
|
|
11537
12029
|
/**
|
|
11538
|
-
*
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
12030
|
+
* 长任务信息
|
|
12031
|
+
*/
|
|
12032
|
+
interface LongTaskInfo {
|
|
12033
|
+
startTime: number;
|
|
12034
|
+
duration: number;
|
|
12035
|
+
attribution: string[];
|
|
12036
|
+
}
|
|
12037
|
+
/**
|
|
12038
|
+
* 调用关系节点
|
|
12039
|
+
*/
|
|
12040
|
+
interface CallGraphNode {
|
|
12041
|
+
name: string;
|
|
12042
|
+
category: ProfileCategory;
|
|
12043
|
+
/** 被调用次数 */
|
|
12044
|
+
callCount: number;
|
|
12045
|
+
/** 总耗时 */
|
|
12046
|
+
totalTime: number;
|
|
12047
|
+
/** 调用者列表 */
|
|
12048
|
+
callers: Map<string, {
|
|
12049
|
+
count: number;
|
|
12050
|
+
totalTime: number;
|
|
12051
|
+
}>;
|
|
12052
|
+
/** 被调用者列表 */
|
|
12053
|
+
callees: Map<string, {
|
|
12054
|
+
count: number;
|
|
12055
|
+
totalTime: number;
|
|
12056
|
+
}>;
|
|
12057
|
+
}
|
|
12058
|
+
/**
|
|
12059
|
+
* 性能分析报告
|
|
12060
|
+
*/
|
|
12061
|
+
interface ProfileReport {
|
|
12062
|
+
startTime: number;
|
|
12063
|
+
endTime: number;
|
|
12064
|
+
totalFrames: number;
|
|
12065
|
+
averageFrameTime: number;
|
|
12066
|
+
minFrameTime: number;
|
|
12067
|
+
maxFrameTime: number;
|
|
12068
|
+
p95FrameTime: number;
|
|
12069
|
+
p99FrameTime: number;
|
|
12070
|
+
/** 热点函数 (按耗时排序) */
|
|
12071
|
+
hotspots: ProfileSampleStats[];
|
|
12072
|
+
/** 调用图 */
|
|
12073
|
+
callGraph: Map<string, CallGraphNode>;
|
|
12074
|
+
/** 类别统计 */
|
|
12075
|
+
categoryBreakdown: Map<ProfileCategory, {
|
|
12076
|
+
totalTime: number;
|
|
12077
|
+
averageTime: number;
|
|
12078
|
+
percentOfTotal: number;
|
|
12079
|
+
}>;
|
|
12080
|
+
/** 内存趋势 */
|
|
12081
|
+
memoryTrend: MemorySnapshot[];
|
|
12082
|
+
/** 长任务列表 */
|
|
12083
|
+
longTasks: LongTaskInfo[];
|
|
12084
|
+
}
|
|
12085
|
+
/**
|
|
12086
|
+
* 默认配置
|
|
12087
|
+
*/
|
|
12088
|
+
declare const DEFAULT_PROFILER_CONFIG: ProfilerConfig;
|
|
12089
|
+
|
|
12090
|
+
/**
|
|
12091
|
+
* 高级性能分析数据收集器
|
|
11544
12092
|
*
|
|
11545
|
-
*
|
|
11546
|
-
*
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
*
|
|
11551
|
-
|
|
12093
|
+
* 整合 ProfilerSDK 和现有 PerformanceMonitor 的数据,
|
|
12094
|
+
* 提供统一的高级性能分析数据接口
|
|
12095
|
+
*/
|
|
12096
|
+
|
|
12097
|
+
/**
|
|
12098
|
+
* 旧版 PerformanceMonitor 接口 (用于兼容)
|
|
12099
|
+
*/
|
|
12100
|
+
interface ILegacyPerformanceMonitor {
|
|
12101
|
+
getAllSystemStats?: () => Map<string, {
|
|
12102
|
+
averageTime: number;
|
|
12103
|
+
minTime?: number;
|
|
12104
|
+
maxTime?: number;
|
|
12105
|
+
executionCount?: number;
|
|
12106
|
+
}>;
|
|
12107
|
+
getAllSystemData?: () => Map<string, {
|
|
12108
|
+
executionTime: number;
|
|
12109
|
+
entityCount?: number;
|
|
12110
|
+
}>;
|
|
12111
|
+
}
|
|
12112
|
+
/**
|
|
12113
|
+
* 热点函数项(支持递归层级)
|
|
12114
|
+
*/
|
|
12115
|
+
interface IHotspotItem {
|
|
12116
|
+
name: string;
|
|
12117
|
+
category: string;
|
|
12118
|
+
inclusiveTime: number;
|
|
12119
|
+
inclusiveTimePercent: number;
|
|
12120
|
+
exclusiveTime: number;
|
|
12121
|
+
exclusiveTimePercent: number;
|
|
12122
|
+
callCount: number;
|
|
12123
|
+
avgCallTime: number;
|
|
12124
|
+
/** 层级深度 */
|
|
12125
|
+
depth: number;
|
|
12126
|
+
/** 子函数 */
|
|
12127
|
+
children?: IHotspotItem[] | undefined;
|
|
12128
|
+
}
|
|
12129
|
+
/**
|
|
12130
|
+
* 高级性能数据接口
|
|
12131
|
+
*/
|
|
12132
|
+
interface IAdvancedProfilerData {
|
|
12133
|
+
/** 当前帧信息 */
|
|
12134
|
+
currentFrame: {
|
|
12135
|
+
frameNumber: number;
|
|
12136
|
+
frameTime: number;
|
|
12137
|
+
fps: number;
|
|
12138
|
+
memory: MemorySnapshot;
|
|
12139
|
+
};
|
|
12140
|
+
/** 帧时间历史 (用于绘制图表) */
|
|
12141
|
+
frameTimeHistory: Array<{
|
|
12142
|
+
frameNumber: number;
|
|
12143
|
+
time: number;
|
|
12144
|
+
duration: number;
|
|
12145
|
+
}>;
|
|
12146
|
+
/** 按类别分组的统计 */
|
|
12147
|
+
categoryStats: Array<{
|
|
12148
|
+
category: string;
|
|
12149
|
+
totalTime: number;
|
|
12150
|
+
percentOfFrame: number;
|
|
12151
|
+
sampleCount: number;
|
|
12152
|
+
expanded?: boolean;
|
|
12153
|
+
items: Array<{
|
|
12154
|
+
name: string;
|
|
12155
|
+
inclusiveTime: number;
|
|
12156
|
+
exclusiveTime: number;
|
|
12157
|
+
callCount: number;
|
|
12158
|
+
percentOfCategory: number;
|
|
12159
|
+
percentOfFrame: number;
|
|
12160
|
+
}>;
|
|
12161
|
+
}>;
|
|
12162
|
+
/** 热点函数列表(支持层级) */
|
|
12163
|
+
hotspots: IHotspotItem[];
|
|
12164
|
+
/** 调用关系数据 */
|
|
12165
|
+
callGraph: {
|
|
12166
|
+
/** 当前选中的函数 */
|
|
12167
|
+
currentFunction: string | null;
|
|
12168
|
+
/** 调用当前函数的函数列表 */
|
|
12169
|
+
callers: Array<{
|
|
12170
|
+
name: string;
|
|
12171
|
+
callCount: number;
|
|
12172
|
+
totalTime: number;
|
|
12173
|
+
percentOfCurrent: number;
|
|
12174
|
+
}>;
|
|
12175
|
+
/** 当前函数调用的函数列表 */
|
|
12176
|
+
callees: Array<{
|
|
12177
|
+
name: string;
|
|
12178
|
+
callCount: number;
|
|
12179
|
+
totalTime: number;
|
|
12180
|
+
percentOfCurrent: number;
|
|
12181
|
+
}>;
|
|
12182
|
+
};
|
|
12183
|
+
/** 长任务列表 */
|
|
12184
|
+
longTasks: Array<{
|
|
12185
|
+
startTime: number;
|
|
12186
|
+
duration: number;
|
|
12187
|
+
attribution: string[];
|
|
12188
|
+
}>;
|
|
12189
|
+
/** 内存趋势 */
|
|
12190
|
+
memoryTrend: Array<{
|
|
12191
|
+
time: number;
|
|
12192
|
+
usedMB: number;
|
|
12193
|
+
totalMB: number;
|
|
12194
|
+
gcCount: number;
|
|
12195
|
+
}>;
|
|
12196
|
+
/** 统计摘要 */
|
|
12197
|
+
summary: {
|
|
12198
|
+
totalFrames: number;
|
|
12199
|
+
averageFrameTime: number;
|
|
12200
|
+
minFrameTime: number;
|
|
12201
|
+
maxFrameTime: number;
|
|
12202
|
+
p95FrameTime: number;
|
|
12203
|
+
p99FrameTime: number;
|
|
12204
|
+
currentMemoryMB: number;
|
|
12205
|
+
peakMemoryMB: number;
|
|
12206
|
+
gcCount: number;
|
|
12207
|
+
longTaskCount: number;
|
|
12208
|
+
};
|
|
12209
|
+
}
|
|
12210
|
+
/**
|
|
12211
|
+
* 高级性能分析数据收集器
|
|
11552
12212
|
*/
|
|
11553
|
-
declare
|
|
12213
|
+
declare class AdvancedProfilerCollector {
|
|
12214
|
+
private selectedFunction;
|
|
12215
|
+
private peakMemory;
|
|
12216
|
+
constructor();
|
|
12217
|
+
/**
|
|
12218
|
+
* 设置选中的函数(用于调用关系视图)
|
|
12219
|
+
*/
|
|
12220
|
+
setSelectedFunction(name: string | null): void;
|
|
12221
|
+
/**
|
|
12222
|
+
* 收集高级性能数据
|
|
12223
|
+
*/
|
|
12224
|
+
collectAdvancedData(performanceMonitor?: ILegacyPerformanceMonitor): IAdvancedProfilerData;
|
|
12225
|
+
/**
|
|
12226
|
+
* 从现有 PerformanceMonitor 数据构建兼容格式
|
|
12227
|
+
*/
|
|
12228
|
+
collectFromLegacyMonitor(performanceMonitor: ILegacyPerformanceMonitor | null): IAdvancedProfilerData;
|
|
12229
|
+
private buildCurrentFrameData;
|
|
12230
|
+
private buildFrameTimeHistory;
|
|
12231
|
+
private buildCategoryStats;
|
|
12232
|
+
private buildCategoryStatsFromLegacy;
|
|
12233
|
+
private buildHotspots;
|
|
12234
|
+
private buildHotspotsFromLegacy;
|
|
12235
|
+
private buildCallGraph;
|
|
12236
|
+
private buildMemoryTrend;
|
|
12237
|
+
private buildSummary;
|
|
12238
|
+
private getCurrentMemory;
|
|
12239
|
+
private getDefaultMemory;
|
|
12240
|
+
private createEmptyData;
|
|
12241
|
+
}
|
|
12242
|
+
|
|
11554
12243
|
/**
|
|
11555
|
-
*
|
|
11556
|
-
*
|
|
11557
|
-
* 如果组件已存在则返回现有组件,否则通过工厂函数创建并添加
|
|
11558
|
-
*
|
|
11559
|
-
* @param entity - 实体实例
|
|
11560
|
-
* @param componentType - 组件类型构造函数
|
|
11561
|
-
* @param factory - 组件工厂函数(仅在组件不存在时调用)
|
|
11562
|
-
* @returns 组件实例
|
|
11563
|
-
*
|
|
11564
|
-
* @example
|
|
11565
|
-
* ```typescript
|
|
11566
|
-
* const health = getOrAddComponent(entity, Health, () => new Health(100));
|
|
11567
|
-
* ```
|
|
12244
|
+
* 二进制序列化器
|
|
12245
|
+
* 将对象转换为UTF8字节数组
|
|
11568
12246
|
*/
|
|
11569
|
-
declare
|
|
12247
|
+
declare class BinarySerializer {
|
|
12248
|
+
/**
|
|
12249
|
+
* 将字符串编码为UTF8字节数组
|
|
12250
|
+
*/
|
|
12251
|
+
private static stringToUtf8;
|
|
12252
|
+
/**
|
|
12253
|
+
* 将UTF8字节数组解码为字符串
|
|
12254
|
+
*/
|
|
12255
|
+
private static utf8ToString;
|
|
12256
|
+
/**
|
|
12257
|
+
* 将对象编码为二进制数据
|
|
12258
|
+
*/
|
|
12259
|
+
static encode(value: any): Uint8Array;
|
|
12260
|
+
/**
|
|
12261
|
+
* 将二进制数据解码为对象
|
|
12262
|
+
*/
|
|
12263
|
+
static decode(bytes: Uint8Array): any;
|
|
12264
|
+
}
|
|
12265
|
+
|
|
11570
12266
|
/**
|
|
11571
|
-
*
|
|
11572
|
-
*
|
|
11573
|
-
* @param entity - 实体实例
|
|
11574
|
-
* @param componentType - 组件类型构造函数
|
|
11575
|
-
* @param data - 要更新的部分数据
|
|
11576
|
-
* @returns 如果更新成功返回true,组件不存在返回false
|
|
12267
|
+
* 性能分析器 SDK
|
|
11577
12268
|
*
|
|
11578
|
-
*
|
|
11579
|
-
*
|
|
11580
|
-
*
|
|
11581
|
-
*
|
|
12269
|
+
* 提供统一的性能分析接口,支持:
|
|
12270
|
+
* - 手动采样标记
|
|
12271
|
+
* - 自动作用域测量
|
|
12272
|
+
* - 调用层级追踪
|
|
12273
|
+
* - 计数器和仪表
|
|
11582
12274
|
*/
|
|
11583
|
-
|
|
12275
|
+
|
|
11584
12276
|
/**
|
|
11585
|
-
*
|
|
11586
|
-
*
|
|
11587
|
-
* @example
|
|
11588
|
-
* ```typescript
|
|
11589
|
-
* const player = buildEntity(scene.createEntity("Player"))
|
|
11590
|
-
* .with(new Position(100, 100))
|
|
11591
|
-
* .with(new Velocity(0, 0))
|
|
11592
|
-
* .withTag(1)
|
|
11593
|
-
* .build();
|
|
11594
|
-
* ```
|
|
12277
|
+
* 性能分析器 SDK
|
|
11595
12278
|
*/
|
|
11596
|
-
declare class
|
|
11597
|
-
private
|
|
11598
|
-
|
|
12279
|
+
declare class ProfilerSDK {
|
|
12280
|
+
private static instance;
|
|
12281
|
+
private config;
|
|
12282
|
+
private currentFrame;
|
|
12283
|
+
private frameHistory;
|
|
12284
|
+
private frameNumber;
|
|
12285
|
+
private activeSamples;
|
|
12286
|
+
private sampleStack;
|
|
12287
|
+
private counters;
|
|
12288
|
+
private callGraph;
|
|
12289
|
+
private gcCount;
|
|
12290
|
+
private previousHeapSize;
|
|
12291
|
+
private longTasks;
|
|
12292
|
+
private performanceObserver;
|
|
12293
|
+
private constructor();
|
|
11599
12294
|
/**
|
|
11600
|
-
*
|
|
12295
|
+
* 获取单例实例
|
|
11601
12296
|
*/
|
|
11602
|
-
|
|
12297
|
+
static getInstance(config?: Partial<ProfilerConfig>): ProfilerSDK;
|
|
11603
12298
|
/**
|
|
11604
|
-
*
|
|
12299
|
+
* 重置实例(测试用)
|
|
11605
12300
|
*/
|
|
11606
|
-
|
|
12301
|
+
static resetInstance(): void;
|
|
11607
12302
|
/**
|
|
11608
|
-
*
|
|
12303
|
+
* 开始采样
|
|
11609
12304
|
*/
|
|
11610
|
-
|
|
12305
|
+
static beginSample(name: string, category?: ProfileCategory): SampleHandle | null;
|
|
11611
12306
|
/**
|
|
11612
|
-
*
|
|
12307
|
+
* 结束采样
|
|
11613
12308
|
*/
|
|
11614
|
-
|
|
12309
|
+
static endSample(handle: SampleHandle | null): void;
|
|
11615
12310
|
/**
|
|
11616
|
-
*
|
|
12311
|
+
* 测量同步函数执行时间
|
|
11617
12312
|
*/
|
|
11618
|
-
|
|
12313
|
+
static measure<T>(name: string, fn: () => T, category?: ProfileCategory): T;
|
|
12314
|
+
/**
|
|
12315
|
+
* 测量异步函数执行时间
|
|
12316
|
+
*/
|
|
12317
|
+
static measureAsync<T>(name: string, fn: () => Promise<T>, category?: ProfileCategory): Promise<T>;
|
|
12318
|
+
/**
|
|
12319
|
+
* 开始帧
|
|
12320
|
+
*/
|
|
12321
|
+
static beginFrame(): void;
|
|
12322
|
+
/**
|
|
12323
|
+
* 结束帧
|
|
12324
|
+
*/
|
|
12325
|
+
static endFrame(): void;
|
|
12326
|
+
/**
|
|
12327
|
+
* 递增计数器
|
|
12328
|
+
*/
|
|
12329
|
+
static incrementCounter(name: string, value?: number, category?: ProfileCategory): void;
|
|
12330
|
+
/**
|
|
12331
|
+
* 设置仪表值
|
|
12332
|
+
*/
|
|
12333
|
+
static setGauge(name: string, value: number, category?: ProfileCategory): void;
|
|
12334
|
+
/**
|
|
12335
|
+
* 启用/禁用分析器
|
|
12336
|
+
*/
|
|
12337
|
+
static setEnabled(enabled: boolean): void;
|
|
12338
|
+
/**
|
|
12339
|
+
* 检查是否启用
|
|
12340
|
+
*/
|
|
12341
|
+
static isEnabled(): boolean;
|
|
12342
|
+
/**
|
|
12343
|
+
* 获取当前帧数据
|
|
12344
|
+
*/
|
|
12345
|
+
static getCurrentFrame(): ProfileFrame | null;
|
|
12346
|
+
/**
|
|
12347
|
+
* 获取帧历史
|
|
12348
|
+
*/
|
|
12349
|
+
static getFrameHistory(): ProfileFrame[];
|
|
12350
|
+
/**
|
|
12351
|
+
* 获取分析报告
|
|
12352
|
+
*/
|
|
12353
|
+
static getReport(frameCount?: number): ProfileReport;
|
|
12354
|
+
/**
|
|
12355
|
+
* 重置数据
|
|
12356
|
+
*/
|
|
12357
|
+
static reset(): void;
|
|
12358
|
+
/**
|
|
12359
|
+
* 开始采样
|
|
12360
|
+
*/
|
|
12361
|
+
beginSample(name: string, category?: ProfileCategory): SampleHandle | null;
|
|
12362
|
+
/**
|
|
12363
|
+
* 结束采样
|
|
12364
|
+
*/
|
|
12365
|
+
endSample(handle: SampleHandle): void;
|
|
12366
|
+
/**
|
|
12367
|
+
* 测量同步函数
|
|
12368
|
+
*/
|
|
12369
|
+
measure<T>(name: string, fn: () => T, category?: ProfileCategory): T;
|
|
12370
|
+
/**
|
|
12371
|
+
* 测量异步函数
|
|
12372
|
+
*/
|
|
12373
|
+
measureAsync<T>(name: string, fn: () => Promise<T>, category?: ProfileCategory): Promise<T>;
|
|
12374
|
+
/**
|
|
12375
|
+
* 开始帧
|
|
12376
|
+
*/
|
|
12377
|
+
beginFrame(): void;
|
|
12378
|
+
/**
|
|
12379
|
+
* 结束帧
|
|
12380
|
+
*/
|
|
12381
|
+
endFrame(): void;
|
|
12382
|
+
/**
|
|
12383
|
+
* 递增计数器
|
|
12384
|
+
*/
|
|
12385
|
+
incrementCounter(name: string, value?: number, category?: ProfileCategory): void;
|
|
12386
|
+
/**
|
|
12387
|
+
* 设置仪表值
|
|
12388
|
+
*/
|
|
12389
|
+
setGauge(name: string, value: number, category?: ProfileCategory): void;
|
|
11619
12390
|
/**
|
|
11620
12391
|
* 设置启用状态
|
|
11621
12392
|
*/
|
|
11622
|
-
|
|
12393
|
+
setEnabled(enabled: boolean): void;
|
|
11623
12394
|
/**
|
|
11624
|
-
*
|
|
12395
|
+
* 重置数据
|
|
11625
12396
|
*/
|
|
11626
|
-
|
|
12397
|
+
reset(): void;
|
|
11627
12398
|
/**
|
|
11628
|
-
*
|
|
12399
|
+
* 生成分析报告
|
|
11629
12400
|
*/
|
|
11630
|
-
|
|
12401
|
+
generateReport(frameCount?: number): ProfileReport;
|
|
11631
12402
|
/**
|
|
11632
|
-
*
|
|
12403
|
+
* 从帧历史构建调用图
|
|
12404
|
+
* 注意:totalTime 存储的是平均耗时(总耗时/调用次数),而不是累计总耗时
|
|
11633
12405
|
*/
|
|
11634
|
-
|
|
12406
|
+
private buildCallGraphFromFrames;
|
|
11635
12407
|
/**
|
|
11636
|
-
*
|
|
12408
|
+
* 获取调用图数据
|
|
11637
12409
|
*/
|
|
11638
|
-
|
|
12410
|
+
getCallGraph(): Map<string, CallGraphNode>;
|
|
12411
|
+
/**
|
|
12412
|
+
* 获取特定函数的调用关系
|
|
12413
|
+
*/
|
|
12414
|
+
getFunctionCallInfo(name: string): {
|
|
12415
|
+
callers: Array<{
|
|
12416
|
+
name: string;
|
|
12417
|
+
count: number;
|
|
12418
|
+
totalTime: number;
|
|
12419
|
+
}>;
|
|
12420
|
+
callees: Array<{
|
|
12421
|
+
name: string;
|
|
12422
|
+
count: number;
|
|
12423
|
+
totalTime: number;
|
|
12424
|
+
}>;
|
|
12425
|
+
} | null;
|
|
12426
|
+
/**
|
|
12427
|
+
* 释放资源
|
|
12428
|
+
*/
|
|
12429
|
+
dispose(): void;
|
|
12430
|
+
private captureMemory;
|
|
12431
|
+
private resetFrameCounters;
|
|
12432
|
+
private calculateSampleStats;
|
|
12433
|
+
private calculateCategoryStats;
|
|
12434
|
+
private updateCallGraph;
|
|
12435
|
+
private aggregateSampleStats;
|
|
12436
|
+
private aggregateCategoryStats;
|
|
12437
|
+
private setupLongTaskObserver;
|
|
12438
|
+
private createEmptyReport;
|
|
11639
12439
|
}
|
|
12440
|
+
|
|
11640
12441
|
/**
|
|
11641
|
-
*
|
|
12442
|
+
* 自动性能分析器
|
|
11642
12443
|
*
|
|
11643
|
-
*
|
|
11644
|
-
*
|
|
12444
|
+
* 提供自动函数包装和采样分析功能,无需手动埋点即可收集性能数据。
|
|
12445
|
+
*
|
|
12446
|
+
* 支持三种分析模式:
|
|
12447
|
+
* 1. 自动包装模式 - 使用 Proxy 自动包装类的所有方法
|
|
12448
|
+
* 2. 采样分析模式 - 定时采样调用栈(需要浏览器支持)
|
|
12449
|
+
* 3. 装饰器模式 - 使用 @Profile() 装饰器手动标记方法
|
|
11645
12450
|
*/
|
|
11646
|
-
declare function buildEntity(entity: Entity): TypedEntityBuilder;
|
|
11647
12451
|
|
|
11648
12452
|
/**
|
|
11649
|
-
*
|
|
11650
|
-
* 提供类型相关的实用方法
|
|
12453
|
+
* 自动分析配置
|
|
11651
12454
|
*/
|
|
11652
|
-
|
|
11653
|
-
/**
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
12455
|
+
interface AutoProfilerConfig {
|
|
12456
|
+
/** 是否启用自动包装 */
|
|
12457
|
+
enabled: boolean;
|
|
12458
|
+
/** 采样间隔(毫秒),用于采样分析器 */
|
|
12459
|
+
sampleInterval: number;
|
|
12460
|
+
/** 最小记录耗时(毫秒),低于此值的调用不记录 */
|
|
12461
|
+
minDuration: number;
|
|
12462
|
+
/** 是否追踪异步方法 */
|
|
12463
|
+
trackAsync: boolean;
|
|
12464
|
+
/** 排除的方法名模式 */
|
|
12465
|
+
excludePatterns: RegExp[];
|
|
12466
|
+
/** 最大采样缓冲区大小 */
|
|
12467
|
+
maxBufferSize: number;
|
|
11659
12468
|
}
|
|
11660
|
-
|
|
11661
12469
|
/**
|
|
11662
|
-
*
|
|
11663
|
-
* 提供数字转换的实用方法
|
|
12470
|
+
* 采样数据
|
|
11664
12471
|
*/
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
* @returns 转换后的数字,如果值为undefined则返回0
|
|
11670
|
-
*/
|
|
11671
|
-
static toNumber(value: unknown): number;
|
|
12472
|
+
interface SampleData {
|
|
12473
|
+
timestamp: number;
|
|
12474
|
+
stack: string[];
|
|
12475
|
+
duration?: number;
|
|
11672
12476
|
}
|
|
11673
|
-
|
|
11674
12477
|
/**
|
|
11675
|
-
*
|
|
11676
|
-
* 提供游戏时间相关的功能,包括帧时间、总时间、时间缩放等
|
|
12478
|
+
* 自动性能分析器
|
|
11677
12479
|
*/
|
|
11678
|
-
declare class
|
|
12480
|
+
declare class AutoProfiler {
|
|
12481
|
+
private static instance;
|
|
12482
|
+
private config;
|
|
12483
|
+
private wrappedObjects;
|
|
12484
|
+
private samplingProfiler;
|
|
12485
|
+
private registeredClasses;
|
|
12486
|
+
private constructor();
|
|
11679
12487
|
/**
|
|
11680
|
-
*
|
|
12488
|
+
* 获取单例实例
|
|
11681
12489
|
*/
|
|
11682
|
-
static
|
|
12490
|
+
static getInstance(config?: Partial<AutoProfilerConfig>): AutoProfiler;
|
|
11683
12491
|
/**
|
|
11684
|
-
*
|
|
12492
|
+
* 重置实例
|
|
11685
12493
|
*/
|
|
11686
|
-
static
|
|
12494
|
+
static resetInstance(): void;
|
|
11687
12495
|
/**
|
|
11688
|
-
*
|
|
12496
|
+
* 启用/禁用自动分析
|
|
11689
12497
|
*/
|
|
11690
|
-
static
|
|
12498
|
+
static setEnabled(enabled: boolean): void;
|
|
11691
12499
|
/**
|
|
11692
|
-
*
|
|
12500
|
+
* 注册类以进行自动分析
|
|
12501
|
+
* 该类的所有实例方法都会被自动包装
|
|
11693
12502
|
*/
|
|
11694
|
-
static
|
|
12503
|
+
static registerClass<T extends new (...args: any[]) => any>(constructor: T, category?: ProfileCategory, className?: string): T;
|
|
11695
12504
|
/**
|
|
11696
|
-
*
|
|
12505
|
+
* 包装对象实例的所有方法
|
|
11697
12506
|
*/
|
|
11698
|
-
static
|
|
12507
|
+
static wrapInstance<T extends object>(instance: T, className: string, category?: ProfileCategory): T;
|
|
11699
12508
|
/**
|
|
11700
|
-
*
|
|
12509
|
+
* 包装单个函数
|
|
11701
12510
|
*/
|
|
11702
|
-
static
|
|
12511
|
+
static wrapFunction<T extends (...args: any[]) => any>(fn: T, name: string, category?: ProfileCategory): T;
|
|
11703
12512
|
/**
|
|
11704
|
-
*
|
|
11705
|
-
* @param deltaTime 外部引擎提供的帧时间间隔(秒)
|
|
12513
|
+
* 启动采样分析器
|
|
11706
12514
|
*/
|
|
11707
|
-
static
|
|
12515
|
+
static startSampling(): void;
|
|
11708
12516
|
/**
|
|
11709
|
-
*
|
|
12517
|
+
* 停止采样分析器
|
|
11710
12518
|
*/
|
|
11711
|
-
static
|
|
12519
|
+
static stopSampling(): SampleData[];
|
|
11712
12520
|
/**
|
|
11713
|
-
*
|
|
11714
|
-
* @param interval 时间间隔(秒)
|
|
11715
|
-
* @param lastTime 上次检查的时间
|
|
11716
|
-
* @returns 是否已经过去指定时间
|
|
12521
|
+
* 设置启用状态
|
|
11717
12522
|
*/
|
|
11718
|
-
|
|
11719
|
-
}
|
|
11720
|
-
|
|
11721
|
-
/**
|
|
11722
|
-
* 二进制序列化器
|
|
11723
|
-
* 将对象转换为UTF8字节数组
|
|
11724
|
-
*/
|
|
11725
|
-
declare class BinarySerializer {
|
|
12523
|
+
setEnabled(enabled: boolean): void;
|
|
11726
12524
|
/**
|
|
11727
|
-
*
|
|
12525
|
+
* 注册类以进行自动分析
|
|
11728
12526
|
*/
|
|
11729
|
-
|
|
12527
|
+
registerClass<T extends new (...args: any[]) => any>(constructor: T, category?: ProfileCategory, className?: string): T;
|
|
11730
12528
|
/**
|
|
11731
|
-
*
|
|
12529
|
+
* 包装对象实例的所有方法
|
|
11732
12530
|
*/
|
|
11733
|
-
|
|
12531
|
+
wrapInstance<T extends object>(instance: T, className: string, category?: ProfileCategory): T;
|
|
11734
12532
|
/**
|
|
11735
|
-
*
|
|
12533
|
+
* 包装单个函数
|
|
11736
12534
|
*/
|
|
11737
|
-
|
|
12535
|
+
wrapFunction<T extends (...args: any[]) => any>(fn: T, name: string, category?: ProfileCategory): T;
|
|
11738
12536
|
/**
|
|
11739
|
-
*
|
|
12537
|
+
* 启动采样分析器
|
|
11740
12538
|
*/
|
|
11741
|
-
|
|
12539
|
+
startSampling(): void;
|
|
12540
|
+
/**
|
|
12541
|
+
* 停止采样分析器
|
|
12542
|
+
*/
|
|
12543
|
+
stopSampling(): SampleData[];
|
|
12544
|
+
/**
|
|
12545
|
+
* 释放资源
|
|
12546
|
+
*/
|
|
12547
|
+
dispose(): void;
|
|
12548
|
+
/**
|
|
12549
|
+
* 创建包装后的方法
|
|
12550
|
+
*/
|
|
12551
|
+
private createWrappedMethod;
|
|
12552
|
+
/**
|
|
12553
|
+
* 获取对象的所有方法名
|
|
12554
|
+
*/
|
|
12555
|
+
private getAllMethodNames;
|
|
12556
|
+
/**
|
|
12557
|
+
* 获取属性描述符
|
|
12558
|
+
*/
|
|
12559
|
+
private getPropertyDescriptor;
|
|
12560
|
+
/**
|
|
12561
|
+
* 判断是否应该排除该方法
|
|
12562
|
+
*/
|
|
12563
|
+
private shouldExcludeMethod;
|
|
11742
12564
|
}
|
|
12565
|
+
/**
|
|
12566
|
+
* @Profile 装饰器
|
|
12567
|
+
* 用于标记需要性能分析的方法
|
|
12568
|
+
*
|
|
12569
|
+
* @example
|
|
12570
|
+
* ```typescript
|
|
12571
|
+
* class MySystem extends System {
|
|
12572
|
+
* @Profile()
|
|
12573
|
+
* update() {
|
|
12574
|
+
* // 方法执行时间会被自动记录
|
|
12575
|
+
* }
|
|
12576
|
+
*
|
|
12577
|
+
* @Profile('customName', ProfileCategory.Physics)
|
|
12578
|
+
* calculatePhysics() {
|
|
12579
|
+
* // 使用自定义名称和分类
|
|
12580
|
+
* }
|
|
12581
|
+
* }
|
|
12582
|
+
* ```
|
|
12583
|
+
*/
|
|
12584
|
+
declare function Profile(name?: string, category?: ProfileCategory): MethodDecorator;
|
|
12585
|
+
/**
|
|
12586
|
+
* @ProfileClass 装饰器
|
|
12587
|
+
* 用于自动包装类的所有方法
|
|
12588
|
+
*
|
|
12589
|
+
* @example
|
|
12590
|
+
* ```typescript
|
|
12591
|
+
* @ProfileClass(ProfileCategory.Physics)
|
|
12592
|
+
* class PhysicsSystem extends System {
|
|
12593
|
+
* update() { ... } // 自动被包装
|
|
12594
|
+
* calculate() { ... } // 自动被包装
|
|
12595
|
+
* }
|
|
12596
|
+
* ```
|
|
12597
|
+
*/
|
|
12598
|
+
declare function ProfileClass(category?: ProfileCategory): ClassDecorator;
|
|
11743
12599
|
|
|
11744
12600
|
/**
|
|
11745
12601
|
* 平台适配器接口
|
|
@@ -12014,5 +12870,5 @@ declare function getFullPlatformConfig(): Promise<any>;
|
|
|
12014
12870
|
declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
|
|
12015
12871
|
declare function hasAdapter(): boolean;
|
|
12016
12872
|
|
|
12017
|
-
export { BinarySerializer, BitMask64Utils, Bits, COMPONENT_DEPENDENCIES, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, DebugConfigService, DebugManager, DebugPlugin, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, IdentifierPool, IgnoreSerialization, IncrementalSerializer, InjectProperty, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, MigrationBuilder, NumberExtension, PROPERTY_METADATA, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PluginManager, PluginState, Pool, PoolManager, ProcessingSystem, Property, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, buildEntity, createECSAPI, createInstance, createLogger, createQuery, getBasicWorkerConfig, getComponentDependencies, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getFullPlatformConfig, getOrAddComponent, getPropertyInjectMetadata, getPropertyMetadata, getSceneByEntityId, getSerializationMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, hasAdapter, hasAnyComponent, hasComponents, hasEntityRef, hasPropertyMetadata, injectProperties, isComponentArray, isComponentType, isSerializable, isUpdatable, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, setLoggerFactory, supportsFeature, tryGetComponent, updateComponent };
|
|
12018
|
-
export type { AnyComponentConstructor, AssetType, BitMask64Data, ComponentChange, ComponentConstructor, ComponentDebugInfo, ComponentInstance, ComponentMigrationFunction, ComponentOptions, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, ECSDebugStats, EntityChange, EntityDebugInfo, EntityRefMetadata, EntityRefRecord, EntityWithComponents, EnumOption, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, LoggerColorConfig, LoggerConfig, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, PropertyAction, PropertyControl, PropertyOptions, PropertyType, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, SceneDataChange, SceneDebugInfo, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceIdentifier, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemDebugInfo, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|
|
12873
|
+
export { AdvancedProfilerCollector, AutoProfiler, BinarySerializer, BitMask64Utils, Bits, COMPONENT_DEPENDENCIES, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, DEFAULT_PROFILER_CONFIG, DebugConfigService, DebugManager, DebugPlugin, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EntityTags, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, HierarchyComponent, HierarchySystem, IdentifierPool, IgnoreSerialization, IncrementalSerializer, InjectProperty, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, MigrationBuilder, NumberExtension, PROPERTY_METADATA, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PluginManager, PluginState, Pool, PoolManager, ProcessingSystem, Profile, ProfileCategory, ProfileClass, ProfilerSDK, Property, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, addEntityTag, buildEntity, createECSAPI, createInstance, createLogger, createQuery, getBasicWorkerConfig, getComponentDependencies, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getFullPlatformConfig, getOrAddComponent, getPropertyInjectMetadata, getPropertyMetadata, getSceneByEntityId, getSerializationMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, hasAdapter, hasAnyComponent, hasComponents, hasEntityRef, hasEntityTag, hasPropertyMetadata, injectProperties, isComponentArray, isComponentType, isFolder, isHidden, isLocked, isSerializable, isUpdatable, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, removeEntityTag, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, setLoggerFactory, supportsFeature, tryGetComponent, updateComponent };
|
|
12874
|
+
export type { AnyComponentConstructor, AssetType, AutoProfilerConfig, BitMask64Data, CallGraphNode, ComponentChange, ComponentConstructor, ComponentDebugInfo, ComponentInstance, ComponentMigrationFunction, ComponentOptions, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, ECSDebugStats, EntityChange, EntityDebugInfo, EntityRefMetadata, EntityRefRecord, EntityTagValue, EntityWithComponents, EnumOption, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IAdvancedProfilerData, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, LoggerColorConfig, LoggerConfig, LongTaskInfo, MemorySnapshot, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, ProfileCounter, ProfileFrame, ProfileReport, ProfileSample, ProfileSampleStats, ProfilerConfig, PropertyAction, PropertyControl, PropertyOptions, PropertyType, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, SampleHandle, SceneDataChange, SceneDebugInfo, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceIdentifier, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemDebugInfo, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|