Thanks to visit codestin.com
Credit goes to docs.rs

bevy_transform/
plugins.rs

1use crate::systems::{mark_dirty_trees, propagate_parent_transforms, sync_simple_transforms};
2use bevy_app::{App, Plugin, PostStartup, PostUpdate};
3use bevy_ecs::schedule::{IntoScheduleConfigs, SystemSet};
4
5/// Set enum for the systems relating to transform propagation
6#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
7pub enum TransformSystems {
8    /// Propagates changes in transform to children's [`GlobalTransform`](crate::components::GlobalTransform)
9    Propagate,
10}
11
12/// Deprecated alias for [`TransformSystems`].
13#[deprecated(since = "0.17.0", note = "Renamed to `TransformSystems`.")]
14pub type TransformSystem = TransformSystems;
15
16/// The base plugin for handling [`Transform`](crate::components::Transform) components
17#[derive(Default)]
18pub struct TransformPlugin;
19
20impl Plugin for TransformPlugin {
21    fn build(&self, app: &mut App) {
22        app
23            // add transform systems to startup so the first update is "correct"
24            .add_systems(
25                PostStartup,
26                (
27                    mark_dirty_trees,
28                    propagate_parent_transforms,
29                    sync_simple_transforms,
30                )
31                    .chain()
32                    .in_set(TransformSystems::Propagate),
33            )
34            .add_systems(
35                PostUpdate,
36                (
37                    mark_dirty_trees,
38                    propagate_parent_transforms,
39                    // TODO: Adjust the internal parallel queries to make this system more efficiently share and fill CPU time.
40                    sync_simple_transforms,
41                )
42                    .chain()
43                    .in_set(TransformSystems::Propagate),
44            );
45    }
46}