Skip to content
Snippets Groups Projects
Unverified Commit a3fecb10 authored by Jerome Humbert's avatar Jerome Humbert Committed by GitHub
Browse files

Fix incorrect change detection triggering (#71)

Ensure change detection on components and assets is only triggered when
an animator effectively modifies said component or asset, and not
invariably just by the simple fact of the animator ticking each frame.

This change modifies the signature of the `component_animator_system()`
and `asset_animator_system()` public functions to directly consume a
`ResMut<Events<TweenCompleted>>` instead of an
`EventWriter<TweenCompleted>`, to work around some internal limitations.

It also publicly exposes a new `Targetable` trait used to work around
the impossibility to retrieve a `Mut<T>` from a `Mut<Assets<T>>`.
Instead, the trait provides an "target dereferencing" method
`target_mut()` which dereferences the target component or asset, and
triggers its change detection. The trait is implemented for all
components via the `ComponentTarget` object, and for all assets via the
`AssetTarget` object. The 3 types described here are publicly exposed to
workaround some Bevy limitations, and because the trait appears in the
public `Tweenable<T>` API. However users are discouraged from taking
strong dependencies on those, as they will be removed once Bevy provides
a way to achieve this conditionaly dereferencing without this
workaround.

Fixes #33
parent f3d614a5
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment