void VesselRecoveryProcessing(ProtoVessel v, MissionRecoveryDialog dialog, float score) { // note: // this function accumulate science stored in drives on recovery, // and visualize the data in the recovery dialog window // do nothing if science system is disabled, or in sandbox mode if (!Features.Science || HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) { return; } var vesselID = Lib.VesselID(v); // get the drive data from DB if (!DB.vessels.ContainsKey(vesselID)) { return; } foreach (Drive drive in Drive.GetDrives(v)) { // for each file in the drive foreach (KeyValuePair <string, File> p in drive.files) { // shortcuts string filename = p.Key; File file = p.Value; // de-buffer partially transmitted data file.size += file.buff; file.buff = 0.0; // get subject ScienceSubject subject = ResearchAndDevelopment.GetSubjectByID(filename); // credit science float credits = Science.Credit(filename, file.size, false, v); // create science widged ScienceSubjectWidget widged = ScienceSubjectWidget.Create ( subject, // subject (float)file.size, // data gathered credits, // science points dialog // recovery dialog ); // add widget to dialog dialog.AddDataWidget(widged); // add science credits to total dialog.scienceEarned += (float)credits; } // for each sample in the drive // for each file in the drive foreach (KeyValuePair <string, Sample> p in drive.samples) { // shortcuts string filename = p.Key; Sample sample = p.Value; // get subject ScienceSubject subject = ResearchAndDevelopment.GetSubjectByID(filename); // credit science float credits = Science.Credit(filename, sample.size, false, v); // create science widged ScienceSubjectWidget widged = ScienceSubjectWidget.Create ( subject, // subject (float)sample.size, // data gathered credits, // science points dialog // recovery dialog ); // add widget to dialog dialog.AddDataWidget(widged); // add science credits to total dialog.scienceEarned += (float)credits; } } }
void VesselRecoveryProcessing(ProtoVessel v, MissionRecoveryDialog dialog, float score) { // note: // this function accumulate science stored in drives on recovery, // and visualize the data in the recovery dialog window // do nothing if science system is disabled, or in sandbox mode if (!Features.Science || HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) return; // get the drive data from DB uint root_id = v.protoPartSnapshots[v.rootIndex].flightID; if (!DB.vessels.ContainsKey(root_id)) return; Drive drive = DB.vessels[root_id].drive; // for each file in the drive foreach (var p in drive.files) { // shortcuts string filename = p.Key; File file = p.Value; // de-buffer partially transmitted data file.size += file.buff; file.buff = 0.0; // get subject ScienceSubject subject = ResearchAndDevelopment.GetSubjectByID(filename); // credit science double credits = Science.Credit(filename, file.size, false, v); // create science widged ScienceSubjectWidget widged = ScienceSubjectWidget.Create ( subject, // subject (float)file.size, // data gathered (float)credits, // science points dialog // recovery dialog ); // add widget to dialog dialog.AddDataWidget(widged); // add science credits to total dialog.scienceEarned += (float)credits; } // for each sample in the drive // for each file in the drive foreach (var p in drive.samples) { // shortcuts string filename = p.Key; Sample sample = p.Value; // get subject ScienceSubject subject = ResearchAndDevelopment.GetSubjectByID(filename); // credit science double credits = Science.Credit(filename, sample.size, false, v); // create science widged ScienceSubjectWidget widged = ScienceSubjectWidget.Create ( subject, // subject (float)sample.size, // data gathered (float)credits, // science points dialog // recovery dialog ); // add widget to dialog dialog.AddDataWidget(widged); // add science credits to total dialog.scienceEarned += (float)credits; } }