* 查询匹配的实体
()
| 518 | * 查询匹配的实体 |
| 519 | */ |
| 520 | private queryEntities(): readonly Entity[] { |
| 521 | if (!this.scene?.querySystem || !this._matcher) { |
| 522 | return []; |
| 523 | } |
| 524 | |
| 525 | const condition = this._matcher.getCondition(); |
| 526 | const querySystem = this.scene.querySystem; |
| 527 | let currentEntities: readonly Entity[] = []; |
| 528 | |
| 529 | // matchNothing 条件返回空数组(用于只需要生命周期方法的系统) |
| 530 | if (this._matcher.isNothing()) { |
| 531 | return []; |
| 532 | } |
| 533 | |
| 534 | // 空条件返回所有实体 |
| 535 | if (this._matcher.isEmpty()) { |
| 536 | currentEntities = querySystem.getAllEntities(); |
| 537 | } else if (this.isSingleCondition(condition)) { |
| 538 | // 单一条件优化查询 |
| 539 | currentEntities = this.executeSingleConditionQuery(condition, querySystem); |
| 540 | } else { |
| 541 | // 复合查询 |
| 542 | currentEntities = this.executeComplexQuery(condition, querySystem); |
| 543 | } |
| 544 | |
| 545 | // 检查实体变化并触发回调 |
| 546 | this.updateEntityTracking(currentEntities); |
| 547 | |
| 548 | return currentEntities; |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * 检查是否为单一条件查询 |
nothing calls this directly
no test coverage detected