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

Provide public unsafe EntityRef::get_change_ticks_by_id that takes ComponentId #6682

Closed
sQu1rr opened this issue Nov 18, 2022 · 2 comments
Closed
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@sQu1rr
Copy link
Contributor

sQu1rr commented Nov 18, 2022

What problem does this solve or what need does it fill?

I need to get the change ticks on the type-erased component for some entities. Basically EnitityRef::get_change_ticks but with ComponentId instead of T. I currently use the modified get_ticks function. My use-case is identifying all entities with changed components, and serializing these components, hence I cannot know the component type in advance.

What solution would you like?

Solution is to define (unsafe?) public get_chage_ticks_by_id() that takes ComponentId instead of T. It should ideally be implemented for both EntityRef and EntityMut for consistency.

What alternative(s) have you considered?

There is already a get_ticks_with_type function that is pub(crate). One solution would be to make it public.

Another solution would be to make get_ticks public.

@sQu1rr sQu1rr added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Nov 18, 2022
@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 and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Nov 18, 2022
@jakobhellermann
Copy link
Contributor

I don't see why such a function would be unsafe, it just needs to return nothing when the component ID doesn't exist on the entity.

@sQu1rr
Copy link
Contributor Author

sQu1rr commented Nov 18, 2022

You are right it shouldn't. I hastily concluded it should be unsafe when saw that the internal functions are unsafe e.g. get_ticks_with_type

I will start working on a PR

@bors bors bot closed this as completed in 9b72780 Dec 2, 2022
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
…entId` (bevyengine#6683)

# Objective

Fixes bevyengine#6682 

## Solution

Add `EntityRef::get_change_ticks_by_id`
Add `EntityMut::get_change_ticks_by_id`


Co-authored-by: Aleksandr Belkin <sQu1rr@users.noreply.github.com>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…entId` (bevyengine#6683)

# Objective

Fixes bevyengine#6682 

## Solution

Add `EntityRef::get_change_ticks_by_id`
Add `EntityMut::get_change_ticks_by_id`


Co-authored-by: Aleksandr Belkin <sQu1rr@users.noreply.github.com>
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
Projects
None yet
3 participants