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


C# PartModule.GetType方法代码示例

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


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

示例1: IntegratedIntakeEngineCrossSectionAdjuster

        public IntegratedIntakeEngineCrossSectionAdjuster(PartModule intake, Matrix4x4 worldToVesselMatrix)
        {
            this.part = intake.part;
            //ModuleResourceIntake intake = intake;

            Type intakeType = intake.GetType();
            intakeTrans = (Transform)intakeType.GetField("intakeTransform", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(intake);

            vehicleBasisForwardVector = Vector3.forward;//intakeTrans.forward;

            if (intakeTrans == null)
                intakeTrans = intake.part.partTransform;

            foreach (AttachNode node in part.attachNodes)
                if(node.nodeType == AttachNode.NodeType.Stack && Vector3.Dot(node.position, (part.transform.worldToLocalMatrix * intakeTrans.localToWorldMatrix).MultiplyVector(Vector3.forward)) > 0)
                {
                    frontNode = node;
                    break;
                }

            thisToVesselMatrix = worldToVesselMatrix * intakeTrans.localToWorldMatrix;

            vehicleBasisForwardVector = thisToVesselMatrix.MultiplyVector(vehicleBasisForwardVector);

            intakeArea = (float)intakeType.GetField("Area").GetValue(intake);
        }
开发者ID:boniboni,项目名称:Ferram-Aerospace-Research,代码行数:26,代码来源:IntegratedIntakeEngineCrossSectionAdjuster.cs

示例2: Construct

        public static ScienceExperimentFields Construct(PartModule mod, SharedObjects shared)
        {
            var typeName = mod.GetType().Name;
            var baseTypeName = mod.GetType().BaseType.Name;

            if (baseTypeName.Contains(DMBASICSCIENCEMODULE) || typeName.Contains(DMASTEROIDSCANNER))
            {
                return new DMScienceExperimentFields(mod, shared);
            }
            else if (typeName.Contains(DMBATHYMETRY))
            {
                return new DMBathymetryFields(mod as ModuleScienceExperiment, shared);
            }
            else if (typeName.Contains(DMSCIENCEANIMATE) || baseTypeName.Contains(DMSCIENCEANIMATE))
            {
                return new DMModuleScienceAnimateFields(mod as ModuleScienceExperiment, shared);
            }

            return null;
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:20,代码来源:DMOrbitalScienceFieldsFactory.cs

示例3: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            if (state != PartModule.StartState.Editor)
            {
                anims = part.FindModelAnimators(animationName);
                if ((anims == null) || (anims.Length == 0))
                {
                    print("ModuleAnimation2Value - animation not found: " + animationName);
                }

                moduleType = part.GetType();
                if (valueModule != "")
                {
                    if (part.Modules.Contains(valueModule))
                    {
                        module = part.Modules[valueModule];
                        moduleType = module.GetType();
                    }
                    else
                    {
                        print("ModuleAnimation2Value - module not found: " + valueModule);
                    }
                }

                field = moduleType.GetField(valueName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
                if (field == null)
                {
                    property = moduleType.GetProperty(valueName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
                    if (property == null)
                    {
                        print("ModuleAnimation2Value - field/property not found: " + valueName);
                    }
                }
                if ((anims != null) && (anims.Length > 0) && ((field != null) || (property != null)))
                {
                    // Check to see if our part contains the Firespitter module FSwheel
                    if (part.Modules.Contains("FSwheel"))
                    {
                        FSwheel = part.Modules["FSwheel"];
                        if (FSwheel != null)
                            fswType = FSwheel.GetType ();
                        // Check to see if our animation is the same as the one used by FSwheel
                        if (animationName == (string)fswType.GetField ("animationName").GetValue (FSwheel))
                            fswHack = true;
                    }
                }
            }

            base.OnStart(state);
        }
开发者ID:NathanKell,项目名称:DeadlyReentry,代码行数:50,代码来源:ModuleAnimation2Value.cs

示例4: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            if (state != PartModule.StartState.Editor)
            {
                anims = part.FindModelAnimators(animationName);
                if ((anims == null) || (anims.Length == 0))
                {
                    print("ModuleAnimation2Value - animation not found: " + animationName);
                }

                moduleType = part.GetType();
                if (valueModule != "")
                {
                    if (part.Modules.Contains(valueModule))
                    {
                        module = part.Modules[valueModule];
                        moduleType = module.GetType();
                    }
                    else
                    {
                        print("ModuleAnimation2Value - module not found: " + valueModule);
                    }
                }

                field = moduleType.GetField(valueName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
                if (field == null)
                {
                    property = moduleType.GetProperty(valueName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
                    if (property == null)
                    {
                        print("ModuleAnimation2Value - field/property not found: " + valueName);
                    }
                }
            }

            base.OnStart(state);
        }
开发者ID:r4m0n,项目名称:KSP_DeadlyReentry,代码行数:37,代码来源:ModuleAnimation2Value.cs

示例5: SetConfiguration

        public virtual void SetConfiguration(string newConfiguration = null, bool resetTechLevels = false)
        {
            if (newConfiguration == null)
                newConfiguration = configuration;

            ConfigSaveLoad();

            ConfigNode newConfig = configs.Find (c => c.GetValue ("name").Equals (newConfiguration));
            if (!UnlockedConfig(newConfig, part))
            {
                if(newConfig == null)
                    Debug.Log("*RFMEC* ERROR Can't find configuration " + newConfiguration + ", falling back to first tech-available config.");

                foreach(ConfigNode cfg in configs)
                    if (UnlockedConfig(cfg, part))
                    {
                        newConfig = cfg;
                        newConfiguration = cfg.GetValue("name");
                        break;
                    }
            }
            if (newConfig != null)
            {
                if (configuration != newConfiguration && resetTechLevels)
                    techLevel = origTechLevel;

                // for asmi
                if (useConfigAsTitle)
                    part.partInfo.title = configuration;

                configuration = newConfiguration;
                config = new ConfigNode("MODULE");
                newConfig.CopyTo(config);
                config.name = "MODULE";

            #if DEBUG
                print ("replacing " + type + " with:");
                print (newConfig.ToString ());
            #endif

                pModule = null;
                // get correct module
                pModule = GetSpecifiedModule(part, engineID, moduleIndex, type, useWeakType);

                if ((object)pModule == null)
                {
                    Debug.Log("*RFMEC* Could not find appropriate module of type " + type + ", with ID=" + engineID + " and index " + moduleIndex);
                    return;
                }

                Type mType = pModule.GetType();
                config.SetValue("name", mType.Name);

                // clear all FloatCurves we need to clear (i.e. if our config has one, or techlevels are enabled)
                bool delAtmo = config.HasNode("atmosphereCurve") || techLevel >= 0;
                bool delDens = config.HasNode("atmCurve") || techLevel >= 0;
                bool delVel = config.HasNode("velCurve") || techLevel >= 0;
                foreach (FieldInfo field in mType.GetFields())
                {
                    if (field.FieldType == typeof(FloatCurve) &&
                        ((field.Name.Equals("atmosphereCurve") && delAtmo)
                        || (field.Name.Equals("atmCurve") && delDens)
                        || (field.Name.Equals("velCurve") && delVel)))
                    {
                        field.SetValue(pModule, new FloatCurve());
                    }
                }
                // clear propellant gauges
                foreach (FieldInfo field in mType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    if (field.FieldType == typeof(Dictionary<Propellant, VInfoBox>))
                    {
                        Dictionary<Propellant, VInfoBox> boxes = (Dictionary<Propellant, VInfoBox>)(field.GetValue(pModule));
                        if (boxes == null)
                            continue;
                        foreach (VInfoBox v in boxes.Values)
                        {
                            if (v == null) //just in case...
                                continue;
                            try
                            {
                                part.stackIcon.RemoveInfo(v);
                            }
                            catch (Exception e)
                            {
                                Debug.Log("*RFMEC* Trying to remove info box: " + e.Message);
                            }
                        }
                        boxes.Clear();
                    }
                }
                if (type.Equals("ModuleRCS") || type.Equals("ModuleRCSFX"))
                {
                    ModuleRCS rcs = (ModuleRCS)pModule;
                    if (rcs != null)
                    {
                        DoConfig(config);
                        if (config.HasNode("PROPELLANT"))
                        {
                            rcs.propellants.Clear();
//.........这里部分代码省略.........
开发者ID:qipa,项目名称:ModularFuelSystem,代码行数:101,代码来源:ModuleEngineConfigs.cs

示例6: OnAwake

 public override void OnAwake()
 {
     base.OnAwake();
     if (part && part.Modules != null) // thanks, FlowerChild!
     {
         is_engine = (part.Modules.Contains("ModuleEngines") || part.Modules.Contains("ModuleEnginesFX"));
         is_eva = part.Modules.Contains("KerbalEVA");
         if (part.Modules.Contains("ModuleParachute"))
             parachute = (ModuleParachute)part.Modules["ModuleParachute"];
         if (part.Modules.Contains("RealChuteModule"))
         {
             realChute = part.Modules["RealChuteModule"];
             rCType = realChute.GetType();
         }
     }
 }
开发者ID:siav8,项目名称:ksp-gamedata,代码行数:16,代码来源:DeadlyReentry.cs

示例7: IntakeCrossSectionAdjuster

        public IntakeCrossSectionAdjuster(PartModule intake, Matrix4x4 worldToVesselMatrix)
        {
            this.part = intake.part;
            intakeModule = intake as ModuleResourceIntake;
            intakeTrans = intakeModule.intakeTransform;

            if (!string.IsNullOrEmpty(intakeModule.occludeNode))
                node = intakeModule.node; 
            
            foreach (AttachNode candidateNode in part.attachNodes)
                if (candidateNode.nodeType == AttachNode.NodeType.Stack && Vector3.Dot(candidateNode.position, (part.transform.worldToLocalMatrix * intakeTrans.localToWorldMatrix).MultiplyVector(Vector3.forward)) > 0)
                {
                    if (candidateNode == node)
                        continue;

                    nodeOffsetArea = candidateNode.size;
                    if (nodeOffsetArea == 0)
                        nodeOffsetArea = 0.5;

                    nodeOffsetArea *= 0.625;     //scale it up as needed
                    nodeOffsetArea *= nodeOffsetArea;
                    nodeOffsetArea *= Math.PI;  //calc area;

                    nodeOffsetArea *= -1;        //and the adjustment area
                    break;
                }

            thisToVesselMatrix = worldToVesselMatrix * intakeTrans.localToWorldMatrix;

            vehicleBasisForwardVector = Vector3.forward;
            vehicleBasisForwardVector = thisToVesselMatrix.MultiplyVector(vehicleBasisForwardVector);

            Type intakeType = intake.GetType();
            intakeArea = (float)intakeType.GetField("Area").GetValue(intake);
        }
开发者ID:cupsster,项目名称:Ferram-Aerospace-Research,代码行数:35,代码来源:IntakeCrossSectionAdjuster.cs

示例8: dumpPartModule

        public static void dumpPartModule(PartModule pm)
        {
            AAprint ("pm: " + pm.moduleName);
            AAprint ("pm.enabled: " + pm.enabled.ToString () + "/" + pm.isEnabled);
            AAprint ("pm.gettype: " + pm.GetType ().ToString ());
            if (pm.moduleName == "CModuleFuelLine") {
                AAprint ("FUEL LINE!");
                CompoundPart cp = (CompoundPart)pm.part;
                if (cp.target == null) {
                    print ("target is null");
                } else {
                    printPart ("target", cp.target);
                }

            }
        }
开发者ID:henrybauer,项目名称:AutoAsparagus,代码行数:16,代码来源:ASPConsoleStuff.cs

示例9: EngageChute

 //============================================================================================================================================
 public void EngageChute()
 {
     //FAR Compatibility =)
     if (assemblyFARUsed == true) {
         foreach (Part EnabledPart in EnabledPartList) {
             if (EnabledPart.Modules.Contains ("RealChuteFAR")) {
                 //FerramAerospaceResearch.RealChuteLite.RealChuteFAR RCF = new FerramAerospaceResearch.RealChuteLite.RealChuteFAR ();
                 //RCF = EnabledPart.FindModuleImplementing<FerramAerospaceResearch.RealChuteLite.RealChuteFAR> ();
                 ChuteFARModuleReference = EnabledPart.Modules ["RealChuteFAR"];
                 PropertyInfo ChuteFARModuleDeploymentState = ChuteFARModuleReference.GetType().GetProperty("deploymentState");
                 RoboBrakes_ParaEnabledCount++;
                 ChuteFARDeploymentString = ChuteFARModuleReference.Fields.GetValue ("depState").ToString ();
                 //Repack if Chute was already Cut
                 if ((ChuteFARDeploymentString == "CUT") && (IsLanded == false) && (RoboBrakes_CHUTEAUTO == true)) {
                     //Bypassing RealChutes Repacking Method so we don't have to EVA - Also we can't set 'canRepack' bool as it is read only :-/
                     ChuteFARModuleDeploymentState.SetValue(ChuteFARModuleReference, 1, null);
                     ChuteFARModuleReference.part.Effect ("rcrepack");
                     ChuteFARModuleReference.part.stackIcon.SetIconColor (XKCDColors.White);
                     ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("PACKED", 1);
                     ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("RCDEPLOYED", 0);
                     print ("ROBOBRAKES - RealChute " + EnabledPart.name + " was already Cut! Repacked Automatically!");
                 }
                 //Deploy Chute
                 if ((RoboBrakes_CHUTEREADY == true && RoboBrakes_CHUTEAUTO == true)) {
                     RoboBrakes_CHUTEREADY = false;
                     //Deploy Real Chute
                     ChuteFARModuleReference.SendMessage("ActivateRC");
                 }
                 //Repack Chute Automatically
                 if (ChuteFARDeploymentString == "DEPLOYED" | ChuteFARDeploymentString == "PREDEPLOYED") {
                     if (RoboBrakes_CUTCHUTE == true) {
                         RoboBrakes_CUTCHUTE = false;
                         //Cut Real Chute
                         ChuteFARModuleReference.SendMessage("Cut");
                         //Bypassing RealChutes Repacking Method so we don't have to EVA - Also we can't set 'canRepack' bool as it is read only :-/
                         ChuteFARModuleDeploymentState.SetValue(ChuteFARModuleReference, 1, null);
                         ChuteFARModuleReference.part.Effect ("rcrepack");
                         ChuteFARModuleReference.part.stackIcon.SetIconColor (XKCDColors.White);
                         ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("PACKED", 1);
                         ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("RCDEPLOYED", 0);
                         print ("ROBOBRAKES - RealChute " + EnabledPart.name + " was Cut & Repacked Automatically!");
                     }
                 }
             }
         }
     }
     foreach (Part EnabledPart in EnabledPartList) {
         //Module Parachutes
         //---------------------------------------------------------------------------------------------------------------------
         if (EnabledPart.Modules.Contains ("ModuleParachute")) {
             ModuleParachute MPA = new ModuleParachute ();
             MPA = EnabledPart.FindModuleImplementing<ModuleParachute> ();
             RoboBrakes_ParaEnabledCount++;
             //Repack the Chute automatically if it has been manually cut
             if ((MPA.deploymentState.Equals (ModuleParachute.deploymentStates.CUT)) && (IsLanded == false) && (RoboBrakes_CHUTEAUTO == true)) {
                 MPA.Repack ();
                 print ("ROBOBRAKES - Chute " + EnabledPart.name + " was already Cut! Repacked Automatically!");
             }
             //Deploy Chute
             if ((RoboBrakes_AUTOMATICBRAKE_ACTIVE == true && RoboBrakes_CHUTEAUTO == true)) {
                 if (RoboBrakes_CHUTEREADY == true) {
                     RoboBrakes_CHUTEREADY = false;
                     MPA.Deploy ();
                 }
             }
             //Repack Chute
             if (MPA.deploymentState.Equals (ModuleParachute.deploymentStates.DEPLOYED)) {
                 if (RoboBrakes_CUTCHUTE == true) {
                     RoboBrakes_CUTCHUTE = false;
                     MPA.CutParachute ();
                     MPA.Repack ();
                     print ("ROBOBRAKES - Chute " + EnabledPart.name + " was Cut & Repacked Automatically!");
                 }
             }
         }
     }
 }
开发者ID:wrcsubers,项目名称:RoboBrakes,代码行数:78,代码来源:RoboBrakesMono.cs

示例10: PartModuleModuleToIndex

 //return index count of specific partmodule type only, not of entire part.modules list. Used in save routine
 public static int PartModuleModuleToIndex(PartModule pm, PartModuleList pmList)
 {
     try
     {
         List<PartModule> pmListThisType = new List<PartModule>();
         foreach (PartModule pm2 in pmList)
         {
             if (pm2.GetType().Name == pm.GetType().Name)
             {
                 pmListThisType.Add(pm2);
             }
         }
         return pmListThisType.IndexOf(pm);
     }
     catch
     {
         Debug.Log("AGX SavePMIndex Fail, using default");
         return 0;
     }
 }
开发者ID:Kerbas-ad-astra,项目名称:AGExt,代码行数:21,代码来源:CommonMethods.cs

示例11: createUpdater

 private static IRescalable createUpdater(PartModule module)
 {
     if (module is IRescalable)
     {
         return module as IRescalable;
     }
     if (ctors.ContainsKey(module.GetType()))
     {
         return ctors[module.GetType()](module);
     }
     return null;
 }
开发者ID:kevin-ye,项目名称:TweakScale,代码行数:12,代码来源:Updater.cs

示例12: SetConfiguration

        public virtual void SetConfiguration(string newConfiguration = null)
        {
            if (newConfiguration == null)
                newConfiguration = configuration;
            ConfigNode newConfig = configs.Find (c => c.GetValue ("name").Equals (newConfiguration));
            if (newConfig != null) {

                // for asmi
                if (useConfigAsTitle)
                    part.partInfo.title = configuration;

                configuration = newConfiguration;
                config = new ConfigNode ("MODULE");
                newConfig.CopyTo (config);
                config.name = "MODULE";

                // fix for HotRockets etc.
                if (type.Equals("ModuleEngines") && part.Modules.Contains("ModuleEnginesFX") && !part.Modules.Contains("ModuleEngines"))
                    type = "ModuleEnginesFX";
                if (type.Equals("ModuleEnginesFX") && part.Modules.Contains("ModuleEngines") && !part.Modules.Contains("ModuleEnginesFX"))
                    type = "ModuleEngines";
                // fix for ModuleRCSFX etc
                if (type.Equals("ModuleRCS") && part.Modules.Contains("ModuleRCSFX") && !part.Modules.Contains("ModuleRCS"))
                    type = "ModuleRCSFX";
                if (type.Equals("ModuleRCSFX") && part.Modules.Contains("ModuleRCS") && !part.Modules.Contains("ModuleRCSFX"))
                    type = "ModuleRCS";

                config.SetValue("name", type);

                #if DEBUG
                print ("replacing " + type + " with:");
                print (newConfig.ToString ());
                #endif

                pModule = null;
                if (part.Modules.Contains(type))
                {
                        pModule = part.Modules[type];

                    // clear all FloatCurves
                    Type mType = pModule.GetType();
                    foreach (FieldInfo field in mType.GetFields())
                    {
                        if (field.FieldType == typeof(FloatCurve) && (field.Name.Equals("atmosphereCurve") || field.Name.Equals("velocityCurve")))
                        {
                            //print("*MFS* resetting curve " + field.Name);
                            field.SetValue(pModule, new FloatCurve());
                        }
                    }
                    // clear propellant gauges
                    foreach (FieldInfo field in mType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                    {
                        if (field.FieldType == typeof(Dictionary<Propellant, VInfoBox>))
                        {
                            Dictionary<Propellant, VInfoBox> boxes = (Dictionary<Propellant, VInfoBox>)(field.GetValue(pModule));
                            if (boxes == null)
                                continue;
                            foreach (VInfoBox v in boxes.Values)
                            {
                                if (v == null) //just in case...
                                    continue;
                                try
                                {
                                    part.stackIcon.RemoveInfo(v);
                                }
                                catch (Exception e)
                                {
                                    print("*MFS* Trying to remove info box: " + e.Message);
                                }
                            }
                            boxes.Clear();
                        }
                    }
                }
                if (type.Equals("ModuleRCS") || type.Equals("ModuleRCSFX"))
                {
                    ModuleRCS rcs = (ModuleRCS)pModule;
                    if (rcs != null)
                    {
                        rcs.G = 9.80665f;
                        /*bool oldRes = config.HasValue("resourceName");
                        string resource = "";
                        if (oldRes)
                        {
                            resource = config.GetValue("resourceName");
                            rcs.resourceName = resource;
                        }*/
                        DoConfig(config);
                        if (config.HasNode("PROPELLANT"))
                        {
                            rcs.propellants.Clear();
                        }
                        pModule.Load(config);
                        /*if (oldRes)
                        {
                            rcs.resourceName = resource;
                            rcs.SetResource(resource);
                        }*/
                        // PROPELLANT handling is automatic.
                        fastRCS = rcs;
//.........这里部分代码省略.........
开发者ID:Biotronic,项目名称:ModularFuelSystem,代码行数:101,代码来源:ModularEngines.cs


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