Skip to content

Commit

Permalink
Remove deprecated ECS items (#16853)
Browse files Browse the repository at this point in the history
# Objective

- Cleanup deprecated code

## Solution

- Removed `#[deprecated]` items which were marked as such in 0.15 or
prior versions.

## Migration Guide

- The following deprecated items were removed: `Events::get_reader`,
`Events::get_reader_current`, `ManualEventReader`,
`Condition::and_then`, `Condition::or_else`, `World::,many_entities`,
`World::many_entities_mut`, `World::get_many_entities`,
`World::get_many_entities_dynamic`, `World::get_many_entities_mut`,
`World::get_many_entities_dynamic_mut`,
`World::get_many_entities_from_set_mut`
  • Loading branch information
ItsDoot authored Dec 17, 2024
1 parent dff3a54 commit cc0f6a8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 402 deletions.
22 changes: 0 additions & 22 deletions crates/bevy_ecs/src/event/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,28 +192,6 @@ impl<E: Event> Events<E> {
}
}

#[deprecated(
since = "0.14.0",
note = "`get_reader` has been deprecated. Please use `get_cursor` instead."
)]
/// Gets a new [`EventCursor`]. This will include all events already in the event buffers.
pub fn get_reader(&self) -> EventCursor<E> {
EventCursor::default()
}

#[deprecated(
since = "0.14.0",
note = "`get_reader_current` has been replaced. Please use `get_cursor_current` instead."
)]
/// Gets a new [`EventCursor`]. This will ignore all events already in the event buffers.
/// It will read all future events.
pub fn get_reader_current(&self) -> EventCursor<E> {
EventCursor {
last_event_count: self.event_count,
..Default::default()
}
}

/// Swaps the event buffers and clears the oldest event buffer. In general, this should be
/// called once per frame/update.
///
Expand Down
11 changes: 0 additions & 11 deletions crates/bevy_ecs/src/event/event_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ use bevy_ecs::event::{
use bevy_ecs::event::{EventMutParIter, EventParIter};
use core::marker::PhantomData;

// Deprecated in favor of `EventCursor`, there is no nice way to deprecate this
// because generic constraints are not allowed in type aliases, so this will always
// 'dead code'. Hence the `#[allow(dead_code)]`.
#[deprecated(
since = "0.14.0",
note = "`ManualEventReader` has been replaced. Please use `EventCursor` instead."
)]
#[doc(alias = "EventCursor")]
#[allow(dead_code)]
pub type ManualEventReader<E> = EventCursor<E>;

/// Stores the state for an [`EventReader`] or [`EventMutator`].
///
/// Access to the [`Events<E>`] resource is required to read any incoming events.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub use bevy_ptr as ptr;
///
/// This includes the most common types in this crate, re-exported for your convenience.
pub mod prelude {
#[allow(deprecated)]
#[expect(deprecated)]
#[doc(hidden)]
pub use crate::{
bundle::Bundle,
Expand Down
115 changes: 7 additions & 108 deletions crates/bevy_ecs/src/schedule/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,57 +123,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
CombinatorSystem::new(a, b, Cow::Owned(name))
}

/// Returns a new run condition that only returns `true`
/// if both this one and the passed `and_then` return `true`.
///
/// The returned run condition is short-circuiting, meaning
/// `and_then` will only be invoked if `self` returns `true`.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// #[derive(Resource, PartialEq)]
/// struct R(u32);
///
/// # let mut app = Schedule::default();
/// # let mut world = World::new();
/// # fn my_system() {}
/// app.add_systems(
/// // The `resource_equals` run condition will fail since we don't initialize `R`,
/// // just like if we used `Res<R>` in a system.
/// my_system.run_if(resource_equals(R(0))),
/// );
/// # app.run(&mut world);
/// ```
///
/// Use `.and_then()` to avoid checking the condition.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # #[derive(Resource, PartialEq)]
/// # struct R(u32);
/// # let mut app = Schedule::default();
/// # let mut world = World::new();
/// # fn my_system() {}
/// app.add_systems(
/// // `resource_equals` will only get run if the resource `R` exists.
/// my_system.run_if(resource_exists::<R>.and_then(resource_equals(R(0)))),
/// );
/// # app.run(&mut world);
/// ```
///
/// Note that in this case, it's better to just use the run condition [`resource_exists_and_equals`].
///
/// [`resource_exists_and_equals`]: common_conditions::resource_exists_and_equals
#[deprecated(
note = "Users should use the `.and(condition)` method in lieu of `.and_then(condition)`"
)]
fn and_then<M, C: Condition<M, In>>(self, and_then: C) -> And<Self::System, C::System> {
self.and(and_then)
}

