-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] - Remove the config api #3633
Conversation
After using As it's a useful feature, and |
7c75a0c
to
b350551
Compare
/// move |mut val| val.0 = value.0 | ||
/// } | ||
/// | ||
/// // .add_system(reset_to(my_config)) |
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.
could this example be more complete? you missed a rename here as it's commented
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.
We're stuck in bevy_ecs here, so I can't create an App
, without making a stub implementation. That seemed like quite a lot of effort for the example.
There's not really a great way to demonstrate adding systems within bevy_ecs
imo, since every consumer should also be using bevy_app
.
The rename does need to happen though, thanks.
b66c33e
to
9b05419
Compare
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.
After trying to use this way to configure my system, I'm not completely a fan:
fn configured_animate_scale(
speed: f32,
) -> impl FnMut(Res<Time>, Query<&mut Transform, (With<Text>, With<AnimateScale>)>) {
move |time, mut query| {
for mut transform in query.iter_mut() {
transform.translation = Vec3::new(400.0, 0.0, 0.0);
transform.scale =
Vec3::splat((time.seconds_since_startup().sin() as f32 + 1.1) * speed);
}
}
}
// Adding this system
app.add_system(configured_animate_scale(5.0))
But still better than the current config api so... 🤷
This is also an option. Slightly more typing, but allows you to home the variable type next to the variable name. fn prepare_system(mut state: LocalFixedTimestepState) -> impl System<In = (), Out = ShouldRun> {
IntoSystem::into_system(
move |time: Res<Time>, mut fixed_timesteps: ResMut<FixedTimesteps>| {
let should_run = state.update(&time);
if let Some(ref label) = state.label {
let res_state = fixed_timesteps.fixed_timesteps.get_mut(label).unwrap();
res_state.step = state.step;
res_state.accumulator = state.accumulator;
}
should_run
},
)
} Or this if you're willing to use deprecated methods 😄 fn prepare_system(mut state: LocalFixedTimestepState) -> impl System<In = (), Out = ShouldRun> {
(move |time: Res<Time>, mut fixed_timesteps: ResMut<FixedTimesteps>| {
let should_run = state.update(&time);
if let Some(ref label) = state.label {
let res_state = fixed_timesteps.fixed_timesteps.get_mut(label).unwrap();
res_state.step = state.step;
res_state.accumulator = state.accumulator;
}
should_run
})
.system()
} |
bors r+ |
# Objective - Fix the ugliness of the `config` api. - Supercedes bevyengine#2440, bevyengine#2463, bevyengine#2491 ## Solution - Since bevyengine#2398, capturing closure systems have worked. - Use those instead where we needed config before - Remove the rest of the config api. - Related: bevyengine#2777
Objective
config
api.Required
system param #2440,Local
with required config as a const generic parameter #2463,Local
with required config as a type parameter #2491Solution
.system
#2398, capturing closure systems have worked.