Add names to entities

This commit is contained in:
Michael Bradley 2025-05-22 23:03:32 -04:00
parent 2df3f0262b
commit bef0b66ee1
Signed by: MichaelBradley
SSH key fingerprint: SHA256:o/aaeYtRubILK7OYYjYP12DmU7BsPUhKji1AgaQ+ge4

View file

@ -50,6 +50,7 @@ pub fn setup_player(
) { ) {
let circle = Circle::new(radius.0); let circle = Circle::new(radius.0);
commands.spawn(( commands.spawn((
Name::new("Player"),
Player, Player,
Collider::from(circle), Collider::from(circle),
Mesh2d(meshes.add(circle)), Mesh2d(meshes.add(circle)),
@ -65,9 +66,10 @@ pub fn setup_balls(
region: Res<PlayableArea>, region: Res<PlayableArea>,
) { ) {
let mut random = thread_rng(); let mut random = thread_rng();
for _ in 0..BALL_COUNT { for i in 0..BALL_COUNT {
let circle = Circle::new(random.random_range(BALL_SIZES)); let circle = Circle::new(random.random_range(BALL_SIZES));
commands.spawn(( commands.spawn((
Name::new(format!("Ball[{i}]")),
Ball, Ball,
Collider::from(circle), Collider::from(circle),
Mesh2d(meshes.add(circle)), Mesh2d(meshes.add(circle)),
@ -104,6 +106,7 @@ pub fn setup_walls(
); );
commands.spawn(( commands.spawn((
Name::new(format!("Wall[{i}]")),
Wall, Wall,
Collider::rectangle(length, thickness), Collider::rectangle(length, thickness),
Mesh2d(meshes.add(Rectangle::new(length, thickness))), Mesh2d(meshes.add(Rectangle::new(length, thickness))),