refactor: layer -> list
This commit is contained in:
parent
05d7b4097d
commit
d2dbaaa6ae
|
@ -64,8 +64,8 @@ export default (latus) => class Collider extends decorate(Trait) {
|
|||
if (!this.params.activeCollision) {
|
||||
return;
|
||||
}
|
||||
const {layer} = this.entity;
|
||||
if (!layer) {
|
||||
const {list} = this.entity;
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
const query = Rectangle.compose(
|
||||
|
@ -76,7 +76,7 @@ export default (latus) => class Collider extends decorate(Trait) {
|
|||
this.entity.shape.aabb,
|
||||
this.entity.position,
|
||||
);
|
||||
const entities = layer.visibleEntities(query);
|
||||
const entities = list.visibleEntities(query);
|
||||
for (let i = 0; i < entities.length; ++i) {
|
||||
const entity = entities[i];
|
||||
if (
|
||||
|
|
|
@ -155,9 +155,5 @@ export default (latus) => {
|
|||
};
|
||||
}
|
||||
|
||||
visibleEntities(query) {
|
||||
return this.entityList.visibleEntities(query);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -124,17 +124,5 @@ export default (latus) => {
|
|||
return this.layers.map((layer) => layer.toNetwork(informed));
|
||||
}
|
||||
|
||||
visibleEntities(query) {
|
||||
const entities = [];
|
||||
for (let i = 0; i < this.layers.length; i++) {
|
||||
const layerVisibleEntities = this.layers[i].visibleEntities(query);
|
||||
for (let j = 0; j < layerVisibleEntities.length; j++) {
|
||||
const layerVisibleEntity = layerVisibleEntities[j];
|
||||
entities.push(layerVisibleEntity);
|
||||
}
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -117,9 +117,5 @@ export default (latus) => {
|
|||
};
|
||||
}
|
||||
|
||||
visibleEntities(query) {
|
||||
return this.layers.visibleEntities(query);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -18,22 +18,4 @@ describe('Layer', () => {
|
|||
expect(Object.keys(layer.entities).length).to.equal(0);
|
||||
expect(layer.tiles.size).to.deep.equal([0, 0]);
|
||||
});
|
||||
describe('entity list interaction', () => {
|
||||
let entity;
|
||||
let layer;
|
||||
beforeEach(async () => {
|
||||
const {Entity, EntityList, Layer} = latus.get('%resources');
|
||||
entity = await Entity.load({});
|
||||
const entityList = new EntityList();
|
||||
entityList.addEntity(entity);
|
||||
layer = new Layer();
|
||||
layer.setEntityList(entityList);
|
||||
})
|
||||
it('delegates to entity list', async () => {
|
||||
expect(Object.keys(layer.entities).length).to.equal(1);
|
||||
});
|
||||
it('can find entities', async () => {
|
||||
expect(layer.findEntity(entity.instanceUuid)).to.equal(entity);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user