* 执行查询并返回结果 * * 根据已添加的查询条件执行实体查询。 * * @returns 查询结果,包含匹配的实体和性能信息
()
| 1312 | * @returns 查询结果,包含匹配的实体和性能信息 |
| 1313 | */ |
| 1314 | public execute(): QueryResult { |
| 1315 | const startTime = performance.now(); |
| 1316 | |
| 1317 | // 简化实现:目前只支持单一条件 |
| 1318 | if (this.conditions.length === 1) { |
| 1319 | const condition = this.conditions[0]!; |
| 1320 | switch (condition.type) { |
| 1321 | case QueryConditionType.ALL: |
| 1322 | return this.querySystem.queryAll(...condition.componentTypes); |
| 1323 | case QueryConditionType.ANY: |
| 1324 | return this.querySystem.queryAny(...condition.componentTypes); |
| 1325 | case QueryConditionType.NONE: |
| 1326 | return this.querySystem.queryNone(...condition.componentTypes); |
| 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | // 多条件查询的复杂实现留待后续扩展 |
| 1331 | return { |
| 1332 | entities: [], |
| 1333 | count: 0, |
| 1334 | executionTime: performance.now() - startTime, |
| 1335 | fromCache: false |
| 1336 | }; |
| 1337 | } |
| 1338 | |
| 1339 | /** |
| 1340 | * 创建组件掩码 |