@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.
Files changed (490) hide show
  1. package/index.cjs +2 -0
  2. package/index.cjs.map +1 -0
  3. package/index.d.ts +13466 -0
  4. package/index.es5.js +4 -0
  5. package/index.es5.js.map +1 -0
  6. package/index.mjs +2 -0
  7. package/index.mjs.map +1 -0
  8. package/index.umd.js +4 -0
  9. package/index.umd.js.map +1 -0
  10. package/package.json +47 -84
  11. package/bin/Core/DI/Decorators.d.ts +0 -206
  12. package/bin/Core/DI/Decorators.d.ts.map +0 -1
  13. package/bin/Core/DI/Decorators.js +0 -253
  14. package/bin/Core/DI/Decorators.js.map +0 -1
  15. package/bin/Core/DI/index.d.ts +0 -8
  16. package/bin/Core/DI/index.d.ts.map +0 -1
  17. package/bin/Core/DI/index.js +0 -7
  18. package/bin/Core/DI/index.js.map +0 -1
  19. package/bin/Core/Plugin.d.ts +0 -112
  20. package/bin/Core/Plugin.d.ts.map +0 -1
  21. package/bin/Core/Plugin.js +0 -19
  22. package/bin/Core/Plugin.js.map +0 -1
  23. package/bin/Core/PluginManager.d.ts +0 -118
  24. package/bin/Core/PluginManager.d.ts.map +0 -1
  25. package/bin/Core/PluginManager.js +0 -229
  26. package/bin/Core/PluginManager.js.map +0 -1
  27. package/bin/Core/ServiceContainer.d.ts +0 -221
  28. package/bin/Core/ServiceContainer.d.ts.map +0 -1
  29. package/bin/Core/ServiceContainer.js +0 -352
  30. package/bin/Core/ServiceContainer.js.map +0 -1
  31. package/bin/Core.d.ts +0 -379
  32. package/bin/Core.d.ts.map +0 -1
  33. package/bin/Core.js +0 -553
  34. package/bin/Core.js.map +0 -1
  35. package/bin/ECS/Component.d.ts +0 -104
  36. package/bin/ECS/Component.d.ts.map +0 -1
  37. package/bin/ECS/Component.js +0 -105
  38. package/bin/ECS/Component.js.map +0 -1
  39. package/bin/ECS/Components/HierarchyComponent.d.ts +0 -46
  40. package/bin/ECS/Components/HierarchyComponent.d.ts.map +0 -1
  41. package/bin/ECS/Components/HierarchyComponent.js +0 -65
  42. package/bin/ECS/Components/HierarchyComponent.js.map +0 -1
  43. package/bin/ECS/Components/index.d.ts +0 -2
  44. package/bin/ECS/Components/index.d.ts.map +0 -1
  45. package/bin/ECS/Components/index.js +0 -2
  46. package/bin/ECS/Components/index.js.map +0 -1
  47. package/bin/ECS/Core/ArchetypeSystem.d.ts +0 -103
  48. package/bin/ECS/Core/ArchetypeSystem.d.ts.map +0 -1
  49. package/bin/ECS/Core/ArchetypeSystem.js +0 -244
  50. package/bin/ECS/Core/ArchetypeSystem.js.map +0 -1
  51. package/bin/ECS/Core/CommandBuffer.d.ts +0 -154
  52. package/bin/ECS/Core/CommandBuffer.d.ts.map +0 -1
  53. package/bin/ECS/Core/CommandBuffer.js +0 -244
  54. package/bin/ECS/Core/CommandBuffer.js.map +0 -1
  55. package/bin/ECS/Core/ComponentPool.d.ts +0 -139
  56. package/bin/ECS/Core/ComponentPool.d.ts.map +0 -1
  57. package/bin/ECS/Core/ComponentPool.js +0 -276
  58. package/bin/ECS/Core/ComponentPool.js.map +0 -1
  59. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +0 -127
  60. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +0 -1
  61. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +0 -235
  62. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +0 -1
  63. package/bin/ECS/Core/ComponentStorage.d.ts +0 -185
  64. package/bin/ECS/Core/ComponentStorage.d.ts.map +0 -1
  65. package/bin/ECS/Core/ComponentStorage.js +0 -321
  66. package/bin/ECS/Core/ComponentStorage.js.map +0 -1
  67. package/bin/ECS/Core/EntityLifecyclePolicy.d.ts +0 -26
  68. package/bin/ECS/Core/EntityLifecyclePolicy.d.ts.map +0 -1
  69. package/bin/ECS/Core/EntityLifecyclePolicy.js +0 -2
  70. package/bin/ECS/Core/EntityLifecyclePolicy.js.map +0 -1
  71. package/bin/ECS/Core/EventBus.d.ts +0 -210
  72. package/bin/ECS/Core/EventBus.d.ts.map +0 -1
  73. package/bin/ECS/Core/EventBus.js +0 -370
  74. package/bin/ECS/Core/EventBus.js.map +0 -1
  75. package/bin/ECS/Core/EventSystem.d.ts +0 -225
  76. package/bin/ECS/Core/EventSystem.d.ts.map +0 -1
  77. package/bin/ECS/Core/EventSystem.js +0 -448
  78. package/bin/ECS/Core/EventSystem.js.map +0 -1
  79. package/bin/ECS/Core/Events/index.d.ts +0 -3
  80. package/bin/ECS/Core/Events/index.d.ts.map +0 -1
  81. package/bin/ECS/Core/Events/index.js +0 -3
  82. package/bin/ECS/Core/Events/index.js.map +0 -1
  83. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +0 -35
  84. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +0 -1
  85. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +0 -48
  86. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +0 -1
  87. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +0 -135
  88. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +0 -1
  89. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +0 -166
  90. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +0 -1
  91. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +0 -58
  92. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +0 -1
  93. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +0 -85
  94. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +0 -1
  95. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +0 -110
  96. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +0 -1
  97. package/bin/ECS/Core/FluentAPI/EntityBuilder.js +0 -181
  98. package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +0 -1
  99. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +0 -53
  100. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +0 -1
  101. package/bin/ECS/Core/FluentAPI/SceneBuilder.js +0 -79
  102. package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +0 -1
  103. package/bin/ECS/Core/FluentAPI/index.d.ts +0 -6
  104. package/bin/ECS/Core/FluentAPI/index.d.ts.map +0 -1
  105. package/bin/ECS/Core/FluentAPI/index.js +0 -6
  106. package/bin/ECS/Core/FluentAPI/index.js.map +0 -1
  107. package/bin/ECS/Core/FluentAPI.d.ts +0 -2
  108. package/bin/ECS/Core/FluentAPI.d.ts.map +0 -1
  109. package/bin/ECS/Core/FluentAPI.js +0 -3
  110. package/bin/ECS/Core/FluentAPI.js.map +0 -1
  111. package/bin/ECS/Core/Query/TypedQuery.d.ts +0 -214
  112. package/bin/ECS/Core/Query/TypedQuery.d.ts.map +0 -1
  113. package/bin/ECS/Core/Query/TypedQuery.js +0 -294
  114. package/bin/ECS/Core/Query/TypedQuery.js.map +0 -1
  115. package/bin/ECS/Core/Query/index.d.ts +0 -3
  116. package/bin/ECS/Core/Query/index.d.ts.map +0 -1
  117. package/bin/ECS/Core/Query/index.js +0 -3
  118. package/bin/ECS/Core/Query/index.js.map +0 -1
  119. package/bin/ECS/Core/QuerySystem.d.ts +0 -458
  120. package/bin/ECS/Core/QuerySystem.d.ts.map +0 -1
  121. package/bin/ECS/Core/QuerySystem.js +0 -1069
  122. package/bin/ECS/Core/QuerySystem.js.map +0 -1
  123. package/bin/ECS/Core/QueryTypes.d.ts +0 -34
  124. package/bin/ECS/Core/QueryTypes.d.ts.map +0 -1
  125. package/bin/ECS/Core/QueryTypes.js +0 -13
  126. package/bin/ECS/Core/QueryTypes.js.map +0 -1
  127. package/bin/ECS/Core/ReactiveQuery.d.ts +0 -211
  128. package/bin/ECS/Core/ReactiveQuery.d.ts.map +0 -1
  129. package/bin/ECS/Core/ReactiveQuery.js +0 -401
  130. package/bin/ECS/Core/ReactiveQuery.js.map +0 -1
  131. package/bin/ECS/Core/ReferenceTracker.d.ts +0 -111
  132. package/bin/ECS/Core/ReferenceTracker.d.ts.map +0 -1
  133. package/bin/ECS/Core/ReferenceTracker.js +0 -254
  134. package/bin/ECS/Core/ReferenceTracker.js.map +0 -1
  135. package/bin/ECS/Core/SoASerializer.d.ts +0 -28
  136. package/bin/ECS/Core/SoASerializer.d.ts.map +0 -1
  137. package/bin/ECS/Core/SoASerializer.js +0 -85
  138. package/bin/ECS/Core/SoASerializer.js.map +0 -1
  139. package/bin/ECS/Core/SoAStorage.d.ts +0 -129
  140. package/bin/ECS/Core/SoAStorage.d.ts.map +0 -1
  141. package/bin/ECS/Core/SoAStorage.js +0 -685
  142. package/bin/ECS/Core/SoAStorage.js.map +0 -1
  143. package/bin/ECS/Core/SoATypeRegistry.d.ts +0 -50
  144. package/bin/ECS/Core/SoATypeRegistry.d.ts.map +0 -1
  145. package/bin/ECS/Core/SoATypeRegistry.js +0 -135
  146. package/bin/ECS/Core/SoATypeRegistry.js.map +0 -1
  147. package/bin/ECS/Core/Storage/index.d.ts +0 -4
  148. package/bin/ECS/Core/Storage/index.d.ts.map +0 -1
  149. package/bin/ECS/Core/Storage/index.js +0 -4
  150. package/bin/ECS/Core/Storage/index.js.map +0 -1
  151. package/bin/ECS/Core/StorageDecorators.d.ts +0 -20
  152. package/bin/ECS/Core/StorageDecorators.d.ts.map +0 -1
  153. package/bin/ECS/Core/StorageDecorators.js +0 -27
  154. package/bin/ECS/Core/StorageDecorators.js.map +0 -1
  155. package/bin/ECS/CoreEvents.d.ts +0 -131
  156. package/bin/ECS/CoreEvents.d.ts.map +0 -1
  157. package/bin/ECS/CoreEvents.js +0 -163
  158. package/bin/ECS/CoreEvents.js.map +0 -1
  159. package/bin/ECS/Decorators/EntityRefDecorator.d.ts +0 -46
  160. package/bin/ECS/Decorators/EntityRefDecorator.d.ts.map +0 -1
  161. package/bin/ECS/Decorators/EntityRefDecorator.js +0 -118
  162. package/bin/ECS/Decorators/EntityRefDecorator.js.map +0 -1
  163. package/bin/ECS/Decorators/PropertyDecorator.d.ts +0 -168
  164. package/bin/ECS/Decorators/PropertyDecorator.d.ts.map +0 -1
  165. package/bin/ECS/Decorators/PropertyDecorator.js +0 -40
  166. package/bin/ECS/Decorators/PropertyDecorator.js.map +0 -1
  167. package/bin/ECS/Decorators/TypeDecorators.d.ts +0 -124
  168. package/bin/ECS/Decorators/TypeDecorators.d.ts.map +0 -1
  169. package/bin/ECS/Decorators/TypeDecorators.js +0 -151
  170. package/bin/ECS/Decorators/TypeDecorators.js.map +0 -1
  171. package/bin/ECS/Decorators/index.d.ts +0 -7
  172. package/bin/ECS/Decorators/index.d.ts.map +0 -1
  173. package/bin/ECS/Decorators/index.js +0 -4
  174. package/bin/ECS/Decorators/index.js.map +0 -1
  175. package/bin/ECS/Entity.d.ts +0 -415
  176. package/bin/ECS/Entity.d.ts.map +0 -1
  177. package/bin/ECS/Entity.js +0 -683
  178. package/bin/ECS/Entity.js.map +0 -1
  179. package/bin/ECS/EntityTags.d.ts +0 -71
  180. package/bin/ECS/EntityTags.d.ts.map +0 -1
  181. package/bin/ECS/EntityTags.js +0 -82
  182. package/bin/ECS/EntityTags.js.map +0 -1
  183. package/bin/ECS/IScene.d.ts +0 -308
  184. package/bin/ECS/IScene.d.ts.map +0 -1
  185. package/bin/ECS/IScene.js +0 -2
  186. package/bin/ECS/IScene.js.map +0 -1
  187. package/bin/ECS/Scene.d.ts +0 -799
  188. package/bin/ECS/Scene.d.ts.map +0 -1
  189. package/bin/ECS/Scene.js +0 -1203
  190. package/bin/ECS/Scene.js.map +0 -1
  191. package/bin/ECS/SceneManager.d.ts +0 -197
  192. package/bin/ECS/SceneManager.d.ts.map +0 -1
  193. package/bin/ECS/SceneManager.js +0 -264
  194. package/bin/ECS/SceneManager.js.map +0 -1
  195. package/bin/ECS/Serialization/ComponentSerializer.d.ts +0 -106
  196. package/bin/ECS/Serialization/ComponentSerializer.d.ts.map +0 -1
  197. package/bin/ECS/Serialization/ComponentSerializer.js +0 -251
  198. package/bin/ECS/Serialization/ComponentSerializer.js.map +0 -1
  199. package/bin/ECS/Serialization/EntitySerializer.d.ts +0 -111
  200. package/bin/ECS/Serialization/EntitySerializer.d.ts.map +0 -1
  201. package/bin/ECS/Serialization/EntitySerializer.js +0 -155
  202. package/bin/ECS/Serialization/EntitySerializer.js.map +0 -1
  203. package/bin/ECS/Serialization/IncrementalSerializer.d.ts +0 -259
  204. package/bin/ECS/Serialization/IncrementalSerializer.d.ts.map +0 -1
  205. package/bin/ECS/Serialization/IncrementalSerializer.js +0 -500
  206. package/bin/ECS/Serialization/IncrementalSerializer.js.map +0 -1
  207. package/bin/ECS/Serialization/SceneSerializer.d.ts +0 -213
  208. package/bin/ECS/Serialization/SceneSerializer.d.ts.map +0 -1
  209. package/bin/ECS/Serialization/SceneSerializer.js +0 -387
  210. package/bin/ECS/Serialization/SceneSerializer.js.map +0 -1
  211. package/bin/ECS/Serialization/SerializationDecorators.d.ts +0 -136
  212. package/bin/ECS/Serialization/SerializationDecorators.d.ts.map +0 -1
  213. package/bin/ECS/Serialization/SerializationDecorators.js +0 -216
  214. package/bin/ECS/Serialization/SerializationDecorators.js.map +0 -1
  215. package/bin/ECS/Serialization/VersionMigration.d.ts +0 -156
  216. package/bin/ECS/Serialization/VersionMigration.d.ts.map +0 -1
  217. package/bin/ECS/Serialization/VersionMigration.js +0 -279
  218. package/bin/ECS/Serialization/VersionMigration.js.map +0 -1
  219. package/bin/ECS/Serialization/index.d.ts +0 -18
  220. package/bin/ECS/Serialization/index.d.ts.map +0 -1
  221. package/bin/ECS/Serialization/index.js +0 -18
  222. package/bin/ECS/Serialization/index.js.map +0 -1
  223. package/bin/ECS/Systems/EntityCache.d.ts +0 -114
  224. package/bin/ECS/Systems/EntityCache.d.ts.map +0 -1
  225. package/bin/ECS/Systems/EntityCache.js +0 -145
  226. package/bin/ECS/Systems/EntityCache.js.map +0 -1
  227. package/bin/ECS/Systems/EntitySystem.d.ts +0 -591
  228. package/bin/ECS/Systems/EntitySystem.d.ts.map +0 -1
  229. package/bin/ECS/Systems/EntitySystem.js +0 -1102
  230. package/bin/ECS/Systems/EntitySystem.js.map +0 -1
  231. package/bin/ECS/Systems/HierarchySystem.d.ts +0 -155
  232. package/bin/ECS/Systems/HierarchySystem.d.ts.map +0 -1
  233. package/bin/ECS/Systems/HierarchySystem.js +0 -498
  234. package/bin/ECS/Systems/HierarchySystem.js.map +0 -1
  235. package/bin/ECS/Systems/IntervalSystem.d.ts +0 -33
  236. package/bin/ECS/Systems/IntervalSystem.d.ts.map +0 -1
  237. package/bin/ECS/Systems/IntervalSystem.js +0 -50
  238. package/bin/ECS/Systems/IntervalSystem.js.map +0 -1
  239. package/bin/ECS/Systems/PassiveSystem.d.ts +0 -17
  240. package/bin/ECS/Systems/PassiveSystem.d.ts.map +0 -1
  241. package/bin/ECS/Systems/PassiveSystem.js +0 -19
  242. package/bin/ECS/Systems/PassiveSystem.js.map +0 -1
  243. package/bin/ECS/Systems/ProcessingSystem.d.ts +0 -21
  244. package/bin/ECS/Systems/ProcessingSystem.d.ts.map +0 -1
  245. package/bin/ECS/Systems/ProcessingSystem.js +0 -20
  246. package/bin/ECS/Systems/ProcessingSystem.js.map +0 -1
  247. package/bin/ECS/Systems/WorkerEntitySystem.d.ts +0 -313
  248. package/bin/ECS/Systems/WorkerEntitySystem.d.ts.map +0 -1
  249. package/bin/ECS/Systems/WorkerEntitySystem.js +0 -792
  250. package/bin/ECS/Systems/WorkerEntitySystem.js.map +0 -1
  251. package/bin/ECS/Systems/index.d.ts +0 -8
  252. package/bin/ECS/Systems/index.d.ts.map +0 -1
  253. package/bin/ECS/Systems/index.js +0 -8
  254. package/bin/ECS/Systems/index.js.map +0 -1
  255. package/bin/ECS/TypedEntity.d.ts +0 -192
  256. package/bin/ECS/TypedEntity.d.ts.map +0 -1
  257. package/bin/ECS/TypedEntity.js +0 -254
  258. package/bin/ECS/TypedEntity.js.map +0 -1
  259. package/bin/ECS/Utils/BigIntCompatibility.d.ts +0 -151
  260. package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +0 -1
  261. package/bin/ECS/Utils/BigIntCompatibility.js +0 -476
  262. package/bin/ECS/Utils/BigIntCompatibility.js.map +0 -1
  263. package/bin/ECS/Utils/BitMaskHashMap.d.ts +0 -28
  264. package/bin/ECS/Utils/BitMaskHashMap.d.ts.map +0 -1
  265. package/bin/ECS/Utils/BitMaskHashMap.js +0 -127
  266. package/bin/ECS/Utils/BitMaskHashMap.js.map +0 -1
  267. package/bin/ECS/Utils/Bits.d.ts +0 -154
  268. package/bin/ECS/Utils/Bits.d.ts.map +0 -1
  269. package/bin/ECS/Utils/Bits.js +0 -331
  270. package/bin/ECS/Utils/Bits.js.map +0 -1
  271. package/bin/ECS/Utils/ComponentSparseSet.d.ts +0 -143
  272. package/bin/ECS/Utils/ComponentSparseSet.d.ts.map +0 -1
  273. package/bin/ECS/Utils/ComponentSparseSet.js +0 -347
  274. package/bin/ECS/Utils/ComponentSparseSet.js.map +0 -1
  275. package/bin/ECS/Utils/EntityList.d.ts +0 -115
  276. package/bin/ECS/Utils/EntityList.d.ts.map +0 -1
  277. package/bin/ECS/Utils/EntityList.js +0 -258
  278. package/bin/ECS/Utils/EntityList.js.map +0 -1
  279. package/bin/ECS/Utils/EntityProcessorList.d.ts +0 -56
  280. package/bin/ECS/Utils/EntityProcessorList.d.ts.map +0 -1
  281. package/bin/ECS/Utils/EntityProcessorList.js +0 -113
  282. package/bin/ECS/Utils/EntityProcessorList.js.map +0 -1
  283. package/bin/ECS/Utils/IdentifierPool.d.ts +0 -203
  284. package/bin/ECS/Utils/IdentifierPool.d.ts.map +0 -1
  285. package/bin/ECS/Utils/IdentifierPool.js +0 -325
  286. package/bin/ECS/Utils/IdentifierPool.js.map +0 -1
  287. package/bin/ECS/Utils/Matcher.d.ts +0 -171
  288. package/bin/ECS/Utils/Matcher.d.ts.map +0 -1
  289. package/bin/ECS/Utils/Matcher.js +0 -293
  290. package/bin/ECS/Utils/Matcher.js.map +0 -1
  291. package/bin/ECS/Utils/SparseSet.d.ts +0 -170
  292. package/bin/ECS/Utils/SparseSet.d.ts.map +0 -1
  293. package/bin/ECS/Utils/SparseSet.js +0 -280
  294. package/bin/ECS/Utils/SparseSet.js.map +0 -1
  295. package/bin/ECS/Utils/index.d.ts +0 -9
  296. package/bin/ECS/Utils/index.d.ts.map +0 -1
  297. package/bin/ECS/Utils/index.js +0 -10
  298. package/bin/ECS/Utils/index.js.map +0 -1
  299. package/bin/ECS/World.d.ts +0 -238
  300. package/bin/ECS/World.d.ts.map +0 -1
  301. package/bin/ECS/World.js +0 -416
  302. package/bin/ECS/World.js.map +0 -1
  303. package/bin/ECS/WorldManager.d.ts +0 -224
  304. package/bin/ECS/WorldManager.d.ts.map +0 -1
  305. package/bin/ECS/WorldManager.js +0 -365
  306. package/bin/ECS/WorldManager.js.map +0 -1
  307. package/bin/ECS/index.d.ts +0 -26
  308. package/bin/ECS/index.d.ts.map +0 -1
  309. package/bin/ECS/index.js +0 -21
  310. package/bin/ECS/index.js.map +0 -1
  311. package/bin/Platform/IPlatformAdapter.d.ts +0 -169
  312. package/bin/Platform/IPlatformAdapter.d.ts.map +0 -1
  313. package/bin/Platform/IPlatformAdapter.js +0 -2
  314. package/bin/Platform/IPlatformAdapter.js.map +0 -1
  315. package/bin/Platform/PlatformDetector.d.ts +0 -56
  316. package/bin/Platform/PlatformDetector.d.ts.map +0 -1
  317. package/bin/Platform/PlatformDetector.js +0 -247
  318. package/bin/Platform/PlatformDetector.js.map +0 -1
  319. package/bin/Platform/PlatformManager.d.ts +0 -50
  320. package/bin/Platform/PlatformManager.d.ts.map +0 -1
  321. package/bin/Platform/PlatformManager.js +0 -114
  322. package/bin/Platform/PlatformManager.js.map +0 -1
  323. package/bin/Platform/index.d.ts +0 -19
  324. package/bin/Platform/index.d.ts.map +0 -1
  325. package/bin/Platform/index.js +0 -29
  326. package/bin/Platform/index.js.map +0 -1
  327. package/bin/Plugins/DebugPlugin.d.ts +0 -156
  328. package/bin/Plugins/DebugPlugin.d.ts.map +0 -1
  329. package/bin/Plugins/DebugPlugin.js +0 -248
  330. package/bin/Plugins/DebugPlugin.js.map +0 -1
  331. package/bin/Plugins/index.d.ts +0 -2
  332. package/bin/Plugins/index.d.ts.map +0 -1
  333. package/bin/Plugins/index.js +0 -2
  334. package/bin/Plugins/index.js.map +0 -1
  335. package/bin/Types/IUpdatable.d.ts +0 -18
  336. package/bin/Types/IUpdatable.d.ts.map +0 -1
  337. package/bin/Types/IUpdatable.js +0 -7
  338. package/bin/Types/IUpdatable.js.map +0 -1
  339. package/bin/Types/TypeHelpers.d.ts +0 -238
  340. package/bin/Types/TypeHelpers.d.ts.map +0 -1
  341. package/bin/Types/TypeHelpers.js +0 -19
  342. package/bin/Types/TypeHelpers.js.map +0 -1
  343. package/bin/Types/index.d.ts +0 -466
  344. package/bin/Types/index.d.ts.map +0 -1
  345. package/bin/Types/index.js +0 -7
  346. package/bin/Types/index.js.map +0 -1
  347. package/bin/Utils/BinarySerializer.d.ts +0 -23
  348. package/bin/Utils/BinarySerializer.d.ts.map +0 -1
  349. package/bin/Utils/BinarySerializer.js +0 -100
  350. package/bin/Utils/BinarySerializer.js.map +0 -1
  351. package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts +0 -153
  352. package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts.map +0 -1
  353. package/bin/Utils/Debug/AdvancedProfilerCollector.js +0 -406
  354. package/bin/Utils/Debug/AdvancedProfilerCollector.js.map +0 -1
  355. package/bin/Utils/Debug/ComponentDataCollector.d.ts +0 -32
  356. package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +0 -1
  357. package/bin/Utils/Debug/ComponentDataCollector.js +0 -250
  358. package/bin/Utils/Debug/ComponentDataCollector.js.map +0 -1
  359. package/bin/Utils/Debug/DebugConfigService.d.ts +0 -16
  360. package/bin/Utils/Debug/DebugConfigService.d.ts.map +0 -1
  361. package/bin/Utils/Debug/DebugConfigService.js +0 -42
  362. package/bin/Utils/Debug/DebugConfigService.js.map +0 -1
  363. package/bin/Utils/Debug/DebugManager.d.ts +0 -131
  364. package/bin/Utils/Debug/DebugManager.d.ts.map +0 -1
  365. package/bin/Utils/Debug/DebugManager.js +0 -848
  366. package/bin/Utils/Debug/DebugManager.js.map +0 -1
  367. package/bin/Utils/Debug/EntityDataCollector.d.ts +0 -115
  368. package/bin/Utils/Debug/EntityDataCollector.d.ts.map +0 -1
  369. package/bin/Utils/Debug/EntityDataCollector.js +0 -870
  370. package/bin/Utils/Debug/EntityDataCollector.js.map +0 -1
  371. package/bin/Utils/Debug/PerformanceDataCollector.d.ts +0 -31
  372. package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +0 -1
  373. package/bin/Utils/Debug/PerformanceDataCollector.js +0 -203
  374. package/bin/Utils/Debug/PerformanceDataCollector.js.map +0 -1
  375. package/bin/Utils/Debug/SceneDataCollector.d.ts +0 -18
  376. package/bin/Utils/Debug/SceneDataCollector.d.ts.map +0 -1
  377. package/bin/Utils/Debug/SceneDataCollector.js +0 -43
  378. package/bin/Utils/Debug/SceneDataCollector.js.map +0 -1
  379. package/bin/Utils/Debug/SystemDataCollector.d.ts +0 -14
  380. package/bin/Utils/Debug/SystemDataCollector.d.ts.map +0 -1
  381. package/bin/Utils/Debug/SystemDataCollector.js +0 -60
  382. package/bin/Utils/Debug/SystemDataCollector.js.map +0 -1
  383. package/bin/Utils/Debug/WebSocketManager.d.ts +0 -54
  384. package/bin/Utils/Debug/WebSocketManager.d.ts.map +0 -1
  385. package/bin/Utils/Debug/WebSocketManager.js +0 -141
  386. package/bin/Utils/Debug/WebSocketManager.js.map +0 -1
  387. package/bin/Utils/Debug/index.d.ts +0 -11
  388. package/bin/Utils/Debug/index.d.ts.map +0 -1
  389. package/bin/Utils/Debug/index.js +0 -10
  390. package/bin/Utils/Debug/index.js.map +0 -1
  391. package/bin/Utils/Emitter.d.ts +0 -61
  392. package/bin/Utils/Emitter.d.ts.map +0 -1
  393. package/bin/Utils/Emitter.js +0 -101
  394. package/bin/Utils/Emitter.js.map +0 -1
  395. package/bin/Utils/Extensions/NumberExtension.d.ts +0 -13
  396. package/bin/Utils/Extensions/NumberExtension.d.ts.map +0 -1
  397. package/bin/Utils/Extensions/NumberExtension.js +0 -17
  398. package/bin/Utils/Extensions/NumberExtension.js.map +0 -1
  399. package/bin/Utils/Extensions/TypeUtils.d.ts +0 -13
  400. package/bin/Utils/Extensions/TypeUtils.d.ts.map +0 -1
  401. package/bin/Utils/Extensions/TypeUtils.js +0 -15
  402. package/bin/Utils/Extensions/TypeUtils.js.map +0 -1
  403. package/bin/Utils/Extensions/index.d.ts +0 -3
  404. package/bin/Utils/Extensions/index.d.ts.map +0 -1
  405. package/bin/Utils/Extensions/index.js +0 -4
  406. package/bin/Utils/Extensions/index.js.map +0 -1
  407. package/bin/Utils/GlobalManager.d.ts +0 -29
  408. package/bin/Utils/GlobalManager.d.ts.map +0 -1
  409. package/bin/Utils/GlobalManager.js +0 -50
  410. package/bin/Utils/GlobalManager.js.map +0 -1
  411. package/bin/Utils/Logger/ConsoleLogger.d.ts +0 -74
  412. package/bin/Utils/Logger/ConsoleLogger.d.ts.map +0 -1
  413. package/bin/Utils/Logger/ConsoleLogger.js +0 -187
  414. package/bin/Utils/Logger/ConsoleLogger.js.map +0 -1
  415. package/bin/Utils/Logger/Constants.d.ts +0 -36
  416. package/bin/Utils/Logger/Constants.d.ts.map +0 -1
  417. package/bin/Utils/Logger/Constants.js +0 -40
  418. package/bin/Utils/Logger/Constants.js.map +0 -1
  419. package/bin/Utils/Logger/LoggerManager.d.ts +0 -91
  420. package/bin/Utils/Logger/LoggerManager.d.ts.map +0 -1
  421. package/bin/Utils/Logger/LoggerManager.js +0 -167
  422. package/bin/Utils/Logger/LoggerManager.js.map +0 -1
  423. package/bin/Utils/Logger/Types.d.ts +0 -40
  424. package/bin/Utils/Logger/Types.d.ts.map +0 -1
  425. package/bin/Utils/Logger/Types.js +0 -2
  426. package/bin/Utils/Logger/Types.js.map +0 -1
  427. package/bin/Utils/Logger/index.d.ts +0 -5
  428. package/bin/Utils/Logger/index.d.ts.map +0 -1
  429. package/bin/Utils/Logger/index.js +0 -5
  430. package/bin/Utils/Logger/index.js.map +0 -1
  431. package/bin/Utils/PerformanceMonitor.d.ts +0 -196
  432. package/bin/Utils/PerformanceMonitor.d.ts.map +0 -1
  433. package/bin/Utils/PerformanceMonitor.js +0 -244
  434. package/bin/Utils/PerformanceMonitor.js.map +0 -1
  435. package/bin/Utils/Pool/IPoolable.d.ts +0 -29
  436. package/bin/Utils/Pool/IPoolable.d.ts.map +0 -1
  437. package/bin/Utils/Pool/IPoolable.js +0 -2
  438. package/bin/Utils/Pool/IPoolable.js.map +0 -1
  439. package/bin/Utils/Pool/Pool.d.ts +0 -109
  440. package/bin/Utils/Pool/Pool.d.ts.map +0 -1
  441. package/bin/Utils/Pool/Pool.js +0 -238
  442. package/bin/Utils/Pool/Pool.js.map +0 -1
  443. package/bin/Utils/Pool/PoolManager.d.ts +0 -96
  444. package/bin/Utils/Pool/PoolManager.d.ts.map +0 -1
  445. package/bin/Utils/Pool/PoolManager.js +0 -199
  446. package/bin/Utils/Pool/PoolManager.js.map +0 -1
  447. package/bin/Utils/Pool/index.d.ts +0 -4
  448. package/bin/Utils/Pool/index.d.ts.map +0 -1
  449. package/bin/Utils/Pool/index.js +0 -4
  450. package/bin/Utils/Pool/index.js.map +0 -1
  451. package/bin/Utils/Profiler/AutoProfiler.d.ts +0 -160
  452. package/bin/Utils/Profiler/AutoProfiler.d.ts.map +0 -1
  453. package/bin/Utils/Profiler/AutoProfiler.js +0 -503
  454. package/bin/Utils/Profiler/AutoProfiler.js.map +0 -1
  455. package/bin/Utils/Profiler/ProfilerSDK.d.ts +0 -175
  456. package/bin/Utils/Profiler/ProfilerSDK.d.ts.map +0 -1
  457. package/bin/Utils/Profiler/ProfilerSDK.js +0 -727
  458. package/bin/Utils/Profiler/ProfilerSDK.js.map +0 -1
  459. package/bin/Utils/Profiler/ProfilerTypes.d.ts +0 -218
  460. package/bin/Utils/Profiler/ProfilerTypes.d.ts.map +0 -1
  461. package/bin/Utils/Profiler/ProfilerTypes.js +0 -47
  462. package/bin/Utils/Profiler/ProfilerTypes.js.map +0 -1
  463. package/bin/Utils/Profiler/index.d.ts +0 -8
  464. package/bin/Utils/Profiler/index.d.ts.map +0 -1
  465. package/bin/Utils/Profiler/index.js +0 -7
  466. package/bin/Utils/Profiler/index.js.map +0 -1
  467. package/bin/Utils/Time.d.ts +0 -47
  468. package/bin/Utils/Time.d.ts.map +0 -1
  469. package/bin/Utils/Time.js +0 -64
  470. package/bin/Utils/Time.js.map +0 -1
  471. package/bin/Utils/Timers/ITimer.d.ts +0 -16
  472. package/bin/Utils/Timers/ITimer.d.ts.map +0 -1
  473. package/bin/Utils/Timers/ITimer.js +0 -2
  474. package/bin/Utils/Timers/ITimer.js.map +0 -1
  475. package/bin/Utils/Timers/Timer.d.ts +0 -30
  476. package/bin/Utils/Timers/Timer.d.ts.map +0 -1
  477. package/bin/Utils/Timers/Timer.js +0 -58
  478. package/bin/Utils/Timers/Timer.js.map +0 -1
  479. package/bin/Utils/Timers/TimerManager.d.ts +0 -26
  480. package/bin/Utils/Timers/TimerManager.d.ts.map +0 -1
  481. package/bin/Utils/Timers/TimerManager.js +0 -48
  482. package/bin/Utils/Timers/TimerManager.js.map +0 -1
  483. package/bin/Utils/index.d.ts +0 -11
  484. package/bin/Utils/index.d.ts.map +0 -1
  485. package/bin/Utils/index.js +0 -11
  486. package/bin/Utils/index.js.map +0 -1
  487. package/bin/index.d.ts +0 -29
  488. package/bin/index.d.ts.map +0 -1
  489. package/bin/index.js +0 -36
  490. package/bin/index.js.map +0 -1
