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


C# Part.GetModule方法代码示例

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


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

示例1: PartSim

        public PartSim(Part part, double atmosphere)
        {
            this.part = part;

            foreach (PartResource resource in part.Resources)
            {
                resources.Add(resource.info.id, resource.amount);
            }

            if (this.part.HasModule<MultiModeEngine>())
            {
                string mode = this.part.GetModule<MultiModeEngine>().mode;

                foreach (ModuleEnginesFX engine in this.part.GetModules<ModuleEnginesFX>())
                {
                    if (engine.engineID == mode)
                    {
                        if (part.vessel != null)
                        {
                            actualThrust = engine.requestedThrust;
                            isp = engine.atmosphereCurve.Evaluate((float)part.staticPressureAtm);
                        }
                        else
                        {
                            isp = engine.atmosphereCurve.Evaluate((float)atmosphere);
                        }

                        thrust = engine.maxThrust * (engine.thrustPercentage / 100f);
                    }
                }
            }
            else if (this.part.HasModule<ModuleEngines>())
            {
                ModuleEngines engine = part.GetModule<ModuleEngines>();

                if (part.vessel != null)
                {
                    actualThrust = engine.requestedThrust;
                    isp = engine.atmosphereCurve.Evaluate((float)part.staticPressureAtm);
                }
                else
                {
                    isp = engine.atmosphereCurve.Evaluate((float)atmosphere);
                }

                thrust = engine.maxThrust * (engine.thrustPercentage / 100f);
            }

            decoupledInStage = DecoupledInStage();
        }
开发者ID:jclapis,项目名称:Engineer,代码行数:50,代码来源:PartSim.cs

示例2: GetVisibleParts

        /// <summary>
        /// Gets a list of parts that have
        /// </summary>
        /// <returns></returns>
        private static List<Part> GetVisibleParts(Part part, ref List<Part> visibleParts)
        {
            ModuleFreeIva iva = part.GetModule<ModuleFreeIva>();
            if (iva != null)
            {
                if (!visibleParts.Contains(part))
                    visibleParts.Add(part);

                for (int i = 0; i < iva.Hatches.Count; i++)
                {
                    Hatch h = iva.Hatches[i];

                    if (h.IsOpen && h.ConnectedHatch != null && h.ConnectedHatch.IsOpen &&
                        h.ConnectedHatch.Part != null && !visibleParts.Contains(h.ConnectedHatch.Part))
                        visibleParts.AddRange(GetVisibleParts(h.ConnectedHatch.Part, ref visibleParts));
                }
            }

            return visibleParts;
        }
开发者ID:Charon77,项目名称:FreeIVA,代码行数:24,代码来源:FreeIva.cs

示例3: IsDecoupler

        private bool IsDecoupler(Part thePart)
        {
            PartExtensions.ProtoModuleDecoupler protoDecoupler = thePart.GetProtoModuleDecoupler();
            if (protoDecoupler != null && protoDecoupler.IsStageEnabled)
                return true;

            ModuleDockingNode modDock = thePart.GetModule<ModuleDockingNode>();
            if (modDock != null && modDock.IsStageable())
                return true;

            return false;
        }
开发者ID:CYBUTEK,项目名称:KerbalEngineer,代码行数:12,代码来源:PartSim.cs

示例4: SetupFuelLineSourcesEditor

 public void SetupFuelLineSourcesEditor(Part part, Dictionary<Part, FuelNode> nodeLookup)
 {
     // In the editor scene, fuel lines have to inform their targets that they
     // are valid fuel sources (and in the editor docking nodes attach via regular stack nodes,
     // so they need no special treatment).
     CModuleFuelLine fuelLine = part.GetModule<CModuleFuelLine>();
     if (fuelLine != null && fuelLine.target != null)
     {
         FuelNode targetNode;
         if (nodeLookup.TryGetValue(fuelLine.target, out targetNode))
             targetNode.fuelLineSources.Add(this);
     }
 }
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:13,代码来源:FuelFlowSimulation.cs

