EntityUpdatePacket.cpp 849 B

12345678910111213141516171819202122232425262728
  1. #include "common/network/toclient/EntityUpdatePacket.h"
  2. #include "common/network/Packets.h"
  3. EntityUpdatePacket::EntityUpdatePacket(const Entity& e)
  4. : lengthAngle(e.lengthAngle), widthAngle(e.widthAngle),
  5. position(e.position), velocity(e.velocity) {
  6. }
  7. EntityUpdatePacket::EntityUpdatePacket() {
  8. }
  9. void EntityUpdatePacket::write(OutPacket& out) const {
  10. out.writeU16(Packets::S_ENTITY_UPDATE);
  11. out.writeFloat(lengthAngle);
  12. out.writeFloat(widthAngle);
  13. Packets::writeVector(out, position);
  14. Packets::writeVector(out, velocity);
  15. }
  16. bool EntityUpdatePacket::read(InPacket& in) {
  17. return in.readFloat(lengthAngle) || in.readFloat(widthAngle) ||
  18. Packets::readVector(in, position) ||
  19. Packets::readVector(in, velocity);
  20. }
  21. int EntityUpdatePacket::getSize() {
  22. return sizeof(EntityUpdatePacket) + 2;
  23. }