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

Add get_change_ticks method to EntityRef and EntityMut #2539

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

@TheRawMeatball
Copy link
Member

@TheRawMeatball TheRawMeatball commented Jul 25, 2021

Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.

@mockersf
Copy link
Member

@mockersf mockersf commented Jul 25, 2021

As this is a little advanced, some doc comments would be nice 😃

pub fn get_change_ticks<T: Component>(&self) -> Option<&'w ComponentTicks> {
// SAFE: entity location is valid and returned component is of type T
unsafe {
get_component_and_ticks_with_type(
Copy link
Contributor

@cart cart Aug 10, 2021

I know you're trying to reuse code here, but we don't need to retrieve the component for this operation. This seems like the sort of small inefficiency that we'd merge and then forget about. A theoretical get_ticks and the existing get_component and get_component_with_ticks methods probably have some refactoring potential to share code. They all need to "get the entity's offset in each storage". This seems like a relatively trivial refactor for Table storage, but Sparse Set storage would probably need some new get_with_dense_index_unchecked() apis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants