diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-04 22:11:51 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-04 22:11:51 +0200 |
commit | c646336dc3bf470d4185eec995d00a89c420127b (patch) | |
tree | e1ad02976adc2489b547242a513757014e2b4862 /server/src/entity/book.rs | |
parent | 4df50b07df35f8c75980ce19d954f3f366dae848 (diff) | |
download | hurrycurry-c646336dc3bf470d4185eec995d00a89c420127b.tar hurrycurry-c646336dc3bf470d4185eec995d00a89c420127b.tar.bz2 hurrycurry-c646336dc3bf470d4185eec995d00a89c420127b.tar.zst |
book as entity and /book command
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) + } +} |