Skip to main content

euv_engine/scene/
trait.rs

1use super::*;
2
3/// The base trait for all game scenes.
4///
5/// A scene encapsulates a self-contained portion of the game world,
6/// managing its own game objects, resources, and update logic.
7pub trait Scene {
8    /// Called once when this scene becomes the active scene.
9    fn on_enter(&mut self);
10
11    /// Called once when this scene is being replaced or removed.
12    fn on_exit(&mut self);
13
14    /// Called every fixed timestep to update game logic.
15    ///
16    /// # Arguments
17    ///
18    /// - `f64` - The delta time in seconds.
19    fn on_update(&mut self, delta_time: f64);
20
21    /// Called every render frame to record the scene's draw commands.
22    ///
23    /// Instead of drawing immediately, the scene pushes `DrawCommand`s into the
24    /// provided `DrawList`; the engine replays the whole list once per frame in
25    /// a single batched pass.
26    ///
27    /// # Arguments
28    ///
29    /// - `&mut DrawList` - The draw list to record commands into.
30    fn on_render(&self, draw_list: &mut DrawList);
31
32    /// Returns the name of this scene for identification.
33    ///
34    /// # Returns
35    ///
36    /// - `&str` - The scene name.
37    fn name(&self) -> &str;
38}