ResourceTileSelection.ToArray C# (CSharp) Method

ToArray() public method

Converts to an array.
public ToArray ( ) : int[]
return int[]
	public int[] ToArray()
	{
		return this.resource_tile_ids.ToArray();
	}
	/// <summary>

Usage Example

	/// <summary>
	/// Submits the resource tile selection to server API.
	/// </summary>
	/// <remarks>
	/// This differs from the base implementation because the API returns timber values, not modified resource tiles
	/// </remarks>
	/// <returns>
	/// The resource tile selection to server API.
	/// </returns>
	/// <param name='selection'>
	/// The resource tile selection.
	/// </param>
	protected override IEnumerator SubmitResourceTileSelectionToServerAPI(ResourceTileSelection selection)
	{
		//HACK -- HACK -- HACK -- HACK
		/*selection = FilterSelection(selection);
		if (selection.Count() <= 0) {
			Debug.LogError("No tiles in the selection can have an action performed on them.");
			yield break;
		}*/
		//END HACK
		
		
		// initialize a clearcut
		Harvest harvest = new Harvest(selection.ToArray(), 1);
		// configure harvest to perform
		if (m_cutType == CutType.DiameterLimitCut) {
			harvest = new Harvest(
				selection.ToArray(), 1,
				m_diameterLimit, m_diameterLimitDirection
			);
		} else if (m_cutType == CutType.QRatioCut) {
			harvest = new Harvest(
				selection.ToArray(), 1,
				m_qRatio, m_basalArea
			);
		}
		// perform harvest (50% of action progress)
		StartCoroutine(harvest.DoIt());
		while (harvest.progress < 1f) {
			m_actionProgress = 0.5f*harvest.progress;
			if (!string.IsNullOrEmpty(harvest.doItError)) {
				Debug.LogError(harvest.doItError);
				StartCoroutine(RefreshAfterActionFailed(harvest.doItError));
				yield break;
			}
			yield return 0;
		}
		// get updated tiles (100% of action progress)
		/*List<ResourceTile> tiles = new List<ResourceTile>();
		float div = 1f/selection.Count();
		HTTP.Request request;
		for (int i=0; i<selection.Count(); ++i) {
			int id = selection[i];
			request = new HTTP.Request( "Get", WebRequests.GetURLToResourceTile(id) );
			request.AddParameters( WebRequests.authenticatedParameters );
			request.Send();
			
			while (!request.isDone) {
				//m_actionProgress = 0.5f*(1f+(i+www.progress)*div);
				yield return 0;
			}
			if( request.ProducedError ) {
				m_actionProgress = 1f;
				yield break;
			}
			try {
				tiles.Add(JSONDecoder.Decode<IndividualResourceTile>(request.response.Text).resource_tile);
			}
			catch (JsonException) {
				//Debug.LogError(www.text);
			}
		}*/
		// conclude the action
		ConcludeActionOnResourceTiles(selection);
		GameManager.use.worldDataIsValid = false;
		TerrainManager.use.RefreshFromIds(selection.resource_tile_ids.ToArray());
		IEnumerator e = WebRequests.DownloadPlayerData(Player.current);
		while (e.MoveNext()) {
			yield return 0;
		}
	}