/// Returns a new run condition that only returns `false`
/// if both this one and the passed `nand` return `true`.
///
Expand Down Expand Up @@ -325,53 +274,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
CombinatorSystem::new(a, b, Cow::Owned(name))
}

/// Returns a new run condition that returns `true`
/// if either this one or the passed `or` return `true`.
///
/// The returned run condition is short-circuiting, meaning
/// `or` will only be invoked if `self` returns `false`.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// #[derive(Resource, PartialEq)]
/// struct A(u32);
///
/// #[derive(Resource, PartialEq)]
/// struct B(u32);
///
/// # let mut app = Schedule::default();
/// # let mut world = World::new();
/// # #[derive(Resource)] struct C(bool);
/// # fn my_system(mut c: ResMut<C>) { c.0 = true; }
/// app.add_systems(
/// // Only run the system if either `A` or `B` exist.
/// my_system.run_if(resource_exists::<A>.or(resource_exists::<B>)),
/// );
/// #
/// # world.insert_resource(C(false));
/// # app.run(&mut world);
/// # assert!(!world.resource::<C>().0);
/// #
/// # world.insert_resource(A(0));
/// # app.run(&mut world);
/// # assert!(world.resource::<C>().0);
/// #
/// # world.remove_resource::<A>();
/// # world.insert_resource(B(0));
/// # world.insert_resource(C(false));
/// # app.run(&mut world);
/// # assert!(world.resource::<C>().0);
/// ```
#[deprecated(
note = "Users should use the `.or(condition)` method in lieu of `.or_else(condition)`"
)]
fn or_else<M, C: Condition<M, In>>(self, or_else: C) -> Or<Self::System, C::System> {
self.or(or_else)
}

/// Returns a new run condition that only returns `true`
/// if `self` and `xnor` **both** return `false` or **both** return `true`.
///
Expand Down Expand Up @@ -1406,7 +1308,6 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn run_condition_combinators() {
let mut world = World::new();
world.init_resource::<Counter>();
Expand All @@ -1415,23 +1316,21 @@ mod tests {
schedule.add_systems(
(
increment_counter.run_if(every_other_time.and(|| true)), // Run every odd cycle.
increment_counter.run_if(every_other_time.and_then(|| true)), // Run every odd cycle.
increment_counter.run_if(every_other_time.nand(|| false)), // Always run.
double_counter.run_if(every_other_time.nor(|| false)), // Run every even cycle.
increment_counter.run_if(every_other_time.or(|| true)), // Always run.
increment_counter.run_if(every_other_time.or_else(|| true)), // Always run.
increment_counter.run_if(every_other_time.nand(|| false)), // Always run.
double_counter.run_if(every_other_time.nor(|| false)), // Run every even cycle.
increment_counter.run_if(every_other_time.or(|| true)), // Always run.
increment_counter.run_if(every_other_time.xnor(|| true)), // Run every odd cycle.
double_counter.run_if(every_other_time.xnor(|| false)), // Run every even cycle.
double_counter.run_if(every_other_time.xnor(|| false)), // Run every even cycle.
increment_counter.run_if(every_other_time.xor(|| false)), // Run every odd cycle.
double_counter.run_if(every_other_time.xor(|| true)), // Run every even cycle.
double_counter.run_if(every_other_time.xor(|| true)), // Run every even cycle.
)
.chain(),
);

schedule.run(&mut world);
assert_eq!(world.resource::<Counter>().0, 7);
assert_eq!(world.resource::<Counter>().0, 5);
schedule.run(&mut world);
assert_eq!(world.resource::<Counter>().0, 72);
assert_eq!(world.resource::<Counter>().0, 52);
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_ecs/src/schedule/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ impl SystemSchedule {
}

/// See [`ApplyDeferred`].
#[deprecated = "Use `ApplyDeferred` instead. This was previously a function but is now a marker struct System."]
#[deprecated(
since = "0.16.0",
note = "Use `ApplyDeferred` instead. This was previously a function but is now a marker struct System."
)]
#[expect(non_upper_case_globals)]
pub const apply_deferred: ApplyDeferred = ApplyDeferred;

Expand Down
Loading

0 comments on commit cc0f6a8

Please sign in to comment.