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


C# Part.GetComponent方法代码示例

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


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

示例1: Update

        public void Update()
        {
            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.K))
            {
                if (GuiConfigToogle)
                {
                    Debug.Log("KASAddonDebugMenu - Closing KAS debug tools");
                    GuiConfigToogle = false;
                }
                else
                {
                    Debug.Log("KASAddonDebugMenu - Opening KAS debug tools");
                    GuiConfigToogle = true;
                }
            }

            if (GuiConfigToogle)
            {
                if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Mouse0))
                {
                    Debug.Log("KASAddonDebugMenu - On click");
                    clickedPart = KAS_Shared.GetPartUnderCursor();
                    if (clickedPart)
                    {
                        moduleWinch = null;
                        moduleGrab = null;
                        moduleMagnet = null;
                        moduleSuctionCup = null;
                        moduleGrapple = null;
                        moduleTimedBomb = null;
                        modulePort = null;
                        moduleAnchor = null;
                        moduleStrut = null;
                        moduleRotor = null;

                        moduleWinch = clickedPart.GetComponent<KASModuleWinch>();
                        moduleGrab = clickedPart.GetComponent<KASModuleGrab>();
                        moduleMagnet = clickedPart.GetComponent<KASModuleMagnet>();
                        moduleSuctionCup = clickedPart.GetComponent<KASModuleSuctionCup>();
                        moduleGrapple = clickedPart.GetComponent<KASModuleGrapplingHook>();
                        moduleTimedBomb = clickedPart.GetComponent<KASModuleTimedBomb>();
                        modulePort = clickedPart.GetComponent<KASModulePort>();
                        moduleAnchor = clickedPart.GetComponent<KASModuleAnchor>();
                        moduleStrut = clickedPart.GetComponent<KASModuleStrut>();
                        moduleRotor = clickedPart.GetComponent<KASModuleRotor>();
                    }     
                }
            }

            if (FlightGlobals.ActiveVessel.heightFromTerrain == -1f)
            {
                if (FlightGlobals.ActiveVessel.Landed)
                {
                    KAS_Shared.DebugWarning("Warning ! ActiveVessel is landed and heightFromTerrain are negative (" + FlightGlobals.ActiveVessel.heightFromTerrain + ")");
                }
            }
        }
开发者ID:ACCBizon,项目名称:KAS,代码行数:57,代码来源:KASAddonDebugTools.cs

示例2: hasModuleEngineConfigs

 public static bool hasModuleEngineConfigs(Part part)
 {
     Type type = Type.GetType("RealFuels.ModuleEngineConfigs,RealFuels");
     PartModule module = null;
     if (type != null)
     {
         module = (PartModule)part.GetComponent(type);
     }
     return module != null;
 }
开发者ID:shadowmage45,项目名称:SSTULabs,代码行数:10,代码来源:SSTUModInterop.cs

示例3: addPart

        public void addPart(Part p, Part prevPart)
        {
            if (p==null || hash.Contains(p)) return;
            hash.Add(p);

            if (p.GetComponent<LaunchClamp>()!=null) return;
            if (p==prevPart.parent && prevPart.srfAttachNode.attachedPart==p) return;

            // check for another fairing base
            if (p.GetComponent<ProceduralFairingBase>()!=null
              && p.GetComponent<ProceduralFairingAdapter>()==null)
            {
              AttachNode node=p.findAttachNode("top");
              if (node!=null && node.attachedPart==prevPart)
              {
            // reversed base - potential inline fairing target
            if (nestedBases<=0) { targets.Add(p); return; }
            else --nestedBases;
              }
              else ++nestedBases;
            }

            payload.Add(p);
        }
开发者ID:ItMustBeACamel,项目名称:ProceduralFairings,代码行数:24,代码来源:PayloadScan.cs

示例4: onPartFuelVolumeUpdate

 public static void onPartFuelVolumeUpdate(Part part, float cubicMeters)
 {
     bool mfTank = false;
     Type moduleFuelTank = null;
     if (isRFInstalled())
     {
         moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,RealFuels");
         if (moduleFuelTank == null)
         {
             MonoBehaviour.print("ERROR: Set to use RealFuels, and RealFuels is installed, but no RealFuels-ModuleFuelTank PartModule found.");
             return;
         }
     }
     else if (isMFTInstalled())
     {
         moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,modularFuelTanks");
         if (moduleFuelTank == null)
         {
             MonoBehaviour.print("ERROR: Set to use ModularFuelTanks, and ModularFuelTanks is installed, but no ModularFuelTanks-ModuleFuelTank PartModule found.");
             return;
         }
         mfTank = true;
     }
     else
     {
         MonoBehaviour.print("Config is for part: "+part+" is set to use RF/MFT, but neither RF nor MFT is installed, cannot update part volumes through them.  Please check your configs and/or patches for errors.");
         return;
     }
     PartModule pm = (PartModule)part.GetComponent(moduleFuelTank);
     if (pm == null)
     {
         MonoBehaviour.print("ERROR! Could not find ModuleFuelTank in part for RealFuels/MFT for type: "+moduleFuelTank);
         return;
     }
     MethodInfo mi = moduleFuelTank.GetMethod("ChangeTotalVolume");
     double volumeLiters = cubicMeters * 1000f;
     if (mfTank)
     {
         volumeLiters *= 0.2f;//convert liters into stock units....
     }
     mi.Invoke(pm, new System.Object[] { volumeLiters, false });
     String message = "SSTU - Set RF/MFT total tank volume to: " + volumeLiters + (mfTank? " Units": " Liters for part: "+part.name);
     MethodInfo mi2 = moduleFuelTank.GetMethod("CalculateMass");
     mi2.Invoke(pm, new System.Object[] { });
 }
开发者ID:Joshg213,项目名称:SSTULabs,代码行数:45,代码来源:SSTUModInterop.cs

示例5: KIS_Item

 // New part from scene
 public KIS_Item(Part part, ModuleKISInventory inventory, float quantity = 1)
 {
     // Get part node
     this.availablePart = PartLoader.getPartInfoByName(part.partInfo.name);
     this.partNode = new ConfigNode();
     KIS_Shared.PartSnapshot(part).CopyTo(this.partNode);
     // init config
     this.InitConfig(availablePart, inventory, quantity);
     // Get mass
     this.resourceMass = part.GetResourceMass();
     ModuleKISInventory itemInventory = part.GetComponent<ModuleKISInventory>();
     if (itemInventory)
     {
         this.contentMass = itemInventory.GetContentMass();
         this.contentCost = itemInventory.GetContentCost();
         if (itemInventory.invName != "") this.inventoryName = itemInventory.invName;
     }
 }
开发者ID:khr15714n,项目名称:KIS,代码行数:19,代码来源:KIS_Item.cs

示例6: KerbalActor

        public KerbalActor(Part part, ProtoCrewMember crewMember)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }
            if (crewMember == null)
            {
                throw new ArgumentNullException("crewMember");
            }

            Util.Log("Creating actor: {0} with name {1}, gameobject name {2}", crewMember.name, part.name, part.gameObject.name);

            Part = part;

            if (!Part.GetComponent<LineOverlay>())
            {
                //var parentTransform = Part.parentTransform.FindChild("globalMove01");

                LineOverlay = Part.gameObject.AddComponent<LineOverlay>();
            }

            Util.GetGameObjectBehaviors(part.gameObject);
            CrewMember = crewMember;

            EVA = part.GetComponent<KerbalEVA>();
            if (EVA == null)
            {
                throw new InvalidOperationException("Part does not have KerbalEVA");
            }

            GetExpessionAnimator(part);

            GetFSM();

            GetHeadMeshes();

            GetBoneRig();
        }
开发者ID:JoshBlake,项目名称:KerbExpressions,代码行数:39,代码来源:KerbalActor.cs

示例7: getModuleFuelTanks

 public static PartModule getModuleFuelTanks(Part part)
 {
     Type moduleFuelTank = null;
     if (isRFInstalled())
     {
         moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,RealFuels");
         if (moduleFuelTank == null)
         {
             MonoBehaviour.print("ERROR: Set to use RealFuels, and RealFuels is installed, but no RealFuels-ModuleFuelTank PartModule found.");
             return null;
         }
     }
     else if (isMFTInstalled())
     {
         moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,modularFuelTanks");
         if (moduleFuelTank == null)
         {
             MonoBehaviour.print("ERROR: Set to use ModularFuelTanks, and ModularFuelTanks is installed, but no ModularFuelTanks-ModuleFuelTank PartModule found.");
             return null;
         }
     }
     PartModule pm = (PartModule)part.GetComponent(moduleFuelTank);
     return pm;
 }
开发者ID:shadowmage45,项目名称:SSTULabs,代码行数:24,代码来源:SSTUModInterop.cs

示例8: CheckIfMissile

 public static bool CheckIfMissile(Part p)
 {
     if(p.GetComponent<MissileLauncher>())
     {
         return true;
     }
     else return false;
 }
开发者ID:jiangtiandao,项目名称:BDArmory,代码行数:8,代码来源:MissileLauncher.cs

示例9: removePart

        void removePart(Part part)
        {
            Debug.Log (String.Format ("[EL GUI] remove: {0}", part));

            var ship = EditorLogic.fetch.ship;
            if (ship.parts.Count != parts_count) {
                buildCost.removePart (part);
                parts_count--;
            }

            ExShipInfoEventCatcher ec = part.GetComponent<ExShipInfoEventCatcher> ();
            part.RemoveModule (ec);
        }
开发者ID:GlassFragments,项目名称:Extraplanetary-Launchpads,代码行数:13,代码来源:ShipInfo.cs

示例10: CalcBodyGeometryFromMesh

        public static BodyGeometryForDrag CalcBodyGeometryFromMesh(Part p)
        {
            BodyGeometryForDrag partGeometry = new BodyGeometryForDrag();

            maxBounds = new Vector3(-100, -100, -100);
            minBounds = new Vector3(100, 100, 100);

            int symmetryCounterpartNum = 1;
            //Vector3 centerOfSymCounterparts = p.transform.position;
            Matrix4x4 base_matrix = WorldToPartUpMatrix(p);

            Transform[] ModelTransforms = PartModelTransformArray(p);

            if (p.parent != null && p.GetComponent<FARPayloadFairingModule>() != null)
            {
                foreach (Part q in p.symmetryCounterparts)
                    if (q != p)
                    {
                        //centerOfSymCounterparts += q.transform.position;
                        symmetryCounterpartNum++;
                    }

                //centerOfSymCounterparts /= symmetryCounterpartNum;

                foreach (Part q in p.symmetryCounterparts)
                    if (q != p)
                    {
                        //Vector3 offset = q.transform.position - centerOfSymCounterparts;
                        PartMaxBoundaries(q, Vector3.zero, WorldToPartUpMatrix(q), ModelTransforms);
                    }
            }
            PartMaxBoundaries(p, Vector3.zero, base_matrix, ModelTransforms);

            upperAxis1 = new Vector2(-100, -100);                 //1s are the "positive" values
            lowerAxis1 = new Vector2(-100, -100);
            upperAxis2 = new Vector2(100, 100);               //2 are the "negative" values
            lowerAxis2 = new Vector2(100, 100);

            Vector3d size = maxBounds - minBounds;

            double toleranceForTaper = Mathf.Abs((float)size.y) / 5;
            toleranceForTaper = Math.Max(toleranceForTaper, 0.25);

            if (p.parent != null && p.GetComponent<FARPayloadFairingModule>() != null)
            {
                foreach (Part q in p.symmetryCounterparts)
                    if (q != p)
                    {
                        //Vector3 offset = q.transform.position - centerOfSymCounterparts;
                        PartTaperBoundaries(q, toleranceForTaper, Vector3.zero, WorldToPartUpMatrix(q), ModelTransforms);
                    }
            }
            PartTaperBoundaries(p, toleranceForTaper, Vector3.zero, base_matrix, ModelTransforms);

            Vector3d upperDiameters = (Vector3)(upperAxis1 - upperAxis2);
            Vector3d lowerDiameters = (Vector3)(lowerAxis1 - lowerAxis2);

            //            if (p.Modules.Contains("ModuleJettison"))
            //                upperDiameters = lowerDiameters = size;
            //size *= p.scaleFactor;
            Vector3d centroid = Vector3d.zero;

            double lowerR = lowerDiameters.magnitude * 0.5;
            double upperR = upperDiameters.magnitude * 0.5;
            centroid.y = 4 * (lowerR * lowerR + lowerR * upperR + upperR * upperR);
            centroid.y = size.y * (lowerR * lowerR + 2 * lowerR * upperR + 3 * upperR * upperR) / centroid.y;
            centroid.y += minBounds.y;
            centroid.x = (maxBounds.x + minBounds.x);
            centroid.z = (maxBounds.z + minBounds.z);

            partGeometry.originToCentroid = centroid;

            partGeometry.crossSectionalArea = (size.x * size.z) / 4;                    //avg radius
            partGeometry.crossSectionalArea *= Math.PI;
            partGeometry.crossSectionalArea /= (symmetryCounterpartNum);

            partGeometry.area = (Math.Abs(upperDiameters.x + upperDiameters.y) + Math.Abs(lowerDiameters.x + lowerDiameters.y)) / 4 * Math.PI * Math.Abs(size.y);              //surface area, not counting cross-sectional area
            partGeometry.area /= (symmetryCounterpartNum);

            partGeometry.finenessRatio = Math.Abs(size.x + size.z) / 2;
            partGeometry.finenessRatio = Math.Abs(size.y) / partGeometry.finenessRatio;

            partGeometry.majorMinorAxisRatio = Math.Abs(size.x / size.z);

            partGeometry.taperRatio = Math.Abs(upperDiameters.x + upperDiameters.y) / Math.Abs(lowerDiameters.x + lowerDiameters.y);

            partGeometry.taperCrossSectionArea = Math.Abs(Math.Pow((upperDiameters.x + upperDiameters.y) / 4, 2) - Math.Pow((lowerDiameters.x + lowerDiameters.y) / 4, 2)) * Math.PI;

            //This is the cross-sectional area of the tapered section

            Debug.Log(p.partInfo.title + ": Geometry model created; Size: " + size + ", LD " + lowerDiameters + ", UD " + upperDiameters + "\n\rSurface area: " + partGeometry.area + "\n\rFineness Ratio: " + partGeometry.finenessRatio + "\n\rTaperRatio: " + partGeometry.taperRatio + "\n\rCross Sectional Area: " + partGeometry.crossSectionalArea + "\n\rCross Sectional Tapered Area: " + partGeometry.taperCrossSectionArea + "\n\rMajor-minor axis ratio: " + partGeometry.majorMinorAxisRatio + "\n\rCentroid: " + partGeometry.originToCentroid);
            return partGeometry;
        }
