From 8ee3eca5d6de0b950881783821d1be86cd0586d5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 2 Jul 2024 00:52:42 +0200 Subject: generalize protocol --- server/src/protocol.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'server/src/protocol.rs') diff --git a/server/src/protocol.rs b/server/src/protocol.rs index 176eb31b..54992feb 100644 --- a/server/src/protocol.rs +++ b/server/src/protocol.rs @@ -99,24 +99,16 @@ pub enum PacketC { pos: Vec2, rot: f32, }, - TakeItem { - tile: IVec2, - player: PlayerID, - }, - PutItem { - player: PlayerID, - tile: IVec2, - }, - SetTileItem { - tile: IVec2, - item: Option, + MoveItem { + from: ItemLocation, + to: ItemLocation, }, - SetPlayerItem { - player: PlayerID, + SetItem { + location: ItemLocation, item: Option, }, - SetActive { - tile: IVec2, + SetProgress { + item: ItemLocation, progress: Option, warn: bool, }, @@ -150,3 +142,10 @@ pub enum PacketC { message: String, }, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ItemLocation { + Tile(IVec2), + Player(PlayerID), +} -- cgit v1.2.3-70-g09d2