2019-04-19 19:32:47 +00:00
|
|
|
use super::ClientState;
|
2019-07-02 18:19:16 +00:00
|
|
|
use crate::terrain::block::Block;
|
2019-07-17 22:10:42 +00:00
|
|
|
use crate::{comp, ChatType};
|
2019-04-29 20:37:19 +00:00
|
|
|
use vek::*;
|
2019-03-05 18:39:18 +00:00
|
|
|
|
2019-04-19 19:32:47 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
2019-03-03 22:02:38 +00:00
|
|
|
pub enum ClientMsg {
|
2019-04-29 20:37:19 +00:00
|
|
|
Register {
|
|
|
|
player: comp::Player,
|
|
|
|
},
|
2019-05-12 21:21:18 +00:00
|
|
|
Character {
|
|
|
|
name: String,
|
2019-05-15 16:06:58 +00:00
|
|
|
body: comp::Body,
|
2019-05-12 21:21:18 +00:00
|
|
|
},
|
2019-06-09 14:20:20 +00:00
|
|
|
Controller(comp::Controller),
|
2019-04-19 19:32:47 +00:00
|
|
|
RequestState(ClientState),
|
2019-05-19 00:45:02 +00:00
|
|
|
SetViewDistance(u32),
|
2019-07-02 18:19:16 +00:00
|
|
|
BreakBlock(Vec3<i32>),
|
|
|
|
PlaceBlock(Vec3<i32>, Block),
|
2019-03-05 18:39:18 +00:00
|
|
|
Ping,
|
|
|
|
Pong,
|
2019-07-17 22:10:42 +00:00
|
|
|
ChatMsg {
|
|
|
|
chat_type: ChatType,
|
2019-07-21 18:34:52 +00:00
|
|
|
message: String,
|
2019-07-17 22:10:42 +00:00
|
|
|
},
|
2019-03-05 18:39:18 +00:00
|
|
|
PlayerPhysics {
|
2019-06-14 15:27:05 +00:00
|
|
|
pos: comp::Pos,
|
|
|
|
vel: comp::Vel,
|
|
|
|
ori: comp::Ori,
|
2019-03-05 18:39:18 +00:00
|
|
|
},
|
2019-07-25 22:52:28 +00:00
|
|
|
SwapInventorySlots(usize, usize),
|
2019-07-26 17:08:40 +00:00
|
|
|
DropInventorySlot(usize),
|
2019-04-10 23:41:37 +00:00
|
|
|
TerrainChunkRequest {
|
2019-05-17 17:44:30 +00:00
|
|
|
key: Vec2<i32>,
|
2019-04-10 23:41:37 +00:00
|
|
|
},
|
2019-03-03 22:02:38 +00:00
|
|
|
Disconnect,
|
|
|
|
}
|
2019-07-17 22:10:42 +00:00
|
|
|
|
|
|
|
impl ClientMsg {
|
2019-07-21 18:34:52 +00:00
|
|
|
pub fn chat(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
2019-07-17 22:10:42 +00:00
|
|
|
chat_type: ChatType::Chat,
|
2019-07-21 18:34:52 +00:00
|
|
|
message,
|
2019-07-17 22:10:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-21 18:34:52 +00:00
|
|
|
pub fn tell(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
2019-07-17 22:10:42 +00:00
|
|
|
chat_type: ChatType::Tell,
|
2019-07-21 18:34:52 +00:00
|
|
|
message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub fn game(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
|
|
|
chat_type: ChatType::GameUpdate,
|
|
|
|
message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub fn broadcast(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
|
|
|
chat_type: ChatType::Broadcast,
|
|
|
|
message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub fn private(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
|
|
|
chat_type: ChatType::Private,
|
|
|
|
message,
|
2019-07-17 22:10:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-29 14:40:46 +00:00
|
|
|
pub fn kill(message: String) -> ClientMsg {
|
|
|
|
ClientMsg::ChatMsg {
|
|
|
|
chat_type: ChatType::Private,
|
|
|
|
message,
|
|
|
|
}
|
|
|
|
}
|
2019-07-17 22:10:42 +00:00
|
|
|
}
|