mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
feat(floors): hide floors above #18
This commit is contained in:
parent
4864ecca93
commit
f08bd72038
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3157,7 +3157,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "maze-ascension"
|
name = "maze-ascension"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bevy",
|
"bevy",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "maze-ascension"
|
name = "maze-ascension"
|
||||||
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug, Reflect, Component, Deref, DerefMut)]
|
#[derive(Debug, Reflect, Component, Deref, DerefMut, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct Floor(pub u8);
|
pub struct Floor(pub u8);
|
||||||
|
|
||||||
|
|||||||
19
src/floor/systems/hide.rs
Normal file
19
src/floor/systems/hide.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::floor::components::{CurrentFloor, Floor};
|
||||||
|
|
||||||
|
pub fn hide_upper_floors(
|
||||||
|
mut query: Query<(&mut Visibility, &Floor)>,
|
||||||
|
current_query: Query<&Floor, With<CurrentFloor>>,
|
||||||
|
) {
|
||||||
|
let Ok(current_floor) = current_query.get_single() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
for (mut visibility, floor) in query.iter_mut() {
|
||||||
|
if floor > current_floor {
|
||||||
|
*visibility = Visibility::Hidden
|
||||||
|
} else {
|
||||||
|
*visibility = Visibility::Visible
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,12 @@
|
|||||||
mod despawn;
|
mod despawn;
|
||||||
|
mod hide;
|
||||||
mod movement;
|
mod movement;
|
||||||
mod spawn;
|
mod spawn;
|
||||||
|
|
||||||
use crate::screens::Screen;
|
use crate::screens::Screen;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use despawn::despawn_floor;
|
use despawn::despawn_floor;
|
||||||
|
use hide::hide_upper_floors;
|
||||||
use movement::{handle_floor_transition_events, move_floors};
|
use movement::{handle_floor_transition_events, move_floors};
|
||||||
use spawn::spawn_floor;
|
use spawn::spawn_floor;
|
||||||
|
|
||||||
@ -16,6 +18,7 @@ pub(super) fn plugin(app: &mut App) {
|
|||||||
despawn_floor,
|
despawn_floor,
|
||||||
handle_floor_transition_events,
|
handle_floor_transition_events,
|
||||||
move_floors,
|
move_floors,
|
||||||
|
hide_upper_floors,
|
||||||
)
|
)
|
||||||
.chain()
|
.chain()
|
||||||
.run_if(in_state(Screen::Gameplay)),
|
.run_if(in_state(Screen::Gameplay)),
|
||||||
|
|||||||
@ -74,7 +74,7 @@ pub fn handle_floor_transition_events(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for event in event_reader.read() {
|
for event in event_reader.read() {
|
||||||
let Some((current_entity, current_floor)) = current_query.get_single().ok() else {
|
let Ok((current_entity, current_floor)) = current_query.get_single() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user