bevy/crates/bevy_ecs/src
Alice Cecile b34833f00c
Add an example teaching users about custom relationships (#17443)
# Objective

After #17398, Bevy now has relations! We don't teach users how to make /
work with these in the examples yet though, but we definitely should.

## Solution

- Add a simple abstract example that goes over defining, spawning,
traversing and removing a custom relations.
- ~~Add `Relationship` and `RelationshipTarget` to the prelude: the
trait methods are really helpful here.~~
- this causes subtle ambiguities with method names and weird compiler
errors. Not doing it here!
- Clean up related documentation that I referenced when writing this
example.

## Testing

`cargo run --example relationships`

## Notes to reviewers

1. Yes, I know that the cycle detection code could be more efficient. I
decided to reduce the caching to avoid distracting from the broader
point of "here's how you traverse relationships".
2. Instead of using an `App`, I've decide to use
`World::run_system_once` + system functions defined inside of `main` to
do something closer to literate programming.

---------

Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
2025-01-20 23:17:38 +00:00
..
entity Parent -> ChildOf (#17427) 2025-01-20 22:13:29 +00:00
event Remove Event: Component trait bound using a wrapper type which impls Component (#17380) 2025-01-15 18:42:47 +00:00
identifier bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
observer Parent -> ChildOf (#17427) 2025-01-20 22:13:29 +00:00
query Add DefaultQueryFilters (#13120) 2025-01-20 21:57:39 +00:00
reflect Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
relationship Add an example teaching users about custom relationships (#17443) 2025-01-20 23:17:38 +00:00
schedule Diagnostics for label traits (#17441) 2025-01-20 21:51:26 +00:00
storage Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
system docs: enhance documentation in query.rs to clarify borrowing rules (#17370) 2025-01-20 21:31:20 +00:00
world Support non-Vec data structures in relations (#17447) 2025-01-20 21:26:08 +00:00
archetype.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
batching.rs Fix *most* clippy lints (#15906) 2024-10-14 20:52:35 +00:00
bundle.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
change_detection.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
component.rs Create bevy_platform_support Crate (#17250) 2025-01-20 20:45:30 +00:00
entity_disabling.rs Add DefaultQueryFilters (#13120) 2025-01-20 21:57:39 +00:00
hierarchy.rs Parent -> ChildOf (#17427) 2025-01-20 22:13:29 +00:00
intern.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
label.rs Add compile-time dyn compatible checks for DynEq, DynHash (#17254) 2025-01-09 07:30:54 +00:00
lib.rs Parent -> ChildOf (#17427) 2025-01-20 22:13:29 +00:00
name.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
removal_detection.rs Replace map + unwrap_or(true) with is_none_or (#17070) 2024-12-31 20:17:03 +00:00
result.rs Add no_std support to bevy_ecs (#16758) 2024-12-17 21:40:36 +00:00
traversal.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00