@esengine/ecs-framework 2.1.15 → 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/README.md +265 -193
- package/index.d.ts +16 -316
- 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;
|
|
@@ -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
|
-
* 实体基础接口(向后兼容)
|
|
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
|
-
* 系统接口
|
|
774
|
+
* 系统基础接口
|
|
869
775
|
*
|
|
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);
|
|
@@ -5368,5 +5068,5 @@ declare class Time {
|
|
|
5368
5068
|
static checkEvery(interval: number, lastTime: number): boolean;
|
|
5369
5069
|
}
|
|
5370
5070
|
|
|
5371
|
-
export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentIndexManager, ComponentPool, ComponentStorage,
|
|
5372
|
-
export type { Archetype, ArchetypeQueryResult,
|
|
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 };
|