• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AvailablePart类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AvailablePart的典型用法代码示例。如果您正苦于以下问题:C# AvailablePart类的具体用法?C# AvailablePart怎么用?C# AvailablePart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AvailablePart类属于命名空间,在下文中一共展示了AvailablePart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: 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 = "KASCreatedPart";
            newPart.partInfo = avPart;
            newPart.highlightRecurse = true;

            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 = (uint)Guid.NewGuid().GetHashCode();
            v.rootPart.flagURL = flagFromPart.flagURL;

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

            v.rootPart.FindModelTransform("model").localScale *= v.rootPart.rescaleFactor;

            //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);
            return newPart;
        }
开发者ID:ErzengelLichtes,项目名称:KAS,代码行数:50,代码来源:KAS_Shared.cs


示例17: EvaAddLifeSupport

        private void EvaAddLifeSupport(AvailablePart part)
        {
            Part prefabPart = part.partPrefab;

            this.Log("Adding resources to " + part.name + "/" + prefabPart.partInfo.title);

            EvaAddPartModule(prefabPart);

            EvaAddResource(prefabPart, globalSettings.EvaElectricityConsumptionRate, globalSettings.Electricity, false);
            EvaAddResource(prefabPart, globalSettings.FoodConsumptionRate, globalSettings.Food, false);
            EvaAddResource(prefabPart, globalSettings.WaterConsumptionRate, globalSettings.Water, false);
            EvaAddResource(prefabPart, globalSettings.OxygenConsumptionRate, globalSettings.Oxygen, false);
            EvaAddResource(prefabPart, globalSettings.CO2ProductionRate, globalSettings.CO2, false);
            EvaAddResource(prefabPart, globalSettings.WasteProductionRate, globalSettings.Waste, false);
            EvaAddResource(prefabPart, globalSettings.WasteWaterProductionRate, globalSettings.WasteWater, false);
        }
开发者ID:VenVen,项目名称:TacLifeSupport,代码行数:16,代码来源:AddLifeSupport.cs


示例18: findExperimentModulInPC

 private ConfigNode findExperimentModulInPC(ProtoPartModuleSnapshot kasModule, AvailablePart experiment)
 {
     ConfigNode partConf = kasModule.moduleValues;
     foreach (ConfigNode contentPart in partConf.GetNodes(CONTENT_PART))
     {
         NE_Helper.log("ContentPart: " + contentPart.GetValue("name"));
         if (contentPart.GetValue("name") == experiment.name)
         {
             foreach (ConfigNode module in contentPart.GetNodes("MODULE"))
             {
                 if (module.GetValue("name") == experimentModulname[experiment.name])
                     return module;
             }
         }
     }
     return null;
 }
开发者ID:N3h3miah,项目名称:OrbitalMaterialScience,代码行数:17,代码来源:KEESExperimentRecovery.cs


示例19: GetKisStats

        public static string GetKisStats(AvailablePart part)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Mass: " + part.partPrefab.mass + " tons");
            sb.AppendLine("Volume: " + KIS_Shared.GetPartVolume(part).ToString("0.0") + " litres");
            sb.AppendLine("Costs: " + part.cost + "$");

            foreach (var resourceInfo in part.partPrefab.Resources)
            {
                if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName))
                {
                    sb.AppendLine(resourceInfo.resourceName + ": " + resourceInfo.maxAmount + " / " + resourceInfo.maxAmount);
                }
                else
                {
                    sb.AppendLine(resourceInfo.resourceName + ": 0 / " + resourceInfo.maxAmount);
                }
            }
            return sb.ToString();
        }
开发者ID:Kerbas-ad-astra,项目名称:Workshop,代码行数:20,代码来源:WorkshopUtils.cs


示例20: AddAltimeter

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

            ConfigureBaseValues(node, rModule);
            ConfigureInstrumentValues(node, rModule);
        }
开发者ID:panarchist,项目名称:KerbalMechanics,代码行数:21,代码来源:ModuleInjector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AvatarAppearance类代码示例发布时间:2022-05-24
下一篇:
C# Availability类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap