summaryrefslogtreecommitdiff
path: root/server/src/protocol.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-17 02:25:55 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-17 02:25:55 +0200
commitb8f7115ef39ff8e855f3452e087241f974745438 (patch)
treef910caf244338c0e23bd6cdb31254bda8feb9ce9 /server/src/protocol.rs
parentb65849bce3fe8ff8d6baebf29728868d4f164827 (diff)
downloadhurrycurry-b8f7115ef39ff8e855f3452e087241f974745438.tar
hurrycurry-b8f7115ef39ff8e855f3452e087241f974745438.tar.bz2
hurrycurry-b8f7115ef39ff8e855f3452e087241f974745438.tar.zst
prime clients and tile rendering
Diffstat (limited to 'server/src/protocol.rs')
-rw-r--r--server/src/protocol.rs71
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,
+ },
}