当前位置: 首页>>代码示例>>C#>>正文


C# Part.GetModuleMass方法代码示例

本文整理汇总了C#中Part.GetModuleMass方法的典型用法代码示例。如果您正苦于以下问题:C# Part.GetModuleMass方法的具体用法?C# Part.GetModuleMass怎么用?C# Part.GetModuleMass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.GetModuleMass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: printMassInfo

 void printMassInfo(Part part)
 {
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("part", GUILayout.Width (w));
         GUILayout.Label (part.partInfo.name);
     }
     GUILayout.EndHorizontal ();
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("mass", GUILayout.Width (w));
         GUILayout.Label (part.mass.ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
     var m = part.partInfo.partPrefab.mass;
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("p. mass", GUILayout.Width (w));
         GUILayout.Label (m.ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("module", GUILayout.Width (w));
         GUILayout.Label (part.GetModuleMass (m).ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("resource", GUILayout.Width (w));
         GUILayout.Label (part.GetResourceMass ().ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("childs", GUILayout.Width (w));
         GUILayout.Label (part.GetPhysicslessChildMassInEditor ().ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
     GUILayout.BeginHorizontal ();
     {
         GUILayout.Label ("total", GUILayout.Width (w));
         GUILayout.Label (part.GetTotalMass ().ToString ("F3"));
     }
     GUILayout.EndHorizontal ();
 }
开发者ID:FormalRiceFarmer,项目名称:KerbalMods,代码行数:46,代码来源:MenuDebug.cs

示例2: FuelNode

        public float moduleMass; // for debugging

        public FuelNode(Part part, bool dVLinearThrust)
        {
            if (!part.IsLaunchClamp())
            {
                //print(part.partInfo.name.PadRight(25) + " " + part.mass.ToString("F4") + " " + part.GetPhysicslessChildMass().ToString("F4") + " " + part.GetModuleMass(part.partInfo.partPrefab.mass).ToString("F4"));
                dryMass = part.mass; // Intentionally ignore the physic flag.

                moduleMass = part.GetModuleMass(part.partInfo.partPrefab != null ? part.partInfo.partPrefab.mass : dryMass);
                if (part.HasModule<ModuleProceduralFairing>())
                {
                    fairingMass = moduleMass;
                }
            }

            inverseStage = part.inverseStage;
            partName = part.partInfo.name;

            //note which resources this part has stored
            for (int i = 0; i < part.Resources.Count; i++)
            {
                PartResource r = part.Resources[i];
                if (r.info.density > 0 && r.info.name != "IntakeAir")
                {
                    if (r.flowState)
                    {
                        resources[r.info.id] = (float) r.amount;
                    }
                    else
                    {
                        dryMass += (float) (r.amount*r.info.density); // disabled resources are just dead weight
                    }
                }
            }

            // TODO : handle the multiple active ModuleEngine case ( SXT engines with integrated vernier )

            //record relevant engine stats
            ModuleEngines engine = part.Modules.OfType<ModuleEngines>().FirstOrDefault(e => e.isEnabled);
            if (engine != null)
            {
                //Only count engines that either are ignited or will ignite in the future:
                if ((HighLogic.LoadedSceneIsEditor || inverseStage < Staging.CurrentStage || engine.getIgnitionState) && (engine.thrustPercentage > 0 || engine.minThrust > 0))
                {
                    //if an engine has been activated early, pretend it is in the current stage:
                    if (engine.getIgnitionState && inverseStage < Staging.CurrentStage)
                        inverseStage = Staging.CurrentStage;

                    isEngine = true;

                    g = engine.g;

                    // If we take into account the engine rotation
                    if (dVLinearThrust)
                    {
                        Vector3 thrust = Vector3d.zero;
                        for (int i = 0; i < engine.thrustTransforms.Count; i++)
                        {
                            thrust -= engine.thrustTransforms[i].forward/engine.thrustTransforms.Count;
                        }

                        Vector3d fwd = HighLogic.LoadedScene == GameScenes.EDITOR ? EditorLogic.VesselRotation * Vector3d.up : engine.part.vessel.GetTransform().up;
                        fwdThrustRatio = Vector3.Dot(fwd, thrust);
                    }

                    thrustPercentage = engine.thrustPercentage;

                    minFuelFlow = engine.minFuelFlow;
                    maxFuelFlow = engine.maxFuelFlow;

                    atmosphereCurve = new FloatCurve(engine.atmosphereCurve.Curve.keys);
                    atmChangeFlow = engine.atmChangeFlow;
                    useAtmCurve = engine.useAtmCurve;
                    if (useAtmCurve)
                        atmCurve = new FloatCurve(engine.atmCurve.Curve.keys);
                    useVelCurve = engine.useVelCurve;
                    if (useAtmCurve)
                        velCurve = new FloatCurve(engine.velCurve.Curve.keys);

                    propellantSumRatioTimesDensity = engine.propellants.Where(prop => !prop.ignoreForIsp).Sum(prop => prop.ratio * MuUtils.ResourceDensity(prop.id));
                    propellantRatios = engine.propellants.Where(prop => MuUtils.ResourceDensity(prop.id) > 0 && !prop.ignoreForIsp ).ToDictionary(prop => prop.id, prop => prop.ratio);
                }
            }
        }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:85,代码来源:FuelFlowSimulation.cs

示例3: PartInfo

 protected void PartInfo(Part part)
 {
     Vector3 com;
     part.GetCoM (out com);
     GUILayout.Label (string.Format (
         "phy: {0} rb: {1} m: {2:F3}t cm: {3:F3}t\n" +
         "pm: {4:F3}t rm: {5:F3} mm: {6:F3}t\n" +
         "com: {7}\n" +
         "max_drag: {8:F3} AreaDrag: {9:F3}\n" +
         "dvector: {10}",
         part.physicalSignificance,
         part.rb != null,
         part.GetTotalMass (),
         part.GetPhysicslessChildMassInEditor (),
         part.mass,
         part.GetResourceMass (),
         part.GetModuleMass (part.mass),
         com,
         part.maximum_drag,
         part.DragCubes.AreaDrag,
         part.DragCubes.DragVector
     ));
     var engines = part.FindModulesImplementing<ModuleEngines> ();
     foreach(var engine in engines) {
         GUILayout.Label ("<b>ModuleEngine</b> " + engine.engineID);
         GUILayout.Label (string.Format (
             "min thrust: {0} max thrust: {1}\n" +
             "vac isp: {2} asl isp: {3}",
             engine.minThrust, engine.maxThrust,
             engine.atmosphereCurve.Evaluate (0f),
             engine.atmosphereCurve.Evaluate (1f)));
     }
     var enginesfx = part.FindModulesImplementing<ModuleEnginesFX> ();
     foreach(var engine in enginesfx) {
         GUILayout.Label ("<b>ModuleEngineFX</b> " + engine.engineID);
         GUILayout.Label (string.Format (
             "min thrust: {0} max thrust: {1}\n" +
             "vac isp: {2} asl isp: {3}",
             engine.minThrust, engine.maxThrust,
             engine.atmosphereCurve.Evaluate (0f),
             engine.atmosphereCurve.Evaluate (1f)));
     }
 }
开发者ID:FormalRiceFarmer,项目名称:KerbalMods,代码行数:43,代码来源:MenuDebug.cs


注:本文中的Part.GetModuleMass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。