Skip to content

Commit 514557d

Browse files
zicklagTekhnaeRaav
andauthored
refactor: update Jumpy to the latest bones version. (#1053)
Co-authored-by: Tekhnae Raav <tekhnaeraav@katharostech.com>
1 parent 8234e6d commit 514557d

File tree

17 files changed

+162
-135
lines changed

17 files changed

+162
-135
lines changed

Cargo.lock

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.81
1+
1.93.0

src/core.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub const MAX_PLAYERS: u32 = 4;
2828

2929
use std::time::Duration;
3030

31-
use crate::{prelude::*, settings::PlayerControlMapping};
31+
use crate::prelude::*;
3232

3333
pub mod prelude {
3434
pub use super::{
@@ -130,15 +130,7 @@ impl SessionRunner for JumpyDefaultMatchRunner {
130130
let last_run = self.last_run.unwrap_or(frame_start);
131131
let delta = (frame_start - last_run).as_secs_f64();
132132

133-
{
134-
let keyboard = world.resource::<KeyboardInputs>();
135-
let gamepad = world.resource::<GamepadInputs>();
136-
self.input_collector.apply_inputs(
137-
&world.resource::<PlayerControlMapping>(),
138-
&keyboard,
139-
&gamepad,
140-
);
141-
}
133+
self.input_collector.apply_inputs(world);
142134

143135
let mut run = || {
144136
// Advance the world time

src/core/editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl_system_param! {
1919
/// running. This can be used both for manual map editing, and by algorithms for generating or
2020
/// randomizing maps.
2121
///
22-
/// Map generators implement the [`MapConstructor`][crate::core::map_constructor::MapConstructor]
22+
/// Map generators implement the [`MapConstructor`]
2323
/// trait, which is given a [`MapManager`] to make its changes with.
2424
pub struct MapManager<'a> {
2525
commands: Commands<'a>,

src/core/input.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::array;
44

5-
use bones_framework::input::PlayerControls;
5+
use bones_framework::input::Controls;
66

77
use crate::{prelude::*, MAX_PLAYERS};
88

@@ -15,33 +15,19 @@ pub fn install(session: &mut SessionBuilder) {
1515
pub struct MatchInputs {
1616
pub players: [PlayerInput; MAX_PLAYERS as usize],
1717
}
18-
18+
impl MatchInputs {
19+
pub fn get_control_source(&self, player_idx: usize) -> Option<ControlSource> {
20+
self.players.get(player_idx).unwrap().control_source
21+
}
22+
}
1923
impl Default for MatchInputs {
2024
fn default() -> Self {
2125
Self {
2226
players: array::from_fn(|_| default()),
2327
}
2428
}
2529
}
26-
27-
impl PlayerControls<'_, PlayerControl> for MatchInputs {
28-
type ControlSource = ControlSource;
29-
type ControlMapping = PlayerControlMapping;
30-
type InputCollector = PlayerInputCollector;
31-
32-
fn update_controls(&mut self, collector: &mut PlayerInputCollector) {
33-
(0..MAX_PLAYERS as usize).for_each(|i| {
34-
let player_input = &mut self.players[i];
35-
if let Some(source) = &player_input.control_source {
36-
player_input.control = *collector.get_control(i, *source);
37-
}
38-
});
39-
}
40-
41-
fn get_control_source(&self, player_idx: usize) -> Option<ControlSource> {
42-
self.players.get(player_idx).unwrap().control_source
43-
}
44-
30+
impl Controls<'_, PlayerControl> for MatchInputs {
4531
fn get_control(&self, player_idx: usize) -> &PlayerControl {
4632
&self.players.get(player_idx).unwrap().control
4733
}

src/core/map.rs

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
472472
node,
473473
above3l2,
474474
NavGraphEdge {
475-
inputs: std::iter::repeat(PlayerControl {
476-
move_direction: vec2(-1.0, 0.0),
477-
jump_just_pressed: true,
478-
jump_pressed: true,
479-
..default()
480-
})
481-
.take(20)
475+
inputs: std::iter::repeat_n(
476+
PlayerControl {
477+
move_direction: vec2(-1.0, 0.0),
478+
jump_just_pressed: true,
479+
jump_pressed: true,
480+
..default()
481+
},
482+
20,
483+
)
482484
.collect(),
483485
distance: node.distance(&above3l2),
484486
},
@@ -496,13 +498,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
496498
node,
497499
above3l3,
498500
NavGraphEdge {
499-
inputs: std::iter::repeat(PlayerControl {
500-
move_direction: vec2(-1.0, 0.0),
501-
jump_just_pressed: true,
502-
jump_pressed: true,
503-
..default()
504-
})
505-
.take(20)
501+
inputs: std::iter::repeat_n(
502+
PlayerControl {
503+
move_direction: vec2(-1.0, 0.0),
504+
jump_just_pressed: true,
505+
jump_pressed: true,
506+
..default()
507+
},
508+
20,
509+
)
506510
.collect(),
507511
distance: node.distance(&above3l3),
508512
},
@@ -519,13 +523,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
519523
node,
520524
above3r2,
521525
NavGraphEdge {
522-
inputs: std::iter::repeat(PlayerControl {
523-
move_direction: vec2(1.0, 0.0),
524-
jump_just_pressed: true,
525-
jump_pressed: true,
526-
..default()
527-
})
528-
.take(20)
526+
inputs: std::iter::repeat_n(
527+
PlayerControl {
528+
move_direction: vec2(1.0, 0.0),
529+
jump_just_pressed: true,
530+
jump_pressed: true,
531+
..default()
532+
},
533+
20,
534+
)
529535
.collect(),
530536
distance: node.distance(&above3r2),
531537
},
@@ -543,13 +549,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
543549
node,
544550
above3r3,
545551
NavGraphEdge {
546-
inputs: std::iter::repeat(PlayerControl {
547-
move_direction: vec2(1.0, 0.0),
548-
jump_just_pressed: true,
549-
jump_pressed: true,
550-
..default()
551-
})
552-
.take(20)
552+
inputs: std::iter::repeat_n(
553+
PlayerControl {
554+
move_direction: vec2(1.0, 0.0),
555+
jump_just_pressed: true,
556+
jump_pressed: true,
557+
..default()
558+
},
559+
20,
560+
)
553561
.collect(),
554562
distance: node.distance(&above3r3),
555563
},
@@ -708,12 +716,14 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
708716
node,
709717
far_right_below,
710718
NavGraphEdge {
711-
inputs: std::iter::repeat(PlayerControl {
712-
move_direction: vec2(1.0, 0.0),
713-
jump_pressed: true,
714-
..default()
715-
})
716-
.take(20)
719+
inputs: std::iter::repeat_n(
720+
PlayerControl {
721+
move_direction: vec2(1.0, 0.0),
722+
jump_pressed: true,
723+
..default()
724+
},
725+
20,
726+
)
717727
.collect(),
718728
// Bias against using this move because it doesn't always work, by adding an
719729
// extra distance.
@@ -735,12 +745,14 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
735745
node,
736746
far_left_below,
737747
NavGraphEdge {
738-
inputs: std::iter::repeat(PlayerControl {
739-
move_direction: vec2(-1.0, 0.0),
740-
jump_pressed: true,
741-
..default()
742-
})
743-
.take(20)
748+
inputs: std::iter::repeat_n(
749+
PlayerControl {
750+
move_direction: vec2(-1.0, 0.0),
751+
jump_pressed: true,
752+
..default()
753+
},
754+
20,
755+
)
744756
.collect(),
745757
// Bias against using this move because it doesn't always work, by adding an
746758
// extra distance.

src/core/scoring.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ pub fn round_end(
194194
}
195195

196196
if round_transition_synchronized {
197-
if score.rounds_completed % meta.core.config.rounds_between_intermission == 0 {
197+
if score
198+
.rounds_completed
199+
.is_multiple_of(meta.core.config.rounds_between_intermission)
200+
{
198201
scoring_menu.active = true;
199202
scoring_menu.match_score = score.clone();
200203
scoring_menu.next_maps = state.next_maps.clone();

src/debug.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ use bones_framework::debug::frame_time_diagnostics_plugin;
77
use bones_framework::networking::debug::network_debug_window;
88

99
pub fn game_plugin(game: &mut Game) {
10-
game.sessions.create_with(SessionNames::DEBUG, |builder| {
11-
builder
12-
.install_plugin(session_plugin)
13-
.install_plugin(frame_time_diagnostics_plugin);
14-
});
10+
game.sessions
11+
.create_with(SessionNames::DEBUG, |builder: &mut SessionBuilder| {
12+
builder
13+
.install_plugin(session_plugin)
14+
.install_plugin(frame_time_diagnostics_plugin);
15+
});
1516
}
1617

1718
fn session_plugin(session: &mut SessionBuilder) {

src/fullscreen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn update_fullscreen(game: &mut Game) {
1414
let mut storage = storage.borrow_mut().unwrap();
1515
let window = game.shared_resource_cell::<Window>().unwrap();
1616
let mut window = window.borrow_mut().unwrap();
17-
let keyboard = game.shared_resource::<KeyboardInputs>().unwrap();
17+
let keyboard = game.shared_resource::<KeyboardInputs>();
1818

1919
let f11_pressed = keyboard
2020
.key_events

0 commit comments

Comments
 (0)