diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-16 11:00:02 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-16 11:00:02 -0700 |
| commit | 40e9d818195824749293dff3afcfdd5c1432adbe (patch) | |
| tree | 94cf7696dbc3479082bde99135897b60d9a4c257 /src/main.rs | |
| parent | 643dd9bd632cab366f12dd8dfe3ee2499ae665a2 (diff) | |
lint
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/main.rs b/src/main.rs index 7cac1f3..bb4cb27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,11 +81,10 @@ struct App { impl App { // called as often as possible // delta time is the real seconds elapsed since the last time this was called - fn update(&mut self, delta_time: f32) -> () { + fn update(&mut self, delta_time: f32) { // apply inputs - match &mut self.camera { - Some(camera) => camera.handle_camera_input(&self.input, delta_time), - _ => {} + if let Some(camera) = &mut self.camera { + camera.handle_camera_input(&self.input, delta_time) } // // --TEST DRAWING-- @@ -110,11 +109,10 @@ impl App { let mut cell = Cell::from_material(self.config.brush_material); // ensure we simulate on the first tick cell.flags = (self.sim_seqno as u8) & 0b1; - match &mut self.world { - Some(world) => world.set_cell_from_game_position( + if let Some(world) = &mut self.world { + world.set_cell_from_game_position( x, y, cell, false, // wake the chunk - ), - _ => {} + ) } } } @@ -125,20 +123,17 @@ impl App { // will be called before the render and before the physics update(s) // may be called multiple times if the sim time is behind // sim_delta_time is statically 1/SIM_FPS - fn sim_update(&mut self, sim_delta_time: f32) -> () { - match &mut self.world { - Some(world) => { - sim_tick(world, self.sim_seqno, self.config.use_threading); - self.sim_seqno += 1; - } - _ => {} + fn sim_update(&mut self, _sim_delta_time: f32) { + if let Some(world) = &mut self.world { + sim_tick(world, self.sim_seqno, self.config.use_threading); + self.sim_seqno += 1; } } // called PHYSICS_FPS times per second // will be called before the render // may be called multiple times if the physics time is behind // physics_delta_time is statically 1/PHYSICS_FPS - fn physics_update(&mut self, physics_delta_time: f32) -> () {} + fn physics_update(&mut self, _physics_delta_time: f32) {} } impl Default for App { @@ -216,7 +211,7 @@ impl ApplicationHandler for App { if let Some(renderer_state) = &mut self.renderer_state && let Some(window) = &mut self.window { - let egui_response = renderer_state.egui_state.on_window_event(&window, &event); + let egui_response = renderer_state.egui_state.on_window_event(window, &event); // if egui consumed the event, it means we shouldn't treat any e.g., mouse clicks if egui_response.consumed { return; @@ -245,21 +240,15 @@ impl ApplicationHandler for App { self.sim_paused = !self.sim_paused } } - KeyCode::KeyX => { - if pressed { - self.ignore_pause_next_tick = true - } - } + KeyCode::KeyX if pressed => self.ignore_pause_next_tick = true, _ => {} } } WindowEvent::CursorMoved { position, .. } => { self.input.last_mouse_pos_on_screen = Some((position.x as f32, position.y as f32)); - self.input.last_mouse_world_pos = if let Some(camera) = &mut self.camera { - Some(camera.screen_position_to_world(position.x as f32, position.y as f32)) - } else { - None - } + self.input.last_mouse_world_pos = self.camera.as_mut().map(|camera| { + camera.screen_position_to_world(position.x as f32, position.y as f32) + }) } WindowEvent::MouseInput { state, button, .. } => { if button == MouseButton::Left { @@ -351,7 +340,7 @@ impl ApplicationHandler for App { camera, &mut self.config, &self.diagnostics, - &mut self.input, + &self.input, ); } } |
