diff --git a/src/app/app_builder.rs b/src/app/app_builder.rs index 2eb1c2c0c5..d3d4e0ad74 100644 --- a/src/app/app_builder.rs +++ b/src/app/app_builder.rs @@ -1,8 +1,7 @@ use crate::{ app::{system_stage, App}, - core::{winit::WinitPlugin, CorePlugin}, + core::{plugin::{AppPlugin, load_plugin}, winit::WinitPlugin, CorePlugin}, legion::prelude::{Resources, Runnable, Schedulable, Schedule, Universe, World}, - plugin::{load_plugin, AppPlugin}, render::{renderer::Renderer, *}, ui, }; diff --git a/src/core/core_plugin.rs b/src/core/core_plugin.rs index cf2cf26bb1..53caf7a2d8 100644 --- a/src/core/core_plugin.rs +++ b/src/core/core_plugin.rs @@ -1,5 +1,5 @@ -use super::{Time, Window}; -use crate::{app::AppBuilder, plugin::AppPlugin}; +use super::{Time, Window, plugin::AppPlugin}; +use crate::{app::AppBuilder}; #[derive(Default)] pub struct CorePlugin; @@ -9,6 +9,7 @@ impl AppPlugin for CorePlugin { app.add_resource(Window::default()) .add_resource(Time::new()) } + fn name(&self) -> &'static str { "Core" } diff --git a/src/core/mod.rs b/src/core/mod.rs index 49e220683a..1691f8f7dd 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,9 +1,10 @@ pub mod bytes; mod time; pub mod window; +pub mod plugin; mod core_plugin; pub use bytes::*; pub use time::*; pub use window::*; -pub use core_plugin::*; +pub use core_plugin::*; \ No newline at end of file diff --git a/src/plugin/mod.rs b/src/core/plugin.rs similarity index 88% rename from src/plugin/mod.rs rename to src/core/plugin.rs index 8f4bfd7630..3750135426 100644 --- a/src/plugin/mod.rs +++ b/src/core/plugin.rs @@ -7,7 +7,7 @@ pub trait AppPlugin: Any + Send + Sync { fn name(&self) -> &'static str; } -type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin; +pub type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin; pub fn load_plugin(path: &str) -> (Library, Box) { let lib = Library::new(path).unwrap(); diff --git a/src/core/window/winit/mod.rs b/src/core/window/winit/mod.rs index 738466a119..503130154c 100644 --- a/src/core/window/winit/mod.rs +++ b/src/core/window/winit/mod.rs @@ -1,6 +1,5 @@ use crate::{ - app::{App, AppBuilder}, - plugin::AppPlugin, + app::{App, AppBuilder}, core::plugin::AppPlugin, }; use super::Window; diff --git a/src/diagnostic/diagnostic_plugin.rs b/src/diagnostic/diagnostic_plugin.rs index 6ddd9f33a3..9294a39238 100644 --- a/src/diagnostic/diagnostic_plugin.rs +++ b/src/diagnostic/diagnostic_plugin.rs @@ -2,7 +2,7 @@ use super::{ diagnostics::{frame_time_diagnostic_system, print_diagnostics_system}, Diagnostics, }; -use crate::{app::AppBuilder, plugin::AppPlugin}; +use crate::{app::AppBuilder, core::plugin::AppPlugin}; use std::time::Duration; pub struct DiagnosticsPlugin { @@ -25,12 +25,11 @@ impl AppPlugin for DiagnosticsPlugin { fn build(&self, mut app: AppBuilder) -> AppBuilder { app = app.add_resource(Diagnostics::default()); if self.add_defaults { - let frame_time_diagnostic_system = { - frame_time_diagnostic_system(&mut app.resources, 10) - }; + let frame_time_diagnostic_system = + { frame_time_diagnostic_system(&mut app.resources, 10) }; app = app.add_system(frame_time_diagnostic_system) } - + if self.print_diagnostics { app = app.add_system(print_diagnostics_system(self.print_wait_duration)); } diff --git a/src/lib.rs b/src/lib.rs index 7e948a7f1d..fbc73e6c56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ pub mod asset; pub mod core; pub mod diagnostic; pub mod ecs; -pub mod plugin; pub mod prelude; pub mod render; pub mod serialization; diff --git a/src/prelude.rs b/src/prelude.rs index 27d67e5d87..47b12a8a7f 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,7 +1,7 @@ pub use crate::{ app::{App, AppBuilder}, asset::{Asset, AssetStorage, Handle}, - core::{Time, Window}, + core::{Time, Window, plugin::AppPlugin}, ecs, ecs::{ default_archetypes::*, CommandBufferBuilderSource, EntityArchetype, WorldBuilder, diff --git a/src/render/render_plugin.rs b/src/render/render_plugin.rs index 34ae695957..03275e4423 100644 --- a/src/render/render_plugin.rs +++ b/src/render/render_plugin.rs @@ -11,12 +11,12 @@ use super::{ MeshResourceProvider, UiResourceProvider, }, AssetBatchers, EntityRenderResourceAssignments, RenderResourceAssignments, - }, RenderContext, + }, }; use crate::{ app::AppBuilder, asset::AssetStorage, - plugin::AppPlugin, + core::plugin::AppPlugin, prelude::{ LocalToWorld, Mesh, PipelineDescriptor, Shader, StandardMaterial, Texture, UniformResourceProvider, @@ -57,7 +57,6 @@ impl AppPlugin for RenderPlugin { let mut asset_batchers = AssetBatchers::default(); asset_batchers.batch_types2::(); app = app - .add_resource(RenderContext::default()) .add_resource(RenderGraph::default()) .add_resource(AssetStorage::::new()) .add_resource(AssetStorage::::new()) diff --git a/src/render/renderer/renderers/wgpu_renderer/mod.rs b/src/render/renderer/renderers/wgpu_renderer/mod.rs index 14ee08cd03..4259d1744f 100644 --- a/src/render/renderer/renderers/wgpu_renderer/mod.rs +++ b/src/render/renderer/renderers/wgpu_renderer/mod.rs @@ -7,7 +7,7 @@ pub use wgpu_render_pass::*; pub use wgpu_renderer::*; pub use wgpu_resources::*; -use crate::{app::AppBuilder, plugin::AppPlugin}; +use crate::{app::AppBuilder, core::plugin::AppPlugin}; pub struct WgpuRendererPlugin;