public void RebuildList() { buildCost = null; parts_count = 0; var ship = EditorLogic.fetch.ship; if (ship.parts.Count > 0) { Part root = ship.parts[0]; buildCost = new BuildCost(); addPart(root); foreach (Part p in root.GetComponentsInChildren <Part>()) { if (p != root) { addPart(p); } } } }
public BuildCost.CostReport getBuildCost(ConfigNode craft) { ShipConstruct ship = new ShipConstruct(); ship.LoadShip(craft); GameObject ro = ship.parts[0].localRoot.gameObject; Vessel dummy = ro.AddComponent <Vessel>(); dummy.Initialize(true); craftResources = new VesselResources(dummy); BuildCost resources = new BuildCost(); foreach (Part p in ship.parts) { resources.addPart(p); } dummy.Die(); return(resources.cost); }