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

Expand the RelationshipSourceCollection to return more information #18241

Merged

Conversation

Brezak
Copy link
Contributor

@Brezak Brezak commented Mar 10, 2025

Objective

While redoing #18058 I needed RelationshipSourceCollection (henceforth referred to as the Trait) to implement clear so I added it.

Solution

Add the clear method to the Trait.
Also make add and remove report if they succeeded.

Testing

Eyeballs


Showcase

The RelationshipSourceCollection trait now reports if adding or removing an entity from it was successful.
It also not contains the clear method so you can easily clear the collection in generic contexts.

Changes

EDITED by Alice: We should get this into 0.16, so no migration guide needed.

The RelationshipSourceCollection methods add and remove now need to return a boolean indicating if they were successful (adding a entity to a set that already contains it counts as failure). Additionally the clear method has been added to support clearing the collection in generic contexts.

@Brezak
Copy link
Contributor Author

Brezak commented Mar 10, 2025

I've also considered adding the shrink_to_fit method to the Trait but I don't know how useful it would be.

@Brezak Brezak force-pushed the relationship-collection-bools branch from 784005c to 0dede8e Compare March 10, 2025 20:27
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Mar 10, 2025
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Mar 10, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 10, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 10, 2025
Merged via the queue into bevyengine:main with commit 906d788 Mar 10, 2025
36 checks passed
@Brezak Brezak deleted the relationship-collection-bools branch March 10, 2025 22:58
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-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants