open_dis_rust/common/
entity_coordinate_vector.rs1use bytes::{Buf, BufMut, BytesMut};
8
9#[derive(Copy, Clone, Debug, Default)]
10pub struct EntityCoordinateVector {
12 pub x_coordinate: f32,
14 pub y_coordinate: f32,
16 pub z_coordinate: f32,
18}
19
20impl EntityCoordinateVector {
21 #[must_use]
22 pub fn new(x: f32, y: f32, z: f32) -> Self {
23 EntityCoordinateVector {
24 x_coordinate: x,
25 y_coordinate: y,
26 z_coordinate: z,
27 }
28 }
29
30 pub fn serialize(&self, buf: &mut BytesMut) {
31 buf.put_f32(self.x_coordinate);
32 buf.put_f32(self.y_coordinate);
33 buf.put_f32(self.z_coordinate);
34 }
35
36 pub fn decode(buf: &mut BytesMut) -> EntityCoordinateVector {
37 EntityCoordinateVector {
38 x_coordinate: buf.get_f32(),
39 y_coordinate: buf.get_f32(),
40 z_coordinate: buf.get_f32(),
41 }
42 }
43}