refactor: tile entities again

This commit is contained in:
cha0s 2021-01-19 20:39:20 -06:00
parent 7de9280cf4
commit 0adb244efc

View File

@ -77,14 +77,14 @@ export default (latus) => class Layer extends decorate(JsonResource) {
return this.entityList.findEntity(uuid);
}
// hasTileEntityWithUriAt(tilePosition, uri) {
// const tileEntities = this.tileEntitiesAt(tilePosition);
// if (0 === tileEntities.length) {
// return false;
// }
// const entitiesWithUri = tileEntities.filter((entity) => entity.uri === uri);
// return entitiesWithUri.length > 0;
// }
hasTileEntityWithUriAt(tilePosition, uri) {
const tileEntities = this.tileEntitiesAt(tilePosition);
if (0 === tileEntities.length) {
return false;
}
const entitiesWithUri = tileEntities.filter((entity) => entity.uri === uri);
return entitiesWithUri.length > 0;
}
indexAt(position) {
return this.tiles.indexAt(position);
@ -142,16 +142,16 @@ export default (latus) => class Layer extends decorate(JsonResource) {
this.entityList.removeEntity(entity);
}
// removeTileEntity(entity, index) {
// if (!this.tileEntities[index]) {
// return;
// }
// const entityIndex = this.tileEntities[index].indexOf(entity);
// if (-1 === entityIndex) {
// return;
// }
// this.tileEntities[index].splice(entityIndex, 1);
// }
removeTileEntity(entity, index) {
if (!this.tileEntities[index]) {
return;
}
const entityIndex = this.tileEntities[index].indexOf(entity);
if (-1 === entityIndex) {
return;
}
this.tileEntities[index].splice(entityIndex, 1);
}
setEntityList(entityList) {
if (this.entityList) {
@ -189,13 +189,13 @@ export default (latus) => class Layer extends decorate(JsonResource) {
return this.tiles.tileAt(position);
}
// tileEntitiesAt(tilePosition) {
// const index = this.indexAt(tilePosition);
// if (!this.tileEntities[index]) {
// return [];
// }
// return this.tileEntities[index];
// }
tileEntitiesAt(tilePosition) {
const index = this.indexAt(tilePosition);
if (!this.tileEntities[index]) {
return [];
}
return this.tileEntities[index];
}
toJSON() {
return {