public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }
            infoView = new InfoView();
            CBAttributeMapSO.MapAttribute biome = Utils.GetCurrentBiome(this.part.vessel);
            biomeName = biome.name;

            if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.SPLASHED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH)
            {
                harvestID = (HarvestTypes)harvestType;
                planetID  = this.part.vessel.mainBody.flightGlobalsIndex;
            }

            moduleSwitcher = this.part.FindModuleImplementing <WBIModuleSwitcher>();

            GameEvents.onCrewOnEva.Add(this.onCrewEVA);
            GameEvents.onCrewTransferred.Add(this.onCrewTransfer);
            GameEvents.onCrewBoardVessel.Add(this.onCrewBoardVessel);

            originalCriticalSuccess = criticalSuccess;
            setupModuleInfo();
        }
        public override void OnStart(StartState state)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                base.OnStart(state);
            }

            if (!string.IsNullOrEmpty(overrideExperimentID))
            {
                LoadFromDefinition(overrideExperimentID);
            }

            SetGUIVisible(isGUIVisible);
            infoView = new InfoView();

            //Required resources
            rebuildResourceMap();

            //Clear resources if needed
            if (clearResourcesAfterCompleted && isCompleted)
            {
                PartResource[] resources = this.part.Resources.ToArray();
                for (int resourceIndex = 0; resourceIndex < resources.Length; resourceIndex++)
                {
                    resources[resourceIndex].amount = 0f;
                }
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorPartPlaced.Add(onPartPlaced);
            }
        }
示例#3
0
        protected void setupModuleInfo()
        {
            string  description = "";
            Texture moduleLogo  = null;
            string  panelName;

            infoView = new InfoView();

            if (moduleSwitcher != null)
            {
                description = moduleSwitcher.CurrentTemplate.GetValue("description");

                panelName = moduleSwitcher.CurrentTemplate.GetValue("logoPanel");
                if (panelName != null)
                {
                    moduleLogo = GameDatabase.Instance.GetTexture(panelName, false);
                    if (moduleLogo != null)
                    {
                        infoView.moduleLabel = moduleLogo;
                    }
                }
            }

            infoView.ModuleInfo = description + "\r\n\r\n" + GetInfo();
        }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            infoView = new InfoView();
            setupGUI();

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorPartPlaced.Add(onPartPlaced);
            }
        }
示例#5
0
        public override void OnStart(StartState state)
        {
            infoView = new InfoView();
            Events["GetModuleInfo"].guiActive = guiVisible;
            Events["GetModuleInfo"].guiName   = outputsGuiName;

            if (HighLogic.LoadedSceneIsFlight)
            {
                //Get the allowed harvest types
                setupHarvestTypes();

                //Prepare outputs
                prepareOutputs();
            }

            base.OnStart(state);
        }
示例#6
0
        public void showAssemblyRequirements()
        {
            StringBuilder requirementsList = new StringBuilder();
            string        templateName     = "";

            //If we have a template then be sure to list its requirements.
            //Template name
            if (CurrentTemplate.HasValue("title"))
            {
                templateName = CurrentTemplate.GetValue("title");
            }
            else
            {
                templateName = CurrentTemplate.GetValue("name");
            }
            if (templateName.ToLower() != "empty")
            {
                requirementsList.AppendLine("Configuration: " + templateName);
            }

            //Resource Requirements.
            buildInputList(templateName);
            string[] keys = inputList.Keys.ToArray();
            for (int index = 0; index < keys.Length; index++)
            {
                requirementsList.Append(keys[index]);
                requirementsList.Append(": ");
                requirementsList.AppendLine(string.Format("{0:f2}", inputList[keys[index]]));
            }

            if (keys.Length == 0)
            {
                requirementsList.AppendLine("No resource requirements");
            }

            InfoView infoView = new InfoView();

            infoView.ModuleInfo = requirementsList.ToString();
            infoView.SetVisible(true);
        }
示例#7
0
        protected void drawPreviewGUI()
        {
            //Only allow reconfiguring of the module if it allows field reconfiguration.
            if (techResearched == false)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("<color=yellow>This module cannot be reconfigured. Research more technology.</color>");
                GUILayout.FlexibleSpace();
                return;
            }

            string moduleInfo;

            GUILayout.Label("<color=white>Current Preview: " + previewName + "</color>");
            GUILayout.Label("<color=white>Reconfiguration Cost: " + cost + " RocketParts</color>");

            //Make sure we have something to display
            if (string.IsNullOrEmpty(previewName))
            {
                previewName = nextName;
            }

            if (converters.Count > 2)
            {
                //Next preview button
                if (GUILayout.Button("Next: " + nextName))
                {
                    if (nextPreviewDelegate != null)
                    {
                        nextPreviewDelegate(previewName);
                    }
                }

                //Prev preview button
                if (GUILayout.Button("Prev: " + prevName))
                {
                    if (prevPreviewDelegate != null)
                    {
                        prevPreviewDelegate(previewName);
                    }
                }
            }

            else
            {
                //Next preview button
                if (GUILayout.Button("Next: " + nextName))
                {
                    if (nextPreviewDelegate != null)
                    {
                        nextPreviewDelegate(previewName);
                    }
                }
            }

            //More info button
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("More Info"))
            {
                if (getModuleInfoDelegate != null)
                {
                    moduleInfo = getModuleInfoDelegate(previewName);
                    InfoView modSummary = new InfoView();
                    Texture  moduleLabel;

                    modSummary.ModuleInfo = moduleInfo;

                    if (this.getModuleLogoDelegate != null)
                    {
                        moduleLabel            = getModuleLogoDelegate(previewName);
                        modSummary.moduleLabel = moduleLabel;
                    }
                    modSummary.ToggleVisible();
                }
            }

            if (GUILayout.Button("Reconfigure"))
            {
                changeModuleTypeDelegate(previewName);
            }

            GUILayout.EndHorizontal();
        }
示例#8
0
        public void ShowResourceOutputs()
        {
            StringBuilder outputInfo = new StringBuilder();

            //Make sure we're up to date.
            this.OnUpdate();

            if (Utils.IsBiomeUnlocked(this.part.vessel) == false)
            {
                outputInfo.Append("<color=white><b>Unlock the biome to get the list of outputs.</b></color>");
            }

            else
            {
                if (IsSituationValid())
                {
                    int           count = resourceRatios.Count;
                    ResourceRatio output;
                    for (int index = 0; index < count; index++)
                    {
                        output = resourceRatios[index];
                        outputInfo.Append("<color=white>");
                        outputInfo.Append(formatResource(output.ResourceName, output.Ratio));
                        outputInfo.AppendLine("</color>");
                    }
                }

                else
                {
                    outputInfo.AppendLine("<color=white><b>Requires one of:</b></color>");

                    foreach (HarvestTypes harvestType in this.harvestTypeList)
                    {
                        switch (harvestType)
                        {
                        case HarvestTypes.Atmospheric:
                            outputInfo.AppendLine("<color=white>Flying</color>");
                            break;

                        case HarvestTypes.Oceanic:
                            outputInfo.AppendLine("<color=white>In water</color>");
                            break;

                        case HarvestTypes.Exospheric:
                            outputInfo.AppendLine("<color=white>In Space</color>");
                            break;

                        default:
                            outputInfo.AppendLine("<color=white>On the ground</color>");
                            break;
                        }
                    }
                }
            }

            //Setup info view
            infoView             = new InfoView();
            infoView.WindowTitle = this.part.partInfo.title;
            infoView.ModuleInfo  = outputInfo.ToString();
            infoView.SetVisible(true);
        }