diff --git a/amethyst_assets/examples/hl.rs b/amethyst_assets/examples/hl.rs index baf4d1ab39..d84f565bfb 100644 --- a/amethyst_assets/examples/hl.rs +++ b/amethyst_assets/examples/hl.rs @@ -9,11 +9,9 @@ use serde::{Deserialize, Serialize}; use amethyst_assets::*; use amethyst_core::{ - ecs::{ - prelude::{ - Builder, Dispatcher, DispatcherBuilder, Read, ReadExpect, System, VecStorage, World, WorldExt, - Write, - }, + ecs::prelude::{ + Builder, Dispatcher, DispatcherBuilder, Read, ReadExpect, System, VecStorage, World, + WorldExt, Write, }, Time, }; diff --git a/amethyst_assets/src/helper.rs b/amethyst_assets/src/helper.rs index 9ee8a598e1..132d1b4318 100644 --- a/amethyst_assets/src/helper.rs +++ b/amethyst_assets/src/helper.rs @@ -1,6 +1,9 @@ use std::{borrow::Borrow, hash::Hash}; -use amethyst_core::ecs::{Read, ReadExpect, World, shred::{SystemData, ResourceId}}; +use amethyst_core::ecs::{ + shred::{ResourceId, SystemData}, + Read, ReadExpect, World, +}; use crate::{Asset, AssetStorage, Format, Handle, Loader, Progress}; diff --git a/amethyst_assets/src/prefab/mod.rs b/amethyst_assets/src/prefab/mod.rs index 01794c854f..81ac914a4b 100644 --- a/amethyst_assets/src/prefab/mod.rs +++ b/amethyst_assets/src/prefab/mod.rs @@ -3,7 +3,8 @@ use std::marker::PhantomData; use serde::{Deserialize, Serialize}; use amethyst_core::ecs::prelude::{ - Component, DenseVecStorage, Entity, FlaggedStorage, Read, ReadExpect, SystemData, WriteStorage, World, ResourceId + Component, DenseVecStorage, Entity, FlaggedStorage, Read, ReadExpect, ResourceId, SystemData, + World, WriteStorage, }; use amethyst_error::Error; diff --git a/amethyst_assets/src/storage.rs b/amethyst_assets/src/storage.rs index 9f60103c4e..c595eef989 100644 --- a/amethyst_assets/src/storage.rs +++ b/amethyst_assets/src/storage.rs @@ -13,9 +13,9 @@ use rayon::ThreadPool; use amethyst_core::{ ecs::{ + hibitset::BitSet, prelude::{Component, Read, ReadExpect, System, VecStorage, Write}, storage::UnprotectedStorage, - hibitset::BitSet }, Time, }; diff --git a/amethyst_audio/src/output.rs b/amethyst_audio/src/output.rs index cf2075faad..080c407dd8 100644 --- a/amethyst_audio/src/output.rs +++ b/amethyst_audio/src/output.rs @@ -123,7 +123,8 @@ pub fn outputs() -> OutputIterator { /// Initialize default output pub fn init_output(world: &mut World) { if let Some(o) = default_output() { - world.entry::() + world + .entry::() .or_insert_with(|| AudioSink::new(&o)); world.entry::().or_insert_with(|| o); } else { diff --git a/amethyst_audio/src/systems/dj.rs b/amethyst_audio/src/systems/dj.rs index 84e44b0073..72323bf623 100644 --- a/amethyst_audio/src/systems/dj.rs +++ b/amethyst_audio/src/systems/dj.rs @@ -5,7 +5,7 @@ use thread_profiler::profile_scope; use amethyst_assets::AssetStorage; use amethyst_core::{ - ecs::prelude::{Read, System, World, WriteExpect, SystemData}, + ecs::prelude::{Read, System, SystemData, World, WriteExpect}, shred::Resource, }; diff --git a/amethyst_controls/src/systems.rs b/amethyst_controls/src/systems.rs index 1949dafd6f..0a683f8eed 100644 --- a/amethyst_controls/src/systems.rs +++ b/amethyst_controls/src/systems.rs @@ -136,9 +136,7 @@ impl FreeRotationSystem { pub fn new(mut world: &mut World, sensitivity_x: f32, sensitivity_y: f32) -> Self { use amethyst_core::ecs::prelude::SystemData; >::SystemData::setup(&mut world); - let event_reader = world - .fetch_mut::>() - .register_reader(); + let event_reader = world.fetch_mut::>().register_reader(); FreeRotationSystem { sensitivity_x, sensitivity_y, @@ -191,9 +189,7 @@ impl MouseFocusUpdateSystem { pub fn new(mut world: &mut World) -> MouseFocusUpdateSystem { use amethyst_core::ecs::prelude::SystemData; >::SystemData::setup(&mut world); - let event_reader = world - .fetch_mut::>() - .register_reader(); + let event_reader = world.fetch_mut::>().register_reader(); Self { event_reader } } } diff --git a/amethyst_core/src/event.rs b/amethyst_core/src/event.rs index 7e8667c452..18c8d858ad 100644 --- a/amethyst_core/src/event.rs +++ b/amethyst_core/src/event.rs @@ -24,7 +24,7 @@ pub trait EventReader<'a> { #[cfg(test)] mod tests { use crate::ecs::Read; - use shrev::{EventChannel, ReaderId}; + use crate::shrev::{EventChannel, ReaderId}; use super::*; diff --git a/amethyst_core/src/lib.rs b/amethyst_core/src/lib.rs index 70acad731a..384df5bfcb 100644 --- a/amethyst_core/src/lib.rs +++ b/amethyst_core/src/lib.rs @@ -20,9 +20,9 @@ pub use alga; pub use approx; pub use nalgebra as math; pub use num_traits as num; +pub use specs as ecs; pub use specs::shred; pub use specs::shrev; -pub use specs as ecs; use rayon; diff --git a/amethyst_core/src/transform/systems.rs b/amethyst_core/src/transform/systems.rs index 606cbe93fd..fc75477696 100644 --- a/amethyst_core/src/transform/systems.rs +++ b/amethyst_core/src/transform/systems.rs @@ -1,10 +1,11 @@ //! Scene graph system and types use crate::ecs::{ + hibitset::BitSet, prelude::{ - ComponentEvent, Entities, Join, ReadExpect, ReadStorage, ReaderId, System, World, WriteStorage, + ComponentEvent, Entities, Join, ReadExpect, ReadStorage, ReaderId, System, World, + WriteStorage, }, - hibitset::BitSet, }; use crate::transform::{HierarchyEvent, Parent, ParentHierarchy, Transform}; @@ -126,12 +127,11 @@ impl<'a> System<'a> for TransformSystem { mod tests { use crate::{ ecs::{ + prelude::{Builder, World, WorldExt}, shred::RunNow, - prelude::{Builder, World}, }, math::{Matrix4, Quaternion, Unit, Vector3}, }; - use shred::RunNow; use specs_hierarchy::{Hierarchy, HierarchySystem}; use crate::transform::{Parent, Transform, TransformSystem}; @@ -154,7 +154,7 @@ mod tests { fn transform_world() -> (World, HierarchySystem, TransformSystem) { let mut world = World::new(); let mut hs = HierarchySystem::::new(); - let mut ts = TransformSystem::new(); + let mut ts = TransformSystem::new(&mut world); hs.setup(&mut world); ts.setup(&mut world); diff --git a/amethyst_derive/tests/test.rs b/amethyst_derive/tests/test.rs index 5af12f9146..87aa706f15 100644 --- a/amethyst_derive/tests/test.rs +++ b/amethyst_derive/tests/test.rs @@ -7,7 +7,7 @@ use amethyst_derive::{EventReader, PrefabData}; use amethyst_assets::{PrefabData, ProgressCounter}; use amethyst_core::{ - ecs::{Component, DenseVecStorage, Entity, Read, World, SystemData, WriteStorage}, + ecs::{Component, DenseVecStorage, Entity, Read, SystemData, World, WriteStorage}, shrev::{EventChannel, ReaderId}, EventReader, }; diff --git a/amethyst_input/src/sdl_events_system.rs b/amethyst_input/src/sdl_events_system.rs index 3c15e8561e..b54c4902e8 100644 --- a/amethyst_input/src/sdl_events_system.rs +++ b/amethyst_input/src/sdl_events_system.rs @@ -8,7 +8,7 @@ use sdl2::{ }; use amethyst_core::{ - ecs::prelude::{World, RunNow, SystemData, Write}, + ecs::prelude::{RunNow, SystemData, World, Write}, shrev::EventChannel, }; diff --git a/amethyst_input/src/system.rs b/amethyst_input/src/system.rs index e2ceb91f96..66dfa88df2 100644 --- a/amethyst_input/src/system.rs +++ b/amethyst_input/src/system.rs @@ -26,16 +26,11 @@ impl InputSystem { pub fn new(mut world: &mut World, bindings: Option>) -> Self { use amethyst_core::ecs::prelude::SystemData; >::SystemData::setup(&mut world); - let reader = world - .fetch_mut::>() - .register_reader(); + let reader = world.fetch_mut::>().register_reader(); if let Some(ref bindings) = bindings { world.fetch_mut::>().bindings = bindings.clone(); } - InputSystem { - reader, - bindings, - } + InputSystem { reader, bindings } } fn process_event( diff --git a/amethyst_rendy/src/pass/base_3d.rs b/amethyst_rendy/src/pass/base_3d.rs index edf8b5098b..50d9beef85 100644 --- a/amethyst_rendy/src/pass/base_3d.rs +++ b/amethyst_rendy/src/pass/base_3d.rs @@ -13,7 +13,7 @@ use crate::{ }; use amethyst_assets::{AssetStorage, Handle}; use amethyst_core::{ - ecs::{Join, Read, ReadExpect, ReadStorage, World, SystemData}, + ecs::{Join, Read, ReadExpect, ReadStorage, SystemData, World}, transform::Transform, Hidden, HiddenPropagate, }; diff --git a/amethyst_rendy/src/pass/debug_lines.rs b/amethyst_rendy/src/pass/debug_lines.rs index 406075fe4e..a506df4e71 100644 --- a/amethyst_rendy/src/pass/debug_lines.rs +++ b/amethyst_rendy/src/pass/debug_lines.rs @@ -6,7 +6,7 @@ use crate::{ types::Backend, util, }; -use amethyst_core::ecs::{Join, Read, World, SystemData, Write, WriteStorage}; +use amethyst_core::ecs::{Join, Read, SystemData, World, Write, WriteStorage}; use derivative::Derivative; use glsl_layout::*; use rendy::{ diff --git a/amethyst_rendy/src/pass/flat2d.rs b/amethyst_rendy/src/pass/flat2d.rs index 172116f39e..9c98c2f659 100644 --- a/amethyst_rendy/src/pass/flat2d.rs +++ b/amethyst_rendy/src/pass/flat2d.rs @@ -11,7 +11,7 @@ use crate::{ }; use amethyst_assets::AssetStorage; use amethyst_core::{ - ecs::{Join, Read, ReadExpect, ReadStorage, World, SystemData}, + ecs::{Join, Read, ReadExpect, ReadStorage, SystemData, World}, transform::Transform, Hidden, HiddenPropagate, }; diff --git a/amethyst_rendy/src/pass/skybox.rs b/amethyst_rendy/src/pass/skybox.rs index 18a553f8fc..a679f8d07b 100644 --- a/amethyst_rendy/src/pass/skybox.rs +++ b/amethyst_rendy/src/pass/skybox.rs @@ -7,7 +7,7 @@ use crate::{ types::Backend, util, }; -use amethyst_core::ecs::{Read, World, SystemData}; +use amethyst_core::ecs::{Read, SystemData, World}; use derivative::Derivative; use glsl_layout::{vec3, AsStd140}; use rendy::{ diff --git a/amethyst_rendy/src/render_test_bundle.rs b/amethyst_rendy/src/render_test_bundle.rs index 6a7191b09a..59104796cb 100644 --- a/amethyst_rendy/src/render_test_bundle.rs +++ b/amethyst_rendy/src/render_test_bundle.rs @@ -3,7 +3,7 @@ use std::{marker::PhantomData, ops::Deref, sync::Arc}; use amethyst_assets::Processor; use amethyst_core::{ bundle::SystemBundle, - ecs::{DispatcherBuilder, ReadExpect, World, SystemData}, + ecs::{DispatcherBuilder, ReadExpect, SystemData, World}, }; use amethyst_error::Error; use amethyst_window::{ScreenDimensions, Window}; @@ -185,11 +185,7 @@ where false } - fn builder( - &mut self, - _factory: &mut Factory, - _world: &World, - ) -> GraphBuilder { + fn builder(&mut self, _factory: &mut Factory, _world: &World) -> GraphBuilder { GraphBuilder::new() } } diff --git a/amethyst_rendy/src/shape.rs b/amethyst_rendy/src/shape.rs index a1927aee5f..fef2784393 100644 --- a/amethyst_rendy/src/shape.rs +++ b/amethyst_rendy/src/shape.rs @@ -3,8 +3,8 @@ use crate::types::Mesh; use amethyst_assets::{AssetStorage, Handle, Loader, PrefabData, Progress, ProgressCounter}; use amethyst_core::{ ecs::{ - shred::{SystemData, ResourceId}, - prelude::{Entity, Read, ReadExpect, WriteStorage, World}, + prelude::{Entity, Read, ReadExpect, World, WriteStorage}, + shred::{ResourceId, SystemData}, }, math::Vector3, }; diff --git a/amethyst_rendy/src/sprite/prefab.rs b/amethyst_rendy/src/sprite/prefab.rs index 37328914dc..861b348c9f 100644 --- a/amethyst_rendy/src/sprite/prefab.rs +++ b/amethyst_rendy/src/sprite/prefab.rs @@ -261,7 +261,7 @@ mod tests { Texture, }; use amethyst_assets::{Handle, Loader}; - use amethyst_core::ecs::{Builder, Read, ReadExpect, World}; + use amethyst_core::ecs::{Builder, Read, ReadExpect, World, WorldExt}; use rayon::ThreadPoolBuilder; use std::sync::Arc; diff --git a/amethyst_rendy/src/sprite_visibility.rs b/amethyst_rendy/src/sprite_visibility.rs index d35f2b520b..481c722715 100644 --- a/amethyst_rendy/src/sprite_visibility.rs +++ b/amethyst_rendy/src/sprite_visibility.rs @@ -5,8 +5,8 @@ use crate::{ }; use amethyst_core::{ ecs::{ + hibitset::BitSet, prelude::{Entities, Entity, Join, Read, ReadStorage, System, Write}, - hibitset::BitSet, }, math::{Point3, Vector3}, Hidden, HiddenPropagate, Transform, diff --git a/amethyst_rendy/src/submodules/environment.rs b/amethyst_rendy/src/submodules/environment.rs index 9c1bd86fab..21775391ae 100644 --- a/amethyst_rendy/src/submodules/environment.rs +++ b/amethyst_rendy/src/submodules/environment.rs @@ -15,7 +15,7 @@ use crate::{ util::{self, TapCountIter}, }; use amethyst_core::{ - ecs::{Join, ReadStorage, World, SystemData}, + ecs::{Join, ReadStorage, SystemData, World}, math::{convert, Vector3}, transform::Transform, }; diff --git a/amethyst_rendy/src/submodules/gather.rs b/amethyst_rendy/src/submodules/gather.rs index 82741b322d..3b8ce9561b 100644 --- a/amethyst_rendy/src/submodules/gather.rs +++ b/amethyst_rendy/src/submodules/gather.rs @@ -5,7 +5,7 @@ use crate::{ resources::AmbientColor, }; use amethyst_core::{ - ecs::{Join, Read, ReadExpect, ReadStorage, World, SystemData}, + ecs::{Join, Read, ReadExpect, ReadStorage, SystemData, World}, math::{convert, Matrix4, Vector3}, transform::Transform, }; diff --git a/amethyst_rendy/src/submodules/material.rs b/amethyst_rendy/src/submodules/material.rs index 98a301a646..516dbe3d81 100644 --- a/amethyst_rendy/src/submodules/material.rs +++ b/amethyst_rendy/src/submodules/material.rs @@ -15,7 +15,7 @@ use crate::{ util, }; use amethyst_assets::{AssetStorage, Handle}; -use amethyst_core::ecs::{Read, World, SystemData}; +use amethyst_core::ecs::{Read, SystemData, World}; use glsl_layout::*; #[cfg(feature = "profiler")] diff --git a/amethyst_rendy/src/submodules/texture.rs b/amethyst_rendy/src/submodules/texture.rs index 35b2beff02..b593ca3595 100644 --- a/amethyst_rendy/src/submodules/texture.rs +++ b/amethyst_rendy/src/submodules/texture.rs @@ -10,7 +10,7 @@ use crate::{ util, }; use amethyst_assets::{AssetStorage, Handle}; -use amethyst_core::ecs::{Read, World, SystemData}; +use amethyst_core::ecs::{Read, SystemData, World}; #[cfg(feature = "profiler")] use thread_profiler::profile_scope; diff --git a/amethyst_rendy/src/system.rs b/amethyst_rendy/src/system.rs index 531ff82ae5..f18420c149 100644 --- a/amethyst_rendy/src/system.rs +++ b/amethyst_rendy/src/system.rs @@ -16,7 +16,7 @@ use amethyst_assets::{ }; use amethyst_core::{ components::Transform, - ecs::{Read, ReadExpect, ReadStorage, World, RunNow, SystemData, Write, WriteExpect}, + ecs::{Read, ReadExpect, ReadStorage, RunNow, SystemData, World, Write, WriteExpect}, timing::Time, Hidden, HiddenPropagate, }; diff --git a/amethyst_rendy/src/visibility.rs b/amethyst_rendy/src/visibility.rs index 5f67807d2c..d5f2cf3a58 100644 --- a/amethyst_rendy/src/visibility.rs +++ b/amethyst_rendy/src/visibility.rs @@ -5,11 +5,11 @@ use crate::{ }; use amethyst_core::{ ecs::{ + hibitset::BitSet, prelude::{ - Component, DenseVecStorage, Entities, Entity, Join, Read, ReadExpect, ReadStorage, System, - Write, + Component, DenseVecStorage, Entities, Entity, Join, Read, ReadExpect, ReadStorage, + System, Write, }, - hibitset::BitSet, }, math::{convert, distance_squared, Matrix4, Point3, Vector4}, Hidden, HiddenPropagate, Transform, diff --git a/amethyst_test/src/amethyst_application.rs b/amethyst_test/src/amethyst_application.rs index 4168087121..56fcc8cbd5 100644 --- a/amethyst_test/src/amethyst_application.rs +++ b/amethyst_test/src/amethyst_application.rs @@ -91,6 +91,9 @@ where state_fns: Vec>, /// Game data and event type. state_data: PhantomData<(T, E, R)>, + /// World used for setup. + #[derivative(Debug = "ignore")] + world: World, } impl AmethystApplication, StateEvent, StateEventReader> { @@ -102,6 +105,7 @@ impl AmethystApplication, StateEvent, StateEventReade resource_add_fns: Vec::new(), state_fns: Vec::new(), state_data: PhantomData, + world: World::new(), } } @@ -137,7 +141,7 @@ where for<'b> R: EventReader<'b, Event = E>, { let params = (self.bundle_add_fns, self.resource_add_fns, self.state_fns); - Self::build_internal(params) + Self::build_internal(params, self.world) } // Hack to get around `S` or `T` not being `Send` @@ -154,6 +158,7 @@ where Vec, Vec, E>>, ), + world: World, ) -> Result, E, R>, Error> where for<'b> R: EventReader<'b, Event = E>, @@ -170,20 +175,26 @@ where .into_iter() .rev() .for_each(|state_fn| states.push(state_fn.call())); - Self::build_application(SequencerState::new(states), game_data, resource_add_fns) + Self::build_application( + SequencerState::new(states), + game_data, + resource_add_fns, + world, + ) } fn build_application( first_state: S, game_data: GameDataBuilder<'static, 'static>, resource_add_fns: Vec, + world: World, ) -> Result, E, R>, Error> where S: State, E> + 'static, for<'b> R: EventReader<'b, Event = E>, { let mut application_builder = - CoreApplication::build(AmethystApplication::assets_dir()?, first_state)?; + CoreApplication::build(AmethystApplication::assets_dir()?, first_state, world)?; { let world = &mut application_builder.world; for mut function in resource_add_fns { @@ -202,7 +213,7 @@ where // `CoreApplication` is `!UnwindSafe`, but wrapping it in a `Mutex` allows us to // recover from a panic. - let application = Mutex::new(Self::build_internal(params)?); + let application = Mutex::new(Self::build_internal(params, self.world)?); panic::catch_unwind(move || { application .lock() @@ -283,6 +294,7 @@ where resource_add_fns: self.resource_add_fns, state_fns: Vec::new(), state_data: PhantomData, + world: self.world, } } @@ -313,7 +325,9 @@ where // // See self.bundle_add_fns.push(SendBoxFnOnce::from( - |game_data: GameDataBuilder<'static, 'static>| game_data.with_bundle(bundle), + |game_data: GameDataBuilder<'static, 'static>| { + game_data.with_bundle(&mut self.world, bundle) + }, )); self } @@ -333,7 +347,7 @@ where { self.bundle_add_fns.push(SendBoxFnOnce::from( move |game_data: GameDataBuilder<'static, 'static>| { - game_data.with_bundle(bundle_function()) + game_data.with_bundle(&mut self.world, bundle_function()) }, )); self @@ -1065,7 +1079,11 @@ mod test { #[derive(Debug)] struct BundleZero; impl<'a, 'b> SystemBundle<'a, 'b> for BundleZero { - fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> { + fn build( + self, + _world: &mut World, + builder: &mut DispatcherBuilder<'a, 'b>, + ) -> Result<(), Error> { builder.add(SystemZero, "system_zero", &[]); Ok(()) } @@ -1074,7 +1092,11 @@ mod test { #[derive(Debug)] struct BundleOne; impl<'a, 'b> SystemBundle<'a, 'b> for BundleOne { - fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> { + fn build( + self, + _world: &mut World, + builder: &mut DispatcherBuilder<'a, 'b>, + ) -> Result<(), Error> { builder.add(SystemOne, "system_one", &["system_zero"]); builder.add(SystemNonDefault, "system_non_default", &[]); Ok(()) @@ -1084,7 +1106,11 @@ mod test { #[derive(Debug)] struct BundleAsset; impl<'a, 'b> SystemBundle<'a, 'b> for BundleAsset { - fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> { + fn build( + self, + _world: &mut World, + builder: &mut DispatcherBuilder<'a, 'b>, + ) -> Result<(), Error> { builder.add( Processor::::new(), "asset_translation_zero_processor", diff --git a/amethyst_test/src/system_injection_bundle.rs b/amethyst_test/src/system_injection_bundle.rs index 7bc1680947..1178dea88e 100644 --- a/amethyst_test/src/system_injection_bundle.rs +++ b/amethyst_test/src/system_injection_bundle.rs @@ -25,7 +25,11 @@ impl<'a, 'b, Sys> SystemBundle<'a, 'b> for SystemInjectionBundle<'a, Sys> where Sys: for<'s> System<'s> + Send + 'a, { - fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> { + fn build( + self, + _world: &mut World, + builder: &mut DispatcherBuilder<'a, 'b>, + ) -> Result<(), Error> { builder.add( self.system, &self.system_name, diff --git a/amethyst_test/src/thread_local_injection_bundle.rs b/amethyst_test/src/thread_local_injection_bundle.rs index 2e61c67359..daede91171 100644 --- a/amethyst_test/src/thread_local_injection_bundle.rs +++ b/amethyst_test/src/thread_local_injection_bundle.rs @@ -20,7 +20,11 @@ impl<'a, 'b, Sys> SystemBundle<'a, 'b> for ThreadLocalInjectionBundle where Sys: for<'s> RunNow<'s> + 'b, { - fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> { + fn build( + self, + _world: &mut World, + builder: &mut DispatcherBuilder<'a, 'b>, + ) -> Result<(), Error> { builder.add_thread_local(self.system); Ok(()) } diff --git a/amethyst_ui/src/button/builder.rs b/amethyst_ui/src/button/builder.rs index 8c10749ef3..fd577d67bc 100644 --- a/amethyst_ui/src/button/builder.rs +++ b/amethyst_ui/src/button/builder.rs @@ -4,8 +4,8 @@ use amethyst_assets::{AssetStorage, Handle, Loader}; use amethyst_audio::SourceHandle; use amethyst_core::{ ecs::{ - shred::{SystemData, ResourceId}, prelude::{Entities, Entity, Read, ReadExpect, World, WriteExpect, WriteStorage}, + shred::{ResourceId, SystemData}, }, Parent, }; diff --git a/amethyst_ui/src/event_retrigger.rs b/amethyst_ui/src/event_retrigger.rs index 05d6b15088..9bcae1bff9 100644 --- a/amethyst_ui/src/event_retrigger.rs +++ b/amethyst_ui/src/event_retrigger.rs @@ -58,9 +58,7 @@ where /// always be used to construct `EventRetriggerSystem`s. pub fn new(mut world: &mut World) -> Self { >::SystemData::setup(&mut world); - let event_reader = world - .fetch_mut::>() - .register_reader(); + let event_reader = world.fetch_mut::>().register_reader(); Self { event_reader } } } diff --git a/amethyst_ui/src/glyphs.rs b/amethyst_ui/src/glyphs.rs index 43b20cb06c..0f8c1241ca 100644 --- a/amethyst_ui/src/glyphs.rs +++ b/amethyst_ui/src/glyphs.rs @@ -7,8 +7,8 @@ use crate::{ use amethyst_assets::{AssetStorage, Handle}; use amethyst_core::{ ecs::{ - Component, DenseVecStorage, Entities, Join, Read, ReadStorage, System, - SystemData, World, Write, WriteExpect, WriteStorage, + Component, DenseVecStorage, Entities, Join, Read, ReadStorage, System, SystemData, World, + Write, WriteExpect, WriteStorage, }, Hidden, HiddenPropagate, }; diff --git a/amethyst_ui/src/label.rs b/amethyst_ui/src/label.rs index 2f0a56b013..30d0ee62f0 100644 --- a/amethyst_ui/src/label.rs +++ b/amethyst_ui/src/label.rs @@ -5,10 +5,8 @@ use crate::{ use amethyst_assets::{AssetStorage, Loader}; use amethyst_core::ecs::{ - shred::{SystemData, ResourceId}, - prelude::{ - Entities, Entity, Read, ReadExpect, World, WriteExpect, WriteStorage, - }, + prelude::{Entities, Entity, Read, ReadExpect, World, WriteExpect, WriteStorage}, + shred::{ResourceId, SystemData}, }; const DEFAULT_Z: f32 = 1.0; diff --git a/amethyst_ui/src/pass.rs b/amethyst_ui/src/pass.rs index 0d4e2d5b0a..454c2b60bf 100644 --- a/amethyst_ui/src/pass.rs +++ b/amethyst_ui/src/pass.rs @@ -4,7 +4,9 @@ use crate::{ }; use amethyst_assets::{AssetStorage, Handle, Loader}; use amethyst_core::{ - ecs::{hibitset::BitSet, Entities, Entity, Join, Read, ReadExpect, ReadStorage, World, SystemData}, + ecs::{ + hibitset::BitSet, Entities, Entity, Join, Read, ReadExpect, ReadStorage, SystemData, World, + }, Hidden, HiddenPropagate, }; use amethyst_rendy::{ diff --git a/amethyst_ui/src/prefab.rs b/amethyst_ui/src/prefab.rs index bdb778cec5..0ad0cb97db 100644 --- a/amethyst_ui/src/prefab.rs +++ b/amethyst_ui/src/prefab.rs @@ -12,8 +12,8 @@ use amethyst_assets::{ use amethyst_audio::Source as Audio; use amethyst_core::{ ecs::{ - shred::{SystemData, ResourceId}, - prelude::{Entities, Entity, Read, ReadExpect, Write, WriteStorage, World}, + prelude::{Entities, Entity, Read, ReadExpect, World, Write, WriteStorage}, + shred::{ResourceId, SystemData}, }, HiddenPropagate, }; diff --git a/amethyst_ui/src/resize.rs b/amethyst_ui/src/resize.rs index 8b7ba38910..627d48f8af 100644 --- a/amethyst_ui/src/resize.rs +++ b/amethyst_ui/src/resize.rs @@ -1,7 +1,7 @@ use amethyst_core::{ ecs::prelude::{ - BitSet, Component, ComponentEvent, FlaggedStorage, Join, ReadExpect, System, - World, WriteStorage, + BitSet, Component, ComponentEvent, FlaggedStorage, Join, ReadExpect, System, World, + WriteStorage, }, shrev::ReaderId, }; diff --git a/amethyst_ui/src/selection.rs b/amethyst_ui/src/selection.rs index d445fbc1e2..7cf5e23376 100644 --- a/amethyst_ui/src/selection.rs +++ b/amethyst_ui/src/selection.rs @@ -68,9 +68,7 @@ where /// Creates a new `SelectionKeyboardSystem`. pub fn new(mut world: &mut World) -> Self { >::SystemData::setup(&mut world); - let window_reader_id = world - .fetch_mut::>() - .register_reader(); + let window_reader_id = world.fetch_mut::>().register_reader(); Self { window_reader_id, phantom: PhantomData, @@ -189,9 +187,7 @@ where /// Creates a new `SelectionMouseSystem`. pub fn new(mut world: &mut World) -> Self { >::SystemData::setup(&mut world); - let ui_reader_id = world - .fetch_mut::>() - .register_reader(); + let ui_reader_id = world.fetch_mut::>().register_reader(); Self { ui_reader_id, phantom: PhantomData, diff --git a/amethyst_ui/src/selection_order_cache.rs b/amethyst_ui/src/selection_order_cache.rs index 42b9e85286..6fd382a411 100644 --- a/amethyst_ui/src/selection_order_cache.rs +++ b/amethyst_ui/src/selection_order_cache.rs @@ -1,5 +1,6 @@ use amethyst_core::ecs::{ - hibitset::BitSet, storage::GenericReadStorage, Entities, Entity, Join, ReadStorage, System, Write, + hibitset::BitSet, storage::GenericReadStorage, Entities, Entity, Join, ReadStorage, System, + Write, }; use derive_new::new; use std::{cmp::Ordering, marker::PhantomData}; diff --git a/amethyst_ui/src/text.rs b/amethyst_ui/src/text.rs index be19c0c9d3..4fadde259b 100644 --- a/amethyst_ui/src/text.rs +++ b/amethyst_ui/src/text.rs @@ -150,9 +150,7 @@ impl TextEditingMouseSystem { pub fn new(mut world: &mut World) -> Self { use amethyst_core::ecs::prelude::SystemData; >::SystemData::setup(&mut world); - let reader = world - .fetch_mut::>() - .register_reader(); + let reader = world.fetch_mut::>().register_reader(); Self { reader, left_mouse_button_pressed: false, diff --git a/amethyst_ui/src/text_editing.rs b/amethyst_ui/src/text_editing.rs index 76d5fcf199..e25ae9851f 100644 --- a/amethyst_ui/src/text_editing.rs +++ b/amethyst_ui/src/text_editing.rs @@ -8,9 +8,7 @@ use winit::{ElementState, Event, KeyboardInput, ModifiersState, VirtualKeyCode, use crate::{LineMode, Selected, TextEditing, UiEvent, UiEventType, UiText}; use amethyst_core::{ - ecs::prelude::{ - Entities, Join, Read, ReadStorage, System, World, Write, WriteStorage, - }, + ecs::prelude::{Entities, Join, Read, ReadStorage, System, World, Write, WriteStorage}, shrev::{EventChannel, ReaderId}, }; @@ -30,9 +28,7 @@ impl TextEditingInputSystem { pub fn new(mut world: &mut World) -> Self { use amethyst_core::ecs::prelude::SystemData; >::SystemData::setup(&mut world); - let reader = world - .fetch_mut::>() - .register_reader(); + let reader = world.fetch_mut::>().register_reader(); Self { reader } } } diff --git a/amethyst_ui/src/transform.rs b/amethyst_ui/src/transform.rs index 1b2fe1bd80..011d4214a0 100644 --- a/amethyst_ui/src/transform.rs +++ b/amethyst_ui/src/transform.rs @@ -4,7 +4,7 @@ use amethyst_core::ecs::{ prelude::{ Component, DenseVecStorage, Entities, Entity, FlaggedStorage, Join, ReadStorage, World, }, - shred::{SystemData, ResourceId}, + shred::{ResourceId, SystemData}, }; use serde::{Deserialize, Serialize}; diff --git a/amethyst_utils/Cargo.toml b/amethyst_utils/Cargo.toml index 99ee740025..f32a2d06e5 100644 --- a/amethyst_utils/Cargo.toml +++ b/amethyst_utils/Cargo.toml @@ -24,8 +24,6 @@ amethyst_derive = { path = "../amethyst_derive", version = "0.4.0" } amethyst_rendy = { path = "../amethyst_rendy", version = "0.1.0" } amethyst_window = { path = "../amethyst_window", version = "0.1.0" } log = "0.4.6" -shred-derive = "0.5" -shred = "0.7" serde = { version = "1.0", features = ["derive"] } specs-derive = "0.4.0" specs-hierarchy = { version = "0.3" } diff --git a/amethyst_utils/src/tag.rs b/amethyst_utils/src/tag.rs index c08ac205dd..95714ac9cd 100644 --- a/amethyst_utils/src/tag.rs +++ b/amethyst_utils/src/tag.rs @@ -3,14 +3,14 @@ use std::marker::PhantomData; use amethyst_assets::PrefabData; -use amethyst_core::ecs::prelude::{ - Component, Entities, Entity, Join, NullStorage, ReadStorage, WriteStorage, +use amethyst_core::ecs::{ + shred::{ResourceId, SystemData}, + Component, Entities, Entity, Join, NullStorage, ReadStorage, World, WriteStorage, }; use amethyst_derive::PrefabData; use amethyst_error::Error; use serde::{Deserialize, Serialize}; -use shred_derive::SystemData; /// Tag component that can be used with a custom type to tag entities for processing #[derive(Clone, Debug, Serialize, Deserialize, PrefabData)] diff --git a/examples/animation/main.rs b/examples/animation/main.rs index e53a8aa6b2..bcfe86d90a 100644 --- a/examples/animation/main.rs +++ b/examples/animation/main.rs @@ -314,7 +314,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/arc_ball_camera/main.rs b/examples/arc_ball_camera/main.rs index a007f2ec49..a049914ee0 100644 --- a/examples/arc_ball_camera/main.rs +++ b/examples/arc_ball_camera/main.rs @@ -68,7 +68,7 @@ struct CameraDistanceSystem { } impl CameraDistanceSystem { - pub fn new(world: &mut World) -> Self { + pub fn new(mut world: &mut World) -> Self { >::SystemData::setup(&mut world); let event_reader = world .fetch_mut::>>() @@ -160,7 +160,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = *new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/asset_loading/main.rs b/examples/asset_loading/main.rs index 55b9e8818c..8b6aef9f13 100644 --- a/examples/asset_loading/main.rs +++ b/examples/asset_loading/main.rs @@ -4,7 +4,7 @@ use amethyst::{ assets::{Format as AssetFormat, Handle, Loader}, core::{math::Vector3, Transform, TransformBundle}, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, error::Error, input::{InputBundle, StringBindings}, prelude::*, @@ -196,7 +196,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/auto_fov/main.rs b/examples/auto_fov/main.rs index 7072a55fdc..062d5f5c3e 100644 --- a/examples/auto_fov/main.rs +++ b/examples/auto_fov/main.rs @@ -5,7 +5,7 @@ use amethyst::{ }, core::{Transform, TransformBundle}, derive::PrefabData, - ecs::{Entity, ReadExpect, ReadStorage, World, System, WorldExt, WriteStorage}, + ecs::{Entity, ReadExpect, ReadStorage, System, World, WorldExt, WriteStorage}, input::{is_close_requested, is_key_down, InputBundle, StringBindings}, prelude::{ Application, Builder, GameData, GameDataBuilder, SimpleState, SimpleTrans, StateData, @@ -241,7 +241,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.cloned(); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/custom_game_data/game_data.rs b/examples/custom_game_data/game_data.rs index 9ef55a22e6..0f58650b77 100644 --- a/examples/custom_game_data/game_data.rs +++ b/examples/custom_game_data/game_data.rs @@ -24,7 +24,7 @@ impl<'a, 'b> CustomGameData<'a, 'b> { } /// Dispose game data, dropping the dispatcher - pub fn dispose(&mut self, world: &mut World) { + pub fn dispose(&mut self, mut world: &mut World) { if let Some(base) = self.base.take() { base.dispose(&mut world); } @@ -92,20 +92,25 @@ impl<'a, 'b> CustomGameDataBuilder<'a, 'b> { } impl<'a, 'b> DataInit> for CustomGameDataBuilder<'a, 'b> { - fn build(self, world: &mut World) -> CustomGameData<'a, 'b> { - #[cfg(not(no_threading))] - let pool = world.read_resource::().clone(); - - #[cfg(not(no_threading))] - let mut base = self.base.with_pool(pool.clone()).build(); - #[cfg(no_threading)] - let mut base = self.base.build(); - base.setup(&mut world); + fn build(self, mut world: &mut World) -> CustomGameData<'a, 'b> { + let (mut base, mut running) = { + #[cfg(not(no_threading))] + let pool = world.read_resource::().clone(); + + #[cfg(not(no_threading))] + let base = self.base.with_pool((*pool).clone()).build(); + #[cfg(no_threading)] + let base = self.base.build(); + + #[cfg(not(no_threading))] + let running = self.running.with_pool((*pool).clone()).build(); + #[cfg(no_threading)] + let running = self.running.build(); - #[cfg(not(no_threading))] - let mut running = self.running.with_pool((*pool).clone()).build(); - #[cfg(no_threading)] - let mut running = self.running.build(); + (base, running) + }; + + base.setup(&mut world); running.setup(&mut world); CustomGameData { diff --git a/examples/custom_game_data/main.rs b/examples/custom_game_data/main.rs index f0c5ca68ca..673d9ac24c 100644 --- a/examples/custom_game_data/main.rs +++ b/examples/custom_game_data/main.rs @@ -10,8 +10,8 @@ use amethyst::{ }, core::transform::TransformBundle, ecs::{ - prelude::{Component, Entity, ReadExpect, World, SystemData}, - NullStorage, World, + prelude::{Component, Entity, ReadExpect, SystemData, World}, + NullStorage, WorldExt, }, input::{is_close_requested, is_key_down, InputBundle, StringBindings}, prelude::*, @@ -255,11 +255,11 @@ struct ExampleGraph { impl GraphCreator for ExampleGraph { fn rebuild(&mut self, world: &World) -> bool { // Rebuild when dimensions change, but wait until at least two frames have the same. - let new_dimensions = res.try_fetch::(); + let new_dimensions = world.try_fetch::(); use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty @@ -276,7 +276,7 @@ impl GraphCreator for ExampleGraph { }; self.dirty = false; - let window = >::fetch(res); + let window = >::fetch(world); let surface = factory.create_surface(&window); // cache surface format to speed things up let surface_format = *self diff --git a/examples/custom_ui/main.rs b/examples/custom_ui/main.rs index 016ece4409..85cad5ad9d 100644 --- a/examples/custom_ui/main.rs +++ b/examples/custom_ui/main.rs @@ -3,7 +3,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, RonFormat}, core::transform::TransformBundle, - ecs::prelude::{ReadExpect, World, SystemData, WorldExt}, + ecs::prelude::{ReadExpect, SystemData, World, WorldExt}, input::StringBindings, prelude::*, renderer::{ @@ -141,7 +141,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/debug_lines/main.rs b/examples/debug_lines/main.rs index 2fc3d7df5f..cf072b1fec 100644 --- a/examples/debug_lines/main.rs +++ b/examples/debug_lines/main.rs @@ -7,7 +7,7 @@ use amethyst::{ transform::{Transform, TransformBundle}, Time, }, - ecs::{Read, ReadExpect, World, System, SystemData, WorldExt, Write}, + ecs::{Read, ReadExpect, System, SystemData, World, WorldExt, Write}, input::{is_close_requested, is_key_down, InputBundle, StringBindings}, prelude::*, renderer::{ @@ -67,8 +67,7 @@ impl SimpleState for ExampleState { // Setup debug lines as a resource data.world.insert(DebugLines::new()); // Configure width of lines. Optional step - data.world - .insert(DebugLinesParams { line_width: 2.0 }); + data.world.insert(DebugLinesParams { line_width: 2.0 }); // Setup debug lines as a component and add lines to render axis&grid let mut debug_lines_component = DebugLinesComponent::with_capacity(100); @@ -233,7 +232,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/debug_lines_ortho/main.rs b/examples/debug_lines_ortho/main.rs index 85c8d3af56..4e2cd29c6c 100644 --- a/examples/debug_lines_ortho/main.rs +++ b/examples/debug_lines_ortho/main.rs @@ -5,7 +5,7 @@ use amethyst::{ transform::{Transform, TransformBundle}, Time, }, - ecs::{Read, ReadExpect, World, System, SystemData, WorldExt, Write}, + ecs::{Read, ReadExpect, System, SystemData, World, WorldExt, Write}, prelude::*, renderer::{ camera::Camera, @@ -54,8 +54,7 @@ impl SimpleState for ExampleState { // Setup debug lines as a resource data.world.insert(DebugLines::new()); // Configure width of lines. Optional step - data.world - .insert(DebugLinesParams { line_width: 2.0 }); + data.world.insert(DebugLinesParams { line_width: 2.0 }); // Setup debug lines as a component and add lines to render axis&grid let mut debug_lines_component = DebugLinesComponent::new(); @@ -143,7 +142,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/events/main.rs b/examples/events/main.rs index 4a1dcabff3..d9fcd1816f 100644 --- a/examples/events/main.rs +++ b/examples/events/main.rs @@ -62,11 +62,9 @@ struct ReceivingSystem { } impl ReceivingSystem { - pub fn new(world: &mut World) -> Self { + pub fn new(mut world: &mut World) -> Self { >::SystemData::setup(&mut world); - let reader = world - .fetch_mut::>() - .register_reader(); + let reader = world.fetch_mut::>().register_reader(); ReceivingSystem { reader } } } diff --git a/examples/fly_camera/main.rs b/examples/fly_camera/main.rs index 9772922976..74a033969d 100644 --- a/examples/fly_camera/main.rs +++ b/examples/fly_camera/main.rs @@ -4,7 +4,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, RonFormat}, controls::{FlyControlBundle, HideCursor}, core::transform::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, input::{is_key_down, is_mouse_button_down, InputBundle, StringBindings}, prelude::*, renderer::{ @@ -120,7 +120,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/gltf/main.rs b/examples/gltf/main.rs index 18de235cbe..9f540dacb6 100644 --- a/examples/gltf/main.rs +++ b/examples/gltf/main.rs @@ -12,7 +12,7 @@ use amethyst::{ controls::{ControlTagPrefab, FlyControlBundle}, core::transform::{Transform, TransformBundle}, derive::PrefabData, - ecs::{Entity, ReadExpect, ReadStorage, World, SystemData, Write, WriteStorage}, + ecs::{Entity, ReadExpect, ReadStorage, SystemData, World, Write, WriteStorage}, input::{is_close_requested, is_key_down, StringBindings, VirtualKeyCode}, prelude::*, renderer::{ diff --git a/examples/material/main.rs b/examples/material/main.rs index 4bfaf6ceb8..57b48692c0 100644 --- a/examples/material/main.rs +++ b/examples/material/main.rs @@ -2,7 +2,7 @@ use amethyst::{ assets::AssetLoaderSystemData, core::{ - ecs::{Builder, ReadExpect, World, SystemData, WorldExt}, + ecs::{Builder, ReadExpect, SystemData, World, WorldExt}, Transform, TransformBundle, }, renderer::{ @@ -184,11 +184,11 @@ struct ExampleGraph { impl GraphCreator for ExampleGraph { fn rebuild(&mut self, world: &World) -> bool { // Rebuild when dimensions change, but wait until at least two frames have the same. - let new_dimensions = res.try_fetch::(); + let new_dimensions = world.try_fetch::(); use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty @@ -206,7 +206,7 @@ impl GraphCreator for ExampleGraph { self.dirty = false; - let window = >::fetch(res); + let window = >::fetch(world); let surface = factory.create_surface(&window); // cache surface format to speed things up let surface_format = *self diff --git a/examples/pong/main.rs b/examples/pong/main.rs index 035ef3ea0e..fe7e552376 100644 --- a/examples/pong/main.rs +++ b/examples/pong/main.rs @@ -183,7 +183,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| *(d.clone())); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/pong_tutorial_01/main.rs b/examples/pong_tutorial_01/main.rs index b84cdde0d0..4f1fa7375a 100644 --- a/examples/pong_tutorial_01/main.rs +++ b/examples/pong_tutorial_01/main.rs @@ -74,7 +74,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/pong_tutorial_02/main.rs b/examples/pong_tutorial_02/main.rs index e462b50e70..b35b557dca 100644 --- a/examples/pong_tutorial_02/main.rs +++ b/examples/pong_tutorial_02/main.rs @@ -6,7 +6,7 @@ use crate::pong::Pong; use amethyst::{ assets::Processor, core::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, prelude::*, renderer::{ pass::DrawFlat2DDesc, types::DefaultBackend, Factory, Format, GraphBuilder, GraphCreator, @@ -76,7 +76,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| *(d.clone())); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/pong_tutorial_03/main.rs b/examples/pong_tutorial_03/main.rs index a4681537d6..029ab65ff6 100644 --- a/examples/pong_tutorial_03/main.rs +++ b/examples/pong_tutorial_03/main.rs @@ -7,7 +7,7 @@ use crate::pong::Pong; use amethyst::{ assets::Processor, core::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, input::{InputBundle, StringBindings}, prelude::*, renderer::{ @@ -86,7 +86,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/pong_tutorial_04/main.rs b/examples/pong_tutorial_04/main.rs index a3ce24e414..0708d27a12 100644 --- a/examples/pong_tutorial_04/main.rs +++ b/examples/pong_tutorial_04/main.rs @@ -7,7 +7,7 @@ use crate::pong::Pong; use amethyst::{ assets::Processor, core::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, input::{InputBundle, StringBindings}, prelude::*, renderer::{ @@ -92,7 +92,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/pong_tutorial_05/main.rs b/examples/pong_tutorial_05/main.rs index 8da829f5a2..23051df97d 100644 --- a/examples/pong_tutorial_05/main.rs +++ b/examples/pong_tutorial_05/main.rs @@ -7,7 +7,7 @@ use crate::pong::Pong; use amethyst::{ assets::Processor, core::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, input::{InputBundle, StringBindings}, prelude::*, renderer::{ @@ -98,7 +98,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = *new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/prefab/main.rs b/examples/prefab/main.rs index ae6dc67f9e..843044ecbc 100644 --- a/examples/prefab/main.rs +++ b/examples/prefab/main.rs @@ -3,7 +3,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, RonFormat}, core::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, prelude::*, renderer::{ pass::DrawShadedDesc, @@ -80,7 +80,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/prefab_adapter/main.rs b/examples/prefab_adapter/main.rs index b28209c796..8d3af4affa 100644 --- a/examples/prefab_adapter/main.rs +++ b/examples/prefab_adapter/main.rs @@ -8,8 +8,8 @@ use amethyst::{ ProgressCounter, RonFormat, }, ecs::{ - storage::DenseVecStorage, Component, Entities, Entity, Join, ReadStorage, World, - WriteStorage, WorldExt, + storage::DenseVecStorage, Component, Entities, Entity, Join, ReadStorage, World, WorldExt, + WriteStorage, }, prelude::*, utils::application_root_dir, diff --git a/examples/renderable/main.rs b/examples/renderable/main.rs index 64f4b90a64..b3b9d6762a 100644 --- a/examples/renderable/main.rs +++ b/examples/renderable/main.rs @@ -14,7 +14,7 @@ use amethyst::{ transform::{Transform, TransformBundle}, }, ecs::prelude::{ - Entity, Join, Read, ReadExpect, ReadStorage, World, System, SystemData, WorldExt, Write, + Entity, Join, Read, ReadExpect, ReadStorage, System, SystemData, World, WorldExt, Write, WriteStorage, }, input::{ @@ -348,7 +348,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/rendy/main.rs b/examples/rendy/main.rs index 3899bd51a4..b9deb6b7a6 100644 --- a/examples/rendy/main.rs +++ b/examples/rendy/main.rs @@ -13,7 +13,7 @@ use amethyst::{ core::{ ecs::{ Component, DenseVecStorage, Entities, Entity, Join, Read, ReadExpect, ReadStorage, - World, System, SystemData, World, Write, WriteStorage, + System, SystemData, World, World, Write, WriteStorage, }, math::{Unit, UnitQuaternion, Vector3}, Time, Transform, TransformBundle, diff --git a/examples/sphere/main.rs b/examples/sphere/main.rs index 3b946f4c43..1c83732102 100644 --- a/examples/sphere/main.rs +++ b/examples/sphere/main.rs @@ -3,7 +3,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, RonFormat}, core::transform::TransformBundle, - ecs::prelude::{ReadExpect, World, SystemData, WorldExt}, + ecs::prelude::{ReadExpect, SystemData, World, WorldExt}, prelude::*, renderer::{ pass::DrawShadedDesc, @@ -76,7 +76,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.cloned(); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/spotlights/main.rs b/examples/spotlights/main.rs index 5c5e4deb5e..bde1059822 100644 --- a/examples/spotlights/main.rs +++ b/examples/spotlights/main.rs @@ -1,7 +1,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, RonFormat}, core::transform::TransformBundle, - ecs::{ReadExpect, World, SystemData, WorldExt}, + ecs::{ReadExpect, SystemData, World, WorldExt}, prelude::*, renderer::{ pass::DrawPbrDesc, @@ -74,7 +74,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = *new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/sprite_animation/main.rs b/examples/sprite_animation/main.rs index 1c3eed11f6..aa7780aaf4 100644 --- a/examples/sprite_animation/main.rs +++ b/examples/sprite_animation/main.rs @@ -10,10 +10,7 @@ use amethyst::{ assets::{PrefabData, PrefabLoader, PrefabLoaderSystem, Processor, ProgressCounter, RonFormat}, core::transform::{Transform, TransformBundle}, derive::PrefabData, - ecs::{ - prelude::Entity, Entities, Join, ReadExpect, ReadStorage, SystemData, - WriteStorage, - }, + ecs::{prelude::Entity, Entities, Join, ReadExpect, ReadStorage, SystemData, WriteStorage}, error::Error, prelude::{Builder, World, WorldExt}, renderer::{ @@ -202,7 +199,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/sprite_camera_follow/main.rs b/examples/sprite_camera_follow/main.rs index 88dca98071..5517594da1 100644 --- a/examples/sprite_camera_follow/main.rs +++ b/examples/sprite_camera_follow/main.rs @@ -2,8 +2,8 @@ use amethyst::{ assets::{AssetStorage, Handle, Loader, Processor}, core::{Named, Parent, Transform, TransformBundle}, ecs::{ - Component, Entity, Join, NullStorage, Read, ReadExpect, ReadStorage, World, System, - SystemData, WorldExt, WriteStorage, + Component, Entity, Join, NullStorage, Read, ReadExpect, ReadStorage, System, SystemData, + World, WorldExt, WriteStorage, }, input::{is_close_requested, is_key_down, InputBundle, InputHandler, StringBindings}, prelude::*, @@ -253,7 +253,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = *new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/sprites_ordered/main.rs b/examples/sprites_ordered/main.rs index 92feef1ce8..09a929a339 100644 --- a/examples/sprites_ordered/main.rs +++ b/examples/sprites_ordered/main.rs @@ -9,7 +9,7 @@ mod sprite_sheet_loader; use amethyst::{ assets::{AssetStorage, Handle, Loader, Processor}, core::{Hidden, Transform, TransformBundle}, - ecs::{Entity, ReadExpect, World, SystemData, WorldExt}, + ecs::{Entity, ReadExpect, SystemData, World, WorldExt}, input::{get_key, is_close_requested, is_key_down, ElementState}, prelude::*, renderer::{ @@ -413,7 +413,7 @@ impl GraphCreator for ExampleGraph { use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty diff --git a/examples/ui/main.rs b/examples/ui/main.rs index 8574c70f41..318f319f49 100644 --- a/examples/ui/main.rs +++ b/examples/ui/main.rs @@ -4,7 +4,7 @@ use amethyst::{ assets::{PrefabLoader, PrefabLoaderSystem, Processor, RonFormat}, audio::{output::init_output, Source}, core::{frame_limiter::FrameRateLimitStrategy, transform::TransformBundle, Time}, - ecs::prelude::{Entity, ReadExpect, World, System, SystemData, World, Write}, + ecs::prelude::{Entity, ReadExpect, System, SystemData, World, WorldExt, Write}, input::{is_close_requested, is_key_down, InputBundle, StringBindings}, prelude::*, renderer::{ @@ -42,7 +42,7 @@ struct Example { impl SimpleState for Example { fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>) { - let StateData { world, .. } = data; + let StateData { mut world, .. } = data; // Initialise the scene with an object, a light and a camera. let handle = world.exec(|loader: PrefabLoader<'_, MyPrefabData>| { loader.load("prefab/sphere.ron", RonFormat, ()) @@ -202,11 +202,11 @@ struct ExampleGraph { impl GraphCreator for ExampleGraph { fn rebuild(&mut self, world: &World) -> bool { // Rebuild when dimensions change, but wait until at least two frames have the same. - let new_dimensions = res.try_fetch::(); + let new_dimensions = world.try_fetch::(); use std::ops::Deref; if self.dimensions.as_ref() != new_dimensions.as_ref().map(|d| d.deref()) { self.dirty = true; - self.dimensions = new_dimensions.map(|d| d.clone()); + self.dimensions = new_dimensions.map(|d| (*d).clone()); return false; } self.dirty @@ -224,7 +224,7 @@ impl GraphCreator for ExampleGraph { self.dirty = false; - let window = >::fetch(res); + let window = >::fetch(world); let surface = factory.create_surface(&window); // cache surface format to speed things up let surface_format = *self diff --git a/src/app.rs b/src/app.rs index 8504a6585e..5fe46ca7d6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -21,9 +21,7 @@ use crate::{ timing::{Stopwatch, Time}, ArcThreadPool, EventReader, Named, }, - ecs::{ - prelude::{Component, Read, World, WorldExt, Write}, - }, + ecs::prelude::{Component, Read, World, WorldExt, Write}, error::Error, game_data::{DataDispose, DataInit}, state::{State, StateData, StateMachine, TransEvent}, @@ -783,8 +781,7 @@ where /// /// This function returns the ApplicationBuilder after modifying it. pub fn with_frame_limit(mut self, strategy: FrameRateLimitStrategy, max_fps: u32) -> Self { - self.world - .insert(FrameLimiter::new(strategy, max_fps)); + self.world.insert(FrameLimiter::new(strategy, max_fps)); self } diff --git a/src/state.rs b/src/state.rs index ae702fb052..3935dd1b16 100644 --- a/src/state.rs +++ b/src/state.rs @@ -558,7 +558,7 @@ mod tests { #[test] fn switch_pop() { - use crate::ecs::prelude::World; + use crate::ecs::prelude::{World, WorldExt}; let mut world = World::new(); diff --git a/src/state_event.rs b/src/state_event.rs index aa1b43dcff..a5553ac41b 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -1,6 +1,6 @@ use crate::{ core::{ - ecs::{Read, World, SystemData}, + ecs::{Read, SystemData, World}, shrev::{EventChannel, ReaderId}, EventReader, },