From f88d063beb1b9bfbb005f1e56a1c26d31d2d39fd Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 7 May 2024 15:35:47 +0200 Subject: [PATCH] add spotlight to player --- src/commands.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index 746af99..b251c0a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -17,6 +17,7 @@ use bevy::math::DVec3; use bevy::pbr::{NotShadowCaster, NotShadowReceiver}; use crate::{actor, camera, chat, hud, nature, shading, skeleton, var, world}; use regex::Regex; +use std::f32::consts::PI; use std::f64::consts::PI as PI64; use std::time::SystemTime; @@ -743,6 +744,30 @@ fn spawn_entities( if let Some(_) = state.ar_model { actor.insert(hud::AugmentedRealityOverlayBroadcaster); } + if state.is_player { + actor.with_children(|builder| { + builder.spawn(( + world::DespawnOnPlayerDeath, + SpotLightBundle { + transform: Transform { + translation: Vec3::new(0.0, 0.0, 1.0), + rotation: Quat::from_rotation_y(180f32.to_radians()), + ..default() + }, + spot_light: SpotLight { + intensity: 40_000_000.0, // lumens + color: Color::WHITE, + shadows_enabled: true, + inner_angle: PI / 8.0 * 0.85, + outer_angle: PI / 4.0, + range: 2000.0, + ..default() + }, + ..default() + } + )); + }); + } actor_entity = actor.id(); }