コード例 #1
0
        public override void UpdateContentsAndGui(string templateName)
        {
            ModuleScienceContainer scienceContainer = this.part.FindModuleImplementing <ModuleScienceContainer>();

            if (scienceContainer != null)
            {
                ScienceData[] dataQueue = scienceContainer.GetData();
                if (dataQueue != null)
                {
                    if (dataQueue.Length > 0)
                    {
                        scienceContainer.Events["ReviewDataEvent"].guiActiveUnfocused = true;
                        scienceContainer.Events["ReviewDataEvent"].guiActive          = true;
                    }
                }
            }

            base.UpdateContentsAndGui(templateName);

            //Check to see if we've displayed the tooltip for the template.

            //First, we're only interested in deployed modules.
            if (isDeployed == false)
            {
                return;
            }

            //Now check
            checkAndShowToolTip();
        }
コード例 #2
0
ファイル: WBIGeologyLab.cs プロジェクト: ozraven/Pathfinder
        protected int countCoreSamples()
        {
            int coreSamples = 0;

            ScienceData[] dataList = scienceContainer.GetData();

            foreach (ScienceData data in dataList)
            {
                if (data.subjectID.Contains("WBICoreSampleAnalysis") || data.subjectID.Contains(WBIBiomeAnalysis.kBiomeAnalysisID))
                {
                    coreSamples += 1;
                }
            }

            return(coreSamples);
        }