示例5: update_state

 void update_state()
 {
     try
     {
         //get asteroid hatch
         var hatch = entrance.ConnectedPartWithModule<SingleUseGrappleNode>();
         grapple_node = hatch.GetModule<SingleUseGrappleNode>();
         storage = hatch.GetModule<HangarStorageDynamic>();
         if(grapple_node == null || storage == null) throw new Exception();
         //get asteroid
         asteroid = hatch.AttachedPartWithModule<ModuleAsteroid>();
         asteroid_info = asteroid.GetModule<AsteroidInfo>();
         if(!asteroid_info.AsteroidIsUsable)
         {
             ScreenMessager.showMessage(6, "This asteroid is used by Asteroid Recycling machinery.\n" +
                 "Mining it is prohibited for safety reasons.");
             throw new Exception();
         }
     }
     catch
     {
         asteroid = null;
         asteroid_info = null;
         grapple_node = null;
         storage = null;
         dM_buffer = 0;
         if(pump != null)
             pump.Clear();
     }
     Converting &= can_convert();
     update_events();
 }
开发者ID:pjslauta,项目名称:hangar,代码行数:32,代码来源:AsteroidMassConverter.cs

示例6: SetupOnTransform

        public static Part SetupOnTransform(Vessel original_vessel, Part original_part, 
		                                    Transform debris_transform, 
		                                    float density, float cost, double lifetime)
        {
            //get the part form DB
            var info = PartLoader.getPartInfoByName(DEBRIS_PART);
            if(info == null) return null;
            var part = (Part)Instantiate(info.partPrefab);
            //set part's transform and parent the debris to the part
            part.transform.position = debris_transform.position;
            part.transform.rotation = original_part.transform.rotation;
            debris_transform.parent = part.transform.GetChild(0);
            debris_transform.localPosition = Vector3.zero;
            //initialize the part
            part.gameObject.SetActive(true);
            part.physicalSignificance = Part.PhysicalSignificance.NONE;
            part.PromoteToPhysicalPart();
            part.rigidbody.SetDensity(density);
            part.mass   = part.rigidbody.mass;
            part.orgPos = Vector3.zero;
            part.orgRot = Quaternion.identity;
            //set part's velocities
            part.rigidbody.angularVelocity = original_part.rigidbody.angularVelocity;
            part.rigidbody.velocity = original_part.rigidbody.velocity +
                Vector3.Cross(original_vessel.CurrentCoM - original_part.rigidbody.worldCenterOfMass,
                              part.rigidbody.angularVelocity);
            //initialize Debris module
            var debris = part.GetModule<Debris>();
            if(debris == null)
            {
                Utils.Log("WARNING: {0} part does not have Debris module!", DEBRIS_PART);
                Destroy(part.gameObject); return null;
            }
            debris.saved_cost = cost;
            debris.original_part_name = original_part.partInfo.name;
            debris.debris_transform_name = debris_transform.name;
            debris.model = debris_transform;
            debris.local_rotation = debris_transform.localRotation;
            var resizer = original_part.GetModule<HangarPartResizer>();
            if(resizer != null)
            {
                debris.size = resizer.size/resizer.orig_size;
                debris.aspect = resizer.aspect;
            }
            //initialize the vessel
            var vessel = part.gameObject.AddComponent<Vessel>();
            vessel.name = vessel.vesselName = "Debris";
            vessel.id = Guid.NewGuid();
            vessel.Initialize();
            //setup ids and flag
            part.flightID = original_part.flightID;
            part.missionID = original_part.missionID;
            part.launchID = original_part.launchID;
            part.flagURL = original_part.flagURL;
            //setup discovery info
            vessel.DiscoveryInfo.SetLastObservedTime(Planetarium.GetUniversalTime());
            vessel.DiscoveryInfo.SetUnobservedLifetime(lifetime);
            vessel.DiscoveryInfo.SetUntrackedObjectSize(UntrackedObjectClass.A);
            vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned);
            //inform the game about the new vessel
            GameEvents.onNewVesselCreated.Fire(vessel);
            //return the part
            return part;
        }
开发者ID:pjslauta,项目名称:hangar,代码行数:64,代码来源:HangarFairings.cs


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