开发者ID:vosechu,项目名称:Ferram-Aerospace-Research,代码行数:93,代码来源:FARGeoUtil.cs

示例11: OnMouseGrabEnterPart

        void OnMouseGrabEnterPart(Part part)
        {
            if (!grabActive) return;
            grabOk = false;
            if (!HighLogic.LoadedSceneIsFlight) return;
            if (KISAddonPointer.isRunning) return;
            if (hoverInventoryGui()) return;
            if (draggedPart == part) return;
            ModuleKISPartDrag pDrag = part.GetComponent<ModuleKISPartDrag>();
            ModuleKISPartMount parentMount = null;
            if (part.parent) parentMount = part.parent.GetComponent<ModuleKISPartMount>();
            ModuleKISItem item = part.GetComponent<ModuleKISItem>();

            // Drag part over another one if possible (ex : mount)
            if (draggedPart && pDrag)
            {
                KISAddonCursor.CursorEnable(pDrag.dragIconPath, pDrag.dragText, '(' + pDrag.dragText2 + ')');
                return;
            }

            if (draggedPart)
            {
                KISAddonCursor.CursorDisable();
                return;
            }

            // Do nothing if part is EVA
            if (part.vessel.isEVA) return;

            // Check part distance
            if (!HasActivePickupInRange(part))
            {
                KISAddonCursor.CursorEnable("KIS/Textures/tooFar", "Too far", "(Move closer to the part)");
                return;
            }

            // Check part mass
            float pMass = (part.mass + part.GetResourceMass());
            float pickupMaxMass = GetAllPickupMaxMassInRange(part);
            if (pMass > pickupMaxMass)
            {
                KISAddonCursor.CursorEnable("KIS/Textures/tooHeavy", "Too heavy", "(Bring more kerbal [" + pMass + " > " + pickupMaxMass + ")");
                return;
            }

            // Check if part can be detached and grabbed
            if (!parentMount)
            {
                if (part.children.Count > 0 || part.parent)
                {
                    //Part with a child or a parent
                    if (item)
                    {
                        if (item.allowPartAttach == 0)
                        {
                            KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Can't grab", "(This part can't be detached)");
                            return;
                        }
                        else if (item.allowPartAttach == 2)
                        {
                            ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true);
                            if (!pickupModule)
                            {
                                if (FlightGlobals.ActiveVessel.isEVA)
                                {
                                    KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed", "(This part can't be detached without a tool)");
                                    return;
                                }
                                else
                                {
                                    KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported", "(Detach function is not supported on this part)");
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true);
                        if (!pickupModule)
                        {
                            if (FlightGlobals.ActiveVessel.isEVA)
                            {
                                KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed", "(This part can't be detached without a tool)");
                                return;
                            }
                            else
                            {
                                KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported", "(Detach function is not supported on this part)");
                                return;
                            }
                        }
                    }
                }
                else
                {
                    // Part without childs and parent
                    if (item)
                    {
                        if (item.staticAttached && item.allowStaticAttach == 2)
//.........这里部分代码省略.........
开发者ID:khr15714n,项目名称:KIS,代码行数:101,代码来源:KISAddonPickup.cs

示例12: OnMouseDetachEnterPart

        void OnMouseDetachEnterPart(Part part)
        {
            if (!detachActive) {
              return;
            }
            detachOk = false;
            if (!HighLogic.LoadedSceneIsFlight
            || KISAddonPointer.isRunning
            || hoverInventoryGui()
            || draggedPart) {
              return;
            }

            // Don't separate kerbals with their parts. They have a reason to be attached.
            if (part.name == "kerbalEVA" || part.name == "kerbalEVAfemale") {
              KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Can't detach",
                                  "(This kerbanaut looks too attached to the part)");
              return;
            }

            ModuleKISPartDrag pDrag = part.GetComponent<ModuleKISPartDrag>();
            ModuleKISItem item = part.GetComponent<ModuleKISItem>();
            ModuleKISPartMount parentMount = null;
            if (part.parent) {
              parentMount = part.parent.GetComponent<ModuleKISPartMount>();
            }

            // Do nothing if part is EVA
            if (part.vessel.isEVA) {
              return;
            }

            // Check part distance
            if (!HasActivePickupInRange(part)) {
              KISAddonCursor.CursorEnable("KIS/Textures/tooFar", "Too far", "(Move closer to the part)");
              return;
            }

            // Check if part is static attached
            if (item) {
              if (item.staticAttached) {
            ModuleKISPickup pickupModule = GetActivePickupNearest(part, canStaticAttachOnly: true);
            if ((item.allowStaticAttach == ModuleKISItem.ItemAttachMode.AllowedAlways)
            || (pickupModule
                && item.allowStaticAttach == ModuleKISItem.ItemAttachMode.AllowedWithKisTool)) {
              part.SetHighlightColor(XKCDColors.Periwinkle);
              part.SetHighlight(true, false);
              KISAddonCursor.CursorEnable("KIS/Textures/detachOk", "Detach from ground",
                                      '(' + part.partInfo.title + ')');
              detachOk = true;
            } else {
              if (FlightGlobals.ActiveVessel.isEVA) {
            KISAddonCursor.CursorEnable(
                "KIS/Textures/needtool", "Tool needed",
                "(This part can't be detached from the ground without a tool)");
              } else {
            KISAddonCursor.CursorEnable(
                "KIS/Textures/forbidden", "Not supported",
                "(Detach from ground function is not supported on this part)");
              }
            }
              }
            }

            // Check if part can be detached
            if (!parentMount) {
              if (part.children.Count > 0 || part.parent) {
            //Part with a child or a parent
            if (item) {
              if (item.allowPartAttach == ModuleKISItem.ItemAttachMode.Disabled) {
            KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Can't detach",
                                        "(This part can't be detached)");
              } else if (item.allowPartAttach == ModuleKISItem.ItemAttachMode.AllowedWithKisTool) {
            ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true);
            if (!pickupModule) {
              if (FlightGlobals.ActiveVessel.isEVA) {
                KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed",
                                            "(Part can't be detached without a tool)");
              } else {
                KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported",
                                            "(Detach function is not supported on this part)");
              }
            }
              }
              return;
            }
            if (!CheckCanDetach(part)) {
              return;
            }
              } else {
            // Part without childs and parent
            return;
              }
            }

            // Check if part is a root
            if (!part.parent) {
              KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Root part",
                                  "(Cannot detach a root part)");
              return;
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:KIS,代码行数:101,代码来源:KISAddonPickup.cs

示例13: DecoupleFromAll

 public static void DecoupleFromAll(Part p)
 {
     SendKISMessage(p, MessageAction.Decouple);
     if (p.parent)
     {
         p.decouple();
         //name container if needed
         ModuleKISInventory inv = p.GetComponent<ModuleKISInventory>();
         if (inv)
         {
             if (inv.invName != "")
             {
                 p.vessel.vesselName = inv.part.partInfo.title + " | " + inv.invName;
             }
             else
             {
                 p.vessel.vesselName = inv.part.partInfo.title;
             }
         }
     }
     if (p.children.Count != 0)
     {
         DecoupleAllChilds(p);
     }
 }
开发者ID:Amorymeltzer,项目名称:KIS,代码行数:25,代码来源:KIS_Shared.cs

示例14: OnMouseDetachEnterPart

        void OnMouseDetachEnterPart(Part part)
        {
            if (!detachActive) return;
            detachOk = false;
            if (!HighLogic.LoadedSceneIsFlight) return;
            if (KISAddonPointer.isRunning) return;
            if (hoverInventoryGui()) return;
            if (draggedPart) return;
            ModuleKISPartDrag pDrag = part.GetComponent<ModuleKISPartDrag>();
            ModuleKISItem item = part.GetComponent<ModuleKISItem>();
            ModuleKISPartMount parentMount = null;
            if (part.parent) parentMount = part.parent.GetComponent<ModuleKISPartMount>();

            // Do nothing if part is EVA
            if (part.vessel.isEVA)
            {
                return;
            }

            // Check part distance
            if (!HasActivePickupInRange(part))
            {
                KISAddonCursor.CursorEnable("KIS/Textures/tooFar", "Too far", "(Move closer to the part)");
                return;
            }

            // Check if part is static attached
            if (item)
            {
                if (item.staticAttached)
                {
                    ModuleKISPickup pickupModule = GetActivePickupNearest(part, canStaticAttachOnly: true);
                    if ((item.allowStaticAttach == 1) || (pickupModule && item.allowStaticAttach == 2))
                    {
                        part.SetHighlightColor(XKCDColors.Periwinkle);
                        part.SetHighlight(true, false);
                        KISAddonCursor.CursorEnable("KIS/Textures/detachOk", "Detach from ground", '(' + part.partInfo.title + ')');
                        detachOk = true;
                        return;
                    }
                    else
                    {
                        if (FlightGlobals.ActiveVessel.isEVA)
                        {
                            KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed", "(This part can't be detached from the ground without a tool)");
                            return;
                        }
                        else
                        {
                            KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported", "(Detach from ground function is not supported on this part)");
                            return;
                        }
                    }
                }
            }

            // Check if part can be detached
            if (!parentMount)
            {
                if (part.children.Count > 0 || part.parent)
                {
                    //Part with a child or a parent
                    if (item)
                    {
                        if (item.allowPartAttach == 0)
                        {
                            KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Can't detach", "(This part can't be detached)");
                            return;
                        }
                        else if (item.allowPartAttach == 2)
                        {
                            ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true);
                            if (!pickupModule)
                            {
                                if (FlightGlobals.ActiveVessel.isEVA)
                                {
                                    KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed", "(Part can't be detached without a tool)");
                                    return;
                                }
                                else
                                {
                                    KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported", "(Detach function is not supported on this part)");
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true);
                        if (!pickupModule)
                        {
                            if (FlightGlobals.ActiveVessel.isEVA)
                            {
                                KISAddonCursor.CursorEnable("KIS/Textures/needtool", "Tool needed", "(Part can't be detached without a tool)");
                                return;
                            }
                            else
                            {
                                KISAddonCursor.CursorEnable("KIS/Textures/forbidden", "Not supported", "(Detach function is not supported on this part)");
//.........这里部分代码省略.........
开发者ID:khr15714n,项目名称:KIS,代码行数:101,代码来源:KISAddonPickup.cs

示例15: onPartKISInventoryVolumeChanged

 public static void onPartKISInventoryVolumeChanged(Part part, float liters)
 {
     if (!isKISInstalled())
     {
         return;
     }
     string typeName = "KIS.ModuleKISInventory,KIS";
     Type kisModuleType = Type.GetType(typeName);
     if (kisModuleType == null)
     {
         MonoBehaviour.print("ERROR: Could not locate KIS module for name: "+typeName);
     }
     PartModule pm = (PartModule)part.GetComponent(kisModuleType);
     if(pm == null)
     {
         if (liters != 0)
         {
             MonoBehaviour.print("ERROR: Could not locate KIS module on part for type: " + part + " :: " + kisModuleType);
         }
         return;
     }
     FieldInfo fi = kisModuleType.GetField("maxVolume");
     fi.SetValue(pm, liters);
     BaseEvent inventoryEvent = pm.Events["ShowInventory"];
     inventoryEvent.guiActive = inventoryEvent.guiActiveEditor = liters > 0;
 }
开发者ID:shadowmage45,项目名称:SSTULabs,代码行数:26,代码来源:SSTUModInterop.cs


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