From d945ecf5ced1324ac618a8dc8b4774c0b914270a Mon Sep 17 00:00:00 2001 From: Alice I Cecile Date: Thu, 28 Nov 2024 15:46:30 -0500 Subject: [PATCH 1/3] Clarify inheritance behavior of required components Co-authored by: @BenjaminBrienen --- crates/bevy_ecs/src/component.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index b915f8b5cad09..8fa5571d6d102 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -226,9 +226,9 @@ use derive_more::derive::{Display, Error}; /// assert_eq!(2, world.entity(id).get::().unwrap().0); /// ``` /// -/// In general, this shouldn't happen often, but when it does the algorithm is simple and predictable: -/// 1. Use all of the constructors (including default constructors) directly defined in the spawned component's require list -/// 2. In the order the requires are defined in `#[require()]`, recursively visit the require list of each of the components in the list (this is a Depth First Search). When a constructor is found, it will only be used if one has not already been found. +/// In general, this shouldn't happen often, but when it does the algorithm for choosing the constructor from the tree is simple and predictable: +/// 1. A constructor from a direct #[requires()], if one exists, is selected with priority. +/// 2. Otherwise, perform a Depth First Search on the tree of requirements and select the first one found. /// /// From a user perspective, just think about this as the following: /// 1. Specifying a required component constructor for Foo directly on a spawned component Bar will result in that constructor being used (and overriding existing constructors lower in the inheritance tree). This is the classic "inheritance override" behavior people expect. From e35f5f48b6a1805f25094720cae0e84ac0186f60 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 28 Nov 2024 15:50:03 -0500 Subject: [PATCH 2/3] Use the exact syntax Co-authored-by: Joona Aalto --- crates/bevy_ecs/src/component.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 8fa5571d6d102..5adcfc112c5f8 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -227,7 +227,7 @@ use derive_more::derive::{Display, Error}; /// ``` /// /// In general, this shouldn't happen often, but when it does the algorithm for choosing the constructor from the tree is simple and predictable: -/// 1. A constructor from a direct #[requires()], if one exists, is selected with priority. +/// 1. A constructor from a direct #[require()], if one exists, is selected with priority. /// 2. Otherwise, perform a Depth First Search on the tree of requirements and select the first one found. /// /// From a user perspective, just think about this as the following: From a8537ad562967158a8cee4dac6e5d1de46b9789b Mon Sep 17 00:00:00 2001 From: Alice I Cecile Date: Thu, 28 Nov 2024 15:57:11 -0500 Subject: [PATCH 3/3] Add backticks --- crates/bevy_ecs/src/component.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 5adcfc112c5f8..cdf93adb6d060 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -227,7 +227,7 @@ use derive_more::derive::{Display, Error}; /// ``` /// /// In general, this shouldn't happen often, but when it does the algorithm for choosing the constructor from the tree is simple and predictable: -/// 1. A constructor from a direct #[require()], if one exists, is selected with priority. +/// 1. A constructor from a direct `#[require()]`, if one exists, is selected with priority. /// 2. Otherwise, perform a Depth First Search on the tree of requirements and select the first one found. /// /// From a user perspective, just think about this as the following: