aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/book.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-04 22:11:51 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-04 22:11:51 +0200
commitc646336dc3bf470d4185eec995d00a89c420127b (patch)
treee1ad02976adc2489b547242a513757014e2b4862 /server/src/entity/book.rs
parent4df50b07df35f8c75980ce19d954f3f366dae848 (diff)
downloadhurrycurry-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.rs21
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)
+ }
+}