Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AnneKitsune committed Jul 5, 2019
1 parent db8283b commit 5582438
Show file tree
Hide file tree
Showing 70 changed files with 532 additions and 233 deletions.
18 changes: 15 additions & 3 deletions amethyst_animation/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ impl<'a> VertexSkinningBundle<'a> {
}

impl<'a, 'b, 'c> SystemBundle<'a, 'b> for VertexSkinningBundle<'c> {
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(
VertexSkinningSystem::new(world),
"vertex_skinning_system",
Expand Down Expand Up @@ -85,7 +89,11 @@ impl<'a, 'b, 'c, T> SystemBundle<'a, 'b> for SamplingBundle<'c, T>
where
T: AnimationSampling + Component,
{
fn build(self, _world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
_world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(SamplerProcessor::<T::Primitive>::new(), "", &[]);
builder.add(SamplerInterpolationSystem::<T>::new(), self.name, self.dep);
Ok(())
Expand Down Expand Up @@ -140,7 +148,11 @@ where
I: PartialEq + Eq + Hash + Copy + Send + Sync + 'static,
T: AnimationSampling + Component + Clone,
{
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(AnimationProcessor::<T>::new(), "", &[]);
builder.add(
AnimationControlSystem::<I, T>::new(world),
Expand Down
2 changes: 1 addition & 1 deletion amethyst_animation/src/skinning/systems.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use amethyst_core::{
ecs::prelude::{
BitSet, ComponentEvent, Join, ReadStorage, ReaderId, System, WriteStorage, World,
BitSet, ComponentEvent, Join, ReadStorage, ReaderId, System, World, WriteStorage,
},
math::{convert, Matrix4},
Transform,
Expand Down
4 changes: 2 additions & 2 deletions amethyst_animation/src/systems/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use minterpolate::InterpolationPrimitive;
use amethyst_assets::{AssetStorage, Handle};
use amethyst_core::{
ecs::prelude::{
Component, Entities, Entity, Join, Read, ReadStorage, System, SystemData,
WriteStorage, World,
Component, Entities, Entity, Join, Read, ReadStorage, System, SystemData, World,
WriteStorage,
},
timing::secs_to_duration,
};
Expand Down
4 changes: 2 additions & 2 deletions amethyst_assets/src/prefab/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use log::error;
use amethyst_core::{
ecs::{
storage::ComponentEvent, BitSet, Entities, Entity, Join, Read, ReadExpect, ReadStorage,
ReaderId, Resources, System, Write, WriteStorage, World,
ReaderId, Resources, System, World, Write, WriteStorage,
},
ArcThreadPool, Parent, Time,
};
Expand All @@ -32,7 +32,7 @@ pub struct PrefabLoaderSystem<T> {
next_tag: u64,
}

impl<'a, T> PrefabLoaderSystem<T>
impl<'a, T> PrefabLoaderSystem<T>
where
T: PrefabData<'a> + Send + Sync + 'static,
{
Expand Down
14 changes: 11 additions & 3 deletions amethyst_assets/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{sync::Arc, time::Instant};

use amethyst_core::{
ecs::prelude::{DispatcherBuilder, Read, Resources, System, Write, World},
ecs::prelude::{DispatcherBuilder, Read, Resources, System, World, Write},
SystemBundle, Time,
};
use amethyst_error::Error;
Expand All @@ -28,8 +28,16 @@ impl HotReloadBundle {
}

impl<'a, 'b> SystemBundle<'a, 'b> for HotReloadBundle {
fn build(self, world: &mut World, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
dispatcher.add(HotReloadSystem::new(world, self.strategy), "hot_reload", &[]);
fn build(
self,
world: &mut World,
dispatcher: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
dispatcher.add(
HotReloadSystem::new(world, self.strategy),
"hot_reload",
&[],
);
Ok(())
}
}
Expand Down
11 changes: 9 additions & 2 deletions amethyst_audio/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! ECS audio bundles
use amethyst_assets::Processor;
use amethyst_core::{bundle::SystemBundle, ecs::prelude::{DispatcherBuilder, World}};
use amethyst_core::{
bundle::SystemBundle,
ecs::prelude::{DispatcherBuilder, World},
};
use amethyst_error::Error;

use crate::{output::Output, source::*, systems::AudioSystem};
Expand All @@ -17,7 +20,11 @@ use crate::{output::Output, source::*, systems::AudioSystem};
pub struct AudioBundle(Output);

impl<'a, 'b> SystemBundle<'a, 'b> for AudioBundle {
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(AudioSystem::new(world, self.0), "audio_system", &[]);
builder.add(Processor::<Source>::new(), "source_processor", &[]);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion amethyst_audio/src/systems/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use thread_profiler::profile_scope;

use amethyst_core::{
ecs::prelude::{
Entities, Entity, Join, Read, ReadStorage, System, SystemData, WriteStorage, World,
Entities, Entity, Join, Read, ReadStorage, System, SystemData, World, WriteStorage,
},
math::convert,
transform::Transform,
Expand Down
4 changes: 2 additions & 2 deletions amethyst_audio/src/systems/dj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use amethyst_assets::AssetStorage;
use amethyst_core::{
ecs::{
common::Errors,
prelude::{Read, System, WriteExpect, World},
prelude::{Read, System, World, WriteExpect},
},
shred::Resource,
};
Expand All @@ -25,7 +25,7 @@ pub struct DjSystem<F, R> {
marker: PhantomData<R>,
}

impl<F, R> DjSystem<F, R>
impl<F, R> DjSystem<F, R>
where
F: FnMut(&mut R) -> Option<SourceHandle>,
R: Resource,
Expand Down
30 changes: 25 additions & 5 deletions amethyst_controls/src/bundles.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::marker::PhantomData;

use amethyst_core::{bundle::SystemBundle, ecs::prelude::{DispatcherBuilder, World}, math::one};
use amethyst_core::{
bundle::SystemBundle,
ecs::prelude::{DispatcherBuilder, World},
math::one,
};
use amethyst_error::Error;
use amethyst_input::BindingTypes;

Expand Down Expand Up @@ -69,7 +73,11 @@ impl<T: BindingTypes> FlyControlBundle<T> {
}

impl<'a, 'b, T: BindingTypes> SystemBundle<'a, 'b> for FlyControlBundle<T> {
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(
FlyMovementSystem::<T>::new(
self.speed,
Expand All @@ -90,7 +98,11 @@ impl<'a, 'b, T: BindingTypes> SystemBundle<'a, 'b> for FlyControlBundle<T> {
"mouse_focus",
&["free_rotation"],
);
builder.add(CursorHideSystem::new(world), "cursor_hide", &["mouse_focus"]);
builder.add(
CursorHideSystem::new(world),
"cursor_hide",
&["mouse_focus"],
);
Ok(())
}
}
Expand Down Expand Up @@ -134,7 +146,11 @@ impl<T: BindingTypes> Default for ArcBallControlBundle<T> {
}

impl<'a, 'b, T: BindingTypes> SystemBundle<'a, 'b> for ArcBallControlBundle<T> {
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(ArcBallRotationSystem::default(), "arc_ball_rotation", &[]);
builder.add(
FreeRotationSystem::new(world, self.sensitivity_x, self.sensitivity_y),
Expand All @@ -146,7 +162,11 @@ impl<'a, 'b, T: BindingTypes> SystemBundle<'a, 'b> for ArcBallControlBundle<T> {
"mouse_focus",
&["free_rotation"],
);
builder.add(CursorHideSystem::new(world), "cursor_hide", &["mouse_focus"]);
builder.add(
CursorHideSystem::new(world),
"cursor_hide",
&["mouse_focus"],
);
Ok(())
}
}
20 changes: 11 additions & 9 deletions amethyst_controls/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
resources::{HideCursor, WindowFocus},
};
use amethyst_core::{
ecs::prelude::{Join, Read, ReadExpect, ReadStorage, System, Write, WriteStorage, World},
ecs::prelude::{Join, Read, ReadExpect, ReadStorage, System, World, Write, WriteStorage},
math::{convert, Unit, Vector3},
shrev::{EventChannel, ReaderId},
timing::Time,
Expand Down Expand Up @@ -136,7 +136,10 @@ impl FreeRotationSystem {
pub fn new(world: &mut World, sensitivity_x: f32, sensitivity_y: f32) -> Self {
use amethyst_core::ecs::prelude::SystemData;
<Self as System<'_>>::SystemData::setup(&mut world.res);
let event_reader = world.res.fetch_mut::<EventChannel<Event>>().register_reader();
let event_reader = world
.res
.fetch_mut::<EventChannel<Event>>()
.register_reader();
FreeRotationSystem {
sensitivity_x,
sensitivity_y,
Expand All @@ -159,9 +162,7 @@ impl<'a> System<'a> for FreeRotationSystem {
profile_scope!("free_rotation_system");

let focused = focus.is_focused;
for event in
events.read(&mut self.event_reader)
{
for event in events.read(&mut self.event_reader) {
if focused && hide.hide {
if let Event::DeviceEvent { ref event, .. } = *event {
if let DeviceEvent::MouseMotion { delta: (x, y) } = *event {
Expand Down Expand Up @@ -191,10 +192,11 @@ impl MouseFocusUpdateSystem {
pub fn new(world: &mut World) -> MouseFocusUpdateSystem {
use amethyst_core::ecs::prelude::SystemData;
<Self as System<'_>>::SystemData::setup(&mut world.res);
let event_reader = world.res.fetch_mut::<EventChannel<Event>>().register_reader();
Self {
event_reader
}
let event_reader = world
.res
.fetch_mut::<EventChannel<Event>>()
.register_reader();
Self { event_reader }
}
}

Expand Down
6 changes: 5 additions & 1 deletion amethyst_core/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ use amethyst_error::Error;
/// A bundle of ECS components, resources and systems.
pub trait SystemBundle<'a, 'b> {
/// Build and add ECS resources, register components, add systems etc to the Application.
fn build(self, world: &mut World, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error>;
fn build(
self,
world: &mut World,
dispatcher: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error>;
}
7 changes: 2 additions & 5 deletions amethyst_core/src/hide_system.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
ecs::prelude::{
BitSet, ComponentEvent, ReadExpect, ReadStorage, ReaderId, System, WriteStorage, World,
BitSet, ComponentEvent, ReadExpect, ReadStorage, ReaderId, System, World, WriteStorage,
},
transform::components::{HierarchyEvent, Parent, ParentHierarchy},
};
Expand Down Expand Up @@ -66,10 +66,7 @@ impl<'a> System<'a> for HideHierarchySystem {
ComponentEvent::Modified(_id) => {}
});

for event in hierarchy
.changed()
.read(&mut self.parent_events_id)
{
for event in hierarchy.changed().read(&mut self.parent_events_id) {
match *event {
HierarchyEvent::Removed(entity) => {
self_marked_as_modified.add(entity.id());
Expand Down
12 changes: 10 additions & 2 deletions amethyst_core/src/transform/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
use amethyst_error::Error;
use specs_hierarchy::HierarchySystem;

use crate::{bundle::SystemBundle, ecs::prelude::{DispatcherBuilder, World}, transform::*};
use crate::{
bundle::SystemBundle,
ecs::prelude::{DispatcherBuilder, World},
transform::*,
};

/// Transform bundle
///
Expand Down Expand Up @@ -39,7 +43,11 @@ impl<'a> TransformBundle<'a> {
}

impl<'a, 'b, 'c> SystemBundle<'a, 'b> for TransformBundle<'c> {
fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<(), Error> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(
HierarchySystem::<Parent>::new(),
"parent_hierarchy_system",
Expand Down
15 changes: 4 additions & 11 deletions amethyst_core/src/transform/systems.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Scene graph system and types
use crate::ecs::prelude::{
ComponentEvent, Entities, Join, ReadExpect, ReadStorage, ReaderId, System,
WriteStorage, World,
ComponentEvent, Entities, Join, ReadExpect, ReadStorage, ReaderId, System, World, WriteStorage,
};
use hibitset::BitSet;

Expand Down Expand Up @@ -51,19 +50,15 @@ impl<'a> System<'a> for TransformSystem {

locals
.channel()
.read(
&mut self.locals_events_id,
)
.read(&mut self.locals_events_id)
.for_each(|event| match event {
ComponentEvent::Inserted(id) | ComponentEvent::Modified(id) => {
self.local_modified.add(*id);
}
ComponentEvent::Removed(_id) => {}
});

for event in hierarchy.changed().read(
&mut self.parent_events_id
) {
for event in hierarchy.changed().read(&mut self.parent_events_id) {
match *event {
HierarchyEvent::Removed(entity) => {
// Sometimes the user may have already deleted the entity.
Expand Down Expand Up @@ -121,9 +116,7 @@ impl<'a> System<'a> for TransformSystem {
}

// Clear the local event reader.
locals
.channel()
.read(&mut self.locals_events_id);
locals.channel().read(&mut self.locals_events_id);
}
}

Expand Down
Loading

0 comments on commit 5582438

Please sign in to comment.