@esengine/ecs-framework 2.3.0 → 2.3.2
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.cjs +2 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +13466 -0
- package/index.es5.js +4 -0
- package/index.es5.js.map +1 -0
- package/index.mjs +2 -0
- package/index.mjs.map +1 -0
- package/index.umd.js +4 -0
- package/index.umd.js.map +1 -0
- package/package.json +47 -84
- package/bin/Core/DI/Decorators.d.ts +0 -206
- package/bin/Core/DI/Decorators.d.ts.map +0 -1
- package/bin/Core/DI/Decorators.js +0 -253
- package/bin/Core/DI/Decorators.js.map +0 -1
- package/bin/Core/DI/index.d.ts +0 -8
- package/bin/Core/DI/index.d.ts.map +0 -1
- package/bin/Core/DI/index.js +0 -7
- package/bin/Core/DI/index.js.map +0 -1
- package/bin/Core/Plugin.d.ts +0 -112
- package/bin/Core/Plugin.d.ts.map +0 -1
- package/bin/Core/Plugin.js +0 -19
- package/bin/Core/Plugin.js.map +0 -1
- package/bin/Core/PluginManager.d.ts +0 -118
- package/bin/Core/PluginManager.d.ts.map +0 -1
- package/bin/Core/PluginManager.js +0 -229
- package/bin/Core/PluginManager.js.map +0 -1
- package/bin/Core/ServiceContainer.d.ts +0 -221
- package/bin/Core/ServiceContainer.d.ts.map +0 -1
- package/bin/Core/ServiceContainer.js +0 -352
- package/bin/Core/ServiceContainer.js.map +0 -1
- package/bin/Core.d.ts +0 -379
- package/bin/Core.d.ts.map +0 -1
- package/bin/Core.js +0 -553
- package/bin/Core.js.map +0 -1
- package/bin/ECS/Component.d.ts +0 -104
- package/bin/ECS/Component.d.ts.map +0 -1
- package/bin/ECS/Component.js +0 -105
- package/bin/ECS/Component.js.map +0 -1
- package/bin/ECS/Components/HierarchyComponent.d.ts +0 -46
- package/bin/ECS/Components/HierarchyComponent.d.ts.map +0 -1
- package/bin/ECS/Components/HierarchyComponent.js +0 -65
- package/bin/ECS/Components/HierarchyComponent.js.map +0 -1
- package/bin/ECS/Components/index.d.ts +0 -2
- package/bin/ECS/Components/index.d.ts.map +0 -1
- package/bin/ECS/Components/index.js +0 -2
- package/bin/ECS/Components/index.js.map +0 -1
- package/bin/ECS/Core/ArchetypeSystem.d.ts +0 -103
- package/bin/ECS/Core/ArchetypeSystem.d.ts.map +0 -1
- package/bin/ECS/Core/ArchetypeSystem.js +0 -244
- package/bin/ECS/Core/ArchetypeSystem.js.map +0 -1
- package/bin/ECS/Core/CommandBuffer.d.ts +0 -154
- package/bin/ECS/Core/CommandBuffer.d.ts.map +0 -1
- package/bin/ECS/Core/CommandBuffer.js +0 -244
- package/bin/ECS/Core/CommandBuffer.js.map +0 -1
- package/bin/ECS/Core/ComponentPool.d.ts +0 -139
- package/bin/ECS/Core/ComponentPool.d.ts.map +0 -1
- package/bin/ECS/Core/ComponentPool.js +0 -276
- package/bin/ECS/Core/ComponentPool.js.map +0 -1
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +0 -127
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +0 -1
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +0 -235
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +0 -1
- package/bin/ECS/Core/ComponentStorage.d.ts +0 -185
- package/bin/ECS/Core/ComponentStorage.d.ts.map +0 -1
- package/bin/ECS/Core/ComponentStorage.js +0 -321
- package/bin/ECS/Core/ComponentStorage.js.map +0 -1
- package/bin/ECS/Core/EntityLifecyclePolicy.d.ts +0 -26
- package/bin/ECS/Core/EntityLifecyclePolicy.d.ts.map +0 -1
- package/bin/ECS/Core/EntityLifecyclePolicy.js +0 -2
- package/bin/ECS/Core/EntityLifecyclePolicy.js.map +0 -1
- package/bin/ECS/Core/EventBus.d.ts +0 -210
- package/bin/ECS/Core/EventBus.d.ts.map +0 -1
- package/bin/ECS/Core/EventBus.js +0 -370
- package/bin/ECS/Core/EventBus.js.map +0 -1
- package/bin/ECS/Core/EventSystem.d.ts +0 -225
- package/bin/ECS/Core/EventSystem.d.ts.map +0 -1
- package/bin/ECS/Core/EventSystem.js +0 -448
- package/bin/ECS/Core/EventSystem.js.map +0 -1
- package/bin/ECS/Core/Events/index.d.ts +0 -3
- package/bin/ECS/Core/Events/index.d.ts.map +0 -1
- package/bin/ECS/Core/Events/index.js +0 -3
- package/bin/ECS/Core/Events/index.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +0 -35
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +0 -48
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +0 -135
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +0 -166
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +0 -58
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +0 -85
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +0 -110
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js +0 -181
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +0 -53
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js +0 -79
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +0 -1
- package/bin/ECS/Core/FluentAPI/index.d.ts +0 -6
- package/bin/ECS/Core/FluentAPI/index.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI/index.js +0 -6
- package/bin/ECS/Core/FluentAPI/index.js.map +0 -1
- package/bin/ECS/Core/FluentAPI.d.ts +0 -2
- package/bin/ECS/Core/FluentAPI.d.ts.map +0 -1
- package/bin/ECS/Core/FluentAPI.js +0 -3
- package/bin/ECS/Core/FluentAPI.js.map +0 -1
- package/bin/ECS/Core/Query/TypedQuery.d.ts +0 -214
- package/bin/ECS/Core/Query/TypedQuery.d.ts.map +0 -1
- package/bin/ECS/Core/Query/TypedQuery.js +0 -294
- package/bin/ECS/Core/Query/TypedQuery.js.map +0 -1
- package/bin/ECS/Core/Query/index.d.ts +0 -3
- package/bin/ECS/Core/Query/index.d.ts.map +0 -1
- package/bin/ECS/Core/Query/index.js +0 -3
- package/bin/ECS/Core/Query/index.js.map +0 -1
- package/bin/ECS/Core/QuerySystem.d.ts +0 -458
- package/bin/ECS/Core/QuerySystem.d.ts.map +0 -1
- package/bin/ECS/Core/QuerySystem.js +0 -1069
- package/bin/ECS/Core/QuerySystem.js.map +0 -1
- package/bin/ECS/Core/QueryTypes.d.ts +0 -34
- package/bin/ECS/Core/QueryTypes.d.ts.map +0 -1
- package/bin/ECS/Core/QueryTypes.js +0 -13
- package/bin/ECS/Core/QueryTypes.js.map +0 -1
- package/bin/ECS/Core/ReactiveQuery.d.ts +0 -211
- package/bin/ECS/Core/ReactiveQuery.d.ts.map +0 -1
- package/bin/ECS/Core/ReactiveQuery.js +0 -401
- package/bin/ECS/Core/ReactiveQuery.js.map +0 -1
- package/bin/ECS/Core/ReferenceTracker.d.ts +0 -111
- package/bin/ECS/Core/ReferenceTracker.d.ts.map +0 -1
- package/bin/ECS/Core/ReferenceTracker.js +0 -254
- package/bin/ECS/Core/ReferenceTracker.js.map +0 -1
- package/bin/ECS/Core/SoASerializer.d.ts +0 -28
- package/bin/ECS/Core/SoASerializer.d.ts.map +0 -1
- package/bin/ECS/Core/SoASerializer.js +0 -85
- package/bin/ECS/Core/SoASerializer.js.map +0 -1
- package/bin/ECS/Core/SoAStorage.d.ts +0 -129
- package/bin/ECS/Core/SoAStorage.d.ts.map +0 -1
- package/bin/ECS/Core/SoAStorage.js +0 -685
- package/bin/ECS/Core/SoAStorage.js.map +0 -1
- package/bin/ECS/Core/SoATypeRegistry.d.ts +0 -50
- package/bin/ECS/Core/SoATypeRegistry.d.ts.map +0 -1
- package/bin/ECS/Core/SoATypeRegistry.js +0 -135
- package/bin/ECS/Core/SoATypeRegistry.js.map +0 -1
- package/bin/ECS/Core/Storage/index.d.ts +0 -4
- package/bin/ECS/Core/Storage/index.d.ts.map +0 -1
- package/bin/ECS/Core/Storage/index.js +0 -4
- package/bin/ECS/Core/Storage/index.js.map +0 -1
- package/bin/ECS/Core/StorageDecorators.d.ts +0 -20
- package/bin/ECS/Core/StorageDecorators.d.ts.map +0 -1
- package/bin/ECS/Core/StorageDecorators.js +0 -27
- package/bin/ECS/Core/StorageDecorators.js.map +0 -1
- package/bin/ECS/CoreEvents.d.ts +0 -131
- package/bin/ECS/CoreEvents.d.ts.map +0 -1
- package/bin/ECS/CoreEvents.js +0 -163
- package/bin/ECS/CoreEvents.js.map +0 -1
- package/bin/ECS/Decorators/EntityRefDecorator.d.ts +0 -46
- package/bin/ECS/Decorators/EntityRefDecorator.d.ts.map +0 -1
- package/bin/ECS/Decorators/EntityRefDecorator.js +0 -118
- package/bin/ECS/Decorators/EntityRefDecorator.js.map +0 -1
- package/bin/ECS/Decorators/PropertyDecorator.d.ts +0 -168
- package/bin/ECS/Decorators/PropertyDecorator.d.ts.map +0 -1
- package/bin/ECS/Decorators/PropertyDecorator.js +0 -40
- package/bin/ECS/Decorators/PropertyDecorator.js.map +0 -1
- package/bin/ECS/Decorators/TypeDecorators.d.ts +0 -124
- package/bin/ECS/Decorators/TypeDecorators.d.ts.map +0 -1
- package/bin/ECS/Decorators/TypeDecorators.js +0 -151
- package/bin/ECS/Decorators/TypeDecorators.js.map +0 -1
- package/bin/ECS/Decorators/index.d.ts +0 -7
- package/bin/ECS/Decorators/index.d.ts.map +0 -1
- package/bin/ECS/Decorators/index.js +0 -4
- package/bin/ECS/Decorators/index.js.map +0 -1
- package/bin/ECS/Entity.d.ts +0 -415
- package/bin/ECS/Entity.d.ts.map +0 -1
- package/bin/ECS/Entity.js +0 -683
- package/bin/ECS/Entity.js.map +0 -1
- package/bin/ECS/EntityTags.d.ts +0 -71
- package/bin/ECS/EntityTags.d.ts.map +0 -1
- package/bin/ECS/EntityTags.js +0 -82
- package/bin/ECS/EntityTags.js.map +0 -1
- package/bin/ECS/IScene.d.ts +0 -308
- package/bin/ECS/IScene.d.ts.map +0 -1
- package/bin/ECS/IScene.js +0 -2
- package/bin/ECS/IScene.js.map +0 -1
- package/bin/ECS/Scene.d.ts +0 -799
- package/bin/ECS/Scene.d.ts.map +0 -1
- package/bin/ECS/Scene.js +0 -1203
- package/bin/ECS/Scene.js.map +0 -1
- package/bin/ECS/SceneManager.d.ts +0 -197
- package/bin/ECS/SceneManager.d.ts.map +0 -1
- package/bin/ECS/SceneManager.js +0 -264
- package/bin/ECS/SceneManager.js.map +0 -1
- package/bin/ECS/Serialization/ComponentSerializer.d.ts +0 -106
- package/bin/ECS/Serialization/ComponentSerializer.d.ts.map +0 -1
- package/bin/ECS/Serialization/ComponentSerializer.js +0 -251
- package/bin/ECS/Serialization/ComponentSerializer.js.map +0 -1
- package/bin/ECS/Serialization/EntitySerializer.d.ts +0 -111
- package/bin/ECS/Serialization/EntitySerializer.d.ts.map +0 -1
- package/bin/ECS/Serialization/EntitySerializer.js +0 -155
- package/bin/ECS/Serialization/EntitySerializer.js.map +0 -1
- package/bin/ECS/Serialization/IncrementalSerializer.d.ts +0 -259
- package/bin/ECS/Serialization/IncrementalSerializer.d.ts.map +0 -1
- package/bin/ECS/Serialization/IncrementalSerializer.js +0 -500
- package/bin/ECS/Serialization/IncrementalSerializer.js.map +0 -1
- package/bin/ECS/Serialization/SceneSerializer.d.ts +0 -213
- package/bin/ECS/Serialization/SceneSerializer.d.ts.map +0 -1
- package/bin/ECS/Serialization/SceneSerializer.js +0 -387
- package/bin/ECS/Serialization/SceneSerializer.js.map +0 -1
- package/bin/ECS/Serialization/SerializationDecorators.d.ts +0 -136
- package/bin/ECS/Serialization/SerializationDecorators.d.ts.map +0 -1
- package/bin/ECS/Serialization/SerializationDecorators.js +0 -216
- package/bin/ECS/Serialization/SerializationDecorators.js.map +0 -1
- package/bin/ECS/Serialization/VersionMigration.d.ts +0 -156
- package/bin/ECS/Serialization/VersionMigration.d.ts.map +0 -1
- package/bin/ECS/Serialization/VersionMigration.js +0 -279
- package/bin/ECS/Serialization/VersionMigration.js.map +0 -1
- package/bin/ECS/Serialization/index.d.ts +0 -18
- package/bin/ECS/Serialization/index.d.ts.map +0 -1
- package/bin/ECS/Serialization/index.js +0 -18
- package/bin/ECS/Serialization/index.js.map +0 -1
- package/bin/ECS/Systems/EntityCache.d.ts +0 -114
- package/bin/ECS/Systems/EntityCache.d.ts.map +0 -1
- package/bin/ECS/Systems/EntityCache.js +0 -145
- package/bin/ECS/Systems/EntityCache.js.map +0 -1
- package/bin/ECS/Systems/EntitySystem.d.ts +0 -591
- package/bin/ECS/Systems/EntitySystem.d.ts.map +0 -1
- package/bin/ECS/Systems/EntitySystem.js +0 -1102
- package/bin/ECS/Systems/EntitySystem.js.map +0 -1
- package/bin/ECS/Systems/HierarchySystem.d.ts +0 -155
- package/bin/ECS/Systems/HierarchySystem.d.ts.map +0 -1
- package/bin/ECS/Systems/HierarchySystem.js +0 -498
- package/bin/ECS/Systems/HierarchySystem.js.map +0 -1
- package/bin/ECS/Systems/IntervalSystem.d.ts +0 -33
- package/bin/ECS/Systems/IntervalSystem.d.ts.map +0 -1
- package/bin/ECS/Systems/IntervalSystem.js +0 -50
- package/bin/ECS/Systems/IntervalSystem.js.map +0 -1
- package/bin/ECS/Systems/PassiveSystem.d.ts +0 -17
- package/bin/ECS/Systems/PassiveSystem.d.ts.map +0 -1
- package/bin/ECS/Systems/PassiveSystem.js +0 -19
- package/bin/ECS/Systems/PassiveSystem.js.map +0 -1
- package/bin/ECS/Systems/ProcessingSystem.d.ts +0 -21
- package/bin/ECS/Systems/ProcessingSystem.d.ts.map +0 -1
- package/bin/ECS/Systems/ProcessingSystem.js +0 -20
- package/bin/ECS/Systems/ProcessingSystem.js.map +0 -1
- package/bin/ECS/Systems/WorkerEntitySystem.d.ts +0 -313
- package/bin/ECS/Systems/WorkerEntitySystem.d.ts.map +0 -1
- package/bin/ECS/Systems/WorkerEntitySystem.js +0 -792
- package/bin/ECS/Systems/WorkerEntitySystem.js.map +0 -1
- package/bin/ECS/Systems/index.d.ts +0 -8
- package/bin/ECS/Systems/index.d.ts.map +0 -1
- package/bin/ECS/Systems/index.js +0 -8
- package/bin/ECS/Systems/index.js.map +0 -1
- package/bin/ECS/TypedEntity.d.ts +0 -192
- package/bin/ECS/TypedEntity.d.ts.map +0 -1
- package/bin/ECS/TypedEntity.js +0 -254
- package/bin/ECS/TypedEntity.js.map +0 -1
- package/bin/ECS/Utils/BigIntCompatibility.d.ts +0 -151
- package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +0 -1
- package/bin/ECS/Utils/BigIntCompatibility.js +0 -476
- package/bin/ECS/Utils/BigIntCompatibility.js.map +0 -1
- package/bin/ECS/Utils/BitMaskHashMap.d.ts +0 -28
- package/bin/ECS/Utils/BitMaskHashMap.d.ts.map +0 -1
- package/bin/ECS/Utils/BitMaskHashMap.js +0 -127
- package/bin/ECS/Utils/BitMaskHashMap.js.map +0 -1
- package/bin/ECS/Utils/Bits.d.ts +0 -154
- package/bin/ECS/Utils/Bits.d.ts.map +0 -1
- package/bin/ECS/Utils/Bits.js +0 -331
- package/bin/ECS/Utils/Bits.js.map +0 -1
- package/bin/ECS/Utils/ComponentSparseSet.d.ts +0 -143
- package/bin/ECS/Utils/ComponentSparseSet.d.ts.map +0 -1
- package/bin/ECS/Utils/ComponentSparseSet.js +0 -347
- package/bin/ECS/Utils/ComponentSparseSet.js.map +0 -1
- package/bin/ECS/Utils/EntityList.d.ts +0 -115
- package/bin/ECS/Utils/EntityList.d.ts.map +0 -1
- package/bin/ECS/Utils/EntityList.js +0 -258
- package/bin/ECS/Utils/EntityList.js.map +0 -1
- package/bin/ECS/Utils/EntityProcessorList.d.ts +0 -56
- package/bin/ECS/Utils/EntityProcessorList.d.ts.map +0 -1
- package/bin/ECS/Utils/EntityProcessorList.js +0 -113
- package/bin/ECS/Utils/EntityProcessorList.js.map +0 -1
- package/bin/ECS/Utils/IdentifierPool.d.ts +0 -203
- package/bin/ECS/Utils/IdentifierPool.d.ts.map +0 -1
- package/bin/ECS/Utils/IdentifierPool.js +0 -325
- package/bin/ECS/Utils/IdentifierPool.js.map +0 -1
- package/bin/ECS/Utils/Matcher.d.ts +0 -171
- package/bin/ECS/Utils/Matcher.d.ts.map +0 -1
- package/bin/ECS/Utils/Matcher.js +0 -293
- package/bin/ECS/Utils/Matcher.js.map +0 -1
- package/bin/ECS/Utils/SparseSet.d.ts +0 -170
- package/bin/ECS/Utils/SparseSet.d.ts.map +0 -1
- package/bin/ECS/Utils/SparseSet.js +0 -280
- package/bin/ECS/Utils/SparseSet.js.map +0 -1
- package/bin/ECS/Utils/index.d.ts +0 -9
- package/bin/ECS/Utils/index.d.ts.map +0 -1
- package/bin/ECS/Utils/index.js +0 -10
- package/bin/ECS/Utils/index.js.map +0 -1
- package/bin/ECS/World.d.ts +0 -238
- package/bin/ECS/World.d.ts.map +0 -1
- package/bin/ECS/World.js +0 -416
- package/bin/ECS/World.js.map +0 -1
- package/bin/ECS/WorldManager.d.ts +0 -224
- package/bin/ECS/WorldManager.d.ts.map +0 -1
- package/bin/ECS/WorldManager.js +0 -365
- package/bin/ECS/WorldManager.js.map +0 -1
- package/bin/ECS/index.d.ts +0 -26
- package/bin/ECS/index.d.ts.map +0 -1
- package/bin/ECS/index.js +0 -21
- package/bin/ECS/index.js.map +0 -1
- package/bin/Platform/IPlatformAdapter.d.ts +0 -169
- package/bin/Platform/IPlatformAdapter.d.ts.map +0 -1
- package/bin/Platform/IPlatformAdapter.js +0 -2
- package/bin/Platform/IPlatformAdapter.js.map +0 -1
- package/bin/Platform/PlatformDetector.d.ts +0 -56
- package/bin/Platform/PlatformDetector.d.ts.map +0 -1
- package/bin/Platform/PlatformDetector.js +0 -247
- package/bin/Platform/PlatformDetector.js.map +0 -1
- package/bin/Platform/PlatformManager.d.ts +0 -50
- package/bin/Platform/PlatformManager.d.ts.map +0 -1
- package/bin/Platform/PlatformManager.js +0 -114
- package/bin/Platform/PlatformManager.js.map +0 -1
- package/bin/Platform/index.d.ts +0 -19
- package/bin/Platform/index.d.ts.map +0 -1
- package/bin/Platform/index.js +0 -29
- package/bin/Platform/index.js.map +0 -1
- package/bin/Plugins/DebugPlugin.d.ts +0 -156
- package/bin/Plugins/DebugPlugin.d.ts.map +0 -1
- package/bin/Plugins/DebugPlugin.js +0 -248
- package/bin/Plugins/DebugPlugin.js.map +0 -1
- package/bin/Plugins/index.d.ts +0 -2
- package/bin/Plugins/index.d.ts.map +0 -1
- package/bin/Plugins/index.js +0 -2
- package/bin/Plugins/index.js.map +0 -1
- package/bin/Types/IUpdatable.d.ts +0 -18
- package/bin/Types/IUpdatable.d.ts.map +0 -1
- package/bin/Types/IUpdatable.js +0 -7
- package/bin/Types/IUpdatable.js.map +0 -1
- package/bin/Types/TypeHelpers.d.ts +0 -238
- package/bin/Types/TypeHelpers.d.ts.map +0 -1
- package/bin/Types/TypeHelpers.js +0 -19
- package/bin/Types/TypeHelpers.js.map +0 -1
- package/bin/Types/index.d.ts +0 -466
- package/bin/Types/index.d.ts.map +0 -1
- package/bin/Types/index.js +0 -7
- package/bin/Types/index.js.map +0 -1
- package/bin/Utils/BinarySerializer.d.ts +0 -23
- package/bin/Utils/BinarySerializer.d.ts.map +0 -1
- package/bin/Utils/BinarySerializer.js +0 -100
- package/bin/Utils/BinarySerializer.js.map +0 -1
- package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts +0 -153
- package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/AdvancedProfilerCollector.js +0 -406
- package/bin/Utils/Debug/AdvancedProfilerCollector.js.map +0 -1
- package/bin/Utils/Debug/ComponentDataCollector.d.ts +0 -32
- package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/ComponentDataCollector.js +0 -250
- package/bin/Utils/Debug/ComponentDataCollector.js.map +0 -1
- package/bin/Utils/Debug/DebugConfigService.d.ts +0 -16
- package/bin/Utils/Debug/DebugConfigService.d.ts.map +0 -1
- package/bin/Utils/Debug/DebugConfigService.js +0 -42
- package/bin/Utils/Debug/DebugConfigService.js.map +0 -1
- package/bin/Utils/Debug/DebugManager.d.ts +0 -131
- package/bin/Utils/Debug/DebugManager.d.ts.map +0 -1
- package/bin/Utils/Debug/DebugManager.js +0 -848
- package/bin/Utils/Debug/DebugManager.js.map +0 -1
- package/bin/Utils/Debug/EntityDataCollector.d.ts +0 -115
- package/bin/Utils/Debug/EntityDataCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/EntityDataCollector.js +0 -870
- package/bin/Utils/Debug/EntityDataCollector.js.map +0 -1
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts +0 -31
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/PerformanceDataCollector.js +0 -203
- package/bin/Utils/Debug/PerformanceDataCollector.js.map +0 -1
- package/bin/Utils/Debug/SceneDataCollector.d.ts +0 -18
- package/bin/Utils/Debug/SceneDataCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/SceneDataCollector.js +0 -43
- package/bin/Utils/Debug/SceneDataCollector.js.map +0 -1
- package/bin/Utils/Debug/SystemDataCollector.d.ts +0 -14
- package/bin/Utils/Debug/SystemDataCollector.d.ts.map +0 -1
- package/bin/Utils/Debug/SystemDataCollector.js +0 -60
- package/bin/Utils/Debug/SystemDataCollector.js.map +0 -1
- package/bin/Utils/Debug/WebSocketManager.d.ts +0 -54
- package/bin/Utils/Debug/WebSocketManager.d.ts.map +0 -1
- package/bin/Utils/Debug/WebSocketManager.js +0 -141
- package/bin/Utils/Debug/WebSocketManager.js.map +0 -1
- package/bin/Utils/Debug/index.d.ts +0 -11
- package/bin/Utils/Debug/index.d.ts.map +0 -1
- package/bin/Utils/Debug/index.js +0 -10
- package/bin/Utils/Debug/index.js.map +0 -1
- package/bin/Utils/Emitter.d.ts +0 -61
- package/bin/Utils/Emitter.d.ts.map +0 -1
- package/bin/Utils/Emitter.js +0 -101
- package/bin/Utils/Emitter.js.map +0 -1
- package/bin/Utils/Extensions/NumberExtension.d.ts +0 -13
- package/bin/Utils/Extensions/NumberExtension.d.ts.map +0 -1
- package/bin/Utils/Extensions/NumberExtension.js +0 -17
- package/bin/Utils/Extensions/NumberExtension.js.map +0 -1
- package/bin/Utils/Extensions/TypeUtils.d.ts +0 -13
- package/bin/Utils/Extensions/TypeUtils.d.ts.map +0 -1
- package/bin/Utils/Extensions/TypeUtils.js +0 -15
- package/bin/Utils/Extensions/TypeUtils.js.map +0 -1
- package/bin/Utils/Extensions/index.d.ts +0 -3
- package/bin/Utils/Extensions/index.d.ts.map +0 -1
- package/bin/Utils/Extensions/index.js +0 -4
- package/bin/Utils/Extensions/index.js.map +0 -1
- package/bin/Utils/GlobalManager.d.ts +0 -29
- package/bin/Utils/GlobalManager.d.ts.map +0 -1
- package/bin/Utils/GlobalManager.js +0 -50
- package/bin/Utils/GlobalManager.js.map +0 -1
- package/bin/Utils/Logger/ConsoleLogger.d.ts +0 -74
- package/bin/Utils/Logger/ConsoleLogger.d.ts.map +0 -1
- package/bin/Utils/Logger/ConsoleLogger.js +0 -187
- package/bin/Utils/Logger/ConsoleLogger.js.map +0 -1
- package/bin/Utils/Logger/Constants.d.ts +0 -36
- package/bin/Utils/Logger/Constants.d.ts.map +0 -1
- package/bin/Utils/Logger/Constants.js +0 -40
- package/bin/Utils/Logger/Constants.js.map +0 -1
- package/bin/Utils/Logger/LoggerManager.d.ts +0 -91
- package/bin/Utils/Logger/LoggerManager.d.ts.map +0 -1
- package/bin/Utils/Logger/LoggerManager.js +0 -167
- package/bin/Utils/Logger/LoggerManager.js.map +0 -1
- package/bin/Utils/Logger/Types.d.ts +0 -40
- package/bin/Utils/Logger/Types.d.ts.map +0 -1
- package/bin/Utils/Logger/Types.js +0 -2
- package/bin/Utils/Logger/Types.js.map +0 -1
- package/bin/Utils/Logger/index.d.ts +0 -5
- package/bin/Utils/Logger/index.d.ts.map +0 -1
- package/bin/Utils/Logger/index.js +0 -5
- package/bin/Utils/Logger/index.js.map +0 -1
- package/bin/Utils/PerformanceMonitor.d.ts +0 -196
- package/bin/Utils/PerformanceMonitor.d.ts.map +0 -1
- package/bin/Utils/PerformanceMonitor.js +0 -244
- package/bin/Utils/PerformanceMonitor.js.map +0 -1
- package/bin/Utils/Pool/IPoolable.d.ts +0 -29
- package/bin/Utils/Pool/IPoolable.d.ts.map +0 -1
- package/bin/Utils/Pool/IPoolable.js +0 -2
- package/bin/Utils/Pool/IPoolable.js.map +0 -1
- package/bin/Utils/Pool/Pool.d.ts +0 -109
- package/bin/Utils/Pool/Pool.d.ts.map +0 -1
- package/bin/Utils/Pool/Pool.js +0 -238
- package/bin/Utils/Pool/Pool.js.map +0 -1
- package/bin/Utils/Pool/PoolManager.d.ts +0 -96
- package/bin/Utils/Pool/PoolManager.d.ts.map +0 -1
- package/bin/Utils/Pool/PoolManager.js +0 -199
- package/bin/Utils/Pool/PoolManager.js.map +0 -1
- package/bin/Utils/Pool/index.d.ts +0 -4
- package/bin/Utils/Pool/index.d.ts.map +0 -1
- package/bin/Utils/Pool/index.js +0 -4
- package/bin/Utils/Pool/index.js.map +0 -1
- package/bin/Utils/Profiler/AutoProfiler.d.ts +0 -160
- package/bin/Utils/Profiler/AutoProfiler.d.ts.map +0 -1
- package/bin/Utils/Profiler/AutoProfiler.js +0 -503
- package/bin/Utils/Profiler/AutoProfiler.js.map +0 -1
- package/bin/Utils/Profiler/ProfilerSDK.d.ts +0 -175
- package/bin/Utils/Profiler/ProfilerSDK.d.ts.map +0 -1
- package/bin/Utils/Profiler/ProfilerSDK.js +0 -727
- package/bin/Utils/Profiler/ProfilerSDK.js.map +0 -1
- package/bin/Utils/Profiler/ProfilerTypes.d.ts +0 -218
- package/bin/Utils/Profiler/ProfilerTypes.d.ts.map +0 -1
- package/bin/Utils/Profiler/ProfilerTypes.js +0 -47
- package/bin/Utils/Profiler/ProfilerTypes.js.map +0 -1
- package/bin/Utils/Profiler/index.d.ts +0 -8
- package/bin/Utils/Profiler/index.d.ts.map +0 -1
- package/bin/Utils/Profiler/index.js +0 -7
- package/bin/Utils/Profiler/index.js.map +0 -1
- package/bin/Utils/Time.d.ts +0 -47
- package/bin/Utils/Time.d.ts.map +0 -1
- package/bin/Utils/Time.js +0 -64
- package/bin/Utils/Time.js.map +0 -1
- package/bin/Utils/Timers/ITimer.d.ts +0 -16
- package/bin/Utils/Timers/ITimer.d.ts.map +0 -1
- package/bin/Utils/Timers/ITimer.js +0 -2
- package/bin/Utils/Timers/ITimer.js.map +0 -1
- package/bin/Utils/Timers/Timer.d.ts +0 -30
- package/bin/Utils/Timers/Timer.d.ts.map +0 -1
- package/bin/Utils/Timers/Timer.js +0 -58
- package/bin/Utils/Timers/Timer.js.map +0 -1
- package/bin/Utils/Timers/TimerManager.d.ts +0 -26
- package/bin/Utils/Timers/TimerManager.d.ts.map +0 -1
- package/bin/Utils/Timers/TimerManager.js +0 -48
- package/bin/Utils/Timers/TimerManager.js.map +0 -1
- package/bin/Utils/index.d.ts +0 -11
- package/bin/Utils/index.d.ts.map +0 -1
- package/bin/Utils/index.js +0 -11
- package/bin/Utils/index.js.map +0 -1
- package/bin/index.d.ts +0 -29
- package/bin/index.d.ts.map +0 -1
- package/bin/index.js +0 -36
- package/bin/index.js.map +0 -1
package/bin/ECS/Scene.js
DELETED
|
@@ -1,1203 +0,0 @@
|
|
|
1
|
-
import { Entity } from './Entity';
|
|
2
|
-
import { EntityList } from './Utils/EntityList';
|
|
3
|
-
import { IdentifierPool } from './Utils/IdentifierPool';
|
|
4
|
-
import { EntitySystem } from './Systems/EntitySystem';
|
|
5
|
-
import { ComponentStorageManager, ComponentRegistry } from './Core/ComponentStorage';
|
|
6
|
-
import { QuerySystem } from './Core/QuerySystem';
|
|
7
|
-
import { TypeSafeEventSystem } from './Core/EventSystem';
|
|
8
|
-
import { ReferenceTracker } from './Core/ReferenceTracker';
|
|
9
|
-
import { getComponentInstanceTypeName, getSystemInstanceTypeName, getSystemMetadata } from './Decorators';
|
|
10
|
-
import { TypedQueryBuilder } from './Core/Query/TypedQuery';
|
|
11
|
-
import { SceneSerializer } from './Serialization/SceneSerializer';
|
|
12
|
-
import { IncrementalSerializer } from './Serialization/IncrementalSerializer';
|
|
13
|
-
import { ComponentPoolManager } from './Core/ComponentPool';
|
|
14
|
-
import { PerformanceMonitor } from '../Utils/PerformanceMonitor';
|
|
15
|
-
import { ProfilerSDK } from '../Utils/Profiler/ProfilerSDK';
|
|
16
|
-
import { ProfileCategory } from '../Utils/Profiler/ProfilerTypes';
|
|
17
|
-
import { AutoProfiler } from '../Utils/Profiler/AutoProfiler';
|
|
18
|
-
import { ServiceContainer } from '../Core/ServiceContainer';
|
|
19
|
-
import { createInstance, isInjectable, injectProperties } from '../Core/DI';
|
|
20
|
-
import { createLogger } from '../Utils/Logger';
|
|
21
|
-
/**
|
|
22
|
-
* 游戏场景默认实现类
|
|
23
|
-
*
|
|
24
|
-
* 实现IScene接口,提供场景的基础功能。
|
|
25
|
-
* 推荐使用组合而非继承的方式来构建自定义场景。
|
|
26
|
-
*/
|
|
27
|
-
export class Scene {
|
|
28
|
-
/**
|
|
29
|
-
* 获取场景中所有已注册的EntitySystem
|
|
30
|
-
*
|
|
31
|
-
* 按updateOrder排序。使用缓存机制,仅在系统变化时重新排序。
|
|
32
|
-
*
|
|
33
|
-
* @returns 系统列表
|
|
34
|
-
*/
|
|
35
|
-
get systems() {
|
|
36
|
-
if (!this._systemsOrderDirty && this._cachedSystems) {
|
|
37
|
-
return this._cachedSystems;
|
|
38
|
-
}
|
|
39
|
-
this._cachedSystems = this._rebuildSystemsCache();
|
|
40
|
-
this._systemsOrderDirty = false;
|
|
41
|
-
return this._cachedSystems;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 重新构建系统缓存
|
|
45
|
-
*
|
|
46
|
-
* 从服务容器中提取所有EntitySystem并排序
|
|
47
|
-
*/
|
|
48
|
-
_rebuildSystemsCache() {
|
|
49
|
-
const allServices = this._services.getAll();
|
|
50
|
-
const systems = this._filterEntitySystems(allServices);
|
|
51
|
-
return this._sortSystemsByUpdateOrder(systems);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 从服务列表中过滤出EntitySystem实例
|
|
55
|
-
*/
|
|
56
|
-
_filterEntitySystems(services) {
|
|
57
|
-
return services.filter((service) => service instanceof EntitySystem);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 按 updateOrder 排序系统,相同时按 addOrder 保证稳定性
|
|
61
|
-
* Sort systems by updateOrder, use addOrder as secondary key for stability
|
|
62
|
-
*/
|
|
63
|
-
_sortSystemsByUpdateOrder(systems) {
|
|
64
|
-
return systems.sort((a, b) => {
|
|
65
|
-
const orderDiff = a.updateOrder - b.updateOrder;
|
|
66
|
-
if (orderDiff !== 0)
|
|
67
|
-
return orderDiff;
|
|
68
|
-
return a.addOrder - b.addOrder;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* 通过类型获取System实例
|
|
73
|
-
*
|
|
74
|
-
* @param systemType System类型
|
|
75
|
-
* @returns System实例,如果未找到则返回null
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* const physics = scene.getSystem(PhysicsSystem);
|
|
80
|
-
* if (physics) {
|
|
81
|
-
* physics.doSomething();
|
|
82
|
-
* }
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
getSystem(systemType) {
|
|
86
|
-
return this._services.tryResolve(systemType);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 标记系统顺序为脏
|
|
90
|
-
*
|
|
91
|
-
* 当系统列表或顺序发生变化时调用,使缓存失效
|
|
92
|
-
*/
|
|
93
|
-
markSystemsOrderDirty() {
|
|
94
|
-
this._systemsOrderDirty = true;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 获取场景的服务容器
|
|
98
|
-
*
|
|
99
|
-
* 用于注册和解析场景级别的服务(如EntitySystem)。
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* // 注册服务
|
|
104
|
-
* scene.services.registerSingleton(PhysicsSystem);
|
|
105
|
-
*
|
|
106
|
-
* // 解析服务
|
|
107
|
-
* const physics = scene.services.resolve(PhysicsSystem);
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
get services() {
|
|
111
|
-
return this._services;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* 创建场景实例
|
|
115
|
-
*/
|
|
116
|
-
constructor(config) {
|
|
117
|
-
/**
|
|
118
|
-
* 场景名称
|
|
119
|
-
*
|
|
120
|
-
* 用于标识和调试的友好名称。
|
|
121
|
-
*/
|
|
122
|
-
this.name = '';
|
|
123
|
-
/**
|
|
124
|
-
* 场景自定义数据
|
|
125
|
-
*
|
|
126
|
-
* 用于存储场景级别的配置和状态数据。
|
|
127
|
-
*/
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
-
this.sceneData = new Map();
|
|
130
|
-
/**
|
|
131
|
-
* 性能监控器缓存
|
|
132
|
-
*
|
|
133
|
-
* 用于监控场景和系统的性能。从 ServiceContainer 获取。
|
|
134
|
-
*/
|
|
135
|
-
this._performanceMonitor = null;
|
|
136
|
-
/**
|
|
137
|
-
* 场景是否已开始运行
|
|
138
|
-
*/
|
|
139
|
-
this._didSceneBegin = false;
|
|
140
|
-
/**
|
|
141
|
-
* 编辑器模式标志
|
|
142
|
-
*
|
|
143
|
-
* 当为 true 时,组件的生命周期回调(如 onAddedToEntity)会被延迟,
|
|
144
|
-
* 直到调用 begin() 开始运行场景时才会触发。
|
|
145
|
-
*
|
|
146
|
-
* Editor mode flag.
|
|
147
|
-
* When true, component lifecycle callbacks (like onAddedToEntity) are deferred
|
|
148
|
-
* until begin() is called to start running the scene.
|
|
149
|
-
*/
|
|
150
|
-
this.isEditorMode = false;
|
|
151
|
-
/**
|
|
152
|
-
* 延迟的组件生命周期回调队列
|
|
153
|
-
*
|
|
154
|
-
* 在编辑器模式下,组件的 onAddedToEntity 回调会被加入此队列,
|
|
155
|
-
* 等到 begin() 调用时统一执行。
|
|
156
|
-
*
|
|
157
|
-
* Deferred component lifecycle callback queue.
|
|
158
|
-
* In editor mode, component's onAddedToEntity callbacks are queued here,
|
|
159
|
-
* and will be executed when begin() is called.
|
|
160
|
-
*/
|
|
161
|
-
this._deferredComponentCallbacks = [];
|
|
162
|
-
/**
|
|
163
|
-
* 系统列表缓存
|
|
164
|
-
*/
|
|
165
|
-
this._cachedSystems = null;
|
|
166
|
-
/**
|
|
167
|
-
* 系统顺序脏标记
|
|
168
|
-
*
|
|
169
|
-
* 当系统增删或 updateOrder 改变时标记为 true,下次访问 systems 时重新构建缓存
|
|
170
|
-
*/
|
|
171
|
-
this._systemsOrderDirty = true;
|
|
172
|
-
/**
|
|
173
|
-
* 系统错误计数器
|
|
174
|
-
*
|
|
175
|
-
* 跟踪每个系统的错误次数,用于自动禁用频繁出错的系统
|
|
176
|
-
*/
|
|
177
|
-
this._systemErrorCount = new Map();
|
|
178
|
-
/**
|
|
179
|
-
* 最大允许错误次数
|
|
180
|
-
*
|
|
181
|
-
* 系统错误次数超过此阈值后将被自动禁用
|
|
182
|
-
*/
|
|
183
|
-
this._maxErrorCount = 10;
|
|
184
|
-
/**
|
|
185
|
-
* 系统添加计数器
|
|
186
|
-
*
|
|
187
|
-
* 用于为每个添加的系统分配唯一的添加顺序,保证排序稳定性
|
|
188
|
-
* Counter for assigning unique add order to each system for stable sorting
|
|
189
|
-
*/
|
|
190
|
-
this._systemAddCounter = 0;
|
|
191
|
-
/**
|
|
192
|
-
* 组件ID到系统的索引映射
|
|
193
|
-
*
|
|
194
|
-
* 用于快速查找关心特定组件的系统,避免遍历所有系统。
|
|
195
|
-
* 使用组件ID(数字)而非ComponentType作为key,避免类引用问题。
|
|
196
|
-
*
|
|
197
|
-
* Component ID to systems index map.
|
|
198
|
-
* Used for fast lookup of systems that care about specific components.
|
|
199
|
-
* Uses component ID (number) instead of ComponentType as key to avoid class reference issues.
|
|
200
|
-
*/
|
|
201
|
-
this._componentIdToSystems = new Map();
|
|
202
|
-
/**
|
|
203
|
-
* 需要接收所有组件变化通知的系统集合
|
|
204
|
-
*
|
|
205
|
-
* 包括使用 none 条件、tag/name 查询、或空匹配器的系统。
|
|
206
|
-
* 这些系统无法通过组件ID索引优化,需要在每次组件变化时都检查。
|
|
207
|
-
*
|
|
208
|
-
* Systems that need to receive all component change notifications.
|
|
209
|
-
* Includes systems using none conditions, tag/name queries, or empty matchers.
|
|
210
|
-
* These systems cannot be optimized via component ID indexing.
|
|
211
|
-
*/
|
|
212
|
-
this._globalNotifySystems = new Set();
|
|
213
|
-
this.entities = new EntityList(this);
|
|
214
|
-
this.identifierPool = new IdentifierPool();
|
|
215
|
-
this.componentStorageManager = new ComponentStorageManager();
|
|
216
|
-
this.querySystem = new QuerySystem();
|
|
217
|
-
this.eventSystem = new TypeSafeEventSystem();
|
|
218
|
-
this.referenceTracker = new ReferenceTracker();
|
|
219
|
-
this._services = new ServiceContainer();
|
|
220
|
-
this.logger = createLogger('Scene');
|
|
221
|
-
if (config?.name) {
|
|
222
|
-
this.name = config.name;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 获取性能监控器
|
|
227
|
-
*
|
|
228
|
-
* 从 ServiceContainer 获取,如果未注册则创建默认实例(向后兼容)
|
|
229
|
-
*/
|
|
230
|
-
get performanceMonitor() {
|
|
231
|
-
if (!this._performanceMonitor) {
|
|
232
|
-
this._performanceMonitor = this._services.tryResolve(PerformanceMonitor) ?? new PerformanceMonitor();
|
|
233
|
-
}
|
|
234
|
-
return this._performanceMonitor;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* 初始化场景
|
|
238
|
-
*
|
|
239
|
-
* 在场景创建时调用,子类可以重写此方法来设置初始实体和组件。
|
|
240
|
-
*/
|
|
241
|
-
initialize() { }
|
|
242
|
-
/**
|
|
243
|
-
* 场景开始运行时的回调
|
|
244
|
-
*
|
|
245
|
-
* 在场景开始运行时调用,可以在此方法中执行场景启动逻辑。
|
|
246
|
-
*/
|
|
247
|
-
onStart() { }
|
|
248
|
-
/**
|
|
249
|
-
* 场景卸载时的回调
|
|
250
|
-
*
|
|
251
|
-
* 在场景被销毁时调用,可以在此方法中执行清理工作。
|
|
252
|
-
*/
|
|
253
|
-
unload() { }
|
|
254
|
-
/**
|
|
255
|
-
* 添加延迟的组件生命周期回调
|
|
256
|
-
*
|
|
257
|
-
* 在编辑器模式下,组件的 onAddedToEntity 回调会通过此方法加入队列。
|
|
258
|
-
*
|
|
259
|
-
* Queue a deferred component lifecycle callback.
|
|
260
|
-
* In editor mode, component's onAddedToEntity callbacks are queued via this method.
|
|
261
|
-
*
|
|
262
|
-
* @param callback 要延迟执行的回调 | The callback to defer
|
|
263
|
-
*/
|
|
264
|
-
queueDeferredComponentCallback(callback) {
|
|
265
|
-
this._deferredComponentCallbacks.push(callback);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* 开始场景,启动实体处理器等
|
|
269
|
-
*
|
|
270
|
-
* 这个方法会启动场景。它将启动实体处理器等,并调用onStart方法。
|
|
271
|
-
* 在编辑器模式下,此方法还会执行所有延迟的组件生命周期回调。
|
|
272
|
-
*
|
|
273
|
-
* This method starts the scene. It will start entity processors and call onStart.
|
|
274
|
-
* In editor mode, this method also executes all deferred component lifecycle callbacks.
|
|
275
|
-
*/
|
|
276
|
-
begin() {
|
|
277
|
-
// 标记场景已开始运行
|
|
278
|
-
this._didSceneBegin = true;
|
|
279
|
-
// 执行所有延迟的组件生命周期回调 | Execute all deferred component lifecycle callbacks
|
|
280
|
-
if (this._deferredComponentCallbacks.length > 0) {
|
|
281
|
-
for (const callback of this._deferredComponentCallbacks) {
|
|
282
|
-
try {
|
|
283
|
-
callback();
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
this.logger.error('Error executing deferred component callback:', error);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
// 清空队列 | Clear the queue
|
|
290
|
-
this._deferredComponentCallbacks = [];
|
|
291
|
-
}
|
|
292
|
-
// 调用onStart方法
|
|
293
|
-
this.onStart();
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* 结束场景,清除实体、实体处理器等
|
|
297
|
-
*
|
|
298
|
-
* 这个方法会结束场景。它将移除所有实体,结束实体处理器等,并调用unload方法。
|
|
299
|
-
*
|
|
300
|
-
* 执行顺序:
|
|
301
|
-
* 1. 调用 unload() - 用户可以在此访问实体和系统进行清理
|
|
302
|
-
* 2. 清理所有实体
|
|
303
|
-
* 3. 清空服务容器,触发所有系统的 onDestroy()
|
|
304
|
-
*
|
|
305
|
-
* 注意:
|
|
306
|
-
* - onRemoved 回调不会在 Scene.end() 时触发,因为这是批量销毁场景
|
|
307
|
-
* - 用户清理:在 Scene.unload() 中处理(可访问实体和系统)
|
|
308
|
-
* - 系统清理:在 System.onDestroy() 中处理(实体已被清理)
|
|
309
|
-
*/
|
|
310
|
-
end() {
|
|
311
|
-
// 标记场景已结束运行
|
|
312
|
-
this._didSceneBegin = false;
|
|
313
|
-
// 先调用用户的卸载方法,此时用户可以访问实体和系统进行清理
|
|
314
|
-
this.unload();
|
|
315
|
-
// 移除所有实体
|
|
316
|
-
this.entities.removeAllEntities();
|
|
317
|
-
// 清理查询系统中的实体引用和缓存
|
|
318
|
-
this.querySystem.setEntities([]);
|
|
319
|
-
// 清空组件存储
|
|
320
|
-
this.componentStorageManager.clear();
|
|
321
|
-
// 清空服务容器(会调用所有服务的dispose方法,包括所有EntitySystem)
|
|
322
|
-
// 系统的 onDestroy 回调会在这里被触发
|
|
323
|
-
this._services.clear();
|
|
324
|
-
// 清空系统缓存
|
|
325
|
-
this._cachedSystems = null;
|
|
326
|
-
this._systemsOrderDirty = true;
|
|
327
|
-
// 清空组件索引 | Clear component indices
|
|
328
|
-
this._componentIdToSystems.clear();
|
|
329
|
-
this._globalNotifySystems.clear();
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* 更新场景
|
|
333
|
-
*/
|
|
334
|
-
update() {
|
|
335
|
-
// 开始性能采样帧
|
|
336
|
-
ProfilerSDK.beginFrame();
|
|
337
|
-
const frameHandle = ProfilerSDK.beginSample('Scene.update', ProfileCategory.ECS);
|
|
338
|
-
try {
|
|
339
|
-
ComponentPoolManager.getInstance().update();
|
|
340
|
-
this.entities.updateLists();
|
|
341
|
-
const systems = this.systems;
|
|
342
|
-
// Update 阶段
|
|
343
|
-
const updateHandle = ProfilerSDK.beginSample('Systems.update', ProfileCategory.ECS);
|
|
344
|
-
try {
|
|
345
|
-
for (const system of systems) {
|
|
346
|
-
if (system.enabled) {
|
|
347
|
-
const systemHandle = ProfilerSDK.beginSample(system.systemName, ProfileCategory.ECS);
|
|
348
|
-
try {
|
|
349
|
-
system.update();
|
|
350
|
-
}
|
|
351
|
-
catch (error) {
|
|
352
|
-
this._handleSystemError(system, 'update', error);
|
|
353
|
-
}
|
|
354
|
-
finally {
|
|
355
|
-
ProfilerSDK.endSample(systemHandle);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
finally {
|
|
361
|
-
ProfilerSDK.endSample(updateHandle);
|
|
362
|
-
}
|
|
363
|
-
// LateUpdate 阶段
|
|
364
|
-
const lateUpdateHandle = ProfilerSDK.beginSample('Systems.lateUpdate', ProfileCategory.ECS);
|
|
365
|
-
try {
|
|
366
|
-
for (const system of systems) {
|
|
367
|
-
if (system.enabled) {
|
|
368
|
-
const systemHandle = ProfilerSDK.beginSample(`${system.systemName}.late`, ProfileCategory.ECS);
|
|
369
|
-
try {
|
|
370
|
-
system.lateUpdate();
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
this._handleSystemError(system, 'lateUpdate', error);
|
|
374
|
-
}
|
|
375
|
-
finally {
|
|
376
|
-
ProfilerSDK.endSample(systemHandle);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
finally {
|
|
382
|
-
ProfilerSDK.endSample(lateUpdateHandle);
|
|
383
|
-
}
|
|
384
|
-
// 执行所有系统的延迟命令
|
|
385
|
-
// Flush all systems' deferred commands
|
|
386
|
-
this.flushCommandBuffers(systems);
|
|
387
|
-
}
|
|
388
|
-
finally {
|
|
389
|
-
ProfilerSDK.endSample(frameHandle);
|
|
390
|
-
// 结束性能采样帧
|
|
391
|
-
ProfilerSDK.endFrame();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* 执行所有系统的延迟命令
|
|
396
|
-
* Flush all systems' deferred commands
|
|
397
|
-
*
|
|
398
|
-
* 在帧末统一执行所有通过 CommandBuffer 提交的延迟操作。
|
|
399
|
-
* Execute all deferred operations submitted via CommandBuffer at end of frame.
|
|
400
|
-
*/
|
|
401
|
-
flushCommandBuffers(systems) {
|
|
402
|
-
const flushHandle = ProfilerSDK.beginSample('Scene.flushCommandBuffers', ProfileCategory.ECS);
|
|
403
|
-
try {
|
|
404
|
-
for (const system of systems) {
|
|
405
|
-
try {
|
|
406
|
-
system.flushCommands();
|
|
407
|
-
}
|
|
408
|
-
catch (error) {
|
|
409
|
-
this.logger.error(`Error flushing commands for system ${system.systemName}:`, error);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
finally {
|
|
414
|
-
ProfilerSDK.endSample(flushHandle);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* 处理系统执行错误
|
|
419
|
-
*
|
|
420
|
-
* 记录错误信息并跟踪错误次数。当系统错误次数超过阈值时自动禁用该系统。
|
|
421
|
-
*
|
|
422
|
-
* @param system 出错的系统
|
|
423
|
-
* @param phase 错误发生的阶段(update 或 lateUpdate)
|
|
424
|
-
* @param error 错误对象
|
|
425
|
-
*/
|
|
426
|
-
_handleSystemError(system, phase, error) {
|
|
427
|
-
const errorCount = (this._systemErrorCount.get(system) || 0) + 1;
|
|
428
|
-
this._systemErrorCount.set(system, errorCount);
|
|
429
|
-
this.logger.error(`Error in system ${system.constructor.name}.${phase}() [${errorCount}/${this._maxErrorCount}]:`, error);
|
|
430
|
-
if (errorCount >= this._maxErrorCount) {
|
|
431
|
-
system.enabled = false;
|
|
432
|
-
this.logger.error(`System ${system.constructor.name} has been disabled due to excessive errors (${errorCount} errors)`);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* 将实体添加到此场景,并返回它
|
|
437
|
-
* @param name 实体名称
|
|
438
|
-
*/
|
|
439
|
-
createEntity(name) {
|
|
440
|
-
const entity = new Entity(name, this.identifierPool.checkOut());
|
|
441
|
-
this.eventSystem.emitSync('entity:created', { entityName: name, entity, scene: this });
|
|
442
|
-
return this.addEntity(entity);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* 清除所有EntitySystem的实体缓存
|
|
446
|
-
* 当实体或组件发生变化时调用
|
|
447
|
-
*/
|
|
448
|
-
clearSystemEntityCaches() {
|
|
449
|
-
for (const system of this.systems) {
|
|
450
|
-
system.clearEntityCache();
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* 通知相关系统实体的组件发生了变化
|
|
455
|
-
*
|
|
456
|
-
* 这是事件驱动设计的核心:当组件被添加或移除时,立即通知相关系统检查该实体是否匹配,
|
|
457
|
-
* 并触发 onAdded/onRemoved 回调。通过组件ID索引优化,只通知关心该组件的系统。
|
|
458
|
-
*
|
|
459
|
-
* This is the core of event-driven design: when a component is added or removed,
|
|
460
|
-
* immediately notify relevant systems to check if the entity matches and trigger
|
|
461
|
-
* onAdded/onRemoved callbacks. Optimized via component ID indexing to only notify
|
|
462
|
-
* systems that care about the changed component.
|
|
463
|
-
*
|
|
464
|
-
* @param entity 组件发生变化的实体 | The entity whose components changed
|
|
465
|
-
* @param changedComponentType 变化的组件类型(可选) | The changed component type (optional)
|
|
466
|
-
*/
|
|
467
|
-
notifyEntityComponentChanged(entity, changedComponentType) {
|
|
468
|
-
// 已通知的系统集合,避免重复通知 | Set of notified systems to avoid duplicates
|
|
469
|
-
const notifiedSystems = new Set();
|
|
470
|
-
// 如果提供了组件类型,使用索引优化 | If component type provided, use index optimization
|
|
471
|
-
if (changedComponentType && ComponentRegistry.isRegistered(changedComponentType)) {
|
|
472
|
-
const componentId = ComponentRegistry.getBitIndex(changedComponentType);
|
|
473
|
-
const interestedSystems = this._componentIdToSystems.get(componentId);
|
|
474
|
-
if (interestedSystems) {
|
|
475
|
-
for (const system of interestedSystems) {
|
|
476
|
-
system.handleEntityComponentChanged(entity);
|
|
477
|
-
notifiedSystems.add(system);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
// 通知全局监听系统(none条件、tag/name查询等) | Notify global listener systems
|
|
482
|
-
for (const system of this._globalNotifySystems) {
|
|
483
|
-
if (!notifiedSystems.has(system)) {
|
|
484
|
-
system.handleEntityComponentChanged(entity);
|
|
485
|
-
notifiedSystems.add(system);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
// 如果没有提供组件类型,回退到遍历所有系统 | Fallback to all systems if no component type
|
|
489
|
-
if (!changedComponentType) {
|
|
490
|
-
for (const system of this.systems) {
|
|
491
|
-
if (!notifiedSystems.has(system)) {
|
|
492
|
-
system.handleEntityComponentChanged(entity);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* 将系统添加到组件索引
|
|
499
|
-
*
|
|
500
|
-
* 根据系统的 Matcher 条件,将系统注册到相应的组件ID索引中。
|
|
501
|
-
*
|
|
502
|
-
* Index a system by its interested component types.
|
|
503
|
-
* Registers the system to component ID indices based on its Matcher conditions.
|
|
504
|
-
*
|
|
505
|
-
* @param system 要索引的系统 | The system to index
|
|
506
|
-
*/
|
|
507
|
-
indexSystemByComponents(system) {
|
|
508
|
-
const matcher = system.matcher;
|
|
509
|
-
if (!matcher) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
// nothing 匹配器不需要索引 | Nothing matcher doesn't need indexing
|
|
513
|
-
if (matcher.isNothing()) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
const condition = matcher.getCondition();
|
|
517
|
-
// 有 none/tag/name 条件的系统加入全局通知 | Systems with none/tag/name go to global
|
|
518
|
-
if (condition.none.length > 0 || condition.tag !== undefined || condition.name !== undefined) {
|
|
519
|
-
this._globalNotifySystems.add(system);
|
|
520
|
-
}
|
|
521
|
-
// 空匹配器(匹配所有实体)加入全局通知 | Empty matcher (matches all) goes to global
|
|
522
|
-
if (matcher.isEmpty()) {
|
|
523
|
-
this._globalNotifySystems.add(system);
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
// 索引 all 条件中的组件 | Index components in all condition
|
|
527
|
-
for (const componentType of condition.all) {
|
|
528
|
-
this.addSystemToComponentIndex(componentType, system);
|
|
529
|
-
}
|
|
530
|
-
// 索引 any 条件中的组件 | Index components in any condition
|
|
531
|
-
for (const componentType of condition.any) {
|
|
532
|
-
this.addSystemToComponentIndex(componentType, system);
|
|
533
|
-
}
|
|
534
|
-
// 索引单组件查询 | Index single component query
|
|
535
|
-
if (condition.component) {
|
|
536
|
-
this.addSystemToComponentIndex(condition.component, system);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* 将系统添加到指定组件的索引
|
|
541
|
-
*
|
|
542
|
-
* Add system to the index for a specific component type.
|
|
543
|
-
*
|
|
544
|
-
* @param componentType 组件类型 | Component type
|
|
545
|
-
* @param system 系统 | System
|
|
546
|
-
*/
|
|
547
|
-
addSystemToComponentIndex(componentType, system) {
|
|
548
|
-
if (!ComponentRegistry.isRegistered(componentType)) {
|
|
549
|
-
ComponentRegistry.register(componentType);
|
|
550
|
-
}
|
|
551
|
-
const componentId = ComponentRegistry.getBitIndex(componentType);
|
|
552
|
-
let systems = this._componentIdToSystems.get(componentId);
|
|
553
|
-
if (!systems) {
|
|
554
|
-
systems = new Set();
|
|
555
|
-
this._componentIdToSystems.set(componentId, systems);
|
|
556
|
-
}
|
|
557
|
-
systems.add(system);
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* 从组件索引中移除系统
|
|
561
|
-
*
|
|
562
|
-
* Remove a system from all component indices.
|
|
563
|
-
*
|
|
564
|
-
* @param system 要移除的系统 | The system to remove
|
|
565
|
-
*/
|
|
566
|
-
removeSystemFromIndex(system) {
|
|
567
|
-
// 从全局通知列表移除 | Remove from global notify list
|
|
568
|
-
this._globalNotifySystems.delete(system);
|
|
569
|
-
// 从所有组件索引中移除 | Remove from all component indices
|
|
570
|
-
for (const systems of this._componentIdToSystems.values()) {
|
|
571
|
-
systems.delete(system);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* 在场景的实体列表中添加一个实体
|
|
576
|
-
* @param entity 要添加的实体
|
|
577
|
-
* @param deferCacheClear 是否延迟缓存清理(用于批量操作)
|
|
578
|
-
*/
|
|
579
|
-
addEntity(entity, deferCacheClear = false) {
|
|
580
|
-
this.entities.add(entity);
|
|
581
|
-
entity.scene = this;
|
|
582
|
-
// 将实体添加到查询系统(可延迟缓存清理)
|
|
583
|
-
this.querySystem.addEntity(entity, deferCacheClear);
|
|
584
|
-
// 清除系统缓存以确保系统能及时发现新实体
|
|
585
|
-
if (!deferCacheClear) {
|
|
586
|
-
this.clearSystemEntityCaches();
|
|
587
|
-
}
|
|
588
|
-
// 触发实体添加事件
|
|
589
|
-
this.eventSystem.emitSync('entity:added', { entity, scene: this });
|
|
590
|
-
return entity;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* 批量创建实体(高性能版本)
|
|
594
|
-
* @param count 要创建的实体数量
|
|
595
|
-
* @param namePrefix 实体名称前缀
|
|
596
|
-
* @returns 创建的实体列表
|
|
597
|
-
*/
|
|
598
|
-
createEntities(count, namePrefix = 'Entity') {
|
|
599
|
-
const entities = [];
|
|
600
|
-
// 批量创建实体对象,不立即添加到系统
|
|
601
|
-
for (let i = 0; i < count; i++) {
|
|
602
|
-
const entity = new Entity(`${namePrefix}_${i}`, this.identifierPool.checkOut());
|
|
603
|
-
entity.scene = this;
|
|
604
|
-
entities.push(entity);
|
|
605
|
-
}
|
|
606
|
-
// 批量添加到实体列表
|
|
607
|
-
for (const entity of entities) {
|
|
608
|
-
this.entities.add(entity);
|
|
609
|
-
}
|
|
610
|
-
// 批量添加到查询系统(无重复检查,性能最优)
|
|
611
|
-
this.querySystem.addEntitiesUnchecked(entities);
|
|
612
|
-
// 批量触发事件(可选,减少事件开销)
|
|
613
|
-
this.eventSystem.emitSync('entities:batch_added', { entities, scene: this, count });
|
|
614
|
-
return entities;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* 批量销毁实体
|
|
618
|
-
*/
|
|
619
|
-
destroyEntities(entities) {
|
|
620
|
-
if (entities.length === 0)
|
|
621
|
-
return;
|
|
622
|
-
for (const entity of entities) {
|
|
623
|
-
entity.setDestroyedState(true);
|
|
624
|
-
}
|
|
625
|
-
for (const entity of entities) {
|
|
626
|
-
entity.removeAllComponents();
|
|
627
|
-
}
|
|
628
|
-
for (const entity of entities) {
|
|
629
|
-
this.entities.remove(entity);
|
|
630
|
-
this.querySystem.removeEntity(entity);
|
|
631
|
-
}
|
|
632
|
-
this.querySystem.clearCache();
|
|
633
|
-
this.clearSystemEntityCaches();
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* 从场景中删除所有实体
|
|
637
|
-
*/
|
|
638
|
-
destroyAllEntities() {
|
|
639
|
-
this.entities.removeAllEntities();
|
|
640
|
-
this.querySystem.setEntities([]);
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* 搜索并返回第一个具有名称的实体
|
|
644
|
-
* @param name 实体名称
|
|
645
|
-
*/
|
|
646
|
-
findEntity(name) {
|
|
647
|
-
return this.entities.findEntity(name);
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* 根据ID查找实体
|
|
651
|
-
* @param id 实体ID
|
|
652
|
-
*/
|
|
653
|
-
findEntityById(id) {
|
|
654
|
-
return this.entities.findEntityById(id);
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* 根据标签查找实体
|
|
658
|
-
* @param tag 实体标签
|
|
659
|
-
*/
|
|
660
|
-
findEntitiesByTag(tag) {
|
|
661
|
-
const result = [];
|
|
662
|
-
for (const entity of this.entities.buffer) {
|
|
663
|
-
if (entity.tag === tag) {
|
|
664
|
-
result.push(entity);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
return result;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* 查找所有持久化实体
|
|
671
|
-
*
|
|
672
|
-
* Find all persistent entities in this scene.
|
|
673
|
-
*
|
|
674
|
-
* @returns 持久化实体数组 | Array of persistent entities
|
|
675
|
-
*/
|
|
676
|
-
findPersistentEntities() {
|
|
677
|
-
return this.entities.buffer.filter(entity => entity.isPersistent);
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* 提取持久化实体(从场景中分离但不销毁)
|
|
681
|
-
*
|
|
682
|
-
* 用于场景切换时收集需要迁移的实体。
|
|
683
|
-
*
|
|
684
|
-
* Extract persistent entities (detach from scene without destroying).
|
|
685
|
-
* Used during scene transitions to collect entities for migration.
|
|
686
|
-
*
|
|
687
|
-
* @returns 被提取的持久化实体数组 | Array of extracted persistent entities
|
|
688
|
-
*
|
|
689
|
-
* @internal
|
|
690
|
-
*/
|
|
691
|
-
extractPersistentEntities() {
|
|
692
|
-
const persistentEntities = this.findPersistentEntities();
|
|
693
|
-
for (const entity of persistentEntities) {
|
|
694
|
-
// 从实体列表移除
|
|
695
|
-
this.entities.remove(entity);
|
|
696
|
-
// 从查询系统移除
|
|
697
|
-
this.querySystem.removeEntity(entity);
|
|
698
|
-
// 清除场景引用(但保留组件数据)
|
|
699
|
-
entity.scene = null;
|
|
700
|
-
}
|
|
701
|
-
return persistentEntities;
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* 接收迁移的实体
|
|
705
|
-
*
|
|
706
|
-
* 将从其他场景迁移来的实体添加到当前场景。
|
|
707
|
-
*
|
|
708
|
-
* Receive migrated entities from another scene.
|
|
709
|
-
*
|
|
710
|
-
* @param entities 要接收的实体数组 | Entities to receive
|
|
711
|
-
*
|
|
712
|
-
* @internal
|
|
713
|
-
*/
|
|
714
|
-
receiveMigratedEntities(entities) {
|
|
715
|
-
for (const entity of entities) {
|
|
716
|
-
// 设置新场景引用
|
|
717
|
-
entity.scene = this;
|
|
718
|
-
// 添加到实体列表
|
|
719
|
-
this.entities.add(entity);
|
|
720
|
-
// 添加到查询系统
|
|
721
|
-
this.querySystem.addEntity(entity);
|
|
722
|
-
// 重新注册组件到新场景的存储
|
|
723
|
-
for (const component of entity.components) {
|
|
724
|
-
this.componentStorageManager.addComponent(entity.id, component);
|
|
725
|
-
this.referenceTracker?.registerEntityScene(entity.id, this);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
// 清除系统缓存
|
|
729
|
-
if (entities.length > 0) {
|
|
730
|
-
this.clearSystemEntityCaches();
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* 根据名称查找实体(别名方法)
|
|
735
|
-
*
|
|
736
|
-
* @param name 实体名称
|
|
737
|
-
* @deprecated 请使用 findEntity() 代替此方法
|
|
738
|
-
*/
|
|
739
|
-
getEntityByName(name) {
|
|
740
|
-
return this.findEntity(name);
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* 根据标签查找实体(别名方法)
|
|
744
|
-
*
|
|
745
|
-
* @param tag 实体标签
|
|
746
|
-
* @deprecated 请使用 findEntitiesByTag() 代替此方法
|
|
747
|
-
*/
|
|
748
|
-
getEntitiesByTag(tag) {
|
|
749
|
-
return this.findEntitiesByTag(tag);
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* 查询拥有所有指定组件的实体
|
|
753
|
-
*
|
|
754
|
-
* @param componentTypes - 组件类型数组
|
|
755
|
-
* @returns 查询结果
|
|
756
|
-
*
|
|
757
|
-
* @example
|
|
758
|
-
* ```typescript
|
|
759
|
-
* const result = scene.queryAll(Position, Velocity);
|
|
760
|
-
* for (const entity of result.entities) {
|
|
761
|
-
* const pos = entity.getComponent(Position);
|
|
762
|
-
* const vel = entity.getComponent(Velocity);
|
|
763
|
-
* }
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
queryAll(...componentTypes) {
|
|
767
|
-
return this.querySystem.queryAll(...componentTypes);
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* 查询拥有任意一个指定组件的实体
|
|
771
|
-
*
|
|
772
|
-
* @param componentTypes - 组件类型数组
|
|
773
|
-
* @returns 查询结果
|
|
774
|
-
*/
|
|
775
|
-
queryAny(...componentTypes) {
|
|
776
|
-
return this.querySystem.queryAny(...componentTypes);
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* 查询不包含指定组件的实体
|
|
780
|
-
*
|
|
781
|
-
* @param componentTypes - 组件类型数组
|
|
782
|
-
* @returns 查询结果
|
|
783
|
-
*/
|
|
784
|
-
queryNone(...componentTypes) {
|
|
785
|
-
return this.querySystem.queryNone(...componentTypes);
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* 创建类型安全的查询构建器
|
|
789
|
-
*
|
|
790
|
-
* @returns 查询构建器,支持链式调用
|
|
791
|
-
*
|
|
792
|
-
* @example
|
|
793
|
-
* ```typescript
|
|
794
|
-
* // 使用查询构建器
|
|
795
|
-
* const matcher = scene.query()
|
|
796
|
-
* .withAll(Position, Velocity)
|
|
797
|
-
* .withNone(Disabled)
|
|
798
|
-
* .buildMatcher();
|
|
799
|
-
*
|
|
800
|
-
* // 在System中使用
|
|
801
|
-
* class MovementSystem extends EntitySystem {
|
|
802
|
-
* constructor() {
|
|
803
|
-
* super(matcher);
|
|
804
|
-
* }
|
|
805
|
-
* }
|
|
806
|
-
* ```
|
|
807
|
-
*/
|
|
808
|
-
query() {
|
|
809
|
-
return new TypedQueryBuilder();
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* 在场景中添加一个EntitySystem处理器
|
|
813
|
-
*
|
|
814
|
-
* 支持两种使用方式:
|
|
815
|
-
* 1. 传入类型(推荐):自动使用DI创建实例,支持@Injectable和@InjectProperty装饰器
|
|
816
|
-
* 2. 传入实例:直接使用提供的实例
|
|
817
|
-
*
|
|
818
|
-
* @param systemTypeOrInstance 系统类型或系统实例
|
|
819
|
-
* @returns 添加的处理器实例
|
|
820
|
-
*
|
|
821
|
-
* @example
|
|
822
|
-
* ```typescript
|
|
823
|
-
* // 方式1:传入类型,自动DI(推荐)
|
|
824
|
-
* @Injectable()
|
|
825
|
-
* class PhysicsSystem extends EntitySystem {
|
|
826
|
-
* @InjectProperty(CollisionSystem)
|
|
827
|
-
* private collision!: CollisionSystem;
|
|
828
|
-
*
|
|
829
|
-
* constructor() {
|
|
830
|
-
* super(Matcher.empty().all(Transform));
|
|
831
|
-
* }
|
|
832
|
-
* }
|
|
833
|
-
* scene.addEntityProcessor(PhysicsSystem);
|
|
834
|
-
*
|
|
835
|
-
* // 方式2:传入实例
|
|
836
|
-
* const system = new MySystem();
|
|
837
|
-
* scene.addEntityProcessor(system);
|
|
838
|
-
* ```
|
|
839
|
-
*/
|
|
840
|
-
addEntityProcessor(systemTypeOrInstance) {
|
|
841
|
-
let system;
|
|
842
|
-
let constructor;
|
|
843
|
-
if (typeof systemTypeOrInstance === 'function') {
|
|
844
|
-
constructor = systemTypeOrInstance;
|
|
845
|
-
if (this._services.isRegistered(constructor)) {
|
|
846
|
-
const existingSystem = this._services.resolve(constructor);
|
|
847
|
-
this.logger.debug(`System ${constructor.name} already registered, returning existing instance`);
|
|
848
|
-
return existingSystem;
|
|
849
|
-
}
|
|
850
|
-
if (isInjectable(constructor)) {
|
|
851
|
-
system = createInstance(constructor, this._services);
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
system = new constructor();
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
else {
|
|
858
|
-
system = systemTypeOrInstance;
|
|
859
|
-
constructor = system.constructor;
|
|
860
|
-
if (this._services.isRegistered(constructor)) {
|
|
861
|
-
const existingSystem = this._services.resolve(constructor);
|
|
862
|
-
if (existingSystem === system) {
|
|
863
|
-
this.logger.debug(`System ${constructor.name} instance already registered, returning it`);
|
|
864
|
-
return system;
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
this.logger.warn(`Attempting to register a different instance of ${constructor.name}, ` +
|
|
868
|
-
'but type is already registered. Returning existing instance.');
|
|
869
|
-
return existingSystem;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
system.scene = this;
|
|
874
|
-
// 分配添加顺序,用于稳定排序 | Assign add order for stable sorting
|
|
875
|
-
system.addOrder = this._systemAddCounter++;
|
|
876
|
-
system.setPerformanceMonitor(this.performanceMonitor);
|
|
877
|
-
const metadata = getSystemMetadata(constructor);
|
|
878
|
-
if (metadata?.updateOrder !== undefined) {
|
|
879
|
-
system.setUpdateOrder(metadata.updateOrder);
|
|
880
|
-
}
|
|
881
|
-
if (metadata?.enabled !== undefined) {
|
|
882
|
-
system.enabled = metadata.enabled;
|
|
883
|
-
}
|
|
884
|
-
this._services.registerInstance(constructor, system);
|
|
885
|
-
// 标记系统列表已变化
|
|
886
|
-
this.markSystemsOrderDirty();
|
|
887
|
-
// 建立组件类型到系统的索引 | Build component type to system index
|
|
888
|
-
this.indexSystemByComponents(system);
|
|
889
|
-
injectProperties(system, this._services);
|
|
890
|
-
// 调试模式下自动包装系统方法以收集性能数据(ProfilerSDK 启用时表示调试模式)
|
|
891
|
-
if (ProfilerSDK.isEnabled()) {
|
|
892
|
-
AutoProfiler.wrapInstance(system, system.systemName, ProfileCategory.ECS);
|
|
893
|
-
}
|
|
894
|
-
system.initialize();
|
|
895
|
-
this.logger.debug(`System ${constructor.name} registered and initialized`);
|
|
896
|
-
return system;
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* 批量注册EntitySystem到场景(使用DI)
|
|
900
|
-
*
|
|
901
|
-
* 自动按照依赖顺序注册多个System。
|
|
902
|
-
* 所有System必须使用@Injectable装饰器标记。
|
|
903
|
-
*
|
|
904
|
-
* @param systemTypes System类型数组
|
|
905
|
-
* @returns 注册的System实例数组
|
|
906
|
-
*
|
|
907
|
-
* @example
|
|
908
|
-
* ```typescript
|
|
909
|
-
* @Injectable()
|
|
910
|
-
* @ECSSystem('Collision', { updateOrder: 5 })
|
|
911
|
-
* class CollisionSystem extends EntitySystem implements IService {
|
|
912
|
-
* constructor() { super(Matcher.empty().all(Collider)); }
|
|
913
|
-
* dispose() {}
|
|
914
|
-
* }
|
|
915
|
-
*
|
|
916
|
-
* @Injectable()
|
|
917
|
-
* @ECSSystem('Physics', { updateOrder: 10 })
|
|
918
|
-
* class PhysicsSystem extends EntitySystem implements IService {
|
|
919
|
-
* @InjectProperty(CollisionSystem)
|
|
920
|
-
* private collision!: CollisionSystem;
|
|
921
|
-
*
|
|
922
|
-
* constructor() {
|
|
923
|
-
* super(Matcher.empty().all(Transform, RigidBody));
|
|
924
|
-
* }
|
|
925
|
-
* dispose() {}
|
|
926
|
-
* }
|
|
927
|
-
*
|
|
928
|
-
* // 批量注册(自动解析依赖顺序)
|
|
929
|
-
* scene.registerSystems([
|
|
930
|
-
* CollisionSystem,
|
|
931
|
-
* PhysicsSystem, // 自动注入CollisionSystem
|
|
932
|
-
* RenderSystem
|
|
933
|
-
* ]);
|
|
934
|
-
* ```
|
|
935
|
-
*/
|
|
936
|
-
registerSystems(systemTypes) {
|
|
937
|
-
const registeredSystems = [];
|
|
938
|
-
for (const systemType of systemTypes) {
|
|
939
|
-
const system = this.addEntityProcessor(systemType);
|
|
940
|
-
registeredSystems.push(system);
|
|
941
|
-
}
|
|
942
|
-
return registeredSystems;
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* 添加系统到场景(addEntityProcessor的别名)
|
|
946
|
-
* @param system 系统
|
|
947
|
-
*/
|
|
948
|
-
addSystem(system) {
|
|
949
|
-
return this.addEntityProcessor(system);
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* 从场景中删除EntitySystem处理器
|
|
953
|
-
* @param processor 要删除的处理器
|
|
954
|
-
*/
|
|
955
|
-
removeEntityProcessor(processor) {
|
|
956
|
-
const constructor = processor.constructor;
|
|
957
|
-
// 从ServiceContainer移除
|
|
958
|
-
this._services.unregister(constructor);
|
|
959
|
-
// 标记系统列表已变化
|
|
960
|
-
this.markSystemsOrderDirty();
|
|
961
|
-
// 从组件类型索引中移除 | Remove from component type index
|
|
962
|
-
this.removeSystemFromIndex(processor);
|
|
963
|
-
// 重置System状态
|
|
964
|
-
processor.reset();
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* 从场景中删除系统(removeEntityProcessor的别名)
|
|
968
|
-
* @param system 系统
|
|
969
|
-
*/
|
|
970
|
-
removeSystem(system) {
|
|
971
|
-
this.removeEntityProcessor(system);
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* 获取指定类型的EntitySystem处理器
|
|
975
|
-
*
|
|
976
|
-
* @deprecated 推荐使用依赖注入代替此方法。使用 `scene.services.resolve(SystemType)` 或使用 `@InjectProperty(SystemType)` 装饰器。
|
|
977
|
-
*
|
|
978
|
-
* @param type 处理器类型
|
|
979
|
-
* @returns 处理器实例,如果未找到则返回null
|
|
980
|
-
*
|
|
981
|
-
* @example
|
|
982
|
-
* ```typescript
|
|
983
|
-
* @Injectable()
|
|
984
|
-
* class MySystem extends EntitySystem {
|
|
985
|
-
* @InjectProperty(PhysicsSystem)
|
|
986
|
-
* private physics!: PhysicsSystem;
|
|
987
|
-
*
|
|
988
|
-
* constructor() {
|
|
989
|
-
* super(Matcher.empty());
|
|
990
|
-
* }
|
|
991
|
-
* }
|
|
992
|
-
* ```
|
|
993
|
-
*/
|
|
994
|
-
getEntityProcessor(type) {
|
|
995
|
-
return this._services.tryResolve(type);
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* 获取场景统计信息
|
|
999
|
-
*/
|
|
1000
|
-
getStats() {
|
|
1001
|
-
return {
|
|
1002
|
-
entityCount: this.entities.count,
|
|
1003
|
-
processorCount: this.systems.length,
|
|
1004
|
-
componentStorageStats: this.componentStorageManager.getAllStats()
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
/**
|
|
1008
|
-
* 获取场景的调试信息
|
|
1009
|
-
*/
|
|
1010
|
-
getDebugInfo() {
|
|
1011
|
-
const systems = this.systems;
|
|
1012
|
-
return {
|
|
1013
|
-
name: this.name || this.constructor.name,
|
|
1014
|
-
entityCount: this.entities.count,
|
|
1015
|
-
processorCount: systems.length,
|
|
1016
|
-
isRunning: this._didSceneBegin,
|
|
1017
|
-
entities: this.entities.buffer.map((entity) => ({
|
|
1018
|
-
name: entity.name,
|
|
1019
|
-
id: entity.id,
|
|
1020
|
-
componentCount: entity.components.length,
|
|
1021
|
-
componentTypes: entity.components.map((c) => getComponentInstanceTypeName(c))
|
|
1022
|
-
})),
|
|
1023
|
-
processors: systems.map((processor) => ({
|
|
1024
|
-
name: getSystemInstanceTypeName(processor),
|
|
1025
|
-
updateOrder: processor.updateOrder,
|
|
1026
|
-
entityCount: processor.entities.length
|
|
1027
|
-
})),
|
|
1028
|
-
componentStats: this.componentStorageManager.getAllStats()
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* 序列化场景
|
|
1033
|
-
*
|
|
1034
|
-
* 将场景及其所有实体、组件序列化为JSON字符串或二进制Uint8Array
|
|
1035
|
-
*
|
|
1036
|
-
* @param options 序列化选项
|
|
1037
|
-
* @returns 序列化后的数据(JSON字符串或二进制Uint8Array)
|
|
1038
|
-
*
|
|
1039
|
-
* @example
|
|
1040
|
-
* ```typescript
|
|
1041
|
-
* // JSON格式
|
|
1042
|
-
* const jsonData = scene.serialize({
|
|
1043
|
-
* format: 'json',
|
|
1044
|
-
* pretty: true
|
|
1045
|
-
* });
|
|
1046
|
-
*
|
|
1047
|
-
* // 二进制格式(更小、更快)
|
|
1048
|
-
* const binaryData = scene.serialize({
|
|
1049
|
-
* format: 'binary'
|
|
1050
|
-
* });
|
|
1051
|
-
* ```
|
|
1052
|
-
*/
|
|
1053
|
-
serialize(options) {
|
|
1054
|
-
return SceneSerializer.serialize(this, options);
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* 反序列化场景
|
|
1058
|
-
*
|
|
1059
|
-
* 从序列化数据恢复场景状态
|
|
1060
|
-
*
|
|
1061
|
-
* @param saveData 序列化的数据(JSON字符串或二进制Uint8Array)
|
|
1062
|
-
* @param options 反序列化选项
|
|
1063
|
-
*
|
|
1064
|
-
* @example
|
|
1065
|
-
* ```typescript
|
|
1066
|
-
* // 从JSON恢复(自动从ComponentRegistry获取组件类型)
|
|
1067
|
-
* scene.deserialize(jsonData, {
|
|
1068
|
-
* strategy: 'replace'
|
|
1069
|
-
* });
|
|
1070
|
-
*
|
|
1071
|
-
* // 从二进制恢复
|
|
1072
|
-
* scene.deserialize(binaryData, {
|
|
1073
|
-
* strategy: 'replace'
|
|
1074
|
-
* });
|
|
1075
|
-
* ```
|
|
1076
|
-
*/
|
|
1077
|
-
deserialize(saveData, options) {
|
|
1078
|
-
SceneSerializer.deserialize(this, saveData, options);
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* 创建增量序列化的基础快照
|
|
1082
|
-
*
|
|
1083
|
-
* 在需要进行增量序列化前,先调用此方法创建基础快照
|
|
1084
|
-
*
|
|
1085
|
-
* @param options 序列化选项
|
|
1086
|
-
*
|
|
1087
|
-
* @example
|
|
1088
|
-
* ```typescript
|
|
1089
|
-
* // 创建基础快照
|
|
1090
|
-
* scene.createIncrementalSnapshot();
|
|
1091
|
-
*
|
|
1092
|
-
* // 进行一些修改...
|
|
1093
|
-
* entity.addComponent(new PositionComponent(100, 200));
|
|
1094
|
-
*
|
|
1095
|
-
* // 计算增量变更
|
|
1096
|
-
* const incremental = scene.serializeIncremental();
|
|
1097
|
-
* ```
|
|
1098
|
-
*/
|
|
1099
|
-
createIncrementalSnapshot(options) {
|
|
1100
|
-
this._incrementalBaseSnapshot = IncrementalSerializer.createSnapshot(this, options);
|
|
1101
|
-
}
|
|
1102
|
-
/**
|
|
1103
|
-
* 增量序列化场景
|
|
1104
|
-
*
|
|
1105
|
-
* 只序列化相对于基础快照的变更部分
|
|
1106
|
-
*
|
|
1107
|
-
* @param options 序列化选项
|
|
1108
|
-
* @returns 增量快照对象
|
|
1109
|
-
*
|
|
1110
|
-
* @example
|
|
1111
|
-
* ```typescript
|
|
1112
|
-
* // 创建基础快照
|
|
1113
|
-
* scene.createIncrementalSnapshot();
|
|
1114
|
-
*
|
|
1115
|
-
* // 修改场景
|
|
1116
|
-
* const entity = scene.createEntity('NewEntity');
|
|
1117
|
-
* entity.addComponent(new PositionComponent(50, 100));
|
|
1118
|
-
*
|
|
1119
|
-
* // 获取增量变更
|
|
1120
|
-
* const incremental = scene.serializeIncremental();
|
|
1121
|
-
* console.log(`变更数量: ${incremental.entityChanges.length}`);
|
|
1122
|
-
*
|
|
1123
|
-
* // 序列化为JSON
|
|
1124
|
-
* const json = IncrementalSerializer.serializeIncremental(incremental);
|
|
1125
|
-
* ```
|
|
1126
|
-
*/
|
|
1127
|
-
serializeIncremental(options) {
|
|
1128
|
-
if (!this._incrementalBaseSnapshot) {
|
|
1129
|
-
throw new Error('必须先调用 createIncrementalSnapshot() 创建基础快照');
|
|
1130
|
-
}
|
|
1131
|
-
return IncrementalSerializer.computeIncremental(this, this._incrementalBaseSnapshot, options);
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* 应用增量变更到场景
|
|
1135
|
-
*
|
|
1136
|
-
* @param incremental 增量快照数据(IncrementalSnapshot对象、JSON字符串或二进制Uint8Array)
|
|
1137
|
-
* @param componentRegistry 组件类型注册表(可选,默认使用全局注册表)
|
|
1138
|
-
*
|
|
1139
|
-
* @example
|
|
1140
|
-
* ```typescript
|
|
1141
|
-
* // 应用增量变更对象
|
|
1142
|
-
* scene.applyIncremental(incrementalSnapshot);
|
|
1143
|
-
*
|
|
1144
|
-
* // 从JSON字符串应用
|
|
1145
|
-
* const jsonData = IncrementalSerializer.serializeIncremental(snapshot, { format: 'json' });
|
|
1146
|
-
* scene.applyIncremental(jsonData);
|
|
1147
|
-
*
|
|
1148
|
-
* // 从二进制Uint8Array应用
|
|
1149
|
-
* const binaryData = IncrementalSerializer.serializeIncremental(snapshot, { format: 'binary' });
|
|
1150
|
-
* scene.applyIncremental(binaryData);
|
|
1151
|
-
* ```
|
|
1152
|
-
*/
|
|
1153
|
-
applyIncremental(incremental, componentRegistry) {
|
|
1154
|
-
const isSerializedData = typeof incremental === 'string' || incremental instanceof Uint8Array;
|
|
1155
|
-
const snapshot = isSerializedData
|
|
1156
|
-
? IncrementalSerializer.deserializeIncremental(incremental)
|
|
1157
|
-
: incremental;
|
|
1158
|
-
const registry = componentRegistry || ComponentRegistry.getAllComponentNames();
|
|
1159
|
-
IncrementalSerializer.applyIncremental(this, snapshot, registry);
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* 更新增量快照基准
|
|
1163
|
-
*
|
|
1164
|
-
* 将当前场景状态设为新的增量序列化基准
|
|
1165
|
-
*
|
|
1166
|
-
* @param options 序列化选项
|
|
1167
|
-
*
|
|
1168
|
-
* @example
|
|
1169
|
-
* ```typescript
|
|
1170
|
-
* // 创建初始快照
|
|
1171
|
-
* scene.createIncrementalSnapshot();
|
|
1172
|
-
*
|
|
1173
|
-
* // 进行一些修改并序列化
|
|
1174
|
-
* const incremental1 = scene.serializeIncremental();
|
|
1175
|
-
*
|
|
1176
|
-
* // 更新基准,之后的增量将基于当前状态
|
|
1177
|
-
* scene.updateIncrementalSnapshot();
|
|
1178
|
-
*
|
|
1179
|
-
* // 继续修改
|
|
1180
|
-
* const incremental2 = scene.serializeIncremental();
|
|
1181
|
-
* ```
|
|
1182
|
-
*/
|
|
1183
|
-
updateIncrementalSnapshot(options) {
|
|
1184
|
-
this.createIncrementalSnapshot(options);
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* 清除增量快照
|
|
1188
|
-
*
|
|
1189
|
-
* 释放快照占用的内存
|
|
1190
|
-
*/
|
|
1191
|
-
clearIncrementalSnapshot() {
|
|
1192
|
-
this._incrementalBaseSnapshot = undefined;
|
|
1193
|
-
}
|
|
1194
|
-
/**
|
|
1195
|
-
* 检查是否有增量快照
|
|
1196
|
-
*
|
|
1197
|
-
* @returns 如果已创建增量快照返回true
|
|
1198
|
-
*/
|
|
1199
|
-
hasIncrementalSnapshot() {
|
|
1200
|
-
return this._incrementalBaseSnapshot !== undefined;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
//# sourceMappingURL=Scene.js.map
|