generated from tipragot/rust
This commit is contained in:
parent
1067e457e3
commit
c1de8c625f
|
@ -7,10 +7,6 @@ use bevy::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
/// TODO
|
|
||||||
#[derive(Resource, Default, Deserialize, Serialize, Clone)]
|
|
||||||
pub struct AllPlayers(pub HashMap<String, Uuid>);
|
|
||||||
|
|
||||||
/// The plugin that manages the connection to the host.
|
/// The plugin that manages the connection to the host.
|
||||||
pub struct ConnectionPlugin;
|
pub struct ConnectionPlugin;
|
||||||
|
|
||||||
|
@ -18,20 +14,30 @@ impl Plugin for ConnectionPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_network_event::<RequestConnection>()
|
app.add_network_event::<RequestConnection>()
|
||||||
.add_network_event::<UpdatePlayers>()
|
.add_network_event::<UpdatePlayers>()
|
||||||
|
.add_network_event::<KickPlayer>()
|
||||||
.init_resource::<AllPlayers>();
|
.init_resource::<AllPlayers>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event, Deserialize, Serialize)]
|
/// All the players in the game.
|
||||||
|
#[derive(Resource, Default)]
|
||||||
|
pub struct AllPlayers(HashMap<Uuid, String>);
|
||||||
|
|
||||||
/// The message sent by the client to the server to request a connection.
|
/// The message sent by the client to the server to request a connection.
|
||||||
|
#[derive(Event, Deserialize, Serialize)]
|
||||||
pub struct RequestConnection {
|
pub struct RequestConnection {
|
||||||
/// The name of the player.
|
/// The name of the player.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event, Deserialize, Serialize)]
|
/// The message sent in order to update the list of players.
|
||||||
/// The message sent by the server to all clients when a new player joins.
|
pub struct AddPlayer {
|
||||||
pub struct UpdatePlayers {
|
pub uuid: Uuid,
|
||||||
/// All players in the game.
|
pub name: String,
|
||||||
pub players: AllPlayers,
|
}
|
||||||
|
|
||||||
|
/// The packet sent when a player is removed.
|
||||||
|
#[derive(Event, Deserialize, Serialize)]
|
||||||
|
pub struct RemovePlayer {
|
||||||
|
pub uuid: String,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue