當前位置: 首頁>>代碼示例>>C#>>正文


C# AvailablePart類代碼示例

本文整理匯總了C#中AvailablePart的典型用法代碼示例。如果您正苦於以下問題:C# AvailablePart類的具體用法?C# AvailablePart怎麽用?C# AvailablePart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AvailablePart類屬於命名空間,在下文中一共展示了AvailablePart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetDescription

 public static string GetDescription(AvailablePart part)
 {
     var sb = new StringBuilder();
     sb.AppendLine(part.title);
     sb.AppendLine(part.description);
     return sb.ToString();
 }
開發者ID:Kerbas-ad-astra,項目名稱:Workshop,代碼行數:7,代碼來源:WorkshopUtils.cs

示例2: ProcessFactoryPart

 public static Blueprint ProcessFactoryPart(AvailablePart part)
 {
     var resources = new Dictionary<string, WorkshopResource>();
     if (PartRecipes.ContainsKey(part.name))
     {
         var recipe = FactoryRecipes[part.name];
         foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
         {
             if (resources.ContainsKey(workshopResource.Name))
             {
                 resources[workshopResource.Name].Merge(workshopResource);
             }
             else
             {
                 resources[workshopResource.Name] = workshopResource;
             }
         }
     }
     else
     {
         Debug.LogWarning("[OSE] - No FactoryRecipeFound for " + part.title);
         return null;
     }
     var blueprint = new Blueprint();
     blueprint.AddRange(resources.Values);
     blueprint.Funds = Mathf.Max(part.cost - (float)blueprint.ResourceCosts(), 0);
     return blueprint;
 }
開發者ID:Kerbas-ad-astra,項目名稱:Workshop,代碼行數:28,代碼來源:WorkshopRecipeDatabase.cs

示例3: KIS_Item

 /// <summary>Creates a new part from save.</summary>
 public KIS_Item(AvailablePart availablePart, ConfigNode itemNode, ModuleKISInventory inventory,
           float quantity = 1)
 {
     // Get part node
     this.availablePart = availablePart;
     partNode = new ConfigNode();
     itemNode.GetNode("PART").CopyTo(partNode);
     // init config
     this.InitConfig(availablePart, inventory, quantity);
     // Get mass
     if (itemNode.HasValue("resourceMass")) {
       resourceMass = float.Parse(itemNode.GetValue("resourceMass"));
     } else {
       resourceMass = availablePart.partPrefab.GetResourceMass();
     }
     if (itemNode.HasValue("contentMass")) {
       contentMass = float.Parse(itemNode.GetValue("contentMass"));
     }
     if (itemNode.HasValue("contentCost")) {
       contentCost = float.Parse(itemNode.GetValue("contentCost"));
     }
     if (itemNode.HasValue("inventoryName")) {
       inventoryName = itemNode.GetValue("inventoryName");
     }
 }
開發者ID:Kerbas-ad-astra,項目名稱:KIS,代碼行數:26,代碼來源:KIS_Item.cs

示例4: GetParachuteDragFromPart

 public static double GetParachuteDragFromPart(AvailablePart parachute)
 {
     /* foreach (AvailablePart.ModuleInfo mi in parachute.moduleInfos)
     {
         if (mi.info.Contains("Fully-Deployed Drag"))
         {
             string[] split = mi.info.Split(new Char[] { ':', '\n' });
             for (int i = 0; i < split.Length; i++)
             {
                 if (split[i].Contains("Fully-Deployed Drag"))
                 {
                     float drag = 500;
                     if (!float.TryParse(split[i + 1], out drag))
                     {
                         string[] split2 = split[i + 1].Split('>');
                         if (!float.TryParse(split2[1], out drag))
                         {
                             Debug.Log("[SR] Failure trying to read parachute data. Assuming 500 drag.");
                             drag = 500;
                         }
                     }
                     return drag;
                 }
             }
         }
     }*/
     double area = 0;
     if (parachute.partPrefab.Modules.Contains("ModuleParachute"))
     {
         area = ((ModuleParachute)parachute.partPrefab.Modules["ModuleParachute"]).areaDeployed;
     }
     return area;
 }
開發者ID:Kerbas-ad-astra,項目名稱:StageRecovery,代碼行數:33,代碼來源:RecoveryItem.cs

