public static float GetNextReportValue(ScienceSubject subject, ScienceExperiment experiment, List <ScienceData> onboard, float xmitScalar = 1f) { var data = new ScienceData(experiment.baseValue * experiment.dataScale * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier, xmitScalar, 0f, subject.id, string.Empty); data.labBoost = ModuleScienceLab.GetBoostForVesselData(FlightGlobals.ActiveVessel, data); xmitScalar += data.labBoost; #if DEBUG //Log.Debug("GetNextReportValue for {0}, calculated labBoost of {1}", experiment.experimentTitle, data.labBoost); #endif if (onboard.Count == 0) { return(ResearchAndDevelopment.GetScienceValue(experiment.baseValue * experiment.dataScale, subject, xmitScalar) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); } float experimentValue = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject, xmitScalar) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (onboard.Count == 1) { return(experimentValue); } // we'll have to estimate return(experimentValue / UnityEngine.Mathf.Pow(4f, onboard.Count - 1)); }
private float GetCurrentScienceValue(ScienceExperiment experiment, ScienceSubject subject, List <ScienceData> storedData) { // get total value of science in experiment containers and the kerbalism data drive int numberOfExperimentsOnBoard = storedData.Count; if (numberOfExperimentsOnBoard == 0) { return(subject.science); } float potentialScience = subject.science + ResearchAndDevelopment.GetScienceValue(storedData.First().dataAmount, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (numberOfExperimentsOnBoard > 1) { float secondReport = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; potentialScience += secondReport; if (numberOfExperimentsOnBoard > 2) { for (int i = 3; i < numberOfExperimentsOnBoard; ++i) { potentialScience += secondReport / Mathf.Pow(4f, i - 2); } } } return(potentialScience); }
/// <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 float CalculateNextReportValue(ScienceSubject subject, ExperimentSituations situation, List <ScienceData> stored) { if (stored.Count == 0) { return(ResearchAndDevelopment.GetScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); } float experimentValue = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (stored.Count == 1) { return(experimentValue); } return(experimentValue / Mathf.Pow(4f, stored.Count - 1)); }
private float GetScienceValue(ScienceExperiment experiment, ScienceSubject subject, List <ScienceData> scienceData) { ; float currentScienceValue = GetCurrentScienceValue(experiment, subject, scienceData); if (scienceData.Count == 0) { return(ResearchAndDevelopment.GetScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); } float experimentValue = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (scienceData.Count == 1) { return(experimentValue); } return(experimentValue / Mathf.Pow(4f, scienceData.Count - 1)); }
public static float GetNextReportValue(ScienceSubject subject, ScienceExperiment experiment, System.Collections.Generic.List <ScienceData> onboard, float xmitScalar = 1f) { ScienceData scienceData = new ScienceData (experiment.baseValue * experiment.dataScale * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier, xmitScalar, 0f, subject.id, string.Empty); //scienceData.transmitBonus = ModuleScienceLab.GetBoostForVesselData(FlightGlobals.ActiveVessel, scienceData); ??? xmitScalar += scienceData.transmitBonus; if (onboard.Count == 0) { return(ResearchAndDevelopment.GetScienceValue(experiment.baseValue * experiment.dataScale, subject, xmitScalar) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); } float num = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject, xmitScalar) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (onboard.Count == 1) { return(num); } return(num / Mathf.Pow(4f, (float)(onboard.Count - 1))); }
/// <summary> /// Calculate the value of a report if taken at this instant while /// considering existing science and reports stored onboard /// </summary> /// <param name="subject"></param> /// <param name="situation"></param> /// <param name="stored"></param> /// <returns></returns> protected float CalculateNextReportValue(ScienceSubject subject, ExperimentSituations situation, List <ScienceData> stored) { if (stored.Count == 0) { return(ResearchAndDevelopment.GetScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); } float experimentValue = ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, subject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (stored.Count == 1) { return(experimentValue); } // for two or more, we'll have to estimate. Presumably there's some // kind of interpolation going on. I've found that just dividing the previous // value by four is a good estimate. return(experimentValue / Mathf.Pow(4f, stored.Count - 1)); }
private float GetNextExperimentScience(ScienceInstance exp, List <ScienceData> onboardData) { float experimentValue = 0f; var subjectOnboardData = onboardData.Where(d => d.subjectID == exp.ScienceSubject.id).ToArray(); if (subjectOnboardData.Length == 0) { experimentValue = ResearchAndDevelopment.GetScienceValue(exp.ScienceExperiment.baseValue * exp.ScienceExperiment.dataScale, exp.ScienceSubject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; } else { experimentValue = ResearchAndDevelopment.GetNextScienceValue(exp.ScienceExperiment.baseValue * exp.ScienceExperiment.dataScale, exp.ScienceSubject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; if (subjectOnboardData.Length > 1) { experimentValue /= Mathf.Pow(4f, subjectOnboardData.Length - 1); } } return(experimentValue); }
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); }
private static float GetNextScienceValue(ScienceExperiment experiment, ScienceSubject currentScienceSubject) { return(ResearchAndDevelopment.GetNextScienceValue(experiment.baseValue * experiment.dataScale, currentScienceSubject) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier); }