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


C# Part.GetComponents方法代码示例

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


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

示例1: updateNodePosition

 public static void updateNodePosition(Part part, String nodeName, Vector3 pos)
 {
     SSTUSelectableNodes[] modules = part.GetComponents<SSTUSelectableNodes>();
     int len = modules.Length;
     for (int i = 0; i < len; i++)
     {
         if (modules[i].nodeName == nodeName)
         {
             modules[i].nodeDefaultPosition = pos;
         }
     }
 }
开发者ID:shadowmage45,项目名称:SSTULabs,代码行数:12,代码来源:SSTUSelectableNodes.cs

示例2: locateAnimationController

 //Static method for use by other modules to locate a control module; reduces code duplication in animation controlling modules
 public static SSTUAnimateControlled locateAnimationController(Part part, int id, Action<SSTUAnimState> callback)
 {
     if (id < 0)
     {
         return null;
     }
     SSTUAnimateControlled[] potentialAnimators = part.GetComponents<SSTUAnimateControlled>();
     foreach(SSTUAnimateControlled ac in potentialAnimators)
     {
         if(ac.animationID == id)
         {
             ac.addCallback(callback);
             return ac;
         }
     }
     return null;
 }
开发者ID:Kerbas-ad-astra,项目名称:SSTULabs,代码行数:18,代码来源:SSTUAnimateControlled.cs

示例3: OnEditPartCreate

 /// <summary>Adds default items to the pod's seats.</summary>
 /// <remarks>Items are only added to a part created in the editor. Thus, reacting on the editor
 /// event.</remarks>
 /// <param name="type">Unused.</param>
 /// <param name="p">A target part.</param>
 void OnEditPartCreate(ConstructionEventType type, Part p)
 {
     if (type != ConstructionEventType.PartCreated && type != ConstructionEventType.PartCopied) {
       return;
     }
     var inventories = p.GetComponents<ModuleKISInventory>();
     foreach (var inventory in inventories) {
       if (inventory.podSeat != -1 && ModuleKISInventory.defaultItemsForAllSeats.Count > 0) {
     Logger.logInfo(
     "Adding default item(s) into seat's {0} inventory of part {1}: {2}",
     inventory.podSeat, p.name, Logger.C2S(ModuleKISInventory.defaultItemsForAllSeats));
     AddItems(inventory, ModuleKISInventory.defaultItemsForAllSeats);
       }
       if (inventory.podSeat == 0 && ModuleKISInventory.defaultItemsForTheFirstSeat.Count > 0) {
     Logger.logInfo("Adding default item(s) into the first seat of part {0}: {1}",
                p.name, Logger.C2S(ModuleKISInventory.defaultItemsForTheFirstSeat));
     AddItems(inventory, ModuleKISInventory.defaultItemsForTheFirstSeat);
       }
     }
 }
开发者ID:Kerbas-ad-astra,项目名称:KIS,代码行数:25,代码来源:EditorDefaultItemsAdder.cs

示例4: setResourcesInPart

 public void setResourcesInPart(Part part, float volume, bool fill)
 {
     part.Resources.list.Clear ();
     PartResource[] resources = part.GetComponents<PartResource> ();
     int len = resources.Length;
     for (int i = 0; i < len; i++)
     {
         GameObject.Destroy(resources[i]);
     }
     int rawFuelUnits = (int)(volume * unitsPerCubicMeter);
     int units;
     ConfigNode resourceNode;
     foreach (SSTUFuelEntry entry in fuelEntries)
     {
         units = entry.ratio * rawFuelUnits;
         resourceNode = new ConfigNode("RESOURCE");
         resourceNode.AddValue("name", entry.resourceName);
         resourceNode.AddValue("maxAmount", units);
         resourceNode.AddValue("amount", fill? units : 0);
         part.AddResource(resourceNode);
     }
 }
开发者ID:Kerbas-ad-astra,项目名称:SSTULabs,代码行数:22,代码来源:SSTUFuelType.cs

示例5: RemoveHingeJointBetween

 public static void RemoveHingeJointBetween(Part part1, Part part2)
 {
     List<HingeJoint> hingeJoints1 = new List<HingeJoint>(part1.GetComponents<HingeJoint>());
     foreach (HingeJoint hj1 in hingeJoints1)
     {
         if (hj1.connectedBody == part2.rigidbody)
         {
             UnityEngine.Object.Destroy(hj1);
         }
     }
     List<HingeJoint> hingeJoints2 = new List<HingeJoint>(part2.GetComponents<HingeJoint>());
     foreach (HingeJoint hj2 in hingeJoints2)
     {
         if (hj2.connectedBody == part1.rigidbody)
         {
             UnityEngine.Object.Destroy(hj2);
         }
     }
 }
