From e94aa047360d833537e051a6dc417423bb4ddf75 Mon Sep 17 00:00:00 2001 From: Ida Iyes Date: Mon, 17 Apr 2023 20:10:38 +0300 Subject: [PATCH 01/15] bevy_audio: ECS-based API redesign --- crates/bevy_audio/src/audio.rs | 411 ++++++++------------------ crates/bevy_audio/src/audio_output.rs | 201 +++++-------- crates/bevy_audio/src/lib.rs | 40 +-- crates/bevy_audio/src/sinks.rs | 53 +--- examples/audio/audio.rs | 7 +- examples/audio/audio_control.rs | 42 +-- examples/audio/decodable.rs | 4 +- examples/audio/spatial_audio_2d.rs | 51 ++-- examples/audio/spatial_audio_3d.rs | 53 ++-- examples/games/breakout.rs | 21 +- 10 files changed, 323 insertions(+), 560 deletions(-) diff --git a/crates/bevy_audio/src/audio.rs b/crates/bevy_audio/src/audio.rs index 0e17168f9b6a6..4615bb8b5f6e3 100644 --- a/crates/bevy_audio/src/audio.rs +++ b/crates/bevy_audio/src/audio.rs @@ -1,256 +1,9 @@ -use crate::{AudioSink, AudioSource, Decodable, SpatialAudioSink}; -use bevy_asset::{Asset, Handle, HandleId}; +use crate::{AudioSource, Decodable}; +use bevy_asset::{Asset, Handle}; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::system::Resource; +use bevy_ecs::prelude::*; use bevy_math::Vec3; use bevy_transform::prelude::Transform; -use parking_lot::RwLock; -use std::{collections::VecDeque, fmt}; - -/// Use this [`Resource`] to play audio. -/// -/// ``` -/// # use bevy_ecs::system::Res; -/// # use bevy_asset::AssetServer; -/// # use bevy_audio::Audio; -/// fn play_audio_system(asset_server: Res, audio: Res