use crate::entity::{EntityCategory, EntityKind};
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum Biome {
#[default]
Void,
RainForest,
Swampland,
SeasonalForest,
Forest,
Savanna,
ShrubLand,
Taiga,
Desert,
Plains,
IceDesert,
Tundra,
Nether,
Sky,
}
impl Biome {
#[inline]
pub fn has_rain(self) -> bool {
match self {
Biome::Desert |
Biome::IceDesert |
Biome::Nether |
Biome::Sky => false,
_ => true
}
}
#[inline]
pub fn has_snow(self) -> bool {
match self {
Biome::Taiga |
Biome::IceDesert |
Biome::Tundra => true,
_ => false
}
}
pub fn natural_entity_kinds(self, category: EntityCategory) -> &'static [NaturalEntityKind] {
const ANIMALS: &'static [NaturalEntityKind] = &[
NaturalEntityKind::new(EntityKind::Sheep, 12),
NaturalEntityKind::new(EntityKind::Pig, 10),
NaturalEntityKind::new(EntityKind::Chicken, 10),
NaturalEntityKind::new(EntityKind::Cow, 8),
NaturalEntityKind::new(EntityKind::Wolf, 2),
];
const WATER_ANIMALS: &'static [NaturalEntityKind] = &[
NaturalEntityKind::new(EntityKind::Squid, 10),
];
const MOBS: &'static [NaturalEntityKind] = &[
NaturalEntityKind::new(EntityKind::Spider, 10),
NaturalEntityKind::new(EntityKind::Zombie, 10),
NaturalEntityKind::new(EntityKind::Skeleton, 10),
NaturalEntityKind::new(EntityKind::Creeper, 10),
NaturalEntityKind::new(EntityKind::Slime, 10),
];
const NETHER_MOBS: &'static [NaturalEntityKind] = &[
NaturalEntityKind::new(EntityKind::Ghast, 10),
NaturalEntityKind::new(EntityKind::PigZombie, 10),
];
const SKY_ANIMALS: &'static [NaturalEntityKind] = &[
NaturalEntityKind::new(EntityKind::Chicken, 10),
];
match self {
Biome::Void => &[],
Biome::RainForest |
Biome::Swampland |
Biome::SeasonalForest |
Biome::Savanna |
Biome::ShrubLand |
Biome::Desert |
Biome::Plains |
Biome::IceDesert |
Biome::Tundra => {
match category {
EntityCategory::Animal => &ANIMALS[..ANIMALS.len() - 1], EntityCategory::WaterAnimal => WATER_ANIMALS,
EntityCategory::Mob => MOBS,
EntityCategory::Other => &[]
}
}
Biome::Forest |
Biome::Taiga => {
match category {
EntityCategory::Animal => ANIMALS, EntityCategory::WaterAnimal => WATER_ANIMALS,
EntityCategory::Mob => MOBS,
EntityCategory::Other => &[]
}
}
Biome::Nether => {
match category {
EntityCategory::Mob => NETHER_MOBS,
_ => &[]
}
}
Biome::Sky => {
match category {
EntityCategory::Animal => SKY_ANIMALS,
_ => &[]
}
}
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct NaturalEntityKind {
pub kind: EntityKind,
pub chance: u16,
}
impl NaturalEntityKind {
#[inline]
pub const fn new(kind: EntityKind, chance: u16) -> Self {
Self { kind, chance }
}
}