refactor: clone context
This commit is contained in:
parent
4989ac4590
commit
17f8e8ff79
|
@ -1,4 +1,4 @@
|
|||
import {compile, Context} from '@avocado/behavior';
|
||||
import {compile} from '@avocado/behavior';
|
||||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {QuadTree, Rectangle} from '@avocado/math';
|
||||
import {JsonResource} from '@avocado/resource';
|
||||
|
@ -174,18 +174,15 @@ export default (latus) => class EntityList extends decorate(JsonResource) {
|
|||
return this.#quadTree;
|
||||
}
|
||||
|
||||
queryEntities(query, condition) {
|
||||
queryEntities(query, condition, context) {
|
||||
const check = compile(condition, latus);
|
||||
const candidates = this.visibleEntities(query, true);
|
||||
const fails = [];
|
||||
for (let i = 0; i < candidates.length; ++i) {
|
||||
const entity = candidates[i];
|
||||
if (!check(new Context(
|
||||
{
|
||||
entity,
|
||||
},
|
||||
latus,
|
||||
))) {
|
||||
const clone = context.clone();
|
||||
clone.add('entity', entity);
|
||||
if (!check(clone)) {
|
||||
fails.push(entity);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user