mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 06:48:43 -06:00
generalize lookingat
This commit is contained in:
parent
b8bbda4be8
commit
f3e8459968
|
@ -34,7 +34,7 @@ use rendering::{
|
||||||
use world::{
|
use world::{
|
||||||
init_game_world,
|
init_game_world,
|
||||||
loading::update_loaded_world_around_player,
|
loading::update_loaded_world_around_player,
|
||||||
raycast::update_player_raycast
|
raycast::update_raycasts
|
||||||
};
|
};
|
||||||
use player::spawn_player;
|
use player::spawn_player;
|
||||||
use prefabs::load_prefabs;
|
use prefabs::load_prefabs;
|
||||||
|
@ -64,7 +64,7 @@ fn update() -> Workload {
|
||||||
process_inputs,
|
process_inputs,
|
||||||
update_controllers,
|
update_controllers,
|
||||||
update_loaded_world_around_player,
|
update_loaded_world_around_player,
|
||||||
update_player_raycast,
|
update_raycasts,
|
||||||
compute_cameras
|
compute_cameras
|
||||||
).into_workload()
|
).into_workload()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,12 @@ impl ChunkStorage {
|
||||||
#[derive(Component, Clone, Copy, Debug, Default)]
|
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||||
pub struct LookingAtBlock(pub Option<RaycastReport>);
|
pub struct LookingAtBlock(pub Option<RaycastReport>);
|
||||||
|
|
||||||
pub fn update_player_raycast(
|
pub fn update_raycasts(
|
||||||
main_player: View<MainPlayer>,
|
|
||||||
transform: View<Transform>,
|
transform: View<Transform>,
|
||||||
mut raycast: ViewMut<LookingAtBlock>,
|
mut raycast: ViewMut<LookingAtBlock>,
|
||||||
world: UniqueView<ChunkStorage>,
|
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 (_, rotation, position) = transform.0.to_scale_rotation_translation();
|
||||||
let direction = rotation * Vec3::NEG_Z;
|
let direction = rotation * Vec3::NEG_Z;
|
||||||
*report = LookingAtBlock(world.raycast(position, direction, Some(30.)));
|
*report = LookingAtBlock(world.raycast(position, direction, Some(30.)));
|
||||||
|
|
Loading…
Reference in a new issue