/// <summary> /// Create an InventoryPart from an origin ConfigNode, extracting the name, dry cost, and relevant MODULEs /// </summary> /// <param name="originPartConfigNode">The <see cref="ConfigNode"/> to use as the basis of the <see cref="InventoryPart"/>.</param> public InventoryPart(ConfigNode originPartConfigNode) { _name = ConfigNodeUtils.PartNameFromNode(originPartConfigNode); float fuelCost; AvailablePart availablePartForNode = ConfigNodeUtils.AvailablePartFromNode(originPartConfigNode); if (availablePartForNode != null) { float dryMass, fuelMass; ShipConstruction.GetPartCostsAndMass(originPartConfigNode, availablePartForNode, out _dryCost, out fuelCost, out dryMass, out fuelMass); } if (originPartConfigNode.HasNode("MODULE")) { foreach (ConfigNode module in originPartConfigNode.GetNodes("MODULE")) { foreach (string trackedModuleName in ScrapYard.Instance.Settings.TrackedModules) { if (module.GetValue("name").ToUpper().Contains(trackedModuleName)) { savedModules.Add(module); } } } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (part.partInfo == null) { // Loading of the prefab from the part config _updateHitpoints = true; } else { // Loading of the part from a saved craft if (HighLogic.LoadedSceneIsEditor) { _updateHitpoints = true; } else // Loading of the part from a craft in flight mode { if (BDArmorySettings.RESET_HP && part.vessel != null) // Reset Max HP { var maxHPString = ConfigNodeUtils.FindPartModuleConfigNodeValue(part.partInfo.partConfig, "HitpointTracker", "maxHitPoints"); if (!string.IsNullOrEmpty(maxHPString)) // Use the default value from the MM patch. { try { maxHitPoints = float.Parse(maxHPString); if (BDArmorySettings.DRAW_DEBUG_LABELS) { Debug.Log("[BDArmory.HitPointTracker]: setting maxHitPoints of " + part + " on " + part.vessel.vesselName + " to " + maxHitPoints); } _updateHitpoints = true; } catch (Exception e) { Debug.LogError("[BDArmory.HitPointTracker]: Failed to parse maxHitPoints configNode: " + e.Message); } } else // Use the stock default value. { maxHitPoints = 0f; } } else // Don't. { enabled = false; } } } }
/// <summary> /// Create an InventoryPart from an origin ConfigNode, extracting the name, dry cost, and relevant MODULEs /// </summary> /// <param name="originPartConfigNode">The <see cref="ConfigNode"/> to use as the basis of the <see cref="InventoryPart"/>.</param> public InventoryPart(ConfigNode originPartConfigNode) { //if the ConfigNode given is already an InventoryPart, just load it instead if (originPartConfigNode.name == typeof(InventoryPart).FullName) { State = originPartConfigNode; } else { _name = ConfigNodeUtils.PartNameFromNode(originPartConfigNode); if (ScrapYard.Instance.Settings.PartBlacklist.Contains(Name)) { DoNotStore = true; } AvailablePart availablePartForNode = ConfigNodeUtils.AvailablePartFromNode(originPartConfigNode); if (availablePartForNode != null) { float dryMass, fuelMass, fuelCost; ShipConstruction.GetPartCostsAndMass(originPartConfigNode, availablePartForNode, out _dryCost, out fuelCost, out dryMass, out fuelMass); } if (originPartConfigNode.HasNode("MODULE")) { foreach (ConfigNode module in originPartConfigNode.GetNodes("MODULE")) { string name = module.GetValue("name"); bool isTracker = name.Equals("ModuleSYPartTracker"); _allModules.Add(module); if (isTracker) { TrackerModule = new TrackerModuleWrapper(module); } } } uint id = 0; if (originPartConfigNode.TryGetValue("persistentId", ref id)) { ID = id; } else { Logging.Log($"Could not find a persistent ID for part {_name}", Logging.LogType.ERROR); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (part.partInfo != null) { if (HighLogic.LoadedSceneIsEditor) { FBSetup(null, null); } else { if (part.vessel != null) { var SSTString = ConfigNodeUtils.FindPartModuleConfigNodeValue(part.partInfo.partConfig, "ModuleSelfSealingTank", "SSTank"); if (!string.IsNullOrEmpty(SSTString)) { try { SSTank = bool.Parse(SSTString); FBSetup(null, null); } catch (Exception e) { Debug.LogError("[ModuleSelfSealingTank]: Exception parsing SSTank: " + e.Message); } } else { SSTank = false; } } else { enabled = false; } } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (part.partInfo != null) { if (HighLogic.LoadedSceneIsEditor) { CASESetup(null, null); } else { if (part.vessel != null) { var CASEString = ConfigNodeUtils.FindPartModuleConfigNodeValue(part.partInfo.partConfig, "ModuleCASE", "CASELevel"); if (!string.IsNullOrEmpty(CASEString)) { try { CASELevel = float.Parse(CASEString); CASESetup(null, null); } catch (Exception e) { Debug.LogError("[ModuleCASE]: Exception parsing CASELevel: " + e.Message); } } else { CASELevel = 0f; } } else // Don't. { enabled = false; } } } }