@@ -1,1069 +0,0 @@
1
- import { ComponentRegistry } from './ComponentStorage';
2
- import { BitMask64Utils } from '../Utils/BigIntCompatibility';
3
- import { createLogger } from '../../Utils/Logger';
4
- import { getComponentTypeName } from '../Decorators';
5
- import { ArchetypeSystem } from './ArchetypeSystem';
6
- import { ReactiveQuery } from './ReactiveQuery';
7
- import { QueryConditionType } from './QueryTypes';
8
- export { QueryConditionType };
9
- /**
10
- * 高性能实体查询系统
11
- *
12
- * 提供快速的实体查询功能,支持按组件类型、标签、名称等多种方式查询实体。
13
- *
14
- * @example
15
- * ```typescript
16
- * // 查询所有包含Position和Velocity组件的实体
17
- * const movingEntities = querySystem.queryAll(PositionComponent, VelocityComponent);
18
- *
19
- * // 查询特定标签的实体
20
- * const playerEntities = querySystem.queryByTag(PLAYER_TAG);
21
- * ```
22
- */
23
- export class QuerySystem {
24
- constructor() {
25
- this._logger = createLogger('QuerySystem');
26
- this._entities = [];
27
- this._version = 0;
28
- this._queryCache = new Map();
29
- this._cacheMaxSize = 1000;
30
- this._cacheTimeout = 5000;
31
- this._componentMaskCache = new Map();
32
- this._queryStats = {
33
- totalQueries: 0,
34
- cacheHits: 0,
35
- indexHits: 0,
36
- linearScans: 0,
37
- archetypeHits: 0,
38
- dirtyChecks: 0
39
- };
40
- /**
41
- * 响应式查询集合(内部使用,作为智能缓存)
42
- * 传统查询API(queryAll/queryAny/queryNone)内部自动使用响应式查询优化性能
43
- */
44
- this._reactiveQueries = new Map();
45
- /**
46
- * 按组件类型索引的响应式查询
47
- * 用于快速定位哪些查询关心某个组件类型
48
- */
49
- this._reactiveQueriesByComponent = new Map();
50
- this._entityIndex = {
51
- byTag: new Map(),
52
- byName: new Map()
53
- };
54
- this._archetypeSystem = new ArchetypeSystem();
55
- }
56
- /**
57
- * 设置实体列表并重建索引
58
- *
59
- * 当实体集合发生大规模变化时调用此方法。
60
- * 系统将重新构建所有索引以确保查询性能。
61
- *
62
- * @param entities 新的实体列表
63
- */
64
- setEntities(entities) {
65
- this._entities = entities;
66
- this.clearQueryCache();
67
- this.clearReactiveQueries();
68
- this.rebuildIndexes();
69
- }
70
- /**
71
- * 添加单个实体到查询系统
72
- *
73
- * 将新实体添加到查询系统中,并自动更新相关索引。
74
- * 为了提高批量添加性能,可以延迟缓存清理。
75
- *
76
- * @param entity 要添加的实体
77
- * @param deferCacheClear 是否延迟缓存清理(用于批量操作)
78
- */
79
- addEntity(entity, deferCacheClear = false) {
80
- if (!this._entities.includes(entity)) {
81
- this._entities.push(entity);
82
- this.addEntityToIndexes(entity);
83
- this._archetypeSystem.addEntity(entity);
84
- // 通知响应式查询
85
- this.notifyReactiveQueriesEntityAdded(entity);
86
- // 只有在非延迟模式下才立即清理缓存
87
- if (!deferCacheClear) {
88
- this.clearQueryCache();
89
- }
90
- // 更新版本号
91
- this._version++;
92
- }
93
- }
94
- /**
95
- * 批量添加实体
96
- *
97
- * 高效地批量添加多个实体,减少缓存清理次数。
98
- * 使用Set来避免O(n)的重复检查。
99
- *
100
- * @param entities 要添加的实体列表
101
- */
102
- addEntities(entities) {
103
- if (entities.length === 0)
104
- return;
105
- // 使用Set来快速检查重复
106
- const existingIds = new Set(this._entities.map((e) => e.id));
107
- let addedCount = 0;
108
- for (const entity of entities) {
109
- if (!existingIds.has(entity.id)) {
110
- this._entities.push(entity);
111
- this.addEntityToIndexes(entity);
112
- // 更新索引管理器
113
- this._archetypeSystem.addEntity(entity);
114
- existingIds.add(entity.id);
115
- addedCount++;
116
- }
117
- }
118
- // 只在有实体被添加时才清理缓存
119
- if (addedCount > 0) {
120
- this.clearQueryCache();
121
- }
122
- }
123
- /**
124
- * 批量添加实体(无重复检查版本)
125
- *
126
- * 假设所有实体都是新的,跳过重复检查以获得最大性能。
127
- * 仅在确保没有重复实体时使用。
128
- *
129
- * @param entities 要添加的实体列表
130
- */
131
- addEntitiesUnchecked(entities) {
132
- if (entities.length === 0)
133
- return;
134
- // 避免调用栈溢出,分批添加
135
- for (const entity of entities) {
136
- this._entities.push(entity);
137
- }
138
- // 批量更新索引
139
- for (const entity of entities) {
140
- this.addEntityToIndexes(entity);
141
- // 更新索引管理器
142
- this._archetypeSystem.addEntity(entity);
143
- }
144
- // 清理缓存
145
- this.clearQueryCache();
146
- }
147
- /**
148
- * 从查询系统移除实体
149
- *
150
- * 从查询系统中移除指定实体,并清理相关索引。
151
- *
152
- * @param entity 要移除的实体
153
- */
154
- removeEntity(entity) {
155
- const index = this._entities.indexOf(entity);
156
- if (index !== -1) {
157
- const componentTypes = [];
158
- for (const component of entity.components) {
159
- componentTypes.push(component.constructor);
160
- }
161
- this._entities.splice(index, 1);
162
- this.removeEntityFromIndexes(entity);
163
- this._archetypeSystem.removeEntity(entity);
164
- if (componentTypes.length > 0) {
165
- this.notifyReactiveQueriesEntityRemoved(entity, componentTypes);
166
- }
167
- else {
168
- this.notifyReactiveQueriesEntityRemovedFallback(entity);
169
- }
170
- this.clearQueryCache();
171
- this._version++;
172
- }
173
- }
174
- /**
175
- * 更新实体在查询系统中的索引
176
- *
177
- * 当实体的组件组合发生变化时调用此方法,高效地更新实体在查询系统中的索引。
178
- *
179
- * @param entity 要更新的实体
180
- */
181
- updateEntity(entity) {
182
- // 检查实体是否在查询系统中
183
- if (!this._entities.includes(entity)) {
184
- // 如果实体不在系统中,直接添加
185
- this.addEntity(entity);
186
- return;
187
- }
188
- // 先从索引中移除实体的旧状态
189
- this.removeEntityFromIndexes(entity);
190
- // 更新ArchetypeSystem中的实体状态
191
- this._archetypeSystem.updateEntity(entity);
192
- // 重新添加实体到索引(基于新的组件状态)
193
- this.addEntityToIndexes(entity);
194
- // 通知响应式查询
195
- this.notifyReactiveQueriesEntityChanged(entity);
196
- // 清理查询缓存,因为实体组件状态已改变
197
- this.clearQueryCache();
198
- // 更新版本号以使缓存失效
199
- this._version++;
200
- }
201
- /**
202
- * 将实体添加到各种索引中
203
- */
204
- addEntityToIndexes(entity) {
205
- // 标签索引
206
- const tag = entity.tag;
207
- if (tag !== undefined) {
208
- const tagSet = this._entityIndex.byTag.get(tag) || this.createAndSetTagIndex(tag);
209
- tagSet.add(entity);
210
- }
211
- // 名称索引
212
- const name = entity.name;
213
- if (name) {
214
- const nameSet = this._entityIndex.byName.get(name) || this.createAndSetNameIndex(name);
215
- nameSet.add(entity);
216
- }
217
- }
218
- createAndSetTagIndex(tag) {
219
- const set = new Set();
220
- this._entityIndex.byTag.set(tag, set);
221
- return set;
222
- }
223
- createAndSetNameIndex(name) {
224
- const set = new Set();
225
- this._entityIndex.byName.set(name, set);
226
- return set;
227
- }
228
- /**
229
- * 从各种索引中移除实体
230
- */
231
- removeEntityFromIndexes(entity) {
232
- // 从标签索引移除
233
- if (entity.tag !== undefined) {
234
- const tagSet = this._entityIndex.byTag.get(entity.tag);
235
- if (tagSet) {
236
- tagSet.delete(entity);
237
- if (tagSet.size === 0) {
238
- this._entityIndex.byTag.delete(entity.tag);
239
- }
240
- }
241
- }
242
- // 从名称索引移除
243
- if (entity.name) {
244
- const nameSet = this._entityIndex.byName.get(entity.name);
245
- if (nameSet) {
246
- nameSet.delete(entity);
247
- if (nameSet.size === 0) {
248
- this._entityIndex.byName.delete(entity.name);
249
- }
250
- }
251
- }
252
- }
253
- /**
254
- * 重建所有索引
255
- *
256
- * 清空并重新构建所有查询索引。
257
- * 通常在大量实体变更后调用以确保索引一致性。
258
- */
259
- rebuildIndexes() {
260
- this._entityIndex.byTag.clear();
261
- this._entityIndex.byName.clear();
262
- // 清理ArchetypeSystem和ComponentIndexManager
263
- this._archetypeSystem.clear();
264
- for (const entity of this._entities) {
265
- this.addEntityToIndexes(entity);
266
- this._archetypeSystem.addEntity(entity);
267
- }
268
- }
269
- /**
270
- * 查询包含所有指定组件的实体
271
- *
272
- * 返回同时包含所有指定组件类型的实体列表。
273
- * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
274
- *
275
- * @param componentTypes 要查询的组件类型列表
276
- * @returns 查询结果,包含匹配的实体和性能信息
277
- *
278
- * @example
279
- * ```typescript
280
- * // 查询同时具有位置和速度组件的实体
281
- * const result = querySystem.queryAll(PositionComponent, VelocityComponent);
282
- * logger.info(`找到 ${result.count} 个移动实体`);
283
- * ```
284
- */
285
- queryAll(...componentTypes) {
286
- const startTime = performance.now();
287
- this._queryStats.totalQueries++;
288
- // 使用内部响应式查询作为智能缓存
289
- const reactiveQuery = this.getOrCreateReactiveQuery(QueryConditionType.ALL, componentTypes);
290
- // 从响应式查询获取结果(永远是最新的)
291
- const entities = reactiveQuery.getEntities();
292
- // 统计为缓存命中(响应式查询本质上是永不过期的智能缓存)
293
- this._queryStats.cacheHits++;
294
- return {
295
- entities,
296
- count: entities.length,
297
- executionTime: performance.now() - startTime,
298
- fromCache: true
299
- };
300
- }
301
- /**
302
- * 查询包含任意指定组件的实体
303
- *
304
- * 返回包含任意一个指定组件类型的实体列表。
305
- * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
306
- *
307
- * @param componentTypes 要查询的组件类型列表
308
- * @returns 查询结果,包含匹配的实体和性能信息
309
- *
310
- * @example
311
- * ```typescript
312
- * // 查询具有武器或护甲组件的实体
313
- * const result = querySystem.queryAny(WeaponComponent, ArmorComponent);
314
- * logger.info(`找到 ${result.count} 个装备实体`);
315
- * ```
316
- */
317
- queryAny(...componentTypes) {
318
- const startTime = performance.now();
319
- this._queryStats.totalQueries++;
320
- // 使用内部响应式查询作为智能缓存
321
- const reactiveQuery = this.getOrCreateReactiveQuery(QueryConditionType.ANY, componentTypes);
322
- // 从响应式查询获取结果(永远是最新的)
323
- const entities = reactiveQuery.getEntities();
324
- // 统计为缓存命中(响应式查询本质上是永不过期的智能缓存)
325
- this._queryStats.cacheHits++;
326
- return {
327
- entities,
328
- count: entities.length,
329
- executionTime: performance.now() - startTime,
330
- fromCache: true
331
- };
332
- }
333
- /**
334
- * 查询不包含任何指定组件的实体
335
- *
336
- * 返回不包含任何指定组件类型的实体列表。
337
- * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
338
- *
339
- * @param componentTypes 要排除的组件类型列表
340
- * @returns 查询结果,包含匹配的实体和性能信息
341
- *
342
- * @example
343
- * ```typescript
344
- * // 查询不具有AI和玩家控制组件的实体(如静态物体)
345
- * const result = querySystem.queryNone(AIComponent, PlayerControlComponent);
346
- * logger.info(`找到 ${result.count} 个静态实体`);
347
- * ```
348
- */
349
- queryNone(...componentTypes) {
350
- const startTime = performance.now();
351
- this._queryStats.totalQueries++;
352
- // 使用内部响应式查询作为智能缓存
353
- const reactiveQuery = this.getOrCreateReactiveQuery(QueryConditionType.NONE, componentTypes);
354
- // 从响应式查询获取结果(永远是最新的)
355
- const entities = reactiveQuery.getEntities();
356
- // 统计为缓存命中(响应式查询本质上是永不过期的智能缓存)
357
- this._queryStats.cacheHits++;
358
- return {
359
- entities,
360
- count: entities.length,
361
- executionTime: performance.now() - startTime,
362
- fromCache: true
363
- };
364
- }
365
- /**
366
- * 按标签查询实体
367
- *
368
- * 返回具有指定标签的所有实体。
369
- * 标签查询使用专用索引,具有很高的查询性能。
370
- *
371
- * @param tag 要查询的标签值
372
- * @returns 查询结果,包含匹配的实体和性能信息
373
- *
374
- * @example
375
- * ```typescript
376
- * // 查询所有玩家实体
377
- * const players = querySystem.queryByTag(PLAYER_TAG);
378
- * ```
379
- */
380
- queryByTag(tag) {
381
- const startTime = performance.now();
382
- this._queryStats.totalQueries++;
383
- const cacheKey = `tag:${tag}`;
384
- // 检查缓存
385
- const cached = this.getFromCache(cacheKey);
386
- if (cached) {
387
- this._queryStats.cacheHits++;
388
- return {
389
- entities: cached,
390
- count: cached.length,
391
- executionTime: performance.now() - startTime,
392
- fromCache: true
393
- };
394
- }
395
- // 使用索引查询
396
- this._queryStats.indexHits++;
397
- const entities = Array.from(this._entityIndex.byTag.get(tag) || []);
398
- // 缓存结果
399
- this.addToCache(cacheKey, entities);
400
- return {
401
- entities,
402
- count: entities.length,
403
- executionTime: performance.now() - startTime,
404
- fromCache: false
405
- };
406
- }
407
- /**
408
- * 按名称查询实体
409
- *
410
- * 返回具有指定名称的所有实体。
411
- * 名称查询使用专用索引,适用于查找特定的命名实体。
412
- *
413
- * @param name 要查询的实体名称
414
- * @returns 查询结果,包含匹配的实体和性能信息
415
- *
416
- * @example
417
- * ```typescript
418
- * // 查找名为"Player"的实体
419
- * const player = querySystem.queryByName("Player");
420
- * ```
421
- */
422
- queryByName(name) {
423
- const startTime = performance.now();
424
- this._queryStats.totalQueries++;
425
- const cacheKey = `name:${name}`;
426
- // 检查缓存
427
- const cached = this.getFromCache(cacheKey);
428
- if (cached) {
429
- this._queryStats.cacheHits++;
430
- return {
431
- entities: cached,
432
- count: cached.length,
433
- executionTime: performance.now() - startTime,
434
- fromCache: true
435
- };
436
- }
437
- // 使用索引查询
438
- this._queryStats.indexHits++;
439
- const entities = Array.from(this._entityIndex.byName.get(name) || []);
440
- // 缓存结果
441
- this.addToCache(cacheKey, entities);
442
- return {
443
- entities,
444
- count: entities.length,
445
- executionTime: performance.now() - startTime,
446
- fromCache: false
447
- };
448
- }
449
- /**
450
- * 按单个组件类型查询实体
451
- *
452
- * 返回包含指定组件类型的所有实体。
453
- * 这是最基础的查询方法,具有最高的查询性能。
454
- *
455
- * @param componentType 要查询的组件类型
456
- * @returns 查询结果,包含匹配的实体和性能信息
457
- *
458
- * @example
459
- * ```typescript
460
- * // 查询所有具有位置组件的实体
461
- * const entitiesWithPosition = querySystem.queryByComponent(PositionComponent);
462
- * ```
463
- */
464
- queryByComponent(componentType) {
465
- const startTime = performance.now();
466
- this._queryStats.totalQueries++;
467
- const cacheKey = this.generateCacheKey('component', [componentType]);
468
- // 检查缓存
469
- const cached = this.getFromCache(cacheKey);
470
- if (cached) {
471
- this._queryStats.cacheHits++;
472
- return {
473
- entities: cached,
474
- count: cached.length,
475
- executionTime: performance.now() - startTime,
476
- fromCache: true
477
- };
478
- }
479
- this._queryStats.indexHits++;
480
- const entities = this._archetypeSystem.getEntitiesByComponent(componentType);
481
- // 缓存结果
482
- this.addToCache(cacheKey, entities);
483
- return {
484
- entities,
485
- count: entities.length,
486
- executionTime: performance.now() - startTime,
487
- fromCache: false
488
- };
489
- }
490
- /**
491
- * 从缓存获取查询结果
492
- */
493
- getFromCache(cacheKey) {
494
- const entry = this._queryCache.get(cacheKey);
495
- if (!entry)
496
- return null;
497
- // 检查缓存是否过期或版本过期
498
- if (Date.now() - entry.timestamp > this._cacheTimeout || entry.version !== this._version) {
499
- this._queryCache.delete(cacheKey);
500
- return null;
501
- }
502
- entry.hitCount++;
503
- return entry.entities;
504
- }
505
- /**
506
- * 添加查询结果到缓存
507
- */
508
- addToCache(cacheKey, entities) {
509
- // 如果缓存已满,清理最少使用的条目
510
- if (this._queryCache.size >= this._cacheMaxSize) {
511
- this.cleanupCache();
512
- }
513
- this._queryCache.set(cacheKey, {
514
- entities: entities, // 直接使用引用,通过版本号控制失效
515
- timestamp: Date.now(),
516
- hitCount: 0,
517
- version: this._version
518
- });
519
- }
520
- /**
521
- * 清理缓存
522
- */
523
- cleanupCache() {
524
- // 移除过期的缓存条目
525
- const now = Date.now();
526
- for (const [key, entry] of this._queryCache.entries()) {
527
- if (now - entry.timestamp > this._cacheTimeout) {
528
- this._queryCache.delete(key);
529
- }
530
- }
531
- // 如果还是太满,移除最少使用的条目
532
- if (this._queryCache.size >= this._cacheMaxSize) {
533
- let minHitCount = Infinity;
534
- let oldestKey = '';
535
- let oldestTimestamp = Infinity;
536
- // 单次遍历找到最少使用或最旧的条目
537
- for (const [key, entry] of this._queryCache.entries()) {
538
- if (entry.hitCount < minHitCount ||
539
- (entry.hitCount === minHitCount && entry.timestamp < oldestTimestamp)) {
540
- minHitCount = entry.hitCount;
541
- oldestKey = key;
542
- oldestTimestamp = entry.timestamp;
543
- }
544
- }
545
- if (oldestKey) {
546
- this._queryCache.delete(oldestKey);
547
- }
548
- }
549
- }
550
- /**
551
- * 清除所有查询缓存
552
- */
553
- clearQueryCache() {
554
- this._queryCache.clear();
555
- this._componentMaskCache.clear();
556
- }
557
- /**
558
- * 清除所有响应式查询
559
- *
560
- * 销毁所有响应式查询实例并清理索引
561
- * 通常在setEntities时调用以确保缓存一致性
562
- */
563
- clearReactiveQueries() {
564
- for (const query of this._reactiveQueries.values()) {
565
- query.dispose();
566
- }
567
- this._reactiveQueries.clear();
568
- this._reactiveQueriesByComponent.clear();
569
- }
570
- /**
571
- * 高效的缓存键生成
572
- */
573
- generateCacheKey(prefix, componentTypes) {
574
- // 快速路径:单组件查询
575
- if (componentTypes.length === 1) {
576
- const name = getComponentTypeName(componentTypes[0]);
577
- return `${prefix}:${name}`;
578
- }
579
- // 多组件查询:使用排序后的类型名称创建键
580
- const sortKey = componentTypes
581
- .map((t) => {
582
- const name = getComponentTypeName(t);
583
- return name;
584
- })
585
- .sort()
586
- .join(',');
587
- const fullKey = `${prefix}:${sortKey}`;
588
- return fullKey;
589
- }
590
- /**
591
- * 清理查询缓存
592
- *
593
- * 用于外部调用清理缓存,通常在批量操作后使用。
594
- * 注意:此方法也会清理响应式查询缓存
595
- */
596
- clearCache() {
597
- this.clearQueryCache();
598
- this.clearReactiveQueries();
599
- }
600
- /**
601
- * 创建响应式查询
602
- *
603
- * 响应式查询会自动跟踪实体/组件的变化,并通过事件通知订阅者。
604
- * 适合需要实时响应实体变化的场景(如UI更新、AI系统等)。
605
- *
606
- * @param componentTypes 查询的组件类型列表
607
- * @param config 可选的查询配置
608
- * @returns 响应式查询实例
609
- *
610
- * @example
611
- * ```typescript
612
- * const query = querySystem.createReactiveQuery([Position, Velocity], {
613
- * enableBatchMode: true,
614
- * batchDelay: 16
615
- * });
616
- *
617
- * query.subscribe((change) => {
618
- * if (change.type === ReactiveQueryChangeType.ADDED) {
619
- * console.log('新实体:', change.entity);
620
- * }
621
- * });
622
- * ```
623
- */
624
- createReactiveQuery(componentTypes, config) {
625
- if (!componentTypes || componentTypes.length === 0) {
626
- throw new Error('组件类型列表不能为空');
627
- }
628
- const mask = this.createComponentMask(componentTypes);
629
- const condition = {
630
- type: QueryConditionType.ALL,
631
- componentTypes,
632
- mask
633
- };
634
- const query = new ReactiveQuery(condition, config);
635
- const initialEntities = this.executeTraditionalQuery(QueryConditionType.ALL, componentTypes);
636
- query.initializeWith(initialEntities);
637
- const cacheKey = this.generateCacheKey('all', componentTypes);
638
- this._reactiveQueries.set(cacheKey, query);
639
- for (const type of componentTypes) {
640
- let queries = this._reactiveQueriesByComponent.get(type);
641
- if (!queries) {
642
- queries = new Set();
643
- this._reactiveQueriesByComponent.set(type, queries);
644
- }
645
- queries.add(query);
646
- }
647
- return query;
648
- }
649
- /**
650
- * 销毁响应式查询
651
- *
652
- * 清理查询占用的资源,包括监听器和实体引用。
653
- * 销毁后的查询不应再被使用。
654
- *
655
- * @param query 要销毁的响应式查询
656
- *
657
- * @example
658
- * ```typescript
659
- * const query = querySystem.createReactiveQuery([Position, Velocity]);
660
- * // ... 使用查询
661
- * querySystem.destroyReactiveQuery(query);
662
- * ```
663
- */
664
- destroyReactiveQuery(query) {
665
- if (!query) {
666
- return;
667
- }
668
- const cacheKey = query.id;
669
- this._reactiveQueries.delete(cacheKey);
670
- for (const type of query.condition.componentTypes) {
671
- const queries = this._reactiveQueriesByComponent.get(type);
672
- if (queries) {
673
- queries.delete(query);
674
- if (queries.size === 0) {
675
- this._reactiveQueriesByComponent.delete(type);
676
- }
677
- }
678
- }
679
- query.dispose();
680
- }
681
- /**
682
- * 创建组件掩码
683
- *
684
- * 根据组件类型列表生成对应的位掩码。
685
- * 使用缓存避免重复计算。
686
- * 注意:必须使用ComponentRegistry来确保与Entity.componentMask使用相同的bitIndex
687
- *
688
- * @param componentTypes 组件类型列表
689
- * @returns 生成的位掩码
690
- */
691
- createComponentMask(componentTypes) {
692
- // 生成缓存键
693
- const cacheKey = componentTypes
694
- .map((t) => {
695
- return getComponentTypeName(t);
696
- })
697
- .sort()
698
- .join(',');
699
- // 检查缓存
700
- const cached = this._componentMaskCache.get(cacheKey);
701
- if (cached) {
702
- return cached;
703
- }
704
- // 使用ComponentRegistry而不是ComponentTypeManager,确保bitIndex一致
705
- const mask = BitMask64Utils.clone(BitMask64Utils.ZERO);
706
- for (const type of componentTypes) {
707
- // 确保组件已注册
708
- if (!ComponentRegistry.isRegistered(type)) {
709
- ComponentRegistry.register(type);
710
- }
711
- const bitMask = ComponentRegistry.getBitMask(type);
712
- BitMask64Utils.orInPlace(mask, bitMask);
713
- }
714
- // 缓存结果
715
- this._componentMaskCache.set(cacheKey, mask);
716
- return mask;
717
- }
718
- /**
719
- * 获取当前版本号(用于缓存失效)
720
- */
721
- get version() {
722
- return this._version;
723
- }
724
- /**
725
- * 获取所有实体
726
- */
727
- getAllEntities() {
728
- return this._entities;
729
- }
730
- /**
731
- * 获取系统统计信息
732
- *
733
- * 返回查询系统的详细统计信息,包括实体数量、索引状态、
734
- * 查询性能统计等,用于性能监控和调试。
735
- *
736
- * @returns 系统统计信息对象
737
- */
738
- getStats() {
739
- return {
740
- entityCount: this._entities.length,
741
- indexStats: {
742
- componentIndexSize: this._archetypeSystem.getAllArchetypes().length,
743
- tagIndexSize: this._entityIndex.byTag.size,
744
- nameIndexSize: this._entityIndex.byName.size
745
- },
746
- queryStats: {
747
- ...this._queryStats,
748
- cacheHitRate: this._queryStats.totalQueries > 0
749
- ? ((this._queryStats.cacheHits / this._queryStats.totalQueries) * 100).toFixed(2) + '%'
750
- : '0%'
751
- },
752
- optimizationStats: {
753
- archetypeSystem: this._archetypeSystem.getAllArchetypes().map((a) => ({
754
- id: a.id,
755
- componentTypes: a.componentTypes.map((t) => getComponentTypeName(t)),
756
- entityCount: a.entities.size
757
- }))
758
- },
759
- cacheStats: {
760
- size: this._reactiveQueries.size,
761
- hitRate: this._queryStats.totalQueries > 0
762
- ? ((this._queryStats.cacheHits / this._queryStats.totalQueries) * 100).toFixed(2) + '%'
763
- : '0%'
764
- }
765
- };
766
- }
767
- /**
768
- * 获取实体所属的原型信息
769
- *
770
- * @param entity 要查询的实体
771
- */
772
- getEntityArchetype(entity) {
773
- return this._archetypeSystem.getEntityArchetype(entity);
774
- }
775
- /**
776
- * 获取或创建内部响应式查询(作为智能缓存)
777
- *
778
- * @param queryType 查询类型
779
- * @param componentTypes 组件类型列表
780
- * @returns 响应式查询实例
781
- */
782
- getOrCreateReactiveQuery(queryType, componentTypes) {
783
- // 生成缓存键(与传统缓存键格式一致)
784
- const cacheKey = this.generateCacheKey(queryType, componentTypes);
785
- // 检查是否已存在响应式查询
786
- let reactiveQuery = this._reactiveQueries.get(cacheKey);
787
- if (!reactiveQuery) {
788
- // 创建查询条件
789
- const mask = this.createComponentMask(componentTypes);
790
- const condition = {
791
- type: queryType,
792
- componentTypes,
793
- mask
794
- };
795
- // 创建响应式查询(禁用批量模式,保持实时性)
796
- reactiveQuery = new ReactiveQuery(condition, {
797
- enableBatchMode: false,
798
- debug: false
799
- });
800
- // 初始化查询结果(使用传统方式获取初始数据)
801
- const initialEntities = this.executeTraditionalQuery(queryType, componentTypes);
802
- reactiveQuery.initializeWith(initialEntities);
803
- // 注册响应式查询
804
- this._reactiveQueries.set(cacheKey, reactiveQuery);
805
- // 为每个组件类型注册索引
806
- for (const type of componentTypes) {
807
- let queries = this._reactiveQueriesByComponent.get(type);
808
- if (!queries) {
809
- queries = new Set();
810
- this._reactiveQueriesByComponent.set(type, queries);
811
- }
812
- queries.add(reactiveQuery);
813
- }
814
- this._logger.debug(`创建内部响应式查询缓存: ${cacheKey}`);
815
- }
816
- return reactiveQuery;
817
- }
818
- /**
819
- * 执行传统查询(内部使用,用于响应式查询初始化)
820
- *
821
- * @param queryType 查询类型
822
- * @param componentTypes 组件类型列表
823
- * @returns 匹配的实体列表
824
- */
825
- executeTraditionalQuery(queryType, componentTypes) {
826
- switch (queryType) {
827
- case QueryConditionType.ALL: {
828
- const archetypeResult = this._archetypeSystem.queryArchetypes(componentTypes, 'AND');
829
- const entities = [];
830
- for (const archetype of archetypeResult.archetypes) {
831
- for (const entity of archetype.entities) {
832
- entities.push(entity);
833
- }
834
- }
835
- return entities;
836
- }
837
- case QueryConditionType.ANY: {
838
- const archetypeResult = this._archetypeSystem.queryArchetypes(componentTypes, 'OR');
839
- const entities = [];
840
- for (const archetype of archetypeResult.archetypes) {
841
- for (const entity of archetype.entities) {
842
- entities.push(entity);
843
- }
844
- }
845
- return entities;
846
- }
847
- case QueryConditionType.NONE: {
848
- const mask = this.createComponentMask(componentTypes);
849
- return this._entities.filter((entity) => BitMask64Utils.hasNone(entity.componentMask, mask));
850
- }
851
- default:
852
- return [];
853
- }
854
- }
855
- /**
856
- * 通知所有响应式查询实体已添加
857
- *
858
- * 使用组件类型索引,只通知关心该实体组件的查询
859
- *
860
- * @param entity 添加的实体
861
- */
862
- notifyReactiveQueriesEntityAdded(entity) {
863
- if (this._reactiveQueries.size === 0)
864
- return;
865
- const notified = new Set();
866
- for (const component of entity.components) {
867
- const componentType = component.constructor;
868
- const queries = this._reactiveQueriesByComponent.get(componentType);
869
- if (queries) {
870
- for (const query of queries) {
871
- if (!notified.has(query)) {
872
- query.notifyEntityAdded(entity);
873
- notified.add(query);
874
- }
875
- }
876
- }
877
- }
878
- }
879
- /**
880
- * 通知响应式查询实体已移除
881
- *
882
- * 使用组件类型索引,只通知关心该实体组件的查询
883
- *
884
- * @param entity 移除的实体
885
- * @param componentTypes 实体移除前的组件类型列表
886
- */
887
- notifyReactiveQueriesEntityRemoved(entity, componentTypes) {
888
- if (this._reactiveQueries.size === 0)
889
- return;
890
- const notified = new Set();
891
- for (const componentType of componentTypes) {
892
- const queries = this._reactiveQueriesByComponent.get(componentType);
893
- if (queries) {
894
- for (const query of queries) {
895
- if (!notified.has(query)) {
896
- query.notifyEntityRemoved(entity);
897
- notified.add(query);
898
- }
899
- }
900
- }
901
- }
902
- }
903
- /**
904
- * 通知响应式查询实体已移除(后备方案)
905
- *
906
- * 当实体已经清空组件时使用,通知所有查询
907
- *
908
- * @param entity 移除的实体
909
- */
910
- notifyReactiveQueriesEntityRemovedFallback(entity) {
911
- if (this._reactiveQueries.size === 0)
912
- return;
913
- for (const query of this._reactiveQueries.values()) {
914
- query.notifyEntityRemoved(entity);
915
- }
916
- }
917
- /**
918
- * 通知响应式查询实体已变化
919
- *
920
- * 使用混合策略:
921
- * 1. 首先通知关心实体当前组件的查询
922
- * 2. 然后通知所有其他查询(包括那些可能因为组件移除而不再匹配的查询)
923
- *
924
- * @param entity 变化的实体
925
- */
926
- notifyReactiveQueriesEntityChanged(entity) {
927
- if (this._reactiveQueries.size === 0) {
928
- return;
929
- }
930
- const notified = new Set();
931
- for (const component of entity.components) {
932
- const componentType = component.constructor;
933
- const queries = this._reactiveQueriesByComponent.get(componentType);
934
- if (queries) {
935
- for (const query of queries) {
936
- if (!notified.has(query)) {
937
- query.notifyEntityChanged(entity);
938
- notified.add(query);
939
- }
940
- }
941
- }
942
- }
943
- for (const query of this._reactiveQueries.values()) {
944
- if (!notified.has(query)) {
945
- query.notifyEntityChanged(entity);
946
- }
947
- }
948
- }
949
- }
950
- /**
951
- * 查询构建器
952
- *
953
- * 提供链式API来构建复杂的实体查询条件。
954
- * 支持组合多种查询条件,创建灵活的查询表达式。
955
- *
956
- * @example
957
- * ```typescript
958
- * const result = new QueryBuilder(querySystem)
959
- * .withAll(PositionComponent, VelocityComponent)
960
- * .without(DeadComponent)
961
- * .execute();
962
- * ```
963
- */
964
- export class QueryBuilder {
965
- constructor(querySystem) {
966
- this._logger = createLogger('QueryBuilder');
967
- this.conditions = [];
968
- this.querySystem = querySystem;
969
- }
970
- /**
971
- * 添加"必须包含所有组件"条件
972
- *
973
- * @param componentTypes 必须包含的组件类型
974
- * @returns 查询构建器实例,支持链式调用
975
- */
976
- withAll(...componentTypes) {
977
- this.conditions.push({
978
- type: QueryConditionType.ALL,
979
- componentTypes,
980
- mask: this.createComponentMask(componentTypes)
981
- });
982
- return this;
983
- }
984
- /**
985
- * 添加"必须包含任意组件"条件
986
- *
987
- * @param componentTypes 必须包含其中任意一个的组件类型
988
- * @returns 查询构建器实例,支持链式调用
989
- */
990
- withAny(...componentTypes) {
991
- this.conditions.push({
992
- type: QueryConditionType.ANY,
993
- componentTypes,
994
- mask: this.createComponentMask(componentTypes)
995
- });
996
- return this;
997
- }
998
- /**
999
- * 添加"不能包含任何组件"条件
1000
- *
1001
- * @param componentTypes 不能包含的组件类型
1002
- * @returns 查询构建器实例,支持链式调用
1003
- */
1004
- without(...componentTypes) {
1005
- this.conditions.push({
1006
- type: QueryConditionType.NONE,
1007
- componentTypes,
1008
- mask: this.createComponentMask(componentTypes)
1009
- });
1010
- return this;
1011
- }
1012
- /**
1013
- * 执行查询并返回结果
1014
- *
1015
- * 根据已添加的查询条件执行实体查询。
1016
- *
1017
- * @returns 查询结果,包含匹配的实体和性能信息
1018
- */
1019
- execute() {
1020
- const startTime = performance.now();
1021
- // 简化实现:目前只支持单一条件
1022
- if (this.conditions.length === 1) {
1023
- const condition = this.conditions[0];
1024
- switch (condition.type) {
1025
- case QueryConditionType.ALL:
1026
- return this.querySystem.queryAll(...condition.componentTypes);
1027
- case QueryConditionType.ANY:
1028
- return this.querySystem.queryAny(...condition.componentTypes);
1029
- case QueryConditionType.NONE:
1030
- return this.querySystem.queryNone(...condition.componentTypes);
1031
- }
1032
- }
1033
- // 多条件查询的复杂实现留待后续扩展
1034
- return {
1035
- entities: [],
1036
- count: 0,
1037
- executionTime: performance.now() - startTime,
1038
- fromCache: false
1039
- };
1040
- }
1041
- /**
1042
- * 创建组件掩码
1043
- */
1044
- createComponentMask(componentTypes) {
1045
- const mask = BitMask64Utils.clone(BitMask64Utils.ZERO);
1046
- for (const type of componentTypes) {
1047
- try {
1048
- const bitMask = ComponentRegistry.getBitMask(type);
1049
- BitMask64Utils.orInPlace(mask, bitMask);
1050
- }
1051
- catch (error) {
1052
- this._logger.warn(`组件类型 ${getComponentTypeName(type)} 未注册,跳过`);
1053
- }
1054
- }
1055
- return mask;
1056
- }
1057
- /**
1058
- * 重置查询构建器
1059
- *
1060
- * 清除所有已添加的查询条件,重新开始构建查询。
1061
- *
1062
- * @returns 查询构建器实例,支持链式调用
1063
- */
1064
- reset() {
1065
- this.conditions = [];
1066
- return this;
1067
- }
1068
- }
1069
- //# sourceMappingURL=QuerySystem.js.map