gemini_engine/containers/
visibility_toggle.rsuse crate::core::CanDraw;
use super::CanCollide;
#[derive(Debug, Clone)]
pub struct VisibilityToggle<E: CanDraw> {
pub element: E,
pub visible: bool,
}
impl<E: CanDraw> VisibilityToggle<E> {
pub const fn new(element: E) -> Self {
Self {
element,
visible: true,
}
}
}
impl<E: CanDraw> CanDraw for VisibilityToggle<E> {
fn draw_to(&self, canvas: &mut impl crate::core::Canvas) {
if self.visible {
self.element.draw_to(canvas);
}
}
}
impl<E: CanDraw + CanCollide> CanCollide for VisibilityToggle<E> {
fn collides_with_pos(&self, pos: crate::core::Vec2D) -> bool {
if self.visible {
self.element.collides_with_pos(pos)
} else {
false
}
}
}