Engineer.VesselSimulator.PartSim.PartSim C# (CSharp) Method

PartSim() public method

public PartSim ( Part thePart, int id, double atmosphere, LogMsg log ) : System
thePart Part
id int
atmosphere double
log LogMsg
return System
        public PartSim(Part thePart, int id, double atmosphere, LogMsg log)
        {
            part = thePart;
            partId = id;
            name = part.partInfo.name;

            if (log != null)
                log.buf.AppendLine("Create PartSim for " + name);

            parent = null;
            parentAttach = part.attachMode;
            fuelCrossFeed = part.fuelCrossFeed;
            noCrossFeedNodeKey = part.NoCrossFeedNodeKey;
            decoupledInStage = DecoupledInStage(part);
            isFuelLine = part is FuelLine;
            isFuelTank = part is FuelTank;
            isSepratron = IsSepratron();
            inverseStage = part.inverseStage;
            //MonoBehaviour.print("inverseStage = " + inverseStage);

            cost = part.partInfo.cost;
            foreach (PartResource resource in part.Resources)
            {
                cost -= (float)((resource.maxAmount - resource.amount) * resource.info.unitCost);
            }

            // Work out if the part should have no physical significance
            isNoPhysics = part.HasModule<LaunchClamp>() ||
                            part.physicalSignificance == Part.PhysicalSignificance.NONE ||
                            part.PhysicsSignificance == 1;

            if (!isNoPhysics)
                baseMass = part.mass;

            if (SimManager.logOutput)
                MonoBehaviour.print((isNoPhysics ? "Ignoring" : "Using") + " part.mass of " + part.mass);

            foreach (PartResource resource in part.Resources)
            {
                // 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);

                    resources.Add(resource.info.id, resource.amount);
                    resourceFlowStates.Add(resource.info.id, resource.flowState ? 1 : 0);
                }
                else
                {
                    MonoBehaviour.print(resource.resourceName + " is NaN. Skipping.");
                }
            }

            startMass = GetMass();

            hasVessel = (part.vessel != null);
            isLanded = hasVessel && part.vessel.Landed;
            if (hasVessel)
            {
                vesselName = part.vessel.vesselName;
                vesselType = part.vesselType;
            }
            initialVesselName = part.initialVesselName;

            hasMultiModeEngine = part.HasModule<MultiModeEngine>();
            hasModuleEnginesFX = part.HasModule<ModuleEnginesFX>();
            hasModuleEngines = part.HasModule<ModuleEngines>();

            isEngine = hasMultiModeEngine || hasModuleEnginesFX || hasModuleEngines;

            if (SimManager.logOutput)
                MonoBehaviour.print("Created " + name + ". Decoupled in stage " + decoupledInStage);
        }