
# Objective - Closes #15577 ## Solution The following functions can now also take multiple component IDs and return multiple pointers back: - `EntityRef::get_by_id` - `EntityMut::get_by_id` - `EntityMut::into_borrow_by_id` - `EntityMut::get_mut_by_id` - `EntityMut::into_mut_by_id` - `EntityWorldMut::get_by_id` - `EntityWorldMut::into_borrow_by_id` - `EntityWorldMut::get_mut_by_id` - `EntityWorldMut::into_mut_by_id` If you pass in X, you receive Y: - give a single `ComponentId`, receive a single `Ptr`/`MutUntyped` - give a `[ComponentId; N]` (array), receive a `[Ptr; N]`/`[MutUntyped; N]` - give a `&[ComponentId; N]` (array), receive a `[Ptr; N]`/`[MutUntyped; N]` - give a `&[ComponentId]` (slice), receive a `Vec<Ptr>`/`Vec<MutUntyped>` - give a `&HashSet<ComponentId>`, receive a `HashMap<ComponentId, Ptr>`/`HashMap<ComponentId, MutUntyped>` ## Testing - Added 4 new tests. --- ## Migration Guide - The following functions now return an `Result<_, EntityComponentError>` instead of a `Option<_>`: `EntityRef::get_by_id`, `EntityMut::get_by_id`, `EntityMut::into_borrow_by_id`, `EntityMut::get_mut_by_id`, `EntityMut::into_mut_by_id`, `EntityWorldMut::get_by_id`, `EntityWorldMut::into_borrow_by_id`, `EntityWorldMut::get_mut_by_id`, `EntityWorldMut::into_mut_by_id`
24 lines
1.0 KiB
Rust
24 lines
1.0 KiB
Rust
//! Contains error types returned by bevy's schedule.
|
|
|
|
use thiserror::Error;
|
|
|
|
use crate::{component::ComponentId, schedule::InternedScheduleLabel};
|
|
|
|
/// The error type returned by [`World::try_run_schedule`] if the provided schedule does not exist.
|
|
///
|
|
/// [`World::try_run_schedule`]: crate::world::World::try_run_schedule
|
|
#[derive(Error, Debug)]
|
|
#[error("The schedule with the label {0:?} was not found.")]
|
|
pub struct TryRunScheduleError(pub InternedScheduleLabel);
|
|
|
|
/// An error that occurs when dynamically retrieving components from an entity.
|
|
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum EntityComponentError {
|
|
/// The component with the given [`ComponentId`] does not exist on the entity.
|
|
#[error("The component with ID {0:?} does not exist on the entity.")]
|
|
MissingComponent(ComponentId),
|
|
/// The component with the given [`ComponentId`] was requested mutably more than once.
|
|
#[error("The component with ID {0:?} was requested mutably more than once.")]
|
|
AliasedMutability(ComponentId),
|
|
}
|