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: Lifecycle {
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 render frame to record the scene's draw commands.
15    ///
16    /// Instead of drawing immediately, the scene pushes `DrawCommand`s into the
17    /// provided `DrawList`; the engine replays the whole list once per frame in
18    /// a single batched pass.
19    ///
20    /// # Arguments
21    ///
22    /// - `&mut DrawList` - The draw list to record commands into.
23    fn on_render(&self, draw_list: &mut DrawList);
24
25    /// Returns the name of this scene for identification.
26    ///
27    /// # Returns
28    ///
29    /// - `&str` - The scene name.
30    fn name(&self) -> &str;
31}