Skip to content
Merged
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
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ bevy_ggrs = { git = "https://github.com/zicklag/bevy_ggrs.git", branch = "jumpy"
bevy_kira_audio = { version = "0.12.0", features = ["ogg"], default-features = false }
# bevy_mod_js_scripting = { git = "https://github.com/zicklag/bevy_mod_js_scripting.git", branch = "jumpy" }
bevy_prototype_lyon = "0.6.0"
bevy_system_graph = "0.3.0"
bevy_tweening = { version = "0.5", default-features = false }
bitfield = "0.14.0"
blocking = "1.2.0"
Expand All @@ -63,13 +64,13 @@ postcard = { git = "https://github.com/zicklag/postcard.git", branch = "custom-e
rand = "0.8.5"
rustls = { version = "0.20.7", features = ["dangerous_configuration", "quic"] }
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.89"
serde_yaml = "0.9.2"
sys-locale = "0.2.1"
thiserror = "1.0.31"
tracing = { version = "0.1.37", features = ["release_max_level_debug"] }
turborand = { version = "0.8.0", features = ["atomic", "serialize"] }
unic-langid = "0.9.0"
serde_json = "1.0.89"

[dependencies.bevy]
version = "0.8"
Expand Down
39 changes: 11 additions & 28 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,17 @@ impl Plugin for AnimationPlugin {
.register_rollback_type::<AnimationBank>()
.register_rollback_type::<AnimationBankSprite>()
})
.extend_rollback_schedule(|schedule| {
schedule
.add_stage_after(
RollbackStage::PostUpdate,
AnimationStage::Hydrate,
SystemStage::single_threaded()
.with_system(hydrate_animation_bank_sprites)
.with_system(
hydrate_animated_sprites.after(hydrate_animation_bank_sprites),
),
)
.add_stage_after(
AnimationStage::Hydrate,
AnimationStage::Animate,
SystemStage::single_threaded()
.with_system(update_animation_bank_sprites)
.with_system(
update_animated_sprite_components
.after(update_animation_bank_sprites),
)
.with_system(
animate_sprites
.run_in_state(GameState::InGame)
.run_not_in_state(InGameState::Paused)
.after(update_animated_sprite_components.as_system_label()),
),
);
});
.add_rollback_system(RollbackStage::PostUpdate, hydrate_animation_bank_sprites)
.add_rollback_system(RollbackStage::PostUpdate, hydrate_animated_sprites)
.add_rollback_system(RollbackStage::PostUpdate, update_animation_bank_sprites)
.add_rollback_system(RollbackStage::PostUpdate, update_animated_sprite_components)
.add_rollback_system(
RollbackStage::PostUpdate,
animate_sprites
.run_in_state(GameState::InGame)
.run_not_in_state(InGameState::Paused)
.after(update_animated_sprite_components.as_system_label()),
);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ impl Plugin for CameraPlugin {
fn build(&self, app: &mut App) {
app.register_type::<GameCamera>()
.register_type::<EditorCamera>()
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(RollbackStage::Update, camera_controller);
});
.add_rollback_system(RollbackStage::Update, camera_controller);

app.add_plugin(bevy_parallax::ParallaxPlugin);
}
Expand Down
5 changes: 1 addition & 4 deletions src/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ impl Plugin for DamagePlugin {
.register_rollback_type::<DamageRegion>()
.register_rollback_type::<DamageRegionOwner>()
})
.extend_rollback_schedule(|schedule| {
schedule
.add_system_to_stage(RollbackStage::PostUpdate, kill_players_in_damage_region);
});
.add_rollback_system(RollbackStage::PostUpdate, kill_players_in_damage_region);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ impl Plugin for LifetimePlugin {
fn build(&self, app: &mut App) {
app.register_type::<Lifetime>()
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<Lifetime>())
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(RollbackStage::PostUpdate, lifetime_system);
});
.add_rollback_system(RollbackStage::PostUpdate, lifetime_system);
}
}

