diff options
Diffstat (limited to 'server/src/protocol.rs')
| -rw-r--r-- | server/src/protocol.rs | 71 | 
1 files changed, 55 insertions, 16 deletions
| diff --git a/server/src/protocol.rs b/server/src/protocol.rs index dc2af7d6..a8fd9979 100644 --- a/server/src/protocol.rs +++ b/server/src/protocol.rs @@ -1,13 +1,22 @@ -use glam::{UVec2, Vec2}; +use glam::{IVec2, Vec2};  use serde::{Deserialize, Serialize};  pub type ID = u32; -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum Item {} +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum Item { +    Dough, +    Pancake, +} -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum Tile {} +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum Tile { +    Floor, +    Table, +    Pan, +}  #[derive(Debug, Clone, Serialize, Deserialize)]  #[serde(rename_all = "snake_case")] @@ -15,20 +24,50 @@ pub enum PacketS {      Join { name: String },      Leave,      Position { pos: Vec2, rot: f32 }, -    Interact { pos: UVec2 }, +    Interact { pos: IVec2 },  }  #[derive(Debug, Clone, Serialize, Deserialize)]  #[serde(rename_all = "snake_case")]  pub enum PacketC { -    Joined { id: ID }, -    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 }, +    Joined { +        id: ID, +    }, +    AddPlayer { +        id: ID, +        name: String, +        hand: Option<(ID, Item)>, +    }, +    RemovePlayer { +        id: ID, +    }, +    Position { +        player: ID, +        pos: Vec2, +        rot: f32, +    }, +    TakeItem { +        item: ID, +        player: ID, +    }, +    PutItem { +        item: ID, +        pos: IVec2, +    }, +    ProduceItem { +        id: ID, +        pos: IVec2, +        kind: Item, +    }, +    ConsumeItem { +        id: ID, +        pos: IVec2, +    }, +    SetActive { +        tile: IVec2, +    }, +    UpdateMap { +        pos: IVec2, +        tile: Tile, +    },  } | 
