Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bevy 0.12 #401

Closed
Closed
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ egui = ['dep:bevy_egui']

[dependencies]
leafwing_input_manager_macros = { path = "macros", version = "0.9" }
bevy = { version = "0.11", default-features = false, features = [
bevy = { version = "0.12", default-features = false, features = [
"serialize",
"bevy_gilrs",
] }
bevy_egui = { version = "0.22", optional = true }
bevy_egui = { git = "https://github.com/raffaeleragni/bevy_egui.git", rev = "8ce18a1", optional = true }

petitset = { version = "0.2.1", features = ["serde_compat"] }
derive_more = { version = "0.99", default-features = false, features = [
Expand All @@ -43,8 +43,8 @@ fixedbitset = "0.4.2"
once_cell = "1.17.1"

[dev-dependencies]
bevy_egui = { version = "0.22" }
bevy = { version = "0.11", default-features = false, features = [
bevy_egui = { git = "https://github.com/raffaeleragni/bevy_egui.git", rev = "8ce18a1" }
bevy = { version = "0.12", default-features = false, features = [
"bevy_asset",
"bevy_sprite",
"bevy_text",
Expand Down
6 changes: 3 additions & 3 deletions examples/binding_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ struct InputEvents<'w, 's> {

impl InputEvents<'_, '_> {
fn input_button(&mut self) -> Option<InputKind> {
if let Some(keyboard_input) = self.keys.iter().next() {
if let Some(keyboard_input) = self.keys.read().next() {
if keyboard_input.state == ButtonState::Released {
if let Some(key_code) = keyboard_input.key_code {
return Some(key_code.into());
}
}
}
if let Some(mouse_input) = self.mouse_buttons.iter().next() {
if let Some(mouse_input) = self.mouse_buttons.read().next() {
if mouse_input.state == ButtonState::Released {
return Some(mouse_input.button.into());
}
Expand All @@ -280,7 +280,7 @@ impl InputEvents<'_, '_> {
gamepad: _,
button_type,
value: strength,
})) = self.gamepad_events.iter().next()
})) = self.gamepad_events.read().next()
{
if *strength <= 0.5 {
return Some((*button_type).into());
Expand Down
2 changes: 1 addition & 1 deletion examples/send_actions_over_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn send_events<A: Send + Sync + 'static + Debug + Clone + Event>(
let mut reader = reader.unwrap_or_else(|| client_events.get_reader());

// Push the clients' events to the server
for client_event in reader.iter(client_events) {
for client_event in reader.read(client_events) {
dbg!(client_event.clone());
server_events.send(client_event.clone());
}
Expand Down
8 changes: 4 additions & 4 deletions src/input_streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'a> InputStreams<'a> {
// PERF: this summing is computed for every individual input
// This should probably be computed once, and then cached / read
// Fix upstream!
for mouse_wheel_event in event_reader.iter(mouse_wheel) {
for mouse_wheel_event in event_reader.read(mouse_wheel) {
total_mouse_wheel_movement += match mouse_wheel_direction {
MouseWheelDirection::Up | MouseWheelDirection::Down => mouse_wheel_event.y,
MouseWheelDirection::Left | MouseWheelDirection::Right => {
Expand All @@ -203,7 +203,7 @@ impl<'a> InputStreams<'a> {
// FIXME: verify that this works and doesn't double count events
let mut event_reader = self.mouse_motion.get_reader();

for mouse_motion_event in event_reader.iter(self.mouse_motion) {
for mouse_motion_event in event_reader.read(self.mouse_motion) {
total_mouse_movement += match mouse_motion_direction {
MouseMotionDirection::Up | MouseMotionDirection::Down => {
mouse_motion_event.delta.y
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<'a> InputStreams<'a> {
// FIXME: verify that this works and doesn't double count events
let mut event_reader = mouse_wheel.get_reader();

for mouse_wheel_event in event_reader.iter(mouse_wheel) {
for mouse_wheel_event in event_reader.read(mouse_wheel) {
total_mouse_wheel_movement += match axis_type {
MouseWheelAxisType::X => mouse_wheel_event.x,
MouseWheelAxisType::Y => mouse_wheel_event.y,
Expand All @@ -323,7 +323,7 @@ impl<'a> InputStreams<'a> {
// FIXME: verify that this works and doesn't double count events
let mut event_reader = self.mouse_motion.get_reader();

for mouse_wheel_event in event_reader.iter(self.mouse_motion) {
for mouse_wheel_event in event_reader.read(self.mouse_motion) {
total_mouse_motion_movement += match axis_type {
MouseMotionAxisType::X => mouse_wheel_event.delta.x,
MouseMotionAxisType::Y => mouse_wheel_event.delta.y,
Expand Down
8 changes: 4 additions & 4 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ impl<A: Actionlike> Plugin for InputManagerPlugin<A> {
update_action_state::<A>.in_set(InputManagerSystem::Update),
);

app.configure_set(
app.configure_sets(
PreUpdate,
InputManagerSystem::Update
.run_if(run_if_enabled::<A>)
.after(InputSystem),
);

#[cfg(feature = "egui")]
app.configure_set(
app.configure_sets(
PreUpdate,
InputManagerSystem::Update.after(bevy_egui::EguiSet::ProcessInput),
);

#[cfg(feature = "ui")]
app.configure_set(PreUpdate, InputManagerSystem::Update.after(UiSystem::Focus));
app.configure_sets(PreUpdate, InputManagerSystem::Update.after(UiSystem::Focus));

#[cfg(feature = "ui")]
app.configure_set(
app.configure_sets(
PreUpdate,
InputManagerSystem::ManualControl
.run_if(run_if_enabled::<A>)
Expand Down
21 changes: 12 additions & 9 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ use crate::{
Actionlike,
};

use bevy::input::{
gamepad::{GamepadAxis, GamepadButton, Gamepads},
keyboard::KeyCode,
mouse::{MouseButton, MouseMotion, MouseWheel},
Axis, Input,
};
use bevy::time::Time;
use bevy::utils::Instant;
use bevy::{ecs::prelude::*, prelude::ScanCode};
use bevy::{
input::{
gamepad::{GamepadAxis, GamepadButton, Gamepads},
keyboard::KeyCode,
mouse::{MouseButton, MouseMotion, MouseWheel},
Axis, Input,
},
time::Real,
};

#[cfg(feature = "ui")]
use bevy::ui::Interaction;
Expand All @@ -34,7 +37,7 @@ use bevy_egui::EguiContexts;
pub fn tick_action_state<A: Actionlike>(
mut query: Query<&mut ActionState<A>>,
action_state: Option<ResMut<ActionState<A>>>,
time: Res<Time>,
time: Res<Time<Real>>,
mut stored_previous_instant: Local<Option<Instant>>,
) {
// If this is the very first tick, measure from the start of the app
Expand Down Expand Up @@ -215,7 +218,7 @@ pub fn process_action_diffs<A: Actionlike, ID: Eq + Component + Clone>(
mut action_diffs: EventReader<ActionDiff<A, ID>>,
) {
// PERF: This would probably be faster with an index, but is much more fussy
for action_diff in action_diffs.iter() {
for action_diff in action_diffs.read() {
for (mut action_state, id) in action_state_query.iter_mut() {
match action_diff {
ActionDiff::Pressed {
Expand Down Expand Up @@ -269,7 +272,7 @@ pub fn release_on_input_map_removed<A: Actionlike>(
mut input_map_resource_existed: Local<bool>,
mut action_state_query: Query<&mut ActionState<A>>,
) {
let mut iter = action_state_query.iter_many_mut(removed_components.iter());
let mut iter = action_state_query.iter_many_mut(removed_components.read());
while let Some(mut action_state) = iter.fetch_next() {
action_state.release_all();
}
Expand Down
Loading