28 lines
633 B
JavaScript
28 lines
633 B
JavaScript
|
import {Container, Sprite} from '@avocado/graphics';
|
||
|
|
||
|
export class EntityListView extends Container {
|
||
|
|
||
|
constructor(entityList) {
|
||
|
super();
|
||
|
this.entityList = entityList;
|
||
|
entityList.on('entityAdded', this.onListEntityAdded, this);
|
||
|
entityList.on('entityRemoved', this.onListEntityRemoved, this);
|
||
|
for (const entity of entityList) {
|
||
|
this.onListEntityAdded(entity);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onListEntityAdded(entity) {
|
||
|
if (entity.is('graphical')) {
|
||
|
this.addChild(entity.container);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onListEntityRemoved(entity) {
|
||
|
if (entity.is('graphical')) {
|
||
|
this.removeChild(entity.container);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|