(
pos: Vec2,
texture: Texture2D,
health: i32,
death_method: EnemyDeathMethod,
enemy_type: EnemyType,
enemy_color: EnemyColor,
)
| 90 | |
| 91 | impl Enemy { |
| 92 | pub fn new( |
| 93 | pos: Vec2, |
| 94 | texture: Texture2D, |
| 95 | health: i32, |
| 96 | death_method: EnemyDeathMethod, |
| 97 | enemy_type: EnemyType, |
| 98 | enemy_color: EnemyColor, |
| 99 | ) -> Self { |
| 100 | let charge_timer_optional = match enemy_type { |
| 101 | EnemyType::Normal => None, |
| 102 | EnemyType::Mini => Some(rand::gen_range( |
| 103 | ENEMY_MINI_HOMING_TIME_RANGE.x, |
| 104 | ENEMY_MINI_HOMING_TIME_RANGE.y, |
| 105 | )), |
| 106 | }; |
| 107 | Enemy { |
| 108 | state_shared: EnemyStateShared { |
| 109 | pos, |
| 110 | texture, |
| 111 | collision_rect: Rect::new(0f32, 0f32, texture.width(), texture.height()), |
| 112 | health, |
| 113 | angle: 0f32, |
| 114 | angle_speed: rand::gen_range(ENEMY_ANGLE_SPEED_RANGE.x, ENEMY_ANGLE_SPEED_RANGE.y), |
| 115 | death_method, |
| 116 | animation_timer: 0f32, |
| 117 | enemy_type, |
| 118 | charge_timer_optional, |
| 119 | enemy_color, |
| 120 | }, |
| 121 | state: EnemyState::Spawning(EnemyStateSpawning { spawn_timer: 0f32 }), |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | pub fn update( |
| 126 | &mut self, |
nothing calls this directly
no outgoing calls
no test coverage detected