开发者ID:ACCBizon,项目名称:KAS,代码行数:19,代码来源:KAS_Shared.cs

示例6: RemoveFixedJointBetween

 public static void RemoveFixedJointBetween(Part part1, Part part2)
 {
     List<FixedJoint> fixedJoints1 = new List<FixedJoint>(part1.GetComponents<FixedJoint>());
     foreach (FixedJoint fj1 in fixedJoints1)
     {
         if (fj1.connectedBody == part2.rigidbody)
         {
             UnityEngine.Object.Destroy(fj1);
         }
     }
     List<FixedJoint> fixedJoints2 = new List<FixedJoint>(part2.GetComponents<FixedJoint>());
     foreach (FixedJoint fj2 in fixedJoints2)
     {
         if (fj2.connectedBody == part1.rigidbody)
         {
             UnityEngine.Object.Destroy(fj2);
         }
     }
 }
开发者ID:ACCBizon,项目名称:KAS,代码行数:19,代码来源:KAS_Shared.cs

示例7: setupTankInPart

        private void setupTankInPart(Part currentPart, bool calledByPlayer)
        {
            currentPart.Resources.list.Clear();
            PartResource[] partResources = currentPart.GetComponents<PartResource>();
            for (int i = 0; i < partResources.Length; i++)
            {
                DestroyImmediate(partResources[i]);
            }            

            for (int tankCount = 0; tankCount < tankList.Count; tankCount++)
            {
                if (selectedTankSetup == tankCount)
                {
                    for (int resourceCount = 0; resourceCount < tankList[tankCount].resources.Count; resourceCount++)
                    {
                        if (tankList[tankCount].resources[resourceCount].name != "Structural")
                        {
                            //Debug.Log("new node: " + tankList[i].resources[j].name);
                            ConfigNode newResourceNode = new ConfigNode("RESOURCE");
                            newResourceNode.AddValue("name", tankList[tankCount].resources[resourceCount].name);
                            newResourceNode.AddValue("maxAmount", tankList[tankCount].resources[resourceCount].maxAmount);
                            if (calledByPlayer && !HighLogic.LoadedSceneIsEditor)
                            {
                                newResourceNode.AddValue("amount", 0.0f);
                            } 
                            else
                            {
                                newResourceNode.AddValue("amount", tankList[tankCount].resources[resourceCount].amount);
                            }

                            //Debug.Log("add node to part");
                            currentPart.AddResource(newResourceNode);                          
                        }
                        else
                        {
                            //Debug.Log("Skipping structural fuel type");
                        }
                    }
                }
            }
            currentPart.Resources.UpdateList();
            updateWeight(currentPart, selectedTankSetup);
            updateCost();
        }
开发者ID:KevinMilcz,项目名称:Firespitter,代码行数:44,代码来源:FSfuelSwitch.cs

示例8: checkPart

 private void checkPart(Part part) 
 {
     foreach (PartModule pm in part.GetComponents<PartModule>())
     {
         foreach (BaseEvent mEvent in pm.Events)
         {
             if (mEvent.guiActive & mEvent.active) 
             {
                 List<Part> partList;
                 if (!actionsList.ContainsKey(mEvent.guiName))
                 {
                     partList = new List<Part>();
                     actionsList.Add(mEvent.guiName, partList);
                 }
                 else 
                 {
                     partList = actionsList[mEvent.guiName];
                 }
                 if (partList != null) 
                 {
                     partList.Add(part);
                 }
                 
             }
         }
     }
 }
开发者ID:icedown,项目名称:VesselViewer,代码行数:27,代码来源:VViewMenuPartSelectorGlobal.cs

示例9: PartModelTransformList

        public static List<Transform> PartModelTransformList(Part p)
        {
            List<Transform> returnList = new List<Transform>();

            Transform[] propellersToIgnore = IgnoreModelTransformArray(p);

            returnList.AddRange(p.FindModelComponents<Transform>());

            if (p.Modules.Contains("ModuleJettison"))
            {
                ModuleJettison[] jettisons = p.GetComponents<ModuleJettison>();
                foreach (ModuleJettison j in jettisons)
                {
                    if (j.isJettisoned || j.jettisonTransform == null)
                        continue;

                    returnList.Add(j.jettisonTransform);
                }
            }

            foreach (Transform t in propellersToIgnore)
                returnList.Remove(t);

            //foreach (Transform t in returnList)
            //    Debug.Log(t.name);
            Debug.Log("Part: " + p.partInfo.title + " Transforms: " + returnList.Count);
            return returnList;
        }
