private IEnumerator CoWall() { int targetType = (int)KnownVoxelTypes.Ground; int playerIndex = m_gameState.LocalToPlayerIndex(m_localPlayerIndex); long[] selectedUnitIds = m_unitSelection.GetSelection(playerIndex, playerIndex); Guid assignmentGroup = Guid.NewGuid(); ITaskEngine taskEngine = m_engine.GetClientTaskEngine(playerIndex); for (int i = 0; i < selectedUnitIds.Length; ++i) { long unitId = selectedUnitIds[i]; IMatchUnitAssetView unit = m_gameState.GetPlayerView(playerIndex).GetUnitOrAsset(unitId); if (unit == null || !unit.IsAlive) { continue; } bool nextLocationPicked = false; Coordinate coordinate = new Coordinate(); LocationPickerArgs.PickStatus status = LocationPickerArgs.PickStatus.Cancelled; m_locationPicker.PickLocationToConvert(unit.Data, targetType, pickedArgs => { coordinate = pickedArgs.Coordinate; status = pickedArgs.Status; nextLocationPicked = true; }); while (!nextLocationPicked) { yield return(new WaitForEndOfFrame()); } if (status == LocationPickerArgs.PickStatus.Cancelled) { yield break; } if (status == LocationPickerArgs.PickStatus.Failed) { i--; continue; } TaskInfo taskInfo = m_playersBot.SubmitAssignment(Time.realtimeSinceStartup, assignmentGroup, unit, targetType | (int)KnownVoxelTypes.Preview, coordinate, TaskTemplateType.ConvertTo, TaskInfo.DefineConvertCmd(targetType), TaskInfo.DefineCanConvertExpr(targetType), TaskInfo.Define(coordinate) ); while (taskEngine.IsTaskActive(taskInfo.TaskId)) { yield return(new WaitForEndOfFrame()); } if (taskInfo.IsFailed) { i--; continue; } m_locationPicker.EndPickLocation(); } }