app: rename AppPlugin to Plugin

This commit is contained in:
Carter Anderson 2020-08-07 20:22:17 -07:00
parent bc6194a2f8
commit f963cd41dc
27 changed files with 37 additions and 37 deletions

View File

@ -1,7 +1,7 @@
use crate::{
app::{App, AppExit},
event::Events,
plugin::{load_plugin, AppPlugin},
plugin::{load_plugin, Plugin},
stage, startup_stage,
};
use bevy_ecs::{FromResources, IntoQuerySystem, Resources, System, World};
@ -228,7 +228,7 @@ impl AppBuilder {
pub fn add_plugin<T>(&mut self, plugin: T) -> &mut Self
where
T: AppPlugin,
T: Plugin,
{
log::debug!("added plugin: {}", plugin.name());
plugin.build(self);

View File

@ -9,7 +9,7 @@ mod startup_stage;
pub use app::*;
pub use app_builder::*;
pub use bevy_derive::DynamicAppPlugin;
pub use bevy_derive::DynamicPlugin;
pub use event::*;
pub use plugin::*;
pub use schedule_runner::*;
@ -20,7 +20,7 @@ pub mod prelude {
app::App,
app_builder::AppBuilder,
event::{EventReader, Events},
plugin::AppPlugin,
stage, DynamicAppPlugin,
plugin::Plugin,
stage, DynamicPlugin,
};
}

View File

@ -2,20 +2,20 @@ use crate::AppBuilder;
use libloading::{Library, Symbol};
use std::any::Any;
pub trait AppPlugin: Any + Send + Sync {
pub trait Plugin: Any + Send + Sync {
fn build(&self, app: &mut AppBuilder);
fn name(&self) -> &str {
std::any::type_name::<Self>()
}
}
pub type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin;
pub type CreatePlugin = unsafe fn() -> *mut dyn Plugin;
pub fn load_plugin(path: &str) -> (Library, Box<dyn AppPlugin>) {
pub fn load_plugin(path: &str) -> (Library, Box<dyn Plugin>) {
let lib = Library::new(path).unwrap();
unsafe {
let func: Symbol<CreateAppPlugin> = lib.get(b"_create_plugin").unwrap();
let func: Symbol<CreatePlugin> = lib.get(b"_create_plugin").unwrap();
let plugin = Box::from_raw(func());
(lib, plugin)
}

View File

@ -2,7 +2,7 @@ use super::{App, AppBuilder};
use crate::{
app::AppExit,
event::{EventReader, Events},
plugin::AppPlugin,
plugin::Plugin,
};
use std::{thread, time::Duration};
@ -39,7 +39,7 @@ impl ScheduleRunnerPlugin {
}
}
impl AppPlugin for ScheduleRunnerPlugin {
impl Plugin for ScheduleRunnerPlugin {
fn build(&self, app: &mut AppBuilder) {
let run_mode = self.run_mode;
app.set_runner(move |mut app: App| {

View File

@ -21,14 +21,14 @@ pub mod prelude {
pub use crate::{AddAsset, AssetEvent, AssetServer, Assets, Handle};
}
use bevy_app::{prelude::AppPlugin, AppBuilder};
use bevy_app::{prelude::Plugin, AppBuilder};
use bevy_ecs::IntoQuerySystem;
use bevy_type_registry::RegisterType;
#[derive(Default)]
pub struct AssetPlugin;
impl AppPlugin for AssetPlugin {
impl Plugin for AssetPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_stage_before(bevy_app::stage::PRE_UPDATE, stage::LOAD_ASSETS)
.add_stage_after(bevy_app::stage::POST_UPDATE, stage::ASSET_EVENTS)

View File

@ -15,7 +15,7 @@ use bevy_ecs::IntoQuerySystem;
#[derive(Default)]
pub struct AudioPlugin;
impl AppPlugin for AudioPlugin {
impl Plugin for AudioPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<AudioOutput>()
.add_asset::<AudioSource>()

View File

@ -20,7 +20,7 @@ use bevy_type_registry::RegisterType;
#[derive(Default)]
pub struct CorePlugin;
impl AppPlugin for CorePlugin {
impl Plugin for CorePlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<Time>()
.init_resource::<EntityLabels>()

View File

@ -2,13 +2,13 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};
pub fn derive_dynamic_app_plugin(input: TokenStream) -> TokenStream {
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let struct_name = &ast.ident;
TokenStream::from(quote! {
#[no_mangle]
pub extern "C" fn _create_plugin() -> *mut bevy::app::AppPlugin {
pub extern "C" fn _create_plugin() -> *mut bevy::app::Plugin {
// TODO: without this the assembly does nothing. why is that the case?
print!("");
// make sure the constructor is the correct type.

View File

@ -41,7 +41,7 @@ pub fn derive_as_vertex_buffer_descriptor(input: TokenStream) -> TokenStream {
as_vertex_buffer_descriptor::derive_as_vertex_buffer_descriptor(input)
}
#[proc_macro_derive(DynamicAppPlugin)]
#[proc_macro_derive(DynamicPlugin)]
pub fn derive_app_plugin(input: TokenStream) -> TokenStream {
app_plugin::derive_dynamic_app_plugin(input)
app_plugin::derive_dynamic_plugin(input)
}

View File

@ -6,7 +6,7 @@ use bevy_ecs::{IntoQuerySystem, Res, ResMut};
#[derive(Default)]
pub struct FrameTimeDiagnosticsPlugin;
impl AppPlugin for FrameTimeDiagnosticsPlugin {
impl Plugin for FrameTimeDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::AppBuilder) {
app.add_startup_system(Self::setup_system.system())
.add_system(Self::diagnostic_system.system());

View File

@ -14,7 +14,7 @@ pub struct PrintDiagnostics {}
#[derive(Default)]
pub struct DiagnosticsPlugin;
impl AppPlugin for DiagnosticsPlugin {
impl Plugin for DiagnosticsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<Diagnostics>();
#[cfg(feature = "profiler")]

View File

@ -25,7 +25,7 @@ impl Default for PrintDiagnosticsPlugin {
}
}
impl AppPlugin for PrintDiagnosticsPlugin {
impl Plugin for PrintDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::AppBuilder) {
app.add_resource(PrintDiagnosticsState {
timer: Timer::new(self.wait_duration),

View File

@ -8,7 +8,7 @@ use bevy_render::mesh::Mesh;
#[derive(Default)]
pub struct GltfPlugin;
impl AppPlugin for GltfPlugin {
impl Plugin for GltfPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset_loader::<Mesh, GltfLoader>();
}

View File

@ -20,7 +20,7 @@ use bevy_ecs::IntoQuerySystem;
#[derive(Default)]
pub struct InputPlugin;
impl AppPlugin for InputPlugin {
impl Plugin for InputPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_event::<KeyboardInput>()
.add_event::<MouseButtonInput>()

View File

@ -22,7 +22,7 @@ use render_graph::ForwardPbrRenderGraphBuilder;
#[derive(Default)]
pub struct PbrPlugin;
impl AppPlugin for PbrPlugin {
impl Plugin for PbrPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<StandardMaterial>()
.register_component::<Light>()

View File

@ -66,7 +66,7 @@ impl Default for RenderPlugin {
}
}
impl AppPlugin for RenderPlugin {
impl Plugin for RenderPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, stage::RENDER_RESOURCE)
.add_stage_after(stage::RENDER_RESOURCE, stage::RENDER_GRAPH_SYSTEMS)

View File

@ -20,7 +20,7 @@ pub struct ScenePlugin;
pub const SCENE_STAGE: &str = "scene";
impl AppPlugin for ScenePlugin {
impl Plugin for ScenePlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<Scene>()
.add_asset_loader::<Scene, SceneLoader>()

View File

@ -40,7 +40,7 @@ pub struct SpritePlugin;
pub const QUAD_HANDLE: Handle<Mesh> = Handle::from_u128(142404619811301375266013514540294236421);
impl AppPlugin for SpritePlugin {
impl Plugin for SpritePlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<ColorMaterial>()
.add_asset::<TextureAtlas>()

View File

@ -20,7 +20,7 @@ use bevy_asset::AddAsset;
#[derive(Default)]
pub struct TextPlugin;
impl AppPlugin for TextPlugin {
impl Plugin for TextPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<Font>()
.add_asset::<FontAtlasSet>()

View File

@ -29,7 +29,7 @@ pub(crate) fn transform_systems() -> Vec<Box<dyn System>> {
#[derive(Default)]
pub struct TransformPlugin;
impl AppPlugin for TransformPlugin {
impl Plugin for TransformPlugin {
fn build(&self, app: &mut AppBuilder) {
app.register_component::<Children>()
.register_component::<Parent>()

View File

@ -10,7 +10,7 @@ use bevy_property::DynamicProperties;
#[derive(Default)]
pub struct TypeRegistryPlugin;
impl AppPlugin for TypeRegistryPlugin {
impl Plugin for TypeRegistryPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<TypeRegistry>()
.register_property::<DynamicProperties>();

View File

@ -36,7 +36,7 @@ pub mod stage {
pub const UI: &'static str = "ui";
}
impl AppPlugin for UiPlugin {
impl Plugin for UiPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<FlexSurface>()
.add_stage_before(bevy_app::stage::POST_UPDATE, stage::UI)

View File

@ -7,7 +7,7 @@ use bevy_render::renderer::RenderResourceContext;
#[derive(Default)]
pub struct WgpuResourceDiagnosticsPlugin;
impl AppPlugin for WgpuResourceDiagnosticsPlugin {
impl Plugin for WgpuResourceDiagnosticsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_startup_system(Self::setup_system.system())
.add_system(Self::diagnostic_system.system());

View File

@ -17,7 +17,7 @@ use renderer::WgpuRenderResourceContext;
#[derive(Default)]
pub struct WgpuPlugin;
impl AppPlugin for WgpuPlugin {
impl Plugin for WgpuPlugin {
fn build(&self, app: &mut AppBuilder) {
let render_system = wgpu_render_system(app.resources_mut());
app.add_system_to_stage(

View File

@ -29,7 +29,7 @@ impl Default for WindowPlugin {
}
}
impl AppPlugin for WindowPlugin {
impl Plugin for WindowPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_event::<WindowResized>()
.add_event::<CreateWindow>()

View File

@ -22,7 +22,7 @@ use winit::{
#[derive(Default)]
pub struct WinitPlugin;
impl AppPlugin for WinitPlugin {
impl Plugin for WinitPlugin {
fn build(&self, app: &mut AppBuilder) {
app
// TODO: It would be great to provide a raw winit WindowEvent here, but the lifetime on it is

View File

@ -22,7 +22,7 @@ pub struct PrintMessagePlugin {
message: String,
}
impl AppPlugin for PrintMessagePlugin {
impl Plugin for PrintMessagePlugin {
// this is where we set up our plugin
fn build(&self, app: &mut AppBuilder) {
let state = PrintMessageState {