summaryrefslogtreecommitdiff
path: root/src/systems/growth.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-04-13 13:13:04 +0200
committertroido <troido@protonmail.com>2020-04-13 13:13:04 +0200
commitdb7b138cb66a2b48492e457fdf0ae8cd65cc73db (patch)
tree048e7931d0c7055ebdc7ce5b8f5083cc62154336 /src/systems/growth.rs
parent56f44d5898696d1af50f38009629384f8d38cb46 (diff)
volate replaced by grow
Diffstat (limited to 'src/systems/growth.rs')
-rw-r--r--src/systems/growth.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/systems/growth.rs b/src/systems/growth.rs
index 3baa3e8..7daa3d7 100644
--- a/src/systems/growth.rs
+++ b/src/systems/growth.rs
@@ -33,8 +33,12 @@ impl <'a> System<'a> for Growth{
for (entity, grow) in (&entities, &mut grows).join(){
if grow.target_time == None {
let creation_time = time.time + time_offsets.get(entity).map(|ct| ct.dtime).unwrap_or(0);
- let duration = grow.delay as f64 * (1.0 + rand::random::<f64>()) / (if rand::random() {1.0} else {2.0});
- grow.target_time = Some(creation_time + duration as i64);
+ let mut r = 1.0 - rand::random::<f64>() * grow.spread;
+ if rand::random() {
+ r = 1.0 / r;
+ }
+ let duration = (grow.delay as f64 * r + 0.4) as i64;
+ grow.target_time = Some(creation_time + duration);
}
let target_time = grow.target_time.unwrap();
if target_time <= time.time {