Skip to content
Snippets Groups Projects
  • Jerome Humbert's avatar
    Fix incorrect change detection triggering (#71) · a3fecb10
    Jerome Humbert authored
    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
    a3fecb10