// If the other player has associated action choosers,
// we should despawn the old ones, or it will get confusing.
If the other player has associated action choosers,
we should despawn the old ones, or it will get confusing.
If the other player has associated action choosers we should despawn the old ones or it will get confusing .
pub fn despawn_action_choosers(
  mut commands: Commands,
  players: Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>,
  choosers: Query<(Entity, &MapActionChooser)>,
) {
  for (player_pos, player_pending_action) in players.iter() {
    if player_pending_action.is_wait() || player_pending_action.is_ready {
      for (chooser_entity, chooser_origin) in choosers.iter() {
        if *player_pos == chooser_origin.origin {
          commands.entity(chooser_entity).despawn_recursive();
        }
      }
    }
  }
}
pub fn despawn_action_choosers ( mut commands : Commands , players : Query < ( & TilePos , & EntityPendingAction ) , With < PlayerStatus > > , choosers : Query < ( Entity , & MapActionChooser ) > , ) { for ( player_pos , player_pending_action ) in players . iter ( ) { if player_pending_action . is_wait ( ) || player_pending_action . is_ready { for ( chooser_entity , chooser_origin ) in choosers . iter ( ) { if * player_pos == chooser_origin . origin { commands . entity ( chooser_entity ) . despawn_recursive ( ) ; } } } } }
If the other player has associated action choosers,
we should despawn the old ones, or it will get confusing.
If the other player has associated action choosers we should despawn the old ones or it will get confusing .
commands
Commands
players
Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>
choosers
Query<(Entity, &MapActionChooser)>