Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nested entities to be interaction targets #298

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/world_interaction/.interactions_ui.rs.swp
Binary file not shown.
14 changes: 7 additions & 7 deletions src/world_interaction/interactions_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ pub(crate) struct InteractionOpportunity(pub(crate) Option<Entity>);
#[sysfail(Log<anyhow::Error, Error>)]
fn update_interaction_opportunities(
mut collisions: EventReader<Collision>,
player_query: Query<&Transform, With<Player>>,
player_query: Query<&GlobalTransform, With<Player>>,
parents: Query<&Parent>,
target_query: Query<
(Entity, &Transform),
(Entity, &GlobalTransform),
(With<DialogTarget>, Without<Player>, Without<IngameCamera>),
>,
camera_query: Query<(&IngameCamera, &Transform), Without<Player>>,
camera_query: Query<(&IngameCamera, &GlobalTransform), Without<Player>>,
mut interaction_opportunity: ResMut<InteractionOpportunity>,
) {
interaction_opportunity.0 = None;
Expand Down Expand Up @@ -79,14 +79,14 @@ fn update_interaction_opportunities(
}

// Check if we are facing the right way
let player_translation = player_query.get(player).unwrap().translation;
let player_translation = player_query.get(player).unwrap().translation();
let Some((camera, camera_transform)) = camera_query.iter().next() else {
continue;
};
let is_facing_target = is_facing_target(
player_translation,
target_transform.translation,
*camera_transform,
target_transform.translation(),
camera_transform.compute_transform(),
camera,
);
if is_facing_target {
Expand All @@ -96,7 +96,7 @@ fn update_interaction_opportunities(
}

fn get_player_and_target(
player_query: &Query<&Transform, With<Player>>,
player_query: &Query<&GlobalTransform, With<Player>>,
entity_a: Entity,
entity_b: Entity,
) -> Option<(Entity, Entity)> {
Expand Down