Skip to content

Commit

Permalink
reset GameTime on game reset
Browse files Browse the repository at this point in the history
  • Loading branch information
thombruce committed Nov 14, 2023
1 parent af452ce commit 6cfaf44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/resources/game_time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{prelude::*, time::Stopwatch};

#[derive(Resource, Deref)]
pub struct GameTime(Stopwatch);
pub struct GameTime(pub Stopwatch);

pub struct GameTimePlugin;
impl Plugin for GameTimePlugin {
Expand Down
5 changes: 4 additions & 1 deletion src/systems/states/transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::{
};
use bevy_picking_core::pointer::PointerId;

use crate::core::resources::assets::AudioAssets;
use crate::core::resources::{assets::AudioAssets, game_time::GameTime};

use super::{ForState, GameState};

Expand Down Expand Up @@ -44,6 +44,7 @@ pub(crate) fn game_reset(
entities: Query<Entity, (Without<Window>, Without<Camera>, Without<PointerId>)>,
mut next_state: ResMut<NextState<GameState>>,
mut window: Query<&mut Window>,
mut game_time: ResMut<GameTime>,
) {
for entity in entities.iter() {
commands.entity(entity).despawn_recursive();
Expand All @@ -54,6 +55,8 @@ pub(crate) fn game_reset(
..default()
};

game_time.0.reset();

next_state.set(GameState::Loading);
}

Expand Down

0 comments on commit 6cfaf44

Please sign in to comment.