avocado-old/packages/graphics/packets/trait-update-visible.packet.js
2020-06-15 17:26:20 -05:00

28 lines
522 B
JavaScript

import {Packet} from '@avocado/net';
export default class TraitUpdateVisiblePacket extends Packet {
static pack(packet) {
const data = packet.data[1];
data.opacity = Math.floor(data.opacity * 255);
return super.pack(packet);
}
static get schema() {
return {
...super.schema,
data: {
isVisible: 'bool',
opacity: 'uint8',
},
};
}
static unpack(packet) {
const data = super.unpack(packet);
data.opacity = data.opacity / 255;
return data;
}
}