veloren/common/src/msg/client.rs

81 lines
1.8 KiB
Rust
Raw Normal View History

use super::ClientState;
use crate::terrain::block::Block;
2019-07-17 22:10:42 +00:00
use crate::{comp, ChatType};
use vek::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ClientMsg {
Register {
player: comp::Player,
2019-08-08 03:56:02 +00:00
password: String,
},
Character {
name: String,
body: comp::Body,
main: Option<comp::item::Tool>,
},
2019-06-09 14:20:20 +00:00
Controller(comp::Controller),
RequestState(ClientState),
SetViewDistance(u32),
BreakBlock(Vec3<i32>),
PlaceBlock(Vec3<i32>, Block),
Ping,
Pong,
2019-07-17 22:10:42 +00:00
ChatMsg {
chat_type: ChatType,
message: String,
2019-07-17 22:10:42 +00:00
},
PlayerPhysics {
pos: comp::Pos,
vel: comp::Vel,
ori: comp::Ori,
},
ActivateInventorySlot(usize),
2019-07-25 22:52:28 +00:00
SwapInventorySlots(usize, usize),
2019-07-26 17:08:40 +00:00
DropInventorySlot(usize),
PickUp(u64),
TerrainChunkRequest {
key: Vec2<i32>,
},
Disconnect,
}
2019-07-17 22:10:42 +00:00
impl ClientMsg {
pub fn chat(message: String) -> ClientMsg {
ClientMsg::ChatMsg {
2019-07-17 22:10:42 +00:00
chat_type: ChatType::Chat,
message,
2019-07-17 22:10:42 +00:00
}
}
pub fn tell(message: String) -> ClientMsg {
ClientMsg::ChatMsg {
2019-07-17 22:10:42 +00:00
chat_type: ChatType::Tell,
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
}