aboutsummaryrefslogtreecommitdiff
path: root/examples/breakout/protocol.rs
blob: 766094a9f9127cc83c897261c57d127440909e45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use bevy::prelude::{Entity, Vec2, Vec3};
use bevy_quinnet::ClientId;
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub(crate) enum PaddleInput {
    #[default]
    None,
    Left,
    Right,
}

// Messages from clients
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) enum ClientMessage {
    PaddleInput { input: PaddleInput },
}

// Messages from the server
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) enum ServerMessage {
    InitClient {
        client_id: ClientId,
    },
    SpawnPaddle {
        client_id: ClientId,
        entity: Entity,
        position: Vec3,
    },
    SpawnBall {
        entity: Entity,
        position: Vec3,
        direction: Vec2,
    },
    StartGame {},
    BrickDestroyed {
        client_id: ClientId,
    },
    BallPosition {
        entity: Entity,
        position: Vec3,
    },
    PaddlePosition {
        entity: Entity,
        position: Vec3,
    },
}