Enable registering time runners of different steps and schedules#15
Enable registering time runners of different steps and schedules#15Multirious merged 38 commits intomainfrom
Conversation
* Time runners will now determine the time according to which they should be ticked (for example, Fixed) * Therefore, the general schedule on which their ticking systems would run can be configured (would make no sense to tick fixed timers on PostUpdate) * This does mean that one has to register these as separate plugins * The previous configuration (default time on PostUpdate) is registered by default
to make up for the fact time runners are now generic
|
IIRC, this is done prior bevy 0.18 so I'll rerun CI just to make sure. |
This reverts commit b5e62eb.
| pub struct TimeRunnerPlugin { | ||
| pub struct TimeRunnerRegistrationPlugin<TimeStep = ()> | ||
| where | ||
| TimeStep: Default + Send + Sync + 'static, |
There was a problem hiding this comment.
Originally, the generic type in Time only requires Default. https://docs.rs/bevy/latest/bevy/prelude/struct.Time.html
We might need to make the requirements the same. (This also applies to other part of the changes)
There was a problem hiding this comment.
It does, but the original time is a Resource and not a component
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
|
||
| /// Add [`time_runner_system`] | ||
| /// Registers [`TimeRunner`] | ||
| /// Add [`time_runner_system on schedule`] |
There was a problem hiding this comment.
This break doc links. Should probably be
Add [`time_runner_system`] on schedule
Or maybe
Add [`time_runner_system::<TimeStep>`] on schedule
?
There was a problem hiding this comment.
Changed to Add [time_runner_system::] on schedule
| fn default() -> Self { | ||
| TimeRunnerPlugin { | ||
| schedule: PostUpdate.intern(), | ||
| default_time_schedule: PostUpdate.intern(), |
There was a problem hiding this comment.
I think renaming is not necessary here, since by Plugin documentation, TimeRunnerPlugin should already be known as default configuration. This only adds additional breaking changes.
| #[derive(Debug, Clone, PartialEq, Component)] | ||
| #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] | ||
| #[cfg_attr(feature = "bevy_reflect", reflect(Component))] | ||
| #[require(TimeStepMarker<()>)] |
There was a problem hiding this comment.
I think this does basically nothing?
| repeat: Option<(Repeat, RepeatStyle)>, | ||
| } | ||
|
|
||
| /// A marker component attached to all TimeRunners no matter their TimeStep, for ease of querying |
There was a problem hiding this comment.
This documents likely out-dated here
…fault This commit adds `enable_debug` field `TimeRunnerPlugin` which is a breaking change.
Generic time steps extra
Feature
Previously, bevy_time_runner systems only support running in the default time context
().This PR adds support to register systems in arbitary time context to support some cases where running in non-default context is necessary, such as, playing animation in
Fixedtime which is required to be in sync with physic engines.Notable Changes
TimeRunnerPluginwhich now usesTimeRunnerSystemsPlugin<()>by default.TimeRunneris always expected to have theTimeContext<TimeCtx>marker component.TimeContext<TimeCtx>is automatically inserted to children ofTimeRunner.debug. This addsTimeRunnerDebugPluginwhich logs warnings on missingTimeContext<TimeCtx>marker component when enabled.Detailed Changes
TimeRunnerSystemsPlugin<TimeCtx = ()>TimeContext<TimeCtx>marker component.TaggingtoTimeRunnerSet(Breaking)tag_time_runner_children_with_contextsystem.debugfeature is enabled, an "on add" hook is registered toTimeRunnerTimeRunnerDebugPluginTimeRunnerDebugInforesourcetrueby default (Breaking)TimeRunnerPluginautomatically addsTimeRunnerSystemsPlugin::<()>when is not added.TimeRunnerPluginautomatically addsTimeRunnerDebugPlugin::default()when is not added andenable_debugis true.These systems now expected
TimeCtxgeneric and modified parameter (Breaking)tag_time_runner_children_with_contexttick_time_runner_systemtime_runner_systemDependency
debugfeature which depends onbevy_logInternal
time_runner_with_no_time_steps_warningtest