summaryrefslogtreecommitdiff
path: root/src/components/ear.rs
blob: 4bfc87bccff87ba2a3302659ac056d6c253d92b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

use specs::{
	HashMapStorage,
	Component,
};


#[derive(Debug, Clone)]
pub struct Sound {
	pub source: Option<String>,
	pub text: String
}

impl Sound {
	pub fn as_message(self) -> (Option<String>, String) {
		(None, format!("{}: {}", self.source.unwrap_or("".to_string()), self.text))
	}
}

#[derive(Component, Debug, Clone, Default)]
#[storage(HashMapStorage)]
pub struct Ear{
	pub sounds: Vec<Sound>
}