Skip to content

Commit

Permalink
Make Command's public? (bevyengine#2034)
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
deprilula28 authored and NiklasEi committed May 1, 2021
1 parent 346e7c5 commit d81c2d4
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions crates/bevy_ecs/src/system/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ impl<'a, 'b> EntityCommands<'a, 'b> {
}

#[derive(Debug)]
pub(crate) struct Spawn<T> {
bundle: T,
pub struct Spawn<T> {
pub bundle: T,
}

impl<T> Command for Spawn<T>
Expand All @@ -297,12 +297,12 @@ where
}
}

pub(crate) struct SpawnBatch<I>
pub struct SpawnBatch<I>
where
I: IntoIterator,
I::Item: Bundle,
{
bundles_iter: I,
pub bundles_iter: I,
}

impl<I> Command for SpawnBatch<I>
Expand All @@ -316,8 +316,8 @@ where
}

#[derive(Debug)]
pub(crate) struct Despawn {
entity: Entity,
pub struct Despawn {
pub entity: Entity,
}

impl Command for Despawn {
Expand All @@ -328,9 +328,9 @@ impl Command for Despawn {
}
}

pub(crate) struct InsertBundle<T> {
entity: Entity,
bundle: T,
pub struct InsertBundle<T> {
pub entity: Entity,
pub bundle: T,
}

impl<T> Command for InsertBundle<T>
Expand All @@ -343,9 +343,9 @@ where
}

#[derive(Debug)]
pub(crate) struct Insert<T> {
entity: Entity,
component: T,
pub struct Insert<T> {
pub entity: Entity,
pub component: T,
}

impl<T> Command for Insert<T>
Expand All @@ -358,7 +358,7 @@ where
}

#[derive(Debug)]
pub(crate) struct Remove<T> {
pub struct Remove<T> {
entity: Entity,
phantom: PhantomData<T>,
}
Expand All @@ -375,9 +375,9 @@ where
}

#[derive(Debug)]
pub(crate) struct RemoveBundle<T> {
entity: Entity,
phantom: PhantomData<T>,
pub struct RemoveBundle<T> {
pub entity: Entity,
pub phantom: PhantomData<T>,
}

impl<T> Command for RemoveBundle<T>
Expand All @@ -393,8 +393,8 @@ where
}
}

pub(crate) struct InsertResource<T: Component> {
resource: T,
pub struct InsertResource<T: Component> {
pub resource: T,
}

impl<T: Component> Command for InsertResource<T> {
Expand All @@ -403,8 +403,8 @@ impl<T: Component> Command for InsertResource<T> {
}
}

pub(crate) struct RemoveResource<T: Component> {
phantom: PhantomData<T>,
pub struct RemoveResource<T: Component> {
pub phantom: PhantomData<T>,
}

impl<T: Component> Command for RemoveResource<T> {
Expand Down

0 comments on commit d81c2d4

Please sign in to comment.