use crate::{Entity, EntityMoveSpeed, Pos}; pub const ZOMBIE_HEALTH: u32 = 50; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EnemyAttackType { Melee, Ranged, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EnemyType { Zombie, } #[derive(Debug, Clone, Copy, PartialEq)] pub struct Enemy { pub entity: Entity, pub enemy_type: EnemyType, pub attack_type: EnemyAttackType, time_acc: f32, } impl Enemy { pub fn new(enemy_type: EnemyType, pos: Pos) -> Self { match enemy_type { EnemyType::Zombie => Self::zombie(pos), } } fn _new( pos: Pos, health: u32, move_speed: EntityMoveSpeed, enemy_type: EnemyType, attack_type: EnemyAttackType, ) -> Self { let entity = Entity::enemy(pos, move_speed, health); Self { entity, enemy_type, attack_type, time_acc: 0., } } fn zombie(pos: Pos) -> Self { Self::_new( pos, ZOMBIE_HEALTH, EntityMoveSpeed::Slow, EnemyType::Zombie, EnemyAttackType::Melee, ) } }