public void SwitchTemplateType(string templateName) { Log("SwitchTemplateType called."); //Update symmetry parts if ((HighLogic.LoadedSceneIsFlight && storageView.updateSymmetry) || HighLogic.LoadedSceneIsEditor) { int templateIndex = templateManager.FindIndexOfTemplate(templateName); UpdateSymmetry(templateIndex); } //Can we use the index? EInvalidTemplateReasons reasonCode = templateManager.CanUseTemplate(templateName); if (reasonCode == EInvalidTemplateReasons.TemplateIsValid) { //If we require specific skills to perform the reconfigure, do we have sufficient skill to reconfigure it? if (WBIMainSettings.RequiresSkillCheck) { if (hasSufficientSkill(templateName) == false) { return; } } //If we have to pay to reconfigure the module, then do our checks. if (WBIMainSettings.PayToReconfigure) { //Can we afford it? if (canAffordReconfigure(templateName) == false) { return; } //Yup, we can afford it //Pay the reconfigure cost payPartsCost(templateManager.FindIndexOfTemplate(templateName)); } //Update contents UpdateContentsAndGui(templateName); return; } switch (reasonCode) { case EInvalidTemplateReasons.InvalidIndex: ScreenMessages.PostScreenMessage("Cannot find a suitable template.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.TechNotUnlocked: ScreenMessages.PostScreenMessage("More research is required to switch to the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; default: ScreenMessages.PostScreenMessage("Could not switch the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; } }
public void SwitchTemplateType(string templateName) { Log("SwitchTemplateType called."); //Can we use the index? EInvalidTemplateReasons reasonCode = templatesModel.CanUseTemplate(templateName); if (reasonCode == EInvalidTemplateReasons.TemplateIsValid) { //If we require specific skills to perform the reconfigure, do we have sufficient skill to reconfigure it? if (checkForSkill) { if (hasSufficientSkill(templateName) == false) { return; } } //If we have to pay to reconfigure the module, then do our checks. if (payForReconfigure) { //Can we afford it? if (canAffordReconfigure(templateName) == false) { return; } //Yup, we can afford it //Pay the reconfigure cost payPartsCost(); } //Update contents UpdateContentsAndGui(templateName); return; } switch (reasonCode) { case EInvalidTemplateReasons.InvalidIndex: ScreenMessages.PostScreenMessage("Cannot find a suitable template.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.TechNotUnlocked: ScreenMessages.PostScreenMessage("More research is required to switch to the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; default: ScreenMessages.PostScreenMessage("Could not switch the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; } }
public EInvalidTemplateReasons SwitchModuleType(string templateName) { //Can we use the index? EInvalidTemplateReasons reasonCode = mksTemplates.CanUseTemplate(templateName); if (reasonCode == EInvalidTemplateReasons.TemplateIsValid) { UpdateContentsAndGui(templateName); return(reasonCode); } switch (reasonCode) { case EInvalidTemplateReasons.InvalidIndex: ScreenMessages.PostScreenMessage("Cannot find a suitable template.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.ModuleHasCrew: ScreenMessages.PostScreenMessage("Remove crew before redecorating.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.NoFactory: ScreenMessages.PostScreenMessage("You need a Fabricator or Factory Model to remodel this module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.NotEnoughParts: ScreenMessages.PostScreenMessage("You don't have enough parts to remodel.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; case EInvalidTemplateReasons.TechNotUnlocked: ScreenMessages.PostScreenMessage("More research is required to switch to the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; default: ScreenMessages.PostScreenMessage("Could not switch the module.", 5.0f, ScreenMessageStyle.UPPER_CENTER); break; } return(reasonCode); }
public void FilterTemplates() { List <ConfigNode> templates = new List <ConfigNode>(); string[] potentialTemplates = templateNodeName.Split(new char[] { ';' }); ConfigNode[] templateConfigs; foreach (string potentialTemplate in potentialTemplates) { templateConfigs = GameDatabase.Instance.GetConfigNodes(potentialTemplate); if (templateConfigs == null) { continue; } //Find valid templates foreach (ConfigNode config in templateConfigs) { EInvalidTemplateReasons templateReason = CanUseTemplate(config); if (templateReason == EInvalidTemplateReasons.TemplateIsValid) { templates.Add(config); } } } //Done this.templateNodes = templates.ToArray(); Log(templateNodeName + " has " + templates.Count + " templates."); ConfigNode node; for (int index = 0; index < this.templateNodes.Length; index++) { node = this.templateNodes[index]; Log("Template " + index + ": " + node.GetValue("name")); } }