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-11-29 22:07:47 +00:00
|
|
|
use bevy_app::{prelude::*, startup_stage};
|
2020-12-16 05:57:16 +00:00
|
|
|
use bevy_ecs::IntoSystem;
|
2020-11-28 00:39:59 +00:00
|
|
|
use bevy_reflect::RegisterTypeBuilder;
|
2020-11-22 20:05:58 +00:00
|
|
|
use prelude::{parent_update_system, Children, GlobalTransform, Parent, PreviousParent, Transform};
|
2020-07-16 23:32:39 +00:00
|
|
|
|
|
|
|
#[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) {
|
2020-11-28 00:39:59 +00:00
|
|
|
app.register_type::<Children>()
|
|
|
|
.register_type::<Parent>()
|
|
|
|
.register_type::<PreviousParent>()
|
|
|
|
.register_type::<Transform>()
|
|
|
|
.register_type::<GlobalTransform>()
|
2020-07-16 23:32:39 +00:00
|
|
|
// add transform systems to startup so the first update is "correct"
|
2020-12-16 05:57:16 +00:00
|
|
|
.add_startup_system_to_stage(startup_stage::POST_STARTUP, parent_update_system.system())
|
2020-11-29 22:07:47 +00:00
|
|
|
.add_startup_system_to_stage(
|
|
|
|
startup_stage::POST_STARTUP,
|
2020-12-16 05:57:16 +00:00
|
|
|
transform_propagate_system::transform_propagate_system.system(),
|
2020-11-29 22:07:47 +00:00
|
|
|
)
|
2020-12-16 05:57:16 +00:00
|
|
|
.add_system_to_stage(stage::POST_UPDATE, parent_update_system.system())
|
2020-11-17 02:18:00 +00:00
|
|
|
.add_system_to_stage(
|
|
|
|
stage::POST_UPDATE,
|
2020-12-16 05:57:16 +00:00
|
|
|
transform_propagate_system::transform_propagate_system.system(),
|
2020-11-17 02:18:00 +00:00
|
|
|
);
|
2020-07-16 23:32:39 +00:00
|
|
|
}
|
2019-12-02 09:31:07 +00:00
|
|
|
}
|