Skip to content

Commit

Permalink
fix rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
james7132 committed Mar 15, 2022
1 parent e58b087 commit 82febea
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
7 changes: 7 additions & 0 deletions crates/bevy_hierarchy/src/components/parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions crates/bevy_hierarchy/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_hierarchy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
68 changes: 33 additions & 35 deletions crates/bevy_transform/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -227,9 +221,13 @@ mod test {
);

// Parent `e1` to `e2`.
(*world.get_mut::<Parent>(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
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 82febea

Please sign in to comment.