pub fn update_player_action(
  mut commands: Commands,
  mut new_actions: EventReader<PlayerActionChosen>,
) {
  for PlayerActionChosen {
    action_type: new_action,
    player,
  } in new_actions.iter()
  {
    commands.entity(*player).remove::<EntityPendingAction>();
    commands.entity(*player).insert(new_action.to_owned());
  }
}
/// The UI sends PlayerActionChosen events when an action is added, removed, or updated
/// Here, we set the proper EntityPendingAction on the player entity
The UI sends PlayerActionChosen events when an action is added, removed, or updated
Here, we set the proper EntityPendingAction on the player entity
The UI sends PlayerActionChosen events when an action is added removed or updated Here we set the proper EntityPendingAction on the player entity
pub fn update_player_action(
  mut commands: Commands,
  mut new_actions: EventReader<PlayerActionChosen>,
) {
  for PlayerActionChosen {
    action_type: new_action,
    player,
  } in new_actions.iter()
  {
    commands.entity(*player).remove::<EntityPendingAction>();
    commands.entity(*player).insert(new_action.to_owned());
  }
}
pub fn update_player_action ( mut commands : Commands , mut new_actions : EventReader < PlayerActionChosen > , ) { for PlayerActionChosen { action_type : new_action , player , } in new_actions . iter ( ) { commands . entity ( * player ) . remove :: < EntityPendingAction > ( ) ; commands . entity ( * player ) . insert ( new_action . to_owned ( ) ) ; } }
The UI sends PlayerActionChosen events when an action is added, removed, or updated
Here, we set the proper EntityPendingAction on the player entity
The UI sends PlayerActionChosen events when an action is added removed or updated Here we set the proper EntityPendingAction on the player entity
commands
Commands
new_actions
EventReader<PlayerActionChosen>
commands
Commands
new_actions
EventReader<PlayerActionChosen>