save
Some checks failed
Rust Checks / checks (push) Failing after 11m28s

This commit is contained in:
CoCo_Sol 2024-03-16 22:07:52 +01:00
parent 1067e457e3
commit c1de8c625f

View file

@ -7,10 +7,6 @@ use bevy::prelude::*;
use serde::{Deserialize, Serialize};
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.
pub struct ConnectionPlugin;
@ -18,20 +14,30 @@ impl Plugin for ConnectionPlugin {
fn build(&self, app: &mut App) {
app.add_network_event::<RequestConnection>()
.add_network_event::<UpdatePlayers>()
.add_network_event::<KickPlayer>()
.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.
#[derive(Event, Deserialize, Serialize)]
pub struct RequestConnection {
/// The name of the player.
pub name: String,
}
#[derive(Event, Deserialize, Serialize)]
/// The message sent by the server to all clients when a new player joins.
pub struct UpdatePlayers {
/// All players in the game.
pub players: AllPlayers,
/// The message sent in order to update the list of players.
pub struct AddPlayer {
pub uuid: Uuid,
pub name: String,
}
/// The packet sent when a player is removed.
#[derive(Event, Deserialize, Serialize)]
pub struct RemovePlayer {
pub uuid: String,
}