fix: don't send whole state in packets

This commit is contained in:
cha0s 2019-10-03 15:33:39 -05:00
parent 9f2e2960c4
commit c1ddc04703
2 changed files with 8 additions and 2 deletions

View File

@ -98,7 +98,10 @@ export class Alive extends decorate(Trait) {
const packets = [];
const {isDying, life, maxLife} = this.stateDifferences();
if (life || maxLife) {
packets.push(new TraitUpdateAlivePacket(this.state));
packets.push(new TraitUpdateAlivePacket({
life: this.state.life,
maxLife: this.state.maxLife,
}));
}
if (isDying) {
packets.push(new DiedPacket());

View File

@ -96,7 +96,10 @@ export class Visible extends decorate(Trait) {
packets(informed) {
const {isVisible, opacity} = this.stateDifferences();
if (isVisible || opacity) {
return new TraitUpdateVisiblePacket(this.state);
return new TraitUpdateVisiblePacket({
isVisible: this.state.isVisible,
opacity: this.state.opacity,
});
}
}