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


C# Part.AddModule方法代码示例

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


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

示例1: addRootPart

        void addRootPart(Part root)
        {
            //Debug.Log (String.Format ("[EL GUI] root: {0}", root));
            buildCost = new BuildCost ();
            buildCost.addPart (root);

            ExShipInfoEventCatcher ec = (ExShipInfoEventCatcher)root.AddModule ("ExShipInfoEventCatcher");
            ec.shipinfo = this;
        }
开发者ID:GlassFragments,项目名称:Extraplanetary-Launchpads,代码行数:9,代码来源:ShipInfo.cs

示例2: addPart

        void addPart(Part part)
        {
            Debug.Log (String.Format ("[EL GUI] attach: {0}", part));
            buildCost.addPart (part);
            var ship = EditorLogic.fetch.ship;
            parts_count = ship.parts.Count;

            ExShipInfoEventCatcher ec = (ExShipInfoEventCatcher)part.AddModule ("ExShipInfoEventCatcher");
            ec.shipinfo = this;
        }
开发者ID:GlassFragments,项目名称:Extraplanetary-Launchpads,代码行数:10,代码来源:ShipInfo.cs

示例3: AttachCollector

        void AttachCollector(Part toPart) {
            toPart.AddModule("ModuleExhaustCapture");

            ModuleExhaustCapture newModule = toPart.FindModuleImplementing<ModuleExhaustCapture>();
            ModuleResource outPutRes = new ModuleResource();
            
            if (primaryResourceName != null && primaryResourceRate != 0 && PartResourceLibrary.Instance.resourceDefinitions.Contains(primaryResourceName)) 
            {
           
                outPutRes.name = primaryResourceName;
                outPutRes.id = PartResourceLibrary.Instance.GetDefinition(primaryResourceName).id; //Do I need this       
                outPutRes.rate = primaryResourceRate*thrustMultiplier;
           
                newModule.outputResources.Add(outPutRes);
                print("PZER: Capture " + outPutRes.name + " " + outPutRes.id + " added with a real rate of " + outPutRes.rate * thrustMultiplier);
            }
            else
            {
                 print("PZER: " + part.partName + " has bad primary resource/rate: " + primaryResourceName +" rate: " + primaryResourceRate);
            }

            
            
            if (secondaryResourceName != null && secondaryResourceRate != 0 && PartResourceLibrary.Instance.resourceDefinitions.Contains(secondaryResourceName)) {


                outPutRes.name = secondaryResourceName;
                 
                outPutRes.id = PartResourceLibrary.Instance.GetDefinition(secondaryResourceName).id; //see above       
                outPutRes.rate = secondaryResourceRate * thrustMultiplier;

  
                newModule.outputResources.Add(outPutRes);

                print("PZER: Secondary capture " + outPutRes.name + " " + outPutRes.id + " added with a real rate of " + outPutRes.rate * thrustMultiplier);
            }
            else
            
            {
                print("PZER: " + part.partName + " has bad secondary resource/rate: " + secondaryResourceName + " rate: " + secondaryResourceRate);
            }


            

            newModule.heatIncrease = (float)additionalHeatRate;



        }
开发者ID:PalverZ,项目名称:PalverZExhaustRecycler,代码行数:50,代码来源:ExhuastRecycler.cs

示例4: PartUnpacked

        public void PartUnpacked(Part part)
        {
            if (HighLogic.LoadedSceneIsFlight == false)
                return;

            WBIExtractionMonitor extractionMonitor = null;

            if (part.FindModuleImplementing<ModuleResourceHarvester>() == null)
                return;

            //Add an extraction monitor if needed.
            extractionMonitor = part.FindModuleImplementing<WBIExtractionMonitor>();
            if (extractionMonitor == null)
            {
                extractionMonitor = (WBIExtractionMonitor)part.AddModule("WBIExtractionMonitor");
                extractionMonitor.OnActive();
                extractionMonitor.OnStart(PartModule.StartState.Landed);
                extractionMonitor = null;
            }
        }
开发者ID:PalverZ,项目名称:Pathfinder,代码行数:20,代码来源:WBIDrillManager.cs

示例5: AddPartModule

        private void AddPartModule(Part part)
        {
            try
            {
                if (!part.Modules.Contains("LifeSupportModule"))
                {
                    Debug.Log("TAC missing!");

                    ConfigNode node = new ConfigNode("MODULE");
                    node.AddValue("name", "LifeSupportModule");

                    part.AddModule(node);
                }
                else
                {
                    Debug.Log("TAC already there!");
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("TAC Life Support (AddLifeSupport) [" + this.GetInstanceID().ToString("X") + "][" + Time.time
                    + "]: Failed to add the part module: " + ex.Message + "\n" + ex.StackTrace);
            }
        }
开发者ID:NathanKell,项目名称:TacLifeSupport,代码行数:24,代码来源:AddLifeSupport.cs

示例6: AddLaunchClampReinforcementModule

 public static void AddLaunchClampReinforcementModule(Part p)
 {
     p.AddModule("KJRLaunchClampReinforcementModule");
     (p.Modules["KJRLaunchClampReinforcementModule"] as KJRLaunchClampReinforcementModule).OnPartUnpack();
     if (debug)
         Debug.Log("Added KJRLaunchClampReinforcementModule to part " + p.partInfo.title);
 }
开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:7,代码来源:KJRJointUtils.cs

示例7: AddDecouplerJointReinforcementModule

 public static void AddDecouplerJointReinforcementModule(Part p)
 {
     p.AddModule("KJRDecouplerReinforcementModule");
     (p.Modules["KJRDecouplerReinforcementModule"] as KJRDecouplerReinforcementModule).OnPartUnpack();
     if (debug)
         Debug.Log("Added KJRDecouplerReinforcementModule to part " + p.partInfo.title);
 }
开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:7,代码来源:KJRJointUtils.cs

示例8: EvaAddPartModule

        private void EvaAddPartModule(Part part)
        {
            try
            {
                ConfigNode node = new ConfigNode("MODULE");
                node.AddValue("name", "LifeSupportModule");

                part.AddModule(node);
            }
            catch (Exception ex)
            {
                this.LogError("Error adding the part module to EVA (expected?): " + ex.Message + "\n" + ex.StackTrace);
            }
        }
开发者ID:xxApvxx,项目名称:TacLifeSupport,代码行数:14,代码来源:AddLifeSupport.cs

示例9: AddPartModule

        private void AddPartModule(Part part)
        {
            try
            {
                if (!part.Modules.Contains("LifeSupportModule"))
                {
                    this.Log("The LifeSupportModule is missing!");

                    ConfigNode node = new ConfigNode("MODULE");
                    node.AddValue("name", "LifeSupportModule");

                    part.AddModule(node);
                }
                else
                {
                    this.Log("The LifeSupportModule is already there.");
                }
            }
            catch (Exception ex)
            {
                this.LogError("Error adding the Part Module (expected?): " + ex.Message + "\n" + ex.StackTrace);
            }
        }
开发者ID:xxApvxx,项目名称:TacLifeSupport,代码行数:23,代码来源:AddLifeSupport.cs

示例10: InstantiateHandler

            private static bool InstantiateHandler(ConfigNode node, Part ourPart, out Func<string, object> handlerFunction)
            {
                handlerFunction = null;
                var handlerConfiguration = new ConfigNode("MODULE");
                node.CopyTo(handlerConfiguration);
                string moduleName = node.GetValue("name");
                string methodName = node.GetValue("method");

                // Since we're working with part modules here, and starting in a pod config,
                // we'll keep one instance per pod, which will let them instantiate with their own config if needed.
                MonoBehaviour thatModule = null;
                foreach (PartModule potentialModule in ourPart.Modules)
                {
                    if (potentialModule.ClassName == moduleName)
                    {
                        thatModule = potentialModule;
                        break;
                    }
                }
                if (thatModule == null)
                {
                    try
                    {
                        thatModule = ourPart.AddModule(handlerConfiguration);
                    }
                    catch
                    {
                        JUtil.LogErrorMessage(null, "Caught exception when trying to instantiate module '{0}'. Something's fishy here", moduleName);
                    }
                }
                if (thatModule == null)
                {
                    JUtil.LogMessage(null, "Warning, variable handler module \"{0}\" could not be loaded. This could be perfectly normal.", moduleName);
                    return false;
                }
                foreach (MethodInfo m in thatModule.GetType().GetMethods())
                {
                    if (m.Name == node.GetValue("method"))
                    {
                        try
                        {
                            handlerFunction = (Func<string, object>)Delegate.CreateDelegate(typeof(Func<string, object>), thatModule, m);
                        }
                        catch
                        {
                            JUtil.LogErrorMessage(null, "Error, incorrect variable handler configuration for module {0}", moduleName);
                            return false;
                        }
                        break;
                    }
                }
                return true;
            }
开发者ID:ndevenish,项目名称:RasterPropMonitor,代码行数:53,代码来源:VariableHandler.cs

示例11: addUsageModulesToPart

        public static void addUsageModulesToPart(Part part)
        {
            // list of modules to add as a string
            string addModules = "";

            // check part resources
            foreach (PartResource resource in part.Resources)
            {
                // electric batteries (ignore empty batts, probably alternator)
                if (resource.resourceName == "ElectricCharge" &&
                    resource.maxAmount > 0.0 && resource.hideFlow == false)
                {
                    addModules += "usageBatteries;";
                }
            }

            // check part modules
            bool addUsagePods = (part.CrewCapacity > 0);
            foreach (PartModule module in part.Modules)
            {
                // add engine usage
                if (module is ModuleEngines)
                {
                    addModules += "usageEngines;";
                }
                // add gimbal usage
                else if (module is ModuleGimbal)
                {
                    addModules += "usageGimbal;";
                }
                // add crewed command pod usage
                else if (module is ModuleCommand)
                {
                    addModules += "usagePods;";
                    addUsagePods = false;
                }
                // add crewed command pod usage
                else if (module is ModuleReactionWheel)
                {
                    addModules += "usageReactionWheels;";
                }
            }

            // add other modules based on part parameters
            if (addUsagePods)
            {
                addModules += "usagePods;";
            }

            // add generic time usage (aging) for unknown part if no other modules were added
            if (addModules.Length == 0)
            {
                KerbalGUIManager.print("Adding usageGeneric to " + part.partInfo.name);
                part.AddModule("usageGeneric");
            }

            // add known modules
            else
            {
                string[] modulesIds = addModules.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries);
                foreach (string moduleId in modulesIds)
                {
                    KerbalGUIManager.print("Adding " + moduleId + " to " + part.partInfo.name);
                    part.AddModule(moduleId);
                }
            }
        }
开发者ID:MartynasStropa,项目名称:KSP_rusty,代码行数:67,代码来源:rustyPartModules.cs

示例12: Attach

    private bool Attach(Part part)
    {
        bool attached = false;
        List<string> toAttach = new List<string>();

        //		print("scanning " + part.name + " for needed attachments");
        foreach (PartModule pm in part.Modules)
        {
            foreach (Attachment attach in attachments.FindAll(a => a.attachTo == pm.moduleName && !part.Modules.Contains(a.moduleName)))
            {
                if (attach.RestrictionsMet(part))
                {
                    toAttach.Add(attach.moduleName);
                }
            }
        }

        foreach (string a in toAttach)
        {
            print("Attaching " + a + " to " + part.name);
            var pm = part.AddModule(a);
            attached = true;
        }

        return attached;
    }
开发者ID:BloodyRain2k,项目名称:ModuleAttacher,代码行数:26,代码来源:ModuleAttacher.cs

示例13: canDamage

 private bool canDamage(Part p)
 {
     if(hasModule(p, "ModuleGimbal")) {
         // engine gimbal damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleEngines")) {
         // engine damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleParachute")) {
         // parachute damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleDecouple") || hasModule(p, "ModuleAnchoredDecoupler")) {
         // decoupler damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleDockingNode")) {
         // docking port damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(p.Resources.Count > 0) {
         // fuel tank damage
         Debug.Log("Found a fuel tank");
         addPartModule(p, "DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleResourceIntake")) {
         // intake damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleWheel")) {
         // wheel damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleEnviroSensor")) {
         // sensor damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleDeployableSolarPanel")) {
         // solar panel damage
         p.AddModule("DamageTestModule");
         return true;
     }
     if(hasModule(p, "ModuleGenerator")) {
         // generator damage
         p.AddModule("DamageTestModule");
         return true;
     }
     return false;
 }
开发者ID:jbengtson,项目名称:ksp-partfailure,代码行数:60,代码来源:PartFailure.cs

示例14: addPartModule

 private void addPartModule(Part p, string module)
 {
     try {
         ConfigNode node = new ConfigNode("MODULE");
         node.AddValue("name", module);
         p.AddModule(node);
     } catch(Exception e) {
         Debug.Log("PartDamage: Failed to add PartModule" + module + "--> " + e.Message + "\n" + e.StackTrace);
     }
 }
开发者ID:jbengtson,项目名称:ksp-partfailure,代码行数:10,代码来源:PartFailure.cs

示例15: EvaAddPartModule

        private void EvaAddPartModule(Part part)
        {
            try
            {
                ConfigNode node = new ConfigNode("MODULE");
                node.AddValue("name", "LifeSupportModule");

                part.AddModule(node);

                this.LogWarning("The expected exception did not happen when adding the Life Support part module to the EVA!");
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Object reference not set"))
                {
                    this.Log("Adding life support to the EVA part succeeded as expected.");
                }
                else
                {
                    this.LogError("Unexpected error while adding the Life Support part module to the EVA: " + ex.Message + "\n" + ex.StackTrace);
                }
            }
        }
开发者ID:VenVen,项目名称:TacLifeSupport,代码行数:23,代码来源:AddLifeSupport.cs


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