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


C# Part.GetType方法代码示例

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


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

示例1: JointAdjustmentValid

        public static bool JointAdjustmentValid(Part p)
        {
            foreach (string s in exemptPartTypes)
                if (p.GetType().ToString() == s)
                    return false;

            foreach (string s in exemptModuleTypes)
                if (p.Modules.Contains(s))
                    return false;

            return true;
        }
开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:12,代码来源:KJRJointUtils.cs

示例2: plugIn

    public bool plugIn(Part part)
    {
        bool returnValue = false;

        if (part.GetType() == typeof(CPU))
        {
            if (part.partInterface == CPUInterface)
            {
                this.cpu = (CPU) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(GPU))
        {
            if (part.partInterface == GPUInterface)
            {
                this.gpu = (GPU)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(HDD))
        {
            if (part.partInterface == HDDInterface)
            {
                this.hdd = (HDD)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(RAM))
        {
            if (part.partInterface == RAMInterface)
            {
                this.ram = (RAM)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompInput))
        {
            if (part.partInterface == compInputInterface)
            {
                this.input = (CompInput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompOutput))
        {
            if (part.partInterface == compOutputInterface)
            {
                this.output = (CompOutput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompNetwork))
        {
            if (part.partInterface == networkInterface)
            {
                this.network = (CompNetwork) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(PowerSupply))
        {
            if (part.partInterface == powerInterface)
            {
                this.pSupply = (PowerSupply)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(Chassis))
        {
            if (part.partInterface == formFactor)
            {
                this.chassis = (Chassis)part;
                returnValue = true;
            }
        }

        return returnValue;
    }
开发者ID:rhyok,项目名称:hue-r,代码行数:79,代码来源:Parts.cs

示例3: GetsDecouplerStiffeningExtension

        public static bool GetsDecouplerStiffeningExtension(Part p)
        {
            string typeString = p.GetType().ToString();

            foreach (string s in decouplerStiffeningExtensionType)
                if (typeString == s)
                {
                    return true;
                }
            foreach (string s in decouplerStiffeningExtensionType)
                if (p.Modules.Contains(s))
                {
                    return true;
                }

            return false;
        }
开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:17,代码来源:KJRJointUtils.cs

示例4: RestrictionMet

    public bool RestrictionMet(Part part)
    {
        object val;
        var type = part.GetType();
        var prop = type.GetProperty(property);

        if (prop != null)
        {
            val = prop.GetValue(part, null);
        }
        else
        {
            val = type.GetField(property).GetValue(part);
        }

        switch (val.GetType().ToString())
        {
            case "System.Int32":
                System.Int32 i32v = (System.Int32)val;
                System.Int32 i32t = System.Int32.Parse(value);
                switch (comparer)
                {
                        case  ">": return i32v  > i32t;
                        case  "<": return i32v  < i32t;
                        case "!=": return i32v != i32t;
                        case "==": return i32v == i32t;
                        case ">=": return i32v >= i32t;
                        case "<=": return i32v <= i32t;
                        default: ModuleAttacher.print("unknown comparer for " + val.GetType() + ": " + comparer); return false;
                }

            default:
                ModuleAttacher.print("unknown value type: " + val.GetType());
                return false;
        }
    }
开发者ID:BloodyRain2k,项目名称:ModuleAttacher,代码行数:36,代码来源:ModuleAttacher.cs

示例5: transferFuel

    bool transferFuel(Part source, Part dest, float amount, int FuelType)
    {
        bool wasDeactive = false;
        if (dest.State == PartStates.DEACTIVATED) {
            dest.force_activate();
            wasDeactive = true;
        }
        float fuelBefore = getFuelForPartAndFueltype(source, FuelType);

        bool deactivated = false;

        if (source is IFuelSource) {
            IFuelSource ifs = (IFuelSource)source;
            if (ifs.FuelType.Equals(fts.ElementAt(FuelType)) && ifs.RequestFuel(amount, fts.ElementAt(FuelType))) {
                addFuel(dest, amount, FuelType);
                /*
                if (fuelBefore - amount != getFuelForPartAndFueltype(source, FuelType)) {
                    addFuel(source, fuelBefore - amount, FuelType);
                }
                */
            }
            if (ifs.Fuel <= 0.0) {
                source.deactivate();
                deactivated = true;
            }
        } else {
            if (FuelType == RegularFuel && source.GetType() == typeof(FuelTank)) {
                FuelTank ft = (FuelTank)source;
                ft.fuel -= amount;
                addFuel(dest, amount, FuelType);
                if (ft.fuel <= 0.0) {
                    ft.deactivate();
                    deactivated = true;
                }
            } else if (FuelType == RCSFuel && source.GetType() == typeof(RCSFuelTank)) {
                RCSFuelTank ft = (RCSFuelTank)source;
                ft.fuel -= amount;
                addFuel(dest, amount, FuelType);
                /*
                if (fuelBefore - amount != getFuelForPartAndFueltype(source, FuelType)) {
                    addFuel(source, fuelBefore - amount, FuelType);
                }
                */
                if (ft.fuel <= 0.0) {
                    ft.deactivate();
                    deactivated = true;
                }
            }
        }

        if (wasDeactive)
            source.deactivate();
        return deactivated;
    }
开发者ID:careo,项目名称:FuelTransferModule,代码行数:54,代码来源:FuelTransferModule.cs

示例6: getFuelForPartAndFueltype

 float getFuelForPartAndFueltype(Part p, int fuelType)
 {
     if (p is IFuelSource) {
         IFuelSource ifs = (IFuelSource)p;
         if (!ifs.FuelType.Equals(fts.ElementAt(fuelType)))
             return -1;
         return ifs.Fuel;
     }
     if (fuelType == RegularFuel) {
         if (p.GetType () == typeof(FuelTank))
             return ((FuelTank)p).fuel;
     } else if (fuelType == RCSFuel) {
         if (p.GetType () == typeof(RCSFuelTank))
             return ((RCSFuelTank)p).fuel;
     }
     return -1;
 }
开发者ID:careo,项目名称:FuelTransferModule,代码行数:17,代码来源:FuelTransferModule.cs

示例7: addFuel

 private void addFuel(Part dest, float amount, int fuelType)
 {
     /*
     if (dest == null)
         return;
     */
     if (dest is IFuelSource) {
         ((IFuelSource)dest).Fuel += amount;
     }
     if (fuelType == RegularFuel) {
         if (dest.GetType() == typeof(FuelTank)) {
             ((FuelTank)dest).fuel += amount;
         }
     } else if (fuelType == RCSFuel) {
         if (dest.GetType() == typeof(RCSFuelTank)) {
             ((RCSFuelTank)dest).fuel += amount;
         }
     }
 }
开发者ID:careo,项目名称:FuelTransferModule,代码行数:19,代码来源:FuelTransferModule.cs

示例8: DecouplerPartStiffeningList

        public static List<Part> DecouplerPartStiffeningList(Part p, bool childrenNotParent, bool onlyAddLastPart)
        {
            List<Part> tmpPartList = new List<Part>();
            bool extend = false;
            // non-physical parts are skipped over by attachJoints, so do the same
            if (p.physicalSignificance == Part.PhysicalSignificance.NONE)
                extend = true;
            foreach (string s in decouplerStiffeningExtensionType)
                if (p.GetType().ToString() == s)
                {
                    extend = true;
                    break;
                }
            if (!extend)
                foreach (string s in decouplerStiffeningExtensionType)
                    if (p.Modules.Contains(s))
                    {
                        extend = true;
                        break;
                    }

            List<Part> newAdditions = new List<Part>();
            if (extend)
            {
                if (childrenNotParent)
                {
                    if (p.children != null)
                    {
                        foreach (Part q in p.children)
                            if (q != null && q.parent == p)
                            {
                                newAdditions.AddRange(DecouplerPartStiffeningList(q, childrenNotParent, onlyAddLastPart));
                            }
                    }
                }
                else
                {
                    if (p.parent)
                    {
                        newAdditions.AddRange(DecouplerPartStiffeningList(p.parent, childrenNotParent, onlyAddLastPart));
                    }
                }
            }
            else
            {
                float thisPartMaxMass = MaximumPossiblePartMass(p);
                if (childrenNotParent)
                {
                    if (p.children != null)
                        foreach (Part q in p.children)
                        {
                            if (q != null && q.parent == p)
                            {

                                float massRatio = MaximumPossiblePartMass(q) / thisPartMaxMass;

                                if (massRatio > stiffeningExtensionMassRatioThreshold)
                                {
                                    newAdditions.Add(q);
                                    if (debug)
                                        Debug.Log("Part " + q.partInfo.title + " added to list due to mass ratio difference");
                                }
                            }
                        }
                }
                else
                {
                    if (p.parent)
                    {
                        float massRatio = MaximumPossiblePartMass(p.parent) / thisPartMaxMass;

                        if (massRatio > stiffeningExtensionMassRatioThreshold)
                        {
                            newAdditions.Add(p.parent);
                            if (debug)
                                Debug.Log("Part " + p.parent.partInfo.title + " added to list due to mass ratio difference");
                        }
                    }
                }
            }
            if (newAdditions.Count > 0)
                tmpPartList.AddRange(newAdditions);
            else if (onlyAddLastPart)
                extend = false;

            if(!(onlyAddLastPart && extend))
                tmpPartList.Add(p);

            return tmpPartList;
        }
开发者ID:vosechu,项目名称:Kerbal-Joint-Reinforcement,代码行数:90,代码来源:KerbalJointReinforcement.cs


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