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

Simplify commands a bit #268

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Simplify commands a bit #268

merged 3 commits into from
Aug 15, 2024

Conversation

janhohenheim
Copy link
Member

Resolves #265
Resolves #266

@@ -3,7 +3,9 @@
use bevy::{input::common_conditions::input_just_pressed, prelude::*};

use super::Screen;
use crate::{asset_tracking::LoadResource, audio::Music, demo::level::SpawnLevel};
use crate::{
asset_tracking::LoadResource, audio::Music, demo::level::spawn_level as spawn_level_command,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the type alias is helpful here. A comment would be better.

Copy link
Member Author

@janhohenheim janhohenheim Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed because we also have function called spawn_level in this file. Imo both of these "deserve" the name, and qualifying this one with level::spawn_level does not show what the difference between them is.

Copy link
Collaborator

@benfrankel benfrankel Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A point in favor of level::level naming convention 🤐

world.flush_commands();
}
/// A [`Command`] to spawn the level.
/// Exclusive systems, i.e. systems that only accept `&mut World`, implement [`Command`].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exactly true: https://docs.rs/bevy_ecs/0.14.1/src/bevy_ecs/system/commands/mod.rs.html#1173-1175

Also I don't think this comment is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how much newcomers were struggling with custom commands, I think it would be even more confusing to have two completely different ways of defining them without explanation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the struggle with custom commands was that they're unergonomic which makes them look unwieldy, not confusing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better? 70a688d (#268)

Copy link
Member Author

@janhohenheim janhohenheim Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benfrankel IME everything concerning exclusive access to World is spooky. In general, I also don't expect newcomers to know that this kind of fn implements Command, considering they probably have not ever touched a custom command or seen how a Command is implemented.
As such, I strongly feel that we should have some comment here until the day where custom Commands are accepted by newcomers as a common thing to do.

Copy link
Collaborator

@benfrankel benfrankel Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better? 70a688d (#268)

Accurate now, yes. I still think the doc comment calling the function a ['Command'] is sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alice-i-cecile, could you act as a tie-breaker here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think erring on the side of more verbose here is good.

@janhohenheim janhohenheim enabled auto-merge (squash) August 15, 2024 21:29
@janhohenheim janhohenheim merged commit 2c6a95a into main Aug 15, 2024
4 checks passed
@janhohenheim janhohenheim deleted the simpler-commands branch August 15, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants