aboutsummaryrefslogtreecommitdiff
path: root/src/components.rs
blob: 3179f0cba94ec08ab6dd16344431a207f0c3a768 (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
29
30
31
32
33
use std::sync::{Mutex, Arc};

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

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,
}