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?
This commit is contained in:
deprilula28 2021-04-28 20:08:33 +00:00
parent cf40f4ab08
commit cdb9097ed4

View File

@ -284,8 +284,8 @@ impl<'a, 'b> EntityCommands<'a, 'b> {
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Spawn<T> { pub struct Spawn<T> {
bundle: T, pub bundle: T,
} }
impl<T> Command for Spawn<T> impl<T> Command for Spawn<T>
@ -297,12 +297,12 @@ where
} }
} }
pub(crate) struct SpawnBatch<I> pub struct SpawnBatch<I>
where where
I: IntoIterator, I: IntoIterator,
I::Item: Bundle, I::Item: Bundle,
{ {
bundles_iter: I, pub bundles_iter: I,
} }
impl<I> Command for SpawnBatch<I> impl<I> Command for SpawnBatch<I>
@ -316,8 +316,8 @@ where
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Despawn { pub struct Despawn {
entity: Entity, pub entity: Entity,
} }
impl Command for Despawn { impl Command for Despawn {
@ -328,9 +328,9 @@ impl Command for Despawn {
} }
} }
pub(crate) struct InsertBundle<T> { pub struct InsertBundle<T> {
entity: Entity, pub entity: Entity,
bundle: T, pub bundle: T,
} }
impl<T> Command for InsertBundle<T> impl<T> Command for InsertBundle<T>
@ -343,9 +343,9 @@ where
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Insert<T> { pub struct Insert<T> {
entity: Entity, pub entity: Entity,
component: T, pub component: T,
} }
impl<T> Command for Insert<T> impl<T> Command for Insert<T>
@ -358,7 +358,7 @@ where
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Remove<T> { pub struct Remove<T> {
entity: Entity, entity: Entity,
phantom: PhantomData<T>, phantom: PhantomData<T>,
} }
@ -375,9 +375,9 @@ where
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct RemoveBundle<T> { pub struct RemoveBundle<T> {
entity: Entity, pub entity: Entity,
phantom: PhantomData<T>, pub phantom: PhantomData<T>,
} }
impl<T> Command for RemoveBundle<T> impl<T> Command for RemoveBundle<T>
@ -393,8 +393,8 @@ where
} }
} }
pub(crate) struct InsertResource<T: Component> { pub struct InsertResource<T: Component> {
resource: T, pub resource: T,
} }
impl<T: Component> Command for InsertResource<T> { impl<T: Component> Command for InsertResource<T> {
@ -403,8 +403,8 @@ impl<T: Component> Command for InsertResource<T> {
} }
} }
pub(crate) struct RemoveResource<T: Component> { pub struct RemoveResource<T: Component> {
phantom: PhantomData<T>, pub phantom: PhantomData<T>,
} }
impl<T: Component> Command for RemoveResource<T> { impl<T: Component> Command for RemoveResource<T> {