use bevy_derive::{Deref, DerefMut};
pub use bevy_ecs::prelude::*;
use bytemuck::TransparentWrapper;
use crossflow::Service;
use crate::*;
use web_time::Instant;
#[derive(Default, Debug, Clone, Copy, Deref, DerefMut, Resource)]
pub struct Selection(pub Option<Entity>);
#[derive(Default, Debug, Clone, Copy, Deref, DerefMut, Resource)]
pub struct Hovering(pub Option<Entity>);
#[derive(Debug, Clone, Copy)]
pub struct DoubleClickSelection {
pub last_selected_entity: Option<Entity>,
pub last_selected_time: Instant,
}
impl Default for DoubleClickSelection {
fn default() -> Self {
DoubleClickSelection {
last_selected_entity: None,
last_selected_time: Instant::now(),
}
}
}
#[derive(Resource)]
pub struct SelectionBlockers {
pub dragging: bool,
}
impl SelectionBlockers {
pub fn blocking(&self) -> bool {
self.dragging
}
}
impl Default for SelectionBlockers {
fn default() -> Self {
SelectionBlockers { dragging: false }
}
}
#[derive(Resource)]
pub struct InspectorServiceConfigs {
pub inspector_select_service: Service<(), (), SelectionStreams>,
pub inspector_cursor_transform: Service<(), ()>,
pub selection_update: Service<Select, ()>,
}
#[derive(Resource, Debug, TransparentWrapper)]
#[repr(transparent)]
pub struct InspectorService(pub Service<(), ()>);