pub fn run(mut self) -> Result<(), Box<dyn Error>> {
        let mut frames = 0;
        let mut next_fps_measure = Instant::now() + Duration::from_secs(1);
        let mut time_prev = Instant::now();
        info!("______ _             _            ");
        info!("| ___ \\ |           | |  ");
        info!("| |_/ / | __ _ _ __ | |_ _____  __");
        info!("|  __/| |/ _` | '_ \\| __/ _ \\ \\/ /");
        info!("| |   | | (_| | | | | ||  __/>  < ");
        info!("\\_|   |_|\\__,_|_| |_|\\__\\___/_/\\_\\");
        loop {
            self.world_manager
                .update_world(self.control_switcher.get_camera().position);

            let time_now = Instant::now();
            let duration_delta = time_now.duration_since(time_prev);
            // delta in seconds
            let delta = ((duration_delta.subsec_nanos() / 1_000) as f32) / 1_000_000.0
                + duration_delta.as_secs() as f32;
            time_prev = Instant::now();

            self.weather.update(
                &self.control_switcher.get_camera(),
                delta,
                &self.world_manager,
                &self.daytime,
            );
            self.world_manager
                .update_world(self.control_switcher.get_camera().position);

            self.daytime.update(delta);
            self.sky_view.update(self.daytime.get_sun_position());
            self.sun.update(self.daytime.get_sun_position());

            // Check for pillar outline highlight switch
            if self
                .world_manager
                .get_context()
                .get_config()
                .highlight_pillar
            {
                // Display Outline of Hexagon looking at
                let vec = get_pillarsectionpos_looking_at(
                    &self.world_manager.get_world(),
                    self.control_switcher.get_camera(),
                );
                match vec {
                    Some(n) => {
                        // self.remove_hexagon_at(n.1, n.0.z);
                        let mut view = self.world_manager.get_mut_view();
                        view.outline.display = true;
                        view.outline.pos = n.0;
                    }
                    None => {
                        let mut view = self.world_manager.get_mut_view();
                        view.outline.display = false;
                    }
                }
            }

            self.renderer.render(
                &*self.world_manager.get_view(),
                &self.control_switcher.get_camera(),
                &self.daytime,
                &self.sun,
                &mut self.weather,
                &self.sky_view,
            )?;

            let event_resp = self.event_manager.poll_events(vec![
                &mut CloseHandler,
                &mut self.control_switcher,
                &mut self.daytime,
            ]);
            if event_resp == EventResponse::Quit {
                break;
            }

            self.control_switcher.update(delta);

            frames += 1;
            if next_fps_measure < Instant::now() {
                info!("{} FPS", frames);
                next_fps_measure = Instant::now() + Duration::from_secs(1);
                frames = 0;
            }
        }

        Ok(())
    }
