diff options
| author | troido <troido@protonmail.com> | 2020-04-04 14:01:17 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-04 14:01:17 +0200 |
| commit | 2cc5b468cfd4c28bf1ad17ef1b3600c3d42f8b83 (patch) | |
| tree | 835e67143e56fafef795e320ce8fc5d50cb9cc6c /src/components/ear.rs | |
| parent | 0b17829846adf9482b460e4cc616382ede1df6dd (diff) | |
listen to sounds in the world
Diffstat (limited to 'src/components/ear.rs')
| -rw-r--r-- | src/components/ear.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/ear.rs b/src/components/ear.rs new file mode 100644 index 0000000..d032122 --- /dev/null +++ b/src/components/ear.rs @@ -0,0 +1,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) { + return (None, format!("{}: {}", self.source.unwrap_or("".to_string()), self.text)); + } +} + +#[derive(Component, Debug, Clone, Default)] +#[storage(HashMapStorage)] +pub struct Ear{ + pub sounds: Vec<Sound> +} |
