public static void CreateDestinationCargo(Airport airport, Airport dAirport) { //origin airport out double originMassPerDay = GetAirportCargoMass(airport) / 2; double originDemand = (originMassPerDay * CargoFactors[dAirport.Profile.Cargo]) / Airports.CargoAirportsSizes[dAirport.Profile.Cargo]; //destination airport in double destinationMassPerDay = GetAirportCargoMass(dAirport) / 2; double destinationDemand = (destinationMassPerDay * CargoFactors[airport.Profile.Cargo]) / Airports.CargoAirportsSizes[airport.Profile.Cargo]; double distance = MathHelpers.GetDistance(airport, dAirport); double distanceFactor = distance > 5000 ? 1 : 0.5; double sameCountryFactor = airport.Profile.Country == dAirport.Profile.Country ? 0.75 : 1; double sameRegionFactor = sameCountryFactor == 1 && airport.Profile.Country.Region == dAirport.Profile.Country.Region ? 0.5 : 1; double minMass = Math.Min(originMassPerDay, destinationMassPerDay); double volume = minMass / distanceFactor; volume = volume / sameCountryFactor; volume = volume / sameRegionFactor; //converts to pounds of cargo volume *= 35.1; if (volume >= 1) airport.addDestinationCargoRate(new DestinationDemand(dAirport.Profile.IATACode, (ushort)volume)); }