Skip to content

Commit 63244d8

Browse files
committed
Merge remote-tracking branch 'upstream/main' into new-bundle
2 parents 385d1f0 + 3926f02 commit 63244d8

File tree

117 files changed

+2293
-697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2293
-697
lines changed

benches/benches/bevy_ecs/events/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy_ecs::prelude::*;
22

3-
#[derive(Event)]
3+
#[derive(Event, BufferedEvent)]
44
struct BenchEvent<const SIZE: usize>([u8; SIZE]);
55

66
pub struct Benchmark<const SIZE: usize>(Events<BenchEvent<SIZE>>);

benches/benches/bevy_ecs/events/send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy_ecs::prelude::*;
22

3-
#[derive(Event)]
3+
#[derive(Event, BufferedEvent)]
44
struct BenchEvent<const SIZE: usize>([u8; SIZE]);
55

66
impl<const SIZE: usize> Default for BenchEvent<SIZE> {

benches/benches/bevy_ecs/observers/propagation.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,10 @@ pub fn event_propagation(criterion: &mut Criterion) {
6161
group.finish();
6262
}
6363

64-
#[derive(Clone, Component)]
64+
#[derive(Event, EntityEvent, Clone, Component)]
65+
#[entity_event(traversal = &'static ChildOf, auto_propagate)]
6566
struct TestEvent<const N: usize> {}
6667

67-
impl<const N: usize> Event for TestEvent<N> {
68-
type Traversal = &'static ChildOf;
69-
const AUTO_PROPAGATE: bool = true;
70-
}
71-
7268
fn send_events<const N: usize, const N_EVENTS: usize>(world: &mut World, leaves: &[Entity]) {
7369
let target = leaves.iter().choose(&mut rand::thread_rng()).unwrap();
7470

benches/benches/bevy_ecs/observers/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::hint::black_box;
22

33
use bevy_ecs::{
4-
event::Event,
4+
event::{EntityEvent, Event},
55
observer::{On, TriggerTargets},
66
world::World,
77
};
@@ -13,7 +13,7 @@ fn deterministic_rand() -> ChaCha8Rng {
1313
ChaCha8Rng::seed_from_u64(42)
1414
}
1515

16-
#[derive(Clone, Event)]
16+
#[derive(Clone, Event, EntityEvent)]
1717
struct EventBase;
1818

1919
pub fn observe_simple(criterion: &mut Criterion) {

crates/bevy_a11y/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ use accesskit::Node;
2626
use bevy_app::Plugin;
2727
use bevy_derive::{Deref, DerefMut};
2828
use bevy_ecs::{
29-
prelude::{Component, Event},
29+
component::Component,
30+
event::{BufferedEvent, Event},
3031
resource::Resource,
3132
schedule::SystemSet,
3233
};
@@ -44,7 +45,7 @@ use serde::{Deserialize, Serialize};
4445
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
4546

4647
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
47-
#[derive(Event, Deref, DerefMut)]
48+
#[derive(Event, BufferedEvent, Deref, DerefMut)]
4849
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
4950
pub struct ActionRequest(pub accesskit::ActionRequest);
5051

crates/bevy_animation/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ impl AnimationClip {
324324
.push(variable_curve);
325325
}
326326

327-
/// Add a untargeted [`Event`] to this [`AnimationClip`].
327+
/// Add an [`EntityEvent`] with no [`AnimationTarget`] to this [`AnimationClip`].
328328
///
329329
/// The `event` will be cloned and triggered on the [`AnimationPlayer`] entity once the `time` (in seconds)
330330
/// is reached in the animation.
331331
///
332332
/// See also [`add_event_to_target`](Self::add_event_to_target).
333-
pub fn add_event(&mut self, time: f32, event: impl Event + Clone) {
333+
pub fn add_event(&mut self, time: f32, event: impl EntityEvent + Clone) {
334334
self.add_event_fn(
335335
time,
336336
move |commands: &mut Commands, entity: Entity, _time: f32, _weight: f32| {
@@ -339,7 +339,7 @@ impl AnimationClip {
339339
);
340340
}
341341

342-
/// Add an [`Event`] to an [`AnimationTarget`] named by an [`AnimationTargetId`].
342+
/// Add an [`EntityEvent`] to an [`AnimationTarget`] named by an [`AnimationTargetId`].
343343
///
344344
/// The `event` will be cloned and triggered on the entity matching the target once the `time` (in seconds)
345345
/// is reached in the animation.
@@ -349,7 +349,7 @@ impl AnimationClip {
349349
&mut self,
350350
target_id: AnimationTargetId,
351351
time: f32,
352-
event: impl Event + Clone,
352+
event: impl EntityEvent + Clone,
353353
) {
354354
self.add_event_fn_to_target(
355355
target_id,
@@ -360,19 +360,19 @@ impl AnimationClip {
360360
);
361361
}
362362

363-
/// Add a untargeted event function to this [`AnimationClip`].
363+
/// Add an event function with no [`AnimationTarget`] to this [`AnimationClip`].
364364
///
365365
/// The `func` will trigger on the [`AnimationPlayer`] entity once the `time` (in seconds)
366366
/// is reached in the animation.
367367
///
368-
/// For a simpler [`Event`]-based alternative, see [`AnimationClip::add_event`].
368+
/// For a simpler [`EntityEvent`]-based alternative, see [`AnimationClip::add_event`].
369369
/// See also [`add_event_to_target`](Self::add_event_to_target).
370370
///
371371
/// ```
372372
/// # use bevy_animation::AnimationClip;
373373
/// # let mut clip = AnimationClip::default();
374374
/// clip.add_event_fn(1.0, |commands, entity, time, weight| {
375-
/// println!("Animation Event Triggered {entity:#?} at time {time} with weight {weight}");
375+
/// println!("Animation event triggered {entity:#?} at time {time} with weight {weight}");
376376
/// })
377377
/// ```
378378
pub fn add_event_fn(
@@ -388,14 +388,14 @@ impl AnimationClip {
388388
/// The `func` will trigger on the entity matching the target once the `time` (in seconds)
389389
/// is reached in the animation.
390390
///
391-
/// For a simpler [`Event`]-based alternative, see [`AnimationClip::add_event_to_target`].
391+
/// For a simpler [`EntityEvent`]-based alternative, see [`AnimationClip::add_event_to_target`].
392392
/// Use [`add_event`](Self::add_event) instead if you don't have a specific target.
393393
///
394394
/// ```
395395
/// # use bevy_animation::{AnimationClip, AnimationTargetId};
396396
/// # let mut clip = AnimationClip::default();
397397
/// clip.add_event_fn_to_target(AnimationTargetId::from_iter(["Arm", "Hand"]), 1.0, |commands, entity, time, weight| {
398-
/// println!("Animation Event Triggered {entity:#?} at time {time} with weight {weight}");
398+
/// println!("Animation event triggered {entity:#?} at time {time} with weight {weight}");
399399
/// })
400400
/// ```
401401
pub fn add_event_fn_to_target(
@@ -1534,7 +1534,7 @@ mod tests {
15341534

15351535
use super::*;
15361536

1537-
#[derive(Event, Reflect, Clone)]
1537+
#[derive(Event, EntityEvent, Reflect, Clone)]
15381538
struct A;
15391539

15401540
#[track_caller]

crates/bevy_app/src/app.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl App {
345345
self
346346
}
347347

348-
/// Initializes `T` event handling by inserting an event queue resource ([`Events::<T>`])
348+
/// Initializes [`BufferedEvent`] handling for `T` by inserting an event queue resource ([`Events::<T>`])
349349
/// and scheduling an [`event_update_system`] in [`First`].
350350
///
351351
/// See [`Events`] for information on how to define events.
@@ -356,15 +356,15 @@ impl App {
356356
/// # use bevy_app::prelude::*;
357357
/// # use bevy_ecs::prelude::*;
358358
/// #
359-
/// # #[derive(Event)]
359+
/// # #[derive(Event, BufferedEvent)]
360360
/// # struct MyEvent;
361361
/// # let mut app = App::new();
362362
/// #
363363
/// app.add_event::<MyEvent>();
364364
/// ```
365365
pub fn add_event<T>(&mut self) -> &mut Self
366366
where
367-
T: Event,
367+
T: BufferedEvent,
368368
{
369369
self.main_mut().add_event::<T>();
370370
self
@@ -1326,7 +1326,7 @@ impl App {
13261326
/// # friends_allowed: bool,
13271327
/// # };
13281328
/// #
1329-
/// # #[derive(Event)]
1329+
/// # #[derive(Event, EntityEvent)]
13301330
/// # struct Invite;
13311331
/// #
13321332
/// # #[derive(Component)]
@@ -1408,7 +1408,7 @@ fn run_once(mut app: App) -> AppExit {
14081408
app.should_exit().unwrap_or(AppExit::Success)
14091409
}
14101410

1411-
/// An event that indicates the [`App`] should exit. If one or more of these are present at the end of an update,
1411+
/// A [`BufferedEvent`] that indicates the [`App`] should exit. If one or more of these are present at the end of an update,
14121412
/// the [runner](App::set_runner) will end and ([maybe](App::run)) return control to the caller.
14131413
///
14141414
/// This event can be used to detect when an exit is requested. Make sure that systems listening
@@ -1418,7 +1418,7 @@ fn run_once(mut app: App) -> AppExit {
14181418
/// This type is roughly meant to map to a standard definition of a process exit code (0 means success, not 0 means error). Due to portability concerns
14191419
/// (see [`ExitCode`](https://doc.rust-lang.org/std/process/struct.ExitCode.html) and [`process::exit`](https://doc.rust-lang.org/std/process/fn.exit.html#))
14201420
/// we only allow error codes between 1 and [255](u8::MAX).
1421-
#[derive(Event, Debug, Clone, Default, PartialEq, Eq)]
1421+
#[derive(Event, BufferedEvent, Debug, Clone, Default, PartialEq, Eq)]
14221422
pub enum AppExit {
14231423
/// [`App`] exited without any problems.
14241424
#[default]
@@ -1486,7 +1486,7 @@ mod tests {
14861486
change_detection::{DetectChanges, ResMut},
14871487
component::Component,
14881488
entity::Entity,
1489-
event::{Event, EventWriter, Events},
1489+
event::{BufferedEvent, Event, EventWriter, Events},
14901490
lifecycle::RemovedComponents,
14911491
query::With,
14921492
resource::Resource,
@@ -1852,7 +1852,7 @@ mod tests {
18521852
}
18531853
#[test]
18541854
fn events_should_be_updated_once_per_update() {
1855-
#[derive(Event, Clone)]
1855+
#[derive(Event, BufferedEvent, Clone)]
18561856
struct TestEvent;
18571857

18581858
let mut app = App::new();

crates/bevy_app/src/sub_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl SubApp {
338338
/// See [`App::add_event`].
339339
pub fn add_event<T>(&mut self) -> &mut Self
340340
where
341-
T: Event,
341+
T: BufferedEvent,
342342
{
343343
if !self.world.contains_resource::<Events<T>>() {
344344
EventRegistry::register_event::<T>(self.world_mut());

crates/bevy_asset/src/event.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::{Asset, AssetId, AssetLoadError, AssetPath, UntypedAssetId};
2-
use bevy_ecs::event::Event;
2+
use bevy_ecs::event::{BufferedEvent, Event};
33
use bevy_reflect::Reflect;
44
use core::fmt::Debug;
55

6-
/// An event emitted when a specific [`Asset`] fails to load.
6+
/// A [`BufferedEvent`] emitted when a specific [`Asset`] fails to load.
77
///
88
/// For an untyped equivalent, see [`UntypedAssetLoadFailedEvent`].
9-
#[derive(Event, Clone, Debug)]
9+
#[derive(Event, BufferedEvent, Clone, Debug)]
1010
pub struct AssetLoadFailedEvent<A: Asset> {
1111
/// The stable identifier of the asset that failed to load.
1212
pub id: AssetId<A>,
@@ -24,7 +24,7 @@ impl<A: Asset> AssetLoadFailedEvent<A> {
2424
}
2525

2626
/// An untyped version of [`AssetLoadFailedEvent`].
27-
#[derive(Event, Clone, Debug)]
27+
#[derive(Event, BufferedEvent, Clone, Debug)]
2828
pub struct UntypedAssetLoadFailedEvent {
2929
/// The stable identifier of the asset that failed to load.
3030
pub id: UntypedAssetId,
@@ -44,9 +44,9 @@ impl<A: Asset> From<&AssetLoadFailedEvent<A>> for UntypedAssetLoadFailedEvent {
4444
}
4545
}
4646

47-
/// Events that occur for a specific loaded [`Asset`], such as "value changed" events and "dependency" events.
47+
/// [`BufferedEvent`]s that occur for a specific loaded [`Asset`], such as "value changed" events and "dependency" events.
4848
#[expect(missing_docs, reason = "Documenting the id fields is unhelpful.")]
49-
#[derive(Event, Reflect)]
49+
#[derive(Event, BufferedEvent, Reflect)]
5050
pub enum AssetEvent<A: Asset> {
5151
/// Emitted whenever an [`Asset`] is added.
5252
Added { id: AssetId<A> },

0 commit comments

Comments
 (0)