veloren/common/src/time.rs
Monty Marz 2b800a2b63 make clippy happy
Delete glider.ron
2020-10-07 02:23:20 +00:00

31 lines
737 B
Rust

#[derive(Copy, Clone, PartialEq, Eq)]
pub enum DayPeriod {
Night,
Morning,
Noon,
Evening,
}
impl From<f64> for DayPeriod {
fn from(time_of_day: f64) -> Self {
let tod = time_of_day.rem_euclid(60.0 * 60.0 * 24.0);
if tod < 60.0 * 60.0 * 4.0 {
DayPeriod::Night
} else if tod < 60.0 * 60.0 * 10.0 {
DayPeriod::Morning
} else if tod < 60.0 * 60.0 * 16.0 {
DayPeriod::Noon
} else if tod < 60.0 * 60.0 * 20.0 {
DayPeriod::Evening
} else {
DayPeriod::Night
}
}
}
impl DayPeriod {
pub fn is_dark(&self) -> bool { *self == DayPeriod::Night }
pub fn is_light(&self) -> bool { !self.is_dark() }
}