Skip to content

Commit cc0f6a8

Browse files
authored
Remove deprecated ECS items (#16853)
# 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`
1 parent dff3a54 commit cc0f6a8

File tree

6 files changed

+22
-402
lines changed

6 files changed

+22
-402
lines changed

crates/bevy_ecs/src/event/collections.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -192,28 +192,6 @@ impl<E: Event> Events<E> {
192192
}
193193
}
194194

195-
#[deprecated(
196-
since = "0.14.0",
197-
note = "`get_reader` has been deprecated. Please use `get_cursor` instead."
198-
)]
199-
/// Gets a new [`EventCursor`]. This will include all events already in the event buffers.
200-
pub fn get_reader(&self) -> EventCursor<E> {
201-
EventCursor::default()
202-
}
203-
204-
#[deprecated(
205-
since = "0.14.0",
206-
note = "`get_reader_current` has been replaced. Please use `get_cursor_current` instead."
207-
)]
208-
/// Gets a new [`EventCursor`]. This will ignore all events already in the event buffers.
209-
/// It will read all future events.
210-
pub fn get_reader_current(&self) -> EventCursor<E> {
211-
EventCursor {
212-
last_event_count: self.event_count,
213-
..Default::default()
214-
}
215-
}
216-
217195
/// Swaps the event buffers and clears the oldest event buffer. In general, this should be
218196
/// called once per frame/update.
219197
///

crates/bevy_ecs/src/event/event_cursor.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ use bevy_ecs::event::{
66
use bevy_ecs::event::{EventMutParIter, EventParIter};
77
use core::marker::PhantomData;
88

9-
// Deprecated in favor of `EventCursor`, there is no nice way to deprecate this
10-
// because generic constraints are not allowed in type aliases, so this will always
11-
// 'dead code'. Hence the `#[allow(dead_code)]`.
12-
#[deprecated(
13-
since = "0.14.0",
14-
note = "`ManualEventReader` has been replaced. Please use `EventCursor` instead."
15-
)]
16-
#[doc(alias = "EventCursor")]
17-
#[allow(dead_code)]
18-
pub type ManualEventReader<E> = EventCursor<E>;
19-
209
/// Stores the state for an [`EventReader`] or [`EventMutator`].
2110
///
2211
/// Access to the [`Events<E>`] resource is required to read any incoming events.

crates/bevy_ecs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub use bevy_ptr as ptr;
5050
///
5151
/// This includes the most common types in this crate, re-exported for your convenience.
5252
pub mod prelude {
53-
#[allow(deprecated)]
53+
#[expect(deprecated)]
5454
#[doc(hidden)]
5555
pub use crate::{
5656
bundle::Bundle,

crates/bevy_ecs/src/schedule/condition.rs

Lines changed: 7 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -123,57 +123,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
123123
CombinatorSystem::new(a, b, Cow::Owned(name))
124124
}
125125

126-
/// Returns a new run condition that only returns `true`
127-
/// if both this one and the passed `and_then` return `true`.
128-
///
129-
/// The returned run condition is short-circuiting, meaning
130-
/// `and_then` will only be invoked if `self` returns `true`.
131-
///
132-
/// # Examples
133-
///
134-
/// ```
135-
/// use bevy_ecs::prelude::*;
136-
///
137-
/// #[derive(Resource, PartialEq)]
138-
/// struct R(u32);
139-
///
140-
/// # let mut app = Schedule::default();
141-
/// # let mut world = World::new();
142-
/// # fn my_system() {}
143-
/// app.add_systems(
144-
/// // The `resource_equals` run condition will fail since we don't initialize `R`,
145-
/// // just like if we used `Res<R>` in a system.
146-
/// my_system.run_if(resource_equals(R(0))),
147-
/// );
148-
/// # app.run(&mut world);
149-
/// ```
150-
///
151-
/// Use `.and_then()` to avoid checking the condition.
152-
///
153-
/// ```
154-
/// # use bevy_ecs::prelude::*;
155-
/// # #[derive(Resource, PartialEq)]
156-
/// # struct R(u32);
157-
/// # let mut app = Schedule::default();
158-
/// # let mut world = World::new();
159-
/// # fn my_system() {}
160-
/// app.add_systems(
161-
/// // `resource_equals` will only get run if the resource `R` exists.
162-
/// my_system.run_if(resource_exists::<R>.and_then(resource_equals(R(0)))),
163-
/// );
164-
/// # app.run(&mut world);
165-
/// ```
166-
///
167-
/// Note that in this case, it's better to just use the run condition [`resource_exists_and_equals`].
168-
///
169-
/// [`resource_exists_and_equals`]: common_conditions::resource_exists_and_equals
170-
#[deprecated(
171-
note = "Users should use the `.and(condition)` method in lieu of `.and_then(condition)`"
172-
)]
173-
fn and_then<M, C: Condition<M, In>>(self, and_then: C) -> And<Self::System, C::System> {
174-
self.and(and_then)
175-
}
176-
177126
/// Returns a new run condition that only returns `false`
178127
/// if both this one and the passed `nand` return `true`.
179128
///
@@ -325,53 +274,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
325274
CombinatorSystem::new(a, b, Cow::Owned(name))
326275
}
327276

