@esengine/ecs-framework 2.1.15 → 2.1.17

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,204 +1,7 @@
1
1
  /**
2
- * @esengine/ecs-framework v2.1.15
2
+ * @esengine/ecs-framework v2.1.17
3
3
  * TypeScript definitions
4
4
  */
5
- /**
6
- * 用于包装事件的一个小类
7
- */
8
- declare class FuncPack {
9
- /** 函数 */
10
- func: Function;
11
- /** 上下文 */
12
- context: any;
13
- constructor(func: Function, context: any);
14
- }
15
- /**
16
- * 用于事件管理
17
- */
18
- declare class Emitter<T> {
19
- private _messageTable;
20
- constructor();
21
- /**
22
- * 开始监听项
23
- * @param eventType 监听类型
24
- * @param handler 监听函数
25
- * @param context 监听上下文
26
- */
27
- addObserver(eventType: T, handler: Function, context: any): void;
28
- /**
29
- * 移除监听项
30
- * @param eventType 事件类型
31
- * @param handler 事件函数
32
- */
33
- removeObserver(eventType: T, handler: Function): void;
34
- /**
35
- * 触发该事件
36
- * @param eventType 事件类型
37
- * @param data 事件数据
38
- */
39
- emit(eventType: T, ...data: any[]): void;
40
- /**
41
- * 判断是否存在该类型的观察者
42
- * @param eventType 事件类型
43
- * @param handler 事件函数
44
- */
45
- hasObserver(eventType: T, handler: Function): boolean;
46
- }
47
-
48
- /**
49
- * 核心事件枚举
50
- * 定义框架中的核心事件类型
51
- */
52
- declare enum CoreEvents {
53
- /**
54
- * 当场景发生变化时触发
55
- */
56
- sceneChanged = 0,
57
- /**
58
- * 每帧更新事件
59
- */
60
- frameUpdated = 1,
61
- /**
62
- * 当渲染发生时触发
63
- */
64
- renderChanged = 2
65
- }
66
- /**
67
- * ECS事件类型枚举
68
- * 定义实体组件系统中的所有事件类型
69
- */
70
- declare enum ECSEventType {
71
- ENTITY_CREATED = "entity:created",
72
- ENTITY_DESTROYED = "entity:destroyed",
73
- ENTITY_ENABLED = "entity:enabled",
74
- ENTITY_DISABLED = "entity:disabled",
75
- ENTITY_TAG_ADDED = "entity:tag:added",
76
- ENTITY_TAG_REMOVED = "entity:tag:removed",
77
- ENTITY_NAME_CHANGED = "entity:name:changed",
78
- COMPONENT_ADDED = "component:added",
79
- COMPONENT_REMOVED = "component:removed",
80
- COMPONENT_MODIFIED = "component:modified",
81
- COMPONENT_ENABLED = "component:enabled",
82
- COMPONENT_DISABLED = "component:disabled",
83
- SYSTEM_ADDED = "system:added",
84
- SYSTEM_REMOVED = "system:removed",
85
- SYSTEM_ENABLED = "system:enabled",
86
- SYSTEM_DISABLED = "system:disabled",
87
- SYSTEM_PROCESSING_START = "system:processing:start",
88
- SYSTEM_PROCESSING_END = "system:processing:end",
89
- SYSTEM_ERROR = "system:error",
90
- SCENE_CREATED = "scene:created",
91
- SCENE_DESTROYED = "scene:destroyed",
92
- SCENE_ACTIVATED = "scene:activated",
93
- SCENE_DEACTIVATED = "scene:deactivated",
94
- SCENE_PAUSED = "scene:paused",
95
- SCENE_RESUMED = "scene:resumed",
96
- QUERY_EXECUTED = "query:executed",
97
- QUERY_CACHE_HIT = "query:cache:hit",
98
- QUERY_CACHE_MISS = "query:cache:miss",
99
- QUERY_OPTIMIZED = "query:optimized",
100
- PERFORMANCE_WARNING = "performance:warning",
101
- PERFORMANCE_CRITICAL = "performance:critical",
102
- MEMORY_USAGE_HIGH = "memory:usage:high",
103
- FRAME_RATE_DROP = "frame:rate:drop",
104
- INDEX_CREATED = "index:created",
105
- INDEX_UPDATED = "index:updated",
106
- INDEX_OPTIMIZED = "index:optimized",
107
- ARCHETYPE_CREATED = "archetype:created",
108
- ARCHETYPE_ENTITY_ADDED = "archetype:entity:added",
109
- ARCHETYPE_ENTITY_REMOVED = "archetype:entity:removed",
110
- DIRTY_MARK_ADDED = "dirty:mark:added",
111
- DIRTY_BATCH_PROCESSED = "dirty:batch:processed",
112
- ERROR_OCCURRED = "error:occurred",
113
- WARNING_ISSUED = "warning:issued",
114
- FRAMEWORK_INITIALIZED = "framework:initialized",
115
- FRAMEWORK_SHUTDOWN = "framework:shutdown",
116
- DEBUG_INFO = "debug:info",
117
- DEBUG_STATS_UPDATED = "debug:stats:updated"
118
- }
119
- /**
120
- * 事件优先级枚举
121
- * 定义事件处理的优先级级别
122
- */
123
- declare enum EventPriority {
124
- LOWEST = 0,
125
- LOW = 25,
126
- NORMAL = 50,
127
- HIGH = 75,
128
- HIGHEST = 100,
129
- CRITICAL = 200
130
- }
131
- /**
132
- * 预定义的事件类型常量
133
- * 提供类型安全的事件类型字符串
134
- */
135
- declare const EVENT_TYPES: {
136
- readonly CORE: {
137
- readonly SCENE_CHANGED: "core:scene:changed";
138
- readonly FRAME_UPDATED: "core:frame:updated";
139
- readonly RENDER_CHANGED: "core:render:changed";
140
- };
141
- readonly ENTITY: {
142
- readonly CREATED: ECSEventType.ENTITY_CREATED;
143
- readonly DESTROYED: ECSEventType.ENTITY_DESTROYED;
144
- readonly ENABLED: ECSEventType.ENTITY_ENABLED;
145
- readonly DISABLED: ECSEventType.ENTITY_DISABLED;
146
- readonly TAG_ADDED: ECSEventType.ENTITY_TAG_ADDED;
147
- readonly TAG_REMOVED: ECSEventType.ENTITY_TAG_REMOVED;
148
- readonly NAME_CHANGED: ECSEventType.ENTITY_NAME_CHANGED;
149
- };
150
- readonly COMPONENT: {
151
- readonly ADDED: ECSEventType.COMPONENT_ADDED;
152
- readonly REMOVED: ECSEventType.COMPONENT_REMOVED;
153
- readonly MODIFIED: ECSEventType.COMPONENT_MODIFIED;
154
- readonly ENABLED: ECSEventType.COMPONENT_ENABLED;
155
- readonly DISABLED: ECSEventType.COMPONENT_DISABLED;
156
- };
157
- readonly SYSTEM: {
158
- readonly ADDED: ECSEventType.SYSTEM_ADDED;
159
- readonly REMOVED: ECSEventType.SYSTEM_REMOVED;
160
- readonly ENABLED: ECSEventType.SYSTEM_ENABLED;
161
- readonly DISABLED: ECSEventType.SYSTEM_DISABLED;
162
- readonly PROCESSING_START: ECSEventType.SYSTEM_PROCESSING_START;
163
- readonly PROCESSING_END: ECSEventType.SYSTEM_PROCESSING_END;
164
- readonly ERROR: ECSEventType.SYSTEM_ERROR;
165
- };
166
- readonly PERFORMANCE: {
167
- readonly WARNING: ECSEventType.PERFORMANCE_WARNING;
168
- readonly CRITICAL: ECSEventType.PERFORMANCE_CRITICAL;
169
- readonly MEMORY_HIGH: ECSEventType.MEMORY_USAGE_HIGH;
170
- readonly FRAME_DROP: ECSEventType.FRAME_RATE_DROP;
171
- };
172
- };
173
- /**
174
- * 事件类型验证器
175
- * 验证事件类型是否有效
176
- */
177
- declare class EventTypeValidator {
178
- private static validTypes;
179
- /**
180
- * 验证事件类型是否有效
181
- * @param eventType 事件类型
182
- * @returns 是否有效
183
- */
184
- static isValid(eventType: string): boolean;
185
- /**
186
- * 获取所有有效的事件类型
187
- * @returns 事件类型数组
188
- */
189
- static getAllValidTypes(): string[];
190
- /**
191
- * 添加自定义事件类型
192
- * @param eventType 事件类型
193
- */
194
- static addCustomType(eventType: string): void;
195
- /**
196
- * 移除自定义事件类型
197
- * @param eventType 事件类型
198
- */
199
- static removeCustomType(eventType: string): void;
200
- }
201
-
202
5
  /**
203
6
  * 全局管理器的基类。所有全局管理器都应该从此类继承。
204
7
  */
