public bool StoreScience(ModuleScienceContainer container, ScienceSubject subject, float data)
        {
            if (container.capacity > 0 && container.GetScienceCount() >= container.capacity)
            {
                return(false);
            }

            if (container.GetStoredDataCount() != 0)
            {
                return(false);
            }

            float xmitValue = 0.85f;
            float labBoost  = 0.1f;

            ScienceData new_data = new ScienceData(data, xmitValue, labBoost, subject.id, subject.title);

            if (container.AddData(new_data))
            {
                return(true);
            }


            return(false);
        }
示例#2
0
        public override void ReviewData()
        {
            float scienceCap   = WBIBiomeAnalysis.GetScienceCap(this.part);
            float totalScience = scienceAdded;

            if (totalScience < 0.001f)
            {
                ScreenMessages.PostScreenMessage(kNoScience, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            while (totalScience > 0.001f)
            {
                //Set the experiment title
                if (totalScience < scienceCap)
                {
                    dataAmount = totalScience;
                }
                else
                {
                    dataAmount = scienceCap;
                }

                //Generate lab data
                ScienceData data = WBIBiomeAnalysis.CreateData(this.part, dataAmount);
                scienceContainer.AddData(data);

                //Deduct from the total
                totalScience -= dataAmount;
                if (totalScience <= 0.001f)
                {
                    scienceAdded = 0f;
                }
            }

            //Make sure we have some science to transmit.
            if (scienceContainer.GetScienceCount() == 0)
            {
                ScreenMessages.PostScreenMessage(kNoScience, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //Review the data
            scienceContainer.ReviewData();
            swizzler.SwizzleResultsDialog();
        }
示例#3
0
        protected void drawCnCButtons()
        {
            int dataCount = scienceContainer.GetScienceCount();

            GUILayout.BeginVertical();
            GUILayout.BeginScrollView(new Vector2(0, 0));

            if (dataCount > 0)
            {
                if (GUILayout.Button("Review [" + dataCount.ToString() + "] Data"))
                {
                }
            }

            if (GUILayout.Button("Clean Experiments"))
            {
                sciLab.CleanModulesEvent();
            }

            if (converter.ModuleIsActive())
            {
                if (GUILayout.Button(converter.StopActionName))
                {
                    converter.StopResourceConverter();
                }
            }
            else
            {
                if (GUILayout.Button(converter.StartActionName))
                {
                    converter.StartResourceConverter();
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
示例#4
0
        private static void ResourceDetailsViewer()
        {
            try
            {
                _resourceScrollViewerPosition = GUILayout.BeginScrollView(_resourceScrollViewerPosition, SMStyle.ScrollStyle,
                                                                          GUILayout.Height(100), GUILayout.Width(300));
                GUILayout.BeginVertical();

                if (SMAddon.SmVessel.SelectedResources.Count > 0)
                {
                    List <Part> .Enumerator pParts = SMAddon.SmVessel.SelectedResourcesParts.GetEnumerator();
                    while (pParts.MoveNext())
                    {
                        if (pParts.Current == null)
                        {
                            continue;
                        }
                        Part part = pParts.Current;
                        if (SMConditions.AreSelectedResourcesTypeOther(SMAddon.SmVessel.SelectedResources))
                        {
                            GUIStyle noWrap = SMStyle.LabelStyleNoWrap;
                            GUILayout.Label(string.Format("{0}", part.partInfo.title), noWrap, GUILayout.Width(265),
                                            GUILayout.Height(18));
                            GUIStyle noPad = SMStyle.LabelStyleNoPad;
                            List <string> .Enumerator sResources = SMAddon.SmVessel.SelectedResources.GetEnumerator();
                            while (sResources.MoveNext())
                            {
                                if (sResources.Current == null)
                                {
                                    continue;
                                }
                                GUILayout.Label(
                                    string.Format(" - {0}:  ({1:######0.####}/{2:######0.####})", sResources.Current, part.Resources[sResources.Current].amount, part.Resources[sResources.Current].maxAmount), noPad, GUILayout.Width(265),
                                    GUILayout.Height(16));
                            }
                            sResources.Dispose();
                        }
                        else if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Crew.ToString()))
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label(
                                string.Format("{0}, ({1}/{2})", part.partInfo.title, SMUtils.GetPartCrewCount(part), part.CrewCapacity),
                                GUILayout.Width(265), GUILayout.Height(20));
                            GUILayout.EndHorizontal();
                        }
                        else if (SMAddon.SmVessel.SelectedResources.Contains(SMConditions.ResourceType.Science.ToString()))
                        {
                            int         scienceCount = 0;
                            IEnumerator pModules     = part.Modules.GetEnumerator();
                            while (pModules.MoveNext())
                            {
                                if (pModules.Current == null)
                                {
                                    continue;
                                }
                                PartModule             pm        = (PartModule)pModules.Current;
                                ModuleScienceContainer container = pm as ModuleScienceContainer;
                                if (container != null)
                                {
                                    scienceCount += container.GetScienceCount();
                                }
                                else if (pm is ModuleScienceExperiment)
                                {
                                    scienceCount += ((ModuleScienceExperiment)pm).GetScienceCount();
                                }
                            }
                            GUILayout.BeginHorizontal();
                            GUILayout.Label(string.Format("{0}, ({1})", part.partInfo.title, scienceCount), GUILayout.Width(265));
                            GUILayout.EndHorizontal();
                        }
                    }
                    pParts.Dispose();
                }
            }
            catch (Exception ex)
            {
                if (!SMAddon.FrameErrTripped)
                {
                    SMUtils.LogMessage(
                        string.Format(" in WindowManifest.ResourceDetailsViewer.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace),
                        SMUtils.LogType.Error, true); // in, Error
                    SMAddon.FrameErrTripped = true;
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
        }
示例#5
0
 private static string formatContainer(ModuleScienceContainer container)
 {
     return(string.Format("{0} - {1} data", container.part.partInfo.title, container.GetScienceCount()));
 }