fix: children splicing

This commit is contained in:
cha0s 2019-10-01 01:46:13 -05:00
parent ecee85dac8
commit cfd6a5ef67

View File

@ -70,8 +70,10 @@ export class Spawner extends decorate(Trait) {
return {
killAllChildren: () => {
for (let i = 0; i < this.children.length; i++) {
this.children[i].destroyGently();
// Juggle children since this may cause splices and mess up the array.
const children = this.children.slice(0);
for (let i = 0; i < children.length; i++) {
children[i].destroyGently();
}
},