Skip to content

Conversation

@cBournhonesque
Copy link
Contributor

Objective

#21601 introduced helpers to dynamically access relationship values
The RelationshipAccessor can be hard to use manually as it requires manipulating pointers; we can provide helper functions in UnsafeEntityCell and friends to access those.

cBournhonesque and others added 5 commits October 23, 2025 10:52
Change-Id: I0fc5f429189a9a55c233ac353cdb0767ed1502e6
fmt
Change-Id: If524fee3136c91872238be8bb005bfd726aa8ab4
@cBournhonesque cBournhonesque added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 23, 2025
@Victoronz
Copy link
Contributor

Is there a reason why these functions return Box<dyn Iterator> instead of impl Iterator?
Also I am curious how it would error if the '_ are removed, given how use<'a> became a thing recently.

@cBournhonesque
Copy link
Contributor Author

Is there a reason why these functions return Box<dyn Iterator> instead of impl Iterator? Also I am curious how it would error if the '_ are removed, given how use<'a> became a thing recently.

You're right, impl Iterator is much better! will change

@cBournhonesque
Copy link
Contributor Author

I'm not sure how to fix the compile-fail issue.
I generated the stderr file by running with BLESS="true"

@alice-i-cecile alice-i-cecile added S-Needs-Help The author needs help finishing this PR. and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 27, 2025
/// ```
///
/// [`Relationship`]: crate::relationship::Relationship
pub fn get_relationship_by_id(&self, relationship_id: ComponentId) -> Option<Entity> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this needs a clearer name. You're not getting the relationship itself, you're getting the contained entity.

/// ```
///
/// [`RelationshipTarget`]: crate::relationship::RelationshipTarget
pub fn get_relationship_targets_by_id(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on naming here.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much think this should exist and the implementation looks good but:

  1. Naming needs work.
  2. Needs tests.
  3. CI needs to pass <3 I've previously just copy-pasted output from CI >.>

@cBournhonesque
Copy link
Contributor Author

Very much think this should exist and the implementation looks good but:

  1. Naming needs work.
  2. Needs tests.
  3. CI needs to pass <3 I've previously just copy-pasted output from CI >.>
  1. For naming, what do you suggest? I was thinking of get_relationship_target and get_relationship_sources to reuse some of the naming conventions introduced by the Relationship trait.
  2. Yes, will add
  3. @mockersf do you have idea on how i can make the compile-fail pass? i tried running with BLESSED once, but it didn't seem to help

@alice-i-cecile
Copy link
Member

I was thinking of get_relationship_target and get_relationship_sources to reuse some of the naming conventions introduced by the Relationship trait.

This seems solid :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Help The author needs help finishing this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants