forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.rs
More file actions
26 lines (24 loc) · 664 Bytes
/
chat.rs
File metadata and controls
26 lines (24 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use feather_core::text::{Color, TextRoot, Translate};
use feather_server_types::{ChatEvent, ChatPosition, Game, Name, PlayerJoinEvent};
use fecs::World;
#[fecs::event_handler]
pub fn on_player_join_broadcast_join_message(
event: &PlayerJoinEvent,
game: &mut Game,
world: &mut World,
) {
let message: String = {
let name = world.get::<Name>(event.player);
TextRoot::from(
Translate::MultiplayerPlayerJoined * vec![name.0.to_string()] * Color::Yellow,
)
.into()
};
game.handle(
world,
ChatEvent {
message,
position: ChatPosition::Chat,
},
);
}