diff --git a/crates/bevy_plugin/src/commands/command_registry.rs b/crates/bevy_plugin/src/commands/command_registry.rs index ed010c29..bfa39af6 100644 --- a/crates/bevy_plugin/src/commands/command_registry.rs +++ b/crates/bevy_plugin/src/commands/command_registry.rs @@ -179,7 +179,7 @@ mod tests { methods.add_command("test", |_: In<()>| panic!("It works!")); let method = methods.get_mut("test").unwrap(); let mut app = App::new(); - method.call(vec![], &mut app.world); + method.call(vec![], app.world_mut()); } #[test] @@ -189,7 +189,7 @@ mod tests { methods.add_command("test", |In(a): In| assert_eq!(1.0, a)); let method = methods.get_mut("test").unwrap(); let mut app = App::new(); - method.call(to_method_params([1.0]), &mut app.world); + method.call(to_method_params([1.0]), app.world_mut()); } #[test] @@ -209,10 +209,10 @@ mod tests { let mut app = App::new(); { let method1 = methods.get_mut("test1").unwrap(); - method1.call(vec![], &mut app.world); + method1.call(vec![], app.world_mut()); } let method2 = methods.get_mut("test2").unwrap(); - method2.call(to_method_params([1.0]), &mut app.world); + method2.call(to_method_params([1.0]), app.world_mut()); } #[test] @@ -228,8 +228,8 @@ mod tests { let method = methods.get_mut("test").unwrap(); let mut app = App::new(); - method.call(to_method_params([1.0]), &mut app.world); - let data = app.world.resource::(); + method.call(to_method_params([1.0]), app.world_mut()); + let data = app.world().resource::(); assert_eq!(data.0, 1.0); } @@ -247,7 +247,7 @@ mod tests { let method = methods.get_mut("test").unwrap(); let mut app = App::new(); - let task = method.call(vec![], &mut app.world); + let task = method.call(vec![], app.world_mut()); assert!(!task.is_finished()); sleep(Duration::from_millis(600)); assert!(task.is_finished()); diff --git a/crates/bevy_plugin/src/commands/execution.rs b/crates/bevy_plugin/src/commands/execution.rs index d95b71d7..6254b079 100644 --- a/crates/bevy_plugin/src/commands/execution.rs +++ b/crates/bevy_plugin/src/commands/execution.rs @@ -29,7 +29,7 @@ fn execute_commands(world: &mut World, mut reader: Local, ) -> Vec { let events = world.resource::>(); diff --git a/crates/bevy_plugin/src/line_provider/asset_provider/file_extension_asset_provider_plugin.rs b/crates/bevy_plugin/src/line_provider/asset_provider/file_extension_asset_provider_plugin.rs index d28070fe..5ca4e6a8 100644 --- a/crates/bevy_plugin/src/line_provider/asset_provider/file_extension_asset_provider_plugin.rs +++ b/crates/bevy_plugin/src/line_provider/asset_provider/file_extension_asset_provider_plugin.rs @@ -145,7 +145,10 @@ impl AssetProvider for FileExtensionAssetProvider { }; self.loading_handles.retain(|_path, handle| { - asset_server.get_load_state(handle.id()) != Some(LoadState::Failed) + !matches!( + asset_server.get_load_state(handle.id()), + Some(LoadState::Failed(..)) + ) }); let newly_loaded: HashMap<_, _> = self .loading_handles diff --git a/crates/bevy_plugin/src/localization/line_id_generation.rs b/crates/bevy_plugin/src/localization/line_id_generation.rs index 1f1936e4..725d7d64 100644 --- a/crates/bevy_plugin/src/localization/line_id_generation.rs +++ b/crates/bevy_plugin/src/localization/line_id_generation.rs @@ -108,7 +108,7 @@ fn handle_yarn_file_events( continue; } let asset_path = asset_server - .get_path(handle.clone()) + .get_path(handle.id()) .with_context(|| format!("Failed to overwrite Yarn file \"{}\" with new IDs because it was not found on disk", yarn_file.file_name()))?; let path = asset_root.0.join(asset_path.path()); diff --git a/crates/bevy_plugin/src/localization/strings_file/asset.rs b/crates/bevy_plugin/src/localization/strings_file/asset.rs index e20c833c..cb992af4 100644 --- a/crates/bevy_plugin/src/localization/strings_file/asset.rs +++ b/crates/bevy_plugin/src/localization/strings_file/asset.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use anyhow::{anyhow, bail}; -use bevy::asset::{io::Reader, AssetLoader, AsyncReadExt, BoxedFuture, LoadContext}; +use bevy::asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext}; use bevy::prelude::*; use bevy::reflect::TypePath; use bevy::utils::HashMap; @@ -23,20 +23,18 @@ impl AssetLoader for StringsFileAssetLoader { type Asset = StringsFile; type Settings = (); type Error = anyhow::Error; - fn load<'a>( + async fn load<'a>( &'a self, - reader: &'a mut Reader, + reader: &'a mut Reader<'_>, _settings: &'a (), - _load_context: &'a mut LoadContext, - ) -> BoxedFuture<'a, Result> { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - let mut csv_reader = csv::Reader::from_reader(bytes.as_slice()); - let records: csv::Result> = csv_reader.deserialize().collect(); - let strings_file = StringsFile::new_with_single_language(records?)?; - Ok(strings_file) - }) + _load_context: &'a mut LoadContext<'_>, + ) -> Result { + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + let mut csv_reader = csv::Reader::from_reader(bytes.as_slice()); + let records: csv::Result> = csv_reader.deserialize().collect(); + let strings_file = StringsFile::new_with_single_language(records?)?; + Ok(strings_file) } fn extensions(&self) -> &[&str] { diff --git a/crates/bevy_plugin/src/plugin.rs b/crates/bevy_plugin/src/plugin.rs index f41c6b11..2b78e60e 100644 --- a/crates/bevy_plugin/src/plugin.rs +++ b/crates/bevy_plugin/src/plugin.rs @@ -164,7 +164,7 @@ impl Plugin for YarnSpinnerPlugin { If you really want to load no Yarn files right now and do that later, use `YarnSpinnerPlugin::deferred()` instead.\ If you wanted to load from the default directory instead, use `YarnSpinnerPlugin::default()`."); app.add_plugins(Self::deferred()) - .world + .world_mut() .send_event(self.project.clone()); } } @@ -236,7 +236,10 @@ impl YarnApp for App { } fn register_watching_for_changes(&mut self) -> &mut Self { - let asset_server = self.world.get_resource::().expect(ASSET_ERROR); + let asset_server = self + .world() + .get_resource::() + .expect(ASSET_ERROR); let watching_for_changes = asset_server.watching_for_changes(); self.insert_resource(WatchingForChanges(watching_for_changes)) diff --git a/crates/bevy_plugin/tests/test_asset_provider.rs b/crates/bevy_plugin/tests/test_asset_provider.rs index 3bd4f6b7..63ff94d9 100644 --- a/crates/bevy_plugin/tests/test_asset_provider.rs +++ b/crates/bevy_plugin/tests/test_asset_provider.rs @@ -22,7 +22,7 @@ fn does_not_load_asset_without_localizations() -> Result<()> { .add_asset_provider(AudioAssetProvider::new()) .build(); dialogue_runner.start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_project(); let start = Instant::now(); @@ -61,7 +61,7 @@ fn does_not_load_invalid_asset_id() -> Result<()> { dialogue_runner .set_asset_language("en-US") .start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_lines(); @@ -89,13 +89,13 @@ fn loads_asset_from_base_language_localization() -> Result<()> { .add_asset_provider(AudioAssetProvider::new()) .build(); dialogue_runner.start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_lines(); let assets = app.dialogue_runner().get_assets_for_id("line:9"); assert_eq!(1, assets.len()); let asset: Handle = assets.get_handle().unwrap(); - let asset_server = app.world.resource::(); + let asset_server = app.world().resource::(); let path = asset_server.get_path(asset).unwrap(); // Note that this does not contain backslashes on Windows @@ -125,13 +125,13 @@ fn loads_asset_from_translated_localization() -> Result<()> { dialogue_runner .set_asset_language("de-CH") .start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_lines(); let assets = app.dialogue_runner().get_assets_for_id("line:10"); assert_eq!(1, assets.len()); let asset: Handle = assets.get_handle().unwrap(); - let asset_server = app.world.resource::(); + let asset_server = app.world().resource::(); let path = asset_server.get_path(asset).unwrap(); // Note that this does not contains backslashes on Windows @@ -161,7 +161,7 @@ fn panics_on_invalid_language() { dialogue_runner .set_asset_language("fr-FR") .start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_lines(); } @@ -187,7 +187,7 @@ fn does_not_load_asset_with_invalid_type() -> Result<()> { dialogue_runner .set_asset_language("en-US") .start_node("Start"); - app.world.spawn(dialogue_runner); + app.world_mut().spawn(dialogue_runner); app.load_lines(); diff --git a/crates/bevy_plugin/tests/test_dialogue_runner_delivers_lines.rs b/crates/bevy_plugin/tests/test_dialogue_runner_delivers_lines.rs index 717bb4ff..767a343b 100644 --- a/crates/bevy_plugin/tests/test_dialogue_runner_delivers_lines.rs +++ b/crates/bevy_plugin/tests/test_dialogue_runner_delivers_lines.rs @@ -289,10 +289,10 @@ fn setup_dialogue_runner_with_localizations(app: &mut App) -> Mut() - .single_mut(&mut app.world) + .single_mut(app.world_mut()) } fn english_lines() -> Vec { diff --git a/crates/bevy_plugin/tests/test_dialogue_runner_runs_commands.rs b/crates/bevy_plugin/tests/test_dialogue_runner_runs_commands.rs index 6078ee77..d174759e 100644 --- a/crates/bevy_plugin/tests/test_dialogue_runner_runs_commands.rs +++ b/crates/bevy_plugin/tests/test_dialogue_runner_runs_commands.rs @@ -68,7 +68,7 @@ fn executes_commands_and_fns() -> Result<()> { ]); app.continue_dialogue_and_update(); - let resource = app.world.resource::().0.as_str(); + let resource = app.world().resource::().0.as_str(); assert_eq!("foo", resource); assert_events!(asserter, app contains [ PresentLineEvent (n = 0), diff --git a/crates/bevy_plugin/tests/test_strings_tables.rs b/crates/bevy_plugin/tests/test_strings_tables.rs index 042298dd..f6175b39 100644 --- a/crates/bevy_plugin/tests/test_strings_tables.rs +++ b/crates/bevy_plugin/tests/test_strings_tables.rs @@ -20,7 +20,7 @@ fn loads_yarn_assets() { let yarn_files: Vec<_> = app.load_project().yarn_files().cloned().collect(); assert_eq!(1, yarn_files.len()); - let yarn_file_assets = app.world.get_resource::>().unwrap(); + let yarn_file_assets = app.world().get_resource::>().unwrap(); let yarn_file = yarn_file_assets.get(&yarn_files[0]).unwrap(); let expected_source = include_str!("../assets/lines.yarn"); @@ -65,7 +65,7 @@ fn generates_line_ids() -> anyhow::Result<()> { let yarn_file = app.load_project().yarn_files().next().unwrap().clone(); - let yarn_file_assets = app.world.get_resource::>().unwrap(); + let yarn_file_assets = app.world().get_resource::>().unwrap(); let yarn_file_in_app = yarn_file_assets.get(&yarn_file).unwrap(); let yarn_file_on_disk = fs::read_to_string(&yarn_path)?; @@ -169,10 +169,15 @@ fn appends_to_pre_existing_strings_file() -> anyhow::Result<()> { app.load_project(); let handle = app - .world + .world() .resource::() .load_untyped("dialogue/de-CH.strings.csv"); - while app.world.resource::().get_load_state(&handle) != Some(LoadState::Loaded) { + while app + .world() + .resource::() + .get_load_state(&handle) + != Some(LoadState::Loaded) + { app.update(); } @@ -224,10 +229,13 @@ fn replaces_entries_in_strings_file() -> anyhow::Result<()> { let strings_file_path = dir.path().join("dialogue/de-CH.strings.csv"); { - let project = app.world.resource::(); + let project = app.world().resource::(); let handle = project.yarn_files().next().unwrap().clone(); - let mut yarn_file_assets = app.world.get_resource_mut::>().unwrap(); + let mut yarn_file_assets = app + .world_mut() + .get_resource_mut::>() + .unwrap(); let yarn_file = yarn_file_assets.get_mut(&handle).unwrap(); let strings_file_source = @@ -243,7 +251,7 @@ fn replaces_entries_in_strings_file() -> anyhow::Result<()> { } while !app - .world + .world() .resource::>>() .is_empty() { diff --git a/crates/bevy_plugin/tests/utils/assertion.rs b/crates/bevy_plugin/tests/utils/assertion.rs index 40c6d6fb..08c4291b 100644 --- a/crates/bevy_plugin/tests/utils/assertion.rs +++ b/crates/bevy_plugin/tests/utils/assertion.rs @@ -21,21 +21,21 @@ impl EventAsserter { pub fn clear_events(&mut self, app: &mut App) { self.present_line_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.present_options_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.dialogue_start_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.dialogue_complete_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.node_start_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.node_complete_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.line_hints_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); self.execute_command_reader - .clear(app.world.resource::>()); + .clear(app.world().resource::>()); } } @@ -78,7 +78,7 @@ macro_rules! assert_events { assert_events!($asserter, $app contains $event (n = 1) $(with $pred)?); }; ($asserter:ident, $app:ident contains $event:ident (n = $num:expr) $(with $pred:expr)?) => { - let events = $app.world.resource::>(); + let events = $app.world().resource::>(); let reader = $crate::get_reader!($asserter, $event); let events: Vec<&$event> = reader.read(&events).collect(); assert_eq!($num, events.len(), "Expected {} events of type {}, but found {}: {events:#?}", stringify!($num), stringify!($event), events.len()); diff --git a/crates/bevy_plugin/tests/utils/mod.rs b/crates/bevy_plugin/tests/utils/mod.rs index afbeebba..1c83d89c 100644 --- a/crates/bevy_plugin/tests/utils/mod.rs +++ b/crates/bevy_plugin/tests/utils/mod.rs @@ -32,10 +32,6 @@ pub trait AppExt { fn dialogue_runner(&mut self) -> &DialogueRunner; #[must_use] fn dialogue_runner_mut(&mut self) -> Mut; - #[must_use] - fn try_dialogue_runner(&self) -> Option<&DialogueRunner>; - #[must_use] - fn try_dialogue_runner_mut(&mut self) -> Option>; fn setup_default_plugins(&mut self) -> &mut App; fn setup_default_plugins_for_path(&mut self, asset_folder: impl AsRef) -> &mut App; @@ -45,17 +41,17 @@ pub trait AppExt { impl AppExt for App { fn load_project(&mut self) -> &YarnProject { - while !self.world.contains_resource::() { + while !self.world().contains_resource::() { self.update(); } - self.world.resource::() + self.world().resource::() } fn load_project_mut(&mut self) -> Mut { - while !self.world.contains_resource::() { + while !self.world().contains_resource::() { self.update(); } - self.world.resource_mut::() + self.world_mut().resource_mut::() } fn load_lines(&mut self) -> &mut App { @@ -84,9 +80,9 @@ impl AppExt for App { fn dialogue_runner_entity(&mut self) -> Entity { let existing_entity = self - .world + .world() .iter_entities() - .filter(|e| self.world.get::(e.id()).is_some()) + .filter(|e| self.world().get::(e.id()).is_some()) .map(|e| e.id()) .next(); if let Some(entity) = existing_entity { @@ -94,32 +90,18 @@ impl AppExt for App { } else { let project = self.load_project(); let dialogue_runner = project.create_dialogue_runner(); - self.world.spawn(dialogue_runner).id() + self.world_mut().spawn(dialogue_runner).id() } } fn dialogue_runner(&mut self) -> &DialogueRunner { let entity = self.dialogue_runner_entity(); - self.world.get::(entity).unwrap() + self.world().get::(entity).unwrap() } fn dialogue_runner_mut(&mut self) -> Mut { let entity = self.dialogue_runner_entity(); - self.world.get_mut::(entity).unwrap() - } - - fn try_dialogue_runner(&self) -> Option<&DialogueRunner> { - self.world - .iter_entities() - .filter_map(|e| self.world.get::(e.id())) - .next() - } - - fn try_dialogue_runner_mut(&mut self) -> Option> { - self.world - .query::<&mut DialogueRunner>() - .iter_mut(&mut self.world) - .next() + self.world_mut().get_mut::(entity).unwrap() } fn setup_default_plugins(&mut self) -> &mut App { @@ -139,7 +121,7 @@ impl AppExt for App { } fn clone_loaded_untyped_assets(&self) -> Assets { - self.world + self.world() .resource::>() .iter() .map(|(_handle, asset)| LoadedUntypedAsset { @@ -152,6 +134,25 @@ impl AppExt for App { } } +pub trait WorldExt { + #[must_use] + fn try_dialogue_runner(&self) -> Option<&DialogueRunner>; + #[must_use] + fn try_dialogue_runner_mut(&mut self) -> Option>; +} + +impl WorldExt for World { + fn try_dialogue_runner(&self) -> Option<&DialogueRunner> { + self.iter_entities() + .filter_map(|e| self.get::(e.id())) + .next() + } + + fn try_dialogue_runner_mut(&mut self) -> Option> { + self.query::<&mut DialogueRunner>().iter_mut(self).next() + } +} + pub fn project_root_path() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")) } diff --git a/crates/example_dialogue_view/src/option_selection.rs b/crates/example_dialogue_view/src/option_selection.rs index c6922f7e..fafb95fe 100644 --- a/crates/example_dialogue_view/src/option_selection.rs +++ b/crates/example_dialogue_view/src/option_selection.rs @@ -1,6 +1,7 @@ use crate::setup::{spawn_options, DialogueNode, OptionButton, OptionsNode, UiRootNode}; use crate::typewriter::{self, Typewriter, TypewriterFinishedEvent}; use crate::ExampleYarnSpinnerDialogueViewSystemSet; +use bevy::color::palettes::css; use bevy::prelude::*; use bevy::utils::HashMap; use bevy::window::PrimaryWindow; @@ -107,10 +108,10 @@ fn select_option( let (color, icon) = match *interaction { Interaction::Pressed if selection.is_none() => { selection = Some(button.0); - (Color::TOMATO, CursorIcon::Default) + (css::TOMATO.into(), CursorIcon::Default) } Interaction::Hovered => (Color::WHITE, CursorIcon::Pointer), - _ => (Color::TOMATO, CursorIcon::Default), + _ => (css::TOMATO.into(), CursorIcon::Default), }; window.cursor.icon = icon; let text_entity = children.iter().find(|&e| text.contains(*e)).unwrap(); diff --git a/crates/example_dialogue_view/src/setup.rs b/crates/example_dialogue_view/src/setup.rs index a112aafe..4c113715 100644 --- a/crates/example_dialogue_view/src/setup.rs +++ b/crates/example_dialogue_view/src/setup.rs @@ -109,7 +109,7 @@ fn setup(mut commands: Commands) { padding: UiRect::horizontal(Val::Px(TEXT_BORDER)), ..default() }, - background_color: Color::BLACK.with_a(0.8).into(), + background_color: Color::BLACK.with_alpha(0.8).into(), ..default() }, )) @@ -235,7 +235,7 @@ where justify_content: JustifyContent::FlexStart, ..default() }, - background_color: Color::NONE.into(), + image: UiImage::default().with_color(Color::NONE), ..default() }, OptionButton(option.id), @@ -285,6 +285,7 @@ mod style { mod text_style { use super::*; + use bevy::color::palettes::css; pub(crate) fn standard() -> TextStyle { TextStyle { font: font_handle::MEDIUM, @@ -303,7 +304,7 @@ mod text_style { pub(crate) fn option_id() -> TextStyle { TextStyle { font: font_handle::MEDIUM, - color: Color::ALICE_BLUE, + color: css::ALICE_BLUE.into(), ..option_text() } } @@ -311,7 +312,7 @@ mod text_style { pub(crate) fn option_text() -> TextStyle { TextStyle { font_size: 18.0, - color: Color::TOMATO, + color: css::TOMATO.into(), ..standard() } } diff --git a/demo/src/main.rs b/demo/src/main.rs index 23481fad..7a5ee65c 100644 --- a/demo/src/main.rs +++ b/demo/src/main.rs @@ -3,6 +3,7 @@ use self::{setup::*, visual_effects::*, yarnspinner_integration::*}; use bevy::asset::{AssetMetaCheck, LoadState}; +use bevy::color::palettes::css; use bevy::prelude::*; use bevy::scene::SceneInstance; use bevy::window::PresentMode; @@ -17,9 +18,9 @@ mod yarnspinner_integration; fn main() { let mut app = App::new(); - app.insert_resource(AssetMetaCheck::Never) - .add_plugins(( - DefaultPlugins.set(WindowPlugin { + app.add_plugins(( + DefaultPlugins + .set(WindowPlugin { primary_window: Some(Window { title: "Yarn Spinner Story Demo".into(), resolution: (800., 600.).into(), @@ -29,35 +30,39 @@ fn main() { ..default() }), ..default() + }) + .set(AssetPlugin { + meta_check: AssetMetaCheck::Never, + ..default() }), - YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file("dialogue/story.yarn")), - ExampleYarnSpinnerDialogueViewPlugin::new(), - Sprite3dPlugin, - )) - .insert_resource(ClearColor(Color::CYAN)) - .add_systems(Startup, setup) - .add_systems( - Update, - ( - spawn_dialogue_runner.run_if(resource_added::), - adapt_materials.run_if(any_with_component::), - spawn_sprites.run_if(sprites_have_loaded), - ), - ) - .add_systems( - Update, - ( - handle_fade.run_if(resource_exists::), - move_camera.run_if(resource_exists::), - change_speaker, - bob_speaker, - rotate_sprite, - ease_bang.run_if(any_with_component::), - ) - .chain() - .after(ExampleYarnSpinnerDialogueViewSystemSet), + YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file("dialogue/story.yarn")), + ExampleYarnSpinnerDialogueViewPlugin::new(), + Sprite3dPlugin, + )) + .insert_resource(ClearColor(css::LIGHT_CYAN.into())) + .add_systems(Startup, setup) + .add_systems( + Update, + ( + spawn_dialogue_runner.run_if(resource_added::), + adapt_materials.run_if(any_with_component::), + spawn_sprites.run_if(sprites_have_loaded), + ), + ) + .add_systems( + Update, + ( + handle_fade.run_if(resource_exists::), + move_camera.run_if(resource_exists::), + change_speaker, + bob_speaker, + rotate_sprite, + ease_bang.run_if(any_with_component::), ) - .run(); + .chain() + .after(ExampleYarnSpinnerDialogueViewSystemSet), + ) + .run(); } #[derive(Resource)] diff --git a/demo/src/setup.rs b/demo/src/setup.rs index b5144661..15398a70 100644 --- a/demo/src/setup.rs +++ b/demo/src/setup.rs @@ -4,6 +4,7 @@ use crate::yarnspinner_integration::{ Speaker, }; use crate::{Sprites, CAMERA_TRANSLATION, CLIPPY_TRANSLATION, FERRIS_TRANSLATION}; +use bevy::color::palettes::css; #[cfg(not(target_arch = "wasm32"))] use bevy::core_pipeline::bloom::BloomSettings; use bevy::core_pipeline::tonemapping::Tonemapping; @@ -45,7 +46,7 @@ pub(crate) fn setup(mut commands: Commands, asset_server: Res) { }); commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { - color: Color::BISQUE, + color: css::BISQUE.into(), illuminance: light_consts::lux::OVERCAST_DAY, shadows_enabled: true, ..default() @@ -68,7 +69,7 @@ pub(crate) fn setup(mut commands: Commands, asset_server: Res) { ] { commands.spawn(PointLightBundle { point_light: PointLight { - color: Color::rgb(1.0, 0.78, 0.45), + color: Color::srgb(1.0, 0.78, 0.45), intensity: 10_000., shadows_enabled: true, ..default() @@ -94,7 +95,7 @@ pub(crate) fn setup(mut commands: Commands, asset_server: Res) { StageCurtains, )); commands.insert_resource(AmbientLight { - color: Color::rgb(1., 0.75, 0.7), + color: Color::srgb(1., 0.75, 0.7), brightness: 0.25, }); commands.insert_resource(Sprites { diff --git a/demo/src/visual_effects.rs b/demo/src/visual_effects.rs index 285cf35e..4b4b71a2 100644 --- a/demo/src/visual_effects.rs +++ b/demo/src/visual_effects.rs @@ -70,7 +70,7 @@ pub(crate) fn handle_fade( mut color: Query<&mut BackgroundColor, With>, ) { if fade.0.is_done() { - color.single_mut().0.set_a(fade.0.to); + color.single_mut().0.set_alpha(fade.0.to); commands.remove_resource::(); fade.0.set_done(); } else { @@ -81,7 +81,7 @@ pub(crate) fn handle_fade( fade.0.smooth_end() }; let alpha = fade.0.from + (fade.0.to - fade.0.from) * output; - color.single_mut().0.set_a(alpha); + color.single_mut().0.set_alpha(alpha); } } @@ -127,7 +127,7 @@ pub(crate) fn ease_bang( let material = standard_materials.get_mut(material).unwrap(); if bang.0.start_time.elapsed().as_secs_f32() >= bang.0.duration * 3.0 { commands.entity(entity).despawn_recursive(); - material.base_color.set_a(0.0); + material.base_color.set_alpha(0.0); continue; } let input = bang.0.input(); @@ -147,6 +147,6 @@ pub(crate) fn ease_bang( } else { final_alpha }; - material.base_color.set_a(alpha); + material.base_color.set_alpha(alpha); } } diff --git a/demo/src/yarnspinner_integration.rs b/demo/src/yarnspinner_integration.rs index bbc62ea2..6f8e40fd 100644 --- a/demo/src/yarnspinner_integration.rs +++ b/demo/src/yarnspinner_integration.rs @@ -104,7 +104,7 @@ pub(crate) fn fade_in( mut commands: Commands, color: Query<&BackgroundColor, With>, ) -> Arc { - let change = EasedChange::new(color.single().0.a(), 0.0, seconds); + let change = EasedChange::new(color.single().0.alpha(), 0.0, seconds); let done = change.done.clone(); commands.insert_resource(FadeCurtainAlpha(change)); @@ -116,7 +116,7 @@ pub(crate) fn fade_out( mut commands: Commands, color: Query<&BackgroundColor, With>, ) -> Arc { - let change = EasedChange::new(color.single().0.a(), 1.0, seconds); + let change = EasedChange::new(color.single().0.alpha(), 1.0, seconds); let done = change.done.clone(); commands.insert_resource(FadeCurtainAlpha(change)); @@ -124,7 +124,7 @@ pub(crate) fn fade_out( } pub(crate) fn quit(_: In<()>, mut app_exit_events: EventWriter) { - app_exit_events.send(AppExit); + app_exit_events.send(AppExit::Success); } pub(crate) fn move_camera_to_clippy(_: In<()>, mut commands: Commands) -> Arc {