Skip to main content

mittens_engine/engine/ecs/component/
overlay.rs

1use crate::engine::ecs::ComponentId;
2use crate::engine::ecs::component::Component;
3
4/// Marks a subtree as belonging to the overlay render phase.
5///
6/// Any renderables under an `OverlayComponent` ancestor are routed into the overlay pass,
7/// which is drawn after all other passes.
8#[derive(Debug, Default, Clone, Copy)]
9pub struct OverlayComponent {
10    component: Option<ComponentId>,
11}
12
13impl OverlayComponent {
14    pub fn new() -> Self {
15        Self { component: None }
16    }
17
18    pub fn id(&self) -> Option<ComponentId> {
19        self.component
20    }
21}
22
23impl Component for OverlayComponent {
24    fn set_id(&mut self, component: ComponentId) {
25        self.component = Some(component);
26    }
27
28    fn name(&self) -> &'static str {
29        "overlay"
30    }
31
32    fn as_any(&self) -> &dyn std::any::Any {
33        self
34    }
35
36    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
37        self
38    }
39}