public static PartSim New(Part thePart, int id, double atmosphere, LogMsg log) { PartSim partSim = pool.Borrow(); Reset(partSim); partSim.part = thePart; partSim.centerOfMass = thePart.transform.TransformPoint(thePart.CoMOffset); partSim.partId = id; partSim.name = partSim.part.partInfo.name; if (log != null) { log.buf.AppendLine("Create PartSim for " + partSim.name); } partSim.parent = null; partSim.parentAttach = partSim.part.attachMode; partSim.fuelCrossFeed = partSim.part.fuelCrossFeed; partSim.noCrossFeedNodeKey = partSim.part.NoCrossFeedNodeKey; partSim.decoupledInStage = partSim.DecoupledInStage(partSim.part); partSim.isFuelLine = partSim.part.HasModule <CModuleFuelLine>(); partSim.isFuelTank = partSim.part is FuelTank; partSim.isSepratron = partSim.IsSepratron(); partSim.inverseStage = partSim.part.inverseStage; //MonoBehaviour.print("inverseStage = " + inverseStage); partSim.cost = partSim.part.GetCostWet(); // Work out if the part should have no physical significance partSim.isNoPhysics = partSim.part.HasModule <LaunchClamp>() || partSim.part.physicalSignificance == Part.PhysicalSignificance.NONE || partSim.part.PhysicsSignificance == 1; if (!partSim.isNoPhysics) { partSim.baseMass = partSim.part.mass; } if (SimManager.logOutput) { MonoBehaviour.print((partSim.isNoPhysics ? "Ignoring" : "Using") + " part.mass of " + partSim.part.mass); } for (int i = 0; i < partSim.part.Resources.Count; i++) { PartResource resource = partSim.part.Resources[i]; // Make sure it isn't NaN as this messes up the part mass and hence most of the values // This can happen if a resource capacity is 0 and tweakable if (!Double.IsNaN(resource.amount)) { if (SimManager.logOutput) { MonoBehaviour.print(resource.resourceName + " = " + resource.amount); } partSim.resources.Add(resource.info.id, resource.amount); partSim.resourceFlowStates.Add(resource.info.id, resource.flowState ? 1 : 0); } else { MonoBehaviour.print(resource.resourceName + " is NaN. Skipping."); } } partSim.startMass = partSim.GetMass(); partSim.hasVessel = (partSim.part.vessel != null); partSim.isLanded = partSim.hasVessel && partSim.part.vessel.Landed; if (partSim.hasVessel) { partSim.vesselName = partSim.part.vessel.vesselName; partSim.vesselType = partSim.part.vesselType; } partSim.initialVesselName = partSim.part.initialVesselName; partSim.hasMultiModeEngine = partSim.part.HasModule <MultiModeEngine>(); partSim.hasModuleEnginesFX = partSim.part.HasModule <ModuleEnginesFX>(); partSim.hasModuleEngines = partSim.part.HasModule <ModuleEngines>(); partSim.isEngine = partSim.hasMultiModeEngine || partSim.hasModuleEnginesFX || partSim.hasModuleEngines; if (SimManager.logOutput) { MonoBehaviour.print("Created " + partSim.name + ". Decoupled in stage " + partSim.decoupledInStage); } return(partSim); }