Compare commits

...

2 commits

3 changed files with 47 additions and 0 deletions

View file

@ -168,6 +168,8 @@ pub struct MessageOnVehicleEntry(pub String);
#[derive(Component)]
pub struct PlayersFlashLight;
#[derive(Component)]
pub struct MirrorLight;
#[derive(Component)]
pub struct WantsMaxRotation(pub f64);
#[derive(Component)]
pub struct WantsMaxVelocity(pub f64);

View file

@ -101,6 +101,7 @@ struct ParserState {
is_planet: bool,
is_point_of_interest: bool,
is_tidally_locked: bool,
is_mirror: bool,
orbit_distance: Option<f64>,
orbit_object_id: Option<String>,
orbit_phase: Option<f64>,
@ -163,6 +164,7 @@ impl Default for ParserState {
is_planet: false,
is_point_of_interest: false,
is_tidally_locked: false,
is_mirror: false,
orbit_distance: None,
orbit_object_id: None,
orbit_phase: None,
@ -442,6 +444,9 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
["sphere", "yes"] => {
state.is_sphere = true;
}
["mirror", "yes"] => {
state.is_mirror = true;
}
["id", id] => {
state.id = id.to_string();
}
@ -915,6 +920,9 @@ fn spawn_scenes(
state.angular_momentum = DVec3::ZERO;
}
// command: mirror yes
state.is_mirror = true;
// command: scale 10.0
state.model_scale = 10.0;
@ -1239,6 +1247,32 @@ fn spawn_entities(
if !state.ar_models.is_empty() {
actor.insert(hud::AugmentedRealityOverlayBroadcaster);
}
if state.is_mirror {
actor.with_children(|builder| {
// TODO: rotate the light appropriately
builder.spawn((
world::DespawnOnPlayerDeath,
actor::MirrorLight,
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: 2e7,
color: Color::WHITE,
shadows_enabled: false,
inner_angle: PI32 / 16.0,
outer_angle: PI32 / 13.0,
range: 1000.0,
..default()
},
..default()
},
));
});
}
if state.is_player {
actor.with_children(|builder| {
builder.spawn((

View file

@ -600,6 +600,7 @@ fn handle_achievement_event(
fn check_achievements(
time: Res<Time>,
q_player: Query<&Position, With<actor::PlayerCamera>>,
mut q_mirrorlight: Query<&mut Visibility, With<actor::MirrorLight>>,
id2pos: Res<Id2Pos>,
mut ew_achievement: EventWriter<AchievementEvent>,
mut timer: ResMut<AchievementCheckTimer>,
@ -633,6 +634,16 @@ fn check_achievements(
if shadowed {
ew_achievement.send(AchievementEvent::InJupitersShadow);
for mut mirrorlight_vis in &mut q_mirrorlight {
*mirrorlight_vis = Visibility::Hidden;
}
} else {
// This is checking for whether the player is shadowed, not the mirror.
// But in the case where these two are not the same, the player doesn't see
// the mirror anyway and the mirror light's visibility state is irrelevant.
for mut mirrorlight_vis in &mut q_mirrorlight {
*mirrorlight_vis = Visibility::Inherited;
}
}
}