+void Packet::SpawnEntity::WriteEntity(const Entity &e) noexcept {
+ Write(e.ID(), 0);
+ if (e.GetModel()) {
+ Write(e.GetModel().GetModel().ID(), 4);
+ } else {
+ Write(uint32_t(0), 4);
+ }
+ Write(e.ChunkCoords(), 8);
+ Write(e.Position(), 20);
+ Write(e.Velocity(), 32);
+ Write(e.Orientation(), 44);
+ Write(e.AngularVelocity(), 60);
+ Write(e.Bounds(), 72);
+ uint32_t flags = 0;
+ if (e.WorldCollidable()) {
+ flags |= 1;
+ }
+ Write(flags, 96);
+ WriteString(e.Name(), 100, 32);
+}
+
+void Packet::SpawnEntity::ReadEntityID(uint32_t &id) const noexcept {
+ Read(id, 0);
+}
+
+void Packet::SpawnEntity::ReadSkeletonID(uint32_t &id) const noexcept {
+ Read(id, 4);
+}
+
+void Packet::SpawnEntity::ReadEntity(Entity &e) const noexcept {
+ glm::ivec3 chunk_coords(0);
+ glm::vec3 pos;
+ glm::vec3 vel;
+ glm::quat rot;
+ glm::vec3 ang;
+ AABB bounds;
+ uint32_t flags = 0;
+ string name;
+
+ Read(chunk_coords, 8);
+ Read(pos, 20);
+ Read(vel, 32);
+ Read(rot, 44);
+ Read(ang, 60);
+ Read(bounds, 72);
+ Read(flags, 96);
+ ReadString(name, 100, 32);
+
+ e.Position(chunk_coords, pos);
+ e.Velocity(vel);
+ e.Orientation(rot);
+ e.AngularVelocity(ang);
+ e.Bounds(bounds);
+ e.WorldCollidable(flags & 1);
+ e.Name(name);
+}
+
+void Packet::DespawnEntity::WriteEntityID(uint32_t id) noexcept {
+ Write(id, 0);
+}
+
+void Packet::DespawnEntity::ReadEntityID(uint32_t &id) const noexcept {
+ Read(id, 0);
+}
+
+void Packet::EntityUpdate::WriteEntityCount(uint32_t count) noexcept {
+ Write(count, 0);
+}
+
+void Packet::EntityUpdate::ReadEntityCount(uint32_t &count) const noexcept {
+ Read(count, 0);
+}
+
+void Packet::EntityUpdate::WriteEntity(const Entity &entity, uint32_t num) noexcept {
+ uint32_t off = 4 + (num * 64);
+
+ Write(entity.ID(), off);
+ Write(entity.ChunkCoords(), off + 4);
+ Write(entity.Position(), off + 16);
+ Write(entity.Velocity(), off + 28);
+ Write(entity.Orientation(), off + 40);
+ Write(entity.AngularVelocity(), off + 56);
+}
+
+void Packet::EntityUpdate::ReadEntityID(uint32_t &id, uint32_t num) const noexcept {
+ Read(id, 4 + (num * 64));
+}
+
+void Packet::EntityUpdate::ReadEntity(Entity &entity, uint32_t num) const noexcept {
+ uint32_t off = 4 + (num * 64);
+
+ glm::ivec3 chunk_coords(0);
+ glm::vec3 pos;
+ glm::vec3 vel;
+ glm::quat rot;
+ glm::vec3 ang;
+
+ Read(chunk_coords, off + 4);
+ Read(pos, off + 16);
+ Read(vel, off + 28);
+ Read(rot, off + 40);
+ Read(ang, off + 56);
+
+ entity.Position(chunk_coords, pos);
+ entity.Velocity(vel);
+ entity.Orientation(rot);
+ entity.AngularVelocity(ang);
+}
+