delete methods deprecated in 0.12 (#10693)
## Changelog - delete methods deprecated in 0.12
This commit is contained in:
parent
6f56380826
commit
11b1b3a24f
@ -421,17 +421,6 @@ impl App {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configures a system set in the default schedule, adding the set if it does not exist.
|
|
||||||
#[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")]
|
|
||||||
#[track_caller]
|
|
||||||
pub fn configure_set(
|
|
||||||
&mut self,
|
|
||||||
schedule: impl ScheduleLabel,
|
|
||||||
set: impl IntoSystemSetConfigs,
|
|
||||||
) -> &mut Self {
|
|
||||||
self.configure_sets(schedule, set)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Configures a collection of system sets in the default schedule, adding any sets that do not exist.
|
/// Configures a collection of system sets in the default schedule, adding any sets that do not exist.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn configure_sets(
|
pub fn configure_sets(
|
||||||
|
@ -597,10 +597,6 @@ impl Typed for AssetPath<'static> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Reflect for AssetPath<'static> {
|
impl Reflect for AssetPath<'static> {
|
||||||
#[inline]
|
|
||||||
fn type_name(&self) -> &str {
|
|
||||||
::core::any::type_name::<Self>()
|
|
||||||
}
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_represented_type_info(&self) -> Option<&'static TypeInfo> {
|
fn get_represented_type_info(&self) -> Option<&'static TypeInfo> {
|
||||||
Some(<Self as Typed>::type_info())
|
Some(<Self as Typed>::type_info())
|
||||||
|
@ -300,7 +300,7 @@ fn writer(mut writer: EventWriter<MyEvent>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reader(mut reader: EventReader<MyEvent>) {
|
fn reader(mut reader: EventReader<MyEvent>) {
|
||||||
for event in reader.iter() {
|
for event in reader.read() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -131,12 +131,12 @@ struct EventInstance<E: Event> {
|
|||||||
/// events.send(MyEvent { value: 1 });
|
/// events.send(MyEvent { value: 1 });
|
||||||
///
|
///
|
||||||
/// // somewhere else: read the events
|
/// // somewhere else: read the events
|
||||||
/// for event in reader.iter(&events) {
|
/// for event in reader.read(&events) {
|
||||||
/// assert_eq!(event.value, 1)
|
/// assert_eq!(event.value, 1)
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// // events are only processed once per reader
|
/// // events are only processed once per reader
|
||||||
/// assert_eq!(reader.iter(&events).count(), 0);
|
/// assert_eq!(reader.read(&events).count(), 0);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// # Details
|
/// # Details
|
||||||
@ -421,25 +421,11 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
|
|||||||
self.reader.read(&self.events)
|
self.reader.read(&self.events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates over the events this [`EventReader`] has not seen yet. This updates the
|
|
||||||
/// [`EventReader`]'s event counter, which means subsequent event reads will not include events
|
|
||||||
/// that happened before now.
|
|
||||||
#[deprecated = "use `.read()` instead."]
|
|
||||||
pub fn iter(&mut self) -> EventIterator<'_, E> {
|
|
||||||
self.reader.read(&self.events)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
|
/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
|
||||||
pub fn read_with_id(&mut self) -> EventIteratorWithId<'_, E> {
|
pub fn read_with_id(&mut self) -> EventIteratorWithId<'_, E> {
|
||||||
self.reader.read_with_id(&self.events)
|
self.reader.read_with_id(&self.events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events.
|
|
||||||
#[deprecated = "use `.read_with_id() instead."]
|
|
||||||
pub fn iter_with_id(&mut self) -> EventIteratorWithId<'_, E> {
|
|
||||||
self.reader.read_with_id(&self.events)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determines the number of events available to be read from this [`EventReader`] without consuming any.
|
/// Determines the number of events available to be read from this [`EventReader`] without consuming any.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.reader.len(&self.events)
|
self.reader.len(&self.events)
|
||||||
@ -472,8 +458,8 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
|
|||||||
|
|
||||||
/// Consumes all available events.
|
/// Consumes all available events.
|
||||||
///
|
///
|
||||||
/// This means these events will not appear in calls to [`EventReader::iter()`] or
|
/// This means these events will not appear in calls to [`EventReader::read()`] or
|
||||||
/// [`EventReader::iter_with_id()`] and [`EventReader::is_empty()`] will return `true`.
|
/// [`EventReader::read_with_id()`] and [`EventReader::is_empty()`] will return `true`.
|
||||||
///
|
///
|
||||||
/// For usage, see [`EventReader::is_empty()`].
|
/// For usage, see [`EventReader::is_empty()`].
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
@ -583,23 +569,11 @@ impl<E: Event> ManualEventReader<E> {
|
|||||||
self.read_with_id(events).without_id()
|
self.read_with_id(events).without_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`EventReader::iter`]
|
|
||||||
#[deprecated = "use `.read()` instead."]
|
|
||||||
pub fn iter<'a>(&'a mut self, events: &'a Events<E>) -> EventIterator<'a, E> {
|
|
||||||
self.read_with_id(events).without_id()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// See [`EventReader::read_with_id`]
|
/// See [`EventReader::read_with_id`]
|
||||||
pub fn read_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
|
pub fn read_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
|
||||||
EventIteratorWithId::new(self, events)
|
EventIteratorWithId::new(self, events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See [`EventReader::iter_with_id`]
|
|
||||||
#[deprecated = "use `.read_with_id() instead."]
|
|
||||||
pub fn iter_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
|
|
||||||
EventIteratorWithId::new(self, events)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// See [`EventReader::len`]
|
/// See [`EventReader::len`]
|
||||||
pub fn len(&self, events: &Events<E>) -> usize {
|
pub fn len(&self, events: &Events<E>) -> usize {
|
||||||
// The number of events in this reader is the difference between the most recent event
|
// The number of events in this reader is the difference between the most recent event
|
||||||
@ -636,13 +610,6 @@ pub struct EventIterator<'a, E: Event> {
|
|||||||
iter: EventIteratorWithId<'a, E>,
|
iter: EventIteratorWithId<'a, E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator that yields any unread events from an [`EventReader`] or [`ManualEventReader`].
|
|
||||||
///
|
|
||||||
/// This is a type alias for [`EventIterator`], which used to be called `ManualEventIterator`.
|
|
||||||
/// This type alias will be removed in the next release of bevy, so you should use [`EventIterator`] directly instead.
|
|
||||||
#[deprecated = "This type has been renamed to `EventIterator`."]
|
|
||||||
pub type ManualEventIterator<'a, E> = EventIterator<'a, E>;
|
|
||||||
|
|
||||||
impl<'a, E: Event> Iterator for EventIterator<'a, E> {
|
impl<'a, E: Event> Iterator for EventIterator<'a, E> {
|
||||||
type Item = &'a E;
|
type Item = &'a E;
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -683,13 +650,6 @@ pub struct EventIteratorWithId<'a, E: Event> {
|
|||||||
unread: usize,
|
unread: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator that yields any unread events (and their IDs) from an [`EventReader`] or [`ManualEventReader`].
|
|
||||||
///
|
|
||||||
/// This is a type alias for [`EventIteratorWithId`], which used to be called `ManualEventIteratorWithId`.
|
|
||||||
/// This type alias will be removed in the next release of bevy, so you should use [`EventIteratorWithId`] directly instead.
|
|
||||||
#[deprecated = "This type has been renamed to `EventIteratorWithId`."]
|
|
||||||
pub type ManualEventIteratorWithId<'a, E> = EventIteratorWithId<'a, E>;
|
|
||||||
|
|
||||||
impl<'a, E: Event> EventIteratorWithId<'a, E> {
|
impl<'a, E: Event> EventIteratorWithId<'a, E> {
|
||||||
/// Creates a new iterator that yields any `events` that have not yet been seen by `reader`.
|
/// Creates a new iterator that yields any `events` that have not yet been seen by `reader`.
|
||||||
pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self {
|
pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self {
|
||||||
|
@ -28,10 +28,6 @@ pub mod prelude {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
pub use crate::reflect::{AppTypeRegistry, ReflectComponent, ReflectResource};
|
pub use crate::reflect::{AppTypeRegistry, ReflectComponent, ReflectResource};
|
||||||
#[allow(deprecated)]
|
|
||||||
pub use crate::system::adapter::{
|
|
||||||
self as system_adapter, dbg, error, ignore, info, unwrap, warn,
|
|
||||||
};
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
bundle::Bundle,
|
bundle::Bundle,
|
||||||
|
@ -156,19 +156,6 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryParIter<'w, 's, Q, F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs `func` on each query result in parallel.
|
|
||||||
///
|
|
||||||
/// # Panics
|
|
||||||
/// If the [`ComputeTaskPool`] is not initialized. If using this from a query that is being
|
|
||||||
/// initialized and run from the ECS scheduler, this should never panic.
|
|
||||||
///
|
|
||||||
/// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool
|
|
||||||
#[inline]
|
|
||||||
#[deprecated = "use `.for_each(...)` instead."]
|
|
||||||
pub fn for_each_mut<FN: Fn(QueryItem<'w, Q>) + Send + Sync + Clone>(self, func: FN) {
|
|
||||||
self.for_each(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
|
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
|
||||||
fn get_batch_size(&self, thread_count: usize) -> usize {
|
fn get_batch_size(&self, thread_count: usize) -> usize {
|
||||||
if self.batching_strategy.batch_size_limits.is_empty() {
|
if self.batching_strategy.batch_size_limits.is_empty() {
|
||||||
|
@ -127,7 +127,7 @@ pub trait ReflectCommandExt {
|
|||||||
/// // ComponentA or ComponentB. No matter which component is in the resource though,
|
/// // ComponentA or ComponentB. No matter which component is in the resource though,
|
||||||
/// // we can attempt to remove any component of that same type from an entity.
|
/// // we can attempt to remove any component of that same type from an entity.
|
||||||
/// commands.entity(prefab.entity)
|
/// commands.entity(prefab.entity)
|
||||||
/// .remove_reflect(prefab.component.type_name().to_owned());
|
/// .remove_reflect(prefab.component.reflect_type_path().to_owned());
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -128,7 +128,7 @@ impl RemovedComponentEvents {
|
|||||||
/// # #[derive(Component)]
|
/// # #[derive(Component)]
|
||||||
/// # struct MyComponent;
|
/// # struct MyComponent;
|
||||||
/// fn react_on_removal(mut removed: RemovedComponents<MyComponent>) {
|
/// fn react_on_removal(mut removed: RemovedComponents<MyComponent>) {
|
||||||
/// removed.iter().for_each(|removed_entity| println!("{:?}", removed_entity));
|
/// removed.read().for_each(|removed_entity| println!("{:?}", removed_entity));
|
||||||
/// }
|
/// }
|
||||||
/// # bevy_ecs::system::assert_is_system(react_on_removal);
|
/// # bevy_ecs::system::assert_is_system(react_on_removal);
|
||||||
/// ```
|
/// ```
|
||||||
@ -208,14 +208,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
|
|||||||
.map(RemovedComponentEntity::into)
|
.map(RemovedComponentEntity::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates over the events this [`RemovedComponents`] has not seen yet. This updates the
|
|
||||||
/// [`RemovedComponents`]'s event counter, which means subsequent event reads will not include events
|
|
||||||
/// that happened before now.
|
|
||||||
#[deprecated = "use `.read()` instead."]
|
|
||||||
pub fn iter(&mut self) -> RemovedIter<'_> {
|
|
||||||
self.read()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
|
/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
|
||||||
pub fn read_with_id(&mut self) -> RemovedIterWithId<'_> {
|
pub fn read_with_id(&mut self) -> RemovedIterWithId<'_> {
|
||||||
self.reader_mut_with_events()
|
self.reader_mut_with_events()
|
||||||
@ -225,12 +217,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
|
|||||||
.map(map_id_events)
|
.map(map_id_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events.
|
|
||||||
#[deprecated = "use `.read_with_id()` instead."]
|
|
||||||
pub fn iter_with_id(&mut self) -> RemovedIterWithId<'_> {
|
|
||||||
self.read_with_id()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determines the number of removal events available to be read from this [`RemovedComponents`] without consuming any.
|
/// Determines the number of removal events available to be read from this [`RemovedComponents`] without consuming any.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.events()
|
self.events()
|
||||||
|
@ -232,13 +232,6 @@ impl Schedule {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configures a system set in this schedule, adding it if it does not exist.
|
|
||||||
#[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")]
|
|
||||||
#[track_caller]
|
|
||||||
pub fn configure_set(&mut self, set: impl IntoSystemSetConfigs) -> &mut Self {
|
|
||||||
self.configure_sets(set)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Configures a collection of system sets in this schedule, adding them if they does not exist.
|
/// Configures a collection of system sets in this schedule, adding them if they does not exist.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn configure_sets(&mut self, sets: impl IntoSystemSetConfigs) -> &mut Self {
|
pub fn configure_sets(&mut self, sets: impl IntoSystemSetConfigs) -> &mut Self {
|
||||||
|
@ -156,7 +156,7 @@ impl SystemMeta {
|
|||||||
/// world.resource_scope(|world, mut cached_state: Mut<CachedSystemState>| {
|
/// world.resource_scope(|world, mut cached_state: Mut<CachedSystemState>| {
|
||||||
/// let mut event_reader = cached_state.event_state.get_mut(world);
|
/// let mut event_reader = cached_state.event_state.get_mut(world);
|
||||||
///
|
///
|
||||||
/// for events in event_reader.iter() {
|
/// for events in event_reader.read() {
|
||||||
/// println!("Hello World!");
|
/// println!("Hello World!");
|
||||||
/// }
|
/// }
|
||||||
/// });
|
/// });
|
||||||
|
@ -232,226 +232,6 @@ impl<T: System> IntoSystem<T::In, T::Out, ()> for T {
|
|||||||
/// ```
|
/// ```
|
||||||
pub struct In<In>(pub In);
|
pub struct In<In>(pub In);
|
||||||
|
|
||||||
/// A collection of common adapters for [piping](crate::system::PipeSystem) the result of a system.
|
|
||||||
#[deprecated = "this form of system adapter has been deprecated in favor of `system.map(...)`"]
|
|
||||||
pub mod adapter {
|
|
||||||
use crate::system::In;
|
|
||||||
use bevy_utils::tracing;
|
|
||||||
use std::fmt::Debug;
|
|
||||||
|
|
||||||
/// Converts a regular function into a system adapter.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// fn return1() -> u64 { 1 }
|
|
||||||
///
|
|
||||||
/// return1
|
|
||||||
/// .pipe(system_adapter::new(u32::try_from))
|
|
||||||
/// .pipe(system_adapter::unwrap)
|
|
||||||
/// .pipe(print);
|
|
||||||
///
|
|
||||||
/// fn print(In(x): In<impl std::fmt::Debug>) {
|
|
||||||
/// println!("{x:?}");
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(...)` instead"]
|
|
||||||
pub fn new<T, U>(mut f: impl FnMut(T) -> U) -> impl FnMut(In<T>) -> U {
|
|
||||||
move |In(x)| f(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that unwraps the `Ok` variant of a [`Result`].
|
|
||||||
/// This is useful for fallible systems that should panic in the case of an error.
|
|
||||||
///
|
|
||||||
/// There is no equivalent adapter for [`Option`]. Instead, it's best to provide
|
|
||||||
/// an error message and convert to a `Result` using `ok_or{_else}`.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// Panicking on error
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// let mut sched = Schedule::default();
|
|
||||||
/// sched.add_systems(
|
|
||||||
/// // Panic if the load system returns an error.
|
|
||||||
/// load_save_system.pipe(system_adapter::unwrap)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system which may fail irreparably.
|
|
||||||
/// fn load_save_system() -> Result<(), std::io::Error> {
|
|
||||||
/// let save_file = open_file("my_save.json")?;
|
|
||||||
/// dbg!(save_file);
|
|
||||||
/// Ok(())
|
|
||||||
/// }
|
|
||||||
/// # fn open_file(name: &str) -> Result<&'static str, std::io::Error>
|
|
||||||
/// # { Ok("hello world") }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(Result::unwrap)` instead"]
|
|
||||||
pub fn unwrap<T, E: Debug>(In(res): In<Result<T, E>>) -> T {
|
|
||||||
res.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that utilizes the [`bevy_utils::tracing::info!`] macro to print system information.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// let mut sched = Schedule::default();
|
|
||||||
/// sched.add_systems(
|
|
||||||
/// // Prints system information.
|
|
||||||
/// data_pipe_system.pipe(system_adapter::info)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system that returns a String output.
|
|
||||||
/// fn data_pipe_system() -> String {
|
|
||||||
/// "42".to_string()
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(bevy_utils::info)` instead"]
|
|
||||||
pub fn info<T: Debug>(In(data): In<T>) {
|
|
||||||
tracing::info!("{:?}", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that utilizes the [`bevy_utils::tracing::debug!`] macro to print the output of a system.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// let mut sched = Schedule::default();
|
|
||||||
/// sched.add_systems(
|
|
||||||
/// // Prints debug data from system.
|
|
||||||
/// parse_message_system.pipe(system_adapter::dbg)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system that returns a Result<usize, String> output.
|
|
||||||
/// fn parse_message_system() -> Result<usize, std::num::ParseIntError> {
|
|
||||||
/// Ok("42".parse()?)
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(bevy_utils::dbg)` instead"]
|
|
||||||
pub fn dbg<T: Debug>(In(data): In<T>) {
|
|
||||||
tracing::debug!("{:?}", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that utilizes the [`bevy_utils::tracing::warn!`] macro to print the output of a system.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// # let mut sched = Schedule::default();
|
|
||||||
/// sched.add_systems(
|
|
||||||
/// // Prints system warning if system returns an error.
|
|
||||||
/// warning_pipe_system.pipe(system_adapter::warn)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system that returns a Result<(), String> output.
|
|
||||||
/// fn warning_pipe_system() -> Result<(), String> {
|
|
||||||
/// Err("Got to rusty?".to_string())
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(bevy_utils::warn)` instead"]
|
|
||||||
pub fn warn<E: Debug>(In(res): In<Result<(), E>>) {
|
|
||||||
if let Err(warn) = res {
|
|
||||||
tracing::warn!("{:?}", warn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that utilizes the [`bevy_utils::tracing::error!`] macro to print the output of a system.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// let mut sched = Schedule::default();
|
|
||||||
/// sched.add_systems(
|
|
||||||
/// // Prints system error if system fails.
|
|
||||||
/// parse_error_message_system.pipe(system_adapter::error)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system that returns a Result<())> output.
|
|
||||||
/// fn parse_error_message_system() -> Result<(), String> {
|
|
||||||
/// Err("Some error".to_owned())
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(bevy_utils::error)` instead"]
|
|
||||||
pub fn error<E: Debug>(In(res): In<Result<(), E>>) {
|
|
||||||
if let Err(error) = res {
|
|
||||||
tracing::error!("{:?}", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// System adapter that ignores the output of the previous system in a pipe.
|
|
||||||
/// This is useful for fallible systems that should simply return early in case of an `Err`/`None`.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// Returning early
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use bevy_ecs::prelude::*;
|
|
||||||
///
|
|
||||||
/// // Marker component for an enemy entity.
|
|
||||||
/// #[derive(Component)]
|
|
||||||
/// struct Monster;
|
|
||||||
///
|
|
||||||
/// // Building a new schedule/app...
|
|
||||||
/// # let mut sched = Schedule::default(); sched
|
|
||||||
/// .add_systems(
|
|
||||||
/// // If the system fails, just move on and try again next frame.
|
|
||||||
/// fallible_system.pipe(system_adapter::ignore)
|
|
||||||
/// )
|
|
||||||
/// // ...
|
|
||||||
/// # ;
|
|
||||||
/// # let mut world = World::new();
|
|
||||||
/// # sched.run(&mut world);
|
|
||||||
///
|
|
||||||
/// // A system which may return early. It's more convenient to use the `?` operator for this.
|
|
||||||
/// fn fallible_system(
|
|
||||||
/// q: Query<Entity, With<Monster>>
|
|
||||||
/// ) -> Option<()> {
|
|
||||||
/// let monster_id = q.iter().next()?;
|
|
||||||
/// println!("Monster entity is {monster_id:?}");
|
|
||||||
/// Some(())
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
#[deprecated = "use `.map(std::mem::drop)` instead"]
|
|
||||||
pub fn ignore<T>(In(_): In<T>) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ensure that a given function is a [system](System).
|
/// Ensure that a given function is a [system](System).
|
||||||
///
|
///
|
||||||
/// This should be used when writing doc examples,
|
/// This should be used when writing doc examples,
|
||||||
|
@ -322,7 +322,7 @@ fn assert_component_access_compatibility(
|
|||||||
/// &World,
|
/// &World,
|
||||||
/// )>,
|
/// )>,
|
||||||
/// ) {
|
/// ) {
|
||||||
/// for event in set.p0().iter() {
|
/// for event in set.p0().read() {
|
||||||
/// // ...
|
/// // ...
|
||||||
/// # let _event = event;
|
/// # let _event = event;
|
||||||
/// }
|
/// }
|
||||||
|
@ -73,24 +73,6 @@ pub enum ReflectOwned {
|
|||||||
/// [derive macro]: bevy_reflect_derive::Reflect
|
/// [derive macro]: bevy_reflect_derive::Reflect
|
||||||
/// [crate-level documentation]: crate
|
/// [crate-level documentation]: crate
|
||||||
pub trait Reflect: DynamicTypePath + Any + Send + Sync {
|
pub trait Reflect: DynamicTypePath + Any + Send + Sync {
|
||||||
/// Returns the type path of the underlying type.
|
|
||||||
///
|
|
||||||
/// This type path will either be found through [`get_represented_type_info`]
|
|
||||||
/// or taken from a [`TypePath`] implementation if the former isn't available.
|
|
||||||
///
|
|
||||||
/// This method is deprecated; please consider migrating to one of the above methods.
|
|
||||||
///
|
|
||||||
/// [`get_represented_type_info`]: Reflect::get_represented_type_info
|
|
||||||
#[deprecated(
|
|
||||||
since = "0.12.0",
|
|
||||||
note = "view the method documentation to find alternatives to this method."
|
|
||||||
)]
|
|
||||||
fn type_name(&self) -> &str {
|
|
||||||
self.get_represented_type_info()
|
|
||||||
.map(|info| info.type_path())
|
|
||||||
.unwrap_or_else(|| self.reflect_type_path())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the [`TypeInfo`] of the type _represented_ by this value.
|
/// Returns the [`TypeInfo`] of the type _represented_ by this value.
|
||||||
///
|
///
|
||||||
/// For most types, this will simply return their own `TypeInfo`.
|
/// For most types, this will simply return their own `TypeInfo`.
|
||||||
|
Loading…
Reference in New Issue
Block a user