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
27 changes: 14 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.81
1.93.0
12 changes: 2 additions & 10 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const MAX_PLAYERS: u32 = 4;

use std::time::Duration;

use crate::{prelude::*, settings::PlayerControlMapping};
use crate::prelude::*;

pub mod prelude {
pub use super::{
Expand Down Expand Up @@ -130,15 +130,7 @@ impl SessionRunner for JumpyDefaultMatchRunner {
let last_run = self.last_run.unwrap_or(frame_start);
let delta = (frame_start - last_run).as_secs_f64();

{
let keyboard = world.resource::<KeyboardInputs>();
let gamepad = world.resource::<GamepadInputs>();
self.input_collector.apply_inputs(
&world.resource::<PlayerControlMapping>(),
&keyboard,
&gamepad,
);
}
self.input_collector.apply_inputs(world);

let mut run = || {
// Advance the world time
Expand Down
2 changes: 1 addition & 1 deletion src/core/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl_system_param! {
/// running. This can be used both for manual map editing, and by algorithms for generating or
/// randomizing maps.
///
/// Map generators implement the [`MapConstructor`][crate::core::map_constructor::MapConstructor]
/// Map generators implement the [`MapConstructor`]
/// trait, which is given a [`MapManager`] to make its changes with.
pub struct MapManager<'a> {
commands: Commands<'a>,
Expand Down
28 changes: 7 additions & 21 deletions src/core/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::array;

use bones_framework::input::PlayerControls;
use bones_framework::input::Controls;

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

Expand All @@ -15,33 +15,19 @@ pub fn install(session: &mut SessionBuilder) {
pub struct MatchInputs {
pub players: [PlayerInput; MAX_PLAYERS as usize],
}

impl MatchInputs {
pub fn get_control_source(&self, player_idx: usize) -> Option<ControlSource> {
self.players.get(player_idx).unwrap().control_source
}
}
impl Default for MatchInputs {
fn default() -> Self {
Self {
players: array::from_fn(|_| default()),
}
}
}

impl PlayerControls<'_, PlayerControl> for MatchInputs {
type ControlSource = ControlSource;
type ControlMapping = PlayerControlMapping;
type InputCollector = PlayerInputCollector;

fn update_controls(&mut self, collector: &mut PlayerInputCollector) {
(0..MAX_PLAYERS as usize).for_each(|i| {
let player_input = &mut self.players[i];
if let Some(source) = &player_input.control_source {
player_input.control = *collector.get_control(i, *source);
}
});
}

fn get_control_source(&self, player_idx: usize) -> Option<ControlSource> {
self.players.get(player_idx).unwrap().control_source
}

impl Controls<'_, PlayerControl> for MatchInputs {
fn get_control(&self, player_idx: usize) -> &PlayerControl {
&self.players.get(player_idx).unwrap().control
}
Expand Down
92 changes: 52 additions & 40 deletions src/core/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
above3l2,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
},
20,
)
.collect(),
distance: node.distance(&above3l2),
},
Expand All @@ -496,13 +498,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
above3l3,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
},
20,
)
.collect(),
distance: node.distance(&above3l3),
},
Expand All @@ -519,13 +523,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
above3r2,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
},
20,
)
.collect(),
distance: node.distance(&above3r2),
},
Expand All @@ -543,13 +549,15 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
above3r3,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_just_pressed: true,
jump_pressed: true,
..default()
},
20,
)
.collect(),
distance: node.distance(&above3r3),
},
Expand Down Expand Up @@ -708,12 +716,14 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
far_right_below,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(1.0, 0.0),
jump_pressed: true,
..default()
},
20,
)
.collect(),
// Bias against using this move because it doesn't always work, by adding an
// extra distance.
Expand All @@ -735,12 +745,14 @@ fn create_nav_graph(meta: &MapMeta) -> Arc<NavGraphInner> {
node,
far_left_below,
NavGraphEdge {
inputs: std::iter::repeat(PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_pressed: true,
..default()
})
.take(20)
inputs: std::iter::repeat_n(
PlayerControl {
move_direction: vec2(-1.0, 0.0),
jump_pressed: true,
..default()
},
20,
)
.collect(),
// Bias against using this move because it doesn't always work, by adding an
// extra distance.
Expand Down
5 changes: 4 additions & 1 deletion src/core/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ pub fn round_end(
}

if round_transition_synchronized {
if score.rounds_completed % meta.core.config.rounds_between_intermission == 0 {
if score
.rounds_completed
.is_multiple_of(meta.core.config.rounds_between_intermission)
{
scoring_menu.active = true;
scoring_menu.match_score = score.clone();
scoring_menu.next_maps = state.next_maps.clone();
Expand Down
11 changes: 6 additions & 5 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use bones_framework::debug::frame_time_diagnostics_plugin;
use bones_framework::networking::debug::network_debug_window;

pub fn game_plugin(game: &mut Game) {
game.sessions.create_with(SessionNames::DEBUG, |builder| {
builder
.install_plugin(session_plugin)
.install_plugin(frame_time_diagnostics_plugin);
});
game.sessions
.create_with(SessionNames::DEBUG, |builder: &mut SessionBuilder| {
builder
.install_plugin(session_plugin)
.install_plugin(frame_time_diagnostics_plugin);
});
}

fn session_plugin(session: &mut SessionBuilder) {
Expand Down
2 changes: 1 addition & 1 deletion src/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn update_fullscreen(game: &mut Game) {
let mut storage = storage.borrow_mut().unwrap();
let window = game.shared_resource_cell::<Window>().unwrap();
let mut window = window.borrow_mut().unwrap();
let keyboard = game.shared_resource::<KeyboardInputs>().unwrap();
let keyboard = game.shared_resource::<KeyboardInputs>();

let f11_pressed = keyboard
.key_events
Expand Down
Loading
Loading