Skip to content

Commit

Permalink
dev: updated bevy_mod_picking version
Browse files Browse the repository at this point in the history
  • Loading branch information
roboteng committed Nov 4, 2023
1 parent 97018d7 commit dd8f225
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 53 deletions.
123 changes: 88 additions & 35 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ members = [
"game",
"server",
]
default-members = ["game", "ci"]
2 changes: 1 addition & 1 deletion game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
[dependencies]
bevy = "0.11.3"
bevy-ui-dsl = "0.6.1"
bevy_mod_picking = "0.15.0"
bevy_mod_picking = "0.16.0"
41 changes: 25 additions & 16 deletions game/src/in_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl Plugin for InGamePlugin {
fn build(&self, app: &mut App) {
app.add_plugins(DefaultPickingPlugins)
.add_systems(OnEnter(GameState::InGame), (setup, draw_hud))
.add_systems(Update, apply_seelected);
.add_systems(Update, (apply_seelected, click_on_ground));
}
}

Expand All @@ -18,15 +18,12 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
{
let mut camera = Camera3dBundle::default();
camera.camera.order = 0;
camera.transform = Transform::from_xyz(8.0, 8.0, 7.0).looking_at(Vec3::ZERO, Vec3::Y);
camera
},
RaycastPickCamera::default(),
));
commands.spawn(({
let mut camera = Camera3dBundle::default();
camera.camera.order = 0;
camera.transform = Transform::from_xyz(8.0, 8.0, 7.0).looking_at(Vec3::ZERO, Vec3::Y);
camera
},));

commands.spawn(PointLightBundle {
point_light: PointLight {
Expand All @@ -47,11 +44,14 @@ fn setup(
);
let material = materials.add(Color::ALICE_BLUE.into());

commands.spawn(PbrBundle {
mesh,
material,
..Default::default()
});
commands.spawn((
PbrBundle {
mesh,
material,
..Default::default()
},
Ground,
));

let box_mesh = meshes.add(shape::Box::new(0.8, 1.0, 0.8).into());
let box_material = materials.add(Color::SEA_GREEN.into());
Expand All @@ -65,7 +65,6 @@ fn setup(
..Default::default()
},
PickableBundle::default(),
RaycastPickTarget::default(),
Health {
max: 5.0,
current: (i + 2) as f32,
Expand Down Expand Up @@ -103,6 +102,9 @@ fn draw_hud(mut commands: Commands, asset_server: Res<AssetServer>) {
#[derive(Component)]
struct Hud;

#[derive(Component)]
struct Ground;

#[derive(Component)]
struct HealthVis;

Expand Down Expand Up @@ -133,3 +135,10 @@ fn apply_seelected(
}
}
}

fn click_on_ground(ev: EventReader<Pointer<Click>>) {
let len = ev.len();
if len != 0 {
println!("event len: {len}",);
}
}

0 comments on commit dd8f225

Please sign in to comment.