def unit_action(self, cmd, pos, shift):
    """Return a `sc_pb.Action` filled with the cmd and appropriate target."""
    action = sc_pb.Action()
    if pos:
      action_spatial = pos.action_spatial(action)
      unit_command = action_spatial.unit_command
      unit_command.ability_id = cmd.ability_id
      unit_command.queue_command = shift
      if pos.surf.surf_type & SurfType.SCREEN:
        pos.obs_pos.assign_to(unit_command.target_screen_coord)
      elif pos.surf.surf_type & SurfType.MINIMAP:
        pos.obs_pos.assign_to(unit_command.target_minimap_coord)
    else:
      if self._feature_screen_px:
        action.action_feature_layer.unit_command.ability_id = cmd.ability_id
      else:
        action.action_render.unit_command.ability_id = cmd.ability_id

    self.clear_queued_action()
    return action
Return a `sc_pb.Action` filled with the cmd and appropriate target.