Skip to content

Commit

Permalink
Fixing Bevy 0.11 deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankopf committed Aug 7, 2023
1 parent b4fcb6d commit 1062ae4
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 259 deletions.
4 changes: 2 additions & 2 deletions src/button_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pub struct ButtonPlugin;
impl Plugin for ButtonPlugin {
fn build(&self, app: &mut App) {
app
.add_system(
.add_systems(
Update,
button_system
.run_if(in_state(GameState::MainMenu))
)
Expand All @@ -31,7 +32,6 @@ fn button_system(
(Changed<Interaction>, With<Button>),
>,
mut text_query: Query<&mut Text>,
mut gamestate: ResMut<State<GameState>>,
mut nextstate: ResMut<bevy::ecs::schedule::NextState<GameState>>,
) {
for (interaction, mut color, children) in &mut interaction_query {
Expand Down
22 changes: 15 additions & 7 deletions src/combat_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@ use super::prelude::*;
mod melee;
mod ranged;

pub const HALF_SECOND: &str = "half_second";

// Make Plugin
pub struct CombatPlugin;

impl Plugin for CombatPlugin {
fn build(&self, app: &mut App) {
app
.add_system(
.add_systems(
Update,
(
melee::combat_system_melee
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
.run_if(in_state(GameState::InGame))
)
.add_system(
,
ranged::combat_system_ranged
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
.run_if(in_state(GameState::InGame))
)
.add_system(
,
melee::attacked_entities_system
.run_if(in_state(GameState::InGame))
)
)
// .add_system(
// ranged::combat_system_ranged
// .run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
// .run_if(in_state(GameState::InGame))
// )
// .add_system(
// melee::attacked_entities_system
// .run_if(in_state(GameState::InGame))
// )
// .add_fixed_timestep_system(
// HALF_SECOND,
// 0,
Expand Down
2 changes: 1 addition & 1 deletion src/combat_system/melee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn do_melee_damage(
body1: &PhysicalBody,
body2: &mut PhysicalBody,
) {
body2.attributes.health -= 50;
body2.attributes.health -= 10;
println!("Health: {}", body2.attributes.health);
if body2.attributes.health <= 0 {
commands.entity(attacked_entity).despawn_recursive();
Expand Down
39 changes: 23 additions & 16 deletions src/interface/click.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@ impl Plugin for ClickPlugin {
fn build(&self, app: &mut App) {
app
.add_event::<ObjectFinderEvent>()
.add_system(
mouse_click_input
.run_if(in_state(GameState::InGame))
)
.add_system(
mouse_drag_system
.run_if(in_state(GameState::InGame))
)
.add_system(
object_finder_system
.run_if(in_state(GameState::InGame))
)
.add_system(
mouse_move_system
.run_if(in_state(GameState::InGame))
.add_systems(
Update,
( mouse_click_input.run_if(in_state(GameState::InGame)),
mouse_drag_system.run_if(in_state(GameState::InGame)),
object_finder_system.run_if(in_state(GameState::InGame)),
mouse_move_system.run_if(in_state(GameState::InGame)) )
)
// .add_system(
// mouse_click_input
// .run_if(in_state(GameState::InGame))
// )
// .add_system(
// mouse_drag_system
// .run_if(in_state(GameState::InGame))
// )
// .add_system(
// object_finder_system
// .run_if(in_state(GameState::InGame))
// )
// .add_system(
// mouse_move_system
// .run_if(in_state(GameState::InGame))
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(mouse_click_input),
Expand Down Expand Up @@ -151,7 +158,7 @@ pub fn mouse_drag_system(
}

pub fn mouse_move_system(
mut windows: Query<&mut Window>,
windows: Query<&mut Window>,
q_camera: Query<(&Camera, &GlobalTransform)>,
// dragging: Res<Dragging>, Use to only highlight a specific type in the future??
positions: Query<(Entity, &Position, Option<&Brain>, Option<&Food>, Option<&Plant>)>,
Expand Down
12 changes: 8 additions & 4 deletions src/interface/game_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ pub struct GameUiPlugin;
impl Plugin for GameUiPlugin {
fn build(&self, app: &mut App) {
app
.add_startup_system(initialize_game_ui)
.add_systems(
Startup,
initialize_game_ui
)
.add_systems(
OnEnter(GameState::InGame),
start_game_ui
)
.add_system(
game_ui_click
.run_if(in_state(GameState::InGame))
.add_systems(
Update,
game_ui_click.run_if(in_state(GameState::InGame))
)
// .add_startup_system(initialize_game_ui)
// .add_system_set(
// SystemSet::on_enter(GameState::InGame)
// .with_system(start_game_ui),
Expand Down
6 changes: 4 additions & 2 deletions src/interface/info_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ pub struct InfoPanelPlugin;
impl Plugin for InfoPanelPlugin {
fn build(&self, app: &mut App) {
app
.add_system(show_info_panel)
.add_system(info_system)
.add_systems(
Update,
(show_info_panel, info_system)
)
;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/interface/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn keyboard_input(
_commands: Commands,
input: Res<Input<KeyCode>>,
mut camera: Query<&mut Transform, With<Camera>>,
mut gamestate: ResMut<State<GameState>>,
gamestate: ResMut<State<GameState>>,
mut nextstate: ResMut<bevy::ecs::schedule::NextState<GameState>>,
) {
if input.just_pressed(KeyCode::Space) {
Expand Down
9 changes: 2 additions & 7 deletions src/monstergenerator_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ pub struct MonsterGeneratorPlugin;

impl Plugin for MonsterGeneratorPlugin {
fn build(&self, app: &mut App) {
app.add_system(
monster_generator.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
app.add_systems(
Update, monster_generator.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
);
// app.add_system_set(
// SystemSet::new()
// .with_run_criteria(FixedTimestep::step(1.0))
// .with_system(monster_generator),
// );
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/movetoward_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ pub struct MovementPlugin;
impl Plugin for MovementPlugin {
fn build(&self, app: &mut App) {
app
.add_system(movement_path_generating)
.add_system(clear_unreachable_paths)
.add_system(
.add_systems( Update, (movement_path_generating, clear_unreachable_paths))
.add_systems(
Update,
movement_along_path
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(0.5)))
.run_if(in_state(GameState::InGame))
);
// .add_fixed_timestep_system(
// HALF_SECOND, 0,
// movement_along_path.run_in_bevy_state(GameState::InGame),
// )
)
;
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ pub struct NeedsPlugin;

impl Plugin for NeedsPlugin {
fn build(&self, app: &mut App) {
app.add_system(
app.add_systems(
Update,
needs_status_system
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(2.0)))
.run_if(in_state(GameState::InGame))
);
// .add_fixed_timestep_system(
// TWO_SECOND, 0,
// needs_status_system.run_in_bevy_state(GameState::InGame),
// )
// ;
)
;
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/seasons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ pub struct SeasonsPlugin;
impl Plugin for SeasonsPlugin {
fn build(&self, app: &mut App) {
app
.add_system(
.add_systems(
Update,
seasons_system
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(2.0)))
.run_if(in_state(GameState::InGame))
);
// .add_fixed_timestep_system(
// TWO_SECOND, 0,
// seasons.run_in_bevy_state(GameState::InGame),
// )
// ;
)
;
}
}

Expand Down
68 changes: 21 additions & 47 deletions src/selection_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,28 @@ impl Plugin for SelectionPlugin {
fn build(&self, app: &mut App) {
app
.add_event::<SelectionEvent>()
.add_system(
select_unselecting
.run_if(in_state(GameState::InGame))
.add_systems(
Update,
(
select_unselecting
.run_if(in_state(GameState::InGame))
,
select_foragables
.run_if(in_state(GameState::InGame))
,
select_choppables
.run_if(in_state(GameState::InGame))
,
select_zoning
.run_if(in_state(GameState::InGame))
,
select_unzoning
.run_if(in_state(GameState::InGame))
,
select_nothing
.run_if(in_state(GameState::InGame))
)
)
.add_system(
select_foragables
.run_if(in_state(GameState::InGame))
)
.add_system(
select_choppables
.run_if(in_state(GameState::InGame))
)
.add_system(
select_zoning
.run_if(in_state(GameState::InGame))
)
.add_system(
select_unzoning
.run_if(in_state(GameState::InGame))
)
.add_system(
select_nothing
.run_if(in_state(GameState::InGame))
)
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_unselecting),
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_foragables),
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_choppables),
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_zoning),
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_unzoning),
// )
// .add_system_set(
// SystemSet::on_update(GameState::InGame)
// .with_system(select_nothing),
// )
;
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/spoilage_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ pub struct SpoilagePlugin;
impl Plugin for SpoilagePlugin {
fn build(&self, app: &mut App) {
app
.add_system(
.add_systems(
Update,
spoilage_system
.run_if(bevy::time::common_conditions::on_timer(bevy::utils::Duration::from_secs_f32(2.0)))
.run_if(in_state(GameState::InGame))
)
// .add_fixed_timestep_system(
// HALF_SECOND, 0,
// spoilage_system.run_in_bevy_state(GameState::InGame),
// )
;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct StartupPlugin;
impl Plugin for StartupPlugin {
fn build(&self, app: &mut App) {
app
.add_startup_system(startup)
.add_systems(Startup, startup)
.insert_resource(MyFont(Handle::<Font>::default()))
;
}
Expand Down
Loading

0 comments on commit 1062ae4

Please sign in to comment.