示例5: AddAlternator

        void AddAlternator(ConfigNode node, AvailablePart aPart)
        {
            // Get or add module
            ModuleReliabilityAlternator rModule = aPart.partPrefab.GetComponent<ModuleReliabilityAlternator>();
            if (rModule)
            {
                Logger.DebugWarning("ModuleReliabilityAlternator already added to \"" + aPart.name + "\"!");
            }
            else
            {
                rModule = aPart.partPrefab.AddModule("ModuleReliabilityAlternator") as ModuleReliabilityAlternator;
                if (!rModule)
                {
                    Logger.DebugError("Problem adding module to engine!");
                    return;
                }
            }

            //Configure the base values
            ConfigureBaseValues(node, rModule);

            if (node.HasValue("idleChanceToFailPerfect")) { rModule.idleChanceToFailPerfect = double.Parse(node.GetValue("idleChanceToFailPerfect")); }
            if (node.HasValue("idleChanceToFailTerrible")) { rModule.idleChanceToFailTerrible = double.Parse(node.GetValue("idleChanceToFailTerrible")); }
            if (node.HasValue("stressedChanceToFailPerfect")) { rModule.stressedChanceToFailPerfect = double.Parse(node.GetValue("stressedChanceToFailPerfect")); }
            if (node.HasValue("stressedChanceToFailTerrible")) { rModule.stressedChanceToFailTerrible = double.Parse(node.GetValue("stressedChanceToFailTerrible")); }
            if (node.HasValue("maxGeesPerfect")) { rModule.maxGeesPerfect = double.Parse(node.GetValue("maxGeesPerfect")); }
            if (node.HasValue("maxGeesTerrible")) { rModule.maxGeesTerrible = double.Parse(node.GetValue("maxGeesTerrible")); }
        }
開發者ID:panarchist,項目名稱:KerbalMechanics,代碼行數:28,代碼來源:ModuleInjector.cs

示例6: DoUnlock

        protected void DoUnlock(AvailablePart part)
        {
            ProtoTechNode ptn = ResearchAndDevelopment.Instance.GetTechState(part.TechRequired);

            // The tech may be null - we need to create it
            if (ptn == null)
            {
                ptn = new ProtoTechNode();
                ptn.state = RDTech.State.Unavailable;
                ptn.techID = part.TechRequired;
                ptn.scienceCost = 9999; // ignored
            }

            if (unlockTech)
            {
                ptn.state = RDTech.State.Available;
            }

            if (!HighLogic.CurrentGame.Parameters.Difficulty.BypassEntryPurchaseAfterResearch && !ptn.partsPurchased.Contains(part))
            {
                ptn.partsPurchased.Add(part);
            }
            else
            {
                ptn.partsPurchased = new List<AvailablePart>();
            }

            ResearchAndDevelopment.Instance.SetTechState(part.TechRequired, ptn);
        }
開發者ID:linuxgurugamer,項目名稱:ContractConfigurator,代碼行數:29,代碼來源:UnlockPart.cs

示例7: PartEntryCostHolder

 public PartEntryCostHolder(ConfigNode node, AvailablePart part, string Name = "")
 {
     Load(node);
     if(Name != "")
         name = Name;
     entryCost = part.entryCost;
     ap = part;
 }
開發者ID:jhathawaytn,項目名稱:RP-0,代碼行數:8,代碼來源:PartEntryCostHolder.cs

示例8: ProcessPart

        public static Blueprint ProcessPart(AvailablePart part)
        {
            var resources = new Dictionary<string, WorkshopResource>();
            if (PartRecipes.ContainsKey(part.name))
            {
                var recipe = PartRecipes[part.name];
                foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
                {
                    if (resources.ContainsKey(workshopResource.Name))
                    {
                        resources[workshopResource.Name].Merge(workshopResource);
                    }
                    else
                    {
                        resources[workshopResource.Name] = workshopResource;
                    }
                }
            }
            else
            {
                foreach (var workshopResource in DefaultPartRecipe.Prepare(part.partPrefab.mass))
                {
                    if (resources.ContainsKey(workshopResource.Name))
                    {
                        resources[workshopResource.Name].Merge(workshopResource);
                    }
                    else
                    {
                        resources[workshopResource.Name] = workshopResource;
                    }
                }
            }

            foreach (PartResource partResource in part.partPrefab.Resources)
            {
                if (ResourceRecipes.ContainsKey(partResource.resourceName))
                {
                    var definition = PartResourceLibrary.Instance.GetDefinition(partResource.resourceName);
                    var recipe = ResourceRecipes[partResource.resourceName];
                    foreach (var workshopResource in recipe.Prepare(partResource.maxAmount * definition.density))
                    {
                        if (resources.ContainsKey(workshopResource.Name))
                        {
                            resources[workshopResource.Name].Merge(workshopResource);
                        }
                        else
                        {
                            resources[workshopResource.Name] = workshopResource;
                        }
                    }
                }
            }

            var blueprint = new Blueprint();
            blueprint.AddRange(resources.Values);
            blueprint.Funds = Mathf.Max(0, part.cost - (float)blueprint.ResourceCosts());
            return blueprint;
        }
開發者ID:Kerbas-ad-astra,項目名稱:Workshop,代碼行數:58,代碼來源:WorkshopRecipeDatabase.cs

示例9: CreatePart

        public static Part CreatePart(AvailablePart avPart, Vector3 position, Quaternion rotation, Part flagFromPart)
        {
            UnityEngine.Object obj = UnityEngine.Object.Instantiate(avPart.partPrefab);
            if (!obj)
            {
                KAS_Shared.DebugError("CreatePart(Crate) Failed to instantiate " + avPart.partPrefab.name);
                return null;
            }

            Part newPart = (Part)obj;
            newPart.gameObject.SetActive(true);
            newPart.gameObject.name = avPart.name;
            newPart.partInfo = avPart;
            newPart.highlightRecurse = true;
            newPart.SetMirror(Vector3.one);

            ShipConstruct newShip = new ShipConstruct();
            newShip.Add(newPart);
            newShip.SaveShip();
            newShip.shipName = avPart.title;
            newShip.shipType = 1;

            VesselCrewManifest vessCrewManifest = new VesselCrewManifest();
            Vessel currentVessel = FlightGlobals.ActiveVessel;

            Vessel v = newShip.parts[0].localRoot.gameObject.AddComponent<Vessel>();
            v.id = Guid.NewGuid();
            v.vesselName = newShip.shipName;
            v.Initialize(false);
            v.Landed = true;
            v.rootPart.flightID = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
            v.rootPart.missionID = flagFromPart.missionID;
            v.rootPart.flagURL = flagFromPart.flagURL;

            //v.rootPart.collider.isTrigger = true;

            //v.landedAt = "somewhere";

            Staging.beginFlight();
            newShip.parts[0].vessel.ResumeStaging();
            Staging.GenerateStagingSequence(newShip.parts[0].localRoot);
            Staging.RecalculateVesselStaging(newShip.parts[0].vessel);

            FlightGlobals.SetActiveVessel(currentVessel);

            v.SetPosition(position);
            v.SetRotation(rotation);

            // Solar panels from containers don't work otherwise
            for (int i = 0; i < newPart.Modules.Count; i++)
            {
                ConfigNode node = new ConfigNode();
                node.AddValue("name", newPart.Modules[i].moduleName);
                newPart.LoadModule(node, i);
            }

            return newPart;
        }
開發者ID:Blanks821,項目名稱:KAS,代碼行數:58,代碼來源:KAS_Shared.cs

示例10: Load

        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<AvailablePart>(configNode, "part", x => part = x, this);

            return valid;
        }
開發者ID:ToneStack87,項目名稱:ContractConfigurator,代碼行數:9,代碼來源:PartTestFactory.cs

示例11: PartContent

            private PartContent(AvailablePart avPart, KASModuleGrab grab)
            {
                part = avPart;
                grabModule = grab;
                pristine_mass = part.partPrefab.mass;

                foreach (var res in part.partPrefab.GetComponents<PartResource>())
                {
                    pristine_mass += (float)(res.amount * res.info.density);
                }
            }
開發者ID:ACCBizon,項目名稱:KAS,代碼行數:11,代碼來源:KASModuleContainer.cs

示例12: EditorItemsFilter

 private bool EditorItemsFilter(AvailablePart avPart)
 {
     if (avPartItems.Contains(avPart))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
開發者ID:khr15714n,項目名稱:KIS,代碼行數:11,代碼來源:KISAddonEditorFilter.cs

示例13: ItemDescription

 public static void ItemDescription(AvailablePart part, string resourceName, double productivity)
 {
     GUILayout.BeginVertical();
     var text = new StringBuilder();
     text.AppendLine(part.title);
     var density = PartResourceLibrary.Instance.GetDefinition(resourceName).density;
     var requiredResources = (part.partPrefab.mass / density) * productivity;
     text.AppendLine(" " + requiredResources.ToString("0.00") + " " + resourceName);
     GUILayout.Box(text.ToString(), WorkshopStyles.Databox(), GUILayout.Width(250), GUILayout.Height(50));
     GUILayout.EndVertical();
 }
開發者ID:Kerbas-ad-astra,項目名稱:Workshop,代碼行數:11,代碼來源:WorkshopGui.cs

示例14: fixSader

 private void fixSader(AvailablePart availablePart, string brokenShaderName, Shader fixShader)
 {
     // Debug.Log ("IconFixAddon : part: " + availablePart.name);
     foreach (Renderer r in availablePart.iconPrefab.GetComponentsInChildren<Renderer>(true)) {
         foreach (Material m in r.materials) {
             if (m.shader.name == brokenShaderName) {
                 Debug.Log ("IconFixAddon: fixing icon of: " + availablePart.name);
                 m.shader = fixShader;
             }
         }
     }
 }
開發者ID:Kerbas-ad-astra,項目名稱:CommandSeatIconFix,代碼行數:12,代碼來源:IconFixAddon.cs

示例15: AddItem

 public KISItemWrapper AddItem(AvailablePart aPart, ConfigNode configNode, float quantity = 1, int slot = -1)
 {
     return
         KISItemWrapper.FromObject(_partModule.InvokeMethod("AddItem", new object[] { aPart, configNode, quantity, slot },
                                                            new[]
                                                            {
                                                                typeof (AvailablePart),
                                                                typeof (ConfigNode),
                                                                typeof (float),
                                                                typeof (int)
                                                            }));
 }
開發者ID:zerosofadown,項目名稱:Agile.Ksp,代碼行數:12,代碼來源:KISInventoryModuleWrapper.cs


注:本文中的AvailablePart類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。