public void SimulateFlux() { s_SimulateFluxPerfMarker.Begin(); if (state == AtmosStates.Active) { float pressure = GetPressure(); for (int i = 0; i < Gas.numOfGases; i++) { if (atmosContainer.GetGasses()[i] > 0f) { int k = 0; foreach (AtmosObject tile in atmosNeighbours) { if (tileFlux[k] > 0f) { float factor = atmosContainer.GetGasses()[i] * (tileFlux[k] / pressure); if (tile.state != AtmosStates.Vacuum) { tile.atmosContainer.AddGas(i, factor); tile.state = AtmosStates.Active; } else { activeDirection[k] = false; } atmosContainer.RemoveGas(i, factor); } k++; } } } float difference; int j = 0; foreach (AtmosObject tile in atmosNeighbours) { if (activeDirection[j] == true) { difference = (atmosContainer.GetTemperature() - tile.atmosContainer.GetTemperature()) * Gas.thermalBase * atmosContainer.Volume; // / (GetSpecificHeat() * 5f); if (difference > Gas.thermalEpsilon) { tile.atmosContainer.SetTemperature(tile.atmosContainer.GetTemperature() + difference); atmosContainer.SetTemperature(atmosContainer.GetTemperature() - difference); tempSetting = true; } } j++; } float fluxFromLeft = 0; if (atmosNeighbours[2] != null) { fluxFromLeft = atmosNeighbours[2].tileFlux[3]; } float fluxFromRight = 0; if (atmosNeighbours[3] != null) { fluxFromLeft = atmosNeighbours[3].tileFlux[2]; } float fluxFromTop = 0; if (atmosNeighbours[0] != null) { fluxFromTop = atmosNeighbours[0].tileFlux[1]; } float fluxFromBottom = 0; if (atmosNeighbours[1] != null) { fluxFromBottom = atmosNeighbours[1].tileFlux[0]; } float velHorizontal = tileFlux[3] - fluxFromLeft - tileFlux[2] + fluxFromRight; float velVertical = tileFlux[0] - fluxFromTop - tileFlux[1] + fluxFromBottom; velocity = new Vector2(velHorizontal, velVertical); } else if (state == AtmosStates.Semiactive) { velocity = Vector2.zero; SimulateMixing(); } s_SimulateFluxPerfMarker.End(); }
public float GetTemperature() { return(atmosContainer.GetTemperature()); }