/// Main game function: contains the main render loop and owns all important
/// components. This function should remain rather small, all heavy lifting
/// should be done in other functions.
Main game function: contains the main render loop and owns all important
components. This function should remain rather small, all heavy lifting
should be done in other functions.
Main game function : contains the main render loop and owns all important components . This function should remain rather small all heavy lifting should be done in other functions .
pub fn run(mut self) -> Result<(), Box<dyn Error>> {
        let mut frames = 0;
        let mut next_fps_measure = Instant::now() + Duration::from_secs(1);
        let mut time_prev = Instant::now();
        info!("______ _             _            ");
        info!("| ___ \\ |           | |  ");
        info!("| |_/ / | __ _ _ __ | |_ _____  __");
        info!("|  __/| |/ _` | '_ \\| __/ _ \\ \\/ /");
        info!("| |   | | (_| | | | | ||  __/>  < ");
        info!("\\_|   |_|\\__,_|_| |_|\\__\\___/_/\\_\\");
        loop {
            self.world_manager
                .update_world(self.control_switcher.get_camera().position);
            let time_now = Instant::now();
            let duration_delta = time_now.duration_since(time_prev);
            // delta in seconds
            let delta = ((duration_delta.subsec_nanos() / 1_000) as f32) / 1_000_000.0
                + duration_delta.as_secs() as f32;
            time_prev = Instant::now();
            self.weather.update(
                &self.control_switcher.get_camera(),
                delta,
                &self.world_manager,
                &self.daytime,
            );
            self.world_manager
                .update_world(self.control_switcher.get_camera().position);
            self.daytime.update(delta);
            self.sky_view.update(self.daytime.get_sun_position());
            self.sun.update(self.daytime.get_sun_position());
            // Check for pillar outline highlight switch
            if self
                .world_manager
                .get_context()
                .get_config()
                .highlight_pillar
            {
                // Display Outline of Hexagon looking at
                let vec = get_pillarsectionpos_looking_at(
                    &self.world_manager.get_world(),
                    self.control_switcher.get_camera(),
                );
                match vec {
                    Some(n) => {
                        // self.remove_hexagon_at(n.1, n.0.z);
                        let mut view = self.world_manager.get_mut_view();
                        view.outline.display = true;
                        view.outline.pos = n.0;
                    }
                    None => {
                        let mut view = self.world_manager.get_mut_view();
                        view.outline.display = false;
                    }
                }
            }
            self.renderer.render(
                &*self.world_manager.get_view(),
                &self.control_switcher.get_camera(),
                &self.daytime,
                &self.sun,
                &mut self.weather,
                &self.sky_view,
            )?;
            let event_resp = self.event_manager.poll_events(vec![
                &mut CloseHandler,
                &mut self.control_switcher,
                &mut self.daytime,
            ]);
            if event_resp == EventResponse::Quit {
                break;
            }
            self.control_switcher.update(delta);
            frames += 1;
            if next_fps_measure < Instant::now() {
                info!("{} FPS", frames);
                next_fps_measure = Instant::now() + Duration::from_secs(1);
                frames = 0;
            }
        }
        Ok(())
    }
pub fn run ( mut self ) -> Result < ( ) , Box < dyn Error > > { let mut frames = 0 ; let mut next_fps_measure = Instant :: now ( ) + Duration :: from_secs ( 1 ) ; let mut time_prev = Instant :: now ( ) ; info ! ( " " ) ; info ! ( " \\ " ) ; info ! ( " " ) ; info ! ( " \\ \\ \\ " ) ; info ! ( " " ) ; info ! ( " \\ \\ \\ \\ \\ \\ " ) ; loop { self . world_manager . update_world ( self . control_switcher . get_camera ( ) . position ) ; let time_now = Instant :: now ( ) ; let duration_delta = time_now . duration_since ( time_prev ) ; // delta in seconds let delta = ( ( duration_delta . subsec_nanos ( ) / 1_000 ) as f32 ) / 1_000_000.0 + duration_delta . as_secs ( ) as f32 ; time_prev = Instant :: now ( ) ; self . weather . update ( & self . control_switcher . get_camera ( ) , delta , & self . world_manager , & self . daytime , ) ; self . world_manager . update_world ( self . control_switcher . get_camera ( ) . position ) ; self . daytime . update ( delta ) ; self . sky_view . update ( self . daytime . get_sun_position ( ) ) ; self . sun . update ( self . daytime . get_sun_position ( ) ) ; // Check for pillar outline highlight switch if self . world_manager . get_context ( ) . get_config ( ) . highlight_pillar { // Display Outline of Hexagon looking at let vec = get_pillarsectionpos_looking_at ( & self . world_manager . get_world ( ) , self . control_switcher . get_camera ( ) , ) ; match vec { Some ( n ) => { // self.remove_hexagon_at(n.1, n.0.z); let mut view = self . world_manager . get_mut_view ( ) ; view . outline . display = true ; view . outline . pos = n . 0 ; } None => { let mut view = self . world_manager . get_mut_view ( ) ; view . outline . display = false ; } } } self . renderer . render ( & * self . world_manager . get_view ( ) , & self . control_switcher . get_camera ( ) , & self . daytime , & self . sun , & mut self . weather , & self . sky_view , ) ? ; let event_resp = self . event_manager . poll_events ( vec ! [ mut CloseHandler mut self control_switcher mut self daytime ] ) ; if event_resp == EventResponse :: Quit { break ; } self . control_switcher . update ( delta ) ; frames += 1 ; if next_fps_measure < Instant :: now ( ) { info ! ( " " frames ) ; next_fps_measure = Instant :: now ( ) + Duration :: from_secs ( 1 ) ; frames = 0 ; } } Ok ( ( ) ) }
Main game function: contains the main render loop and owns all important
components.
Main game function : contains the main render loop and owns all important components .
mut self