Skip to content

Commit

Permalink
Trigger observers when TweenCompleted event is sent (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peepo-Juice authored Dec 9, 2024
1 parent 2736a2b commit 6607f9c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/tweenable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,16 @@ impl<T> Tweenable<T> for Tween<T> {
// If completed at least once this frame, notify the user
if times_completed > 0 {
if let Some(user_data) = &self.event_data {
events.send(TweenCompleted {
let event = TweenCompleted {
entity,
user_data: *user_data,
});
};

// send regular event
events.send(event);

// trigger all entity-scoped observers
commands.trigger_targets(event, entity);
}
if let Some(cb) = &self.on_completed {
cb(entity, self);
Expand Down Expand Up @@ -1321,10 +1327,16 @@ impl<T> Tweenable<T> for Delay<T> {
// If completed this frame, notify the user
if (state == TweenState::Completed) && !was_completed {
if let Some(user_data) = &self.event_data {
events.send(TweenCompleted {
let event = TweenCompleted {
entity,
user_data: *user_data,
});
};

// send regular event
events.send(event);

// trigger all entity-scoped observers
commands.trigger_targets(event, entity);
}
if let Some(cb) = &self.on_completed {
cb(entity, self);
Expand Down

0 comments on commit 6607f9c

Please sign in to comment.