fix: don't double up remove packets

This commit is contained in:
cha0s 2019-05-16 15:47:39 -05:00
parent 6047a61906
commit 042034d5d8

View File

@ -159,12 +159,19 @@ export class Informed extends decorate(Trait) {
}
injectEntityRemovePackets(packets, visibleEntities) {
const alreadyRemovedEntities = packets.filter((packet) => {
return packet instanceof EntityRemovePacket;
}).map((packet) => {
return packet.entity;
});
for (let i = 0; i < this.seenEntities.length; i++) {
const entity = this.seenEntities[i];
if (-1 === visibleEntities.indexOf(entity)) {
if (-1 === alreadyRemovedEntities.indexOf(entity)) {
packets.push(new EntityRemovePacket({}, entity));
}
}
}
return packets;
}