aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.rs
blob: d463a5d3a8081a849fa04423af649ea017aaa4b1 (plain)
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
use glam::{UVec2, Vec2};
use serde::{Deserialize, Serialize};

pub type ID = u32;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Item {}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Tile {}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PacketS {
    Join { name: String },
    Leave,
    Position { pos: Vec2, rot: f32 },
    Interact { pos: UVec2 },
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PacketC {
    AddPlayer { id: ID, name: String },
    RemovePlayer { id: ID },
    Position { player: ID, pos: Vec2, rot: f32 },
    TakeItem { item: ID, player: ID },
    PutItem { item: ID, pos: UVec2 },
    ProduceItem { id: ID, pos: UVec2, kind: Item },
    ConsumeItem { id: ID, pos: UVec2 },
    SetActive { tile: UVec2 },
    UpdateMap { pos: UVec2, tile: Tile },
}