Expand Down
29 changes: 18 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub mod prelude;
pub mod random;
pub mod run_criteria;
pub mod schedule;
// pub mod scripting;
pub mod session;
pub mod ui;
pub mod utils;
Expand All @@ -74,6 +73,7 @@ use crate::{
player::PlayerPlugin,
prelude::*,
random::RandomPlugin,
schedule::RollbackSystems,
session::SessionPlugin,
ui::UiPlugin,
utils::{run_criteria_game_not_paused, UtilsPlugin},
Expand Down Expand Up @@ -103,7 +103,7 @@ pub enum GameEditorState {
Visible,
}

#[derive(StageLabel)]
#[derive(StageLabel, Eq, PartialEq, Hash)]
pub enum RollbackStage {
Input,
First,
Expand Down Expand Up @@ -161,42 +161,43 @@ pub fn main() {
.add_loopless_state(InGameState::Playing)
.add_loopless_state(GameEditorState::Hidden);

// Create the GGRS rollback schedule and plugin
// Create the GGRS rollback schedule, systems, and plugin
let mut rollback_schedule = Schedule::default();
let rollback_systems = RollbackSystems::default();
let rollback_plugin = GGRSPlugin::<GgrsConfig>::new();

// Add fixed update stagesrefs/branchless/2fd80952e26d905aa258ebb7e6175a7cfc4cb76f
rollback_schedule
.add_stage(RollbackStage::Input, SystemStage::parallel())
.add_stage_after(
RollbackStage::Input,
RollbackStage::First,
SystemStage::parallel().with_run_criteria(run_criteria_game_not_paused),
SystemStage::single_threaded().with_run_criteria(run_criteria_game_not_paused),
)
.add_stage_after(
RollbackStage::First,
RollbackStage::PreUpdate,
SystemStage::parallel().with_run_criteria(run_criteria_game_not_paused),
SystemStage::single_threaded().with_run_criteria(run_criteria_game_not_paused),
)
.add_stage_after(
RollbackStage::PreUpdate,
RollbackStage::Update,
SystemStage::parallel().with_run_criteria(run_criteria_game_not_paused),
SystemStage::single_threaded().with_run_criteria(run_criteria_game_not_paused),
)
.add_stage_after(
RollbackStage::Update,
RollbackStage::PostUpdate,
SystemStage::parallel().with_run_criteria(run_criteria_game_not_paused),
SystemStage::single_threaded().with_run_criteria(run_criteria_game_not_paused),
)
.add_stage_after(
RollbackStage::PostUpdate,
RollbackStage::Last,
SystemStage::parallel().with_run_criteria(run_criteria_game_not_paused),
SystemStage::single_threaded().with_run_criteria(run_criteria_game_not_paused),
);

// Add the rollback schedule and plugin as resources, temporarily.
// This allows plugins to modify them using `crate::schedule::RollbackScheduleAppExt`.
app.insert_resource(rollback_schedule);
app.insert_non_send_resource(rollback_systems);
app.insert_resource(rollback_plugin);

// Install game plugins
Expand Down Expand Up @@ -235,10 +236,16 @@ pub fn main() {
.add_plugin(NetworkingPlugin)
.add_plugin(SessionPlugin);

// Pull the schedule back out of the world
let rollback_schedule: Schedule = app.world.remove_resource().unwrap();
// Pull the rollback systems back out of the world
let mut rollback_schedule: Schedule = app.world.remove_resource().unwrap();
let rollback_systems: RollbackSystems = app.world.remove_non_send_resource().unwrap();
let ggrs_plugin: GGRSPlugin<GgrsConfig> = app.world.remove_resource().unwrap();

// Add the rollback systems to the schedule
for (stage, set) in rollback_systems {
rollback_schedule.add_system_set_to_stage(stage, set.graph.into());
}

// Build the GGRS plugin
ggrs_plugin
.with_input_system(player::input::input_system)
Expand Down
7 changes: 1 addition & 6 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ impl Plugin for MapPlugin {
.register_rollback_type::<MapElementHydrated>()
.register_rollback_type::<Handle<MapElementMeta>>()
})
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(
RollbackStage::Last,
handle_out_of_bounds_players_and_items,
);
})
.add_rollback_system(RollbackStage::Last, handle_out_of_bounds_players_and_items)
.add_plugin(elements::MapElementsPlugin);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/map/elements/decoration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ pub struct DecorationPlugin;

impl Plugin for DecorationPlugin {
fn build(&self, app: &mut App) {
app.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(RollbackStage::PreUpdate, hydrate_decorations);
});
app.add_rollback_system(RollbackStage::PreUpdate, hydrate_decorations);
}
}

