From f3e84599684e782ce636931f2c3271e6e5a786f1 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sat, 28 Jan 2023 21:37:00 +0100 Subject: [PATCH] generalize lookingat --- src/main.rs | 4 ++-- src/world/raycast.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7bfbd13..8d0edd9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,7 @@ use rendering::{ use world::{ init_game_world, loading::update_loaded_world_around_player, - raycast::update_player_raycast + raycast::update_raycasts }; use player::spawn_player; use prefabs::load_prefabs; @@ -64,7 +64,7 @@ fn update() -> Workload { process_inputs, update_controllers, update_loaded_world_around_player, - update_player_raycast, + update_raycasts, compute_cameras ).into_workload() } diff --git a/src/world/raycast.rs b/src/world/raycast.rs index c55e087..fb705ef 100644 --- a/src/world/raycast.rs +++ b/src/world/raycast.rs @@ -41,13 +41,12 @@ impl ChunkStorage { #[derive(Component, Clone, Copy, Debug, Default)] pub struct LookingAtBlock(pub Option); -pub fn update_player_raycast( - main_player: View, +pub fn update_raycasts( transform: View, mut raycast: ViewMut, world: UniqueView, ) { - for (_, transform, report) in (&main_player, transform.inserted_or_modified(), &mut raycast).iter() { + for (transform, report) in (transform.inserted_or_modified(), &mut raycast).iter() { let (_, rotation, position) = transform.0.to_scale_rotation_translation(); let direction = rotation * Vec3::NEG_Z; *report = LookingAtBlock(world.raycast(position, direction, Some(30.)));