// specifics support public Specifics Specs() { Specifics specs = new Specifics(); if (redundancy.Length > 0) { specs.Add("Redundancy", redundancy); } specs.Add("Repair", new CrewSpecs(repair).Info()); specs.Add(string.Empty); specs.Add("<color=#00ffff>Standard quality</color>"); specs.Add("MTBF", Lib.HumanReadableDuration(mtbf)); specs.Add(string.Empty); specs.Add("<color=#00ffff>High quality</color>"); specs.Add("MTBF", Lib.HumanReadableDuration(mtbf * Settings.QualityScale)); if (extra_cost > double.Epsilon) { specs.Add("Extra cost", Lib.HumanReadableCost(extra_cost * part.partInfo.cost)); } if (extra_mass > double.Epsilon) { specs.Add("Extra mass", Lib.HumanReadableMass(extra_mass * part.partInfo.partPrefab.mass)); } return(specs); }
public void generate_details(Configure cfg) { // If a setup component is defined after the Configure module in the ConfigNode, // then it is not present in the part during Configure::OnLoad (at precompilation time) // so, find_module() will fail in that situation, resulting in no component details // being added to the Configure window. Therefore we are forced to generate the details // at first use every time the module is loaded, instead of generating them only once. // already generated if (details != null) { return; } // generate module details details = new List <Detail>(); foreach (ConfigureModule cm in modules) { // find module, skip if it doesn't exist PartModule m = cfg.find_module(cm); if (m == null) { continue; } // get title IModuleInfo module_info = m as IModuleInfo; string title = module_info != null?module_info.GetModuleTitle() : cm.type; if (title.Length == 0) { continue; } // get specs, skip if not implemented by module ISpecifics specifics = m as ISpecifics; if (specifics == null) { continue; } Specifics specs = specifics.Specs(); if (specs.entries.Count == 0) { continue; } // add title to details details.Add(new Detail(Lib.BuildString("<b><color=#00ffff>", title, "</color></b>"))); // add specs to details foreach (Specifics.Entry e in specs.entries) { details.Add(new Detail(e.label, e.value)); } } // get visible resources subset List <ConfigureResource> visible_resources = resources.FindAll(k => Lib.GetDefinition(k.name).isVisible); // generate resource details if (visible_resources.Count > 0) { // add resources title details.Add(new Detail("<b><color=#00ffff>Resources</color></b>")); // for each visible resource foreach (ConfigureResource cr in visible_resources) { // add capacity info details.Add(new Detail(cr.name, Lib.Parse.ToDouble(cr.maxAmount).ToString("F2"))); } } // generate extra details if (mass > double.Epsilon || cost > double.Epsilon) { details.Add(new Detail("<b><color=#00ffff>Extra</color></b>")); if (mass > double.Epsilon) { details.Add(new Detail("mass", Lib.HumanReadableMass(mass))); } if (cost > double.Epsilon) { details.Add(new Detail("cost", Lib.HumanReadableCost(cost))); } } }
// specifics support public Specifics Specs() { Specifics specs = new Specifics(); if (redundancy.Length > 0) { specs.Add("Redundancy", redundancy); } specs.Add("Repair", new CrewSpecs(repair).Info()); specs.Add(string.Empty); specs.Add("<color=#00ffff>Standard quality</color>"); if (mtbf > 0) { specs.Add("MTBF", Lib.HumanReadableDuration(EffectiveMTBF(false, mtbf))); } if (turnon_failure_probability > 0) { specs.Add("Ignition failures", Lib.HumanReadablePerc(turnon_failure_probability, "F1")); } if (rated_operation_duration > 0) { specs.Add("Rated burn duration", Lib.HumanReadableDuration(EffectiveDuration(false, rated_operation_duration))); } if (rated_ignitions > 0) { specs.Add("Rated ignitions", EffectiveIgnitions(false, rated_ignitions).ToString()); } if (mtbf > 0 && rated_radiation > 0) { specs.Add("Radiation rating", Lib.HumanReadableRadiation(rated_radiation / 3600.0)); } specs.Add(string.Empty); specs.Add("<color=#00ffff>High quality</color>"); if (extra_cost > double.Epsilon) { specs.Add("Extra cost", Lib.HumanReadableCost(extra_cost * part.partInfo.cost)); } if (extra_mass > double.Epsilon) { specs.Add("Extra mass", Lib.HumanReadableMass(extra_mass * part.partInfo.partPrefab.mass)); } if (mtbf > 0) { specs.Add("MTBF", Lib.HumanReadableDuration(EffectiveMTBF(true, mtbf))); } if (turnon_failure_probability > 0) { specs.Add("Ignition failures", Lib.HumanReadablePerc(turnon_failure_probability / Settings.QualityScale, "F1")); } if (rated_operation_duration > 0) { specs.Add("Rated burn duration", Lib.HumanReadableDuration(EffectiveDuration(true, rated_operation_duration))); } if (rated_ignitions > 0) { specs.Add("Rated ignitions", EffectiveIgnitions(true, rated_ignitions).ToString()); } if (mtbf > 0 && rated_radiation > 0) { specs.Add("Radiation rating", Lib.HumanReadableRadiation(Settings.QualityScale * rated_radiation / 3600.0)); } return(specs); }