@@ -258,6 +61,14 @@ declare class Timer implements ITimer {
258
61
  _isDone: boolean;
259
62
  _elapsedTime: number;
260
63
  getContext<T>(): T;
64
+ /**
65
+ * 定时器是否已完成
66
+ */
67
+ get isDone(): boolean;
68
+ /**
69
+ * 定时器已运行的时间
70
+ */
71
+ get elapsedTime(): number;
261
72
  reset(): void;
262
73
  stop(): void;
263
74
  tick(): boolean;
@@ -737,24 +548,6 @@ declare class PoolManager {
737
548
  /**
738
549
  * 框架核心类型定义
739
550
  */
740
- /** 更新顺序比较器接口 */
741
- interface IUpdateOrderComparable {
742
- updateOrder: number;
743
- }
744
- /** 日志类型枚举 */
745
- declare enum LogType {
746
- Error = 0,
747
- Assert = 1,
748
- Warning = 2,
749
- Log = 3,
750
- Exception = 4
751
- }
752
- /** 组件变换类型枚举 */
753
- declare enum ComponentTransform {
754
- Position = 1,
755
- Scale = 2,
756
- Rotation = 4
757
- }
758
551
  /**
759
552
  * 组件接口
760
553
  *
@@ -781,125 +574,14 @@ interface IComponent {
781
574
  update(): void;
782
575
  }
783
576
  /**
784
- * 实体接口
577
+ * 系统基础接口
785
578
  *
786
- * 定义实体的基本契约,所有实体都应该实现此接口
787
- */
788
- interface IEntity {
789
- /** 实体唯一标识符 */
790
- readonly id: string | number;
791
- /** 实体名称 */
792
- name: string;
793
- /** 实体激活状态 */
794
- active: boolean;
795
- /** 实体启用状态 */
796
- enabled: boolean;
797
- /** 实体是否已销毁 */
798
- readonly isDestroyed: boolean;
799
- /** 更新顺序 */
800
- updateOrder: number;
801
- /** 实体标签 */
802
- tag: number;
803
- /** 添加组件 */
804
- addComponent<T extends IComponent>(component: T): T;
805
- /** 创建并添加组件 */
806
- createComponent<T extends IComponent>(componentType: ComponentType$1<T>, ...args: any[]): T;
807
- /** 获取组件 */
808
- getComponent<T extends IComponent>(type: ComponentType$1<T>): T | null;
809
- /** 获取或创建组件 */
810
- getOrCreateComponent<T extends IComponent>(type: ComponentType$1<T>, ...args: any[]): T;
811
- /** 移除组件 */
812
- removeComponent(component: IComponent): void;
813
- /** 通过类型移除组件 */
814
- removeComponentByType<T extends IComponent>(type: ComponentType$1<T>): T | null;
815
- /** 检查是否有组件 */
816
- hasComponent<T extends IComponent>(type: ComponentType$1<T>): boolean;
817
- /** 获取所有指定类型的组件 */
818
- getComponents<T extends IComponent>(type: ComponentType$1<T>): T[];
819
- /** 添加子实体 */
820
- addChild(child: IEntity): IEntity;
821
- /** 移除子实体 */
822
- removeChild(child: IEntity): boolean;
823
- /** 查找子实体 */
824
- findChild(name: string, recursive?: boolean): IEntity | null;
825
- /** 更新实体 */
826
- update(): void;
827
- /** 销毁实体 */
828
- destroy(): void;
829
- }
830
- /**
831
- * 实体基础接口(向后兼容)
832
- *
833
- * 为现有的Entity类提供更灵活的类型定义
834
- */
835
- interface IEntityBase {
836
- /** 实体唯一标识符 */
837
- readonly id: string | number;
838
- /** 实体名称 */
839
- name: string;
840
- /** 实体激活状态 */
841
- active: boolean;
842
- /** 实体启用状态 */
843
- enabled: boolean;
844
- /** 实体是否已销毁 */
845
- readonly isDestroyed: boolean;
846
- /** 更新顺序 */
847
- updateOrder: number;
848
- /** 实体标签 */
849
- tag: number;
850
- /** 添加组件(泛型版本) */
851
- addComponent<T>(component: T): T;
852
- /** 获取组件(泛型版本) */
853
- getComponent<T>(type: ComponentClass<T>): T | null;
854
- /** 检查是否有组件(泛型版本) */
855
- hasComponent<T>(type: ComponentClass<T>): boolean;
856
- /** 添加子实体 */
857
- addChild(child: any): any;
858
- /** 移除子实体 */
859
- removeChild(child: any): boolean;
860
- /** 查找子实体 */
861
- findChild(name: string, recursive?: boolean): any;
862
- /** 更新实体 */
863
- update(): void;
864
- /** 销毁实体 */
865
- destroy(): void;
866
- }
867
- /**
868
- * 系统接口
869
- *
870
- * 定义系统的基本契约,所有系统都应该实现此接口
871
- */
872
- interface ISystem {
873
- /** 系统名称 */
874
- readonly systemName: string;
875
- /** 系统处理的实体列表 */
876
- readonly entities: readonly IEntity[];
877
- /** 更新顺序/优先级 */
878
- updateOrder: number;
879
- /** 系统启用状态 */
880
- enabled: boolean;
881
- /** 系统初始化 */
882
- initialize(): void;
883
- /** 更新系统(主要处理阶段) */
884
- update(): void;
885
- /** 延迟更新系统 */
886
- lateUpdate?(): void;
887
- /** 当实体添加到系统时的回调 */
888
- onEntityAdded?(entity: IEntity): void;
889
- /** 当实体从系统移除时的回调 */
890
- onEntityRemoved?(entity: IEntity): void;
891
- /** 当实体组件发生变化时的回调 */
892
- onEntityChanged?(entity: IEntity): void;
893
- }
894
- /**
895
- * 系统基础接口(向后兼容)
896
- *
897
- * 为现有的EntitySystem类提供更灵活的类型定义
579
+ * 为现有的EntitySystem类提供类型定义
898
580
  */
899
581
  interface ISystemBase {
900
582
  /** 系统名称 */
901
583
  readonly systemName: string;
902
- /** 系统处理的实体列表(泛型版本) */
584
+ /** 系统处理的实体列表 */
903
585
  readonly entities: readonly any[];
904
586
  /** 更新顺序/优先级 */
905
587
  updateOrder: number;
@@ -912,191 +594,12 @@ interface ISystemBase {
912
594
  /** 延迟更新系统 */
913
595
  lateUpdate?(): void;
914
596
  }
915
- /**
916
- * 场景接口
917
- *
918
- * 定义场景的基本契约
919
- */
920
- interface IScene {
921
- /** 场景名称 */
922
- name: string;
923
- /** 场景中的实体列表 */
924
- readonly entities: readonly IEntity[];
925
- /** 场景中的系统列表 */
926
- readonly systems: readonly ISystem[];
927
- /** 创建实体 */
928
- createEntity(name: string): IEntity;
929
- /** 添加实体到场景 */
930
- addEntity(entity: IEntity): void;
931
- /** 从场景移除实体 */
932
- removeEntity(entity: IEntity): void;
933
- /** 查找实体 */
934
- findEntity(name: string): IEntity | null;
935
- /** 添加系统到场景 */
936
- addSystem<T extends ISystem>(system: T): T;
937
- /** 从场景移除系统 */
938
- removeSystem(system: ISystem): void;
939
- /** 获取系统 */
940
- getSystem<T extends ISystem>(systemType: new (...args: any[]) => T): T | null;
941
- /** 更新场景 */
942
- update(): void;
943
- }
944
597
  /**
945
598
  * 组件类型定义
946
599
  *
947
600
  * 用于类型安全的组件操作
948
601
  */
949
602
  type ComponentType$1<T extends IComponent = IComponent> = new (...args: any[]) => T;
950
- /**
951
- * 原始组件类型(向后兼容)
952
- *
953
- * 用于与现有Component类的兼容
954
- */
955
- type ComponentClass<T = any> = new (...args: any[]) => T;
956
- /**
957
- * 实体查询匹配器接口
958
- *
959
- * 用于查询符合特定条件的实体
960
- */
961
- interface IMatcher {
962
- /** 必须包含的组件类型 */
963
- all(...componentTypes: ComponentType$1[]): IMatcher;
964
- /** 至少包含其中一个组件类型 */
965
- any(...componentTypes: ComponentType$1[]): IMatcher;
966
- /** 不能包含的组件类型 */
967
- exclude(...componentTypes: ComponentType$1[]): IMatcher;
968
- /** 检查实体是否匹配 */
969
- isInterestedEntity(entity: IEntity): boolean;
970
- }
971
- /**
972
- * 性能监控接口
973
- */
974
- interface IPerformanceData {
975
- /** 执行时间(毫秒) */
976
- executionTime: number;
977
- /** 调用次数 */
978
- callCount: number;
979
- /** 平均执行时间 */
980
- averageTime: number;
981
- /** 最大执行时间 */
982
- maxTime: number;
983
- /** 最小执行时间 */
984
- minTime: number;
985
- }
986
- /**
987
- * 生命周期管理接口
988
- */
989
- interface ILifecycle {
990
- /** 初始化 */
991
- initialize?(): void;
992
- /** 启动 */
993
- start?(): void;
994
- /** 更新 */
995
- update?(): void;
996
- /** 延迟更新 */
997
- lateUpdate?(): void;
998
- /** 停止 */
999
- stop?(): void;
1000
- /** 销毁 */
1001
- destroy?(): void;
1002
- }
1003
- /**
1004
- * 实体管理器接口
1005
- *
1006
- * 提供统一的实体管理和查询机制,支持高效的实体操作
1007
- */
1008
- interface IEntityManager {
1009
- /** 所有实体数量 */
1010
- readonly entityCount: number;
1011
- /** 激活的实体数量 */
1012
- readonly activeEntityCount: number;
1013
- /** 创建实体 */
1014
- createEntity(name?: string): IEntity;
1015
- /** 销毁实体 */
1016
- destroyEntity(entity: IEntity | string | number): boolean;
1017
- /** 批量销毁实体 */
1018
- destroyEntities(entities: (IEntity | string | number)[]): number;
1019
- /** 销毁所有实体 */
1020
- destroyAllEntities(): number;
1021
- /** 根据ID获取实体 */
1022
- getEntity(id: string | number): IEntity | null;
1023
- /** 根据名称获取实体 */
1024
- getEntityByName(name: string): IEntity | null;
1025
- /** 根据名称获取所有实体 */
1026
- getEntitiesByName(name: string): IEntity[];
1027
- /** 根据标签获取实体 */
1028
- getEntitiesByTag(tag: number): IEntity[];
1029
- /** 获取所有实体 */
1030
- getAllEntities(): IEntity[];
1031
- /** 获取所有激活的实体 */
1032
- getActiveEntities(): IEntity[];
1033
- /** 获取拥有指定组件的实体 */
1034
- getEntitiesWithComponent<T extends IComponent>(componentType: ComponentType$1<T>): IEntity[];
1035
- /** 获取拥有指定组件的实体及其组件 */
1036
- getEntitiesWithComponentData<T extends IComponent>(componentType: ComponentType$1<T>): Array<{
1037
- entity: IEntity;
1038
- component: T;
1039
- }>;
1040
- /** 获取拥有所有指定组件的实体 */
1041
- getEntitiesWithComponents(...componentTypes: ComponentType$1[]): IEntity[];
1042
- /** 获取拥有任一指定组件的实体 */
1043
- getEntitiesWithAnyComponent(...componentTypes: ComponentType$1[]): IEntity[];
1044
- /** 获取不包含指定组件的实体 */
1045
- getEntitiesWithoutComponent<T extends IComponent>(componentType: ComponentType$1<T>): IEntity[];
1046
- /** 对所有实体执行操作 */
1047
- forEachEntity(action: (entity: IEntity) => void): void;
1048
- /** 对符合条件的实体执行操作 */
1049
- forEachEntityWhere(predicate: (entity: IEntity) => boolean, action: (entity: IEntity) => void): void;
1050
- /** 对拥有指定组件的实体执行操作 */
1051
- forEachEntityWithComponent<T extends IComponent>(componentType: ComponentType$1<T>, action: (entity: IEntity, component: T) => void): void;
1052
- /** 查找第一个符合条件的实体 */
1053
- findEntity(predicate: (entity: IEntity) => boolean): IEntity | null;
1054
- /** 查找所有符合条件的实体 */
1055
- findEntities(predicate: (entity: IEntity) => boolean): IEntity[];
1056
- /** 获取统计信息 */
1057
- getStatistics(): {
1058
- totalEntities: number;
1059
- activeEntities: number;
1060
- destroyedEntities: number;
1061
- entitiesByTag: Map<number, number>;
1062
- componentsCount: Map<string, number>;
1063
- };
1064
- /** 清理已销毁的实体 */
1065
- cleanup(): number;
1066
- /** 压缩存储空间 */
1067
- compact(): void;
1068
- }
1069
- /**
1070
- * 实体查询构建器接口
1071
- *
1072
- * 提供流式API构建复杂的实体查询条件
1073
- */
1074
- interface IEntityQueryBuilder {
1075
- /** 必须包含所有指定组件 */
1076
- withAll(...componentTypes: ComponentType$1[]): IEntityQueryBuilder;
1077
- /** 必须包含任一指定组件 */
1078
- withAny(...componentTypes: ComponentType$1[]): IEntityQueryBuilder;
1079
- /** 必须不包含指定组件 */
1080
- without(...componentTypes: ComponentType$1[]): IEntityQueryBuilder;
1081
- /** 必须包含指定标签 */
1082
- withTag(tag: number): IEntityQueryBuilder;
1083
- /** 必须不包含指定标签 */
1084
- withoutTag(tag: number): IEntityQueryBuilder;
1085
- /** 必须处于激活状态 */
1086
- active(): IEntityQueryBuilder;
1087
- /** 必须处于启用状态 */
1088
- enabled(): IEntityQueryBuilder;
1089
- /** 自定义过滤条件 */
1090
- where(predicate: (entity: IEntity) => boolean): IEntityQueryBuilder;
1091
- /** 执行查询,返回所有匹配的实体 */
1092
- execute(): IEntity[];
1093
- /** 执行查询,返回第一个匹配的实体 */
1094
- first(): IEntity | null;
1095
- /** 执行查询,返回匹配实体的数量 */
1096
- count(): number;
1097
- /** 对查询结果执行操作 */
1098
- forEach(action: (entity: IEntity) => void): void;
1099
- }
1100
603
  /**
1101
604
  * 事件总线接口
1102
605
  * 提供类型安全的事件发布订阅机制
@@ -1798,8 +1301,8 @@ declare class ComponentCache {
1798
1301
  * // 获取组件
1799
1302
  * const health = entity.getComponent(HealthComponent);
1800
1303
  *
1801
- * // 设置位置
1802
- * entity.position = new Vector2(100, 200);
1304
+ * // 添加位置组件
1305
+ * entity.addComponent(new PositionComponent(100, 200));
1803
1306
  *
1804
1307
  * // 添加子实体
1805
1308
  * const weapon = new Entity("Weapon", 2);
@@ -4220,7 +3723,7 @@ declare function createECSAPI(scene: Scene, querySystem: QuerySystem, eventSyste
4220
3723
  * 游戏引擎核心类
4221
3724
  *
4222
3725
  * 负责管理游戏的生命周期、场景切换、全局管理器和定时器系统。
4223
- * 提供统一的游戏循环和事件分发机制。
3726
+ * 提供统一的游戏循环管理。
4224
3727
  *
4225
3728
  * @example
4226
3729
  * ```typescript
@@ -4230,6 +3733,12 @@ declare function createECSAPI(scene: Scene, querySystem: QuerySystem, eventSyste
4230
3733
  * // 设置场景
4231
3734
  * Core.scene = new MyScene();
4232
3735
  *
3736
+ * // 在游戏循环中更新(Laya引擎示例)
3737
+ * Laya.timer.frameLoop(1, this, () => {
3738
+ * const deltaTime = Laya.timer.delta / 1000;
3739
+ * Core.update(deltaTime);
3740
+ * });
3741
+ *
4233
3742
  * // 调度定时器
4234
3743
  * Core.schedule(1.0, false, null, (timer) => {
4235
3744
  * console.log("1秒后执行");
@@ -4237,12 +3746,6 @@ declare function createECSAPI(scene: Scene, querySystem: QuerySystem, eventSyste
4237
3746
  * ```
4238
3747
  */
4239
3748
  declare class Core {
4240
- /**
4241
- * 核心事件发射器
4242
- *
4243
- * 用于发布和订阅核心级别的事件,如帧更新、场景切换等。
4244
- */
4245
- static emitter: Emitter<CoreEvents>;
4246
3749
  /**
4247
3750
  * 游戏暂停状态
4248
3751
  *
@@ -4339,10 +3842,36 @@ declare class Core {
4339
3842
  * 如果实例已存在,则返回现有实例。
4340
3843
  *
4341
3844
  * @param debug - 是否为调试模式,默认为true
4342
- * @param options - 额外的配置选项
4343
3845
  * @returns Core实例
4344
3846
  */
4345
3847
  static create(debug?: boolean): Core;
3848
+ /**
3849
+ * 更新游戏逻辑
3850
+ *
3851
+ * 此方法应该在游戏引擎的更新循环中调用。
3852
+ *
3853
+ * @param deltaTime - 外部引擎提供的帧时间间隔(秒)
3854
+ *
3855
+ * @example
3856
+ * ```typescript
3857
+ * // Laya引擎
3858
+ * Laya.timer.frameLoop(1, this, () => {
3859
+ * const deltaTime = Laya.timer.delta / 1000;
3860
+ * Core.update(deltaTime);
3861
+ * });
3862
+ *
3863
+ * // Cocos Creator
3864
+ * update(deltaTime: number) {
3865
+ * Core.update(deltaTime);
3866
+ * }
3867
+ *
3868
+ * // Unity (C#)
3869
+ * void Update() {
3870
+ * Core.Update(Time.deltaTime);
3871
+ * }
3872
+ * ```
3873
+ */
3874
+ static update(deltaTime: number): void;
4346
3875
  /**
4347
3876
  * 注册全局管理器
4348
3877
  *
@@ -4397,13 +3926,185 @@ declare class Core {
4397
3926
  */
4398
3927
  protected initialize(): void;
4399
3928
  /**
4400
- * 游戏主循环更新
3929
+ * 内部更新方法
4401
3930
  *
4402
- * 每帧调用,负责更新时间系统、全局管理器和当前场景。
4403
- *
4404
- * @param currentTime - 当前时间戳,默认为-1(使用系统时间)
3931
+ * @param deltaTime - 帧时间间隔(秒)
3932
+ */
3933
+ private updateInternal;
3934
+ }
3935
+
3936
+ /**
3937
+ * 用于包装事件的一个小类
3938
+ */
3939
+ declare class FuncPack {
3940
+ /** 函数 */
3941
+ func: Function;
3942
+ /** 上下文 */
3943
+ context: any;
3944
+ constructor(func: Function, context: any);
3945
+ }
3946
+ /**
3947
+ * 用于事件管理
3948
+ */
3949
+ declare class Emitter<T> {
3950
+ private _messageTable;
3951
+ constructor();
3952
+ /**
3953
+ * 开始监听项
3954
+ * @param eventType 监听类型
3955
+ * @param handler 监听函数
3956
+ * @param context 监听上下文
4405
3957
  */
4406
- protected update(currentTime?: number): void;
3958
+ addObserver(eventType: T, handler: Function, context: any): void;
3959
+ /**
3960
+ * 移除监听项
3961
+ * @param eventType 事件类型
3962
+ * @param handler 事件函数
3963
+ */
3964
+ removeObserver(eventType: T, handler: Function): void;
3965
+ /**
3966
+ * 触发该事件
3967
+ * @param eventType 事件类型
3968
+ * @param data 事件数据
3969
+ */
3970
+ emit(eventType: T, ...data: any[]): void;
3971
+ /**
3972
+ * 判断是否存在该类型的观察者
3973
+ * @param eventType 事件类型
3974
+ * @param handler 事件函数
3975
+ */
3976
+ hasObserver(eventType: T, handler: Function): boolean;
3977
+ }
3978
+
3979
+ /**
3980
+ * ECS事件类型枚举
3981
+ * 定义实体组件系统中的所有事件类型
3982
+ */
3983
+ declare enum ECSEventType {
3984
+ ENTITY_CREATED = "entity:created",
3985
+ ENTITY_DESTROYED = "entity:destroyed",
3986
+ ENTITY_ENABLED = "entity:enabled",
3987
+ ENTITY_DISABLED = "entity:disabled",
3988
+ ENTITY_TAG_ADDED = "entity:tag:added",
3989
+ ENTITY_TAG_REMOVED = "entity:tag:removed",
3990
+ ENTITY_NAME_CHANGED = "entity:name:changed",
3991
+ COMPONENT_ADDED = "component:added",
3992
+ COMPONENT_REMOVED = "component:removed",
3993
+ COMPONENT_MODIFIED = "component:modified",
3994
+ COMPONENT_ENABLED = "component:enabled",
3995
+ COMPONENT_DISABLED = "component:disabled",
3996
+ SYSTEM_ADDED = "system:added",
3997
+ SYSTEM_REMOVED = "system:removed",
3998
+ SYSTEM_ENABLED = "system:enabled",
3999
+ SYSTEM_DISABLED = "system:disabled",
4000
+ SYSTEM_PROCESSING_START = "system:processing:start",
4001
+ SYSTEM_PROCESSING_END = "system:processing:end",
4002
+ SYSTEM_ERROR = "system:error",
4003
+ SCENE_CREATED = "scene:created",
4004
+ SCENE_DESTROYED = "scene:destroyed",
4005
+ SCENE_ACTIVATED = "scene:activated",
4006
+ SCENE_DEACTIVATED = "scene:deactivated",
4007
+ SCENE_PAUSED = "scene:paused",
4008
+ SCENE_RESUMED = "scene:resumed",
4009
+ QUERY_EXECUTED = "query:executed",
4010
+ QUERY_CACHE_HIT = "query:cache:hit",
4011
+ QUERY_CACHE_MISS = "query:cache:miss",
4012
+ QUERY_OPTIMIZED = "query:optimized",
4013
+ PERFORMANCE_WARNING = "performance:warning",
4014
+ PERFORMANCE_CRITICAL = "performance:critical",
4015
+ MEMORY_USAGE_HIGH = "memory:usage:high",
4016
+ FRAME_RATE_DROP = "frame:rate:drop",
4017
+ INDEX_CREATED = "index:created",
4018
+ INDEX_UPDATED = "index:updated",
4019
+ INDEX_OPTIMIZED = "index:optimized",
4020
+ ARCHETYPE_CREATED = "archetype:created",
4021
+ ARCHETYPE_ENTITY_ADDED = "archetype:entity:added",
4022
+ ARCHETYPE_ENTITY_REMOVED = "archetype:entity:removed",
4023
+ DIRTY_MARK_ADDED = "dirty:mark:added",
4024
+ DIRTY_BATCH_PROCESSED = "dirty:batch:processed",
4025
+ ERROR_OCCURRED = "error:occurred",
4026
+ WARNING_ISSUED = "warning:issued",
4027
+ FRAMEWORK_INITIALIZED = "framework:initialized",
4028
+ FRAMEWORK_SHUTDOWN = "framework:shutdown",
4029
+ DEBUG_INFO = "debug:info",
4030
+ DEBUG_STATS_UPDATED = "debug:stats:updated"
4031
+ }
4032
+ /**
4033
+ * 事件优先级枚举
4034
+ * 定义事件处理的优先级级别
4035
+ */
4036
+ declare enum EventPriority {
4037
+ LOWEST = 0,
4038
+ LOW = 25,
4039
+ NORMAL = 50,
4040
+ HIGH = 75,
4041
+ HIGHEST = 100,
4042
+ CRITICAL = 200
4043
+ }
4044
+ /**
4045
+ * 预定义的事件类型常量
4046
+ * 提供类型安全的事件类型字符串
4047
+ */
4048
+ declare const EVENT_TYPES: {
4049
+ readonly ENTITY: {
4050
+ readonly CREATED: ECSEventType.ENTITY_CREATED;
4051
+ readonly DESTROYED: ECSEventType.ENTITY_DESTROYED;
4052
+ readonly ENABLED: ECSEventType.ENTITY_ENABLED;
4053
+ readonly DISABLED: ECSEventType.ENTITY_DISABLED;
4054
+ readonly TAG_ADDED: ECSEventType.ENTITY_TAG_ADDED;
4055
+ readonly TAG_REMOVED: ECSEventType.ENTITY_TAG_REMOVED;
4056
+ readonly NAME_CHANGED: ECSEventType.ENTITY_NAME_CHANGED;
4057
+ };
4058
+ readonly COMPONENT: {
4059
+ readonly ADDED: ECSEventType.COMPONENT_ADDED;
4060
+ readonly REMOVED: ECSEventType.COMPONENT_REMOVED;
4061
+ readonly MODIFIED: ECSEventType.COMPONENT_MODIFIED;
4062
+ readonly ENABLED: ECSEventType.COMPONENT_ENABLED;
4063
+ readonly DISABLED: ECSEventType.COMPONENT_DISABLED;
4064
+ };
4065
+ readonly SYSTEM: {
4066
+ readonly ADDED: ECSEventType.SYSTEM_ADDED;
4067
+ readonly REMOVED: ECSEventType.SYSTEM_REMOVED;
4068
+ readonly ENABLED: ECSEventType.SYSTEM_ENABLED;
4069
+ readonly DISABLED: ECSEventType.SYSTEM_DISABLED;
4070
+ readonly PROCESSING_START: ECSEventType.SYSTEM_PROCESSING_START;
4071
+ readonly PROCESSING_END: ECSEventType.SYSTEM_PROCESSING_END;
4072
+ readonly ERROR: ECSEventType.SYSTEM_ERROR;
4073
+ };
4074
+ readonly PERFORMANCE: {
4075
+ readonly WARNING: ECSEventType.PERFORMANCE_WARNING;
4076
+ readonly CRITICAL: ECSEventType.PERFORMANCE_CRITICAL;
4077
+ readonly MEMORY_HIGH: ECSEventType.MEMORY_USAGE_HIGH;
4078
+ readonly FRAME_DROP: ECSEventType.FRAME_RATE_DROP;
4079
+ };
4080
+ };
4081
+ /**
4082
+ * 事件类型验证器
4083
+ * 验证事件类型是否有效
4084
+ */
4085
+ declare class EventTypeValidator {
4086
+ private static validTypes;
4087
+ /**
4088
+ * 验证事件类型是否有效
4089
+ * @param eventType 事件类型
4090
+ * @returns 是否有效
4091
+ */
4092
+ static isValid(eventType: string): boolean;
4093
+ /**
4094
+ * 获取所有有效的事件类型
4095
+ * @returns 事件类型数组
4096
+ */
4097
+ static getAllValidTypes(): string[];
4098
+ /**
4099
+ * 添加自定义事件类型
4100
+ * @param eventType 事件类型
4101
+ */
4102
+ static addCustomType(eventType: string): void;
4103
+ /**
4104
+ * 移除自定义事件类型
4105
+ * @param eventType 事件类型
4106
+ */
4107
+ static removeCustomType(eventType: string): void;
4407
4108
  }
4408
4109
 
4409
4110
  /**
@@ -5343,18 +5044,10 @@ declare class Time {
5343
5044
  */
5344
5045
  static frameCount: number;
5345
5046
  /**
5346
- * 上一帧的时间戳
5347
- */
5348
- private static _lastTime;
5349
- /**
5350
- * 是否为第一次更新
5351
- */
5352
- private static _isFirstUpdate;
5353
- /**
5354
- * 更新时间信息
5355
- * @param currentTime 当前时间戳(毫秒)
5047
+ * 使用外部引擎提供的deltaTime更新时间信息
5048
+ * @param deltaTime 外部引擎提供的帧时间间隔(秒)
5356
5049
  */
5357
- static update(currentTime?: number): void;
5050
+ static update(deltaTime: number): void;
5358
5051
  /**
5359
5052
  * 场景改变时重置时间
5360
5053
  */
@@ -5368,5 +5061,5 @@ declare class Time {
5368
5061
  static checkEvery(interval: number, lastTime: number): boolean;
5369
5062
  }
5370
5063
 
5371
- export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentIndexManager, ComponentPool, ComponentStorage, ComponentTransform, ComponentTypeManager, Core, CoreEvents, DirtyFlag, DirtyTrackingSystem, ECSEventType, ECSFluentAPI, EVENT_TYPES, Emitter, Entity, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, FuncPack, GlobalEventBus, GlobalManager, HashComponentIndex, IdentifierPool, IndexType, IndexUpdateBatcher, IntervalSystem, LogType, Matcher, NumberExtension, PassiveSystem, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, createECSAPI };
5372
- export type { Archetype, ArchetypeQueryResult, ComponentClass, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EventListenerConfig, EventStats, IComponent, IComponentEventData, IEntity, IEntityBase, IEntityEventData, IEntityManager, IEntityQueryBuilder, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILifecycle, IMatcher, IPerformanceData, IPerformanceEventData, IPoolable, IScene, ISceneEventData, ISystem, ISystemBase, ISystemEventData, ITimer, IUpdateOrderComparable, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats };
5064
+ export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentIndexManager, ComponentPool, ComponentStorage, ComponentTypeManager, Core, DirtyFlag, DirtyTrackingSystem, ECSEventType, ECSFluentAPI, EVENT_TYPES, Emitter, Entity, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, FuncPack, GlobalEventBus, GlobalManager, HashComponentIndex, IdentifierPool, IndexType, IndexUpdateBatcher, IntervalSystem, Matcher, NumberExtension, PassiveSystem, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, createECSAPI };
5065
+ export type { Archetype, ArchetypeQueryResult, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EventListenerConfig, EventStats, IComponent, IComponentEventData, IEntityEventData, IEventBus, IEventData, IEventListenerConfig, IEventStats, IPerformanceEventData, IPoolable, ISceneEventData, ISystemBase, ISystemEventData, ITimer, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats };