Skip to content
Draft
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ use std::{fmt::Debug, hash::Hash, marker::PhantomData, net::SocketAddr};

pub use ggrs;

pub use local::*;
pub use rollback::*;
pub use snapshot::*;
pub use time::*;

mod local;
pub(crate) mod rollback;
pub(crate) mod schedule_systems;
pub(crate) mod snapshot;
Expand Down Expand Up @@ -122,6 +124,18 @@ pub struct LocalInputs<C: Config>(pub HashMap<PlayerHandle, C::Input>);
#[derive(Resource, Default)]
pub struct LocalPlayers(pub Vec<PlayerHandle>);

/// The number of times we have rolled back (mispredicted)
#[derive(
Resource, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Deref, DerefMut,
)]
pub struct Rollbacks(usize);

/// The number of times we have rolled back (mispredicted)
#[derive(
Resource, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Deref, DerefMut,
)]
pub struct LastRollback(i32);

/// Label for the schedule which reads the inputs for the current frame
#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)]
pub struct ReadInputs;
Expand Down Expand Up @@ -192,6 +206,8 @@ impl<C: Config> Default for GgrsPlugin<C> {
impl<C: Config> Plugin for GgrsPlugin<C> {
fn build(&self, app: &mut App) {
app.init_resource::<RollbackFrameCount>()
.init_resource::<Rollbacks>()
.init_resource::<LastRollback>()
.init_resource::<ConfirmedFrameCount>()
.init_resource::<MaxPredictionWindow>()
.init_resource::<RollbackOrdered>()
Expand Down
Loading