开发者ID:vosechu,项目名称:Ferram-Aerospace-Research,代码行数:28,代码来源:FARGeoUtil.cs

示例10: PartModelTransformList

        public static List<Transform> PartModelTransformList(Part p)
        {
            List<Transform> returnList = new List<Transform>();

            //Very hacky, but is necessary for root parts with broken transforms
            if (p.partTransform == null)
            {
                bool root = p == p.vessel.rootPart;
                Debug.Log("This one is busted: " + p.partInfo.title + " root? " + root);
                if (root)
                    p.partTransform = p.vessel.vesselTransform;
            }

            Transform[] propellersToIgnore = IgnoreModelTransformArray(p);

            returnList.AddRange(p.FindModelComponents<Transform>());

            if (p.Modules.Contains("ModuleJettison"))
            {
                ModuleJettison[] jettisons = p.GetComponents<ModuleJettison>();
                foreach (ModuleJettison j in jettisons)
                {
                    if (j.isJettisoned || j.jettisonTransform == null)
                        continue;

                    returnList.Add(j.jettisonTransform);
                }
            }

            foreach (Transform t in propellersToIgnore)
                returnList.Remove(t);

            //foreach (Transform t in returnList)
            //    Debug.Log(t.name);
            Debug.Log("Part: " + p.partInfo.title + " Transforms: " + returnList.Count);
            return returnList;
        }
开发者ID:kevin-ye,项目名称:Ferram-Aerospace-Research,代码行数:37,代码来源:FARGeoUtil.cs

示例11: PartHide

 private void PartHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     MonoBehaviour.print("Hiding Part " + part.ToString());
     foreach (var r in part.GetComponents<Renderer>())
     {
         r.enabled = false;
     }
 }
开发者ID:EdwardWongHau,项目名称:ksp-kronalutils,代码行数:8,代码来源:VesselViewConfig.cs

示例12: setResourcesToPart

 public void setResourcesToPart(Part part, bool fill)
 {
     part.Resources.list.Clear();
     PartResource[] resources = part.GetComponents<PartResource>();
     int len = resources.Length;
     for (int i = 0; i < len; i++)
     {
         GameObject.Destroy(resources[i]);
     }            
     ConfigNode resourceNode;
     float amt = 0;
     foreach (String name in resourceMap.Keys)
     {
         amt = resourceMap[name];
         resourceNode = new ConfigNode("RESOURCE");
         resourceNode.AddValue("name", name);
         resourceNode.AddValue("maxAmount", amt);
         resourceNode.AddValue("amount", fill ? amt : 0);
         part.AddResource(resourceNode);
     }
 }
开发者ID:SixDasher,项目名称:SSTULabs,代码行数:21,代码来源:FuelType.cs

示例13: PartHide

 private void PartHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     foreach (var r in part.GetComponents<Renderer>())
     {
         r.enabled = false;
     }
 }
开发者ID:bigorangemachine,项目名称:ksp-kronalutils,代码行数:7,代码来源:VesselViewConfig.cs

示例14: partHasAction

 internal bool partHasAction(Part part) 
 {
     foreach (PartModule pm in part.GetComponents<PartModule>())
     {
         foreach (BaseEvent mEvent in pm.Events)
         {
             if (mEvent.guiActive & mEvent.active)
             {
                 if (mEvent.guiName.CompareTo(name) == 0)
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:icedown,项目名称:VesselViewer,代码行数:17,代码来源:VVsinglePartSubmenu.cs

示例15: checkPart

 private void checkPart(Part part)
 {
     foreach (PartModule pm in part.GetComponents<PartModule>())
     {
         foreach (BaseEvent mEvent in pm.Events)
         {
             if (mEvent.guiActive & mEvent.active)
             {
                 if (mEvent.guiName.CompareTo(name) == 0) 
                 {
                     if (master.getSymm()) 
                     {
                         foreach (Part oldPart in partList)
                         {
                             if (oldPart.symmetryCounterparts.Contains(part)) return;
                         }
                     }
                     partList.Add(part);
                     return;
                 }
             }
         }
     }
 }
开发者ID:icedown,项目名称:VesselViewer,代码行数:24,代码来源:VVsinglePartSubmenu.cs


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