Refactor + Begin add SceneSchedule

This commit is contained in:
Florian RICHER 2025-06-13 13:27:34 +02:00
parent 7b1373620c
commit 77affedf93
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
14 changed files with 286 additions and 188 deletions

View file

@ -8,7 +8,7 @@ use egui_winit_vulkano::Gui;
use vulkano_util::{renderer::VulkanoWindowRenderer, window::VulkanoWindows};
use winit::{event_loop::EventLoopProxy, monitor::MonitorHandle, window::WindowId};
use crate::core::{input::InputManager, render::vulkan_context::VulkanContext, timer::Timer};
use crate::core::{input::InputManager, render::vulkan_context::VulkanContext};
use super::user_event::UserEvent;
@ -22,7 +22,6 @@ pub struct WindowContext {
// Données mutables partagées avec Arc<Mutex<>>
pub vulkano_windows: Rc<RefCell<VulkanoWindows>>,
pub input_manager: Arc<RwLock<InputManager>>,
pub timer: Arc<RwLock<Timer>>,
pub gui: Rc<RefCell<Gui>>,
}
@ -31,7 +30,6 @@ impl WindowContext {
vulkan_context: Arc<VulkanContext>,
vulkano_windows: Rc<RefCell<VulkanoWindows>>,
input_manager: Arc<RwLock<InputManager>>,
timer: Arc<RwLock<Timer>>,
gui: Rc<RefCell<Gui>>,
event_loop_proxy: EventLoopProxy<UserEvent>,
window_id: WindowId,
@ -45,7 +43,6 @@ impl WindowContext {
// Données mutables partagées
vulkano_windows,
input_manager,
timer,
gui,
}
}
@ -85,11 +82,6 @@ impl WindowContext {
})
}
/// Récupère le delta time actuel depuis le timer
pub fn get_delta_time(&self) -> f32 {
self.with_timer(|timer| timer.delta_time())
}
/// Récupère la taille de la fenêtre depuis le renderer
pub fn get_window_size(&self) -> [f32; 2] {
self.with_renderer(|renderer| renderer.window_size())
@ -140,13 +132,4 @@ impl WindowContext {
let mut gui = self.gui.borrow_mut();
f(&mut gui)
}
/// Méthode utilitaire pour accéder au timer de manière thread-safe
pub fn with_timer<T, F>(&self, f: F) -> T
where
F: FnOnce(&Timer) -> T,
{
let timer = self.timer.read().expect("Failed to lock timer");
f(&timer)
}
}