mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
generalize lookingat
This commit is contained in:
parent
b8bbda4be8
commit
f3e8459968
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -41,13 +41,12 @@ impl ChunkStorage {
|
|||
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||
pub struct LookingAtBlock(pub Option<RaycastReport>);
|
||||
|
||||
pub fn update_player_raycast(
|
||||
main_player: View<MainPlayer>,
|
||||
pub fn update_raycasts(
|
||||
transform: View<Transform>,
|
||||
mut raycast: ViewMut<LookingAtBlock>,
|
||||
world: UniqueView<ChunkStorage>,
|
||||
) {
|
||||
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.)));
|
||||
|
|
Loading…
Reference in a new issue