/// If a MapActionChooser component is clicked,
/// the corresponding player's EntityPendingAction should be updated to Move, with is_ready=true
If a MapActionChooser component is clicked,
the corresponding player's EntityPendingAction should be updated to Move, with is_ready=true
If a MapActionChooser component is clicked the corresponding player ' s EntityPendingAction should be updated to Move with is_ready = true
pub fn select_player_move(
  mut commands: Commands,
  select_events: Query<&TilePos, (Added<SelectedTile>, Changed<SelectedTile>)>,
  select_markers: Query<(&MapActionChooser, &TilePos), With<PlayerMoveSelect>>,
  player: Query<(Entity, &MapEntityType), With<PlayerStatus>>,
) {
  for clicked_tile in select_events.iter() {
    for (act, marker_pos) in select_markers.iter() {
      if clicked_tile == marker_pos {
        let (player_entity, player_type) = player
          .iter()
          .find(|(_, t)| **t == MapEntityType::Player(act.player))
          .unwrap();
        if *player_type == MapEntityType::Player(act.player) {
          commands
            .entity(player_entity)
            .remove::<EntityPendingAction>();
          commands.entity(player_entity).insert(EntityPendingAction {
            action: EntityAction::Move((act.origin, clicked_tile.to_owned())),
            is_ready: true,
          });
        }
      }
    }
  }
}
pub fn select_player_move ( mut commands : Commands , select_events : Query < & TilePos , ( Added < SelectedTile > , Changed < SelectedTile > ) > , select_markers : Query < ( & MapActionChooser , & TilePos ) , With < PlayerMoveSelect > > , player : Query < ( Entity , & MapEntityType ) , With < PlayerStatus > > , ) { for clicked_tile in select_events . iter ( ) { for ( act , marker_pos ) in select_markers . iter ( ) { if clicked_tile == marker_pos { let ( player_entity , player_type ) = player . iter ( ) . find ( | ( _ , t ) | * * t == MapEntityType :: Player ( act . player ) ) . unwrap ( ) ; if * player_type == MapEntityType :: Player ( act . player ) { commands . entity ( player_entity ) . remove :: < EntityPendingAction > ( ) ; commands . entity ( player_entity ) . insert ( EntityPendingAction { action : EntityAction :: Move ( ( act . origin , clicked_tile . to_owned ( ) ) ) , is_ready : true , } ) ; } } } } }
If a MapActionChooser component is clicked,
the corresponding player's EntityPendingAction should be updated to Move, with is_ready=true
If a MapActionChooser component is clicked the corresponding player ' s EntityPendingAction should be updated to Move with is_ready = true
commands
Commands
select_events
Query<&TilePos, (Added<SelectedTile>, Changed<SelectedTile>)>
select_markers
Query<(&MapActionChooser, &TilePos), With<PlayerMoveSelect>>
player
Query<(Entity, &MapEntityType), With<PlayerStatus>>