refactor: send updates before destroys

This commit is contained in:
cha0s 2019-10-01 20:45:25 -05:00
parent c08b32b68c
commit a5a09cbcba

View File

@ -139,6 +139,12 @@ export class EntityList extends decorate(class {}) {
previousVisibleEntities.splice(index, 1);
}
}
// Send updates.
this._informedEntities.set(informed, visibleEntities);
if (updates.length > 0) {
packets.push(new EntityListUpdateEntityPacket(updates));
}
// Send destroys.
for (let i = 0; i < previousVisibleEntities.length; i++) {
const entity = previousVisibleEntities[i];
// Newly removed entity.
@ -146,10 +152,6 @@ export class EntityList extends decorate(class {}) {
packets.push(entity.destroyPacket(informed));
}
}
this._informedEntities.set(informed, visibleEntities);
if (updates.length > 0) {
packets.push(new EntityListUpdateEntityPacket(updates));
}
return packets;
}