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
@ -9,6 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
|
|
||||||
|
/// A read-only reference to a particular [`Entity`] and all of its components
|
||||||
pub struct EntityRef<'w> {
|
pub struct EntityRef<'w> {
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
entity: Entity,
|
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> {
|
pub struct EntityMut<'w> {
|
||||||
world: &'w mut World,
|
world: &'w mut World,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
@ -464,6 +466,8 @@ impl<'w> EntityMut<'w> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to Storages?
|
// TODO: move to Storages?
|
||||||
|
/// Get a raw pointer to a particular [`Component`] on a particular [`Entity`] in the provided [`World`].
|
||||||
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside
|
/// `entity_location` must be within bounds of the given archetype and `entity` must exist inside
|
||||||
/// the archetype
|
/// the archetype
|
||||||
@ -494,6 +498,8 @@ unsafe fn get_component(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to Storages?
|
// TODO: move to Storages?
|
||||||
|
/// Get a raw pointer to the [`ComponentTicks`] of a particular [`Component`] on a particular [`Entity`] in the provided [World].
|
||||||
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Caller must ensure that `component_id` is valid
|
/// Caller must ensure that `component_id` is valid
|
||||||
#[inline]
|
#[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
|
/// # Safety
|
||||||
/// `entity_location` must be within bounds of an archetype that exists.
|
/// `entity_location` must be within bounds of an archetype that exists.
|
||||||
unsafe fn get_component_with_type(
|
unsafe fn get_component_with_type(
|
||||||
@ -578,6 +586,8 @@ unsafe fn get_component_with_type(
|
|||||||
get_component(world, component_id, entity, location)
|
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
|
/// # Safety
|
||||||
/// `entity_location` must be within bounds of an archetype that exists.
|
/// `entity_location` must be within bounds of an archetype that exists.
|
||||||
pub(crate) unsafe fn get_component_and_ticks_with_type(
|
pub(crate) unsafe fn get_component_and_ticks_with_type(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user