diff options
| author | troido <troido@protonmail.com> | 2020-02-24 14:39:04 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-24 14:39:04 +0100 |
| commit | 481e03e04b055cebaf230b3a3cdce3446418c68c (patch) | |
| tree | 565a2d8afc2fba8d73e310cd1a32b6a94b84039f /src/systems/volate.rs | |
| parent | f6a037faa2b675cd7318d6dd8ccee5133c89845d (diff) | |
added volatile wounds
Diffstat (limited to 'src/systems/volate.rs')
| -rw-r--r-- | src/systems/volate.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/systems/volate.rs b/src/systems/volate.rs new file mode 100644 index 0000000..8cfa826 --- /dev/null +++ b/src/systems/volate.rs @@ -0,0 +1,34 @@ + +use specs::{ + Read, + WriteStorage, + Entities, + System, + Join +}; + +use crate::{ + components::{Volatile, Removed}, + resources::TimeStamp +}; + +pub struct Volate; +impl <'a> System<'a> for Volate { + type SystemData = ( + Entities<'a>, + WriteStorage<'a, Volatile>, + WriteStorage<'a, Removed>, + Read<'a, TimeStamp> + ); + fn run(&mut self, (entities, mut volatiles, mut removals, timestamp): Self::SystemData) { + for (ent, volatile) in (&entities, &mut volatiles).join() { + if let Some(time) = volatile.end_time { + if time <= timestamp.time { + removals.insert(ent, Removed).unwrap(); + } + } else { + volatile.end_time = Some(timestamp.time + volatile.delay); + } + } + } +} |
