MCPcopy Create free account
hub / github.com/TanTanDev/rusty_demon_attack / update

Method update

src/enemy.rs:125–166  ·  view source on GitHub ↗
(
        &mut self,
        dt: f32,
        bullets: &mut Vec<Bullet>,
        resources: &Resources,
        player_pos: &Vec2,
        game_manager: &mut WaveManager,
        sound_mixer: &mut Sou

Source from the content-addressed store, hash-verified

123 }
124
125 pub fn update(
126 &mut self,
127 dt: f32,
128 bullets: &mut Vec<Bullet>,
129 resources: &Resources,
130 player_pos: &Vec2,
131 game_manager: &mut WaveManager,
132 sound_mixer: &mut SoundMixer,
133 ) {
134 let command_optional = match &mut self.state {
135 EnemyState::Spawning(state_data) => {
136 Self::update_state_spawning(&mut self.state_shared, dt, state_data)
137 }
138 EnemyState::Normal(state_data) => {
139 Self::update_state_normal(&mut self.state_shared, dt, state_data)
140 }
141 EnemyState::Shooting(state_data) => Self::update_state_shooting(
142 &mut self.state_shared,
143 dt,
144 bullets,
145 resources,
146 state_data,
147 sound_mixer,
148 ),
149 EnemyState::Homing(_state_data) => Self::update_state_homing(
150 &mut self.state_shared,
151 dt,
152 player_pos,
153 game_manager,
154 sound_mixer,
155 resources,
156 ),
157 };
158 match command_optional {
159 None => {}
160 Some(command) => match command {
161 EnemyCommand::ChangeState(new_state) => {
162 self.state = new_state;
163 }
164 },
165 };
166 }
167
168 pub fn overlaps(&self, other_rect: &Rect) -> bool {
169 self.state_shared.collision_rect.overlaps(other_rect)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected