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
|
|
|
}
|
|
|
|
|
2021-02-18 21:20:37 +00:00
|
|
|
use bevy_app::prelude::*;
|
|
|
|
use bevy_ecs::{IntoSystem, ParallelSystemDescriptorCoercion, SystemLabel};
|
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;
|
|
|
|
|
2021-02-18 21:20:37 +00:00
|
|
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)]
|
|
|
|
pub enum TransformSystem {
|
|
|
|
TransformPropagate,
|
|
|
|
ParentUpdate,
|
|
|
|
}
|
|
|
|
|
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-11-29 22:07:47 +00:00
|
|
|
.add_startup_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
StartupStage::PostStartup,
|
|
|
|
parent_update_system
|
|
|
|
.system()
|
|
|
|
.label(TransformSystem::ParentUpdate),
|
2021-02-17 02:00:12 +00:00
|
|
|
)
|
|
|
|
.add_startup_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
StartupStage::PostStartup,
|
2021-02-17 02:00:12 +00:00
|
|
|
transform_propagate_system::transform_propagate_system
|
|
|
|
.system()
|
2021-02-18 21:20:37 +00:00
|
|
|
.label(TransformSystem::TransformPropagate)
|
|
|
|
.after(TransformSystem::ParentUpdate),
|
2021-02-17 02:00:12 +00:00
|
|
|
)
|
|
|
|
.add_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
CoreStage::PostUpdate,
|
|
|
|
parent_update_system
|
|
|
|
.system()
|
|
|
|
.label(TransformSystem::ParentUpdate),
|
2020-11-29 22:07:47 +00:00
|
|
|
)
|
2020-11-17 02:18:00 +00:00
|
|
|
.add_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
CoreStage::PostUpdate,
|
2021-02-17 02:00:12 +00:00
|
|
|
transform_propagate_system::transform_propagate_system
|
|
|
|
.system()
|
2021-02-18 21:20:37 +00:00
|
|
|
.label(TransformSystem::TransformPropagate)
|
|
|
|
.after(TransformSystem::ParentUpdate),
|
2020-11-17 02:18:00 +00:00
|
|
|
);
|
2020-07-16 23:32:39 +00:00
|
|
|
}
|
2019-12-02 09:31:07 +00:00
|
|
|
}
|