-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split time functionality into bevy_time (#4187)
# Objective Reduce the catch-all grab-bag of functionality in bevy_core by minimally splitting off time functionality into bevy_time. Functionality like that provided by #3002 would increase the complexity of bevy_time, so this is a good candidate for pulling into its own unit. A step in addressing #2931 and splitting bevy_core into more specific locations. ## Solution Pull the time module of bevy_core into a new crate, bevy_time. # Migration guide - Time related types (e.g. `Time`, `Timer`, `Stopwatch`, `FixedTimestep`, etc.) should be imported from `bevy::time::*` rather than `bevy::core::*`. - If you were adding `CorePlugin` manually, you'll also want to add `TimePlugin` from `bevy::time`. - The `bevy::core::CorePlugin::Time` system label is replaced with `bevy::time::TimeSystem`. Co-authored-by: Carter Anderson <[email protected]>
- Loading branch information
Showing
24 changed files
with
123 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "bevy_time" | ||
version = "0.8.0-dev" | ||
edition = "2021" | ||
description = "Provides time functionality for Bevy Engine" | ||
homepage = "https://bevyengine.org" | ||
repository = "https://github.com/bevyengine/bevy" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["bevy"] | ||
|
||
|
||
[dependencies] | ||
# bevy | ||
bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } | ||
bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev", features = ["bevy_reflect"] } | ||
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] } | ||
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
mod fixed_timestep; | ||
mod stopwatch; | ||
#[allow(clippy::module_inception)] | ||
mod time; | ||
mod timer; | ||
|
||
pub use fixed_timestep::*; | ||
pub use stopwatch::*; | ||
pub use time::*; | ||
pub use timer::*; | ||
|
||
pub mod prelude { | ||
//! The Bevy Time Prelude. | ||
#[doc(hidden)] | ||
pub use crate::{Time, Timer}; | ||
} | ||
|
||
use bevy_app::prelude::*; | ||
use bevy_ecs::prelude::*; | ||
|
||
/// Adds time functionality to Apps. | ||
#[derive(Default)] | ||
pub struct TimePlugin; | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemLabel)] | ||
/// Updates the elapsed time. Any system that interacts with [Time] component should run after | ||
/// this. | ||
pub struct TimeSystem; | ||
|
||
impl Plugin for TimePlugin { | ||
fn build(&self, app: &mut App) { | ||
app.init_resource::<Time>() | ||
.init_resource::<FixedTimesteps>() | ||
.register_type::<Timer>() | ||
// time system is added as an "exclusive system" to ensure it runs before other systems | ||
// in CoreStage::First | ||
.add_system_to_stage( | ||
CoreStage::First, | ||
time_system.exclusive_system().at_start().label(TimeSystem), | ||
); | ||
} | ||
} | ||
|
||
fn time_system(mut time: ResMut<Time>) { | ||
time.update(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.