-
-
Notifications
You must be signed in to change notification settings - Fork 4k
[Merged by Bors] - make ComponentTicks::set_changed public #1711
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,8 +340,19 @@ impl ComponentTicks { | |
check_tick(&mut self.changed, change_tick); | ||
} | ||
|
||
/// Manually sets the change tick. | ||
/// Usually, this is done automatically via the [`Deref`](std::ops::Deref) implementation on [`Mut`](crate::world::Mut) or [`ResMut`](crate::system::ResMut) etc. | ||
/// | ||
/// # Example | ||
/// ```rust,no_run | ||
/// # use bevy_ecs::{world::World, component::ComponentTicks}; | ||
/// let world: World = todo!(); | ||
/// let component_ticks: ComponentTicks = todo!(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you intend to fill this in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just wanted the variables in scope, but I agree that Its hard to come up with a simple example as this is the code I used (copied from bevy): #[inline]
unsafe fn get_component_and_ticks(
world: &World,
component_id: ComponentId,
entity: Entity,
location: EntityLocation,
) -> Option<(*mut u8, *mut ComponentTicks)> {
let archetype = &world.archetypes()[location.archetype_id];
let component_info = world.components().get_info_unchecked(component_id);
match component_info.storage_type() {
StorageType::Table => {
let table = &world.storages().tables[archetype.table_id()];
let components = table.get_column(component_id)?;
let table_row = archetype.entity_table_row(location.index);
// SAFE: archetypes only store valid table_rows and the stored component type is T
Some((
components.get_unchecked(table_row),
components.get_ticks_unchecked(table_row),
))
}
StorageType::SparseSet => world
.storages()
.sparse_sets
.get(component_id)
.and_then(|sparse_set| sparse_set.get_with_ticks(entity)),
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah lets just change these to unimplemented(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
/// | ||
/// component_ticks.set_changed(world.read_change_tick()); | ||
/// ``` | ||
#[inline] | ||
pub(crate) fn set_changed(&mut self, change_tick: u32) { | ||
pub fn set_changed(&mut self, change_tick: u32) { | ||
self.changed = change_tick; | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.