kubi/kubi-shared/src/networking/messages.rs

46 lines
781 B
Rust
Raw Normal View History

use bincode::{Encode, Decode};
use crate::chunk::BlockData;
2023-01-29 20:42:58 -06:00
type IVec3Arr = [i32; 3];
type Vec3Arr = [f32; 3];
type QuatArr = [f32; 3];
#[derive(Encode, Decode)]
2023-01-29 20:42:58 -06:00
pub enum ClientToServerMessage {
ClientHello {
username: String,
password: Option<String>,
},
PositionChanged {
2023-01-30 19:23:44 -06:00
client_id: u8,
secret: u32,
position: Vec3Arr,
direction: QuatArr,
},
ChunkRequest {
client_id: u8,
secret: u32,
chunk: IVec3Arr,
},
2023-01-29 20:42:58 -06:00
}
#[derive(Encode, Decode)]
2023-01-29 20:42:58 -06:00
pub enum ServerToClientMessage {
ServerHello {
2023-01-30 19:23:44 -06:00
client_id: u8,
secret: u32,
},
ServerFuckOff {
reason: String,
},
PlayerPositionChanged {
client_id: u8,
position: Vec3Arr,
direction: QuatArr,
},
ChunkResponse {
chunk: IVec3Arr,
data: BlockData
}
2023-01-29 20:42:58 -06:00
}