fix lights in pillars

main
annieversary 2022-07-07 10:18:41 +01:00
parent afc34ef766
commit 4447ff2aa6
1 changed files with 6 additions and 3 deletions

View File

@ -1,9 +1,11 @@
use bevy::prelude::*; use bevy::{pbr::CubemapVisibleEntities, prelude::*, render::primitives::CubemapFrusta};
use crate::{camera::MouseCoords, player::LightFriends}; use crate::{camera::MouseCoords, player::LightFriends};
const SIZE: f32 = 10.0; const SIZE: f32 = 10.0;
const HEIGHT: f32 = 20.0; const HEIGHT: f32 = 20.0;
/// duration of pillar activation, in secs
const PILLAR_DURATION: f32 = 30.0;
#[derive(Component)] #[derive(Component)]
pub struct UnlitPillar; pub struct UnlitPillar;
@ -29,6 +31,8 @@ pub fn spawn_pillar(
transform: Transform::from_translation(pos), transform: Transform::from_translation(pos),
..Default::default() ..Default::default()
}) })
.insert(CubemapFrusta::default())
.insert(CubemapVisibleEntities::default())
.insert(UnlitPillar); .insert(UnlitPillar);
} }
@ -125,8 +129,7 @@ pub fn decrease_pillar_strength(
let t = time.seconds_since_startup(); let t = time.seconds_since_startup();
for (entity, mut light, handle, pillar) in query.iter_mut() { for (entity, mut light, handle, pillar) in query.iter_mut() {
let d = t - pillar.created_at; let d = t - pillar.created_at;
const DUR: f32 = 10.0; let i = (PILLAR_DURATION - d as f32) / PILLAR_DURATION;
let i = (DUR - d as f32) / DUR;
if i < 0.0 { if i < 0.0 {
// deactivate pillar // deactivate pillar