-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
What problem does this solve or what need does it fill?
Queuing things to run at a specific later point in time is a pretty common requirement for many games, but our current setup for doing this type of thing is pretty boilerplate-heavy: see one example in the repo: https://github.com/bevyengine/bevy/blob/90bb1adeb28b82be96546e0c2cde81530241f7af/examples/time/timers.rs
What solution would you like?
Especially for situations where batch processing is not needed, we should be able to queue commands to happen at a specific future point in time, so a TimedCommands
SystemParam
would make sense:
pub fn foo_system(mut commands: Commands, mut timed_commands: TimedCommands, my_entity: Query<Entity, With<Foo>>) {
let my_entity = my_entity.single();
// Normally you might queue a command, and it would apply at the very next sync point:
commands.entity(my_entity).insert(Bar);
// However, with TimedCommands you would queue it to run a specific duration from now.
// This would run at the soonest sync point after the duration has passed.
timed_commands.after(Duration::from_secs(5)).entity(my_entity).insert(Bar);
}
HOWEVER, developers might run into issues where entities get despawned or changed between the time when the command was queued and when it gets applied, so we should take care with what kinds of operations we allow through TimedCommands
.
What alternative(s) have you considered?
Continue with our current boilerplate-heavy solution.