Skip to content

Commit

Permalink
refactor: refactor some code
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 16, 2024
1 parent cdffe0a commit 6654ce6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 3 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,11 @@ fn main() {
);

app.add_systems(
OnEnter(AppState::AutomaticSolution),
OnEnter(AppState::AutoSolve),
(spawn_lowerbound_marks, clear_action_state),
)
.add_systems(
Update,
update_solver.run_if(in_state(AppState::AutomaticSolution)),
)
.add_systems(
OnExit(AppState::AutomaticSolution),
despawn_lowerbound_marks,
)
.add_systems(Update, update_solver.run_if(in_state(AppState::AutoSolve)))
.add_systems(OnExit(AppState::AutoSolve), despawn_lowerbound_marks)
.insert_resource(SolverState::default());

app.add_systems(OnEnter(AppState::AutoCratePush), spawn_crate_pushable_marks)
Expand Down
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ use bevy::prelude::*;
pub enum AppState {
#[default]
Main,
AutomaticSolution,
AutoSolve,
AutoCratePush,
}
4 changes: 2 additions & 2 deletions src/systems/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub fn handle_automatic_solution_action(
*solver = Solver::new(board.level.clone());
solver.initial(settings.solver.strategy, settings.solver.lower_bound_method);

next_state.set(AppState::AutomaticSolution);
next_state.set(AppState::AutoSolve);
*timer = std::time::Instant::now();
} else {
next_state.set(AppState::Main);
Expand All @@ -346,7 +346,7 @@ pub fn spawn_crate_pushable_marks(

let paths = board.level.crate_pushable_paths(crate_position);

// spawn crate reachable marks
// spawn crate pushable marks
for crate_position in paths.keys().map(|state| state.crate_position).unique() {
commands.spawn((
SpriteBundle {
Expand Down

0 comments on commit 6654ce6

Please sign in to comment.