@@ -123,57 +123,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
123
123
CombinatorSystem :: new ( a, b, Cow :: Owned ( name) )
124
124
}
125
125
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
-
177
126
/// Returns a new run condition that only returns `false`
178
127
/// if both this one and the passed `nand` return `true`.
179
128
///
@@ -325,53 +274,6 @@ pub trait Condition<Marker, In: SystemInput = ()>: sealed::Condition<Marker, In>
325
274
CombinatorSystem :: new ( a, b, Cow :: Owned ( name) )
326
275
}
327
276
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
-
375
277
/// Returns a new run condition that only returns `true`
376
278
/// if `self` and `xnor` **both** return `false` or **both** return `true`.
377
279
///
@@ -1406,7 +1308,6 @@ mod tests {
1406
1308
}
1407
1309
1408
1310
#[ test]
1409
- #[ allow( deprecated) ]
1410
1311
fn run_condition_combinators ( ) {
1411
1312
let mut world = World :: new ( ) ;
1412
1313
world. init_resource :: < Counter > ( ) ;
@@ -1415,23 +1316,21 @@ mod tests {
1415
1316
schedule. add_systems (
1416
1317
(
1417
1318
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.
1423
1322
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.
1425
1324
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.
1427
1326
)
1428
1327
. chain ( ) ,
1429
1328
) ;
1430
1329
1431
1330
schedule. run ( & mut world) ;
1432
- assert_eq ! ( world. resource:: <Counter >( ) . 0 , 7 ) ;
1331
+ assert_eq ! ( world. resource:: <Counter >( ) . 0 , 5 ) ;
1433
1332
schedule. run ( & mut world) ;
1434
- assert_eq ! ( world. resource:: <Counter >( ) . 0 , 72 ) ;
1333
+ assert_eq ! ( world. resource:: <Counter >( ) . 0 , 52 ) ;
1435
1334
}
1436
1335
1437
1336
#[ test]
0 commit comments