コード例 #3
0
        private void OnExperimentsResultDialogClosed()
        {
            if (FlightGlobals.ActiveVessel != null)
            {
                // get all container modules on the vessel
                List <ModuleScienceContainer> containers = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceContainer>();

                // iterate over the containers
                for (int containerIndex = 0; containerIndex < containers.Count; containerIndex++)
                {
                    ModuleScienceContainer container = containers[containerIndex];

                    // get all the experiment modules attached to the same part as the container
                    List <ModuleScienceExperiment> experiments = container.part.FindModulesImplementing <ModuleScienceExperiment>();

                    // iterate over the experiments
                    for (int experimentIndex = 0; experimentIndex < experiments.Count; experimentIndex++)
                    {
                        ModuleScienceExperiment experiment = experiments[experimentIndex];

                        // check that experiment has available data
                        if (experiment.GetScienceCount() > 0)
                        {
                            // get both the container and experiment data for duplicate checking
                            ScienceData[] containerDataArray  = container.GetData();
                            ScienceData[] experimentDataArray = experiment.GetData();

                            // iterate over the experiment data
                            foreach (ScienceData experimentData in experimentDataArray)
                            {
                                bool allowDataTransfer = true;

                                // check for duplicates in the container data
                                foreach (ScienceData containerData in containerDataArray)
                                {
                                    if (containerData.subjectID == experimentData.subjectID)
                                    {
                                        allowDataTransfer = false;

                                        // discard duplicates
                                        if (HighLogic.CurrentGame.Parameters.CustomParams <SMR>().discardDuplicates)
                                        {
                                            experiment.DumpData(experimentData);
                                        }
                                    }
                                }

                                // transfer data from experiment to container
                                if (allowDataTransfer)
                                {
                                    experiment.DumpData(experimentData);
                                    container.AddData(experimentData);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
 private void LoadScienceData()
 {
     results.Clear();
     foreach (ScienceData result in container.GetData())
     {
         results.Add(new ScienceAIData(result));
     }
 }
コード例 #5
0
        private void dockStage4()
        {
            RmmUtil.ToMapView();
            Part placePort = new Part();

            // int portNumber = 0;
            foreach (Part p in transactionVessel.parts)
            {
                if (p.flightID == missionFlightIDDockPart)
                {
                    placePort = p;
                }
                foreach (PartModule pm in p.Modules)
                {
                    //if (pm.GetType() == typeof(ModuleDockingNode))
                    //{
                    //    RMMModule ComOffMod = p.Modules.OfType<RMMModule>().FirstOrDefault();
                    //    if (ComOffMod.trackingPrimary == true)
                    //    {
                    //        placePort = p;
                    //        if (missionOffering.ReturnEnabled)
                    //        {
                    //            ComOffMod.commercialvehiclemode = true;
                    //            ComOffMod.commercialvehicleFolderName = missionOffering.FolderPath;
                    //            ComOffMod.commercialvehiclePartCount = (float)RmmUtil.CountVesselParts(transactionVessel);
                    //            ComOffMod.trackingPrimary = false;
                    //        }
                    //    }
                    //    portNumber = portNumber + 1;
                    //
                    //    ComOffMod.trackingActive = false;
                    //    ComOffMod.returnMission = false;
                    //    ComOffMod.trackMissionId = "";
                    //    ComOffMod.PortCode = "";
                    //}

                    // empty all science
                    if (pm.GetType() == typeof(ModuleScienceContainer))
                    {
                        ModuleScienceContainer moduleScienceContainer = (ModuleScienceContainer)pm;
                        var scienceDatas = moduleScienceContainer.GetData();
                        for (int i = 0; i < scienceDatas.Count(); i++)
                        {
                            moduleScienceContainer.RemoveData(scienceDatas[i]);
                        }
                    }
                }
            }
            transactionVessel.targetObject = null;
            handleLoadCrew(transactionVessel, _mission.CrewCount, _mission.MinimumCrew, _mission.CrewSelection);
            RmmContract.HandleContracts(transactionVessel, true, false);
            LoggerRmm.Debug("st4.5" + RmmUtil.IsDocked(_targetVessel, _targetPart) + checkDockingPortCompatibility(placePort, _targetPart));
            if (!RmmUtil.IsDocked(_targetVessel, _targetPart) && checkDockingPortCompatibility(placePort, _targetPart))
            {
                LoggerRmm.Debug("st4.6");
                placeVesselForDock(transactionVessel, placePort, _targetVessel, _targetPart, RmmUtil.GetDockingDistance(placePort));
                LoggerRmm.Debug("st4.7");
                _nextLogicTime = Planetarium.GetUniversalTime();
                _arrivalStage  = 5;
            }
            else
            {
                ScreenMessages.PostScreenMessage(_mission.VesselName + " rendezvoused", 4, ScreenMessageStyle.UPPER_CENTER);
                finishArrival();
            }
        }
コード例 #6
0
        private bool finishTransfer(Vessel v, ScienceData d, float boost)
        {
            if (v == null)
            {
                return(false);
            }

            if (d == null)
            {
                return(false);
            }

            if (v.loaded)
            {
                List <ModuleScienceContainer> containers = v.FindPartModulesImplementing <ModuleScienceContainer>();

                if (containers.Count <= 0)
                {
                    return(false);
                }

                ModuleScienceContainer currentContainer = null;

                for (int j = containers.Count - 1; j >= 0; j--)
                {
                    ModuleScienceContainer container = containers[j];

                    if (container.capacity != 0 && container.GetData().Length >= container.capacity)
                    {
                        continue;
                    }

                    if (container.allowRepeatedSubjects)
                    {
                        currentContainer = container;
                        break;
                    }

                    if (container.HasData(d))
                    {
                        continue;
                    }

                    currentContainer = container;
                }

                if (currentContainer != null)
                {
                    d.triggered         = false;
                    d.dataAmount       *= (d.baseTransmitValue * (1 + boost));
                    d.transmitBonus     = 1;
                    d.baseTransmitValue = 1;
                    return(currentContainer.AddData(d));
                }
            }
            else
            {
                List <ProtoPartSnapshot> containers = getProtoContainers(v.protoVessel);

                if (containers.Count <= 0)
                {
                    return(false);
                }

                ProtoPartModuleSnapshot currentContainer = null;

                uint host = 0;

                for (int j = containers.Count - 1; j >= 0; j--)
                {
                    ProtoPartSnapshot container = containers[j];

                    host = container.flightID;

                    ProtoPartModuleSnapshot tempContainer = null;

                    for (int k = container.modules.Count - 1; k >= 0; k--)
                    {
                        ProtoPartModuleSnapshot mod = container.modules[k];

                        if (mod.moduleName != "ModuleScienceContainer")
                        {
                            continue;
                        }

                        tempContainer = mod;

                        break;
                    }

                    if (tempContainer == null)
                    {
                        continue;
                    }

                    List <ScienceData> protoData = new List <ScienceData>();

                    ConfigNode[] science = tempContainer.moduleValues.GetNodes("ScienceData");

                    for (int l = science.Length - 1; l >= 0; l--)
                    {
                        ConfigNode node = science[l];

                        protoData.Add(new ScienceData(node));
                    }

                    Part prefab = container.partInfo.partPrefab;

                    ModuleScienceContainer prefabContainer = prefab.FindModuleImplementing <ModuleScienceContainer>();

                    if (prefabContainer != null)
                    {
                        if (prefabContainer.capacity != 0 && protoData.Count >= prefabContainer.capacity)
                        {
                            continue;
                        }

                        if (prefabContainer.allowRepeatedSubjects)
                        {
                            currentContainer = tempContainer;
                            break;
                        }

                        if (HasData(d.subjectID, protoData))
                        {
                            continue;
                        }

                        currentContainer = tempContainer;
                    }
                }

                if (currentContainer != null)
                {
                    d.triggered         = false;
                    d.dataAmount        = d.dataAmount * (d.baseTransmitValue * (boost + 1));
                    d.transmitBonus     = 1;
                    d.baseTransmitValue = 1;
                    d.container         = host;
                    d.Save(currentContainer.moduleValues.AddNode("ScienceData"));
                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
    void drawContainer(ModuleScienceContainer container)
    {
        bool hasData = container.GetData().Length > 0;
        if (!hasData) { return; }

        var list = new List<ScienceData>(container.GetData());
        list.Sort(delegate(ScienceData a, ScienceData b) { return string.Compare(a.title, b.title); });

        foreach (var data in list) {
            var sv = simulateScience(data);
            var tsv = simulateScience(data, true);
            dataAmount += data.dataAmount;
            returnScience += sv;
            transmitScience += tsv;
            string stats = string.Format("( {0:F1} / {1:F1} )", sv, tsv);

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal(GUILayout.MaxHeight(18));
            GUILayout.Label(container.part.partInfo.title + (stats != "" ? " - " + stats : ""), styleTitle);
            GUILayout.Label(data.title, styleTitle);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
    }