Skip to content

Allow Use And Registration of Generic Time Contexts#78

Merged
Multirious merged 71 commits intomainfrom
generic_time_context
Mar 5, 2026
Merged

Allow Use And Registration of Generic Time Contexts#78
Multirious merged 71 commits intomainfrom
generic_time_context

Conversation

@Rabbival
Copy link
Copy Markdown
Collaborator

@Rabbival Rabbival commented Feb 5, 2026

Feature

Previously, bevy_tween 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 Fixed time which is required to be in sync with physic engines.

This PR is a continuation from Multirious/bevy_time_runner#15.

Changes

Breaking:

  • All plugins now have the generic parameter TimeCtx and field schedule with the constructor in_schedule. This is used to specify the time context and schedule to register all the systems in.
    For example:
    • DefaultTweenPlugins::default() remains default for () time context within PostUpdate schedule.
    • DefaultTweenPlugins::<Fixed>::in_schedule(FixedLast) for Fixed time context within FixedLast schedule.
  • ALL animation will not run without bevy_time_runner::TimeContext<TimeCtx> marker component with the complementary plugin registered. This also apply to all children of the animation entity. The library currently make sure that all animation spawned through the framework automatically includes this component, but if you do insert any animation components manually, you will have to make sure to include TimeContext component. Consult the docs for more details.
  • Add enable_debug field to TweenCorePlugin.
  • BevyTweenRegisterSystems::add_tween_systems now expects schedule parameter.
  • Add animation_in_time_context<T>() method to AnimationBuilderExt
  • All tween systems has the generic parameter TimeCtx and changed query to only query for tweens entity with TimeContext<TimeCtx> component.

Non-brekaing:

  • Add component_tween_system_with_time_context which is the same as component_tween_system but has the generic parameter TimeCtx

  • Add component_dyn_tween_system_with_time_context which is the same as component_dyn_tween_system but has the generic parameter TimeCtx

  • Add resource_tween_system_with_time_context which is the same as resource_tween_system but has the generic parameter TimeCtx

  • Deprecated TweenAppResource. Though all plugins will continued to support it to remain compatible except plugin groups.

Example

  • Add time_context_animation example.

Future Works

We can add additional debug warnings to catch cases where users may insert tween components to children manually but forgot TimeContext component.

Multirious and others added 12 commits February 4, 2026 21:21
now tweens can be registered to fire on specific schedules per time context (common use: only fire fixed-ticked tweens on fixed update)
so that curves would only be sampled when relevant, and always sampled when relevant
so that, for example, fixed-time animations would only interpolate their tween values on fixed updates. This is crucial for them to work properly (for example, fixed translation tweens should only move their entities on fixed updates)
by adding a generic constructor and having the previous constructor call it defaultly
* separate plugins that should be registered ones, ones that should be registered per schedule and ones that should be registered per schedule and time context.
* allow registering system sets per schedule (necessary for them to take effect)
* allow adding tween systems to a specific schedule (necessary for the rest to work)
Rabbival and others added 17 commits February 5, 2026 12:55
This prevents unnecessary breaking changes.
(Breaking) Add `schedule` field to `EaseKindPlugin`.
Add `TimeCtx` generic to `EaseKindPlugin` with default to ()
Add `in_schedule` method to `EaseKindPlugin`.
implement `Default` for `EaseClosurePlugin<()>`
Update plugin to follow `TweenAppResource` deprecation
while remaining backward-compatible.

`EaseKindTypeRegistrationPlugin` and
`EaseKindSystemRegistrationPlugin` is removed.
Add `TimeCtx` generic with default to `()`
(Breaking) Add public `schedule` field.
Add `in_schedule` method
Rename `time_context_marker` to `marker`
implement `Default` for `EaseClosurePlugin<()>`
where schedule is `PostUpdate`
Update plugin to follow `TweenAppResource` deprecation
while remaining backward-compatible.
Add `TimeCtx` generic to `apply_asset_tween_system`
Update `apply_asset_tween_system`'s query to filter for only tween
with `TimeContext`

Add `TimeCtx` generic to `asset_dyn_tween_system`
Add `TimeCtx` generic to `asset_tween_system`
Add `TimeCtx` generic to `apply_component_tween_system`
Update `apply_component_tween_system`'s query to filter for only tween
with `TimeContext`

Add `TimeCtx` generic to `component_dyn_tween_system`
Add `TimeCtx` generic to `component_tween_system`
Add `TimeCtx` generic to `apply_resource_tween_system`
Update `apply_resource_tween_system`'s query to filter for only tween
with `TimeContext`

Add `TimeCtx` generic to `resource_dyn_tween_system`
Add `TimeCtx` generic to `resource_tween_system`
Add `TimeCtx` generic with default to `()`
(Breaking) Add public `schedule` field and private `marker` field.
Add `in_schedule` method
implement `Default` for `DefaultInterpolatorsPlugin<()>`
where schedule is `PostUpdate`
Update plugin to follow TweenAppResource deprecation
while remaining backward-compatible.
Update systems to use `TimeCtx`

Remove `DefaultInterpolatorsSystemRegistrationPlugin`
Remove `DefaultInterpolatorsTypeRegistrationPlugin`
Add `TimeCtx` generic with default to `()`
(Breaking) Add public `schedule` field and private `marker` field.
Add `in_schedule` method
implement `Default` for `DefaultDynInterpolatorsPlugin<()>`
where schedule is `PostUpdate`
Update plugin to follow TweenAppResource deprecation
while remaining backward-compatible.
Update systems to use `TimeCtx`

Remove `DefaultDynInterpolatorsSystemRegistrationPlugin`
* it now takes TimeCtx generic with default of ()
* for_schedule constructor has been renamed to in_schedule
* DefaultTweenEventPlugins  now takes schedule as well, to register the default tween event plugins
* it now takes TimeCtx generic with default of ()
* on_schedule constructor has been renamed to in_schedule
- Add TimeCtx generic that defaults to `()`
- Add private `marker` field (Breaking)
- Add `in_schedule` constructor
- Impl Default for `DefaultTweenEventPlugins<()>`
… + rustfmt format something

Rename `animation_for_time_context` to `animation_in_time_context`
@Multirious Multirious merged commit 6c5ccd1 into main Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants