@esengine/ecs-framework 2.1.28 → 2.1.30
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/bin/Core.d.ts +279 -0
- package/bin/Core.d.ts.map +1 -0
- package/bin/Core.js +400 -0
- package/bin/Core.js.map +1 -0
- package/bin/ECS/Component.d.ts +120 -0
- package/bin/ECS/Component.d.ts.map +1 -0
- package/bin/ECS/Component.js +129 -0
- package/bin/ECS/Component.js.map +1 -0
- package/bin/ECS/Components/IUpdatable.d.ts +22 -0
- package/bin/ECS/Components/IUpdatable.d.ts.map +1 -0
- package/bin/ECS/Components/IUpdatable.js +17 -0
- package/bin/ECS/Components/IUpdatable.js.map +1 -0
- package/bin/ECS/Components/SceneComponent.d.ts +40 -0
- package/bin/ECS/Components/SceneComponent.d.ts.map +1 -0
- package/bin/ECS/Components/SceneComponent.js +57 -0
- package/bin/ECS/Components/SceneComponent.js.map +1 -0
- package/bin/ECS/Core/ArchetypeSystem.d.ts +100 -0
- package/bin/ECS/Core/ArchetypeSystem.d.ts.map +1 -0
- package/bin/ECS/Core/ArchetypeSystem.js +193 -0
- package/bin/ECS/Core/ArchetypeSystem.js.map +1 -0
- package/bin/ECS/Core/ComponentIndex.d.ts +151 -0
- package/bin/ECS/Core/ComponentIndex.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentIndex.js +405 -0
- package/bin/ECS/Core/ComponentIndex.js.map +1 -0
- package/bin/ECS/Core/ComponentPool.d.ts +88 -0
- package/bin/ECS/Core/ComponentPool.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentPool.js +159 -0
- package/bin/ECS/Core/ComponentPool.js.map +1 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +92 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +167 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +1 -0
- package/bin/ECS/Core/ComponentStorage.d.ts +233 -0
- package/bin/ECS/Core/ComponentStorage.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentStorage.js +463 -0
- package/bin/ECS/Core/ComponentStorage.js.map +1 -0
- package/bin/ECS/Core/DirtyTrackingSystem.d.ts +197 -0
- package/bin/ECS/Core/DirtyTrackingSystem.d.ts.map +1 -0
- package/bin/ECS/Core/DirtyTrackingSystem.js +297 -0
- package/bin/ECS/Core/DirtyTrackingSystem.js.map +1 -0
- package/bin/ECS/Core/EntityManager.d.ts +379 -0
- package/bin/ECS/Core/EntityManager.d.ts.map +1 -0
- package/bin/ECS/Core/EntityManager.js +686 -0
- package/bin/ECS/Core/EntityManager.js.map +1 -0
- package/bin/ECS/Core/EventBus.d.ts +218 -0
- package/bin/ECS/Core/EventBus.d.ts.map +1 -0
- package/bin/ECS/Core/EventBus.js +402 -0
- package/bin/ECS/Core/EventBus.js.map +1 -0
- package/bin/ECS/Core/EventSystem.d.ts +237 -0
- package/bin/ECS/Core/EventSystem.d.ts.map +1 -0
- package/bin/ECS/Core/EventSystem.js +478 -0
- package/bin/ECS/Core/EventSystem.js.map +1 -0
- package/bin/ECS/Core/Events/index.d.ts +3 -0
- package/bin/ECS/Core/Events/index.d.ts.map +1 -0
- package/bin/ECS/Core/Events/index.js +3 -0
- package/bin/ECS/Core/Events/index.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +35 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +48 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +135 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +166 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +58 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +85 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +110 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js +174 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +53 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js +79 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/index.d.ts +6 -0
- package/bin/ECS/Core/FluentAPI/index.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/index.js +6 -0
- package/bin/ECS/Core/FluentAPI/index.js.map +1 -0
- package/bin/ECS/Core/FluentAPI.d.ts +2 -0
- package/bin/ECS/Core/FluentAPI.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI.js +3 -0
- package/bin/ECS/Core/FluentAPI.js.map +1 -0
- package/bin/ECS/Core/Performance/index.d.ts +4 -0
- package/bin/ECS/Core/Performance/index.d.ts.map +1 -0
- package/bin/ECS/Core/Performance/index.js +4 -0
- package/bin/ECS/Core/Performance/index.js.map +1 -0
- package/bin/ECS/Core/Query/index.d.ts +4 -0
- package/bin/ECS/Core/Query/index.d.ts.map +1 -0
- package/bin/ECS/Core/Query/index.js +4 -0
- package/bin/ECS/Core/Query/index.js.map +1 -0
- package/bin/ECS/Core/QuerySystem.d.ts +438 -0
- package/bin/ECS/Core/QuerySystem.d.ts.map +1 -0
- package/bin/ECS/Core/QuerySystem.js +974 -0
- package/bin/ECS/Core/QuerySystem.js.map +1 -0
- package/bin/ECS/Core/SoAStorage.d.ts +97 -0
- package/bin/ECS/Core/SoAStorage.d.ts.map +1 -0
- package/bin/ECS/Core/SoAStorage.js +548 -0
- package/bin/ECS/Core/SoAStorage.js.map +1 -0
- package/bin/ECS/Core/Storage/index.d.ts +4 -0
- package/bin/ECS/Core/Storage/index.d.ts.map +1 -0
- package/bin/ECS/Core/Storage/index.js +4 -0
- package/bin/ECS/Core/Storage/index.js.map +1 -0
- package/bin/ECS/CoreEvents.d.ts +131 -0
- package/bin/ECS/CoreEvents.d.ts.map +1 -0
- package/bin/ECS/CoreEvents.js +163 -0
- package/bin/ECS/CoreEvents.js.map +1 -0
- package/bin/ECS/Entity.d.ts +455 -0
- package/bin/ECS/Entity.d.ts.map +1 -0
- package/bin/ECS/Entity.js +837 -0
- package/bin/ECS/Entity.js.map +1 -0
- package/bin/ECS/Scene.d.ts +225 -0
- package/bin/ECS/Scene.d.ts.map +1 -0
- package/bin/ECS/Scene.js +325 -0
- package/bin/ECS/Scene.js.map +1 -0
- package/bin/ECS/Systems/EntitySystem.d.ts +200 -0
- package/bin/ECS/Systems/EntitySystem.d.ts.map +1 -0
- package/bin/ECS/Systems/EntitySystem.js +431 -0
- package/bin/ECS/Systems/EntitySystem.js.map +1 -0
- package/bin/ECS/Systems/IntervalSystem.d.ts +33 -0
- package/bin/ECS/Systems/IntervalSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/IntervalSystem.js +50 -0
- package/bin/ECS/Systems/IntervalSystem.js.map +1 -0
- package/bin/ECS/Systems/PassiveSystem.d.ts +17 -0
- package/bin/ECS/Systems/PassiveSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/PassiveSystem.js +19 -0
- package/bin/ECS/Systems/PassiveSystem.js.map +1 -0
- package/bin/ECS/Systems/ProcessingSystem.d.ts +21 -0
- package/bin/ECS/Systems/ProcessingSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/ProcessingSystem.js +20 -0
- package/bin/ECS/Systems/ProcessingSystem.js.map +1 -0
- package/bin/ECS/Systems/index.d.ts +5 -0
- package/bin/ECS/Systems/index.d.ts.map +1 -0
- package/bin/ECS/Systems/index.js +6 -0
- package/bin/ECS/Systems/index.js.map +1 -0
- package/bin/ECS/Utils/BigIntCompatibility.d.ts +164 -0
- package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +1 -0
- package/bin/ECS/Utils/BigIntCompatibility.js +578 -0
- package/bin/ECS/Utils/BigIntCompatibility.js.map +1 -0
- package/bin/ECS/Utils/Bits.d.ts +163 -0
- package/bin/ECS/Utils/Bits.d.ts.map +1 -0
- package/bin/ECS/Utils/Bits.js +286 -0
- package/bin/ECS/Utils/Bits.js.map +1 -0
- package/bin/ECS/Utils/ComponentTypeManager.d.ts +50 -0
- package/bin/ECS/Utils/ComponentTypeManager.d.ts.map +1 -0
- package/bin/ECS/Utils/ComponentTypeManager.js +84 -0
- package/bin/ECS/Utils/ComponentTypeManager.js.map +1 -0
- package/bin/ECS/Utils/EntityList.d.ts +108 -0
- package/bin/ECS/Utils/EntityList.d.ts.map +1 -0
- package/bin/ECS/Utils/EntityList.js +262 -0
- package/bin/ECS/Utils/EntityList.js.map +1 -0
- package/bin/ECS/Utils/EntityProcessorList.d.ts +56 -0
- package/bin/ECS/Utils/EntityProcessorList.d.ts.map +1 -0
- package/bin/ECS/Utils/EntityProcessorList.js +102 -0
- package/bin/ECS/Utils/EntityProcessorList.js.map +1 -0
- package/bin/ECS/Utils/IdentifierPool.d.ts +203 -0
- package/bin/ECS/Utils/IdentifierPool.d.ts.map +1 -0
- package/bin/ECS/Utils/IdentifierPool.js +325 -0
- package/bin/ECS/Utils/IdentifierPool.js.map +1 -0
- package/bin/ECS/Utils/Matcher.d.ts +143 -0
- package/bin/ECS/Utils/Matcher.d.ts.map +1 -0
- package/bin/ECS/Utils/Matcher.js +249 -0
- package/bin/ECS/Utils/Matcher.js.map +1 -0
- package/bin/ECS/Utils/index.d.ts +8 -0
- package/bin/ECS/Utils/index.d.ts.map +1 -0
- package/bin/ECS/Utils/index.js +9 -0
- package/bin/ECS/Utils/index.js.map +1 -0
- package/bin/ECS/index.d.ts +12 -0
- package/bin/ECS/index.d.ts.map +1 -0
- package/bin/ECS/index.js +12 -0
- package/bin/ECS/index.js.map +1 -0
- package/bin/Types/index.d.ts +471 -0
- package/bin/Types/index.d.ts.map +1 -0
- package/bin/Types/index.js +5 -0
- package/bin/Types/index.js.map +1 -0
- package/bin/Utils/Debug/ComponentDataCollector.d.ts +28 -0
- package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/ComponentDataCollector.js +248 -0
- package/bin/Utils/Debug/ComponentDataCollector.js.map +1 -0
- package/bin/Utils/Debug/DebugDataFormatter.d.ts +22 -0
- package/bin/Utils/Debug/DebugDataFormatter.d.ts.map +1 -0
- package/bin/Utils/Debug/DebugDataFormatter.js +117 -0
- package/bin/Utils/Debug/DebugDataFormatter.js.map +1 -0
- package/bin/Utils/Debug/DebugManager.d.ts +104 -0
- package/bin/Utils/Debug/DebugManager.d.ts.map +1 -0
- package/bin/Utils/Debug/DebugManager.js +647 -0
- package/bin/Utils/Debug/DebugManager.js.map +1 -0
- package/bin/Utils/Debug/EntityDataCollector.d.ts +92 -0
- package/bin/Utils/Debug/EntityDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/EntityDataCollector.js +864 -0
- package/bin/Utils/Debug/EntityDataCollector.js.map +1 -0
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts +32 -0
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/PerformanceDataCollector.js +217 -0
- package/bin/Utils/Debug/PerformanceDataCollector.js.map +1 -0
- package/bin/Utils/Debug/SceneDataCollector.d.ts +16 -0
- package/bin/Utils/Debug/SceneDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/SceneDataCollector.js +46 -0
- package/bin/Utils/Debug/SceneDataCollector.js.map +1 -0
- package/bin/Utils/Debug/SystemDataCollector.d.ts +11 -0
- package/bin/Utils/Debug/SystemDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/SystemDataCollector.js +59 -0
- package/bin/Utils/Debug/SystemDataCollector.js.map +1 -0
- package/bin/Utils/Debug/WebSocketManager.d.ts +59 -0
- package/bin/Utils/Debug/WebSocketManager.d.ts.map +1 -0
- package/bin/Utils/Debug/WebSocketManager.js +148 -0
- package/bin/Utils/Debug/WebSocketManager.js.map +1 -0
- package/bin/Utils/Debug/index.d.ts +8 -0
- package/bin/Utils/Debug/index.d.ts.map +1 -0
- package/bin/Utils/Debug/index.js +8 -0
- package/bin/Utils/Debug/index.js.map +1 -0
- package/bin/Utils/Emitter.d.ts +43 -0
- package/bin/Utils/Emitter.d.ts.map +1 -0
- package/bin/Utils/Emitter.js +69 -0
- package/bin/Utils/Emitter.js.map +1 -0
- package/bin/Utils/Extensions/NumberExtension.d.ts +13 -0
- package/bin/Utils/Extensions/NumberExtension.d.ts.map +1 -0
- package/bin/Utils/Extensions/NumberExtension.js +17 -0
- package/bin/Utils/Extensions/NumberExtension.js.map +1 -0
- package/bin/Utils/Extensions/TypeUtils.d.ts +13 -0
- package/bin/Utils/Extensions/TypeUtils.d.ts.map +1 -0
- package/bin/Utils/Extensions/TypeUtils.js +15 -0
- package/bin/Utils/Extensions/TypeUtils.js.map +1 -0
- package/bin/Utils/Extensions/index.d.ts +3 -0
- package/bin/Utils/Extensions/index.d.ts.map +1 -0
- package/bin/Utils/Extensions/index.js +4 -0
- package/bin/Utils/Extensions/index.js.map +1 -0
- package/bin/Utils/GlobalManager.d.ts +32 -0
- package/bin/Utils/GlobalManager.d.ts.map +1 -0
- package/bin/Utils/GlobalManager.js +53 -0
- package/bin/Utils/GlobalManager.js.map +1 -0
- package/bin/Utils/Logger.d.ts +156 -0
- package/bin/Utils/Logger.d.ts.map +1 -0
- package/bin/Utils/Logger.js +256 -0
- package/bin/Utils/Logger.js.map +1 -0
- package/bin/Utils/PerformanceMonitor.d.ts +211 -0
- package/bin/Utils/PerformanceMonitor.d.ts.map +1 -0
- package/bin/Utils/PerformanceMonitor.js +270 -0
- package/bin/Utils/PerformanceMonitor.js.map +1 -0
- package/bin/Utils/Pool/IPoolable.d.ts +29 -0
- package/bin/Utils/Pool/IPoolable.d.ts.map +1 -0
- package/bin/Utils/Pool/IPoolable.js +2 -0
- package/bin/Utils/Pool/IPoolable.js.map +1 -0
- package/bin/Utils/Pool/Pool.d.ts +109 -0
- package/bin/Utils/Pool/Pool.d.ts.map +1 -0
- package/bin/Utils/Pool/Pool.js +238 -0
- package/bin/Utils/Pool/Pool.js.map +1 -0
- package/bin/Utils/Pool/PoolManager.d.ts +91 -0
- package/bin/Utils/Pool/PoolManager.d.ts.map +1 -0
- package/bin/Utils/Pool/PoolManager.js +197 -0
- package/bin/Utils/Pool/PoolManager.js.map +1 -0
- package/bin/Utils/Pool/index.d.ts +4 -0
- package/bin/Utils/Pool/index.d.ts.map +1 -0
- package/bin/Utils/Pool/index.js +4 -0
- package/bin/Utils/Pool/index.js.map +1 -0
- package/bin/Utils/Time.d.ts +47 -0
- package/bin/Utils/Time.d.ts.map +1 -0
- package/bin/Utils/Time.js +64 -0
- package/bin/Utils/Time.js.map +1 -0
- package/bin/Utils/Timers/ITimer.d.ts +16 -0
- package/bin/Utils/Timers/ITimer.d.ts.map +1 -0
- package/bin/Utils/Timers/ITimer.js +2 -0
- package/bin/Utils/Timers/ITimer.js.map +1 -0
- package/bin/Utils/Timers/Timer.d.ts +30 -0
- package/bin/Utils/Timers/Timer.d.ts.map +1 -0
- package/bin/Utils/Timers/Timer.js +58 -0
- package/bin/Utils/Timers/Timer.js.map +1 -0
- package/bin/Utils/Timers/TimerManager.d.ts +19 -0
- package/bin/Utils/Timers/TimerManager.d.ts.map +1 -0
- package/bin/Utils/Timers/TimerManager.js +33 -0
- package/bin/Utils/Timers/TimerManager.js.map +1 -0
- package/bin/Utils/index.d.ts +9 -0
- package/bin/Utils/index.d.ts.map +1 -0
- package/bin/Utils/index.js +9 -0
- package/bin/Utils/index.js.map +1 -0
- package/bin/index.d.ts +16 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +19 -0
- package/bin/index.js.map +1 -0
- package/package.json +52 -25
- package/.npmignore +0 -40
- package/LICENSE +0 -201
- package/README.md +0 -438
- package/SECURITY.md +0 -53
- package/index.cjs +0 -2
- package/index.cjs.map +0 -1
- package/index.d.ts +0 -6383
- package/index.mjs +0 -2
- package/index.mjs.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Component } from '../../Component';
|
|
2
|
+
import { IBigIntLike } from '../../Utils/BigIntCompatibility';
|
|
3
|
+
/**
|
|
4
|
+
* 组件类型定义
|
|
5
|
+
*/
|
|
6
|
+
export type ComponentType<T extends Component = Component> = new (...args: unknown[]) => T;
|
|
7
|
+
/**
|
|
8
|
+
* 组件注册表
|
|
9
|
+
* 管理组件类型的位掩码分配
|
|
10
|
+
*/
|
|
11
|
+
export declare class ComponentRegistry {
|
|
12
|
+
protected static readonly _logger: import("../../../Utils/Logger").ILogger;
|
|
13
|
+
private static componentTypes;
|
|
14
|
+
private static componentNameToType;
|
|
15
|
+
private static componentNameToId;
|
|
16
|
+
private static maskCache;
|
|
17
|
+
private static nextBitIndex;
|
|
18
|
+
private static maxComponents;
|
|
19
|
+
/**
|
|
20
|
+
* 注册组件类型并分配位掩码
|
|
21
|
+
* @param componentType 组件类型
|
|
22
|
+
* @returns 分配的位索引
|
|
23
|
+
*/
|
|
24
|
+
static register<T extends Component>(componentType: ComponentType<T>): number;
|
|
25
|
+
/**
|
|
26
|
+
* 获取组件类型的位掩码
|
|
27
|
+
* @param componentType 组件类型
|
|
28
|
+
* @returns 位掩码
|
|
29
|
+
*/
|
|
30
|
+
static getBitMask<T extends Component>(componentType: ComponentType<T>): IBigIntLike;
|
|
31
|
+
/**
|
|
32
|
+
* 获取组件类型的位索引
|
|
33
|
+
* @param componentType 组件类型
|
|
34
|
+
* @returns 位索引
|
|
35
|
+
*/
|
|
36
|
+
static getBitIndex<T extends Component>(componentType: ComponentType<T>): number;
|
|
37
|
+
/**
|
|
38
|
+
* 检查组件类型是否已注册
|
|
39
|
+
* @param componentType 组件类型
|
|
40
|
+
* @returns 是否已注册
|
|
41
|
+
*/
|
|
42
|
+
static isRegistered<T extends Component>(componentType: ComponentType<T>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 通过名称获取组件类型
|
|
45
|
+
* @param componentName 组件名称
|
|
46
|
+
* @returns 组件类型构造函数
|
|
47
|
+
*/
|
|
48
|
+
static getComponentType(componentName: string): Function | null;
|
|
49
|
+
/**
|
|
50
|
+
* 获取所有已注册的组件类型
|
|
51
|
+
* @returns 组件类型映射
|
|
52
|
+
*/
|
|
53
|
+
static getAllRegisteredTypes(): Map<Function, number>;
|
|
54
|
+
/**
|
|
55
|
+
* 获取所有组件名称到类型的映射
|
|
56
|
+
* @returns 名称到类型的映射
|
|
57
|
+
*/
|
|
58
|
+
static getAllComponentNames(): Map<string, Function>;
|
|
59
|
+
/**
|
|
60
|
+
* 通过名称获取组件类型ID
|
|
61
|
+
* @param componentName 组件名称
|
|
62
|
+
* @returns 组件类型ID
|
|
63
|
+
*/
|
|
64
|
+
static getComponentId(componentName: string): number | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* 注册组件类型(通过名称)
|
|
67
|
+
* @param componentName 组件名称
|
|
68
|
+
* @returns 分配的组件ID
|
|
69
|
+
*/
|
|
70
|
+
static registerComponentByName(componentName: string): number;
|
|
71
|
+
/**
|
|
72
|
+
* 创建单个组件的掩码
|
|
73
|
+
* @param componentName 组件名称
|
|
74
|
+
* @returns 组件掩码
|
|
75
|
+
*/
|
|
76
|
+
static createSingleComponentMask(componentName: string): IBigIntLike;
|
|
77
|
+
/**
|
|
78
|
+
* 创建多个组件的掩码
|
|
79
|
+
* @param componentNames 组件名称数组
|
|
80
|
+
* @returns 组合掩码
|
|
81
|
+
*/
|
|
82
|
+
static createComponentMask(componentNames: string[]): IBigIntLike;
|
|
83
|
+
/**
|
|
84
|
+
* 清除掩码缓存
|
|
85
|
+
*/
|
|
86
|
+
static clearMaskCache(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 重置注册表(用于测试)
|
|
89
|
+
*/
|
|
90
|
+
static reset(): void;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=ComponentRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../../../src/ECS/Core/ComponentStorage/ComponentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAiB,MAAM,iCAAiC,CAAC;AAG7E;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE3F;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,0CAAoC;IACrE,OAAO,CAAC,MAAM,CAAC,cAAc,CAA+B;IAC5D,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAA+B;IACjE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA6B;IAC7D,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAC1D,OAAO,CAAC,MAAM,CAAC,YAAY,CAAK;IAChC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAM;IAElC;;;;OAIG;WACW,QAAQ,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM;IAgBpF;;;;OAIG;WACW,UAAU,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW;IAQ3F;;;;OAIG;WACW,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM;IAQvF;;;;OAIG;WACW,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO;IAIzF;;;;OAIG;WACW,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAItE;;;OAGG;WACW,qBAAqB,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC;IAI5D;;;OAGG;WACW,oBAAoB,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;IAI3D;;;;OAIG;WACW,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIvE;;;;OAIG;WACW,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAcpE;;;;OAIG;WACW,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW;IAiB3E;;;;OAIG;WACW,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,WAAW;IAoBxE;;OAEG;WACW,cAAc,IAAI,IAAI;IAIpC;;OAEG;WACW,KAAK,IAAI,IAAI;CAO9B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { BigIntFactory } from '../../Utils/BigIntCompatibility';
|
|
2
|
+
import { createLogger } from '../../../Utils/Logger';
|
|
3
|
+
/**
|
|
4
|
+
* 组件注册表
|
|
5
|
+
* 管理组件类型的位掩码分配
|
|
6
|
+
*/
|
|
7
|
+
export class ComponentRegistry {
|
|
8
|
+
/**
|
|
9
|
+
* 注册组件类型并分配位掩码
|
|
10
|
+
* @param componentType 组件类型
|
|
11
|
+
* @returns 分配的位索引
|
|
12
|
+
*/
|
|
13
|
+
static register(componentType) {
|
|
14
|
+
if (this.componentTypes.has(componentType)) {
|
|
15
|
+
return this.componentTypes.get(componentType);
|
|
16
|
+
}
|
|
17
|
+
if (this.nextBitIndex >= this.maxComponents) {
|
|
18
|
+
throw new Error(`Maximum number of component types (${this.maxComponents}) exceeded`);
|
|
19
|
+
}
|
|
20
|
+
const bitIndex = this.nextBitIndex++;
|
|
21
|
+
this.componentTypes.set(componentType, bitIndex);
|
|
22
|
+
this.componentNameToType.set(componentType.name, componentType);
|
|
23
|
+
this.componentNameToId.set(componentType.name, bitIndex);
|
|
24
|
+
return bitIndex;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 获取组件类型的位掩码
|
|
28
|
+
* @param componentType 组件类型
|
|
29
|
+
* @returns 位掩码
|
|
30
|
+
*/
|
|
31
|
+
static getBitMask(componentType) {
|
|
32
|
+
const bitIndex = this.componentTypes.get(componentType);
|
|
33
|
+
if (bitIndex === undefined) {
|
|
34
|
+
throw new Error(`Component type ${componentType.name} is not registered`);
|
|
35
|
+
}
|
|
36
|
+
return BigIntFactory.one().shiftLeft(bitIndex);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 获取组件类型的位索引
|
|
40
|
+
* @param componentType 组件类型
|
|
41
|
+
* @returns 位索引
|
|
42
|
+
*/
|
|
43
|
+
static getBitIndex(componentType) {
|
|
44
|
+
const bitIndex = this.componentTypes.get(componentType);
|
|
45
|
+
if (bitIndex === undefined) {
|
|
46
|
+
throw new Error(`Component type ${componentType.name} is not registered`);
|
|
47
|
+
}
|
|
48
|
+
return bitIndex;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 检查组件类型是否已注册
|
|
52
|
+
* @param componentType 组件类型
|
|
53
|
+
* @returns 是否已注册
|
|
54
|
+
*/
|
|
55
|
+
static isRegistered(componentType) {
|
|
56
|
+
return this.componentTypes.has(componentType);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 通过名称获取组件类型
|
|
60
|
+
* @param componentName 组件名称
|
|
61
|
+
* @returns 组件类型构造函数
|
|
62
|
+
*/
|
|
63
|
+
static getComponentType(componentName) {
|
|
64
|
+
return this.componentNameToType.get(componentName) || null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 获取所有已注册的组件类型
|
|
68
|
+
* @returns 组件类型映射
|
|
69
|
+
*/
|
|
70
|
+
static getAllRegisteredTypes() {
|
|
71
|
+
return new Map(this.componentTypes);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 获取所有组件名称到类型的映射
|
|
75
|
+
* @returns 名称到类型的映射
|
|
76
|
+
*/
|
|
77
|
+
static getAllComponentNames() {
|
|
78
|
+
return new Map(this.componentNameToType);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 通过名称获取组件类型ID
|
|
82
|
+
* @param componentName 组件名称
|
|
83
|
+
* @returns 组件类型ID
|
|
84
|
+
*/
|
|
85
|
+
static getComponentId(componentName) {
|
|
86
|
+
return this.componentNameToId.get(componentName);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 注册组件类型(通过名称)
|
|
90
|
+
* @param componentName 组件名称
|
|
91
|
+
* @returns 分配的组件ID
|
|
92
|
+
*/
|
|
93
|
+
static registerComponentByName(componentName) {
|
|
94
|
+
if (this.componentNameToId.has(componentName)) {
|
|
95
|
+
return this.componentNameToId.get(componentName);
|
|
96
|
+
}
|
|
97
|
+
if (this.nextBitIndex >= this.maxComponents) {
|
|
98
|
+
throw new Error(`Maximum number of component types (${this.maxComponents}) exceeded`);
|
|
99
|
+
}
|
|
100
|
+
const bitIndex = this.nextBitIndex++;
|
|
101
|
+
this.componentNameToId.set(componentName, bitIndex);
|
|
102
|
+
return bitIndex;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 创建单个组件的掩码
|
|
106
|
+
* @param componentName 组件名称
|
|
107
|
+
* @returns 组件掩码
|
|
108
|
+
*/
|
|
109
|
+
static createSingleComponentMask(componentName) {
|
|
110
|
+
const cacheKey = `single:${componentName}`;
|
|
111
|
+
if (this.maskCache.has(cacheKey)) {
|
|
112
|
+
return this.maskCache.get(cacheKey);
|
|
113
|
+
}
|
|
114
|
+
const componentId = this.getComponentId(componentName);
|
|
115
|
+
if (componentId === undefined) {
|
|
116
|
+
throw new Error(`Component type ${componentName} is not registered`);
|
|
117
|
+
}
|
|
118
|
+
const mask = BigIntFactory.one().shiftLeft(componentId);
|
|
119
|
+
this.maskCache.set(cacheKey, mask);
|
|
120
|
+
return mask;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 创建多个组件的掩码
|
|
124
|
+
* @param componentNames 组件名称数组
|
|
125
|
+
* @returns 组合掩码
|
|
126
|
+
*/
|
|
127
|
+
static createComponentMask(componentNames) {
|
|
128
|
+
const sortedNames = [...componentNames].sort();
|
|
129
|
+
const cacheKey = `multi:${sortedNames.join(',')}`;
|
|
130
|
+
if (this.maskCache.has(cacheKey)) {
|
|
131
|
+
return this.maskCache.get(cacheKey);
|
|
132
|
+
}
|
|
133
|
+
let mask = BigIntFactory.zero();
|
|
134
|
+
for (const name of componentNames) {
|
|
135
|
+
const componentId = this.getComponentId(name);
|
|
136
|
+
if (componentId !== undefined) {
|
|
137
|
+
mask = mask.or(BigIntFactory.one().shiftLeft(componentId));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.maskCache.set(cacheKey, mask);
|
|
141
|
+
return mask;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 清除掩码缓存
|
|
145
|
+
*/
|
|
146
|
+
static clearMaskCache() {
|
|
147
|
+
this.maskCache.clear();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 重置注册表(用于测试)
|
|
151
|
+
*/
|
|
152
|
+
static reset() {
|
|
153
|
+
this.componentTypes.clear();
|
|
154
|
+
this.componentNameToType.clear();
|
|
155
|
+
this.componentNameToId.clear();
|
|
156
|
+
this.maskCache.clear();
|
|
157
|
+
this.nextBitIndex = 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
ComponentRegistry._logger = createLogger('ComponentStorage');
|
|
161
|
+
ComponentRegistry.componentTypes = new Map();
|
|
162
|
+
ComponentRegistry.componentNameToType = new Map();
|
|
163
|
+
ComponentRegistry.componentNameToId = new Map();
|
|
164
|
+
ComponentRegistry.maskCache = new Map();
|
|
165
|
+
ComponentRegistry.nextBitIndex = 0;
|
|
166
|
+
ComponentRegistry.maxComponents = 64; // 支持最多64种组件类型
|
|
167
|
+
//# sourceMappingURL=ComponentRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../../../../src/ECS/Core/ComponentStorage/ComponentRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOrD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAS1B;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAsB,aAA+B;QACvE,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAE,CAAC;QACnD,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,aAAa,YAAY,CAAC,CAAC;QAC1F,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAChE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACzD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;OAIG;IAC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gCAAc,GAAG,IAAI,GAAG,EAAoB,CAAC;AAC7C,qCAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;AAClD,mCAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC9C,2BAAS,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC3C,8BAAY,GAAG,CAAC,CAAC;AACjB,+BAAa,GAAG,EAAE,CAAC,CAAC,cAAc"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Component } from '../Component';
|
|
2
|
+
import { IBigIntLike } from '../Utils/BigIntCompatibility';
|
|
3
|
+
import { SoAStorage, EnableSoA, HighPrecision, Float64, Int32, SerializeMap, SerializeSet, SerializeArray, DeepCopy } from './SoAStorage';
|
|
4
|
+
export { EnableSoA, HighPrecision, Float64, Int32, SerializeMap, SerializeSet, SerializeArray, DeepCopy };
|
|
5
|
+
/**
|
|
6
|
+
* 组件类型定义
|
|
7
|
+
*/
|
|
8
|
+
export type ComponentType<T extends Component = Component> = new (...args: unknown[]) => T;
|
|
9
|
+
/**
|
|
10
|
+
* 组件注册表
|
|
11
|
+
* 管理组件类型的位掩码分配
|
|
12
|
+
*/
|
|
13
|
+
export declare class ComponentRegistry {
|
|
14
|
+
protected static readonly _logger: import("../../Utils/Logger").ILogger;
|
|
15
|
+
private static componentTypes;
|
|
16
|
+
private static componentNameToType;
|
|
17
|
+
private static componentNameToId;
|
|
18
|
+
private static maskCache;
|
|
19
|
+
private static nextBitIndex;
|
|
20
|
+
private static maxComponents;
|
|
21
|
+
/**
|
|
22
|
+
* 注册组件类型并分配位掩码
|
|
23
|
+
* @param componentType 组件类型
|
|
24
|
+
* @returns 分配的位索引
|
|
25
|
+
*/
|
|
26
|
+
static register<T extends Component>(componentType: ComponentType<T>): number;
|
|
27
|
+
/**
|
|
28
|
+
* 获取组件类型的位掩码
|
|
29
|
+
* @param componentType 组件类型
|
|
30
|
+
* @returns 位掩码
|
|
31
|
+
*/
|
|
32
|
+
static getBitMask<T extends Component>(componentType: ComponentType<T>): IBigIntLike;
|
|
33
|
+
/**
|
|
34
|
+
* 获取组件类型的位索引
|
|
35
|
+
* @param componentType 组件类型
|
|
36
|
+
* @returns 位索引
|
|
37
|
+
*/
|
|
38
|
+
static getBitIndex<T extends Component>(componentType: ComponentType<T>): number;
|
|
39
|
+
/**
|
|
40
|
+
* 检查组件类型是否已注册
|
|
41
|
+
* @param componentType 组件类型
|
|
42
|
+
* @returns 是否已注册
|
|
43
|
+
*/
|
|
44
|
+
static isRegistered<T extends Component>(componentType: ComponentType<T>): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 通过名称获取组件类型
|
|
47
|
+
* @param componentName 组件名称
|
|
48
|
+
* @returns 组件类型构造函数
|
|
49
|
+
*/
|
|
50
|
+
static getComponentType(componentName: string): Function | null;
|
|
51
|
+
/**
|
|
52
|
+
* 获取所有已注册的组件类型
|
|
53
|
+
* @returns 组件类型映射
|
|
54
|
+
*/
|
|
55
|
+
static getAllRegisteredTypes(): Map<Function, number>;
|
|
56
|
+
/**
|
|
57
|
+
* 获取所有组件名称到类型的映射
|
|
58
|
+
* @returns 名称到类型的映射
|
|
59
|
+
*/
|
|
60
|
+
static getAllComponentNames(): Map<string, Function>;
|
|
61
|
+
/**
|
|
62
|
+
* 通过名称获取组件类型ID
|
|
63
|
+
* @param componentName 组件名称
|
|
64
|
+
* @returns 组件类型ID
|
|
65
|
+
*/
|
|
66
|
+
static getComponentId(componentName: string): number | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 注册组件类型(通过名称)
|
|
69
|
+
* @param componentName 组件名称
|
|
70
|
+
* @returns 分配的组件ID
|
|
71
|
+
*/
|
|
72
|
+
static registerComponentByName(componentName: string): number;
|
|
73
|
+
/**
|
|
74
|
+
* 创建单个组件的掩码
|
|
75
|
+
* @param componentName 组件名称
|
|
76
|
+
* @returns 组件掩码
|
|
77
|
+
*/
|
|
78
|
+
static createSingleComponentMask(componentName: string): IBigIntLike;
|
|
79
|
+
/**
|
|
80
|
+
* 创建多个组件的掩码
|
|
81
|
+
* @param componentNames 组件名称数组
|
|
82
|
+
* @returns 组合掩码
|
|
83
|
+
*/
|
|
84
|
+
static createComponentMask(componentNames: string[]): IBigIntLike;
|
|
85
|
+
/**
|
|
86
|
+
* 清除掩码缓存
|
|
87
|
+
*/
|
|
88
|
+
static clearMaskCache(): void;
|
|
89
|
+
/**
|
|
90
|
+
* 重置注册表(用于测试)
|
|
91
|
+
*/
|
|
92
|
+
static reset(): void;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 高性能组件存储器
|
|
96
|
+
* 使用SoA(Structure of Arrays)模式存储组件
|
|
97
|
+
*/
|
|
98
|
+
export declare class ComponentStorage<T extends Component> {
|
|
99
|
+
private components;
|
|
100
|
+
private entityToIndex;
|
|
101
|
+
private indexToEntity;
|
|
102
|
+
private freeIndices;
|
|
103
|
+
private componentType;
|
|
104
|
+
private _size;
|
|
105
|
+
constructor(componentType: ComponentType<T>);
|
|
106
|
+
/**
|
|
107
|
+
* 添加组件
|
|
108
|
+
* @param entityId 实体ID
|
|
109
|
+
* @param component 组件实例
|
|
110
|
+
*/
|
|
111
|
+
addComponent(entityId: number, component: T): void;
|
|
112
|
+
/**
|
|
113
|
+
* 获取组件
|
|
114
|
+
* @param entityId 实体ID
|
|
115
|
+
* @returns 组件实例或null
|
|
116
|
+
*/
|
|
117
|
+
getComponent(entityId: number): T | null;
|
|
118
|
+
/**
|
|
119
|
+
* 检查实体是否有此组件
|
|
120
|
+
* @param entityId 实体ID
|
|
121
|
+
* @returns 是否有组件
|
|
122
|
+
*/
|
|
123
|
+
hasComponent(entityId: number): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* 移除组件
|
|
126
|
+
* @param entityId 实体ID
|
|
127
|
+
* @returns 被移除的组件或null
|
|
128
|
+
*/
|
|
129
|
+
removeComponent(entityId: number): T | null;
|
|
130
|
+
/**
|
|
131
|
+
* 高效遍历所有组件
|
|
132
|
+
* @param callback 回调函数
|
|
133
|
+
*/
|
|
134
|
+
forEach(callback: (component: T, entityId: number, index: number) => void): void;
|
|
135
|
+
/**
|
|
136
|
+
* 获取所有组件(密集数组)
|
|
137
|
+
* @returns 组件数组
|
|
138
|
+
*/
|
|
139
|
+
getDenseArray(): {
|
|
140
|
+
components: T[];
|
|
141
|
+
entityIds: number[];
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* 清空所有组件
|
|
145
|
+
*/
|
|
146
|
+
clear(): void;
|
|
147
|
+
/**
|
|
148
|
+
* 获取组件数量
|
|
149
|
+
*/
|
|
150
|
+
get size(): number;
|
|
151
|
+
/**
|
|
152
|
+
* 获取组件类型
|
|
153
|
+
*/
|
|
154
|
+
get type(): ComponentType<T>;
|
|
155
|
+
/**
|
|
156
|
+
* 压缩存储(移除空洞)
|
|
157
|
+
*/
|
|
158
|
+
compact(): void;
|
|
159
|
+
/**
|
|
160
|
+
* 获取存储统计信息
|
|
161
|
+
*/
|
|
162
|
+
getStats(): {
|
|
163
|
+
totalSlots: number;
|
|
164
|
+
usedSlots: number;
|
|
165
|
+
freeSlots: number;
|
|
166
|
+
fragmentation: number;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 组件存储管理器
|
|
171
|
+
* 管理所有组件类型的存储器
|
|
172
|
+
*/
|
|
173
|
+
export declare class ComponentStorageManager {
|
|
174
|
+
private static readonly _logger;
|
|
175
|
+
private storages;
|
|
176
|
+
/**
|
|
177
|
+
* 获取或创建组件存储器(默认原始存储)
|
|
178
|
+
* @param componentType 组件类型
|
|
179
|
+
* @returns 组件存储器
|
|
180
|
+
*/
|
|
181
|
+
getStorage<T extends Component>(componentType: ComponentType<T>): ComponentStorage<T> | SoAStorage<T>;
|
|
182
|
+
/**
|
|
183
|
+
* 添加组件
|
|
184
|
+
* @param entityId 实体ID
|
|
185
|
+
* @param component 组件实例
|
|
186
|
+
*/
|
|
187
|
+
addComponent<T extends Component>(entityId: number, component: T): void;
|
|
188
|
+
/**
|
|
189
|
+
* 获取组件
|
|
190
|
+
* @param entityId 实体ID
|
|
191
|
+
* @param componentType 组件类型
|
|
192
|
+
* @returns 组件实例或null
|
|
193
|
+
*/
|
|
194
|
+
getComponent<T extends Component>(entityId: number, componentType: ComponentType<T>): T | null;
|
|
195
|
+
/**
|
|
196
|
+
* 检查实体是否有组件
|
|
197
|
+
* @param entityId 实体ID
|
|
198
|
+
* @param componentType 组件类型
|
|
199
|
+
* @returns 是否有组件
|
|
200
|
+
*/
|
|
201
|
+
hasComponent<T extends Component>(entityId: number, componentType: ComponentType<T>): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* 移除组件
|
|
204
|
+
* @param entityId 实体ID
|
|
205
|
+
* @param componentType 组件类型
|
|
206
|
+
* @returns 被移除的组件或null
|
|
207
|
+
*/
|
|
208
|
+
removeComponent<T extends Component>(entityId: number, componentType: ComponentType<T>): T | null;
|
|
209
|
+
/**
|
|
210
|
+
* 移除实体的所有组件
|
|
211
|
+
* @param entityId 实体ID
|
|
212
|
+
*/
|
|
213
|
+
removeAllComponents(entityId: number): void;
|
|
214
|
+
/**
|
|
215
|
+
* 获取实体的组件位掩码
|
|
216
|
+
* @param entityId 实体ID
|
|
217
|
+
* @returns 组件位掩码
|
|
218
|
+
*/
|
|
219
|
+
getComponentMask(entityId: number): IBigIntLike;
|
|
220
|
+
/**
|
|
221
|
+
* 压缩所有存储器
|
|
222
|
+
*/
|
|
223
|
+
compactAll(): void;
|
|
224
|
+
/**
|
|
225
|
+
* 获取所有存储器的统计信息
|
|
226
|
+
*/
|
|
227
|
+
getAllStats(): Map<string, any>;
|
|
228
|
+
/**
|
|
229
|
+
* 清空所有存储器
|
|
230
|
+
*/
|
|
231
|
+
clear(): void;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=ComponentStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentStorage.d.ts","sourceRoot":"","sources":["../../../src/ECS/Core/ComponentStorage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