Exemplo n.º 1
0
        public void Dump()
        {
            if (log == null)
            {
                return;
            }

            log.AppendLine("Part count = ", allParts.Count);

            // Output a nice tree view of the rocket
            if (allParts.Count > 0)
            {
                PartSim root = allParts[0];
                while (root.parent != null)
                {
                    root = root.parent;
                }

                if (root.hasVessel)
                {
                    log.Append("vesselName = '", vesselName, "'  vesselType = ", SimManager.GetVesselTypeString(vesselType));
                }

                root.DumpPartToLog(log, "", allParts);
            }

            log.Flush();
        }
Exemplo n.º 2
0
        public void DumpPartToBuffer(StringBuilder buffer, String prefix, List <PartSim> allParts = null)
        {
            buffer.Append(prefix);
            buffer.Append(this.name);
            buffer.AppendFormat(":[id = {0:d}, decouple = {1:d}, invstage = {2:d}", this.partId, this.decoupledInStage, this.inverseStage);

            buffer.AppendFormat(", vesselName = '{0}'", this.vesselName);
            buffer.AppendFormat(", vesselType = {0}", SimManager.GetVesselTypeString(this.vesselType));
            buffer.AppendFormat(", initialVesselName = '{0}'", this.initialVesselName);

            buffer.AppendFormat(", fuelCF = {0}", this.fuelCrossFeed);
            buffer.AppendFormat(", noCFNKey = '{0}'", this.noCrossFeedNodeKey);

            buffer.AppendFormat(", isSep = {0}", this.isSepratron);

            for (int i = 0; i < this.resources.Types.Count; i++)
            {
                int type = this.resources.Types[i];
                buffer.AppendFormat(", {0} = {1:g6}", ResourceContainer.GetResourceName(type), this.resources[type]);
            }

            if (this.attachNodes.Count > 0)
            {
                buffer.Append(", attached = <");
                this.attachNodes[0].DumpToBuffer(buffer);
                for (int i = 1; i < this.attachNodes.Count; i++)
                {
                    buffer.Append(", ");
                    this.attachNodes[i].DumpToBuffer(buffer);
                }
                buffer.Append(">");
            }

            // Add more info here

            buffer.Append("]\n");

            if (allParts != null)
            {
                String newPrefix = prefix + " ";
                for (int i = 0; i < allParts.Count; i++)
                {
                    PartSim partSim = allParts[i];
                    if (partSim.parent == this)
                    {
                        partSim.DumpPartToBuffer(buffer, newPrefix, allParts);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Dump()
        {
            StringBuilder buffer = new StringBuilder(1024);

            buffer.AppendFormat("Part count = {0:d}\n", this.allParts.Count);

            // Output a nice tree view of the rocket
            if (this.allParts.Count > 0)
            {
                PartSim root = this.allParts[0];
                while (root.parent != null)
                {
                    root = root.parent;
                }

                if (root.hasVessel)
                {
                    buffer.AppendFormat("vesselName = '{0}'  vesselType = {1}\n", this.vesselName, SimManager.GetVesselTypeString(this.vesselType));
                }

                root.DumpPartToBuffer(buffer, "", this.allParts);
            }

            MonoBehaviour.print(buffer);
        }
Exemplo n.º 4
0
 void Awake()
 {
     Instance = this;
     DontDestroyOnLoad(this);
 }
Exemplo n.º 5
0
        public void CreateEngineSims(List <EngineSim> allEngines, double atmosphere, double mach, bool vectoredThrust, bool fullThrust, LogMsg log)
        {
            bool correctThrust = SimManager.DoesEngineUseCorrectedThrust(this.part);

            if (log != null)
            {
                log.buf.AppendLine("CreateEngineSims for " + this.name);
                for (int i = 0; i < this.part.Modules.Count; i++)
                {
                    PartModule partMod = this.part.Modules[i];
                    log.buf.AppendLine("Module: " + partMod.moduleName);
                }

                log.buf.AppendLine("correctThrust = " + correctThrust);
            }

            if (this.hasMultiModeEngine)
            {
                // A multi-mode engine has multiple ModuleEnginesFX but only one is active at any point
                // The mode of the engine is the engineID of the ModuleEnginesFX that is active
                string mode = this.part.GetModule <MultiModeEngine>().mode;

                List <ModuleEnginesFX> enginesFx = this.part.GetModules <ModuleEnginesFX>();
                for (int i = 0; i < enginesFx.Count; i++)
                {
                    ModuleEnginesFX engine = enginesFx[i];
                    if (engine.engineID == mode)
                    {
                        if (log != null)
                        {
                            log.buf.AppendLine("Module: " + engine.moduleName);
                        }

                        Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);

                        EngineSim engineSim = EngineSim.New(
                            this,
                            atmosphere,
                            mach,
                            engine.maxFuelFlow,
                            engine.minFuelFlow,
                            engine.thrustPercentage,
                            thrustvec,
                            engine.atmosphereCurve,
                            engine.atmChangeFlow,
                            engine.useAtmCurve ? engine.atmCurve : null,
                            engine.useVelCurve ? engine.velCurve : null,
                            engine.currentThrottle,
                            engine.g,
                            engine.throttleLocked || fullThrust,
                            engine.propellants,
                            engine.isOperational,
                            correctThrust,
                            engine.thrustTransforms);
                        allEngines.Add(engineSim);
                    }
                }
            }
            else
            {
                if (this.hasModuleEngines)
                {
                    List <ModuleEngines> engines = this.part.GetModules <ModuleEngines>();  // only place that still allocate some memory
                    for (int i = 0; i < engines.Count; i++)
                    {
                        ModuleEngines engine = engines[i];
                        if (log != null)
                        {
                            log.buf.AppendLine("Module: " + engine.moduleName);
                        }

                        Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);

                        EngineSim engineSim = EngineSim.New(
                            this,
                            atmosphere,
                            mach,
                            engine.maxFuelFlow,
                            engine.minFuelFlow,
                            engine.thrustPercentage,
                            thrustvec,
                            engine.atmosphereCurve,
                            engine.atmChangeFlow,
                            engine.useAtmCurve ? engine.atmCurve : null,
                            engine.useVelCurve ? engine.velCurve : null,
                            engine.currentThrottle,
                            engine.g,
                            engine.throttleLocked || fullThrust,
                            engine.propellants,
                            engine.isOperational,
                            correctThrust,
                            engine.thrustTransforms);
                        allEngines.Add(engineSim);
                    }
                }
            }

            if (log != null)
            {
                log.Flush();
            }
        }