From 82febea5bade0b63562798e0a7724877754958d3 Mon Sep 17 00:00:00 2001 From: james7132 Date: Tue, 15 Mar 2022 02:22:03 -0700 Subject: [PATCH] fix rebase errors --- .../bevy_hierarchy/src/components/parent.rs | 7 ++ crates/bevy_hierarchy/src/hierarchy.rs | 6 +- crates/bevy_hierarchy/src/lib.rs | 1 - crates/bevy_transform/src/systems.rs | 68 +++++++++---------- crates/bevy_ui/src/update.rs | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/crates/bevy_hierarchy/src/components/parent.rs b/crates/bevy_hierarchy/src/components/parent.rs index f3605f379cd52..83e40ac855047 100644 --- a/crates/bevy_hierarchy/src/components/parent.rs +++ b/crates/bevy_hierarchy/src/components/parent.rs @@ -13,6 +13,13 @@ use std::ops::Deref; #[reflect(Component, MapEntities, PartialEq)] pub struct Parent(pub(crate) Entity); +impl Parent { + /// Gets the [`Entity`] ID of the parent. + pub fn get(&self) -> Entity { + self.0 + } +} + // TODO: We need to impl either FromWorld or Default so Parent can be registered as Reflect. // This is because Reflect deserialize by creating an instance and apply a patch on top. // However Parent should only ever be set with a real user-defined entity. Its worth looking into diff --git a/crates/bevy_hierarchy/src/hierarchy.rs b/crates/bevy_hierarchy/src/hierarchy.rs index 3916804ac61ed..56c9b0f8ad938 100644 --- a/crates/bevy_hierarchy/src/hierarchy.rs +++ b/crates/bevy_hierarchy/src/hierarchy.rs @@ -116,11 +116,7 @@ mod tests { }; use super::DespawnRecursiveExt; -<<<<<<< HEAD:crates/bevy_hierarchy/src/hierarchy.rs - use crate::{child_builder::BuildChildren, components::Children, ChildAdded, ChildMoved, ChildRemoved}; -======= - use crate::{components::Children, hierarchy::BuildChildren}; ->>>>>>> e7ef4a51 (Scenes are Worlds too):crates/bevy_transform/src/hierarchy/hierarchy.rs + use crate::{child_builder::BuildChildren, components::Children}; #[derive(Component, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Debug)] struct Idx(u32); diff --git a/crates/bevy_hierarchy/src/lib.rs b/crates/bevy_hierarchy/src/lib.rs index 908b79898f221..1cbb2257450b3 100644 --- a/crates/bevy_hierarchy/src/lib.rs +++ b/crates/bevy_hierarchy/src/lib.rs @@ -23,7 +23,6 @@ pub mod prelude { } use bevy_app::prelude::*; -use bevy_ecs::prelude::*; /// The base plugin for handling [`Parent`] and [`Children`] components #[derive(Default)] diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 457b41f8c04af..214af65ff44da 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -82,18 +82,10 @@ mod test { world::World, }; -<<<<<<< HEAD:crates/bevy_transform/src/systems.rs use crate::components::{GlobalTransform, Transform}; use crate::systems::transform_propagate_system; use crate::TransformBundle; - use bevy_hierarchy::{BuildChildren, BuildWorldChildren, Children, Parent, ChildAdded, ChildMoved, ChildRemoved}; -======= - use super::*; - use crate::{ - hierarchy::{BuildChildren, BuildWorldChildren}, - TransformBundle, - }; ->>>>>>> e7ef4a51 (Scenes are Worlds too):crates/bevy_transform/src/transform_propagate_system.rs + use bevy_hierarchy::{BuildChildren, BuildWorldChildren, Children}; #[test] fn did_propagate() { @@ -185,36 +177,38 @@ mod test { let mut world = World::default(); let mut update_stage = SystemStage::parallel(); - update_stage.add_system(parent_update_system); update_stage.add_system(transform_propagate_system); let mut schedule = Schedule::default(); schedule.add_stage("update", update_stage); // Add parent entities - let mut command_queue = CommandQueue::default(); - let mut commands = Commands::new(&mut command_queue, &world); let mut children = Vec::new(); - let parent = commands - .spawn() - .insert(Transform::from_xyz(1.0, 0.0, 0.0)) - .id(); - commands.entity(parent).with_children(|parent| { - children.push( - parent - .spawn() - .insert(Transform::from_xyz(0.0, 2.0, 0.0)) - .id(), - ); - children.push( - parent - .spawn() - .insert(Transform::from_xyz(0.0, 3.0, 0.0)) - .id(), - ); - }); - command_queue.apply(&mut world); - schedule.run(&mut world); + let parent = { + let mut command_queue = CommandQueue::default(); + let mut commands = Commands::new(&mut command_queue, &world); + let parent = commands + .spawn() + .insert(Transform::from_xyz(1.0, 0.0, 0.0)) + .id(); + commands.entity(parent).with_children(|parent| { + children.push( + parent + .spawn() + .insert(Transform::from_xyz(0.0, 2.0, 0.0)) + .id(), + ); + children.push( + parent + .spawn() + .insert(Transform::from_xyz(0.0, 3.0, 0.0)) + .id(), + ); + }); + command_queue.apply(&mut world); + schedule.run(&mut world); + parent + }; assert_eq!( world @@ -227,9 +221,13 @@ mod test { ); // Parent `e1` to `e2`. - (*world.get_mut::(children[0]).unwrap()).0 = children[1]; - - schedule.run(&mut world); + { + let mut command_queue = CommandQueue::default(); + let mut commands = Commands::new(&mut command_queue, &world); + commands.entity(children[1]).add_child(children[0]); + command_queue.apply(&mut world); + schedule.run(&mut world); + } assert_eq!( world diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 4d5e075a7afdc..8af7d72caca62 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -139,7 +139,7 @@ mod tests { system::{CommandQueue, Commands}, world::World, }; - use bevy_hierarchy::{BuildChildren, ChildAdded, ChildMoved, ChildRemoved}; + use bevy_hierarchy::BuildChildren; use bevy_transform::components::Transform; use crate::Node;