2019-12-02 09:31:07 +00:00
|
|
|
pub mod components;
|
2020-07-16 23:51:45 +00:00
|
|
|
pub mod hierarchy;
|
2020-06-07 20:39:50 +00:00
|
|
|
pub mod transform_propagate_system;
|
2019-12-02 09:31:07 +00:00
|
|
|
|
|
|
|
pub mod prelude {
|
2020-07-16 23:32:39 +00:00
|
|
|
pub use crate::{components::*, hierarchy::*, TransformPlugin};
|
2020-07-10 04:18:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 01:47:51 +00:00
|
|
|
use bevy_app::prelude::*;
|
2020-07-17 02:20:51 +00:00
|
|
|
use bevy_ecs::prelude::*;
|
2020-07-16 23:32:39 +00:00
|
|
|
use bevy_type_registry::RegisterType;
|
2020-09-14 21:00:32 +00:00
|
|
|
use prelude::{Children, Parent, Transform};
|
2020-07-10 04:18:35 +00:00
|
|
|
|
2020-07-16 23:32:39 +00:00
|
|
|
pub(crate) fn transform_systems() -> Vec<Box<dyn System>> {
|
|
|
|
let mut systems = Vec::with_capacity(5);
|
2020-07-10 04:18:35 +00:00
|
|
|
|
2020-07-16 23:32:39 +00:00
|
|
|
systems.append(&mut hierarchy::hierarchy_maintenance_systems());
|
|
|
|
systems.push(transform_propagate_system::transform_propagate_system.system());
|
2020-07-10 04:18:35 +00:00
|
|
|
|
2020-07-16 23:32:39 +00:00
|
|
|
systems
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct TransformPlugin;
|
|
|
|
|
2020-08-08 03:22:17 +00:00
|
|
|
impl Plugin for TransformPlugin {
|
2020-07-16 23:32:39 +00:00
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
|
|
|
app.register_component::<Children>()
|
2020-07-24 00:32:53 +00:00
|
|
|
.register_component::<Parent>()
|
2020-07-16 23:32:39 +00:00
|
|
|
.register_component::<Transform>()
|
|
|
|
// add transform systems to startup so the first update is "correct"
|
|
|
|
.add_startup_systems(transform_systems())
|
2020-07-24 01:26:08 +00:00
|
|
|
.add_systems_to_stage(stage::POST_UPDATE, transform_systems());
|
2020-07-16 23:32:39 +00:00
|
|
|
}
|
2019-12-02 09:31:07 +00:00
|
|
|
}
|