Проектная работа - WIP
This commit is contained in:
@@ -119,3 +119,24 @@ pub fn check_bounds_colisions(head: Single<(&Transform,), (With<Head>,)>, mut co
|
||||
commands.trigger(Collision::Bounds);
|
||||
};
|
||||
}
|
||||
|
||||
/// Система отслеживания столкновений c хвостом
|
||||
pub fn check_tail_colisions(
|
||||
head: Single<(&Transform, Entity), (With<Head>,)>,
|
||||
query: Query<(&Transform, &Velocity, &Tail)>,
|
||||
mut commands: Commands, //
|
||||
) {
|
||||
let (head_transform, head_entity) = head.into_inner();
|
||||
for (tail_transform, velocity, tail) in query.into_iter() {
|
||||
if velocity.0 == 0.0 || tail.0 == head_entity {
|
||||
continue;
|
||||
}
|
||||
let distance = head_transform.translation.distance(tail_transform.translation);
|
||||
if distance < GRID_SIZE as f32 {
|
||||
commands.trigger(Collision::Tail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Система отслеживания столкновений с едой
|
||||
pub fn check_meal_collisions() {}
|
||||
|
||||
Reference in New Issue
Block a user