diff options
Diffstat (limited to 'server/src/entity/book.rs')
| -rw-r--r-- | server/src/entity/book.rs | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/server/src/entity/book.rs b/server/src/entity/book.rs new file mode 100644 index 00000000..3787ffaa --- /dev/null +++ b/server/src/entity/book.rs @@ -0,0 +1,21 @@ +use super::{Entity, EntityContext}; +use anyhow::Result; +use hurrycurry_protocol::{glam::IVec2, Menu, PacketC, PlayerID}; + +#[derive(Debug, Clone)] +pub struct Book(pub IVec2); + +impl Entity for Book { +    fn interact( +        &mut self, +        c: EntityContext<'_>, +        pos: Option<IVec2>, +        _player: PlayerID, +    ) -> Result<bool> { +        if pos == Some(self.0) { +            c.packet_out.push_back(PacketC::Menu(Menu::Book)); +            return Ok(true); +        } +        Ok(false) +    } +} | 
