cargo fmt
This commit is contained in:
parent
b11a7f177b
commit
3e3ab92ff5
@ -1,4 +1,4 @@
|
||||
use legion::prelude::{Resources, ResourceMut};
|
||||
use legion::prelude::{ResourceMut, Resources};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
struct EventInstance<T> {
|
||||
@ -225,7 +225,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub trait GetEventReader {
|
||||
/// returns an [EventReader] of the given type
|
||||
fn get_event_reader<T>(&self) -> EventReader<T>
|
||||
|
@ -4,16 +4,16 @@ mod app_builder;
|
||||
mod entity_archetype;
|
||||
mod event;
|
||||
mod plugin;
|
||||
mod resources;
|
||||
pub mod schedule_plan;
|
||||
pub mod schedule_runner;
|
||||
pub mod stage;
|
||||
mod system;
|
||||
mod resources;
|
||||
|
||||
pub use app::*;
|
||||
pub use app_builder::*;
|
||||
pub use entity_archetype::*;
|
||||
pub use event::*;
|
||||
pub use plugin::*;
|
||||
pub use system::*;
|
||||
pub use resources::*;
|
||||
pub use system::*;
|
||||
|
@ -14,7 +14,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> FromResources for EventReader<T> where T: Send + Sync + 'static {
|
||||
impl<T> FromResources for EventReader<T>
|
||||
where
|
||||
T: Send + Sync + 'static,
|
||||
{
|
||||
fn from_resources(resources: &mut Resources) -> Self {
|
||||
resources.get_event_reader::<T>()
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
use legion::{
|
||||
prelude::{
|
||||
Resources,
|
||||
Runnable, Schedulable, World,
|
||||
},
|
||||
};
|
||||
use legion::prelude::{Resources, Runnable, Schedulable, World};
|
||||
pub enum System {
|
||||
Schedulable(Box<dyn Schedulable>),
|
||||
ThreadLocal(Box<dyn Runnable>),
|
||||
|
@ -36,4 +36,4 @@ pub fn start_timer_system(mut time: ResourceMut<Time>) {
|
||||
|
||||
pub fn stop_timer_system(mut time: ResourceMut<Time>) {
|
||||
time.stop();
|
||||
}
|
||||
}
|
||||
|
@ -132,13 +132,9 @@ pub fn derive_resource(input: TokenStream) -> TokenStream {
|
||||
let modules = get_modules(&ast);
|
||||
let bevy_app_path = get_path(&modules.bevy_app);
|
||||
|
||||
let field_types = fields
|
||||
.iter()
|
||||
.map(|field| &field.ty);
|
||||
let field_types = fields.iter().map(|field| &field.ty);
|
||||
|
||||
let fields = fields
|
||||
.iter()
|
||||
.map(|field| field.ident.as_ref().unwrap());
|
||||
let fields = fields.iter().map(|field| field.ident.as_ref().unwrap());
|
||||
|
||||
let generics = ast.generics;
|
||||
let (impl_generics, ty_generics, _where_clause) = generics.split_for_impl();
|
||||
|
@ -8,19 +8,18 @@ mod system_fn_types;
|
||||
pub use bit_set;
|
||||
pub use system::*;
|
||||
pub use system_fn::*;
|
||||
pub use system_fn_types::{ResourceMut, Resource};
|
||||
pub use system_fn_types::{Resource, ResourceMut};
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::{
|
||||
bit_set::BitSet,
|
||||
// aliased preparedread and preparedwrite used by system_fn
|
||||
resource::{
|
||||
ResourceSet, Resources,
|
||||
},
|
||||
resource::{ResourceSet, Resources},
|
||||
schedule::{Executor, Runnable, Schedulable, Schedule},
|
||||
IntoSystem,
|
||||
Resource,
|
||||
ResourceMut,
|
||||
System,
|
||||
SystemBuilder,
|
||||
Resource, ResourceMut,
|
||||
};
|
||||
}
|
||||
|
@ -1,10 +1,21 @@
|
||||
use crate::{schedule::{ArchetypeAccess, Runnable}, resource::{
|
||||
PreparedRead, PreparedWrite, ResourceSet, ResourceTypeId, Resources, self
|
||||
}, QuerySet, SystemId, SubWorld, SystemAccess};
|
||||
use std::{marker::PhantomData, ops::{Deref, DerefMut}, hash::{Hasher, Hash}};
|
||||
use legion_core::{world::{World, WorldId}, storage::ComponentTypeId, borrow::{AtomicRefCell, RefMut}, command::CommandBuffer};
|
||||
use tracing::{debug, span, info, Level};
|
||||
use crate::{
|
||||
resource::{self, PreparedRead, PreparedWrite, ResourceSet, ResourceTypeId, Resources},
|
||||
schedule::{ArchetypeAccess, Runnable},
|
||||
QuerySet, SubWorld, SystemAccess, SystemId,
|
||||
};
|
||||
use fxhash::FxHashMap;
|
||||
use legion_core::{
|
||||
borrow::{AtomicRefCell, RefMut},
|
||||
command::CommandBuffer,
|
||||
storage::ComponentTypeId,
|
||||
world::{World, WorldId},
|
||||
};
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
use tracing::{debug, info, span, Level};
|
||||
#[derive(Debug)]
|
||||
pub struct Resource<'a, T: 'a> {
|
||||
#[allow(dead_code)]
|
||||
@ -22,7 +33,12 @@ impl<'a, T: 'a> Clone for Resource<'a, T> {
|
||||
|
||||
impl<'a, T: 'a> Resource<'a, T> {
|
||||
#[inline(always)]
|
||||
fn new(resource: *const T) -> Self { Self { value: resource, _marker: PhantomData::default()} }
|
||||
fn new(resource: *const T) -> Self {
|
||||
Self {
|
||||
value: resource,
|
||||
_marker: PhantomData::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn map<K: 'a, F: FnMut(&T) -> &K>(&self, mut f: F) -> Resource<'a, K> {
|
||||
@ -106,7 +122,12 @@ impl<'a, T: 'a> Clone for ResourceMut<'a, T> {
|
||||
|
||||
impl<'a, T: 'a> ResourceMut<'a, T> {
|
||||
#[inline(always)]
|
||||
fn new(resource: *mut T) -> Self { Self { value: resource, _marker: PhantomData::default()} }
|
||||
fn new(resource: *mut T) -> Self {
|
||||
Self {
|
||||
value: resource,
|
||||
_marker: PhantomData::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn map_into<K: 'a, F: FnMut(&mut T) -> K>(mut self, mut f: F) -> ResourceMut<'a, K> {
|
||||
@ -179,7 +200,6 @@ impl<'a, T: resource::Resource> ResourceSet for ResourceMut<'a, T> {
|
||||
fn write_types() -> Vec<ResourceTypeId> { Vec::new() }
|
||||
}
|
||||
|
||||
|
||||
impl<T: resource::Resource> ResourceSet for PreparedRead<T> {
|
||||
type PreparedResources = PreparedRead<T>;
|
||||
|
||||
@ -206,7 +226,6 @@ impl<T: resource::Resource> ResourceSet for PreparedWrite<T> {
|
||||
fn write_types() -> Vec<ResourceTypeId> { vec![ResourceTypeId::of::<T>()] }
|
||||
}
|
||||
|
||||
|
||||
/// The concrete type which contains the system closure provided by the user. This struct should
|
||||
/// not be instantiated directly, and instead should be created using `SystemBuilder`.
|
||||
///
|
||||
@ -336,4 +355,4 @@ where
|
||||
) {
|
||||
(self.0)(commands, world, resources, queries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,4 @@ fn main() {
|
||||
|
||||
fn hello_world_system() {
|
||||
println!("hello world");
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_input::system::exit_on_esc_system;
|
||||
|
||||
fn main() {
|
||||
App::build()
|
||||
.add_default_plugins()
|
||||
.add_startup_system(setup)
|
||||
.add_system_init(bevy::input::system::exit_on_esc_system)
|
||||
.add_system_init(exit_on_esc_system)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -44,4 +44,4 @@ fn startup_system(
|
||||
)),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,10 @@
|
||||
//! If you prefer it, you can also consume the individual bevy crates directly.
|
||||
|
||||
#![feature(min_specialization)]
|
||||
#![doc(html_logo_url = "https://bevyengine.org/assets/icon.png", html_favicon_url = "https://bevyengine.org/assets/icon.png")]
|
||||
#![doc(
|
||||
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
||||
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
||||
)]
|
||||
|
||||
mod add_default_plugins;
|
||||
pub mod prelude;
|
||||
|
@ -53,12 +53,9 @@ pub use legion::{
|
||||
query::{IntoQuery, Query, Read, Tagged, TryRead, TryWrite, Write},
|
||||
systems::{
|
||||
bit_set::BitSet,
|
||||
resource::{
|
||||
ResourceSet, Resources,
|
||||
},
|
||||
resource::{ResourceSet, Resources},
|
||||
schedule::{Executor, Runnable, Schedulable, Schedule},
|
||||
IntoSystem, SubWorld, SystemBuilder,
|
||||
Resource, ResourceMut,
|
||||
IntoSystem, Resource, ResourceMut, SubWorld, SystemBuilder,
|
||||
},
|
||||
world::{Universe, World},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user