Skip to content
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

[Merged by Bors] - Make Commands and World apis consistent #1703

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 154 additions & 123 deletions crates/bevy_ecs/src/system/commands.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/exclusive_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod tests {
) {
for entity in query.iter() {
*counter += 1;
commands.remove::<f32>(entity);
commands.entity(entity).remove::<f32>();
}
}

Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,18 @@ fn load_node(
) -> Result<(), GltfError> {
let transform = gltf_node.transform();
let mut gltf_error = None;
let node = world_builder.spawn((
let mut node = world_builder.spawn_bundle((
Transform::from_matrix(Mat4::from_cols_array_2d(&transform.matrix())),
GlobalTransform::identity(),
));

if let Some(name) = gltf_node.name() {
node.with(Name::new(name.to_string()));
node.insert(Name::new(name.to_string()));
}

// create camera node
if let Some(camera) = gltf_node.camera() {
node.with(VisibleEntities {
node.insert(VisibleEntities {
..Default::default()
});

Expand All @@ -325,12 +325,12 @@ fn load_node(
..Default::default()
};

node.with(Camera {
node.insert(Camera {
name: Some(base::camera::CAMERA_2D.to_owned()),
projection_matrix: orthographic_projection.get_projection_matrix(),
..Default::default()
});
node.with(orthographic_projection);
node.insert(orthographic_projection);
}
gltf::camera::Projection::Perspective(perspective) => {
let mut perspective_projection: PerspectiveProjection = PerspectiveProjection {
Expand All @@ -344,12 +344,12 @@ fn load_node(
if let Some(aspect_ratio) = perspective.aspect_ratio() {
perspective_projection.aspect_ratio = aspect_ratio;
}
node.with(Camera {
node.insert(Camera {
name: Some(base::camera::CAMERA_3D.to_owned()),
projection_matrix: perspective_projection.get_projection_matrix(),
..Default::default()
});
node.with(perspective_projection);
node.insert(perspective_projection);
}
}
}
Expand All @@ -374,7 +374,7 @@ fn load_node(
let material_asset_path =
AssetPath::new_ref(load_context.path(), Some(&material_label));

parent.spawn(PbrBundle {
parent.spawn_bundle(PbrBundle {
mesh: load_context.get_handle(mesh_asset_path),
material: load_context.get_handle(material_asset_path),
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_scene/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ impl Command for SpawnScene {
}

pub trait SpawnSceneCommands {
fn spawn_scene(&mut self, scene: Handle<Scene>) -> &mut Self;
fn spawn_scene(&mut self, scene: Handle<Scene>);
}

impl<'a> SpawnSceneCommands for Commands<'a> {
fn spawn_scene(&mut self, scene_handle: Handle<Scene>) -> &mut Self {
self.add_command(SpawnScene { scene_handle })
fn spawn_scene(&mut self, scene_handle: Handle<Scene>) {
self.add(SpawnScene { scene_handle });
}
}

Expand Down
Loading