/// <summary> /// Do all fuel refining on planets and later on gas giant harvesters. /// </summary> /// <param name="P">list of factions.</param> public static void RefineFuel(BindingList <Faction> P) { foreach (Faction CurrentFaction in P) { #warning Implement gas giant harvesters here. foreach (Population CurrentPopulation in CurrentFaction.Populations) { /// <summary> /// Skip this population. /// </summary> if (CurrentPopulation.IsRefining == false) { continue; } float TimeAdjust = (float)Constants.Colony.ConstructionCycle / (float)Constants.TimeInSeconds.Year; float CurrentRefining = CurrentPopulation.CalcTotalRefining() * TimeAdjust; /// <summary> /// If the planet has no refineries or no sorium then no refining happens. /// </summary> if (CurrentRefining > 0.0f && CurrentPopulation.Minerials[(int)Constants.Minerals.MinerialNames.Sorium] > 0.0f) { /// <summary> /// 1 sorium = 2000 fuel /// </summary> float SoriumRequirement = CurrentRefining / Constants.Colony.SoriumToFuel; if (CurrentPopulation.Minerials[(int)Constants.Minerals.MinerialNames.Sorium] < SoriumRequirement) { SoriumRequirement = CurrentPopulation.Minerials[(int)Constants.Minerals.MinerialNames.Sorium]; CurrentRefining = SoriumRequirement * Constants.Colony.SoriumToFuel; } /// <summary> /// Convert Sorium into fuel. /// </summary> CurrentPopulation.Minerials[(int)Constants.Minerals.MinerialNames.Sorium] = CurrentPopulation.Minerials[(int)Constants.Minerals.MinerialNames.Sorium] - SoriumRequirement; CurrentPopulation.FuelStockpile = CurrentPopulation.FuelStockpile + CurrentRefining; } else if (CurrentRefining > 0.0f) { String Entry = String.Format("Insufficient Sorium on {0} to continue refining.", CurrentPopulation); MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.ColonyLacksMinerals, CurrentPopulation.Contact.Position.System, CurrentPopulation.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Entry); CurrentFaction.MessageLog.Add(Msg); } } } }