-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture the Flag Example Using Entity Layers #426
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This diff fixes the entity visibility bug, but I'm not applying it here because it needs to be fixed in #424 . diffdiff --git a/examples/ctf.rs b/examples/ctf.rs
index 97c6a3f..6d88f7b 100644
--- a/examples/ctf.rs
+++ b/examples/ctf.rs
@@ -555,6 +555,7 @@ fn do_team_selector_portals(
&mut Client,
&mut VisibleEntityLayers,
&UniqueId,
+ Option<&JoiningTeam>,
),
Without<Team>,
>,
@@ -573,6 +574,7 @@ fn do_team_selector_portals(
mut client,
mut ent_layers,
unique_id,
+ joining,
) = player;
if pos.0.y < SPAWN_BOX[1] as f64 - 5.0 {
pos.0 = SPAWN_POS.into();
@@ -588,6 +590,13 @@ fn do_team_selector_portals(
};
if let Some(team) = team {
+ let main_layer = main_layers.single();
+ ent_layers.as_mut().0.remove(&main_layer);
+ if joining.is_none() {
+ commands.entity(player).insert(JoiningTeam);
+ return;
+ }
+
*game_mode = GameMode::Survival;
let mut inventory = Inventory::new(InventoryKind::Player);
inventory.set_slot(36, Some(ItemStack::new(ItemKind::WoodenSword, 1, None)));
@@ -617,8 +626,6 @@ fn do_team_selector_portals(
let chat_text: Text = "You are on team ".into_text() + team.team_text() + "!";
client.send_chat_message(chat_text);
- let main_layer = main_layers.single();
- ent_layers.as_mut().0.remove(&main_layer);
for t in Team::iter() {
let enemy_layer = ctf_layers.enemy_layers[&t];
if t == team {
@@ -650,10 +657,17 @@ fn do_team_selector_portals(
..Default::default()
});
player_enemy.insert(ClonedEntity(player));
+
+ commands.entity(player).remove::<JoiningTeam>();
}
}
}
+/// Used to delay spawning the cloned player by one tick.
+#[derive(Component)]
+#[component(storage = "SparseSet")]
+struct JoiningTeam;
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct TriggerArea {
pub a: BlockPos, |
rj00a
reviewed
Aug 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Created to test out the visibility layer API in #424
requires #424
Solution
Added a
ctf
example, where only the players on your team are glowing.Currently somewhat bugged.