protected void updateScienceLab() { bool enableMPLModules = false; if (CurrentTemplate.HasValue("enableMPLModules")) { enableMPLModules = bool.Parse(CurrentTemplate.GetValue("enableMPLModules")); } ModuleScienceLab sciLab = this.part.FindModuleImplementing <ModuleScienceLab>(); if (sciLab != null) { if (HighLogic.LoadedSceneIsEditor) { sciLab.isEnabled = false; sciLab.enabled = false; } else if (enableMPLModules) { sciLab.isEnabled = true; sciLab.enabled = true; sciLab.crewsRequired = originalCrewsRequired; } else { sciLab.crewsRequired = 2000.0f; sciLab.isEnabled = false; sciLab.enabled = false; } } }
public string GetCheckSkill() { if (CurrentTemplate.HasValue("reconfigureSkill")) { return(CurrentTemplate.GetValue("reconfigureSkill")); } else { return("RepairSkill"); } }
public override void RedecorateModule(bool loadTemplateResources = true) { base.RedecorateModule(loadTemplateResources); bool enableMPLModules = false; if (CurrentTemplate.HasValue("enableMPLModules")) { enableMPLModules = bool.Parse(CurrentTemplate.GetValue("enableMPLModules")); } ModuleScienceLab sciLab = this.part.FindModuleImplementing <ModuleScienceLab>(); if (sciLab != null) { if (HighLogic.LoadedSceneIsEditor) { sciLab.isEnabled = false; sciLab.enabled = false; } else if (enableMPLModules) { sciLab.isEnabled = true; sciLab.enabled = true; sciLab.crewsRequired = originalCrewsRequired; } else { sciLab.crewsRequired = 2000.0f; sciLab.isEnabled = false; sciLab.enabled = false; } } ModuleScienceConverter converter = this.part.FindModuleImplementing <ModuleScienceConverter>(); if (converter != null) { if (HighLogic.LoadedSceneIsEditor) { converter.isEnabled = enableMPLModules; converter.enabled = enableMPLModules; } else { converter.isEnabled = enableMPLModules; converter.enabled = enableMPLModules; } } }
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); }
protected void checkAndShowToolTip() { //Now we can check to see if the tooltip for the current template has been shown. WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance; if (scenario.HasShownToolTip(CurrentTemplateName) && scenario.HasShownToolTip(getMyPartName())) { return; } if (!CurrentTemplate.HasValue("toolTipTitle") && !CurrentTemplate.HasValue("toolTip")) { return; } //Tooltip for the current template has never been shown. Show it now. string toolTipTitle = CurrentTemplate.GetValue("toolTipTitle"); string toolTip = CurrentTemplate.GetValue("toolTip"); if (string.IsNullOrEmpty(toolTipTitle)) { toolTipTitle = partToolTipTitle; } //Add the very first part's tool tip. if (scenario.HasShownToolTip(getMyPartName()) == false) { toolTip = partToolTip + "\r\n\r\n" + toolTip; scenario.SetToolTipShown(getMyPartName()); } if (string.IsNullOrEmpty(toolTip) == false) { WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(toolTipTitle, toolTip); toolTipWindow.SetVisible(true); //Cleanup scenario.SetToolTipShown(CurrentTemplateName); } }
protected void updateWorkshop() { PartModule oseWorkshop = null; PartModule oseRecycler = null; bool enableWorkshop = false; //See if the drill is enabled. if (CurrentTemplate.HasValue("enableWorkshop")) { enableWorkshop = bool.Parse(CurrentTemplate.GetValue("enableWorkshop")); } //Find the workshop modules foreach (PartModule pm in this.part.Modules) { if (pm.moduleName == "OseModuleWorkshop") { oseWorkshop = pm; } else if (pm.moduleName == "OseModuleRecycler") { oseRecycler = pm; } } if (oseWorkshop != null) { oseWorkshop.enabled = enableWorkshop; oseWorkshop.isEnabled = enableWorkshop; } if (oseRecycler != null) { oseRecycler.enabled = enableWorkshop; oseRecycler.isEnabled = enableWorkshop; } }
protected virtual void updatePartMass() { if (CurrentTemplate.HasValue("mass")) { partMass = float.Parse(CurrentTemplate.GetValue("mass")); } else { PartResourceDefinition definition; buildInputList(CurrentTemplateName); string[] keys = inputList.Keys.ToArray(); string resourceName; partMass = 0; for (int index = 0; index < keys.Length; index++) { resourceName = keys[index]; definition = ResourceHelper.DefinitionForResource(resourceName); partMass += definition.density * (float)inputList[resourceName]; } } }
protected void updateDrill() { bool enableDrill = false; float value; string resourceName; ModuleResourceHarvester harvester = this.part.FindModuleImplementing <ModuleResourceHarvester>(); //No drill? No need to proceed. if (harvester == null) { return; } //See if the drill is enabled. if (CurrentTemplate.HasValue("enableDrill")) { enableDrill = bool.Parse(CurrentTemplate.GetValue("enableDrill")); } ModuleOverheatDisplay overheat = this.part.FindModuleImplementing <ModuleOverheatDisplay>(); if (overheat != null) { overheat.enabled = enableDrill; overheat.isEnabled = enableDrill; } ModuleCoreHeat coreHeat = this.part.FindModuleImplementing <ModuleCoreHeat>(); if (coreHeat != null) { coreHeat.enabled = enableDrill; coreHeat.isEnabled = enableDrill; } WBIDrillSwitcher drillSwitcher = this.part.FindModuleImplementing <WBIDrillSwitcher>(); if (drillSwitcher != null) { drillSwitcher.enabled = enableDrill; drillSwitcher.isEnabled = enableDrill; } WBIEfficiencyMonitor extractionMonitor = this.part.FindModuleImplementing <WBIEfficiencyMonitor>(); if (extractionMonitor != null) { extractionMonitor.enabled = enableDrill; extractionMonitor.isEnabled = enableDrill; } //Update the drill if (enableDrill) { harvester.EnableModule(); } else { harvester.DisableModule(); } //Setup drill parameters if (enableDrill) { if (CurrentTemplate.HasValue("converterName")) { harvester.ConverterName = CurrentTemplate.GetValue("converterName"); } if (CurrentTemplate.HasValue("drillStartAction")) { harvester.StartActionName = CurrentTemplate.GetValue("drillStartAction"); harvester.Events["StartResourceConverter"].guiName = CurrentTemplate.GetValue("drillStartAction"); } if (CurrentTemplate.HasValue("drillStopAction")) { harvester.StopActionName = CurrentTemplate.GetValue("drillStopAction"); harvester.Events["StopResourceConverter"].guiName = CurrentTemplate.GetValue("drillStopAction"); } if (CurrentTemplate.HasValue("drillEficiency")) { harvester.Efficiency = float.Parse(CurrentTemplate.GetValue("drillEficiency")); } if (CurrentTemplate.HasValue("drillResource")) { resourceName = CurrentTemplate.GetValue("drillResource"); harvester.ResourceName = resourceName; harvester.Fields["ResourceStatus"].guiName = resourceName + " rate"; } if (CurrentTemplate.HasValue("drillElectricCharge")) { if (float.TryParse(CurrentTemplate.GetValue("drillElectricCharge"), out value)) { ResourceRatio[] inputRatios = harvester.inputList.ToArray(); for (int inputIndex = 0; inputIndex < inputRatios.Length; inputIndex++) { if (inputRatios[inputIndex].ResourceName == "ElectricCharge") { inputRatios[inputIndex].Ratio = value; } } } } harvester.Fields["status"].guiName = "Drill Status"; MonoUtilities.RefreshContextWindows(this.part); } }
public override void ToggleInflation() { if (CurrentTemplate.HasValue("requiredResource") == false || HighLogic.LoadedSceneIsEditor) { base.ToggleInflation(); return; } string requiredName = CurrentTemplate.GetValue("requiredResource"); string requiredAmount = CurrentTemplate.GetValue("requiredAmount"); float totalResources = (float)ResourceHelper.GetTotalResourceAmount(requiredName, this.part.vessel); if (string.IsNullOrEmpty(requiredAmount)) { base.ToggleInflation(); return; } float resourceCost = float.Parse(requiredAmount); calculateRemodelCostModifier(); float adjustedPartCost = resourceCost; if (reconfigureCostModifier > 0f) { adjustedPartCost *= reconfigureCostModifier; } //Do we pay for resources? If so, either pay the resources if we're deploying the module, or refund the recycled parts if (WBIMainSettings.PayToReconfigure) { //If we aren't deployed then see if we can afford to pay the resource cost. if (!isDeployed) { //Can we afford it? if (canAffordReconfigure(CurrentTemplateName, false) == false) { return; } //Do we have the skill? if (!hasSufficientSkill(CurrentTemplateName)) { return; } //Yup, we can afford it //Pay the reconfigure cost //reconfigureCost = adjustedPartCost; payPartsCost(CurrentTemplateIndex); // Toggle after payment. base.ToggleInflation(); } //We are deployed, calculate the amount of parts that can be refunded. else { // Toggle first in case deflate confirmation is needed, we'll check the state after the toggle. base.ToggleInflation(); //Recycle what we can. // deflateConfirmed's logic seems backward. if (!HasResources() || (HasResources() && deflateConfirmed == false)) { recoverResourceCost(requiredName, adjustedPartCost * recycleBase); } } } // Not paying for reconfiguration, check for skill requirements else { if (WBIMainSettings.RequiresSkillCheck) { if (hasSufficientSkill(CurrentTemplateName)) { base.ToggleInflation(); } else { return; } } else { base.ToggleInflation(); } } }