New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commands from entities #6733
Commands from entities #6733
Conversation
Very cool! I think this also fixes #6184. |
@@ -113,6 +113,10 @@ impl<'w, 's> Commands<'w, 's> { | |||
} | |||
} | |||
|
|||
pub fn from_entities(queue: &'s mut CommandQueue, entities: &'w Entities) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we alter the above constructor in the terms of this one?
@@ -190,6 +190,7 @@ Example | Description | |||
|
|||
Example | Description | |||
--- | --- | |||
[CommandQueue in World](../examples/ecs/command_queue_in_world.rs) | Manually apply a command Queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a top level example or a doc example/test?
My only concern about this is that |
Not a safety invariant, but dropping the queue probably does "leak" entity id's. Not sure there is a way to clean them up, even manually. |
fn log_entity(query: Query<Entity, With<EntityMarker>>) { | ||
if let Ok(_entitiy) = query.get_single() { | ||
println!("found entitiy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn log_entity(query: Query<Entity, With<EntityMarker>>) { | |
if let Ok(_entitiy) = query.get_single() { | |
println!("found entitiy"); | |
fn log_entity(query: Query<Entity, With<EntityMarker>>) { | |
if let Ok(entity) = query.get_single() { | |
println!("found {entity:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should use query.get_single().is_ok()
if we aren't using the value.
|
||
fn spawn_something(entities: &Entities, mut q: ResMut<MyCommandQueue>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entities
is a fairly niche system param, so I think this example could use a quick explanation of what it is.
@@ -113,6 +113,10 @@ impl<'w, 's> Commands<'w, 's> { | |||
} | |||
} | |||
|
|||
pub fn from_entities(queue: &'s mut CommandQueue, entities: &'w Entities) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that Commands
already has the function new_from_entities(&'s mut CommandQueue, &'w Entities)
. Can you just use that instead?
going to close this as pointed out the function already exists. I don't think that using a command queue as in the example is a good idea at present, since it'll "leak" entities if the command queue isn't applied. So there needs to be a way of cleaning up the entities when the queue is dropped. |
Objective
Changelog
from_entities
builder toCommands