summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-17 14:58:35 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-17 16:57:34 +0200
commitbf1a5cef4b7fa87cdd382c565044731c1ccef9e3 (patch)
tree412c704845fd0e9cf643572608de6e8170d9cbc8
parentf1ffe3f2e0e22dac40c88c8f13f1ffa8b2955743 (diff)
downloadhurrycurry-bf1a5cef4b7fa87cdd382c565044731c1ccef9e3.tar
hurrycurry-bf1a5cef4b7fa87cdd382c565044731c1ccef9e3.tar.bz2
hurrycurry-bf1a5cef4b7fa87cdd382c565044731c1ccef9e3.tar.zst
add hint packet for tutorial
-rw-r--r--server/protocol/src/lib.rs5
-rw-r--r--server/src/entity/mod.rs1
-rw-r--r--server/src/entity/tutorial.rs22
-rw-r--r--test-client/protocol.ts3
4 files changed, 31 insertions, 0 deletions
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index 33873a33..54a7f868 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -209,6 +209,11 @@ pub enum PacketC {
ServerMessage {
text: String,
},
+ ServerHint {
+ #[bincode(with_serde)]
+ position: Option<IVec2>,
+ message: Option<Message>,
+ },
Score(Score),
SetIngame {
state: bool,
diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs
index 30a5da55..70c5c785 100644
--- a/server/src/entity/mod.rs
+++ b/server/src/entity/mod.rs
@@ -23,6 +23,7 @@ pub mod customers;
pub mod environment_effect;
pub mod item_portal;
pub mod player_portal;
+pub mod tutorial;
use crate::{data::ItemTileRegistry, scoreboard::ScoreboardStore};
use anyhow::{anyhow, Result};
diff --git a/server/src/entity/tutorial.rs b/server/src/entity/tutorial.rs
new file mode 100644
index 00000000..20b1d03e
--- /dev/null
+++ b/server/src/entity/tutorial.rs
@@ -0,0 +1,22 @@
+use super::{Entity, EntityContext};
+use anyhow::Result;
+use hurrycurry_protocol::{glam::IVec2, PlayerID};
+
+pub struct Tutorial {
+ player: PlayerID,
+}
+
+impl Entity for Tutorial {
+ fn tick(&mut self, _c: EntityContext<'_>) -> Result<()> {
+ Ok(())
+ }
+ fn destructor(&mut self, _c: EntityContext<'_>) {}
+ fn interact(
+ &mut self,
+ _c: EntityContext<'_>,
+ _pos: Option<IVec2>,
+ _player: PlayerID,
+ ) -> Result<bool> {
+ Ok(false)
+ }
+}
diff --git a/test-client/protocol.ts b/test-client/protocol.ts
index 9c322a09..f88d1dec 100644
--- a/test-client/protocol.ts
+++ b/test-client/protocol.ts
@@ -1,3 +1,5 @@
+import { V2 } from "./util.ts";
+
/*
Hurry Curry! - a game about cooking
Copyright 2024 metamuffin
@@ -58,6 +60,7 @@ export type PacketC =
| { type: "update_map", tile: Vec2, kind: TileIndex | null, neighbors: [TileIndex | null] } // A map tile was changed
| { type: "communicate", player: PlayerID, message?: Message, timeout?: MessageTimeout } // A player wants to communicate something, message is null when cleared
| { type: "server_message", text: string } // Text message from the server
+ | { type: "server_hint", message?: Message, position?: V2 } // Hint message from server with optional position. Message is unset to clear previous message
| { type: "score" } & Score // Supplies information for score OSD
| { type: "menu" } & Menu // Open a menu on the client-side
| { type: "environment", effects: string[] }