From f19e608143b25494d6a05bd19384305d305d72ac Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Mon, 28 Aug 2023 12:04:56 +1000 Subject: [PATCH] Replaced `EntityCommand` Implementation for `FnOnce` --- crates/bevy_ecs/src/system/commands/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index fac21c7c0ffc2..ed6677ea9f7e7 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -5,7 +5,7 @@ use crate::{ self as bevy_ecs, bundle::Bundle, entity::{Entities, Entity}, - world::{FromWorld, World}, + world::{EntityMut, FromWorld, World}, }; use bevy_ecs_macros::SystemParam; use bevy_utils::tracing::{error, info}; @@ -805,12 +805,13 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> { /// /// ``` /// # use bevy_ecs::prelude::*; + /// # use bevy_ecs::world::EntityMut; /// # fn my_system(mut commands: Commands) { /// commands /// .spawn_empty() /// // Closures with this signature implement `EntityCommand`. - /// .add(|id: Entity, world: &mut World| { - /// println!("Executed an EntityCommand for {id:?}"); + /// .add(|entity: EntityMut| { + /// println!("Executed an EntityCommand for {:?}", entity.id()); /// }); /// # } /// # bevy_ecs::system::assert_is_system(my_system); @@ -848,10 +849,10 @@ where impl EntityCommand for F where - F: FnOnce(Entity, &mut World) + Send + 'static, + F: FnOnce(EntityMut) + Send + 'static, { fn apply(self, id: Entity, world: &mut World) { - self(id, world); + self(world.entity_mut(id)); } }