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