Bevy 0.16 upgrade (#24)
This commit is contained in:
@@ -102,9 +102,12 @@ fn spawn(
|
||||
));
|
||||
}
|
||||
|
||||
fn cursor_recenter(mut q_windows: Query<&mut Window, With<PrimaryWindow>>) {
|
||||
let mut primary_window = q_windows.single_mut();
|
||||
let center = Vec2::new(primary_window.width() / 2.0, primary_window.height() / 2.0);
|
||||
fn cursor_recenter(q_windows: Single<&mut Window, With<PrimaryWindow>>) {
|
||||
let mut primary_window = q_windows;
|
||||
let center = Vec2::new(
|
||||
primary_window.resolution.width() / 2.,
|
||||
primary_window.resolution.height() / 2.,
|
||||
);
|
||||
primary_window.set_cursor_position(Some(center));
|
||||
}
|
||||
|
||||
@@ -121,12 +124,8 @@ fn toggle_grab_cursor(window: &mut Window) {
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_cursor_system(mut primary_window: Query<&mut Window, With<PrimaryWindow>>) {
|
||||
if let Ok(mut window) = primary_window.get_single_mut() {
|
||||
toggle_grab_cursor(&mut window);
|
||||
} else {
|
||||
warn!("Primary window not found for `toggle_cursor_system`!");
|
||||
}
|
||||
fn toggle_cursor_system(mut window: Single<&mut Window, With<PrimaryWindow>>) {
|
||||
toggle_grab_cursor(&mut window);
|
||||
}
|
||||
|
||||
fn collect_cash(
|
||||
@@ -154,11 +153,11 @@ fn collect_cash(
|
||||
fn setup_animations_marker_for_player(
|
||||
mut commands: Commands,
|
||||
animation_handles: Query<Entity, Added<AnimationGraphHandle>>,
|
||||
parent_query: Query<&Parent>,
|
||||
children: Query<&ChildOf>,
|
||||
player: Query<&PlayerBodyMesh>,
|
||||
) {
|
||||
for entity in animation_handles.iter() {
|
||||
for ancestor in parent_query.iter_ancestors(entity) {
|
||||
for ancestor in children.iter_ancestors(entity) {
|
||||
if player.contains(ancestor) {
|
||||
commands.entity(entity).insert(PlayerAnimations);
|
||||
return;
|
||||
@@ -196,18 +195,12 @@ fn toggle_animation(
|
||||
fn on_update_head(
|
||||
trigger: Trigger<HeadChanged>,
|
||||
mut commands: Commands,
|
||||
body_mesh: Query<Entity, With<PlayerBodyMesh>>,
|
||||
mut player_head: Query<&mut ActiveHead, With<Player>>,
|
||||
body_mesh: Single<Entity, With<PlayerBodyMesh>>,
|
||||
mut player: Single<&mut ActiveHead, With<Player>>,
|
||||
head_db: Res<HeadsDatabase>,
|
||||
audio_assets: Res<AudioAssets>,
|
||||
) {
|
||||
let Ok(body_mesh) = body_mesh.get_single() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(mut player) = player_head.get_single_mut() else {
|
||||
return;
|
||||
};
|
||||
let body_mesh = *body_mesh;
|
||||
|
||||
player.0 = trigger.0;
|
||||
|
||||
@@ -215,7 +208,7 @@ fn on_update_head(
|
||||
|
||||
commands.trigger(PlaySound::Head(head_str.to_string()));
|
||||
|
||||
commands.entity(body_mesh).despawn_descendants();
|
||||
commands.entity(body_mesh).despawn_related::<Children>();
|
||||
|
||||
commands
|
||||
.entity(body_mesh)
|
||||
|
||||
Reference in New Issue
Block a user