Expand Down
22 changes: 8 additions & 14 deletions src/map/elements/grenade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ impl Default for LitGrenade {

impl Plugin for GrenadePlugin {
fn build(&self, app: &mut App) {
app.extend_rollback_schedule(|schedule| {
schedule
.add_system_to_stage(RollbackStage::PreUpdate, pre_update_in_game)
.add_system_to_stage(
RollbackStage::Update,
update_lit_grenades.before(update_idle_grenades),
)
.add_system_to_stage(RollbackStage::Update, update_idle_grenades);
})
.extend_rollback_plugin(|plugin| {
plugin
.register_rollback_type::<IdleGrenade>()
.register_rollback_type::<LitGrenade>()
});
app.add_rollback_system(RollbackStage::PreUpdate, pre_update_in_game)
.add_rollback_system(RollbackStage::Update, update_lit_grenades)
.add_rollback_system(RollbackStage::Update, update_idle_grenades)
.extend_rollback_plugin(|plugin| {
plugin
.register_rollback_type::<IdleGrenade>()
.register_rollback_type::<LitGrenade>()
});
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/map/elements/player_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ pub struct PlayerSpawnerPlugin;
impl Plugin for PlayerSpawnerPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<CurrentPlayerSpawner>()
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(RollbackStage::PreUpdate, pre_update_in_game);
})
.add_rollback_system(RollbackStage::PreUpdate, pre_update_in_game)
.extend_rollback_plugin(|plugin| {
plugin
.register_rollback_type::<PlayerSpawner>()
Expand Down
9 changes: 3 additions & 6 deletions src/map/elements/sproinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ const FORCE: f32 = 30.0;
pub struct SproingerPlugin;
impl Plugin for SproingerPlugin {
fn build(&self, app: &mut App) {
app.extend_rollback_schedule(|schedule| {
schedule
.add_system_to_stage(RollbackStage::PreUpdate, pre_update_in_game)
.add_system_to_stage(RollbackStage::Update, update_in_game);
})
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<Sproinger>());
app.add_rollback_system(RollbackStage::PreUpdate, pre_update_in_game)
.add_rollback_system(RollbackStage::Update, update_in_game)
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<Sproinger>());
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/map/elements/sword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ use super::*;
pub struct SwordPlugin;
impl Plugin for SwordPlugin {
fn build(&self, app: &mut App) {
app.extend_rollback_schedule(|schedule| {
schedule
.add_system_to_stage(RollbackStage::PreUpdate, pre_update_in_game)
.add_system_to_stage(RollbackStage::Update, update_in_game);
})
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<SwordState>());
app.add_rollback_system(RollbackStage::PreUpdate, pre_update_in_game)
.add_rollback_system(RollbackStage::Update, update_in_game)
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<SwordState>());
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ impl Plugin for PlayerPlugin {
.register_rollback_type::<PlayerState>()
.register_rollback_type::<PlayerKilled>()
})
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(
RollbackStage::PreUpdate,
hydrate_players.run_if_resource_exists::<GameMeta>(),
);
});
.add_rollback_system(
RollbackStage::PreUpdate,
hydrate_players.run_if_resource_exists::<GameMeta>(),
);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/player/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ impl Plugin for PlayerInputPlugin {
)
.add_system_to_stage(CoreStage::Last, clear_input_buffer)
.extend_rollback_plugin(|plugin| plugin.register_rollback_type::<PlayerInputs>())
.extend_rollback_schedule(|schedule| {
schedule.add_system_to_stage(RollbackStage::Input, update_user_input);
});
.add_rollback_system(RollbackStage::Input, update_user_input);
}
}

Expand Down
Loading