Skip to content

Commit 6d6bc2a

Browse files
committed
Merge AppBuilder into App (bevyengine#2531)
This is extracted out of eb8f973 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
1 parent c83a184 commit 6d6bc2a

File tree

130 files changed

+712
-764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+712
-764
lines changed

crates/bevy_app/src/app.rs

Lines changed: 525 additions & 16 deletions
Large diffs are not rendered by default.

crates/bevy_app/src/app_builder.rs

Lines changed: 0 additions & 559 deletions
This file was deleted.

crates/bevy_app/src/ci_testing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::Deserialize;
22

3-
use crate::{app::AppExit, AppBuilder};
3+
use crate::{app::AppExit, App};
44
use bevy_ecs::system::IntoSystem;
55

66
/// Configuration for automated testing on CI
@@ -23,7 +23,7 @@ fn ci_testing_exit_after(
2323
*current_frame += 1;
2424
}
2525

26-
pub(crate) fn setup_app(app_builder: &mut AppBuilder) -> &mut AppBuilder {
26+
pub(crate) fn setup_app(app_builder: &mut App) -> &mut App {
2727
let filename =
2828
std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string());
2929
let config: CiTestingConfig = ron::from_str(

crates/bevy_app/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod app;
2-
mod app_builder;
32
mod plugin;
43
mod plugin_group;
54
mod schedule_runner;
@@ -8,7 +7,6 @@ mod schedule_runner;
87
mod ci_testing;
98

109
pub use app::*;
11-
pub use app_builder::*;
1210
pub use bevy_derive::DynamicPlugin;
1311
pub use bevy_ecs::event::*;
1412
pub use plugin::*;
@@ -17,10 +15,7 @@ pub use schedule_runner::*;
1715

1816
pub mod prelude {
1917
#[doc(hidden)]
20-
pub use crate::{
21-
app::App, app_builder::AppBuilder, CoreStage, DynamicPlugin, Plugin, PluginGroup,
22-
StartupStage,
23-
};
18+
pub use crate::{app::App, CoreStage, DynamicPlugin, Plugin, PluginGroup, StartupStage};
2419
}
2520

2621
use bevy_ecs::schedule::StageLabel;

crates/bevy_app/src/plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::AppBuilder;
1+
use crate::App;
22
use std::any::Any;
33

44
/// A collection of Bevy App logic and configuration
55
///
6-
/// Plugins use [AppBuilder] to configure an [App](crate::App). When an [App](crate::App) registers
6+
/// Plugins configure an [App](crate::App). When an [App](crate::App) registers
77
/// a plugin, the plugin's [Plugin::build] function is run.
88
pub trait Plugin: Any + Send + Sync {
9-
fn build(&self, app: &mut AppBuilder);
9+
fn build(&self, app: &mut App);
1010
fn name(&self) -> &str {
1111
std::any::type_name::<Self>()
1212
}

crates/bevy_app/src/plugin_group.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AppBuilder, Plugin};
1+
use crate::{App, Plugin};
22
use bevy_utils::{tracing::debug, HashMap};
33
use std::any::TypeId;
44

@@ -96,7 +96,7 @@ impl PluginGroupBuilder {
9696
self
9797
}
9898

99-
pub fn finish(self, app: &mut AppBuilder) {
99+
pub fn finish(self, app: &mut App) {
100100
for ty in self.order.iter() {
101101
if let Some(entry) = self.plugins.get(ty) {
102102
if entry.enabled {

crates/bevy_app/src/schedule_runner.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
use super::{App, AppBuilder};
2-
use crate::{app::AppExit, plugin::Plugin, ManualEventReader};
1+
use crate::{
2+
app::{App, AppExit},
3+
plugin::Plugin,
4+
ManualEventReader,
5+
};
36
use bevy_ecs::event::Events;
47
use bevy_utils::{Duration, Instant};
58

@@ -48,9 +51,9 @@ impl ScheduleRunnerSettings {
4851
pub struct ScheduleRunnerPlugin {}
4952

5053
impl Plugin for ScheduleRunnerPlugin {
51-
fn build(&self, app: &mut AppBuilder) {
54+
fn build(&self, app: &mut App) {
5255
let settings = app
53-
.world_mut()
56+
.world
5457
.get_resource_or_insert_with(ScheduleRunnerSettings::default)
5558
.to_owned();
5659
app.set_runner(move |mut app: App| {

crates/bevy_asset/src/assets.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
update_asset_storage_system, Asset, AssetLoader, AssetServer, AssetStage, Handle, HandleId,
33
RefChange,
44
};
5-
use bevy_app::{AppBuilder, EventWriter, Events};
5+
use bevy_app::{App, EventWriter, Events};
66
use bevy_ecs::{
77
system::{IntoSystem, ResMut},
88
world::FromWorld,
@@ -193,7 +193,7 @@ impl<T: Asset> Assets<T> {
193193
}
194194
}
195195

196-
/// [AppBuilder] extension methods for adding new asset types
196+
/// [App] extension methods for adding new asset types
197197
pub trait AddAsset {
198198
fn add_asset<T>(&mut self) -> &mut Self
199199
where
@@ -206,13 +206,13 @@ pub trait AddAsset {
206206
T: AssetLoader;
207207
}
208208

209-
impl AddAsset for AppBuilder {
209+
impl AddAsset for App {
210210
fn add_asset<T>(&mut self) -> &mut Self
211211
where
212212
T: Asset,
213213
{
214214
let assets = {
215-
let asset_server = self.world().get_resource::<AssetServer>().unwrap();
215+
let asset_server = self.world.get_resource::<AssetServer>().unwrap();
216216
asset_server.register_asset_type::<T>()
217217
};
218218

@@ -233,15 +233,15 @@ impl AddAsset for AppBuilder {
233233
where
234234
T: AssetLoader + FromWorld,
235235
{
236-
let result = T::from_world(self.world_mut());
236+
let result = T::from_world(&mut self.world);
237237
self.add_asset_loader(result)
238238
}
239239

240240
fn add_asset_loader<T>(&mut self, loader: T) -> &mut Self
241241
where
242242
T: AssetLoader,
243243
{
244-
self.world_mut()
244+
self.world
245245
.get_resource_mut::<AssetServer>()
246246
.expect("AssetServer does not exist. Consider adding it as a resource.")
247247
.add_loader(loader);

crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<T: Asset> Default for AssetCountDiagnosticsPlugin<T> {
1717
}
1818

1919
impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
20-
fn build(&self, app: &mut AppBuilder) {
20+
fn build(&self, app: &mut App) {
2121
app.add_startup_system(Self::setup_system.system())
2222
.add_system(Self::diagnostic_system.system());
2323
}

crates/bevy_asset/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub use io::*;
2626
pub use loader::*;
2727
pub use path::*;
2828

29-
use bevy_app::{prelude::Plugin, AppBuilder};
29+
use bevy_app::{prelude::Plugin, App};
3030
use bevy_ecs::{
3131
schedule::{StageLabel, SystemStage},
3232
system::IntoSystem,
@@ -61,9 +61,9 @@ impl Default for AssetServerSettings {
6161
///
6262
/// This is useful when providing a custom `AssetIo` instance that needs to
6363
/// delegate to the default `AssetIo` for the platform.
64-
pub fn create_platform_default_asset_io(app: &mut AppBuilder) -> Box<dyn AssetIo> {
64+
pub fn create_platform_default_asset_io(app: &mut App) -> Box<dyn AssetIo> {
6565
let settings = app
66-
.world_mut()
66+
.world
6767
.get_resource_or_insert_with(AssetServerSettings::default);
6868

6969
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))]
@@ -77,10 +77,10 @@ pub fn create_platform_default_asset_io(app: &mut AppBuilder) -> Box<dyn AssetIo
7777
}
7878

7979
impl Plugin for AssetPlugin {
80-
fn build(&self, app: &mut AppBuilder) {
81-
if app.world().get_resource::<AssetServer>().is_none() {
80+
fn build(&self, app: &mut App) {
81+
if app.world.get_resource::<AssetServer>().is_none() {
8282
let task_pool = app
83-
.world()
83+
.world
8484
.get_resource::<IoTaskPool>()
8585
.expect("`IoTaskPool` resource not found.")
8686
.0

0 commit comments

Comments
 (0)