2019-12-02 09:31:07 +00:00
|
|
|
pub mod components;
|
2020-07-16 23:51:45 +00:00
|
|
|
pub mod hierarchy;
|
2020-07-10 04:18:35 +00:00
|
|
|
pub mod local_transform_systems;
|
2020-06-07 20:39:50 +00:00
|
|
|
pub mod transform_propagate_system;
|
2020-07-10 04:18:35 +00:00
|
|
|
pub mod transform_systems;
|
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-16 23:32:39 +00:00
|
|
|
use bevy_app::{AppBuilder, AppPlugin};
|
2020-07-10 04:18:35 +00:00
|
|
|
use bevy_ecs::{IntoQuerySystem, System};
|
2020-07-16 23:32:39 +00:00
|
|
|
use bevy_type_registry::RegisterType;
|
|
|
|
use prelude::{Children, LocalTransform, NonUniformScale, Rotation, Scale, Transform, Translation};
|
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.append(&mut local_transform_systems::local_transform_systems());
|
|
|
|
systems.append(&mut transform_systems::transform_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;
|
|
|
|
|
|
|
|
impl AppPlugin for TransformPlugin {
|
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
|
|
|
app.register_component::<Children>()
|
|
|
|
.register_component::<LocalTransform>()
|
|
|
|
.register_component::<Transform>()
|
|
|
|
.register_component::<Translation>()
|
|
|
|
.register_component::<Rotation>()
|
|
|
|
.register_component::<Scale>()
|
|
|
|
.register_component::<NonUniformScale>()
|
|
|
|
// add transform systems to startup so the first update is "correct"
|
|
|
|
.add_startup_systems(transform_systems())
|
|
|
|
.add_systems(transform_systems());
|
|
|
|
}
|
2019-12-02 09:31:07 +00:00
|
|
|
}
|