mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
fix(floor): double event call
This commit is contained in:
parent
74836df618
commit
cfaf565891
@ -1,3 +1,5 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
floor::{
|
||||
components::{CurrentFloor, Floor, FloorYTarget},
|
||||
@ -6,7 +8,6 @@ use crate::{
|
||||
},
|
||||
maze::{components::MazeConfig, events::SpawnMaze},
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub(super) fn spawn_floor(
|
||||
mut commands: Commands,
|
||||
@ -19,7 +20,7 @@ pub(super) fn spawn_floor(
|
||||
};
|
||||
|
||||
for event in event_reader.read() {
|
||||
if current_floor.0 == 0 && *event == TransitionFloor::Descend {
|
||||
if current_floor.0 == 1 && *event == TransitionFloor::Descend {
|
||||
warn!("Cannot descend below floor 1");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ enum AppSet {
|
||||
TickTimers,
|
||||
/// Record player input.
|
||||
RecordInput,
|
||||
/// Do everything else (consider splitting this into further variants).
|
||||
/// Do everything else.
|
||||
Update,
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ pub mod errors;
|
||||
pub mod events;
|
||||
pub mod resources;
|
||||
mod systems;
|
||||
pub mod triggers;
|
||||
mod triggers;
|
||||
|
||||
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
||||
use components::HexMaze;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
pub mod common;
|
||||
mod despawn;
|
||||
mod respawn;
|
||||
pub mod spawn;
|
||||
mod spawn;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use despawn::despawn_maze;
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
use super::common::generate_maze;
|
||||
use crate::{
|
||||
constants::FLOOR_Y_OFFSET,
|
||||
floor::components::{CurrentFloor, Floor},
|
||||
floor::{
|
||||
components::{CurrentFloor, Floor},
|
||||
events::TransitionFloor,
|
||||
},
|
||||
maze::{
|
||||
assets::MazeAssets,
|
||||
components::{HexMaze, MazeConfig, Tile, Wall},
|
||||
@ -17,13 +20,14 @@ use hexlab::prelude::{Tile as HexTile, *};
|
||||
use hexx::HexOrientation;
|
||||
use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_6};
|
||||
|
||||
pub(crate) fn spawn_maze(
|
||||
pub fn spawn_maze(
|
||||
trigger: Trigger<SpawnMaze>,
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
maze_query: Query<(Entity, &Floor, &Maze)>,
|
||||
global_config: Res<GlobalMazeConfig>,
|
||||
mut event_writer: EventWriter<TransitionFloor>,
|
||||
) {
|
||||
let SpawnMaze { floor, config } = trigger.event();
|
||||
|
||||
@ -68,6 +72,11 @@ pub(crate) fn spawn_maze(
|
||||
config,
|
||||
&global_config,
|
||||
);
|
||||
|
||||
// TODO: find a better way to handle double event indirection
|
||||
if *floor != 1 {
|
||||
event_writer.send(TransitionFloor::Ascend);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn_maze_tiles(
|
||||
|
||||
@ -12,11 +12,8 @@ use vertical_transition::handle_floor_transition;
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
app.add_systems(
|
||||
Update,
|
||||
(
|
||||
player_input,
|
||||
player_movement.after(player_input),
|
||||
handle_floor_transition,
|
||||
)
|
||||
(player_input, player_movement, handle_floor_transition)
|
||||
.chain()
|
||||
.run_if(in_state(Screen::Gameplay)),
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user