Skip to content

Commit

Permalink
Updated to bevy_dolly crate and bevy 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackPhlox committed Sep 17, 2023
1 parent 9df6d01 commit 11bf9b6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ name = "bevy_config_cam"

[dependencies]
rand = "0.8"
strum = "0.24"
strum_macros = "0.24"
bevy_dolly = { git = "https://github.com/BlackPhlox/bevy_dolly", branch = "map_fork_v2" }#{ path = "../bevy_dolly" }
strum = "0.25"
strum_macros = "0.25"
bevy_dolly = "0.0.1"
config_cam_derive = { path = "config_cam_derive" }

[dependencies.bevy]
version = "0.10"
version = "0.11"
features = ["bevy_render","bevy_pbr"]
default-features = false

[dev-dependencies.bevy]
version = "0.10"
version = "0.11"
features = ["bevy_core_pipeline", "bevy_asset", "bevy_scene", "bevy_pbr", "bevy_gltf", "x11", "wayland"]
default-features = false
4 changes: 2 additions & 2 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use bevy_config_cam::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(ConfigCam)
.add_startup_system(setup)
.add_plugins(ConfigCam)
.add_systems(Startup, setup)
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions src/drivers/fpv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn update_fpv_camera(
move_vec.y -= 1.0;
}

let boost: f32 = if keys.pressed(KeyCode::LShift) {
let boost: f32 = if keys.pressed(KeyCode::ShiftLeft) {
1.
} else {
0.
Expand All @@ -104,13 +104,13 @@ pub fn update_fpv_camera(
move_vec,
boost,
boost_mult,
fps_state.0.eq(&MovementType::FirstPerson),
fps_state.get().eq(&MovementType::FirstPerson),
);

if let Ok(window) = windows.get_single() {
if !window.cursor.visible {
if let Some(fpv) = r.try_driver_mut::<Fpv>() {
fpv.set_rotation(delta, sensitivity, move_vec, time_delta_seconds);
fpv.set_rotation(delta, move_vec, time_delta_seconds);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/orbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ fn update_orbit_camera(
delta += event.delta;
}

config.rotation = Quat::from_rotation_y(delta.x);
config.transform.rotation = Quat::from_rotation_y(delta.x);

if pan.0.eq(&Pan::Keys) {
if pan.get().eq(&Pan::Keys) {
if keys.just_pressed(KeyCode::Z) {
camera_driver.rotate_yaw_pitch(-90.0, 0.0);
}
Expand All @@ -95,12 +95,12 @@ fn update_orbit_camera(
}

if keys.just_pressed(KeyCode::E) {
let result = if pan.0.eq(&Pan::Keys) {
let result = if pan.get().eq(&Pan::Keys) {
Pan::Mouse
} else {
Pan::Keys
};
pan.0 = result;
*pan = State::new(result);
println!("State:{result:?}");
}

Expand Down
29 changes: 15 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pub mod drivers;
use bevy::{
prelude::{
default, App, Camera, Commands, Component,
IntoSystemConfig, OrthographicProjection, Plugin, Query, Res, Resource, SystemSet,
Transform, Vec3, With, Camera3dBundle, Camera2dBundle,
OrthographicProjection, Plugin, Query, Res, Resource, SystemSet,
Transform, Vec3, With, Camera3dBundle, Camera2dBundle, Update, Startup, IntoSystemConfigs,
},
render::camera::ScalingMode,
};
Expand All @@ -24,18 +24,18 @@ impl Plugin for ConfigCam {
fn build(&self, app: &mut App) {
app.init_resource::<Drivers>()
.init_resource::<CCConfig>()
.add_plugin(DollyPosCtrl)
.add_plugin(DollyCursorGrab)
.add_plugins(DollyPosCtrl)
.add_plugins(DollyCursorGrab)
.insert_resource(DollyPosCtrlConfig {
default_player: false,
player: Player::None,
..Default::default()
})
.add_startup_system(camera_setup.in_set(CCSetupLabel))
.add_plugin(CCFpv)
.add_plugin(CCOrbit)
.add_system(change_driver_system)
.add_system(update_driver_system)
.add_system(update_look_at);
.add_systems(Startup, camera_setup.run_if(is_init_cameras).in_set(CCSetupLabel))
.add_plugins(CCFpv)
.add_plugins(CCOrbit)
.add_systems(Update, change_driver_system)
.add_systems(Update, update_driver_system)
.add_systems(Update, update_look_at);
}
}

Expand Down Expand Up @@ -80,10 +80,11 @@ impl Default for CCConfig {
}
}

fn is_init_cameras(config: Res<CCConfig>) -> bool {
config.init_cameras
}

fn camera_setup(mut commands: Commands, config: Res<CCConfig>) {
if !config.init_cameras {
return;
}
commands.spawn((
MainCamera,
PerspectiveCamera,
Expand Down

0 comments on commit 11bf9b6

Please sign in to comment.