@esengine/ecs-framework 2.1.14 → 2.1.16
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/.npmignore +0 -6
- package/README.md +265 -193
- package/index.d.ts +34 -545
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.umd.js +1 -1
- 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.1.
|
|
2
|
+
* @esengine/ecs-framework v2.1.16
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -258,6 +258,14 @@ declare class Timer implements ITimer {
|
|
|
258
258
|
_isDone: boolean;
|
|
259
259
|
_elapsedTime: number;
|
|
260
260
|
getContext<T>(): T;
|
|
261
|
+
/**
|
|
262
|
+
* 定时器是否已完成
|
|
263
|
+
*/
|
|
264
|
+
get isDone(): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* 定时器已运行的时间
|
|
267
|
+
*/
|
|
268
|
+
get elapsedTime(): number;
|
|
261
269
|
reset(): void;
|
|
262
270
|
stop(): void;
|
|
263
271
|
tick(): boolean;
|
|
@@ -306,7 +314,7 @@ interface PerformanceData {
|
|
|
306
314
|
/**
|
|
307
315
|
* 性能统计信息
|
|
308
316
|
*/
|
|
309
|
-
interface PerformanceStats
|
|
317
|
+
interface PerformanceStats {
|
|
310
318
|
/** 总执行时间 */
|
|
311
319
|
totalTime: number;
|
|
312
320
|
/** 平均执行时间 */
|
|
@@ -457,7 +465,7 @@ declare class PerformanceMonitor {
|
|
|
457
465
|
* @param systemName 系统名称
|
|
458
466
|
* @returns 统计信息或undefined
|
|
459
467
|
*/
|
|
460
|
-
getSystemStats(systemName: string): PerformanceStats
|
|
468
|
+
getSystemStats(systemName: string): PerformanceStats | undefined;
|
|
461
469
|
/**
|
|
462
470
|
* 获取所有系统的性能数据
|
|
463
471
|
* @returns 所有系统的性能数据
|
|
@@ -467,7 +475,7 @@ declare class PerformanceMonitor {
|
|
|
467
475
|
* 获取所有系统的统计信息
|
|
468
476
|
* @returns 所有系统的统计信息
|
|
469
477
|
*/
|
|
470
|
-
getAllSystemStats(): Map<string, PerformanceStats
|
|
478
|
+
getAllSystemStats(): Map<string, PerformanceStats>;
|
|
471
479
|
/**
|
|
472
480
|
* 获取性能报告
|
|
473
481
|
* @returns 格式化的性能报告字符串
|
|
@@ -737,24 +745,6 @@ declare class PoolManager {
|
|
|
737
745
|
/**
|
|
738
746
|
* 框架核心类型定义
|
|
739
747
|
*/
|
|
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
748
|
/**
|
|
759
749
|
* 组件接口
|
|
760
750
|
*
|
|
@@ -781,125 +771,14 @@ interface IComponent {
|
|
|
781
771
|
update(): void;
|
|
782
772
|
}
|
|
783
773
|
/**
|
|
784
|
-
*
|
|
785
|
-
*
|
|
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
|
-
* 实体基础接口(向后兼容)
|
|
774
|
+
* 系统基础接口
|
|
832
775
|
*
|
|
833
|
-
* 为现有的
|
|
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类提供更灵活的类型定义
|
|
776
|
+
* 为现有的EntitySystem类提供类型定义
|
|
898
777
|
*/
|
|
899
778
|
interface ISystemBase {
|
|
900
779
|
/** 系统名称 */
|
|
901
780
|
readonly systemName: string;
|
|
902
|
-
/**
|
|
781
|
+
/** 系统处理的实体列表 */
|
|
903
782
|
readonly entities: readonly any[];
|
|
904
783
|
/** 更新顺序/优先级 */
|
|
905
784
|
updateOrder: number;
|
|
@@ -912,191 +791,12 @@ interface ISystemBase {
|
|
|
912
791
|
/** 延迟更新系统 */
|
|
913
792
|
lateUpdate?(): void;
|
|
914
793
|
}
|
|
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
794
|
/**
|
|
945
795
|
* 组件类型定义
|
|
946
796
|
*
|
|
947
797
|
* 用于类型安全的组件操作
|
|
948
798
|
*/
|
|
949
799
|
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
800
|
/**
|
|
1101
801
|
* 事件总线接口
|
|
1102
802
|
* 提供类型安全的事件发布订阅机制
|
|
@@ -1798,8 +1498,8 @@ declare class ComponentCache {
|
|
|
1798
1498
|
* // 获取组件
|
|
1799
1499
|
* const health = entity.getComponent(HealthComponent);
|
|
1800
1500
|
*
|
|
1801
|
-
* //
|
|
1802
|
-
* entity.
|
|
1501
|
+
* // 添加位置组件
|
|
1502
|
+
* entity.addComponent(new PositionComponent(100, 200));
|
|
1803
1503
|
*
|
|
1804
1504
|
* // 添加子实体
|
|
1805
1505
|
* const weapon = new Entity("Weapon", 2);
|
|
@@ -2683,7 +2383,7 @@ declare abstract class EntitySystem implements ISystemBase {
|
|
|
2683
2383
|
*
|
|
2684
2384
|
* @returns 性能统计或undefined
|
|
2685
2385
|
*/
|
|
2686
|
-
getPerformanceStats(): PerformanceStats
|
|
2386
|
+
getPerformanceStats(): PerformanceStats | undefined;
|
|
2687
2387
|
/**
|
|
2688
2388
|
* 重置系统的性能数据
|
|
2689
2389
|
*/
|
|
@@ -3014,7 +2714,7 @@ declare class ArchetypeSystem {
|
|
|
3014
2714
|
/**
|
|
3015
2715
|
* 实体查询结果接口
|
|
3016
2716
|
*/
|
|
3017
|
-
interface QueryResult
|
|
2717
|
+
interface QueryResult {
|
|
3018
2718
|
entities: Entity[];
|
|
3019
2719
|
count: number;
|
|
3020
2720
|
/** 查询执行时间(毫秒) */
|
|
@@ -3045,7 +2745,6 @@ interface QueryResult$1 {
|
|
|
3045
2745
|
*/
|
|
3046
2746
|
declare class QuerySystem {
|
|
3047
2747
|
private entities;
|
|
3048
|
-
private wasmAvailable;
|
|
3049
2748
|
private entityIndex;
|
|
3050
2749
|
private indexDirty;
|
|
3051
2750
|
private queryCache;
|
|
@@ -3059,13 +2758,6 @@ declare class QuerySystem {
|
|
|
3059
2758
|
private dirtyTrackingSystem;
|
|
3060
2759
|
private queryStats;
|
|
3061
2760
|
constructor();
|
|
3062
|
-
/**
|
|
3063
|
-
* 初始化WebAssembly支持
|
|
3064
|
-
*
|
|
3065
|
-
* 自动检测运行环境并启用WebAssembly计算加速。
|
|
3066
|
-
* 如果WebAssembly不可用,系统将自动回退到JavaScript实现。
|
|
3067
|
-
*/
|
|
3068
|
-
private initializeWasm;
|
|
3069
2761
|
/**
|
|
3070
2762
|
* 设置实体列表并重建索引
|
|
3071
2763
|
*
|
|
@@ -3142,7 +2834,7 @@ declare class QuerySystem {
|
|
|
3142
2834
|
* console.log(`找到 ${result.count} 个移动实体`);
|
|
3143
2835
|
* ```
|
|
3144
2836
|
*/
|
|
3145
|
-
queryAll(...componentTypes: ComponentType[]): QueryResult
|
|
2837
|
+
queryAll(...componentTypes: ComponentType[]): QueryResult;
|
|
3146
2838
|
/**
|
|
3147
2839
|
* 多组件查询算法
|
|
3148
2840
|
*
|
|
@@ -3179,7 +2871,7 @@ declare class QuerySystem {
|
|
|
3179
2871
|
* console.log(`找到 ${result.count} 个装备实体`);
|
|
3180
2872
|
* ```
|
|
3181
2873
|
*/
|
|
3182
|
-
queryAny(...componentTypes: ComponentType[]): QueryResult
|
|
2874
|
+
queryAny(...componentTypes: ComponentType[]): QueryResult;
|
|
3183
2875
|
/**
|
|
3184
2876
|
* 查询不包含任何指定组件的实体
|
|
3185
2877
|
*
|
|
@@ -3196,7 +2888,7 @@ declare class QuerySystem {
|
|
|
3196
2888
|
* console.log(`找到 ${result.count} 个静态实体`);
|
|
3197
2889
|
* ```
|
|
3198
2890
|
*/
|
|
3199
|
-
queryNone(...componentTypes: ComponentType[]): QueryResult
|
|
2891
|
+
queryNone(...componentTypes: ComponentType[]): QueryResult;
|
|
3200
2892
|
/**
|
|
3201
2893
|
* 按标签查询实体
|
|
3202
2894
|
*
|
|
@@ -3212,7 +2904,7 @@ declare class QuerySystem {
|
|
|
3212
2904
|
* const players = querySystem.queryByTag(PLAYER_TAG);
|
|
3213
2905
|
* ```
|
|
3214
2906
|
*/
|
|
3215
|
-
queryByTag(tag: number): QueryResult
|
|
2907
|
+
queryByTag(tag: number): QueryResult;
|
|
3216
2908
|
/**
|
|
3217
2909
|
* 按名称查询实体
|
|
3218
2910
|
*
|
|
@@ -3228,7 +2920,7 @@ declare class QuerySystem {
|
|
|
3228
2920
|
* const player = querySystem.queryByName("Player");
|
|
3229
2921
|
* ```
|
|
3230
2922
|
*/
|
|
3231
|
-
queryByName(name: string): QueryResult
|
|
2923
|
+
queryByName(name: string): QueryResult;
|
|
3232
2924
|
/**
|
|
3233
2925
|
* 按单个组件类型查询实体
|
|
3234
2926
|
*
|
|
@@ -3244,7 +2936,7 @@ declare class QuerySystem {
|
|
|
3244
2936
|
* const entitiesWithPosition = querySystem.queryByComponent(PositionComponent);
|
|
3245
2937
|
* ```
|
|
3246
2938
|
*/
|
|
3247
|
-
queryByComponent<T extends Component>(componentType: ComponentType<T>): QueryResult
|
|
2939
|
+
queryByComponent<T extends Component>(componentType: ComponentType<T>): QueryResult;
|
|
3248
2940
|
/**
|
|
3249
2941
|
* 从缓存获取查询结果
|
|
3250
2942
|
*/
|
|
@@ -3271,7 +2963,6 @@ declare class QuerySystem {
|
|
|
3271
2963
|
* 批量更新实体组件
|
|
3272
2964
|
*
|
|
3273
2965
|
* 对大量实体进行批量组件更新操作。
|
|
3274
|
-
* 当更新数量超过阈值时,系统会自动使用WebAssembly加速。
|
|
3275
2966
|
*
|
|
3276
2967
|
* @param updates 更新操作列表,包含实体ID和新的组件掩码
|
|
3277
2968
|
*
|
|
@@ -3289,34 +2980,6 @@ declare class QuerySystem {
|
|
|
3289
2980
|
entityId: number;
|
|
3290
2981
|
componentMask: bigint;
|
|
3291
2982
|
}>): void;
|
|
3292
|
-
/**
|
|
3293
|
-
* JavaScript实现的批量更新
|
|
3294
|
-
*/
|
|
3295
|
-
private batchUpdateComponentsJS;
|
|
3296
|
-
/**
|
|
3297
|
-
* 获取加速状态信息
|
|
3298
|
-
*
|
|
3299
|
-
* 返回当前查询系统的加速状态和性能信息。
|
|
3300
|
-
* 包括WebAssembly可用性、缓存统计等详细信息。
|
|
3301
|
-
*
|
|
3302
|
-
* @returns 加速状态信息对象
|
|
3303
|
-
*/
|
|
3304
|
-
getAccelerationStatus(): {
|
|
3305
|
-
wasmEnabled: boolean;
|
|
3306
|
-
currentProvider: string;
|
|
3307
|
-
availableProviders: string[];
|
|
3308
|
-
performanceInfo?: any;
|
|
3309
|
-
};
|
|
3310
|
-
/**
|
|
3311
|
-
* 切换加速提供者
|
|
3312
|
-
*
|
|
3313
|
-
* 兼容性接口,保持向后兼容。
|
|
3314
|
-
* 系统会自动选择最佳的实现方式。
|
|
3315
|
-
*
|
|
3316
|
-
* @param providerName 提供者名称
|
|
3317
|
-
* @returns 是否切换成功
|
|
3318
|
-
*/
|
|
3319
|
-
switchAccelerationProvider(providerName: string): Promise<boolean>;
|
|
3320
2983
|
/**
|
|
3321
2984
|
* 创建组件掩码
|
|
3322
2985
|
*
|
|
@@ -3343,7 +3006,6 @@ declare class QuerySystem {
|
|
|
3343
3006
|
tagIndexSize: number;
|
|
3344
3007
|
nameIndexSize: number;
|
|
3345
3008
|
};
|
|
3346
|
-
accelerationStatus: ReturnType<QuerySystem['getAccelerationStatus']>;
|
|
3347
3009
|
queryStats: {
|
|
3348
3010
|
totalQueries: number;
|
|
3349
3011
|
cacheHits: number;
|
|
@@ -3358,6 +3020,10 @@ declare class QuerySystem {
|
|
|
3358
3020
|
archetypeSystem: any;
|
|
3359
3021
|
dirtyTracking: any;
|
|
3360
3022
|
};
|
|
3023
|
+
cacheStats: {
|
|
3024
|
+
size: number;
|
|
3025
|
+
hitRate: string;
|
|
3026
|
+
};
|
|
3361
3027
|
};
|
|
3362
3028
|
/**
|
|
3363
3029
|
* 切换组件索引类型
|
|
@@ -3444,7 +3110,7 @@ declare class QueryBuilder {
|
|
|
3444
3110
|
*
|
|
3445
3111
|
* @returns 查询结果,包含匹配的实体和性能信息
|
|
3446
3112
|
*/
|
|
3447
|
-
execute(): QueryResult
|
|
3113
|
+
execute(): QueryResult;
|
|
3448
3114
|
/**
|
|
3449
3115
|
* 创建组件掩码
|
|
3450
3116
|
*/
|
|
@@ -3751,9 +3417,8 @@ declare class Scene {
|
|
|
3751
3417
|
get systems(): EntitySystem[];
|
|
3752
3418
|
/**
|
|
3753
3419
|
* 创建场景实例
|
|
3754
|
-
* @param enableWasmAcceleration 是否启用WebAssembly加速,默认为true
|
|
3755
3420
|
*/
|
|
3756
|
-
constructor(
|
|
3421
|
+
constructor();
|
|
3757
3422
|
/**
|
|
3758
3423
|
* 初始化场景
|
|
3759
3424
|
*
|
|
@@ -4377,16 +4042,7 @@ declare class Core {
|
|
|
4377
4042
|
* @param options - 额外的配置选项
|
|
4378
4043
|
* @returns Core实例
|
|
4379
4044
|
*/
|
|
4380
|
-
static create(debug?: boolean
|
|
4381
|
-
disableWasm?: boolean;
|
|
4382
|
-
}): Core;
|
|
4383
|
-
/**
|
|
4384
|
-
* 禁用WASM支持
|
|
4385
|
-
*
|
|
4386
|
-
* 当WASM加载失败或在不支持的环境中使用时调用。
|
|
4387
|
-
* 这将使ECS系统使用JavaScript回退实现。
|
|
4388
|
-
*/
|
|
4389
|
-
static disableWasm(): void;
|
|
4045
|
+
static create(debug?: boolean): Core;
|
|
4390
4046
|
/**
|
|
4391
4047
|
* 注册全局管理器
|
|
4392
4048
|
*
|
|
@@ -5412,172 +5068,5 @@ declare class Time {
|
|
|
5412
5068
|
static checkEvery(interval: number, lastTime: number): boolean;
|
|
5413
5069
|
}
|
|
5414
5070
|
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
*/
|
|
5418
|
-
type EntityId = number;
|
|
5419
|
-
type ComponentMask = bigint;
|
|
5420
|
-
interface QueryResult {
|
|
5421
|
-
entities: Uint32Array;
|
|
5422
|
-
count: number;
|
|
5423
|
-
}
|
|
5424
|
-
interface PerformanceStats {
|
|
5425
|
-
entityCount: number;
|
|
5426
|
-
indexCount: number;
|
|
5427
|
-
queryCount: number;
|
|
5428
|
-
updateCount: number;
|
|
5429
|
-
wasmEnabled: boolean;
|
|
5430
|
-
}
|
|
5431
|
-
interface WasmEcsCoreInstance {
|
|
5432
|
-
create_entity(): number;
|
|
5433
|
-
destroy_entity(entity_id: number): boolean;
|
|
5434
|
-
update_entity_mask(entity_id: number, mask: bigint): void;
|
|
5435
|
-
batch_update_masks(entity_ids: Uint32Array, masks: BigUint64Array): void;
|
|
5436
|
-
query_entities(mask: bigint, max_results: number): number;
|
|
5437
|
-
get_query_result_count(): number;
|
|
5438
|
-
query_cached(mask: bigint): number;
|
|
5439
|
-
get_cached_query_count(mask: bigint): number;
|
|
5440
|
-
query_multiple_components(masks: BigUint64Array, max_results: number): number;
|
|
5441
|
-
query_with_exclusion(include_mask: bigint, exclude_mask: bigint, max_results: number): number;
|
|
5442
|
-
get_entity_mask(entity_id: number): bigint;
|
|
5443
|
-
entity_exists(entity_id: number): boolean;
|
|
5444
|
-
get_entity_count(): number;
|
|
5445
|
-
get_performance_stats(): Array<any>;
|
|
5446
|
-
clear(): void;
|
|
5447
|
-
rebuild_query_cache(): void;
|
|
5448
|
-
free?(): void;
|
|
5449
|
-
}
|
|
5450
|
-
interface WasmModule {
|
|
5451
|
-
EcsCore: new () => WasmEcsCoreInstance;
|
|
5452
|
-
create_component_mask: (componentIds: Uint32Array) => ComponentMask;
|
|
5453
|
-
mask_contains_component: (mask: ComponentMask, componentId: number) => boolean;
|
|
5454
|
-
default: (input?: any) => Promise<any>;
|
|
5455
|
-
initSync?: (input: any) => any;
|
|
5456
|
-
memory?: WebAssembly.Memory;
|
|
5457
|
-
}
|
|
5458
|
-
|
|
5459
|
-
/**
|
|
5460
|
-
* WASM模块加载器
|
|
5461
|
-
*/
|
|
5462
|
-
|
|
5463
|
-
declare class WasmLoader {
|
|
5464
|
-
private wasmModule;
|
|
5465
|
-
private wasmCore;
|
|
5466
|
-
private silent;
|
|
5467
|
-
setSilent(silent: boolean): void;
|
|
5468
|
-
/**
|
|
5469
|
-
* 手动初始化WASM模块
|
|
5470
|
-
*
|
|
5471
|
-
* @param wasmFactory WASM工厂函数(从.js文件导入的default)
|
|
5472
|
-
* @param wasmFile WASM文件数据
|
|
5473
|
-
* @returns 是否初始化成功
|
|
5474
|
-
*
|
|
5475
|
-
* @example
|
|
5476
|
-
* ```typescript
|
|
5477
|
-
* import { ecsCore } from '@esengine/ecs-framework';
|
|
5478
|
-
*
|
|
5479
|
-
* // 1. 导入WASM的JS文件
|
|
5480
|
-
* import('./ecs_wasm_core.js').then(({ default: wasmFactory }) => {
|
|
5481
|
-
* // 2. 加载WASM文件(具体方式根据引擎而定)
|
|
5482
|
-
* // Cocos Creator: this.loadWasmOrAsm("wasmFiles", "ecs_wasm_core", "uuid")
|
|
5483
|
-
* // 其他环境: fetch('./ecs_wasm_core_bg.wasm')
|
|
5484
|
-
* loadWasmFile().then((wasmFile) => {
|
|
5485
|
-
* // 3. 手动初始化ECS的WASM支持
|
|
5486
|
-
* ecsCore.initializeWasm(wasmFactory, wasmFile).then((success) => {
|
|
5487
|
-
* if (success) {
|
|
5488
|
-
* console.log("ECS WASM初始化成功");
|
|
5489
|
-
* } else {
|
|
5490
|
-
* console.log("ECS WASM初始化失败,使用JavaScript回退");
|
|
5491
|
-
* }
|
|
5492
|
-
* });
|
|
5493
|
-
* });
|
|
5494
|
-
* });
|
|
5495
|
-
* ```
|
|
5496
|
-
*/
|
|
5497
|
-
initializeWasm(wasmFactory: any, wasmFile: any): Promise<boolean>;
|
|
5498
|
-
/**
|
|
5499
|
-
* 通用WASM初始化方法
|
|
5500
|
-
*/
|
|
5501
|
-
private initWasmInstance;
|
|
5502
|
-
loadWasmModule(): Promise<boolean>;
|
|
5503
|
-
private initializeWasmModule;
|
|
5504
|
-
getWasmCore(): WasmEcsCoreInstance | null;
|
|
5505
|
-
getWasmModule(): WasmModule | null;
|
|
5506
|
-
cleanup(): void;
|
|
5507
|
-
}
|
|
5508
|
-
|
|
5509
|
-
/**
|
|
5510
|
-
* JavaScript回退实现
|
|
5511
|
-
*/
|
|
5512
|
-
|
|
5513
|
-
declare class JavaScriptFallback {
|
|
5514
|
-
private jsEntityMasks;
|
|
5515
|
-
private jsNextEntityId;
|
|
5516
|
-
private jsQueryCount;
|
|
5517
|
-
private jsUpdateCount;
|
|
5518
|
-
createEntity(): EntityId;
|
|
5519
|
-
destroyEntity(entityId: EntityId): boolean;
|
|
5520
|
-
updateEntityMask(entityId: EntityId, mask: ComponentMask): void;
|
|
5521
|
-
batchUpdateMasks(entityIds: EntityId[], masks: ComponentMask[]): void;
|
|
5522
|
-
queryEntities(mask: ComponentMask, maxResults?: number): QueryResult;
|
|
5523
|
-
queryCached(mask: ComponentMask): QueryResult;
|
|
5524
|
-
queryMultipleComponents(masks: ComponentMask[], maxResults?: number): QueryResult;
|
|
5525
|
-
queryWithExclusion(includeMask: ComponentMask, excludeMask: ComponentMask, maxResults?: number): QueryResult;
|
|
5526
|
-
getEntityMask(entityId: EntityId): ComponentMask | null;
|
|
5527
|
-
entityExists(entityId: EntityId): boolean;
|
|
5528
|
-
createComponentMask(componentIds: number[]): ComponentMask;
|
|
5529
|
-
maskContainsComponent(mask: ComponentMask, componentId: number): boolean;
|
|
5530
|
-
getPerformanceStats(): PerformanceStats;
|
|
5531
|
-
clear(): void;
|
|
5532
|
-
getEntityCount(): number;
|
|
5533
|
-
}
|
|
5534
|
-
|
|
5535
|
-
/**
|
|
5536
|
-
* WASM ECS核心模块
|
|
5537
|
-
*/
|
|
5538
|
-
|
|
5539
|
-
declare class WasmEcsCore {
|
|
5540
|
-
private wasmLoader;
|
|
5541
|
-
private jsFallback;
|
|
5542
|
-
private initialized;
|
|
5543
|
-
private usingWasm;
|
|
5544
|
-
constructor();
|
|
5545
|
-
setSilent(silent: boolean): void;
|
|
5546
|
-
/**
|
|
5547
|
-
* 手动初始化WASM模块
|
|
5548
|
-
*
|
|
5549
|
-
* @param wasmFactory WASM工厂函数(从.js文件导入的default)
|
|
5550
|
-
* @param wasmFile WASM文件数据
|
|
5551
|
-
* @returns 是否初始化成功
|
|
5552
|
-
*/
|
|
5553
|
-
initializeWasm(wasmFactory: any, wasmFile: any): Promise<boolean>;
|
|
5554
|
-
initialize(): Promise<boolean>;
|
|
5555
|
-
createEntity(): EntityId;
|
|
5556
|
-
destroyEntity(entityId: EntityId): boolean;
|
|
5557
|
-
updateEntityMask(entityId: EntityId, mask: ComponentMask): void;
|
|
5558
|
-
batchUpdateMasks(entityIds: EntityId[], masks: ComponentMask[]): void;
|
|
5559
|
-
queryEntities(mask: ComponentMask, maxResults?: number): QueryResult;
|
|
5560
|
-
queryCached(mask: ComponentMask): QueryResult;
|
|
5561
|
-
queryMultipleComponents(masks: ComponentMask[], maxResults?: number): QueryResult;
|
|
5562
|
-
queryWithExclusion(includeMask: ComponentMask, excludeMask: ComponentMask, maxResults?: number): QueryResult;
|
|
5563
|
-
getEntityMask(entityId: EntityId): ComponentMask | null;
|
|
5564
|
-
entityExists(entityId: EntityId): boolean;
|
|
5565
|
-
createComponentMask(componentIds: number[]): ComponentMask;
|
|
5566
|
-
maskContainsComponent(mask: ComponentMask, componentId: number): boolean;
|
|
5567
|
-
getPerformanceStats(): PerformanceStats;
|
|
5568
|
-
clear(): void;
|
|
5569
|
-
isUsingWasm(): boolean;
|
|
5570
|
-
isInitialized(): boolean;
|
|
5571
|
-
private ensureInitialized;
|
|
5572
|
-
cleanup(): void;
|
|
5573
|
-
}
|
|
5574
|
-
|
|
5575
|
-
/**
|
|
5576
|
-
* WASM ECS核心全局实例
|
|
5577
|
-
*/
|
|
5578
|
-
|
|
5579
|
-
declare const ecsCore: WasmEcsCore;
|
|
5580
|
-
declare function initializeEcs(silent?: boolean): Promise<boolean>;
|
|
5581
|
-
|
|
5582
|
-
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, JavaScriptFallback, LogType, Matcher, NumberExtension, PassiveSystem, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, WasmEcsCore, WasmLoader, createECSAPI, ecsCore, initializeEcs };
|
|
5583
|
-
export type { Archetype, ArchetypeQueryResult, ComponentClass, ComponentMask, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EntityId, 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$1 as PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats, QueryResult, PerformanceStats as WasmPerformanceStats };
|
|
5071
|
+
export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentIndexManager, ComponentPool, ComponentStorage, 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, Matcher, NumberExtension, PassiveSystem, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, createECSAPI };
|
|
5072
|
+
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 };
|