Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger observers when TweenCompleted event is sent #133

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading