mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
Basic EntityRef and EntityMut docs (#3388)
# Objective - `EntityRef` and `EntityMut` are surpisingly important public types when working directly with the `World`. - They're undocumented. ## Solution - Just add docs!
This commit is contained in:
parent
5155034a58
commit
4bcb310008
1 changed files with 10 additions and 0 deletions
|
@ -9,6 +9,7 @@ use crate::{
|
|||
};
|
||||
use std::any::TypeId;
|
||||
|
||||
/// A read-only reference to a particular [`Entity`] and all of its components
|
||||
pub struct EntityRef<'w> {
|
||||
world: &'w World,
|
||||
entity: Entity,
|
||||
|
@ -98,6 +99,7 @@ impl<'w> EntityRef<'w> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A mutable reference to a particular [`Entity`] and all of its components
|
||||
pub struct EntityMut<'w> {
|
||||
world: &'w mut World,
|
||||
entity: Entity,
|
||||
|
@ -464,6 +466,8 @@ impl<'w> EntityMut<'w> {
|
|||
}
|
||||
|
||||
// TODO: move to Storages?
|
||||
/// Get a raw pointer to a particular [`Component`] on a particular [`Entity`] in the provided [`World`].
|
||||
///
|
||||
/// # Safety
|
||||
/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside
|
||||
/// the archetype
|
||||
|
@ -494,6 +498,8 @@ unsafe fn get_component(
|
|||
}
|
||||
|
||||
// TODO: move to Storages?
|
||||
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] on a particular [`Entity`] in the provided [World].
|
||||
///
|
||||
/// # Safety
|
||||
/// Caller must ensure that `component_id` is valid
|
||||
#[inline]
|
||||
|
@ -566,6 +572,8 @@ unsafe fn take_component(
|
|||
}
|
||||
}
|
||||
|
||||
/// Get a raw pointer to a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
|
||||
///
|
||||
/// # Safety
|
||||
/// `entity_location` must be within bounds of an archetype that exists.
|
||||
unsafe fn get_component_with_type(
|
||||
|
@ -578,6 +586,8 @@ unsafe fn get_component_with_type(
|
|||
get_component(world, component_id, entity, location)
|
||||
}
|
||||
|
||||
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] by [`TypeId`] on a particular [`Entity`] in the provided [`World`].
|
||||
///
|
||||
/// # Safety
|
||||
/// `entity_location` must be within bounds of an archetype that exists.
|
||||
pub(crate) unsafe fn get_component_and_ticks_with_type(
|
||||
|
|
Loading…
Reference in a new issue