MAJOR rendering overhaul. Snow deformation, persistent light, flowmap out. Also ECS architexture overhaul
This commit is contained in:
53
src/bundles/spotlight.rs
Normal file
53
src/bundles/spotlight.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::bundles::Bundle;
|
||||
use crate::components::RotateComponent;
|
||||
use crate::entity::EntityHandle;
|
||||
use crate::loaders::lights::LightData;
|
||||
use crate::world::{Transform, World};
|
||||
|
||||
pub struct SpotlightBundle
|
||||
{
|
||||
pub light_data: LightData,
|
||||
}
|
||||
|
||||
impl Bundle for SpotlightBundle
|
||||
{
|
||||
fn spawn(self, world: &mut World) -> Result<EntityHandle, String>
|
||||
{
|
||||
let entity = world.spawn();
|
||||
let transform = Transform::from_matrix(self.light_data.transform);
|
||||
world.transforms.insert(entity, transform);
|
||||
world.spotlights.insert(entity, self.light_data.component);
|
||||
if let Some(tag) = self.light_data.tag
|
||||
{
|
||||
if tag == "lighthouse"
|
||||
{
|
||||
world
|
||||
.rotates
|
||||
.insert(entity, RotateComponent::new(Vec3::Y, 1.0));
|
||||
}
|
||||
}
|
||||
Ok(entity)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn_spotlights(world: &mut World, spotlights: Vec<LightData>)
|
||||
{
|
||||
for light_data in spotlights
|
||||
{
|
||||
let entity = world.spawn();
|
||||
let transform = Transform::from_matrix(light_data.transform);
|
||||
world.transforms.insert(entity, transform);
|
||||
world.spotlights.insert(entity, light_data.component);
|
||||
if let Some(tag) = light_data.tag
|
||||
{
|
||||
if tag == "lighthouse"
|
||||
{
|
||||
world
|
||||
.rotates
|
||||
.insert(entity, RotateComponent::new(Vec3::Y, 1.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user