aboutsummaryrefslogtreecommitdiff
path: root/src/components.rs
blob: c1122d0a061c8c3578f72a3ae4faf29fcc5d3ea2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::sync::{Arc, Mutex};

use bevy::{ecs::query::QueryItem, prelude::*, render::extract_component::ExtractComponent};

use crate::render_assets::FramebufferExtractSource;

#[derive(Component, Default, Clone)]
pub struct FramebufferExtractDestination(pub Arc<Mutex<Image>>);

impl ExtractComponent for FramebufferExtractDestination {
    type QueryData = (&'static Self, &'static Handle<FramebufferExtractSource>);

    type QueryFilter = ();

    type Out = (Self, Handle<FramebufferExtractSource>);

    fn extract_component(
        (destination, source_handle): QueryItem<'_, Self::QueryData>,
    ) -> Option<Self::Out> {
        Some((destination.clone(), source_handle.clone()))
    }
}

#[derive(Bundle)]
pub struct ExtractFramebufferBundle {
    pub source: Handle<FramebufferExtractSource>,
    pub dest: FramebufferExtractDestination,
}