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::{
|
use crate::{
|
||||||
floor::{
|
floor::{
|
||||||
components::{CurrentFloor, Floor, FloorYTarget},
|
components::{CurrentFloor, Floor, FloorYTarget},
|
||||||
@ -6,7 +8,6 @@ use crate::{
|
|||||||
},
|
},
|
||||||
maze::{components::MazeConfig, events::SpawnMaze},
|
maze::{components::MazeConfig, events::SpawnMaze},
|
||||||
};
|
};
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
pub(super) fn spawn_floor(
|
pub(super) fn spawn_floor(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
@ -19,7 +20,7 @@ pub(super) fn spawn_floor(
|
|||||||
};
|
};
|
||||||
|
|
||||||
for event in event_reader.read() {
|
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");
|
warn!("Cannot descend below floor 1");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,7 @@ enum AppSet {
|
|||||||
TickTimers,
|
TickTimers,
|
||||||
/// Record player input.
|
/// Record player input.
|
||||||
RecordInput,
|
RecordInput,
|
||||||
/// Do everything else (consider splitting this into further variants).
|
/// Do everything else.
|
||||||
Update,
|
Update,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ pub mod errors;
|
|||||||
pub mod events;
|
pub mod events;
|
||||||
pub mod resources;
|
pub mod resources;
|
||||||
mod systems;
|
mod systems;
|
||||||
pub mod triggers;
|
mod triggers;
|
||||||
|
|
||||||
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
||||||
use components::HexMaze;
|
use components::HexMaze;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
mod despawn;
|
mod despawn;
|
||||||
mod respawn;
|
mod respawn;
|
||||||
pub mod spawn;
|
mod spawn;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use despawn::despawn_maze;
|
use despawn::despawn_maze;
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
use super::common::generate_maze;
|
use super::common::generate_maze;
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::FLOOR_Y_OFFSET,
|
constants::FLOOR_Y_OFFSET,
|
||||||
floor::components::{CurrentFloor, Floor},
|
floor::{
|
||||||
|
components::{CurrentFloor, Floor},
|
||||||
|
events::TransitionFloor,
|
||||||
|
},
|
||||||
maze::{
|
maze::{
|
||||||
assets::MazeAssets,
|
assets::MazeAssets,
|
||||||
components::{HexMaze, MazeConfig, Tile, Wall},
|
components::{HexMaze, MazeConfig, Tile, Wall},
|
||||||
@ -17,13 +20,14 @@ use hexlab::prelude::{Tile as HexTile, *};
|
|||||||
use hexx::HexOrientation;
|
use hexx::HexOrientation;
|
||||||
use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_6};
|
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>,
|
trigger: Trigger<SpawnMaze>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
maze_query: Query<(Entity, &Floor, &Maze)>,
|
maze_query: Query<(Entity, &Floor, &Maze)>,
|
||||||
global_config: Res<GlobalMazeConfig>,
|
global_config: Res<GlobalMazeConfig>,
|
||||||
|
mut event_writer: EventWriter<TransitionFloor>,
|
||||||
) {
|
) {
|
||||||
let SpawnMaze { floor, config } = trigger.event();
|
let SpawnMaze { floor, config } = trigger.event();
|
||||||
|
|
||||||
@ -68,6 +72,11 @@ pub(crate) fn spawn_maze(
|
|||||||
config,
|
config,
|
||||||
&global_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(
|
pub fn spawn_maze_tiles(
|
||||||
|
|||||||
@ -12,11 +12,8 @@ use vertical_transition::handle_floor_transition;
|
|||||||
pub(super) fn plugin(app: &mut App) {
|
pub(super) fn plugin(app: &mut App) {
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
Update,
|
Update,
|
||||||
(
|
(player_input, player_movement, handle_floor_transition)
|
||||||
player_input,
|
.chain()
|
||||||
player_movement.after(player_input),
|
|
||||||
handle_floor_transition,
|
|
||||||
)
|
|
||||||
.run_if(in_state(Screen::Gameplay)),
|
.run_if(in_state(Screen::Gameplay)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user