@esengine/ecs-framework 2.2.2 → 2.2.4
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 +2 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +583 -341
- 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.4
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -2517,7 +2517,7 @@ declare class PerformanceMonitor implements IService {
|
|
|
2517
2517
|
/**
|
|
2518
2518
|
* 查询条件类型
|
|
2519
2519
|
*/
|
|
2520
|
-
interface QueryCondition {
|
|
2520
|
+
interface QueryCondition$1 {
|
|
2521
2521
|
all: ComponentType[];
|
|
2522
2522
|
any: ComponentType[];
|
|
2523
2523
|
none: ComponentType[];
|
|
@@ -2636,7 +2636,7 @@ declare class Matcher {
|
|
|
2636
2636
|
/**
|
|
2637
2637
|
* 获取查询条件(只读)
|
|
2638
2638
|
*/
|
|
2639
|
-
getCondition(): Readonly<QueryCondition>;
|
|
2639
|
+
getCondition(): Readonly<QueryCondition$1>;
|
|
2640
2640
|
/**
|
|
2641
2641
|
* 检查是否为空条件
|
|
2642
2642
|
*/
|
|
@@ -2863,55 +2863,6 @@ declare class Bits {
|
|
|
2863
2863
|
getLowestBitIndex(): number;
|
|
2864
2864
|
}
|
|
2865
2865
|
|
|
2866
|
-
/**
|
|
2867
|
-
* 组件类型管理器
|
|
2868
|
-
* 负责管理组件类型的注册和ID分配
|
|
2869
|
-
* 支持无限数量的组件类型(通过自动扩展 BitMask)
|
|
2870
|
-
*/
|
|
2871
|
-
declare class ComponentTypeManager {
|
|
2872
|
-
private static _instance;
|
|
2873
|
-
private _componentTypes;
|
|
2874
|
-
private _typeNames;
|
|
2875
|
-
private _nextTypeId;
|
|
2876
|
-
/**
|
|
2877
|
-
* 获取单例实例
|
|
2878
|
-
*/
|
|
2879
|
-
static get instance(): ComponentTypeManager;
|
|
2880
|
-
private constructor();
|
|
2881
|
-
/**
|
|
2882
|
-
* 获取组件类型的ID
|
|
2883
|
-
* @param componentType 组件类型构造函数
|
|
2884
|
-
* @returns 组件类型ID
|
|
2885
|
-
*/
|
|
2886
|
-
getTypeId(componentType: ComponentType$1): number;
|
|
2887
|
-
/**
|
|
2888
|
-
* 获取组件类型名称
|
|
2889
|
-
* @param typeId 组件类型ID
|
|
2890
|
-
* @returns 组件类型名称
|
|
2891
|
-
*/
|
|
2892
|
-
getTypeName(typeId: number): string;
|
|
2893
|
-
/**
|
|
2894
|
-
* 创建包含指定组件类型的Bits对象
|
|
2895
|
-
* @param componentTypes 组件类型构造函数数组
|
|
2896
|
-
* @returns Bits对象
|
|
2897
|
-
*/
|
|
2898
|
-
createBits(...componentTypes: ComponentType$1[]): Bits;
|
|
2899
|
-
/**
|
|
2900
|
-
* 获取实体的组件位掩码
|
|
2901
|
-
* @param components 组件数组
|
|
2902
|
-
* @returns Bits对象
|
|
2903
|
-
*/
|
|
2904
|
-
getEntityBits(components: ComponentType$1[]): Bits;
|
|
2905
|
-
/**
|
|
2906
|
-
* 重置管理器(主要用于测试)
|
|
2907
|
-
*/
|
|
2908
|
-
reset(): void;
|
|
2909
|
-
/**
|
|
2910
|
-
* 获取已注册的组件类型数量
|
|
2911
|
-
*/
|
|
2912
|
-
get registeredTypeCount(): number;
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
2866
|
/**
|
|
2916
2867
|
* 稀疏集合实现
|
|
2917
2868
|
*
|
|
@@ -3238,6 +3189,25 @@ interface Archetype {
|
|
|
3238
3189
|
entities: Set<Entity>;
|
|
3239
3190
|
}
|
|
3240
3191
|
|
|
3192
|
+
/**
|
|
3193
|
+
* 查询条件类型
|
|
3194
|
+
*/
|
|
3195
|
+
declare enum QueryConditionType {
|
|
3196
|
+
/** 必须包含所有指定组件 */
|
|
3197
|
+
ALL = "all",
|
|
3198
|
+
/** 必须包含任意一个指定组件 */
|
|
3199
|
+
ANY = "any",
|
|
3200
|
+
/** 不能包含任何指定组件 */
|
|
3201
|
+
NONE = "none"
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* 查询条件接口
|
|
3205
|
+
*/
|
|
3206
|
+
interface QueryCondition {
|
|
3207
|
+
type: QueryConditionType;
|
|
3208
|
+
componentTypes: ComponentType[];
|
|
3209
|
+
mask: BitMask64Data;
|
|
3210
|
+
}
|
|
3241
3211
|
/**
|
|
3242
3212
|
* 实体查询结果接口
|
|
3243
3213
|
*/
|
|
@@ -3249,6 +3219,202 @@ interface QueryResult {
|
|
|
3249
3219
|
/** 是否来自缓存 */
|
|
3250
3220
|
fromCache: boolean;
|
|
3251
3221
|
}
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* 响应式查询变化类型
|
|
3225
|
+
*/
|
|
3226
|
+
declare enum ReactiveQueryChangeType {
|
|
3227
|
+
/** 实体添加到查询结果 */
|
|
3228
|
+
ADDED = "added",
|
|
3229
|
+
/** 实体从查询结果移除 */
|
|
3230
|
+
REMOVED = "removed",
|
|
3231
|
+
/** 查询结果批量更新 */
|
|
3232
|
+
BATCH_UPDATE = "batch_update"
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* 响应式查询变化事件
|
|
3236
|
+
*/
|
|
3237
|
+
interface ReactiveQueryChange {
|
|
3238
|
+
/** 变化类型 */
|
|
3239
|
+
type: ReactiveQueryChangeType;
|
|
3240
|
+
/** 变化的实体 */
|
|
3241
|
+
entity?: Entity;
|
|
3242
|
+
/** 批量变化的实体 */
|
|
3243
|
+
entities?: readonly Entity[];
|
|
3244
|
+
/** 新增的实体列表(仅batch_update时有效) */
|
|
3245
|
+
added?: readonly Entity[];
|
|
3246
|
+
/** 移除的实体列表(仅batch_update时有效) */
|
|
3247
|
+
removed?: readonly Entity[];
|
|
3248
|
+
}
|
|
3249
|
+
/**
|
|
3250
|
+
* 响应式查询监听器
|
|
3251
|
+
*/
|
|
3252
|
+
type ReactiveQueryListener = (change: ReactiveQueryChange) => void;
|
|
3253
|
+
/**
|
|
3254
|
+
* 响应式查询配置
|
|
3255
|
+
*/
|
|
3256
|
+
interface ReactiveQueryConfig {
|
|
3257
|
+
/** 是否启用批量模式(减少通知频率) */
|
|
3258
|
+
enableBatchMode?: boolean;
|
|
3259
|
+
/** 批量模式的延迟时间(毫秒) */
|
|
3260
|
+
batchDelay?: number;
|
|
3261
|
+
/** 调试模式 */
|
|
3262
|
+
debug?: boolean;
|
|
3263
|
+
}
|
|
3264
|
+
/**
|
|
3265
|
+
* 响应式查询类
|
|
3266
|
+
*
|
|
3267
|
+
* 提供基于事件驱动的实体查询机制,只在实体/组件真正变化时触发通知。
|
|
3268
|
+
*
|
|
3269
|
+
* 核心特性:
|
|
3270
|
+
* - Event-driven: 基于事件的增量更新
|
|
3271
|
+
* - 精确通知: 只通知真正匹配的变化
|
|
3272
|
+
* - 性能优化: 避免每帧重复查询
|
|
3273
|
+
*
|
|
3274
|
+
* @example
|
|
3275
|
+
* ```typescript
|
|
3276
|
+
* // 创建响应式查询
|
|
3277
|
+
* const query = new ReactiveQuery(querySystem, {
|
|
3278
|
+
* type: QueryConditionType.ALL,
|
|
3279
|
+
* componentTypes: [Position, Velocity],
|
|
3280
|
+
* mask: createMask([Position, Velocity])
|
|
3281
|
+
* });
|
|
3282
|
+
*
|
|
3283
|
+
* // 订阅变化
|
|
3284
|
+
* query.subscribe((change) => {
|
|
3285
|
+
* if (change.type === ReactiveQueryChangeType.ADDED) {
|
|
3286
|
+
* console.log('新实体:', change.entity);
|
|
3287
|
+
* }
|
|
3288
|
+
* });
|
|
3289
|
+
*
|
|
3290
|
+
* // 获取当前结果
|
|
3291
|
+
* const entities = query.getEntities();
|
|
3292
|
+
* ```
|
|
3293
|
+
*/
|
|
3294
|
+
declare class ReactiveQuery {
|
|
3295
|
+
/** 当前查询结果 */
|
|
3296
|
+
private _entities;
|
|
3297
|
+
/** 实体ID集合,用于快速查找 */
|
|
3298
|
+
private _entityIdSet;
|
|
3299
|
+
/** 查询条件 */
|
|
3300
|
+
private readonly _condition;
|
|
3301
|
+
/** 监听器列表 */
|
|
3302
|
+
private _listeners;
|
|
3303
|
+
/** 配置 */
|
|
3304
|
+
private readonly _config;
|
|
3305
|
+
/** 批量变化缓存 */
|
|
3306
|
+
private _batchChanges;
|
|
3307
|
+
/** 查询ID(用于调试) */
|
|
3308
|
+
private readonly _id;
|
|
3309
|
+
/** 是否已激活 */
|
|
3310
|
+
private _active;
|
|
3311
|
+
constructor(condition: QueryCondition, config?: ReactiveQueryConfig);
|
|
3312
|
+
/**
|
|
3313
|
+
* 生成查询ID
|
|
3314
|
+
*/
|
|
3315
|
+
private generateQueryId;
|
|
3316
|
+
/**
|
|
3317
|
+
* 订阅查询变化
|
|
3318
|
+
*
|
|
3319
|
+
* @param listener 监听器函数
|
|
3320
|
+
* @returns 取消订阅的函数
|
|
3321
|
+
*/
|
|
3322
|
+
subscribe(listener: ReactiveQueryListener): () => void;
|
|
3323
|
+
/**
|
|
3324
|
+
* 取消所有订阅
|
|
3325
|
+
*/
|
|
3326
|
+
unsubscribeAll(): void;
|
|
3327
|
+
/**
|
|
3328
|
+
* 获取当前查询结果
|
|
3329
|
+
*/
|
|
3330
|
+
getEntities(): readonly Entity[];
|
|
3331
|
+
/**
|
|
3332
|
+
* 获取查询结果数量
|
|
3333
|
+
*/
|
|
3334
|
+
get count(): number;
|
|
3335
|
+
/**
|
|
3336
|
+
* 检查实体是否匹配查询条件
|
|
3337
|
+
*
|
|
3338
|
+
* @param entity 要检查的实体
|
|
3339
|
+
* @returns 是否匹配
|
|
3340
|
+
*/
|
|
3341
|
+
matches(entity: Entity): boolean;
|
|
3342
|
+
/**
|
|
3343
|
+
* 通知实体添加
|
|
3344
|
+
*
|
|
3345
|
+
* 当Scene中添加实体时调用
|
|
3346
|
+
*
|
|
3347
|
+
* @param entity 添加的实体
|
|
3348
|
+
*/
|
|
3349
|
+
notifyEntityAdded(entity: Entity): void;
|
|
3350
|
+
/**
|
|
3351
|
+
* 通知实体移除
|
|
3352
|
+
*
|
|
3353
|
+
* 当Scene中移除实体时调用
|
|
3354
|
+
*
|
|
3355
|
+
* @param entity 移除的实体
|
|
3356
|
+
*/
|
|
3357
|
+
notifyEntityRemoved(entity: Entity): void;
|
|
3358
|
+
/**
|
|
3359
|
+
* 通知实体组件变化
|
|
3360
|
+
*
|
|
3361
|
+
* 当实体的组件发生变化时调用
|
|
3362
|
+
*
|
|
3363
|
+
* @param entity 变化的实体
|
|
3364
|
+
*/
|
|
3365
|
+
notifyEntityChanged(entity: Entity): void;
|
|
3366
|
+
/**
|
|
3367
|
+
* 批量初始化查询结果
|
|
3368
|
+
*
|
|
3369
|
+
* @param entities 初始实体列表
|
|
3370
|
+
*/
|
|
3371
|
+
initializeWith(entities: readonly Entity[]): void;
|
|
3372
|
+
/**
|
|
3373
|
+
* 添加到批量变化缓存
|
|
3374
|
+
*/
|
|
3375
|
+
private addToBatch;
|
|
3376
|
+
/**
|
|
3377
|
+
* 刷新批量变化
|
|
3378
|
+
*/
|
|
3379
|
+
private flushBatchChanges;
|
|
3380
|
+
/**
|
|
3381
|
+
* 通知所有监听器
|
|
3382
|
+
*/
|
|
3383
|
+
private notifyListeners;
|
|
3384
|
+
/**
|
|
3385
|
+
* 暂停响应式查询
|
|
3386
|
+
*
|
|
3387
|
+
* 暂停后不再响应实体变化,但可以继续获取当前结果
|
|
3388
|
+
*/
|
|
3389
|
+
pause(): void;
|
|
3390
|
+
/**
|
|
3391
|
+
* 恢复响应式查询
|
|
3392
|
+
*/
|
|
3393
|
+
resume(): void;
|
|
3394
|
+
/**
|
|
3395
|
+
* 销毁响应式查询
|
|
3396
|
+
*
|
|
3397
|
+
* 释放所有资源,清空监听器和结果集
|
|
3398
|
+
*/
|
|
3399
|
+
dispose(): void;
|
|
3400
|
+
/**
|
|
3401
|
+
* 获取查询条件
|
|
3402
|
+
*/
|
|
3403
|
+
get condition(): QueryCondition;
|
|
3404
|
+
/**
|
|
3405
|
+
* 获取查询ID
|
|
3406
|
+
*/
|
|
3407
|
+
get id(): string;
|
|
3408
|
+
/**
|
|
3409
|
+
* 检查是否激活
|
|
3410
|
+
*/
|
|
3411
|
+
get active(): boolean;
|
|
3412
|
+
/**
|
|
3413
|
+
* 获取监听器数量
|
|
3414
|
+
*/
|
|
3415
|
+
get listenerCount(): number;
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3252
3418
|
/**
|
|
3253
3419
|
* 高性能实体查询系统
|
|
3254
3420
|
*
|
|
@@ -3353,7 +3519,7 @@ declare class QuerySystem {
|
|
|
3353
3519
|
* 查询包含所有指定组件的实体
|
|
3354
3520
|
*
|
|
3355
3521
|
* 返回同时包含所有指定组件类型的实体列表。
|
|
3356
|
-
*
|
|
3522
|
+
* 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
|
|
3357
3523
|
*
|
|
3358
3524
|
* @param componentTypes 要查询的组件类型列表
|
|
3359
3525
|
* @returns 查询结果,包含匹配的实体和性能信息
|
|
@@ -3380,7 +3546,7 @@ declare class QuerySystem {
|
|
|
3380
3546
|
* 查询包含任意指定组件的实体
|
|
3381
3547
|
*
|
|
3382
3548
|
* 返回包含任意一个指定组件类型的实体列表。
|
|
3383
|
-
*
|
|
3549
|
+
* 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
|
|
3384
3550
|
*
|
|
3385
3551
|
* @param componentTypes 要查询的组件类型列表
|
|
3386
3552
|
* @returns 查询结果,包含匹配的实体和性能信息
|
|
@@ -3397,7 +3563,7 @@ declare class QuerySystem {
|
|
|
3397
3563
|
* 查询不包含任何指定组件的实体
|
|
3398
3564
|
*
|
|
3399
3565
|
* 返回不包含任何指定组件类型的实体列表。
|
|
3400
|
-
*
|
|
3566
|
+
* 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
|
|
3401
3567
|
*
|
|
3402
3568
|
* @param componentTypes 要排除的组件类型列表
|
|
3403
3569
|
* @returns 查询结果,包含匹配的实体和性能信息
|
|
@@ -3474,6 +3640,13 @@ declare class QuerySystem {
|
|
|
3474
3640
|
* 清除所有查询缓存
|
|
3475
3641
|
*/
|
|
3476
3642
|
private clearQueryCache;
|
|
3643
|
+
/**
|
|
3644
|
+
* 清除所有响应式查询
|
|
3645
|
+
*
|
|
3646
|
+
* 销毁所有响应式查询实例并清理索引
|
|
3647
|
+
* 通常在setEntities时调用以确保缓存一致性
|
|
3648
|
+
*/
|
|
3649
|
+
private clearReactiveQueries;
|
|
3477
3650
|
/**
|
|
3478
3651
|
* 高效的缓存键生成
|
|
3479
3652
|
*/
|
|
@@ -3482,13 +3655,56 @@ declare class QuerySystem {
|
|
|
3482
3655
|
* 清理查询缓存
|
|
3483
3656
|
*
|
|
3484
3657
|
* 用于外部调用清理缓存,通常在批量操作后使用。
|
|
3658
|
+
* 注意:此方法也会清理响应式查询缓存
|
|
3485
3659
|
*/
|
|
3486
3660
|
clearCache(): void;
|
|
3661
|
+
/**
|
|
3662
|
+
* 创建响应式查询
|
|
3663
|
+
*
|
|
3664
|
+
* 响应式查询会自动跟踪实体/组件的变化,并通过事件通知订阅者。
|
|
3665
|
+
* 适合需要实时响应实体变化的场景(如UI更新、AI系统等)。
|
|
3666
|
+
*
|
|
3667
|
+
* @param componentTypes 查询的组件类型列表
|
|
3668
|
+
* @param config 可选的查询配置
|
|
3669
|
+
* @returns 响应式查询实例
|
|
3670
|
+
*
|
|
3671
|
+
* @example
|
|
3672
|
+
* ```typescript
|
|
3673
|
+
* const query = querySystem.createReactiveQuery([Position, Velocity], {
|
|
3674
|
+
* enableBatchMode: true,
|
|
3675
|
+
* batchDelay: 16
|
|
3676
|
+
* });
|
|
3677
|
+
*
|
|
3678
|
+
* query.subscribe((change) => {
|
|
3679
|
+
* if (change.type === ReactiveQueryChangeType.ADDED) {
|
|
3680
|
+
* console.log('新实体:', change.entity);
|
|
3681
|
+
* }
|
|
3682
|
+
* });
|
|
3683
|
+
* ```
|
|
3684
|
+
*/
|
|
3685
|
+
createReactiveQuery(componentTypes: ComponentType[], config?: ReactiveQueryConfig): ReactiveQuery;
|
|
3686
|
+
/**
|
|
3687
|
+
* 销毁响应式查询
|
|
3688
|
+
*
|
|
3689
|
+
* 清理查询占用的资源,包括监听器和实体引用。
|
|
3690
|
+
* 销毁后的查询不应再被使用。
|
|
3691
|
+
*
|
|
3692
|
+
* @param query 要销毁的响应式查询
|
|
3693
|
+
*
|
|
3694
|
+
* @example
|
|
3695
|
+
* ```typescript
|
|
3696
|
+
* const query = querySystem.createReactiveQuery([Position, Velocity]);
|
|
3697
|
+
* // ... 使用查询
|
|
3698
|
+
* querySystem.destroyReactiveQuery(query);
|
|
3699
|
+
* ```
|
|
3700
|
+
*/
|
|
3701
|
+
destroyReactiveQuery(query: ReactiveQuery): void;
|
|
3487
3702
|
/**
|
|
3488
3703
|
* 创建组件掩码
|
|
3489
3704
|
*
|
|
3490
3705
|
* 根据组件类型列表生成对应的位掩码。
|
|
3491
3706
|
* 使用缓存避免重复计算。
|
|
3707
|
+
* 注意:必须使用ComponentRegistry来确保与Entity.componentMask使用相同的bitIndex
|
|
3492
3708
|
*
|
|
3493
3709
|
* @param componentTypes 组件类型列表
|
|
3494
3710
|
* @returns 生成的位掩码
|
|
@@ -3540,6 +3756,67 @@ declare class QuerySystem {
|
|
|
3540
3756
|
* @param entity 要查询的实体
|
|
3541
3757
|
*/
|
|
3542
3758
|
getEntityArchetype(entity: Entity): Archetype | undefined;
|
|
3759
|
+
/**
|
|
3760
|
+
* 响应式查询集合(内部使用,作为智能缓存)
|
|
3761
|
+
* 传统查询API(queryAll/queryAny/queryNone)内部自动使用响应式查询优化性能
|
|
3762
|
+
*/
|
|
3763
|
+
private _reactiveQueries;
|
|
3764
|
+
/**
|
|
3765
|
+
* 按组件类型索引的响应式查询
|
|
3766
|
+
* 用于快速定位哪些查询关心某个组件类型
|
|
3767
|
+
*/
|
|
3768
|
+
private _reactiveQueriesByComponent;
|
|
3769
|
+
/**
|
|
3770
|
+
* 获取或创建内部响应式查询(作为智能缓存)
|
|
3771
|
+
*
|
|
3772
|
+
* @param queryType 查询类型
|
|
3773
|
+
* @param componentTypes 组件类型列表
|
|
3774
|
+
* @returns 响应式查询实例
|
|
3775
|
+
*/
|
|
3776
|
+
private getOrCreateReactiveQuery;
|
|
3777
|
+
/**
|
|
3778
|
+
* 执行传统查询(内部使用,用于响应式查询初始化)
|
|
3779
|
+
*
|
|
3780
|
+
* @param queryType 查询类型
|
|
3781
|
+
* @param componentTypes 组件类型列表
|
|
3782
|
+
* @returns 匹配的实体列表
|
|
3783
|
+
*/
|
|
3784
|
+
private executeTraditionalQuery;
|
|
3785
|
+
/**
|
|
3786
|
+
* 通知所有响应式查询实体已添加
|
|
3787
|
+
*
|
|
3788
|
+
* 使用组件类型索引,只通知关心该实体组件的查询
|
|
3789
|
+
*
|
|
3790
|
+
* @param entity 添加的实体
|
|
3791
|
+
*/
|
|
3792
|
+
private notifyReactiveQueriesEntityAdded;
|
|
3793
|
+
/**
|
|
3794
|
+
* 通知响应式查询实体已移除
|
|
3795
|
+
*
|
|
3796
|
+
* 使用组件类型索引,只通知关心该实体组件的查询
|
|
3797
|
+
*
|
|
3798
|
+
* @param entity 移除的实体
|
|
3799
|
+
* @param componentTypes 实体移除前的组件类型列表
|
|
3800
|
+
*/
|
|
3801
|
+
private notifyReactiveQueriesEntityRemoved;
|
|
3802
|
+
/**
|
|
3803
|
+
* 通知响应式查询实体已移除(后备方案)
|
|
3804
|
+
*
|
|
3805
|
+
* 当实体已经清空组件时使用,通知所有查询
|
|
3806
|
+
*
|
|
3807
|
+
* @param entity 移除的实体
|
|
3808
|
+
*/
|
|
3809
|
+
private notifyReactiveQueriesEntityRemovedFallback;
|
|
3810
|
+
/**
|
|
3811
|
+
* 通知响应式查询实体已变化
|
|
3812
|
+
*
|
|
3813
|
+
* 使用混合策略:
|
|
3814
|
+
* 1. 首先通知关心实体当前组件的查询
|
|
3815
|
+
* 2. 然后通知所有其他查询(包括那些可能因为组件移除而不再匹配的查询)
|
|
3816
|
+
*
|
|
3817
|
+
* @param entity 变化的实体
|
|
3818
|
+
*/
|
|
3819
|
+
private notifyReactiveQueriesEntityChanged;
|
|
3543
3820
|
}
|
|
3544
3821
|
/**
|
|
3545
3822
|
* 查询构建器
|
|
@@ -4100,7 +4377,7 @@ declare class TypedQueryBuilder<TAll extends readonly ComponentConstructor[] = [
|
|
|
4100
4377
|
*
|
|
4101
4378
|
* @returns 查询条件对象
|
|
4102
4379
|
*/
|
|
4103
|
-
getCondition(): QueryCondition;
|
|
4380
|
+
getCondition(): QueryCondition$1;
|
|
4104
4381
|
/**
|
|
4105
4382
|
* 获取required组件类型(用于类型推断)
|
|
4106
4383
|
*/
|
|
@@ -5082,7 +5359,7 @@ declare class Scene implements IScene {
|
|
|
5082
5359
|
* @Injectable()
|
|
5083
5360
|
* class PhysicsSystem extends EntitySystem {
|
|
5084
5361
|
* constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
|
|
5085
|
-
* super(Matcher.
|
|
5362
|
+
* super(Matcher.empty().all(Transform));
|
|
5086
5363
|
* }
|
|
5087
5364
|
* }
|
|
5088
5365
|
* scene.addEntityProcessor(PhysicsSystem);
|
|
@@ -5107,7 +5384,7 @@ declare class Scene implements IScene {
|
|
|
5107
5384
|
* @Injectable()
|
|
5108
5385
|
* @ECSSystem('Collision', { updateOrder: 5 })
|
|
5109
5386
|
* class CollisionSystem extends EntitySystem implements IService {
|
|
5110
|
-
* constructor() { super(Matcher.
|
|
5387
|
+
* constructor() { super(Matcher.empty().all(Collider)); }
|
|
5111
5388
|
* dispose() {}
|
|
5112
5389
|
* }
|
|
5113
5390
|
*
|
|
@@ -5115,7 +5392,7 @@ declare class Scene implements IScene {
|
|
|
5115
5392
|
* @ECSSystem('Physics', { updateOrder: 10 })
|
|
5116
5393
|
* class PhysicsSystem extends EntitySystem implements IService {
|
|
5117
5394
|
* constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
|
|
5118
|
-
* super(Matcher.
|
|
5395
|
+
* super(Matcher.empty().all(Transform, RigidBody));
|
|
5119
5396
|
* }
|
|
5120
5397
|
* dispose() {}
|
|
5121
5398
|
* }
|
|
@@ -5358,7 +5635,7 @@ declare class Scene implements IScene {
|
|
|
5358
5635
|
* // 传统方式
|
|
5359
5636
|
* class MovementSystem extends EntitySystem {
|
|
5360
5637
|
* constructor() {
|
|
5361
|
-
* super(Matcher.
|
|
5638
|
+
* super(Matcher.empty().all(Transform, Velocity));
|
|
5362
5639
|
* }
|
|
5363
5640
|
*
|
|
5364
5641
|
* protected process(entities: readonly Entity[]): void {
|
|
@@ -5373,7 +5650,7 @@ declare class Scene implements IScene {
|
|
|
5373
5650
|
* // 类型安全方式
|
|
5374
5651
|
* class MovementSystem extends EntitySystem<[typeof Transform, typeof Velocity]> {
|
|
5375
5652
|
* constructor() {
|
|
5376
|
-
* super(Matcher.
|
|
5653
|
+
* super(Matcher.empty().all(Transform, Velocity));
|
|
5377
5654
|
* }
|
|
5378
5655
|
*
|
|
5379
5656
|
* protected process(entities: readonly Entity[]): void {
|
|
@@ -6974,7 +7251,7 @@ interface SystemMetadata {
|
|
|
6974
7251
|
* @ECSSystem('Physics', { updateOrder: 10 })
|
|
6975
7252
|
* class PhysicsSystem extends EntitySystem {
|
|
6976
7253
|
* constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
|
|
6977
|
-
* super(Matcher.
|
|
7254
|
+
* super(Matcher.empty().all(Transform, RigidBody));
|
|
6978
7255
|
* }
|
|
6979
7256
|
* }
|
|
6980
7257
|
* ```
|
|
@@ -7418,51 +7695,229 @@ declare class ECSFluentAPI {
|
|
|
7418
7695
|
declare function createECSAPI(scene: IScene, querySystem: QuerySystem, eventSystem: TypeSafeEventSystem): ECSFluentAPI;
|
|
7419
7696
|
|
|
7420
7697
|
/**
|
|
7421
|
-
*
|
|
7422
|
-
*
|
|
7698
|
+
* 单场景管理器
|
|
7699
|
+
*
|
|
7700
|
+
* 适用场景:
|
|
7701
|
+
* - 单人游戏
|
|
7702
|
+
* - 简单场景切换
|
|
7703
|
+
* - 不需要多World隔离的项目
|
|
7704
|
+
*
|
|
7705
|
+
* 特点:
|
|
7706
|
+
* - 轻量级,零额外开销
|
|
7707
|
+
* - 简单直观的API
|
|
7708
|
+
* - 支持延迟场景切换
|
|
7709
|
+
* - 自动管理ECS API
|
|
7710
|
+
*
|
|
7711
|
+
* @example
|
|
7712
|
+
* ```typescript
|
|
7713
|
+
* // 初始化Core
|
|
7714
|
+
* Core.create({ debug: true });
|
|
7715
|
+
*
|
|
7716
|
+
* // 创建场景管理器
|
|
7717
|
+
* const sceneManager = new SceneManager();
|
|
7718
|
+
*
|
|
7719
|
+
* // 设置场景
|
|
7720
|
+
* class GameScene extends Scene {
|
|
7721
|
+
* initialize() {
|
|
7722
|
+
* const player = this.createEntity('Player');
|
|
7723
|
+
* player.addComponent(new Transform(100, 100));
|
|
7724
|
+
* }
|
|
7725
|
+
* }
|
|
7726
|
+
*
|
|
7727
|
+
* sceneManager.setScene(new GameScene());
|
|
7728
|
+
*
|
|
7729
|
+
* // 游戏循环
|
|
7730
|
+
* function gameLoop(deltaTime: number) {
|
|
7731
|
+
* Core.update(deltaTime); // 更新全局服务
|
|
7732
|
+
* sceneManager.update(); // 更新场景
|
|
7733
|
+
* }
|
|
7734
|
+
*
|
|
7735
|
+
* // 延迟切换场景(下一帧生效)
|
|
7736
|
+
* sceneManager.loadScene(new MenuScene());
|
|
7737
|
+
* ```
|
|
7423
7738
|
*/
|
|
7424
|
-
|
|
7425
|
-
/**
|
|
7426
|
-
* 系统名称
|
|
7427
|
-
*/
|
|
7428
|
-
readonly name: string;
|
|
7739
|
+
declare class SceneManager implements IService {
|
|
7429
7740
|
/**
|
|
7430
|
-
*
|
|
7741
|
+
* 内部默认World
|
|
7431
7742
|
*/
|
|
7432
|
-
|
|
7743
|
+
private _defaultWorld;
|
|
7433
7744
|
/**
|
|
7434
|
-
*
|
|
7745
|
+
* 待切换的下一个场景(延迟切换用)
|
|
7435
7746
|
*/
|
|
7436
|
-
|
|
7747
|
+
private _nextScene;
|
|
7437
7748
|
/**
|
|
7438
|
-
*
|
|
7749
|
+
* ECS流式API
|
|
7439
7750
|
*/
|
|
7440
|
-
|
|
7751
|
+
private _ecsAPI;
|
|
7441
7752
|
/**
|
|
7442
|
-
*
|
|
7753
|
+
* 日志器
|
|
7443
7754
|
*/
|
|
7444
|
-
|
|
7445
|
-
}
|
|
7446
|
-
/**
|
|
7447
|
-
* World配置接口
|
|
7448
|
-
*/
|
|
7449
|
-
interface IWorldConfig {
|
|
7755
|
+
private _logger;
|
|
7450
7756
|
/**
|
|
7451
|
-
*
|
|
7757
|
+
* 场景切换回调函数
|
|
7452
7758
|
*/
|
|
7453
|
-
|
|
7759
|
+
private _onSceneChangedCallback?;
|
|
7454
7760
|
/**
|
|
7455
|
-
*
|
|
7761
|
+
* 默认场景ID
|
|
7456
7762
|
*/
|
|
7457
|
-
|
|
7763
|
+
private static readonly DEFAULT_SCENE_ID;
|
|
7764
|
+
constructor();
|
|
7458
7765
|
/**
|
|
7459
|
-
*
|
|
7766
|
+
* 设置场景切换回调
|
|
7767
|
+
*
|
|
7768
|
+
* @param callback 场景切换时的回调函数
|
|
7769
|
+
* @internal
|
|
7460
7770
|
*/
|
|
7461
|
-
|
|
7771
|
+
setSceneChangedCallback(callback: () => void): void;
|
|
7462
7772
|
/**
|
|
7463
|
-
*
|
|
7464
|
-
|
|
7465
|
-
|
|
7773
|
+
* 设置当前场景(立即切换)
|
|
7774
|
+
*
|
|
7775
|
+
* 会自动处理旧场景的结束和新场景的初始化。
|
|
7776
|
+
*
|
|
7777
|
+
* @param scene - 要设置的场景实例
|
|
7778
|
+
* @returns 返回设置的场景实例,便于链式调用
|
|
7779
|
+
*
|
|
7780
|
+
* @example
|
|
7781
|
+
* ```typescript
|
|
7782
|
+
* const gameScene = sceneManager.setScene(new GameScene());
|
|
7783
|
+
* console.log(gameScene.name); // 可以立即使用返回的场景
|
|
7784
|
+
* ```
|
|
7785
|
+
*/
|
|
7786
|
+
setScene<T extends IScene>(scene: T): T;
|
|
7787
|
+
/**
|
|
7788
|
+
* 延迟加载场景(下一帧切换)
|
|
7789
|
+
*
|
|
7790
|
+
* 场景不会立即切换,而是在下一次调用 update() 时切换。
|
|
7791
|
+
* 这对于避免在当前帧的中途切换场景很有用。
|
|
7792
|
+
*
|
|
7793
|
+
* @param scene - 要加载的场景实例
|
|
7794
|
+
*
|
|
7795
|
+
* @example
|
|
7796
|
+
* ```typescript
|
|
7797
|
+
* // 在某个System中触发场景切换
|
|
7798
|
+
* class GameOverSystem extends EntitySystem {
|
|
7799
|
+
* process(entities: readonly Entity[]) {
|
|
7800
|
+
* if (playerHealth <= 0) {
|
|
7801
|
+
* sceneManager.loadScene(new GameOverScene());
|
|
7802
|
+
* // 当前帧继续执行,场景将在下一帧切换
|
|
7803
|
+
* }
|
|
7804
|
+
* }
|
|
7805
|
+
* }
|
|
7806
|
+
* ```
|
|
7807
|
+
*/
|
|
7808
|
+
loadScene<T extends IScene>(scene: T): void;
|
|
7809
|
+
/**
|
|
7810
|
+
* 获取当前活跃的场景
|
|
7811
|
+
*
|
|
7812
|
+
* @returns 当前场景实例,如果没有场景则返回null
|
|
7813
|
+
*/
|
|
7814
|
+
get currentScene(): IScene | null;
|
|
7815
|
+
/**
|
|
7816
|
+
* 获取ECS流式API
|
|
7817
|
+
*
|
|
7818
|
+
* 提供便捷的实体查询、事件发射等功能。
|
|
7819
|
+
*
|
|
7820
|
+
* @returns ECS API实例,如果当前没有场景则返回null
|
|
7821
|
+
*
|
|
7822
|
+
* @example
|
|
7823
|
+
* ```typescript
|
|
7824
|
+
* const api = sceneManager.api;
|
|
7825
|
+
* if (api) {
|
|
7826
|
+
* // 查询所有敌人
|
|
7827
|
+
* const enemies = api.find(Enemy, Transform);
|
|
7828
|
+
*
|
|
7829
|
+
* // 发射事件
|
|
7830
|
+
* api.emit('game:start', { level: 1 });
|
|
7831
|
+
* }
|
|
7832
|
+
* ```
|
|
7833
|
+
*/
|
|
7834
|
+
get api(): ECSFluentAPI | null;
|
|
7835
|
+
/**
|
|
7836
|
+
* 更新场景
|
|
7837
|
+
*
|
|
7838
|
+
* 应该在每帧的游戏循环中调用。
|
|
7839
|
+
* 会自动处理延迟场景切换。
|
|
7840
|
+
*
|
|
7841
|
+
* @example
|
|
7842
|
+
* ```typescript
|
|
7843
|
+
* function gameLoop(deltaTime: number) {
|
|
7844
|
+
* Core.update(deltaTime);
|
|
7845
|
+
* sceneManager.update(); // 每帧调用
|
|
7846
|
+
* }
|
|
7847
|
+
* ```
|
|
7848
|
+
*/
|
|
7849
|
+
update(): void;
|
|
7850
|
+
/**
|
|
7851
|
+
* 销毁场景管理器
|
|
7852
|
+
*
|
|
7853
|
+
* 会自动结束当前场景并清理所有资源。
|
|
7854
|
+
* 通常在应用程序关闭时调用。
|
|
7855
|
+
*/
|
|
7856
|
+
destroy(): void;
|
|
7857
|
+
/**
|
|
7858
|
+
* 检查是否有活跃场景
|
|
7859
|
+
*
|
|
7860
|
+
* @returns 如果有活跃场景返回true,否则返回false
|
|
7861
|
+
*/
|
|
7862
|
+
get hasScene(): boolean;
|
|
7863
|
+
/**
|
|
7864
|
+
* 检查是否有待切换的场景
|
|
7865
|
+
*
|
|
7866
|
+
* @returns 如果有待切换场景返回true,否则返回false
|
|
7867
|
+
*/
|
|
7868
|
+
get hasPendingScene(): boolean;
|
|
7869
|
+
/**
|
|
7870
|
+
* 释放资源(IService接口)
|
|
7871
|
+
*/
|
|
7872
|
+
dispose(): void;
|
|
7873
|
+
}
|
|
7874
|
+
|
|
7875
|
+
/**
|
|
7876
|
+
* 全局系统接口
|
|
7877
|
+
* 全局系统是在World级别运行的系统,不依赖特定Scene
|
|
7878
|
+
*/
|
|
7879
|
+
interface IGlobalSystem {
|
|
7880
|
+
/**
|
|
7881
|
+
* 系统名称
|
|
7882
|
+
*/
|
|
7883
|
+
readonly name: string;
|
|
7884
|
+
/**
|
|
7885
|
+
* 初始化系统
|
|
7886
|
+
*/
|
|
7887
|
+
initialize?(): void;
|
|
7888
|
+
/**
|
|
7889
|
+
* 更新系统
|
|
7890
|
+
*/
|
|
7891
|
+
update(deltaTime?: number): void;
|
|
7892
|
+
/**
|
|
7893
|
+
* 重置系统
|
|
7894
|
+
*/
|
|
7895
|
+
reset?(): void;
|
|
7896
|
+
/**
|
|
7897
|
+
* 销毁系统
|
|
7898
|
+
*/
|
|
7899
|
+
destroy?(): void;
|
|
7900
|
+
}
|
|
7901
|
+
/**
|
|
7902
|
+
* World配置接口
|
|
7903
|
+
*/
|
|
7904
|
+
interface IWorldConfig {
|
|
7905
|
+
/**
|
|
7906
|
+
* World名称
|
|
7907
|
+
*/
|
|
7908
|
+
name?: string;
|
|
7909
|
+
/**
|
|
7910
|
+
* 是否启用调试模式
|
|
7911
|
+
*/
|
|
7912
|
+
debug?: boolean;
|
|
7913
|
+
/**
|
|
7914
|
+
* 最大Scene数量限制
|
|
7915
|
+
*/
|
|
7916
|
+
maxScenes?: number;
|
|
7917
|
+
/**
|
|
7918
|
+
* 是否自动清理空Scene
|
|
7919
|
+
*/
|
|
7920
|
+
autoCleanup?: boolean;
|
|
7466
7921
|
}
|
|
7467
7922
|
/**
|
|
7468
7923
|
* World类 - ECS世界管理器
|
|
@@ -7654,12 +8109,6 @@ interface IWorldManagerConfig {
|
|
|
7654
8109
|
* 是否启用调试模式
|
|
7655
8110
|
*/
|
|
7656
8111
|
debug?: boolean;
|
|
7657
|
-
/**
|
|
7658
|
-
* 是否创建默认World(默认true)
|
|
7659
|
-
*
|
|
7660
|
-
* 当通过Core使用时应该为true,直接使用WorldManager时可设为false
|
|
7661
|
-
*/
|
|
7662
|
-
createDefaultWorld?: boolean;
|
|
7663
8112
|
}
|
|
7664
8113
|
/**
|
|
7665
8114
|
* World管理器 - 管理所有World实例
|
|
@@ -7689,38 +8138,24 @@ interface IWorldManagerConfig {
|
|
|
7689
8138
|
*
|
|
7690
8139
|
* // 游戏循环
|
|
7691
8140
|
* function gameLoop(deltaTime: number) {
|
|
7692
|
-
* Core.update(deltaTime);
|
|
8141
|
+
* Core.update(deltaTime);
|
|
8142
|
+
* worldManager.updateAll(); // 更新所有活跃World
|
|
7693
8143
|
* }
|
|
7694
8144
|
* ```
|
|
7695
8145
|
*/
|
|
7696
|
-
declare class WorldManager implements IService
|
|
7697
|
-
/**
|
|
7698
|
-
* 默认World的ID
|
|
7699
|
-
*/
|
|
7700
|
-
static readonly DEFAULT_WORLD_ID = "__default__";
|
|
8146
|
+
declare class WorldManager implements IService {
|
|
7701
8147
|
private readonly _config;
|
|
7702
8148
|
private readonly _worlds;
|
|
7703
8149
|
private readonly _activeWorlds;
|
|
7704
8150
|
private _cleanupTimer;
|
|
7705
8151
|
private _isRunning;
|
|
7706
8152
|
constructor(config?: IWorldManagerConfig);
|
|
7707
|
-
/**
|
|
7708
|
-
* 获取默认World
|
|
7709
|
-
*
|
|
7710
|
-
* 默认World由WorldManager自动创建,供SceneManager使用。
|
|
7711
|
-
* 此方法主要供SceneManager内部使用。
|
|
7712
|
-
*
|
|
7713
|
-
* @returns 默认World实例
|
|
7714
|
-
*/
|
|
7715
|
-
getDefaultWorld(): World;
|
|
7716
8153
|
/**
|
|
7717
8154
|
* 创建新World
|
|
7718
8155
|
*/
|
|
7719
8156
|
createWorld(worldId: string, config?: IWorldConfig): World;
|
|
7720
8157
|
/**
|
|
7721
8158
|
* 移除World
|
|
7722
|
-
*
|
|
7723
|
-
* 注意:默认World不能被删除
|
|
7724
8159
|
*/
|
|
7725
8160
|
removeWorld(worldId: string): boolean;
|
|
7726
8161
|
/**
|
|
@@ -7746,12 +8181,18 @@ declare class WorldManager implements IService, IUpdatable {
|
|
|
7746
8181
|
/**
|
|
7747
8182
|
* 更新所有活跃的World
|
|
7748
8183
|
*
|
|
7749
|
-
*
|
|
8184
|
+
* 应该在每帧的游戏循环中调用。
|
|
7750
8185
|
* 会自动更新所有活跃World的全局系统和场景。
|
|
7751
8186
|
*
|
|
7752
|
-
* @
|
|
8187
|
+
* @example
|
|
8188
|
+
* ```typescript
|
|
8189
|
+
* function gameLoop(deltaTime: number) {
|
|
8190
|
+
* Core.update(deltaTime); // 更新全局服务
|
|
8191
|
+
* worldManager.updateAll(); // 更新所有World
|
|
8192
|
+
* }
|
|
8193
|
+
* ```
|
|
7753
8194
|
*/
|
|
7754
|
-
|
|
8195
|
+
updateAll(): void;
|
|
7755
8196
|
/**
|
|
7756
8197
|
* 获取所有激活的World
|
|
7757
8198
|
*/
|
|
@@ -7800,12 +8241,6 @@ declare class WorldManager implements IService, IUpdatable {
|
|
|
7800
8241
|
* 是否启用调试模式
|
|
7801
8242
|
*/
|
|
7802
8243
|
debug?: boolean;
|
|
7803
|
-
/**
|
|
7804
|
-
* 是否创建默认World(默认true)
|
|
7805
|
-
*
|
|
7806
|
-
* 当通过Core使用时应该为true,直接使用WorldManager时可设为false
|
|
7807
|
-
*/
|
|
7808
|
-
createDefaultWorld?: boolean;
|
|
7809
8244
|
};
|
|
7810
8245
|
worlds: any[];
|
|
7811
8246
|
};
|
|
@@ -7860,12 +8295,6 @@ declare class WorldManager implements IService, IUpdatable {
|
|
|
7860
8295
|
* 是否启用调试模式
|
|
7861
8296
|
*/
|
|
7862
8297
|
debug?: boolean;
|
|
7863
|
-
/**
|
|
7864
|
-
* 是否创建默认World(默认true)
|
|
7865
|
-
*
|
|
7866
|
-
* 当通过Core使用时应该为true,直接使用WorldManager时可设为false
|
|
7867
|
-
*/
|
|
7868
|
-
createDefaultWorld?: boolean;
|
|
7869
8298
|
};
|
|
7870
8299
|
};
|
|
7871
8300
|
/**
|
|
@@ -7911,188 +8340,6 @@ declare class WorldManager implements IService, IUpdatable {
|
|
|
7911
8340
|
get config(): IWorldManagerConfig;
|
|
7912
8341
|
}
|
|
7913
8342
|
|
|
7914
|
-
/**
|
|
7915
|
-
* 单场景管理器
|
|
7916
|
-
*
|
|
7917
|
-
* 适用场景:
|
|
7918
|
-
* - 单人游戏
|
|
7919
|
-
* - 简单场景切换
|
|
7920
|
-
* - 不需要多World隔离的项目
|
|
7921
|
-
*
|
|
7922
|
-
* 特点:
|
|
7923
|
-
* - 轻量级,零额外开销
|
|
7924
|
-
* - 简单直观的API
|
|
7925
|
-
* - 支持延迟场景切换
|
|
7926
|
-
* - 自动管理ECS API
|
|
7927
|
-
* - 通过依赖注入获取WorldManager的默认World
|
|
7928
|
-
*
|
|
7929
|
-
* @example
|
|
7930
|
-
* ```typescript
|
|
7931
|
-
* // 初始化Core
|
|
7932
|
-
* Core.create({ debug: true });
|
|
7933
|
-
*
|
|
7934
|
-
* // 设置场景
|
|
7935
|
-
* class GameScene extends Scene {
|
|
7936
|
-
* initialize() {
|
|
7937
|
-
* const player = this.createEntity('Player');
|
|
7938
|
-
* player.addComponent(new Transform(100, 100));
|
|
7939
|
-
* }
|
|
7940
|
-
* }
|
|
7941
|
-
*
|
|
7942
|
-
* Core.setScene(new GameScene());
|
|
7943
|
-
*
|
|
7944
|
-
* // 游戏循环
|
|
7945
|
-
* function gameLoop(deltaTime: number) {
|
|
7946
|
-
* Core.update(deltaTime); // 自动更新所有服务(包括SceneManager)
|
|
7947
|
-
* }
|
|
7948
|
-
*
|
|
7949
|
-
* // 延迟切换场景(下一帧生效)
|
|
7950
|
-
* Core.loadScene(new MenuScene());
|
|
7951
|
-
* ```
|
|
7952
|
-
*/
|
|
7953
|
-
declare class SceneManager implements IService, IUpdatable {
|
|
7954
|
-
/**
|
|
7955
|
-
* 内部默认World(从WorldManager获取)
|
|
7956
|
-
*/
|
|
7957
|
-
private _defaultWorld;
|
|
7958
|
-
/**
|
|
7959
|
-
* 待切换的下一个场景(延迟切换用)
|
|
7960
|
-
*/
|
|
7961
|
-
private _nextScene;
|
|
7962
|
-
/**
|
|
7963
|
-
* ECS流式API
|
|
7964
|
-
*/
|
|
7965
|
-
private _ecsAPI;
|
|
7966
|
-
/**
|
|
7967
|
-
* 日志器
|
|
7968
|
-
*/
|
|
7969
|
-
private _logger;
|
|
7970
|
-
/**
|
|
7971
|
-
* 场景切换回调函数
|
|
7972
|
-
*/
|
|
7973
|
-
private _onSceneChangedCallback?;
|
|
7974
|
-
/**
|
|
7975
|
-
* 默认场景ID
|
|
7976
|
-
*/
|
|
7977
|
-
private static readonly DEFAULT_SCENE_ID;
|
|
7978
|
-
/**
|
|
7979
|
-
* 构造函数
|
|
7980
|
-
*
|
|
7981
|
-
* WorldManager通过依赖注入自动传入
|
|
7982
|
-
*
|
|
7983
|
-
* @param worldManager WorldManager实例,用于获取默认World
|
|
7984
|
-
*/
|
|
7985
|
-
constructor(worldManager: WorldManager);
|
|
7986
|
-
/**
|
|
7987
|
-
* 设置场景切换回调
|
|
7988
|
-
*
|
|
7989
|
-
* @param callback 场景切换时的回调函数
|
|
7990
|
-
* @internal
|
|
7991
|
-
*/
|
|
7992
|
-
setSceneChangedCallback(callback: () => void): void;
|
|
7993
|
-
/**
|
|
7994
|
-
* 设置当前场景(立即切换)
|
|
7995
|
-
*
|
|
7996
|
-
* 会自动处理旧场景的结束和新场景的初始化。
|
|
7997
|
-
*
|
|
7998
|
-
* @param scene - 要设置的场景实例
|
|
7999
|
-
* @returns 返回设置的场景实例,便于链式调用
|
|
8000
|
-
*
|
|
8001
|
-
* @example
|
|
8002
|
-
* ```typescript
|
|
8003
|
-
* const gameScene = sceneManager.setScene(new GameScene());
|
|
8004
|
-
* console.log(gameScene.name); // 可以立即使用返回的场景
|
|
8005
|
-
* ```
|
|
8006
|
-
*/
|
|
8007
|
-
setScene<T extends IScene>(scene: T): T;
|
|
8008
|
-
/**
|
|
8009
|
-
* 延迟加载场景(下一帧切换)
|
|
8010
|
-
*
|
|
8011
|
-
* 场景不会立即切换,而是在下一次调用 update() 时切换。
|
|
8012
|
-
* 这对于避免在当前帧的中途切换场景很有用。
|
|
8013
|
-
*
|
|
8014
|
-
* @param scene - 要加载的场景实例
|
|
8015
|
-
*
|
|
8016
|
-
* @example
|
|
8017
|
-
* ```typescript
|
|
8018
|
-
* // 在某个System中触发场景切换
|
|
8019
|
-
* class GameOverSystem extends EntitySystem {
|
|
8020
|
-
* process(entities: readonly Entity[]) {
|
|
8021
|
-
* if (playerHealth <= 0) {
|
|
8022
|
-
* sceneManager.loadScene(new GameOverScene());
|
|
8023
|
-
* // 当前帧继续执行,场景将在下一帧切换
|
|
8024
|
-
* }
|
|
8025
|
-
* }
|
|
8026
|
-
* }
|
|
8027
|
-
* ```
|
|
8028
|
-
*/
|
|
8029
|
-
loadScene<T extends IScene>(scene: T): void;
|
|
8030
|
-
/**
|
|
8031
|
-
* 获取当前活跃的场景
|
|
8032
|
-
*
|
|
8033
|
-
* @returns 当前场景实例,如果没有场景则返回null
|
|
8034
|
-
*/
|
|
8035
|
-
get currentScene(): IScene | null;
|
|
8036
|
-
/**
|
|
8037
|
-
* 获取ECS流式API
|
|
8038
|
-
*
|
|
8039
|
-
* 提供便捷的实体查询、事件发射等功能。
|
|
8040
|
-
*
|
|
8041
|
-
* @returns ECS API实例,如果当前没有场景则返回null
|
|
8042
|
-
*
|
|
8043
|
-
* @example
|
|
8044
|
-
* ```typescript
|
|
8045
|
-
* const api = sceneManager.api;
|
|
8046
|
-
* if (api) {
|
|
8047
|
-
* // 查询所有敌人
|
|
8048
|
-
* const enemies = api.find(Enemy, Transform);
|
|
8049
|
-
*
|
|
8050
|
-
* // 发射事件
|
|
8051
|
-
* api.emit('game:start', { level: 1 });
|
|
8052
|
-
* }
|
|
8053
|
-
* ```
|
|
8054
|
-
*/
|
|
8055
|
-
get api(): ECSFluentAPI | null;
|
|
8056
|
-
/**
|
|
8057
|
-
* 更新场景
|
|
8058
|
-
*
|
|
8059
|
-
* 应该在每帧的游戏循环中调用。
|
|
8060
|
-
* 会自动处理延迟场景切换。
|
|
8061
|
-
*
|
|
8062
|
-
* @example
|
|
8063
|
-
* ```typescript
|
|
8064
|
-
* function gameLoop(deltaTime: number) {
|
|
8065
|
-
* Core.update(deltaTime);
|
|
8066
|
-
* sceneManager.update(); // 每帧调用
|
|
8067
|
-
* }
|
|
8068
|
-
* ```
|
|
8069
|
-
*/
|
|
8070
|
-
update(): void;
|
|
8071
|
-
/**
|
|
8072
|
-
* 销毁场景管理器
|
|
8073
|
-
*
|
|
8074
|
-
* 会自动结束当前场景并清理所有资源。
|
|
8075
|
-
* 通常在应用程序关闭时调用。
|
|
8076
|
-
*/
|
|
8077
|
-
destroy(): void;
|
|
8078
|
-
/**
|
|
8079
|
-
* 检查是否有活跃场景
|
|
8080
|
-
*
|
|
8081
|
-
* @returns 如果有活跃场景返回true,否则返回false
|
|
8082
|
-
*/
|
|
8083
|
-
get hasScene(): boolean;
|
|
8084
|
-
/**
|
|
8085
|
-
* 检查是否有待切换的场景
|
|
8086
|
-
*
|
|
8087
|
-
* @returns 如果有待切换场景返回true,否则返回false
|
|
8088
|
-
*/
|
|
8089
|
-
get hasPendingScene(): boolean;
|
|
8090
|
-
/**
|
|
8091
|
-
* 释放资源(IService接口)
|
|
8092
|
-
*/
|
|
8093
|
-
dispose(): void;
|
|
8094
|
-
}
|
|
8095
|
-
|
|
8096
8343
|
/**
|
|
8097
8344
|
* 组件对象池,用于复用组件实例以减少内存分配
|
|
8098
8345
|
*/
|
|
@@ -9069,14 +9316,26 @@ declare class WebSocketManager {
|
|
|
9069
9316
|
private handleConnectionFailure;
|
|
9070
9317
|
}
|
|
9071
9318
|
|
|
9319
|
+
/**
|
|
9320
|
+
* 调试配置服务
|
|
9321
|
+
*
|
|
9322
|
+
* 管理调试系统的配置信息
|
|
9323
|
+
*/
|
|
9324
|
+
declare class DebugConfigService implements IService {
|
|
9325
|
+
private _config;
|
|
9326
|
+
constructor();
|
|
9327
|
+
setConfig(config: IECSDebugConfig): void;
|
|
9328
|
+
getConfig(): IECSDebugConfig;
|
|
9329
|
+
isEnabled(): boolean;
|
|
9330
|
+
dispose(): void;
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9072
9333
|
/**
|
|
9073
9334
|
* 调试管理器
|
|
9074
9335
|
*
|
|
9075
9336
|
* 整合所有调试数据收集器,负责收集和发送调试数据
|
|
9076
|
-
*
|
|
9077
|
-
* 通过构造函数接收SceneManager和PerformanceMonitor,避免直接依赖Core实例
|
|
9078
9337
|
*/
|
|
9079
|
-
declare class DebugManager implements IService {
|
|
9338
|
+
declare class DebugManager implements IService, IUpdatable {
|
|
9080
9339
|
private config;
|
|
9081
9340
|
private webSocketManager;
|
|
9082
9341
|
private entityCollector;
|
|
@@ -9090,13 +9349,7 @@ declare class DebugManager implements IService {
|
|
|
9090
9349
|
private lastSendTime;
|
|
9091
9350
|
private sendInterval;
|
|
9092
9351
|
private isRunning;
|
|
9093
|
-
|
|
9094
|
-
* 构造调试管理器
|
|
9095
|
-
* @param sceneManager 场景管理器
|
|
9096
|
-
* @param performanceMonitor 性能监控器
|
|
9097
|
-
* @param config 调试配置
|
|
9098
|
-
*/
|
|
9099
|
-
constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, config: IECSDebugConfig);
|
|
9352
|
+
constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, configService: DebugConfigService);
|
|
9100
9353
|
/**
|
|
9101
9354
|
* 启动调试管理器
|
|
9102
9355
|
*/
|
|
@@ -9109,10 +9362,7 @@ declare class DebugManager implements IService {
|
|
|
9109
9362
|
* 更新配置
|
|
9110
9363
|
*/
|
|
9111
9364
|
updateConfig(config: IECSDebugConfig): void;
|
|
9112
|
-
|
|
9113
|
-
* 帧更新回调
|
|
9114
|
-
*/
|
|
9115
|
-
onFrameUpdate(deltaTime: number): void;
|
|
9365
|
+
update(deltaTime?: number): void;
|
|
9116
9366
|
/**
|
|
9117
9367
|
* 场景变更回调
|
|
9118
9368
|
*/
|
|
@@ -9815,6 +10065,11 @@ interface InjectableMetadata {
|
|
|
9815
10065
|
* 依赖列表
|
|
9816
10066
|
*/
|
|
9817
10067
|
dependencies: Array<ServiceType<any> | string | symbol>;
|
|
10068
|
+
/**
|
|
10069
|
+
* 属性注入映射
|
|
10070
|
+
* key: 属性名, value: 服务类型
|
|
10071
|
+
*/
|
|
10072
|
+
properties?: Map<string | symbol, ServiceType<any>>;
|
|
9818
10073
|
}
|
|
9819
10074
|
/**
|
|
9820
10075
|
* 可更新元数据接口
|
|
@@ -9888,20 +10143,7 @@ declare function Updatable(priority?: number): ClassDecorator;
|
|
|
9888
10143
|
*
|
|
9889
10144
|
* 标记构造函数参数需要注入的服务类型
|
|
9890
10145
|
*
|
|
9891
|
-
* @param serviceType
|
|
9892
|
-
*
|
|
9893
|
-
* @example
|
|
9894
|
-
* ```typescript
|
|
9895
|
-
* @Injectable()
|
|
9896
|
-
* class MySystem extends EntitySystem {
|
|
9897
|
-
* constructor(
|
|
9898
|
-
* @Inject(TimeService) private timeService: TimeService,
|
|
9899
|
-
* @Inject(PhysicsService) private physics: PhysicsService
|
|
9900
|
-
* ) {
|
|
9901
|
-
* super();
|
|
9902
|
-
* }
|
|
9903
|
-
* }
|
|
9904
|
-
* ```
|
|
10146
|
+
* @param serviceType 服务类型标识符
|
|
9905
10147
|
*/
|
|
9906
10148
|
declare function Inject(serviceType: ServiceType<any> | string | symbol): ParameterDecorator;
|
|
9907
10149
|
/**
|
|
@@ -10582,5 +10824,5 @@ declare function getFullPlatformConfig(): Promise<any>;
|
|
|
10582
10824
|
declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
|
|
10583
10825
|
declare function hasAdapter(): boolean;
|
|
10584
10826
|
|
|
10585
|
-
export { AutoTyped, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage,
|
|
10586
|
-
export type { AnyComponentConstructor, BitMask64Data, ComponentChange, ComponentConstructor, ComponentInstance, ComponentMigrationFunction, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, EntityChange, EntityRefMetadata, EntityRefRecord, EntityWithComponents, 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, QueryResult$1 as QueryResult, ReadonlyComponent, SceneDataChange, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|
|
10827
|
+
export { AutoTyped, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, DebugConfigService, DebugManager, 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, HighPrecision, IdentifierPool, IgnoreSerialization, IncrementalSerializer, Inject, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, MigrationBuilder, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PluginManager, PluginState, Pool, PoolManager, ProcessingSystem, 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, TypeInference, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, buildEntity, createECSAPI, createInstance, createLogger, createQuery, getBasicWorkerConfig, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getFullPlatformConfig, getOrAddComponent, getSceneByEntityId, getSerializationMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, hasAdapter, hasAnyComponent, hasComponents, hasEntityRef, isComponentArray, isComponentType, isSerializable, isUpdatable, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, supportsFeature, tryGetComponent, updateComponent };
|
|
10828
|
+
export type { AnyComponentConstructor, BitMask64Data, ComponentChange, ComponentConstructor, ComponentInstance, ComponentMigrationFunction, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, EntityChange, EntityRefMetadata, EntityRefRecord, EntityWithComponents, 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, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, SceneDataChange, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|