Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clone, PartialEq, Ser/De traits to Parent/Children #11987

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/bevy_hierarchy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ default = ["bevy_app"]
trace = []
bevy_app = ["reflect", "dep:bevy_app", "bevy_core", "bevy_log"]
reflect = ["bevy_ecs/bevy_reflect", "bevy_reflect"]
serialize = ["dep:serde"]

[dependencies]
# bevy
Expand All @@ -24,6 +25,7 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.13.0", features = [
"bevy",
], optional = true }
bevy_utils = { path = "../bevy_utils", version = "0.13.0" }
serde = { version = "1", features = ["derive"], optional = true }

[lints]
workspace = true
7 changes: 5 additions & 2 deletions crates/bevy_hierarchy/src/components/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use bevy_ecs::{
};
use bevy_utils::smallvec::SmallVec;
use core::slice;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::ops::Deref;

/// Contains references to the child entities of this entity.
Expand All @@ -23,9 +25,10 @@ use std::ops::Deref;
/// [`Query`]: bevy_ecs::system::Query
/// [`Parent`]: crate::components::parent::Parent
/// [`BuildChildren::with_children`]: crate::child_builder::BuildChildren::with_children
#[derive(Component, Debug)]
#[derive(Component, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
#[cfg_attr(feature = "reflect", reflect(Component, MapEntities))]
#[cfg_attr(feature = "reflect", reflect(Component, PartialEq, MapEntities))]
pub struct Children(pub(crate) SmallVec<[Entity; 8]>);

impl MapEntities for Children {
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_hierarchy/src/components/parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use bevy_ecs::{
entity::{Entity, EntityMapper, MapEntities},
world::{FromWorld, World},
};
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::ops::Deref;

/// Holds a reference to the parent entity of this entity.
Expand All @@ -20,7 +22,8 @@ use std::ops::Deref;
/// [`Query`]: bevy_ecs::system::Query
/// [`Children`]: super::children::Children
/// [`BuildChildren::with_children`]: crate::child_builder::BuildChildren::with_children
#[derive(Component, Debug, Eq, PartialEq)]
#[derive(Component, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
#[cfg_attr(feature = "reflect", reflect(Component, MapEntities, PartialEq))]
pub struct Parent(pub(crate) Entity);
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ shader_format_spirv = ["bevy_render/shader_format_spirv"]

serialize = [
"bevy_core/serialize",
"bevy_hierarchy/serialize",
"bevy_input/serialize",
"bevy_time/serialize",
"bevy_window/serialize",
Expand Down
Loading