diff --git a/src/client.rs b/src/client.rs index eeffc177..5c098e88 100644 --- a/src/client.rs +++ b/src/client.rs @@ -10,7 +10,7 @@ use bevy::{ecs::world::CommandQueue, prelude::*}; use bincode::{DefaultOptions, Options}; use bytes::Bytes; use integer_encoding::{FixedIntReader, VarIntReader, VarIntWriter}; -use server_mutate_ticks::ServerMutateTicks; +use server_mutate_ticks::{MutateTickConfirmed, ServerMutateTicks}; use crate::core::{ channels::{ReplicationChannel, RepliconChannels}, @@ -330,6 +330,9 @@ fn apply_mutate_messages( if let Some(mutate_ticks) = &mut params.mutate_ticks { mutate_ticks.confirm(mutate.message_tick, mutate.messages_count); + world.trigger(MutateTickConfirmed { + tick: mutate.message_tick, + }); } false diff --git a/src/client/server_mutate_ticks.rs b/src/client/server_mutate_ticks.rs index d12486f9..7df07678 100644 --- a/src/client/server_mutate_ticks.rs +++ b/src/client/server_mutate_ticks.rs @@ -14,7 +14,7 @@ use crate::core::replicon_tick::RepliconTick; /// [`TrackAppExt::track_mutate_messages`](crate::core::replication::track_mutate_messages::TrackAppExt::track_mutate_messages) /// were called. /// -/// See also [`ServerChangeTick`](super::ServerChangeTick). +/// See also [`MutateTickConfirmed`] and [`ServerChangeTick`](super::ServerChangeTick). #[derive(Debug, Resource)] pub struct ServerMutateTicks { ticks: [TickMessages; 64], @@ -159,6 +159,15 @@ impl TickMessages { } } +/// Triggered when all mutate messages are received for a tick. +/// +/// See also [`ServerMutateTicks`]. +#[derive(Event)] +pub struct MutateTickConfirmed { + /// Message(s) tick. + pub tick: RepliconTick, +} + #[cfg(test)] mod tests { use super::*;