cargo fmt
This commit is contained in:
parent
9230c370ba
commit
45a710fe6a
@ -3,10 +3,10 @@ mod app_builder;
|
||||
mod entity_archetype;
|
||||
mod event;
|
||||
mod plugin;
|
||||
mod system;
|
||||
pub mod schedule_plan;
|
||||
pub mod schedule_runner;
|
||||
pub mod stage;
|
||||
mod system;
|
||||
|
||||
pub use app::*;
|
||||
pub use app_builder::*;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::{cmp::Ordering, collections::HashMap};
|
||||
use crate::System;
|
||||
use legion::prelude::Schedule;
|
||||
use std::{cmp::Ordering, collections::HashMap};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SchedulePlan {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
use legion::{
|
||||
filter::EntityFilter,
|
||||
prelude::{
|
||||
into_resource_system, IntoQuery, ResourceSet, Resources, Runnable,
|
||||
Schedulable, World, into_resource_for_each_system,
|
||||
into_resource_for_each_system, into_resource_system, IntoQuery, ResourceSet, Resources,
|
||||
Runnable, Schedulable, World,
|
||||
},
|
||||
query::{DefaultFilter, View},
|
||||
};
|
||||
|
||||
@ -15,19 +15,19 @@ pub mod world;
|
||||
#[cfg(feature = "serialize")]
|
||||
pub mod serialize;
|
||||
|
||||
mod system_fn_types;
|
||||
mod tuple;
|
||||
mod zip;
|
||||
mod system_fn_types;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::{
|
||||
// used by system_fn
|
||||
borrow::{Ref, RefMut},
|
||||
command::CommandBuffer,
|
||||
entity::Entity,
|
||||
event::Event,
|
||||
filter::filter_fns::*,
|
||||
query::{IntoQuery, Query, Read, Tagged, TryRead, TryWrite, Write},
|
||||
world::{Universe, World},
|
||||
// used by system_fn
|
||||
borrow::{Ref, RefMut}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,5 +1,14 @@
|
||||
use crate::{borrow::{RefIterMut, RefMut, RefIter, Ref}, storage::{ArchetypeData, Component, ComponentStorage, ComponentTypeId}, query::{View, DefaultFilter, ViewElement}, filter::{ComponentFilter, EntityFilterTuple, Passthrough}, index::{SetIndex, ChunkIndex}};
|
||||
use std::{any::TypeId, slice::{IterMut, Iter}};
|
||||
use crate::{
|
||||
borrow::{Ref, RefIter, RefIterMut, RefMut},
|
||||
filter::{ComponentFilter, EntityFilterTuple, Passthrough},
|
||||
index::{ChunkIndex, SetIndex},
|
||||
query::{DefaultFilter, View, ViewElement},
|
||||
storage::{ArchetypeData, Component, ComponentStorage, ComponentTypeId},
|
||||
};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
slice::{Iter, IterMut},
|
||||
};
|
||||
|
||||
impl<'a, T: Component> DefaultFilter for RefMut<'static, T> {
|
||||
type Filter = EntityFilterTuple<ComponentFilter<T>, Passthrough, Passthrough>;
|
||||
@ -7,7 +16,7 @@ impl<'a, T: Component> DefaultFilter for RefMut<'static, T> {
|
||||
fn filter() -> Self::Filter { super::filter::filter_fns::component() }
|
||||
}
|
||||
|
||||
impl<'a, T: Component> View<'a> for RefMut<'static, T>{
|
||||
impl<'a, T: Component> View<'a> for RefMut<'static, T> {
|
||||
type Iter = RefIterMut<'a, T, IterMut<'a, T>>;
|
||||
|
||||
#[inline]
|
||||
@ -58,7 +67,7 @@ impl<'a, T: Component> DefaultFilter for Ref<'static, T> {
|
||||
fn filter() -> Self::Filter { super::filter::filter_fns::component() }
|
||||
}
|
||||
|
||||
impl<'a, T: Component> View<'a> for Ref<'static, T>{
|
||||
impl<'a, T: Component> View<'a> for Ref<'static, T> {
|
||||
type Iter = RefIter<'a, T, Iter<'a, T>>;
|
||||
|
||||
#[inline]
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
pub mod resource;
|
||||
pub mod schedule;
|
||||
|
||||
mod system;
|
||||
mod system_fn;
|
||||
mod system_fn_types;
|
||||
mod system;
|
||||
|
||||
pub use bit_set;
|
||||
pub use system::*;
|
||||
@ -13,11 +13,15 @@ pub use system_fn::*;
|
||||
pub mod prelude {
|
||||
pub use crate::{
|
||||
bit_set::BitSet,
|
||||
into_resource_for_each_system,
|
||||
into_resource_system,
|
||||
// aliased preparedread and preparedwrite used by system_fn
|
||||
resource::{ResourceSet, Resources, PreparedRead as Resource, PreparedWrite as ResourceMut},
|
||||
resource::{
|
||||
PreparedRead as Resource, PreparedWrite as ResourceMut, ResourceSet, Resources,
|
||||
},
|
||||
schedule::{Executor, Runnable, Schedulable, Schedule},
|
||||
System, SystemBuilder,
|
||||
into_resource_system, into_resource_for_each_system,
|
||||
IntoSystem
|
||||
IntoSystem,
|
||||
System,
|
||||
SystemBuilder,
|
||||
};
|
||||
}
|
||||
|
||||
@ -381,9 +381,7 @@ impl<T: Resource> ResourceSet for Read<T> {
|
||||
.unwrap_or_else(|| panic!("Failed to fetch resource!: {}", std::any::type_name::<T>()));
|
||||
PreparedRead::new(resource.deref() as *const T)
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> {
|
||||
vec![ResourceTypeId::of::<T>()]
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> { vec![ResourceTypeId::of::<T>()] }
|
||||
fn write_types() -> Vec<ResourceTypeId> { Vec::new() }
|
||||
}
|
||||
impl<T: Resource> ResourceSet for Write<T> {
|
||||
@ -395,12 +393,8 @@ impl<T: Resource> ResourceSet for Write<T> {
|
||||
.unwrap_or_else(|| panic!("Failed to fetch resource!: {}", std::any::type_name::<T>()));
|
||||
PreparedWrite::new(resource.deref_mut() as *mut T)
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> {
|
||||
Vec::new()
|
||||
}
|
||||
fn write_types() -> Vec<ResourceTypeId> {
|
||||
vec![ResourceTypeId::of::<T>()]
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> { Vec::new() }
|
||||
fn write_types() -> Vec<ResourceTypeId> { vec![ResourceTypeId::of::<T>()] }
|
||||
}
|
||||
|
||||
macro_rules! impl_resource_tuple {
|
||||
|
||||
@ -896,10 +896,11 @@ pub trait SystemFn {
|
||||
);
|
||||
}
|
||||
|
||||
pub struct SystemFnWrapper<R, Q, F: FnMut(&mut CommandBuffer, &mut SubWorld, &mut R, &mut Q) + 'static>(
|
||||
pub F,
|
||||
pub PhantomData<(R, Q)>,
|
||||
);
|
||||
pub struct SystemFnWrapper<
|
||||
R,
|
||||
Q,
|
||||
F: FnMut(&mut CommandBuffer, &mut SubWorld, &mut R, &mut Q) + 'static,
|
||||
>(pub F, pub PhantomData<(R, Q)>);
|
||||
|
||||
impl<F, R, Q> SystemFn for SystemFnWrapper<R, Q, F>
|
||||
where
|
||||
|
||||
@ -13,7 +13,6 @@ use legion_core::{
|
||||
};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
||||
pub fn into_resource_for_each_system<'a, Q, F, R, X>(
|
||||
name: &'static str,
|
||||
mut system: F,
|
||||
@ -154,7 +153,6 @@ where
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
impl<
|
||||
'a,
|
||||
F,
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
use crate::resource::{PreparedRead, ResourceSet, Resources, Resource, PreparedWrite, ResourceTypeId};
|
||||
use crate::resource::{
|
||||
PreparedRead, PreparedWrite, Resource, ResourceSet, ResourceTypeId, Resources,
|
||||
};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
impl<T: Resource> ResourceSet for PreparedRead<T> {
|
||||
@ -10,9 +12,7 @@ impl<T: Resource> ResourceSet for PreparedRead<T> {
|
||||
.unwrap_or_else(|| panic!("Failed to fetch resource!: {}", std::any::type_name::<T>()));
|
||||
PreparedRead::new(resource.deref() as *const T)
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> {
|
||||
vec![ResourceTypeId::of::<T>()]
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> { vec![ResourceTypeId::of::<T>()] }
|
||||
fn write_types() -> Vec<ResourceTypeId> { Vec::new() }
|
||||
}
|
||||
|
||||
@ -25,10 +25,6 @@ impl<T: Resource> ResourceSet for PreparedWrite<T> {
|
||||
.unwrap_or_else(|| panic!("Failed to fetch resource!: {}", std::any::type_name::<T>()));
|
||||
PreparedWrite::new(resource.deref_mut() as *mut T)
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> {
|
||||
Vec::new()
|
||||
}
|
||||
fn write_types() -> Vec<ResourceTypeId> {
|
||||
vec![ResourceTypeId::of::<T>()]
|
||||
}
|
||||
fn read_types() -> Vec<ResourceTypeId> { Vec::new() }
|
||||
fn write_types() -> Vec<ResourceTypeId> { vec![ResourceTypeId::of::<T>()] }
|
||||
}
|
||||
@ -3,7 +3,7 @@ use crate::shader::ShaderDefSuffixProvider;
|
||||
use bevy_asset::Handle;
|
||||
use bevy_core::bytes::GetBytes;
|
||||
use glam::Vec4;
|
||||
use std::ops::{AddAssign, Add};
|
||||
use std::ops::{Add, AddAssign};
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use crate::{
|
||||
batch::AssetBatchers,
|
||||
draw_target::DrawTarget,
|
||||
pass::RenderPass,
|
||||
pipeline::PipelineDescriptor,
|
||||
render_resource::{resource_name, RenderResourceAssignments},
|
||||
renderer::RenderContext,
|
||||
Renderable, batch::AssetBatchers,
|
||||
Renderable,
|
||||
};
|
||||
use bevy_asset::Handle;
|
||||
use legion::prelude::*;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use crate::{
|
||||
batch::AssetBatchers,
|
||||
pipeline::{
|
||||
state_descriptors::{IndexFormat, PrimitiveTopology},
|
||||
VertexBufferDescriptor, VertexBufferDescriptors, VertexFormat,
|
||||
@ -6,7 +7,7 @@ use crate::{
|
||||
render_resource::{BufferInfo, BufferUsage, RenderResourceAssignments},
|
||||
renderer::{GlobalRenderResourceContext, RenderResourceContext},
|
||||
shader::AsUniforms,
|
||||
Renderable, Vertex, batch::AssetBatchers,
|
||||
Renderable, Vertex,
|
||||
};
|
||||
use bevy_asset::{AssetStorage, Handle};
|
||||
use glam::*;
|
||||
|
||||
@ -61,10 +61,12 @@ impl Node for WindowSwapChainNode {
|
||||
let render_resources = render_context.resources_mut();
|
||||
|
||||
// create window swapchain when window is resized or created
|
||||
if self.window_created_event_reader
|
||||
if self
|
||||
.window_created_event_reader
|
||||
.find_latest(&window_created_events, |e| e.id == window.id)
|
||||
.is_some()
|
||||
|| self.window_resized_event_reader
|
||||
|| self
|
||||
.window_resized_event_reader
|
||||
.find_latest(&window_resized_events, |e| e.id == window.id)
|
||||
.is_some()
|
||||
{
|
||||
|
||||
@ -62,10 +62,12 @@ impl Node for WindowTextureNode {
|
||||
.expect("Received window resized event for non-existent window"),
|
||||
};
|
||||
|
||||
if self.window_created_event_reader
|
||||
if self
|
||||
.window_created_event_reader
|
||||
.find_latest(&window_created_events, |e| e.id == window.id)
|
||||
.is_some()
|
||||
|| self.window_resized_event_reader
|
||||
|| self
|
||||
.window_resized_event_reader
|
||||
.find_latest(&window_resized_events, |e| e.id == window.id)
|
||||
.is_some()
|
||||
{
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use crate::{
|
||||
batch::AssetBatchers,
|
||||
color::ColorSource,
|
||||
pipeline::{BindType, VertexBufferDescriptor},
|
||||
texture::Texture,
|
||||
Renderable, batch::AssetBatchers,
|
||||
Renderable,
|
||||
};
|
||||
|
||||
use bevy_asset::{AssetStorage, Handle};
|
||||
|
||||
@ -59,8 +59,9 @@ impl WgpuRenderer {
|
||||
.unwrap();
|
||||
let windows = resources.get::<Windows>().unwrap();
|
||||
let window_created_events = resources.get::<Events<WindowCreated>>().unwrap();
|
||||
for window_created_event in
|
||||
self.window_created_event_reader.iter(&window_created_events)
|
||||
for window_created_event in self
|
||||
.window_created_event_reader
|
||||
.iter(&window_created_events)
|
||||
{
|
||||
let window = windows
|
||||
.get(window_created_event.id)
|
||||
|
||||
@ -41,7 +41,8 @@ fn closure_system() -> Box<dyn Schedulable> {
|
||||
println!("processed entity: {} {}", x.0, y.0);
|
||||
println!("ran {} times", counter);
|
||||
counter += 1;
|
||||
}).into_system("closure_system")
|
||||
})
|
||||
.into_system("closure_system")
|
||||
}
|
||||
|
||||
// if you need more flexibility, you can define complex systems using the system builder
|
||||
|
||||
@ -13,6 +13,7 @@ pub use crate::diagnostic::DiagnosticsPlugin;
|
||||
pub use crate::pbr::{entity::*, light::Light, material::StandardMaterial};
|
||||
#[cfg(feature = "render")]
|
||||
pub use crate::render::{
|
||||
batch::AssetBatchers,
|
||||
draw_target,
|
||||
entity::*,
|
||||
mesh::{shape, Mesh},
|
||||
@ -25,7 +26,6 @@ pub use crate::render::{
|
||||
RenderGraph,
|
||||
},
|
||||
render_resource::resource_name,
|
||||
batch::AssetBatchers,
|
||||
shader::{Shader, ShaderDefSuffixProvider, ShaderStage, ShaderStages},
|
||||
texture::{Texture, TextureType},
|
||||
ActiveCamera, ActiveCamera2d, Camera, CameraType, Color, ColorSource, Renderable,
|
||||
@ -38,24 +38,26 @@ pub use crate::ui::{entity::*, Anchors, Margins, Node};
|
||||
pub use crate::window::{Window, WindowDescriptor, WindowPlugin, Windows};
|
||||
pub use crate::{
|
||||
app::{
|
||||
stage, App, AppBuilder, AppPlugin, EntityArchetype, EventReader, Events, GetEventReader, System
|
||||
stage, App, AppBuilder, AppPlugin, EntityArchetype, EventReader, Events, GetEventReader,
|
||||
System,
|
||||
},
|
||||
math::{self, Mat3, Mat4, Quat, Vec2, Vec3, Vec4},
|
||||
AddDefaultPlugins,
|
||||
};
|
||||
pub use legion::{
|
||||
command::CommandBuffer,
|
||||
borrow::{Ref, RefMut},
|
||||
command::CommandBuffer,
|
||||
entity::Entity,
|
||||
event::Event as LegionEvent,
|
||||
filter::filter_fns::*,
|
||||
query::{IntoQuery, Query, Read, Tagged, TryRead, TryWrite, Write},
|
||||
systems::{
|
||||
bit_set::BitSet,
|
||||
resource::{ResourceSet, Resources, PreparedRead as Resource, PreparedWrite as ResourceMut},
|
||||
resource::{
|
||||
PreparedRead as Resource, PreparedWrite as ResourceMut, ResourceSet, Resources,
|
||||
},
|
||||
schedule::{Executor, Runnable, Schedulable, Schedule},
|
||||
SubWorld, SystemBuilder,
|
||||
IntoSystem
|
||||
IntoSystem, SubWorld, SystemBuilder,
|
||||
},
|
||||
world::{Universe, World},
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user