use super::Boid; use bevy::prelude::*; pub(crate) fn boid_border_teleport( mut boids: Query<&mut Transform, With>, windows: Query<&Window>, ) { let window = windows.get_single().unwrap(); let width = window.resolution.width(); let height = window.resolution.height(); let half_width = width / 2.; let half_height = height / 2.; const PADDING: f32 = 50.; let left_bound = -half_width - PADDING; let right_bound = half_width + PADDING; let top_bound = half_height + PADDING; let bottom_bound = -half_height - PADDING; for mut boid_transform in &mut boids { let translation = &mut boid_transform.translation; if translation.y > top_bound { translation.y = bottom_bound; } if translation.y < bottom_bound { translation.y = top_bound; } if translation.x < left_bound { translation.x = right_bound; } if translation.x > right_bound { translation.x = left_bound; } } }