From d81c2d4eb699b6c641a8e51f19e0e5871cd1ddff Mon Sep 17 00:00:00 2001 From: deprilula28 Date: Wed, 28 Apr 2021 20:08:33 +0000 Subject: [PATCH] Make Command's public? (#2034) I'm using Bevy ECS in a project of mine and I'd like to do world changes asynchronously. The current public API for creating entities, `Commands` , has a lifetime that restricts it from being sent across threads. `CommandQueue` on the other hand is a Vec of commands that can be later ran on a World. So far this is all public, but the commands themselves are private API. I know the intented use is with `Commands`, but that's not possible for my use case as I mentioned, and so I simply copied over the code for the commands I need and it works. Obviously, this isn't a nice solution, so I'd like to ask if it's not out of scope to make the commands public? --- crates/bevy_ecs/src/system/commands.rs | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/bevy_ecs/src/system/commands.rs b/crates/bevy_ecs/src/system/commands.rs index d7336db107304..627b9e4e73531 100644 --- a/crates/bevy_ecs/src/system/commands.rs +++ b/crates/bevy_ecs/src/system/commands.rs @@ -284,8 +284,8 @@ impl<'a, 'b> EntityCommands<'a, 'b> { } #[derive(Debug)] -pub(crate) struct Spawn { - bundle: T, +pub struct Spawn { + pub bundle: T, } impl Command for Spawn @@ -297,12 +297,12 @@ where } } -pub(crate) struct SpawnBatch +pub struct SpawnBatch where I: IntoIterator, I::Item: Bundle, { - bundles_iter: I, + pub bundles_iter: I, } impl Command for SpawnBatch @@ -316,8 +316,8 @@ where } #[derive(Debug)] -pub(crate) struct Despawn { - entity: Entity, +pub struct Despawn { + pub entity: Entity, } impl Command for Despawn { @@ -328,9 +328,9 @@ impl Command for Despawn { } } -pub(crate) struct InsertBundle { - entity: Entity, - bundle: T, +pub struct InsertBundle { + pub entity: Entity, + pub bundle: T, } impl Command for InsertBundle @@ -343,9 +343,9 @@ where } #[derive(Debug)] -pub(crate) struct Insert { - entity: Entity, - component: T, +pub struct Insert { + pub entity: Entity, + pub component: T, } impl Command for Insert @@ -358,7 +358,7 @@ where } #[derive(Debug)] -pub(crate) struct Remove { +pub struct Remove { entity: Entity, phantom: PhantomData, } @@ -375,9 +375,9 @@ where } #[derive(Debug)] -pub(crate) struct RemoveBundle { - entity: Entity, - phantom: PhantomData, +pub struct RemoveBundle { + pub entity: Entity, + pub phantom: PhantomData, } impl Command for RemoveBundle @@ -393,8 +393,8 @@ where } } -pub(crate) struct InsertResource { - resource: T, +pub struct InsertResource { + pub resource: T, } impl Command for InsertResource { @@ -403,8 +403,8 @@ impl Command for InsertResource { } } -pub(crate) struct RemoveResource { - phantom: PhantomData, +pub struct RemoveResource { + pub phantom: PhantomData, } impl Command for RemoveResource {