mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
7401d74aa6
+ add asset tests + migrate tundra animals + migrate taiga animals + declare temperate zone (animals yet to be created) + declare jungle zone (animals yet to be created) + declare tropical zone (animals yet to be created) + declare desert zone (animals yet to be created) + declare water (river inhabitants) zones (animals yet to be created)
33 lines
788 B
Rust
33 lines
788 B
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Hash)]
|
|
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 * 6.0 {
|
|
DayPeriod::Night
|
|
} else if tod < 60.0 * 60.0 * 11.0 {
|
|
DayPeriod::Morning
|
|
} else if tod < 60.0 * 60.0 * 16.0 {
|
|
DayPeriod::Noon
|
|
} else if tod < 60.0 * 60.0 * 19.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() }
|
|
}
|