diff options
| author | troido <troido@protonmail.com> | 2020-03-01 22:28:02 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-01 22:28:02 +0100 |
| commit | 6a7a74e6878ff04e61e6ef21a922e314b9bab271 (patch) | |
| tree | b26015955f50856052153019969f7bee8d1cfbd3 /src/components/mod.rs | |
| parent | c846e929a88837094d7a5383a306df1fec56c333 (diff) | |
use generics for message components
Diffstat (limited to 'src/components/mod.rs')
| -rw-r--r-- | src/components/mod.rs | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs index 6fae490..3925d85 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,7 +1,12 @@ pub mod item; +pub mod messages; pub use item::Item; +pub use messages::{ + AttackMessage, + AttackInbox +}; use specs::{ DenseVecStorage, @@ -9,9 +14,7 @@ use specs::{ HashMapStorage, FlaggedStorage, NullStorage, - Component, - Entity, - WriteStorage + Component }; use crate::{ @@ -22,7 +25,6 @@ use crate::{ controls::Control, Template, playerstate::RoomPos, - attack::Attack, Timestamp }; @@ -126,22 +128,6 @@ pub struct RoomExit { pub dest_pos: RoomPos } -#[derive(Component, Debug, Clone, Default)] -pub struct Attacked { - pub attacks: Vec<Attack> -} - -impl Attacked { - pub fn add_attack(attacked: &mut WriteStorage<Attacked> , ent: Entity, attack: Attack) { - attacked - .entry(ent) - .unwrap() - .or_insert_with(Attacked::default) - .attacks - .push(attack); - } -} - #[derive(Default, Component, Debug, Clone)] #[storage(NullStorage)] pub struct Entered; @@ -153,13 +139,13 @@ pub struct Dying; #[derive(Component, Debug, Clone)] #[storage(HashMapStorage)] pub struct Trap { - pub attack: Attack + pub attack: AttackMessage } #[derive(Component, Debug, Clone)] #[storage(HashMapStorage)] pub struct Fighter { - pub attack: Attack, + pub attack: AttackMessage, pub cooldown: i64 } |
