|
|
|
@ -493,21 +493,19 @@ fn select(
|
|
|
|
hit::intersects3d(&ray, mesh, >).and_then(|_hit| {
|
|
|
|
hit::intersects3d(&ray, mesh, >).and_then(|_hit| {
|
|
|
|
selectable
|
|
|
|
selectable
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.find(|&parent| {
|
|
|
|
.find(|&e| {
|
|
|
|
children
|
|
|
|
// A child was hit (pieces)
|
|
|
|
.iter_descendants(parent)
|
|
|
|
let primary = entity == e;
|
|
|
|
.any(|child| child == entity)
|
|
|
|
// This entity was hit (tile hitboxes)
|
|
|
|
|
|
|
|
let secondary = children
|
|
|
|
|
|
|
|
.iter_descendants(e)
|
|
|
|
|
|
|
|
.any(|child| child == entity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
primary || secondary
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.for_each(|&parent| {
|
|
|
|
.for_each(|&e| {
|
|
|
|
selected.iter().for_each(|s| {
|
|
|
|
commands.entity(e).insert(game::Selected);
|
|
|
|
if s != parent {
|
|
|
|
|
|
|
|
commands
|
|
|
|
|
|
|
|
.entity(s)
|
|
|
|
|
|
|
|
.remove::<game::Selected>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
commands.entity(parent).insert(game::Selected);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Some(())
|
|
|
|
Some(())
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|