@esengine/ecs-framework 2.2.19 → 2.2.21
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 +233 -4
- 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/LICENSE +0 -21
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @esengine/ecs-framework v2.2.
|
|
2
|
+
* @esengine/ecs-framework v2.2.21
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -1323,6 +1323,13 @@ declare class ComponentRegistry {
|
|
|
1323
1323
|
private static componentNameToId;
|
|
1324
1324
|
private static maskCache;
|
|
1325
1325
|
private static nextBitIndex;
|
|
1326
|
+
/**
|
|
1327
|
+
* 热更新模式标志,默认禁用
|
|
1328
|
+
* Hot reload mode flag, disabled by default
|
|
1329
|
+
* 编辑器环境应启用此选项以支持脚本热更新
|
|
1330
|
+
* Editor environment should enable this to support script hot reload
|
|
1331
|
+
*/
|
|
1332
|
+
private static hotReloadEnabled;
|
|
1326
1333
|
/**
|
|
1327
1334
|
* 注册组件类型并分配位掩码
|
|
1328
1335
|
* @param componentType 组件类型
|
|
@@ -1402,6 +1409,23 @@ declare class ComponentRegistry {
|
|
|
1402
1409
|
* 清除掩码缓存
|
|
1403
1410
|
*/
|
|
1404
1411
|
static clearMaskCache(): void;
|
|
1412
|
+
/**
|
|
1413
|
+
* 启用热更新模式
|
|
1414
|
+
* Enable hot reload mode
|
|
1415
|
+
* 在编辑器环境中调用以支持脚本热更新
|
|
1416
|
+
* Call in editor environment to support script hot reload
|
|
1417
|
+
*/
|
|
1418
|
+
static enableHotReload(): void;
|
|
1419
|
+
/**
|
|
1420
|
+
* 禁用热更新模式
|
|
1421
|
+
* Disable hot reload mode
|
|
1422
|
+
*/
|
|
1423
|
+
static disableHotReload(): void;
|
|
1424
|
+
/**
|
|
1425
|
+
* 检查热更新模式是否启用
|
|
1426
|
+
* Check if hot reload mode is enabled
|
|
1427
|
+
*/
|
|
1428
|
+
static isHotReloadEnabled(): boolean;
|
|
1405
1429
|
/**
|
|
1406
1430
|
* 重置注册表(用于测试)
|
|
1407
1431
|
*/
|
|
@@ -4368,12 +4392,17 @@ declare class ComponentSerializer {
|
|
|
4368
4392
|
*/
|
|
4369
4393
|
declare class HierarchySystem extends EntitySystem {
|
|
4370
4394
|
private static readonly MAX_DEPTH;
|
|
4395
|
+
/**
|
|
4396
|
+
* 脏实体集合 - 只有这些实体需要在 process() 中更新缓存
|
|
4397
|
+
* Dirty entity set - only these entities need cache update in process()
|
|
4398
|
+
*/
|
|
4399
|
+
private dirtyEntities;
|
|
4371
4400
|
constructor();
|
|
4372
4401
|
/**
|
|
4373
4402
|
* 系统优先级,确保在其他系统之前更新层级缓存
|
|
4374
4403
|
*/
|
|
4375
4404
|
get updateOrder(): number;
|
|
4376
|
-
protected process(): void;
|
|
4405
|
+
protected process(_entities: readonly Entity[]): void;
|
|
4377
4406
|
/**
|
|
4378
4407
|
* 设置实体的父级
|
|
4379
4408
|
*
|
|
@@ -4474,17 +4503,24 @@ declare class HierarchySystem extends EntitySystem {
|
|
|
4474
4503
|
bIsExpanded: boolean;
|
|
4475
4504
|
}>;
|
|
4476
4505
|
/**
|
|
4477
|
-
*
|
|
4506
|
+
* 标记缓存为脏,并添加到脏实体集合
|
|
4507
|
+
* Mark cache as dirty and add to dirty entity set
|
|
4478
4508
|
*/
|
|
4479
4509
|
private markCacheDirty;
|
|
4480
4510
|
/**
|
|
4481
4511
|
* 更新层级缓存
|
|
4482
4512
|
*/
|
|
4483
4513
|
private updateHierarchyCache;
|
|
4514
|
+
/**
|
|
4515
|
+
* 当实体被添加到系统时,将其加入脏集合
|
|
4516
|
+
* When entity is added to system, add it to dirty set
|
|
4517
|
+
*/
|
|
4518
|
+
protected onAdded(entity: Entity): void;
|
|
4484
4519
|
/**
|
|
4485
4520
|
* 当实体被移除时清理层级关系
|
|
4521
|
+
* When entity is removed, clean up hierarchy relationships
|
|
4486
4522
|
*/
|
|
4487
|
-
protected
|
|
4523
|
+
protected onRemoved(entity: Entity): void;
|
|
4488
4524
|
dispose(): void;
|
|
4489
4525
|
}
|
|
4490
4526
|
|
|
@@ -5137,6 +5173,28 @@ declare class Scene implements IScene {
|
|
|
5137
5173
|
* 场景是否已开始运行
|
|
5138
5174
|
*/
|
|
5139
5175
|
private _didSceneBegin;
|
|
5176
|
+
/**
|
|
5177
|
+
* 编辑器模式标志
|
|
5178
|
+
*
|
|
5179
|
+
* 当为 true 时,组件的生命周期回调(如 onAddedToEntity)会被延迟,
|
|
5180
|
+
* 直到调用 begin() 开始运行场景时才会触发。
|
|
5181
|
+
*
|
|
5182
|
+
* Editor mode flag.
|
|
5183
|
+
* When true, component lifecycle callbacks (like onAddedToEntity) are deferred
|
|
5184
|
+
* until begin() is called to start running the scene.
|
|
5185
|
+
*/
|
|
5186
|
+
isEditorMode: boolean;
|
|
5187
|
+
/**
|
|
5188
|
+
* 延迟的组件生命周期回调队列
|
|
5189
|
+
*
|
|
5190
|
+
* 在编辑器模式下,组件的 onAddedToEntity 回调会被加入此队列,
|
|
5191
|
+
* 等到 begin() 调用时统一执行。
|
|
5192
|
+
*
|
|
5193
|
+
* Deferred component lifecycle callback queue.
|
|
5194
|
+
* In editor mode, component's onAddedToEntity callbacks are queued here,
|
|
5195
|
+
* and will be executed when begin() is called.
|
|
5196
|
+
*/
|
|
5197
|
+
private _deferredComponentCallbacks;
|
|
5140
5198
|
/**
|
|
5141
5199
|
* 系统列表缓存
|
|
5142
5200
|
*/
|
|
@@ -5166,6 +5224,28 @@ declare class Scene implements IScene {
|
|
|
5166
5224
|
* Counter for assigning unique add order to each system for stable sorting
|
|
5167
5225
|
*/
|
|
5168
5226
|
private _systemAddCounter;
|
|
5227
|
+
/**
|
|
5228
|
+
* 组件ID到系统的索引映射
|
|
5229
|
+
*
|
|
5230
|
+
* 用于快速查找关心特定组件的系统,避免遍历所有系统。
|
|
5231
|
+
* 使用组件ID(数字)而非ComponentType作为key,避免类引用问题。
|
|
5232
|
+
*
|
|
5233
|
+
* Component ID to systems index map.
|
|
5234
|
+
* Used for fast lookup of systems that care about specific components.
|
|
5235
|
+
* Uses component ID (number) instead of ComponentType as key to avoid class reference issues.
|
|
5236
|
+
*/
|
|
5237
|
+
private _componentIdToSystems;
|
|
5238
|
+
/**
|
|
5239
|
+
* 需要接收所有组件变化通知的系统集合
|
|
5240
|
+
*
|
|
5241
|
+
* 包括使用 none 条件、tag/name 查询、或空匹配器的系统。
|
|
5242
|
+
* 这些系统无法通过组件ID索引优化,需要在每次组件变化时都检查。
|
|
5243
|
+
*
|
|
5244
|
+
* Systems that need to receive all component change notifications.
|
|
5245
|
+
* Includes systems using none conditions, tag/name queries, or empty matchers.
|
|
5246
|
+
* These systems cannot be optimized via component ID indexing.
|
|
5247
|
+
*/
|
|
5248
|
+
private _globalNotifySystems;
|
|
5169
5249
|
/**
|
|
5170
5250
|
* 获取场景中所有已注册的EntitySystem
|
|
5171
5251
|
*
|
|
@@ -5253,10 +5333,25 @@ declare class Scene implements IScene {
|
|
|
5253
5333
|
* 在场景被销毁时调用,可以在此方法中执行清理工作。
|
|
5254
5334
|
*/
|
|
5255
5335
|
unload(): void;
|
|
5336
|
+
/**
|
|
5337
|
+
* 添加延迟的组件生命周期回调
|
|
5338
|
+
*
|
|
5339
|
+
* 在编辑器模式下,组件的 onAddedToEntity 回调会通过此方法加入队列。
|
|
5340
|
+
*
|
|
5341
|
+
* Queue a deferred component lifecycle callback.
|
|
5342
|
+
* In editor mode, component's onAddedToEntity callbacks are queued via this method.
|
|
5343
|
+
*
|
|
5344
|
+
* @param callback 要延迟执行的回调 | The callback to defer
|
|
5345
|
+
*/
|
|
5346
|
+
queueDeferredComponentCallback(callback: () => void): void;
|
|
5256
5347
|
/**
|
|
5257
5348
|
* 开始场景,启动实体处理器等
|
|
5258
5349
|
*
|
|
5259
5350
|
* 这个方法会启动场景。它将启动实体处理器等,并调用onStart方法。
|
|
5351
|
+
* 在编辑器模式下,此方法还会执行所有延迟的组件生命周期回调。
|
|
5352
|
+
*
|
|
5353
|
+
* This method starts the scene. It will start entity processors and call onStart.
|
|
5354
|
+
* In editor mode, this method also executes all deferred component lifecycle callbacks.
|
|
5260
5355
|
*/
|
|
5261
5356
|
begin(): void;
|
|
5262
5357
|
/**
|
|
@@ -5299,6 +5394,49 @@ declare class Scene implements IScene {
|
|
|
5299
5394
|
* 当实体或组件发生变化时调用
|
|
5300
5395
|
*/
|
|
5301
5396
|
clearSystemEntityCaches(): void;
|
|
5397
|
+
/**
|
|
5398
|
+
* 通知相关系统实体的组件发生了变化
|
|
5399
|
+
*
|
|
5400
|
+
* 这是事件驱动设计的核心:当组件被添加或移除时,立即通知相关系统检查该实体是否匹配,
|
|
5401
|
+
* 并触发 onAdded/onRemoved 回调。通过组件ID索引优化,只通知关心该组件的系统。
|
|
5402
|
+
*
|
|
5403
|
+
* This is the core of event-driven design: when a component is added or removed,
|
|
5404
|
+
* immediately notify relevant systems to check if the entity matches and trigger
|
|
5405
|
+
* onAdded/onRemoved callbacks. Optimized via component ID indexing to only notify
|
|
5406
|
+
* systems that care about the changed component.
|
|
5407
|
+
*
|
|
5408
|
+
* @param entity 组件发生变化的实体 | The entity whose components changed
|
|
5409
|
+
* @param changedComponentType 变化的组件类型(可选) | The changed component type (optional)
|
|
5410
|
+
*/
|
|
5411
|
+
notifyEntityComponentChanged(entity: Entity, changedComponentType?: ComponentType): void;
|
|
5412
|
+
/**
|
|
5413
|
+
* 将系统添加到组件索引
|
|
5414
|
+
*
|
|
5415
|
+
* 根据系统的 Matcher 条件,将系统注册到相应的组件ID索引中。
|
|
5416
|
+
*
|
|
5417
|
+
* Index a system by its interested component types.
|
|
5418
|
+
* Registers the system to component ID indices based on its Matcher conditions.
|
|
5419
|
+
*
|
|
5420
|
+
* @param system 要索引的系统 | The system to index
|
|
5421
|
+
*/
|
|
5422
|
+
private indexSystemByComponents;
|
|
5423
|
+
/**
|
|
5424
|
+
* 将系统添加到指定组件的索引
|
|
5425
|
+
*
|
|
5426
|
+
* Add system to the index for a specific component type.
|
|
5427
|
+
*
|
|
5428
|
+
* @param componentType 组件类型 | Component type
|
|
5429
|
+
* @param system 系统 | System
|
|
5430
|
+
*/
|
|
5431
|
+
private addSystemToComponentIndex;
|
|
5432
|
+
/**
|
|
5433
|
+
* 从组件索引中移除系统
|
|
5434
|
+
*
|
|
5435
|
+
* Remove a system from all component indices.
|
|
5436
|
+
*
|
|
5437
|
+
* @param system 要移除的系统 | The system to remove
|
|
5438
|
+
*/
|
|
5439
|
+
private removeSystemFromIndex;
|
|
5302
5440
|
/**
|
|
5303
5441
|
* 在场景的实体列表中添加一个实体
|
|
5304
5442
|
* @param entity 要添加的实体
|
|
@@ -5982,8 +6120,44 @@ declare abstract class EntitySystem implements ISystemBase, IService {
|
|
|
5982
6120
|
* @returns 系统信息字符串
|
|
5983
6121
|
*/
|
|
5984
6122
|
toString(): string;
|
|
6123
|
+
/**
|
|
6124
|
+
* 检查实体是否匹配当前系统的查询条件
|
|
6125
|
+
* Check if an entity matches this system's query condition
|
|
6126
|
+
*
|
|
6127
|
+
* @param entity 要检查的实体 / The entity to check
|
|
6128
|
+
* @returns 是否匹配 / Whether the entity matches
|
|
6129
|
+
*/
|
|
6130
|
+
matchesEntity(entity: Entity): boolean;
|
|
6131
|
+
/**
|
|
6132
|
+
* 检查实体是否正在被此系统跟踪
|
|
6133
|
+
* Check if an entity is being tracked by this system
|
|
6134
|
+
*
|
|
6135
|
+
* @param entity 要检查的实体 / The entity to check
|
|
6136
|
+
* @returns 是否正在跟踪 / Whether the entity is being tracked
|
|
6137
|
+
*/
|
|
6138
|
+
isTracking(entity: Entity): boolean;
|
|
6139
|
+
/**
|
|
6140
|
+
* 当实体的组件发生变化时由 Scene 调用
|
|
6141
|
+
*
|
|
6142
|
+
* 立即检查实体是否匹配并触发 onAdded/onRemoved 回调。
|
|
6143
|
+
* 这是事件驱动设计的核心:组件变化时立即通知相关系统。
|
|
6144
|
+
*
|
|
6145
|
+
* Called by Scene when an entity's components change.
|
|
6146
|
+
* Immediately checks if the entity matches and triggers onAdded/onRemoved callbacks.
|
|
6147
|
+
* This is the core of event-driven design: notify relevant systems immediately when components change.
|
|
6148
|
+
*
|
|
6149
|
+
* @param entity 组件发生变化的实体 / The entity whose components changed
|
|
6150
|
+
* @internal 由 Scene.notifyEntityComponentChanged 调用 / Called by Scene.notifyEntityComponentChanged
|
|
6151
|
+
*/
|
|
6152
|
+
handleEntityComponentChanged(entity: Entity): void;
|
|
5985
6153
|
/**
|
|
5986
6154
|
* 更新实体跟踪,检查新增和移除的实体
|
|
6155
|
+
*
|
|
6156
|
+
* 由于采用了事件驱动设计,运行时的 onAdded/onRemoved 已在 handleEntityComponentChanged 中
|
|
6157
|
+
* 立即触发。此方法不再触发回调,只同步跟踪状态。
|
|
6158
|
+
*
|
|
6159
|
+
* With event-driven design, runtime onAdded/onRemoved are triggered immediately in
|
|
6160
|
+
* handleEntityComponentChanged. This method no longer triggers callbacks, only syncs tracking state.
|
|
5987
6161
|
*/
|
|
5988
6162
|
private updateEntityTracking;
|
|
5989
6163
|
/**
|
|
@@ -6273,6 +6447,17 @@ interface IScene {
|
|
|
6273
6447
|
* 场景级别的依赖注入容器,用于管理服务的生命周期。
|
|
6274
6448
|
*/
|
|
6275
6449
|
readonly services: ServiceContainer;
|
|
6450
|
+
/**
|
|
6451
|
+
* 编辑器模式标志
|
|
6452
|
+
*
|
|
6453
|
+
* 当为 true 时,组件的生命周期回调(如 onAddedToEntity)会被延迟,
|
|
6454
|
+
* 直到调用 begin() 开始运行场景时才会触发。
|
|
6455
|
+
*
|
|
6456
|
+
* Editor mode flag.
|
|
6457
|
+
* When true, component lifecycle callbacks (like onAddedToEntity) are deferred
|
|
6458
|
+
* until begin() is called to start running the scene.
|
|
6459
|
+
*/
|
|
6460
|
+
isEditorMode: boolean;
|
|
6276
6461
|
/**
|
|
6277
6462
|
* 获取系统列表
|
|
6278
6463
|
*/
|
|
@@ -6289,6 +6474,14 @@ interface IScene {
|
|
|
6289
6474
|
* 场景卸载时的回调
|
|
6290
6475
|
*/
|
|
6291
6476
|
unload(): void;
|
|
6477
|
+
/**
|
|
6478
|
+
* 添加延迟的组件生命周期回调
|
|
6479
|
+
*
|
|
6480
|
+
* Queue a deferred component lifecycle callback.
|
|
6481
|
+
*
|
|
6482
|
+
* @param callback 要延迟执行的回调 | The callback to defer
|
|
6483
|
+
*/
|
|
6484
|
+
queueDeferredComponentCallback(callback: () => void): void;
|
|
6292
6485
|
/**
|
|
6293
6486
|
* 开始场景
|
|
6294
6487
|
*/
|
|
@@ -6307,8 +6500,24 @@ interface IScene {
|
|
|
6307
6500
|
createEntity(name: string): Entity;
|
|
6308
6501
|
/**
|
|
6309
6502
|
* 清除所有EntitySystem的实体缓存
|
|
6503
|
+
* Clear all EntitySystem entity caches
|
|
6310
6504
|
*/
|
|
6311
6505
|
clearSystemEntityCaches(): void;
|
|
6506
|
+
/**
|
|
6507
|
+
* 通知相关系统实体的组件发生了变化
|
|
6508
|
+
*
|
|
6509
|
+
* 当组件被添加或移除时调用,立即通知相关系统检查该实体是否匹配,
|
|
6510
|
+
* 并触发 onAdded/onRemoved 回调。通过组件ID索引优化,只通知关心该组件的系统。
|
|
6511
|
+
*
|
|
6512
|
+
* Notify relevant systems that an entity's components have changed.
|
|
6513
|
+
* Called when a component is added or removed, immediately notifying
|
|
6514
|
+
* relevant systems to check if the entity matches and trigger onAdded/onRemoved callbacks.
|
|
6515
|
+
* Optimized via component ID indexing to only notify systems that care about the changed component.
|
|
6516
|
+
*
|
|
6517
|
+
* @param entity 组件发生变化的实体 | The entity whose components changed
|
|
6518
|
+
* @param changedComponentType 变化的组件类型(可选) | The changed component type (optional)
|
|
6519
|
+
*/
|
|
6520
|
+
notifyEntityComponentChanged(entity: Entity, changedComponentType?: ComponentType): void;
|
|
6312
6521
|
/**
|
|
6313
6522
|
* 添加实体
|
|
6314
6523
|
*/
|
|
@@ -6672,6 +6881,10 @@ declare class Entity {
|
|
|
6672
6881
|
private addComponentInternal;
|
|
6673
6882
|
/**
|
|
6674
6883
|
* 通知Scene中的QuerySystem实体组件发生变动
|
|
6884
|
+
*
|
|
6885
|
+
* Notify the QuerySystem in Scene that entity components have changed
|
|
6886
|
+
*
|
|
6887
|
+
* @param changedComponentType 变化的组件类型(可选,用于优化通知) | Changed component type (optional, for optimized notification)
|
|
6675
6888
|
*/
|
|
6676
6889
|
private notifyQuerySystems;
|
|
6677
6890
|
/**
|
|
@@ -12825,6 +13038,22 @@ declare class PlatformDetector {
|
|
|
12825
13038
|
* 检测是否为浏览器环境
|
|
12826
13039
|
*/
|
|
12827
13040
|
private static isBrowser;
|
|
13041
|
+
/**
|
|
13042
|
+
* 检测是否在 Tauri 桌面环境中运行
|
|
13043
|
+
* Check if running in Tauri desktop environment
|
|
13044
|
+
*
|
|
13045
|
+
* 同时支持 Tauri v1 (__TAURI__) 和 v2 (__TAURI_INTERNALS__)
|
|
13046
|
+
* Supports both Tauri v1 (__TAURI__) and v2 (__TAURI_INTERNALS__)
|
|
13047
|
+
*/
|
|
13048
|
+
static isTauriEnvironment(): boolean;
|
|
13049
|
+
/**
|
|
13050
|
+
* 检测是否在编辑器环境中运行
|
|
13051
|
+
* Check if running in editor environment
|
|
13052
|
+
*
|
|
13053
|
+
* 包括 Tauri 桌面应用或带 __ESENGINE_EDITOR__ 标记的环境
|
|
13054
|
+
* Includes Tauri desktop app or environments marked with __ESENGINE_EDITOR__
|
|
13055
|
+
*/
|
|
13056
|
+
static isEditorEnvironment(): boolean;
|
|
12828
13057
|
/**
|
|
12829
13058
|
* 获取详细的环境信息(用于调试)
|
|
12830
13059
|
*/
|