diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-27 22:02:00 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-27 22:02:00 -0600 |
| commit | 9513f42e87f64c409cdb2a100500a50e5a713bac (patch) | |
| tree | bb6aa8b6d50fddf967bcb1f759e023754ea84e49 /azalea-client/src/plugins/tick_broadcast.rs | |
| parent | 588902ba4a3965982bdd84d92b20c6f7613f3978 (diff) | |
| download | azalea-drasl-9513f42e87f64c409cdb2a100500a50e5a713bac.tar.xz | |
Move Client struct to azalea crate (#297)
* move the Client struct out of azalea-client into azalea
* actually add client impls in azalea
Diffstat (limited to 'azalea-client/src/plugins/tick_broadcast.rs')
| -rw-r--r-- | azalea-client/src/plugins/tick_broadcast.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/azalea-client/src/plugins/tick_broadcast.rs b/azalea-client/src/plugins/tick_broadcast.rs deleted file mode 100644 index e51716cc..00000000 --- a/azalea-client/src/plugins/tick_broadcast.rs +++ /dev/null @@ -1,50 +0,0 @@ -use azalea_core::tick::GameTick; -use bevy_app::prelude::*; -use bevy_ecs::prelude::*; -use derive_more::Deref; -use tokio::sync::broadcast; - -/// A resource that contains a [`broadcast::Sender`] that will be sent every -/// Minecraft tick. -/// -/// This is useful for running code every schedule from async user code. -/// -/// ``` -/// use azalea_client::tick_broadcast::TickBroadcast; -/// # async fn example(client: azalea_client::Client) { -/// let mut receiver = { -/// let ecs = client.ecs.lock(); -/// let tick_broadcast = ecs.resource::<TickBroadcast>(); -/// tick_broadcast.subscribe() -/// }; -/// while receiver.recv().await.is_ok() { -/// // do something -/// } -/// # } -/// ``` -#[derive(Deref, Resource)] -pub struct TickBroadcast(broadcast::Sender<()>); -/// A resource that contains a [`broadcast::Sender`] that will be sent every -/// Azalea ECS Update. -/// -/// Also see [`TickBroadcast`]. -#[derive(Deref, Resource)] -pub struct UpdateBroadcast(broadcast::Sender<()>); - -pub fn send_tick_broadcast(tick_broadcast: ResMut<TickBroadcast>) { - let _ = tick_broadcast.0.send(()); -} -pub fn send_update_broadcast(update_broadcast: ResMut<UpdateBroadcast>) { - let _ = update_broadcast.0.send(()); -} -/// A plugin that makes the [`UpdateBroadcast`] and [`TickBroadcast`] resources -/// available. -pub struct TickBroadcastPlugin; -impl Plugin for TickBroadcastPlugin { - fn build(&self, app: &mut App) { - app.insert_resource(TickBroadcast(broadcast::channel(1).0)) - .insert_resource(UpdateBroadcast(broadcast::channel(1).0)) - .add_systems(GameTick, send_tick_broadcast) - .add_systems(Update, send_update_broadcast); - } -} |
