From e717bac411183a7dd46fcd8fbd46bd27860bba81 Mon Sep 17 00:00:00 2001 From: dilyankostov <44360328+dilyankostov@users.noreply.github.com> Date: Sun, 26 Jun 2022 02:45:58 +0100 Subject: [PATCH 1/3] Fix player number in example game in the ecs_guide Currently, if there are 2 players in this example game, the function exclusive_player_system can add a player with the name "Player 2". However, the name should be "Player 3". This PR fixes this. I also add a message to inform that a new player has arrived in the mock game. --- examples/ecs/ecs_guide.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/ecs/ecs_guide.rs b/examples/ecs/ecs_guide.rs index 4bc0d527263ee..27cc8d72d2577 100644 --- a/examples/ecs/ecs_guide.rs +++ b/examples/ecs/ecs_guide.rs @@ -211,13 +211,14 @@ fn exclusive_player_system(world: &mut World) { }; // Randomly add a new player if should_add_player { + println!("An exclusive player {} has joined the game!", total_players + 1); world.spawn().insert_bundle(( Player { - name: format!("Player {}", total_players), + name: format!("Player {}", total_players + 1), }, Score { value: 0 }, )); - + let mut game_state = world.resource_mut::(); game_state.total_players += 1; } From f5f98a402df3a3c16c4ec6d01801174aca3f6e55 Mon Sep 17 00:00:00 2001 From: Dilyan <44360328+dilyankostov@users.noreply.github.com> Date: Sun, 26 Jun 2022 08:51:35 +0100 Subject: [PATCH 2/3] cargo fmt --all --- examples/ecs/ecs_guide.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/ecs/ecs_guide.rs b/examples/ecs/ecs_guide.rs index 27cc8d72d2577..a681f6c04cf4d 100644 --- a/examples/ecs/ecs_guide.rs +++ b/examples/ecs/ecs_guide.rs @@ -211,14 +211,17 @@ fn exclusive_player_system(world: &mut World) { }; // Randomly add a new player if should_add_player { - println!("An exclusive player {} has joined the game!", total_players + 1); + println!( + "An exclusive player {} has joined the game!", + total_players + 1 + ); world.spawn().insert_bundle(( Player { name: format!("Player {}", total_players + 1), }, Score { value: 0 }, )); - + let mut game_state = world.resource_mut::(); game_state.total_players += 1; } From 32c1f7bf7a7164473d607b252fff19fe7c1eabc1 Mon Sep 17 00:00:00 2001 From: Dilyan Kostov Date: Sun, 26 Jun 2022 11:26:41 +0100 Subject: [PATCH 3/3] Apply PR suggestion: Rename 'An exclusive player' to just 'Player' --- examples/ecs/ecs_guide.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/ecs/ecs_guide.rs b/examples/ecs/ecs_guide.rs index a681f6c04cf4d..60bda9a8e7e73 100644 --- a/examples/ecs/ecs_guide.rs +++ b/examples/ecs/ecs_guide.rs @@ -211,10 +211,7 @@ fn exclusive_player_system(world: &mut World) { }; // Randomly add a new player if should_add_player { - println!( - "An exclusive player {} has joined the game!", - total_players + 1 - ); + println!("Player {} has joined the game!", total_players + 1); world.spawn().insert_bundle(( Player { name: format!("Player {}", total_players + 1),