diff --git a/crates/bevy_hierarchy/src/child_builder.rs b/crates/bevy_hierarchy/src/child_builder.rs index 0f529b6b75d9a..d80c44c29e5e9 100644 --- a/crates/bevy_hierarchy/src/child_builder.rs +++ b/crates/bevy_hierarchy/src/child_builder.rs @@ -161,14 +161,14 @@ fn clear_children(parent: Entity, world: &mut World) { /// Command that adds a child to an entity. #[derive(Debug)] -pub struct AddChild { +pub struct PushChild { /// Parent entity to add the child to. pub parent: Entity, /// Child entity to add. pub child: Entity, } -impl Command for AddChild { +impl Command for PushChild { fn apply(self, world: &mut World) { world.entity_mut(self.parent).add_child(self.child); } @@ -433,7 +433,7 @@ impl<'w, 's, 'a> BuildChildren for EntityCommands<'w, 's, 'a> { if child == parent { panic!("Cannot add entity as a child of itself."); } - self.commands().add(AddChild { child, parent }); + self.commands().add(PushChild { child, parent }); self } @@ -460,7 +460,7 @@ impl<'w, 's, 'a> BuildChildren for EntityCommands<'w, 's, 'a> { if child == parent { panic!("Cannot set parent to itself"); } - self.commands().add(AddChild { child, parent }); + self.commands().add(PushChild { child, parent }); self } diff --git a/crates/bevy_scene/src/dynamic_scene.rs b/crates/bevy_scene/src/dynamic_scene.rs index d071dc8b49754..0484d0a3396e2 100644 --- a/crates/bevy_scene/src/dynamic_scene.rs +++ b/crates/bevy_scene/src/dynamic_scene.rs @@ -193,7 +193,7 @@ where #[cfg(test)] mod tests { use bevy_ecs::{reflect::AppTypeRegistry, system::Command, world::World}; - use bevy_hierarchy::{AddChild, Parent}; + use bevy_hierarchy::{Parent, PushChild}; use bevy_utils::EntityHashMap; use crate::dynamic_scene_builder::DynamicSceneBuilder; @@ -211,7 +211,7 @@ mod tests { .register::(); let original_parent_entity = world.spawn_empty().id(); let original_child_entity = world.spawn_empty().id(); - AddChild { + PushChild { parent: original_parent_entity, child: original_child_entity, } @@ -232,7 +232,7 @@ mod tests { // We then add the parent from the scene as a child of the original child // Hierarchy should look like: // Original Parent <- Original Child <- Scene Parent <- Scene Child - AddChild { + PushChild { parent: original_child_entity, child: from_scene_parent_entity, } diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 33dc7c2ea9d42..6537333877f53 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -7,7 +7,7 @@ use bevy_ecs::{ system::{Command, Resource}, world::{Mut, World}, }; -use bevy_hierarchy::{AddChild, Parent}; +use bevy_hierarchy::{Parent, PushChild}; use bevy_utils::{tracing::error, EntityHashMap, HashMap, HashSet}; use thiserror::Error; use uuid::Uuid; @@ -348,7 +348,7 @@ impl SceneSpawner { // this case shouldn't happen anyway .unwrap_or(true) { - AddChild { + PushChild { parent, child: entity, } diff --git a/crates/bevy_transform/src/commands.rs b/crates/bevy_transform/src/commands.rs index 0c1f2d2e9550c..5f34ead144682 100644 --- a/crates/bevy_transform/src/commands.rs +++ b/crates/bevy_transform/src/commands.rs @@ -2,24 +2,24 @@ //! while preserving [`GlobalTransform`]. use bevy_ecs::{prelude::Entity, system::Command, system::EntityCommands, world::World}; -use bevy_hierarchy::{AddChild, RemoveParent}; +use bevy_hierarchy::{PushChild, RemoveParent}; use crate::{GlobalTransform, Transform}; -/// Command similar to [`AddChild`], but updating the child transform to keep +/// Command similar to [`PushChild`], but updating the child transform to keep /// it at the same [`GlobalTransform`]. /// /// You most likely want to use [`BuildChildrenTransformExt::set_parent_in_place`] /// method on [`EntityCommands`] instead. -pub struct AddChildInPlace { +pub struct PushChildInPlace { /// Parent entity to add the child to. pub parent: Entity, /// Child entity to add. pub child: Entity, } -impl Command for AddChildInPlace { +impl Command for PushChildInPlace { fn apply(self, world: &mut World) { - let hierarchy_command = AddChild { + let hierarchy_command = PushChild { child: self.child, parent: self.parent, }; @@ -88,7 +88,7 @@ pub trait BuildChildrenTransformExt { impl<'w, 's, 'a> BuildChildrenTransformExt for EntityCommands<'w, 's, 'a> { fn set_parent_in_place(&mut self, parent: Entity) -> &mut Self { let child = self.id(); - self.commands().add(AddChildInPlace { child, parent }); + self.commands().add(PushChildInPlace { child, parent }); self }