use super::PhotometricData;
use bevy::prelude::*;
use std::marker::PhantomData;
#[derive(Component, Clone, Debug)]
pub struct PhotometricLight<T: PhotometricData> {
pub data: T,
pub intensity_scale: f32,
pub show_solid: bool,
pub show_model: bool,
pub shadows_enabled: bool,
}
impl<T: PhotometricData> PhotometricLight<T> {
pub fn new(data: T) -> Self {
Self {
data,
intensity_scale: 1.0,
show_solid: false,
show_model: true,
shadows_enabled: false,
}
}
pub fn with_intensity_scale(mut self, scale: f32) -> Self {
self.intensity_scale = scale;
self
}
pub fn with_solid(mut self, show: bool) -> Self {
self.show_solid = show;
self
}
pub fn with_model(mut self, show: bool) -> Self {
self.show_model = show;
self
}
pub fn with_shadows(mut self, enabled: bool) -> Self {
self.shadows_enabled = enabled;
self
}
}
#[derive(Bundle, Clone)]
pub struct PhotometricLightBundle<T: PhotometricData> {
pub light: PhotometricLight<T>,
pub transform: Transform,
pub global_transform: GlobalTransform,
}
impl<T: PhotometricData> PhotometricLightBundle<T> {
pub fn new(data: T) -> Self {
Self {
light: PhotometricLight::new(data),
transform: Transform::default(),
global_transform: GlobalTransform::default(),
}
}
pub fn with_transform(mut self, transform: Transform) -> Self {
self.transform = transform;
self
}
pub fn with_intensity_scale(mut self, scale: f32) -> Self {
self.light = self.light.with_intensity_scale(scale);
self
}
pub fn with_solid(mut self, show: bool) -> Self {
self.light = self.light.with_solid(show);
self
}
pub fn with_model(mut self, show: bool) -> Self {
self.light = self.light.with_model(show);
self
}
pub fn with_shadows(mut self, enabled: bool) -> Self {
self.light = self.light.with_shadows(enabled);
self
}
}
#[derive(Component)]
pub struct BevyLightMarker<T: PhotometricData> {
pub parent: Entity,
_phantom: PhantomData<T>,
}
impl<T: PhotometricData> BevyLightMarker<T> {
pub fn new(parent: Entity) -> Self {
Self {
parent,
_phantom: PhantomData,
}
}
}
#[derive(Component)]
pub struct PhotometricSolid<T: PhotometricData> {
pub parent: Entity,
_phantom: PhantomData<T>,
}
impl<T: PhotometricData> PhotometricSolid<T> {
pub fn new(parent: Entity) -> Self {
Self {
parent,
_phantom: PhantomData,
}
}
}
#[derive(Component)]
pub struct LuminaireModel<T: PhotometricData> {
pub parent: Entity,
_phantom: PhantomData<T>,
}
impl<T: PhotometricData> LuminaireModel<T> {
pub fn new(parent: Entity) -> Self {
Self {
parent,
_phantom: PhantomData,
}
}
}
#[derive(Resource)]
pub struct PhotometricPluginState<T: PhotometricData> {
_phantom: PhantomData<T>,
}
impl<T: PhotometricData> Default for PhotometricPluginState<T> {
fn default() -> Self {
Self {
_phantom: PhantomData,
}
}
}