MCPcopy Create free account
hub / github.com/esengine/esengine / queryEntities

Function queryEntities

packages/core/src/ECS/Systems/EntitySystem.ts:520–549  ·  view source on GitHub ↗

* 查询匹配的实体

()

Source from the content-addressed store, hash-verified

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 * 检查是否为单一条件查询

Callers

nothing calls this directly

Calls 8

isNothingMethod · 0.80
isSingleConditionMethod · 0.80
executeComplexQueryMethod · 0.80
updateEntityTrackingMethod · 0.80
isEmptyMethod · 0.65
getAllEntitiesMethod · 0.65
getConditionMethod · 0.45

Tested by

no test coverage detected