328-
/// Returns a new run condition that returns `true`
329-
/// if either this one or the passed `or` return `true`.
330-
///
331-
/// The returned run condition is short-circuiting, meaning
332-
/// `or` will only be invoked if `self` returns `false`.
333-
///
334-
/// # Examples
335-
///
336-
/// ```
337-
/// use bevy_ecs::prelude::*;
338-
///
339-
/// #[derive(Resource, PartialEq)]
340-
/// struct A(u32);
341-
///
342-
/// #[derive(Resource, PartialEq)]
343-
/// struct B(u32);
344-
///
345-
/// # let mut app = Schedule::default();
346-
/// # let mut world = World::new();
347-
/// # #[derive(Resource)] struct C(bool);
348-
/// # fn my_system(mut c: ResMut<C>) { c.0 = true; }
349-
/// app.add_systems(
350-
/// // Only run the system if either `A` or `B` exist.
351-
/// my_system.run_if(resource_exists::<A>.or(resource_exists::<B>)),
352-
/// );
353-
/// #
354-
/// # world.insert_resource(C(false));
355-
/// # app.run(&mut world);
356-
/// # assert!(!world.resource::<C>().0);
357-
/// #
358-
/// # world.insert_resource(A(0));
359-
/// # app.run(&mut world);
360-
/// # assert!(world.resource::<C>().0);
361-
/// #
362-
/// # world.remove_resource::<A>();
363-
/// # world.insert_resource(B(0));
364-
/// # world.insert_resource(C(false));
365-
/// # app.run(&mut world);
366-
/// # assert!(world.resource::<C>().0);
367-
/// ```
368-
#[deprecated(
369-
note = "Users should use the `.or(condition)` method in lieu of `.or_else(condition)`"
370-
)]
371-
fn or_else<M, C: Condition<M, In>>(self, or_else: C) -> Or<Self::System, C::System> {
372-
self.or(or_else)
373-
}
374-
375277
/// Returns a new run condition that only returns `true`
376278
/// if `self` and `xnor` **both** return `false` or **both** return `true`.
377279
///
@@ -1406,7 +1308,6 @@ mod tests {
14061308
}
14071309

14081310
#[test]
1409-
#[allow(deprecated)]
14101311
fn run_condition_combinators() {
14111312
let mut world = World::new();
14121313
world.init_resource::<Counter>();
@@ -1415,23 +1316,21 @@ mod tests {
14151316
schedule.add_systems(
14161317
(
14171318
increment_counter.run_if(every_other_time.and(|| true)), // Run every odd cycle.
1418-
increment_counter.run_if(every_other_time.and_then(|| true)), // Run every odd cycle.
1419-
increment_counter.run_if(every_other_time.nand(|| false)), // Always run.
1420-
double_counter.run_if(every_other_time.nor(|| false)), // Run every even cycle.
1421-
increment_counter.run_if(every_other_time.or(|| true)), // Always run.
1422-
increment_counter.run_if(every_other_time.or_else(|| true)), // Always run.
1319+
increment_counter.run_if(every_other_time.nand(|| false)), // Always run.
1320+
double_counter.run_if(every_other_time.nor(|| false)), // Run every even cycle.
1321+
increment_counter.run_if(every_other_time.or(|| true)), // Always run.
14231322
increment_counter.run_if(every_other_time.xnor(|| true)), // Run every odd cycle.
1424-
double_counter.run_if(every_other_time.xnor(|| false)), // Run every even cycle.
1323+
double_counter.run_if(every_other_time.xnor(|| false)), // Run every even cycle.
14251324
increment_counter.run_if(every_other_time.xor(|| false)), // Run every odd cycle.
1426-
double_counter.run_if(every_other_time.xor(|| true)), // Run every even cycle.
1325+
double_counter.run_if(every_other_time.xor(|| true)), // Run every even cycle.
14271326
)
14281327
.chain(),
14291328
);
14301329

14311330
schedule.run(&mut world);
1432-
assert_eq!(world.resource::<Counter>().0, 7);
1331+
assert_eq!(world.resource::<Counter>().0, 5);
14331332
schedule.run(&mut world);
1434-
assert_eq!(world.resource::<Counter>().0, 72);
1333+
assert_eq!(world.resource::<Counter>().0, 52);
14351334
}
14361335

14371336
#[test]

crates/bevy_ecs/src/schedule/executor/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ impl SystemSchedule {
108108
}
109109

110110
/// See [`ApplyDeferred`].
111-
#[deprecated = "Use `ApplyDeferred` instead. This was previously a function but is now a marker struct System."]
111+
#[deprecated(
112+
since = "0.16.0",
113+
note = "Use `ApplyDeferred` instead. This was previously a function but is now a marker struct System."
114+
)]
112115
#[expect(non_upper_case_globals)]
113116
pub const apply_deferred: ApplyDeferred = ApplyDeferred;
114117

0 commit comments

Comments
 (0)