/// <summary> /// Calculate the total science value of "known" science plus /// potential science for a given ScienceSubject /// </summary> /// <param name="subject"></param> /// <param name="data"></param> /// <returns></returns> protected virtual float GetScienceTotal(ScienceSubject subject, out List <ScienceData> data) { if (subject == null) { Log.Error("GetScienceTotal: subject is null; cannot locate stored data"); data = new List <ScienceData>(); return(0f); } var found = storage.FindStoredData(subject.id); data = found; if (found.Count() == 0) { // straight stored data return(subject.science); } else { // we've got at least one report we need to consider float potentialScience = subject.science + ResearchAndDevelopment.GetScienceValue(data.First().dataAmount, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (found.Count() > 1) { float secondReport = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; potentialScience += secondReport; // there's some kind of interpolation that the game does for // subsequent experiments. Dividing by four seems to give fairly // decent estimate. It's very unlikely that the exact science value // after the second report is going to matter one way or the other // though, so this is a decent enough solution for now if (found.Count > 2) { for (int i = 3; i < found.Count; ++i) { potentialScience += secondReport / Mathf.Pow(4f, i - 2); } } } return(potentialScience); } }
protected virtual float GetScienceTotal(ScienceSubject subject, out List <ScienceData> data) { if (subject == null) { data = new List <ScienceData>(); return(0f); } var found = storage.FindStoredData(subject.id); data = found; if (found.Count == 0) { return(subject.science); } float potentialScience = subject.science + ResearchAndDevelopment.GetScienceValue(data.First().dataAmount, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (found.Count > 1) { float secondReport = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; potentialScience += secondReport; if (found.Count > 2) { for (int i = 3; i < found.Count; ++i) { potentialScience += secondReport / Mathf.Pow(4f, i - 2); } } } return(potentialScience); }