pub fn remove_action_arrows(
  mut commands: Commands,
  player_q: Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>,
  arrow_q: Query<(Entity, &TilePos), With<ActionIndicationMarker>>,
  turn_q: Query<&TurnDisplayer>,
) {
  // If a turn is animating, despawn the arrows
  if !turn_q.is_empty() {
    for (e, _) in arrow_q.iter() {
      commands.entity(e).despawn_recursive();
    }
    return;
  }
  for (player_pos, player_pending_action) in player_q.iter() {
    if !(player_pending_action.is_move() || player_pending_action.is_attack())
      || !player_pending_action.is_ready
    {
      arrow_q
        .iter()
        .filter(|pos| pos.1 == player_pos)
        .for_each(|(e, _)| {
          commands.entity(e).despawn_recursive();
        })
    }
  }
}
/// Remove the action indicator arrows when they are no longer needed:
/// the player is choosing a different action, or the turn is animating
Remove the action indicator arrows when they are no longer needed:
the player is choosing a different action, or the turn is animating
Remove the action indicator arrows when they are no longer needed : the player is choosing a different action or the turn is animating
pub fn remove_action_arrows(
  mut commands: Commands,
  player_q: Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>,
  arrow_q: Query<(Entity, &TilePos), With<ActionIndicationMarker>>,
  turn_q: Query<&TurnDisplayer>,
) {
  // If a turn is animating, despawn the arrows
  if !turn_q.is_empty() {
    for (e, _) in arrow_q.iter() {
      commands.entity(e).despawn_recursive();
    }
    return;
  }
  for (player_pos, player_pending_action) in player_q.iter() {
    if !(player_pending_action.is_move() || player_pending_action.is_attack())
      || !player_pending_action.is_ready
    {
      arrow_q
        .iter()
        .filter(|pos| pos.1 == player_pos)
        .for_each(|(e, _)| {
          commands.entity(e).despawn_recursive();
        })
    }
  }
}
pub fn remove_action_arrows ( mut commands : Commands , player_q : Query < ( & TilePos , & EntityPendingAction ) , With < PlayerStatus > > , arrow_q : Query < ( Entity , & TilePos ) , With < ActionIndicationMarker > > , turn_q : Query < & TurnDisplayer > , ) { // If a turn is animating, despawn the arrows if ! turn_q . is_empty ( ) { for ( e , _ ) in arrow_q . iter ( ) { commands . entity ( e ) . despawn_recursive ( ) ; } return ; } for ( player_pos , player_pending_action ) in player_q . iter ( ) { if ! ( player_pending_action . is_move ( ) || player_pending_action . is_attack ( ) ) || ! player_pending_action . is_ready { arrow_q . iter ( ) . filter ( | pos | pos . 1 == player_pos ) . for_each ( | ( e , _ ) | { commands . entity ( e ) . despawn_recursive ( ) ; } ) } } }
Remove the action indicator arrows when they are no longer needed:
the player is choosing a different action, or the turn is animating
Remove the action indicator arrows when they are no longer needed : the player is choosing a different action or the turn is animating
commands
Commands
player_q
Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>
arrow_q
Query<(Entity, &TilePos), With<ActionIndicationMarker>>
turn_q
Query<&TurnDisplayer>
commands
Commands
player_q
Query<(&TilePos, &EntityPendingAction), With<PlayerStatus>>
arrow_q
Query<(Entity, &TilePos), With<ActionIndicationMarker>>
turn_q
Query<&TurnDisplayer>