@esengine/ecs-framework 2.2.19 → 2.2.20

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @esengine/ecs-framework v2.2.19
2
+ * @esengine/ecs-framework v2.2.20
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -5166,6 +5166,28 @@ declare class Scene implements IScene {
5166
5166
  * Counter for assigning unique add order to each system for stable sorting
5167
5167
  */
5168
5168
  private _systemAddCounter;
5169
+ /**
5170
+ * 组件ID到系统的索引映射
5171
+ *
5172
+ * 用于快速查找关心特定组件的系统,避免遍历所有系统。
5173
+ * 使用组件ID(数字)而非ComponentType作为key,避免类引用问题。
5174
+ *
5175
+ * Component ID to systems index map.
5176
+ * Used for fast lookup of systems that care about specific components.
5177
+ * Uses component ID (number) instead of ComponentType as key to avoid class reference issues.
5178
+ */
5179
+ private _componentIdToSystems;
5180
+ /**
5181
+ * 需要接收所有组件变化通知的系统集合
5182
+ *
5183
+ * 包括使用 none 条件、tag/name 查询、或空匹配器的系统。
5184
+ * 这些系统无法通过组件ID索引优化,需要在每次组件变化时都检查。
5185
+ *
5186
+ * Systems that need to receive all component change notifications.
5187
+ * Includes systems using none conditions, tag/name queries, or empty matchers.
5188
+ * These systems cannot be optimized via component ID indexing.
5189
+ */
5190
+ private _globalNotifySystems;
5169
5191
  /**
5170
5192
  * 获取场景中所有已注册的EntitySystem
5171
5193
  *
@@ -5299,6 +5321,49 @@ declare class Scene implements IScene {
5299
5321
  * 当实体或组件发生变化时调用
5300
5322
  */
5301
5323
  clearSystemEntityCaches(): void;
5324
+ /**
5325
+ * 通知相关系统实体的组件发生了变化
5326
+ *
5327
+ * 这是事件驱动设计的核心:当组件被添加或移除时,立即通知相关系统检查该实体是否匹配,
5328
+ * 并触发 onAdded/onRemoved 回调。通过组件ID索引优化,只通知关心该组件的系统。
5329
+ *
5330
+ * This is the core of event-driven design: when a component is added or removed,
5331
+ * immediately notify relevant systems to check if the entity matches and trigger
5332
+ * onAdded/onRemoved callbacks. Optimized via component ID indexing to only notify
5333
+ * systems that care about the changed component.
5334
+ *
5335
+ * @param entity 组件发生变化的实体 | The entity whose components changed
5336
+ * @param changedComponentType 变化的组件类型(可选) | The changed component type (optional)
5337
+ */
5338
+ notifyEntityComponentChanged(entity: Entity, changedComponentType?: ComponentType): void;
5339
+ /**
5340
+ * 将系统添加到组件索引
5341
+ *
5342
+ * 根据系统的 Matcher 条件,将系统注册到相应的组件ID索引中。
5343
+ *
5344
+ * Index a system by its interested component types.
5345
+ * Registers the system to component ID indices based on its Matcher conditions.
5346
+ *
5347
+ * @param system 要索引的系统 | The system to index
5348
+ */
5349
+ private indexSystemByComponents;
5350
+ /**
5351
+ * 将系统添加到指定组件的索引
5352
+ *
5353
+ * Add system to the index for a specific component type.
5354
+ *
5355
+ * @param componentType 组件类型 | Component type
5356
+ * @param system 系统 | System
5357
+ */
5358
+ private addSystemToComponentIndex;
5359
+ /**
5360
+ * 从组件索引中移除系统
5361
+ *
5362
+ * Remove a system from all component indices.
5363
+ *
5364
+ * @param system 要移除的系统 | The system to remove
5365
+ */
5366
+ private removeSystemFromIndex;
5302
5367
  /**
5303
5368
  * 在场景的实体列表中添加一个实体
5304
5369
  * @param entity 要添加的实体
@@ -5982,8 +6047,44 @@ declare abstract class EntitySystem implements ISystemBase, IService {
5982
6047
  * @returns 系统信息字符串
5983
6048
  */
5984
6049
  toString(): string;
6050
+ /**
6051
+ * 检查实体是否匹配当前系统的查询条件
6052
+ * Check if an entity matches this system's query condition
6053
+ *
6054
+ * @param entity 要检查的实体 / The entity to check
6055
+ * @returns 是否匹配 / Whether the entity matches
6056
+ */
6057
+ matchesEntity(entity: Entity): boolean;
6058
+ /**
6059
+ * 检查实体是否正在被此系统跟踪
6060
+ * Check if an entity is being tracked by this system
6061
+ *
6062
+ * @param entity 要检查的实体 / The entity to check
6063
+ * @returns 是否正在跟踪 / Whether the entity is being tracked
6064
+ */
6065
+ isTracking(entity: Entity): boolean;
6066
+ /**
6067
+ * 当实体的组件发生变化时由 Scene 调用
6068
+ *
6069
+ * 立即检查实体是否匹配并触发 onAdded/onRemoved 回调。
6070
+ * 这是事件驱动设计的核心:组件变化时立即通知相关系统。
6071
+ *
6072
+ * Called by Scene when an entity's components change.
6073
+ * Immediately checks if the entity matches and triggers onAdded/onRemoved callbacks.
6074
+ * This is the core of event-driven design: notify relevant systems immediately when components change.
6075
+ *
6076
+ * @param entity 组件发生变化的实体 / The entity whose components changed
6077
+ * @internal 由 Scene.notifyEntityComponentChanged 调用 / Called by Scene.notifyEntityComponentChanged
6078
+ */
6079
+ handleEntityComponentChanged(entity: Entity): void;
5985
6080
  /**
5986
6081
  * 更新实体跟踪,检查新增和移除的实体
6082
+ *
6083
+ * 由于采用了事件驱动设计,运行时的 onAdded/onRemoved 已在 handleEntityComponentChanged 中
6084
+ * 立即触发。此方法不再触发回调,只同步跟踪状态。
6085
+ *
6086
+ * With event-driven design, runtime onAdded/onRemoved are triggered immediately in
6087
+ * handleEntityComponentChanged. This method no longer triggers callbacks, only syncs tracking state.
5987
6088
  */
5988
6089
  private updateEntityTracking;
5989
6090
  /**
@@ -6307,8 +6408,24 @@ interface IScene {
6307
6408
  createEntity(name: string): Entity;
6308
6409
  /**
6309
6410
  * 清除所有EntitySystem的实体缓存
6411
+ * Clear all EntitySystem entity caches
6310
6412
  */
6311
6413
  clearSystemEntityCaches(): void;
6414
+ /**
6415
+ * 通知相关系统实体的组件发生了变化
6416
+ *
6417
+ * 当组件被添加或移除时调用,立即通知相关系统检查该实体是否匹配,
6418
+ * 并触发 onAdded/onRemoved 回调。通过组件ID索引优化,只通知关心该组件的系统。
6419
+ *
6420
+ * Notify relevant systems that an entity's components have changed.
6421
+ * Called when a component is added or removed, immediately notifying
6422
+ * relevant systems to check if the entity matches and trigger onAdded/onRemoved callbacks.
6423
+ * Optimized via component ID indexing to only notify systems that care about the changed component.
6424
+ *
6425
+ * @param entity 组件发生变化的实体 | The entity whose components changed
6426
+ * @param changedComponentType 变化的组件类型(可选) | The changed component type (optional)
6427
+ */
6428
+ notifyEntityComponentChanged(entity: Entity, changedComponentType?: ComponentType): void;
6312
6429
  /**
6313
6430
  * 添加实体
6314
6431
  */
@@ -6672,6 +6789,10 @@ declare class Entity {
6672
6789
  private addComponentInternal;
6673
6790
  /**
6674
6791
  * 通知Scene中的QuerySystem实体组件发生变动
6792
+ *
6793
+ * Notify the QuerySystem in Scene that entity components have changed
6794
+ *
6795
+ * @param changedComponentType 变化的组件类型(可选,用于优化通知) | Changed component type (optional, for optimized notification)
6675
6796
  */
6676
6797
  private notifyQuerySystems;
6677
6798
  /**