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


C# Part.IsLaunchClamp方法代码示例

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


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

示例1: AssignDecoupledInStage

        // Determine when this part will be decoupled given when its parent will be decoupled.
        // Then recurse to all of this part's children.
        public void AssignDecoupledInStage(Part p, Dictionary<Part, FuelNode> nodeLookup, int parentDecoupledInStage)
        {
            if (p.IsUnfiredDecoupler() || p.IsLaunchClamp())
            {
                decoupledInStage = p.inverseStage > parentDecoupledInStage ? p.inverseStage : parentDecoupledInStage;
            }
            else
            {
                decoupledInStage = parentDecoupledInStage;
            }

            isSepratron = isEngine && (inverseStage == decoupledInStage);

            for (int i = 0; i < p.children.Count; i++)
            {
                Part child = p.children[i];
                nodeLookup[child].AssignDecoupledInStage(child, nodeLookup, decoupledInStage);
            }
        }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:21,代码来源:FuelFlowSimulation.cs

示例2: Init

        private void Init(Part part, bool dVLinearThrust)
        {
            resources.Clear();
            resourceConsumptions.Clear();
            resourceDrains.Clear();
            freeResources.Clear();

            propellantRatios.Clear();
            propellantFlows.Clear();

            fuelLineSources.Clear();
            stackNodeSources.Clear();
            surfaceMountSources.Clear();

            surfaceMountParent = null;
            isEngine = false;

            dryMass = 0;
            fairingMass = 0;

            moduleMass = 0;
            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.GetModuleMassNoAlloc(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)
                {
                    if (r.flowState)
                    {
                        resources[r.info.id] = (float)r.amount;
                    }
                    else
                    {
                        dryMass += (float)(r.amount * r.info.density); // disabled resources are just dead weight
                    }
                }
                if (r.info.name == "IntakeAir")
                    freeResources[PartResourceLibrary.Instance.GetDefinition("IntakeAir").id] = true;
                // Those two are in the CRP.
                if (r.info.name == "IntakeLqd")
                    freeResources[PartResourceLibrary.Instance.GetDefinition("IntakeLqd").id] = true;
                if (r.info.name == "IntakeAtm")
                    freeResources[PartResourceLibrary.Instance.GetDefinition("IntakeAtm").id] = true;
            }

            // 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);
            ModuleEngines engine = null;
            for (int i = 0; i < part.Modules.Count; i++)
            {
                PartModule pm = part.Modules[i];
                ModuleEngines e = pm as ModuleEngines;
                if (e != null && e.isEnabled)
                {
                    engine = e;
                    break;
                }
            }

            if (engine != null)
            {
                //Only count engines that either are ignited or will ignite in the future:
                if ((HighLogic.LoadedSceneIsEditor || inverseStage < StageManager.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 < StageManager.CurrentStage)
                        inverseStage = StageManager.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.thrustTransformMultipliers[i];
                        }

                        Vector3d fwd = HighLogic.LoadedScene == GameScenes.EDITOR ? EditorLogic.VesselRotation * Vector3d.up : engine.part.vessel.GetTransform().up;
                        fwdThrustRatio = Vector3.Dot(fwd, thrust);
//.........这里部分代码省略.........
开发者ID:BloodyRain2k,项目名称:MechJeb2,代码行数:101,代码来源:FuelFlowSimulation.cs

示例3: 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

示例4: AssignDecoupledInStage


//.........这里部分代码省略.........
                        {
                            attach = p.findAttachNode(mAnchoredDecoupler.explosiveNodeID);
                        }
                        else
                        {
                            attach = p.srfAttachNode;
                        }
                        
                        if (attach != null && attach.attachedPart != null)
                        {
                            if (attach.attachedPart == p.parent)
                            {
                                isDecoupler = true;
                                // We are decoupling our parent
                                // The part and its children are not part of the ship when we decouple
                                decoupledInStage = p.inverseStage;
                                //print("AssignDecoupledInStage ModuleAnchoredDecoupler " + p.partInfo.name + "(" + p.inverseStage + ") decoupling " + attach.attachedPart + "(" + attach.attachedPart.inverseStage + "). parent " + decoupledInStage);

                                // The parent should already have its info assigned at this point
                                //nodeLookup[p.parent].AssignDecoupledInStage(p.parent, nodeLookup, p.inverseStage);
                            }
                            else
                            {
                                isDecoupler = true;
                                // We are still attached to our parent
                                // The part and it's children are dropped when the parent is
                                decoupledInStage = parentDecoupledInStage;

                                //print("AssignDecoupledInStage ModuleAnchoredDecoupler " + p.partInfo.name + "(" + p.inverseStage + ") decoupling " + attach.attachedPart + "(" + attach.attachedPart.inverseStage + "). not the parent " + decoupledInStage);
                                // The part we decouple is dropped when we decouple
                                nodeLookup[attach.attachedPart].AssignDecoupledInStage(attach.attachedPart, nodeLookup, p.inverseStage);
                            }
                        }
                        break;
                    }
                }

                ModuleDockingNode mDockingNode = m as ModuleDockingNode;
                if (mDockingNode != null)
                {
                    if (mDockingNode.staged && mDockingNode.stagingEnabled && p.stagingOn)
                    {
                        Part attachedPart = mDockingNode.referenceNode.attachedPart;
                        if (attachedPart != null)
                        {
                            if (attachedPart == p.parent)
                            {
                                isDecoupler = true;
                                // We are decoupling our parent
                                // The part and its children are not part of the ship when we decouple
                                decoupledInStage = p.inverseStage;

                                // The parent should already have its info assigned at this point
                                //nodeLookup[p.parent].AssignDecoupledInStage(p.parent, nodeLookup, p.inverseStage);
                            }
                            else
                            {
                                isDecoupler = true;
                                decoupledInStage = parentDecoupledInStage;
                                //childDecoupledInStage = parentDecoupledInStage;
                                nodeLookup[attachedPart].AssignDecoupledInStage(attachedPart, nodeLookup, p.inverseStage);
                            }
                        }
                    }
                    break;
                }

                if (m.moduleName == "ProceduralFairingDecoupler")
                {
                    if (!m.Fields["decoupled"].GetValue<bool>(m) && m.stagingEnabled && p.stagingOn)
                    {
                        isDecoupler = true;
                        // We are decoupling our parent
                        // The part and its children are not part of the ship when we decouple
                        decoupledInStage = p.inverseStage;
                        break;
                    }
                }
            }

            if (p.IsLaunchClamp())
            {
                decoupledInStage = p.inverseStage > parentDecoupledInStage ? p.inverseStage : parentDecoupledInStage;
                //print("AssignDecoupledInStage D " + p.partInfo.name + " " + parentDecoupledInStage);

            }
            else if (!isDecoupler)
            {
                decoupledInStage = parentDecoupledInStage;
                //print("AssignDecoupledInStage                         " + p.partInfo.name + "(" + p.inverseStage + ")" + decoupledInStage);
            }
            
            isSepratron = isEngine && (inverseStage == decoupledInStage);

            for (int i = 0; i < p.children.Count; i++)
            {
                Part child = p.children[i];
                nodeLookup[child].AssignDecoupledInStage(child, nodeLookup, decoupledInStage);
            }
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:FuelFlowSimulation.cs


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