Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
tests pass on 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Mar 7, 2024
1 parent 3a0588e commit fcd88b9
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 129 deletions.
334 changes: 219 additions & 115 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = {version = "0.12", default_features = false}
bevy = {version = "0.13", default_features = false}
itertools = "0.11.0"
thiserror = "1.0.44"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Assumes game logic uses bevy's `FixedUpdate` schedule.
Current status: under development alongside a multiplayer server-authoritative game.
I am "RJ" on bevy's discord, in the networking channel, if you want to discuss.

**STATUS** i built this for bevy 0.11, and have recently upgraded to 0.13 (still testing on 0.13..)

### "Sports Games"

This crate is built for so called "sports games" where dynamic entities interact in the same
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ impl Plugin for TimewarpPlugin {
self.config.schedule(),
(
TimewarpPrefixSet::First,
TimewarpPrefixSet::InRollback.run_if(resource_exists::<Rollback>()),
TimewarpPrefixSet::InRollback.run_if(resource_exists::<Rollback>),
// -- apply_deferred -- //
TimewarpPrefixSet::NotInRollback.run_if(not(resource_exists::<Rollback>())),
TimewarpPrefixSet::NotInRollback.run_if(not(resource_exists::<Rollback>)),
// -- apply_deferred -- //
TimewarpPrefixSet::StartRollback.run_if(resource_added::<Rollback>()),
TimewarpPrefixSet::StartRollback.run_if(resource_added::<Rollback>),
TimewarpPrefixSet::UnwrapBlueprints,
TimewarpPrefixSet::Last,
// -- apply_deferred -- //
Expand Down Expand Up @@ -318,7 +318,7 @@ impl Plugin for TimewarpPlugin {
)
.add_systems(
self.config.schedule(),
log_normal_frame.run_if(not(resource_exists::<Rollback>())),
log_normal_frame.run_if(not(resource_exists::<Rollback>)),
)
//
// End debug headers
Expand Down Expand Up @@ -362,7 +362,7 @@ impl Plugin for TimewarpPlugin {
(
TimewarpPostfixSet::First,
TimewarpPostfixSet::Components,
TimewarpPostfixSet::InRollback.run_if(resource_exists::<Rollback>()),
TimewarpPostfixSet::InRollback.run_if(resource_exists::<Rollback>),
TimewarpPostfixSet::Last,
)
.chain(),
Expand Down
4 changes: 2 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl TimewarpTraits for App {
self.add_systems(
schedule,
prefix_first::record_component_death::<T>
.run_if(not(resource_exists::<Rollback>()))
.run_if(not(resource_exists::<Rollback>))
.in_set(TimewarpPrefixSet::First),
);
self.add_systems(
Expand Down Expand Up @@ -154,7 +154,7 @@ trait TimewarpCommands {
fn remove_component_at_end_of_frame<T: TimewarpComponent>(&mut self, frame: FrameNumber);
}

impl TimewarpCommands for EntityCommands<'_, '_, '_> {
impl TimewarpCommands for EntityCommands<'_> {
fn remove_component_at_end_of_frame<T: TimewarpComponent>(&mut self, frame: FrameNumber) {
self.add(RemoveComponentAtFrame::<T>::new(frame));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/basic_rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ fn basic_rollback() {
(inc_frame, take_damage, log_all)
.chain()
.in_set(TimewarpTestSets::GameLogic)
.run_if(not(resource_exists::<Rollback>())),
.run_if(not(resource_exists::<Rollback>)),
);
// the core simulation-only game loop, for running during a rollback
app.add_systems(
FixedUpdate,
(inc_frame, take_damage, log_all)
.chain()
.in_set(TimewarpTestSets::GameLogic)
.run_if(resource_exists::<Rollback>()),
.run_if(resource_exists::<Rollback>),
);

// doing initial spawning here instead of a system in Setup, so we can grab entity ids:
Expand Down Expand Up @@ -244,7 +244,7 @@ fn normal_frames_get_a_chance_to_run_between_rollbacks() {
FixedUpdate,
(
inc_frame,
inc_bloop.run_if(not(resource_exists::<Rollback>())),
inc_bloop.run_if(not(resource_exists::<Rollback>)),
take_damage,
log_all,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/spawns_in_rollback_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ fn rollback_over_new_spawn() {
(inc_frame, take_damage, log_all)
.chain()
.in_set(TimewarpTestSets::GameLogic)
.run_if(not(resource_exists::<Rollback>())),
.run_if(not(resource_exists::<Rollback>)),
);
// the core simulation-only game loop, for running during a rollback
app.add_systems(
FixedUpdate,
(inc_frame, take_damage, log_all)
.chain()
.in_set(TimewarpTestSets::GameLogic)
.run_if(resource_exists::<Rollback>()),
.run_if(resource_exists::<Rollback>),
);

// doing initial spawning here instead of a system in Setup, so we can grab entity ids:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn setup_test_app() -> App {
app.add_plugins(bevy::log::LogPlugin {
level: bevy::log::Level::TRACE,
filter: "bevy_timewarp=trace".to_string(),
update_subscriber: None,
});
app.add_plugins(TimewarpPlugin::new(tw_config));
app.add_plugins(bevy::time::TimePlugin);
Expand All @@ -43,7 +44,7 @@ pub fn setup_test_app() -> App {
// Should be really small compared to [TIMESTEP]
Duration::from_nanos(1),
));
app.add_systems(bevy::app::RunFixedUpdateLoop, |world: &mut World| {
app.add_systems(bevy::app::RunFixedMainLoop, |world: &mut World| {
// Manually runs the `FixedUpdate` schedule every `Update` cycle
world.run_schedule(FixedUpdate);
});
Expand Down

0 comments on commit fcd88b9

Please sign in to comment.