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


C# PartResourceDefinition类代码示例

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


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

示例1: AddOrCreateResource

        // Amount < 0 signifies use existing amount if exists, or create with max amount
        public static PartResource AddOrCreateResource(this Part part, PartResourceDefinition info, float maxAmount, float amount)
        {
            if (amount > maxAmount)
            {
                part.LogWarning($"Cannot add resource '{info.name}' with amount > maxAmount, will use maxAmount (amount = {amount}, maxAmount = {maxAmount})");
                amount = maxAmount;
            }

            PartResource resource = part.Resources[info.name];

            if (resource == null)
            {
                if (amount < 0f)
                    amount = maxAmount;

                resource = part.AddResource(info, maxAmount, amount);
            }
            else
            {
                resource.maxAmount = maxAmount;

                if (amount >= 0f)
                    resource.amount = amount;
            }

            return resource;
        }
开发者ID:blowfishpro,项目名称:B9PartSwitch,代码行数:28,代码来源:PartExtensions.cs

示例2: IsResourceAvailable

        public static double IsResourceAvailable(this Part part, PartResourceDefinition resource, double demand)
        {
            if (resource == null)
            {
                Debug.LogError("Tac.PartExtensions.IsResourceAvailable: resource is null");
                return 0.0;
            }

            switch (resource.resourceFlowMode)
            {
                case ResourceFlowMode.NO_FLOW:
                    return IsResourceAvailable_NoFlow(part, resource, demand);
                case ResourceFlowMode.ALL_VESSEL:
                    return IsResourceAvailable_AllVessel(part, resource, demand);
                case ResourceFlowMode.STACK_PRIORITY_SEARCH:
                    return IsResourceAvailable_StackPriority(part, resource, demand);
                /*case ResourceFlowMode.EVEN_FLOW:
                    Debug.LogWarning("Tac.PartExtensions.IsResourceAvailable: ResourceFlowMode.EVEN_FLOW is not supported yet.");
                    return IsResourceAvailable_AllVessel(part, resource, demand);
                    */
                default:
                    Debug.LogWarning("Tac.PartExtensions.IsResourceAvailable: Unknown ResourceFlowMode = " + resource.resourceFlowMode.ToString());
                    return IsResourceAvailable_AllVessel(part, resource, demand);
            }
        }
开发者ID:MartinLyne,项目名称:BioMass,代码行数:25,代码来源:PartExtensions.cs

示例3: AggregateResourceValue

 public AggregateResourceValue(PartResourceDefinition definition, SharedObjects shared)
 {
     name = definition.name;
     density = definition.density;
     this.shared = shared;
     resources = new List<PartResource>();
     InitializeAggregateResourceSuffixes();
 }
开发者ID:CalebJ2,项目名称:KOS,代码行数:8,代码来源:AggregateResourceValue.cs

示例4: getResourceVolume

 public float getResourceVolume(String name, PartResourceDefinition def)
 {
     float val = 0;
     if (!resourceVolumes.TryGetValue(name, out val))
     {
         val = def == null ? 5.0f : def.volume;
     }
     return val;
 }
开发者ID:shadowmage45,项目名称:SSTULabs,代码行数:9,代码来源:FuelType.cs

示例5: Load

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

            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minRate", x => minRate = x, this, double.MinValue);
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxRate", x => maxRate = x, this, double.MaxValue);
            valid &= ConfigNodeUtil.ParseValue<PartResourceDefinition>(configNode, "resource", x => resource = x, this);

            return valid;
        }
开发者ID:Kerbas-ad-astra,项目名称:ContractConfigurator,代码行数:11,代码来源:ResourceConsumptionFactory.cs

示例6: ResourceTransferValue

        public ResourceTransferValue(TransferManager transferManager, PartResourceDefinition resourceInfo, object transferTo, object transferFrom)
        {
            this.transferManager = transferManager;
            this.resourceInfo = resourceInfo;
            this.transferTo = transferTo;
            this.transferFrom = transferFrom;

            DetermineTypes();
            InitializeSuffixes();

            Status = TransferManager.TransferStatus.Inactive; // Last because the setter for Status prints some of the values calculated above to the log
        }
开发者ID:KSP-KOS,项目名称:KOS,代码行数:12,代码来源:ResourceTransferValue.cs

示例7: ResourceTransfer

 ResourceTransfer (Part fromPart, Part toPart, PartResourceDefinition resource, float amount)
 {
     internalFromPart = fromPart;
     internalToPart = toPart;
     internalResource = resource;
     FromPart = new Parts.Part (fromPart);
     ToPart = new Parts.Part (toPart);
     Resource = resource.name;
     TotalAmount = amount;
     // Compute the transfer rate (in units/sec) as one tenth the size of the destination tank (determined experimentally from the KSP transfer UI)
     var totalStorage = (float)toPart.Resources.Get (resource.id).maxAmount;
     transferRate = 0.1f * totalStorage;
     ResourceTransferAddon.AddTransfer (this);
 }
开发者ID:paperclip,项目名称:krpc,代码行数:14,代码来源:ResourceTransfer.cs

示例8: ResourceConsumption

 public ResourceConsumption(double minRate, double maxRate, PartResourceDefinition resource, string title = null)
     : base(title)
 {
     if (minRate < 0 && maxRate < 0 && maxRate < minRate)
     {
         this.minRate = maxRate;
         this.maxRate = minRate;
     }
     else
     {
         this.minRate = minRate;
         this.maxRate = maxRate;
     }
     this.resource = resource;
 }
开发者ID:Kerbas-ad-astra,项目名称:ContractConfigurator,代码行数:15,代码来源:ResourceConsuption.cs

示例9: AddResource

        public static PartResource AddResource(this Part part, PartResourceDefinition info, float maxAmount, float amount)
        {
            PartResource resource = new PartResource(part);
            resource.SetInfo(info);
            resource.maxAmount = maxAmount;
            resource.amount = amount;
            resource.flowState = true;
            resource.isTweakable = info.isTweakable;
            resource.isVisible = info.isVisible;
            resource.hideFlow = false;
            resource.flowMode = PartResource.FlowMode.Both;
            part.Resources.dict.Add(info.name.GetHashCode(), resource);

            return resource;
        }
开发者ID:blowfishpro,项目名称:B9PartSwitch,代码行数:15,代码来源:PartExtensions.cs

示例10: ResourceQuantity

        /// <summary>
        /// Gets the quantity of the given resource for the vessel.
        /// </summary>
        /// <param name="vessel">Vessel to check</param>
        /// <param name="resource">Resource to check for</param>
        /// <returns></returns>
        public static double ResourceQuantity(this Vessel vessel, PartResourceDefinition resource)
        {
            if (vessel == null)
            {
                return 0.0;
            }

            double quantity = 0.0;
            foreach (Part part in vessel.Parts)
            {
                PartResource pr = part.Resources[resource.name];
                if (pr != null)
                {
                    quantity += pr.amount;
                }
            }
            return quantity;
        }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:24,代码来源:Extensions.cs

示例11: TransferableResource

        public TransferableResource(PartResourceDefinition r)
        {
            resource = r;
            name = resource.name;
            mode = resource.resourceTransferMode;

            switch (name)
            {
                case "LiquidFuel":
                    icon = EVATransfer_Startup.lfIcon;
                    color = XKCDColors.LightRed;
                    break;
                case "Oxidizer":
                    icon = EVATransfer_Startup.loxIcon;
                    color = XKCDColors.OrangeyYellow;
                    break;
                case "MonoPropellant":
                    icon = EVATransfer_Startup.monoIcon;
                    color = Color.white;
                    break;
                case "XenonGas":
                    icon = EVATransfer_Startup.xenonIcon;
                    color = XKCDColors.AquaBlue;
                    break;
                case "ElectricCharge":
                    icon = EVATransfer_Startup.ecIcon;
                    color = XKCDColors.SunnyYellow;
                    break;
                case "Ore":
                    icon = EVATransfer_Startup.oreIcon;
                    color = XKCDColors.Purple_Pink;
                    break;
                default:
                    icon = null;
                    color = Color.white;
                    break;
            }

            if (icon != null)
                primary = true;
        }
开发者ID:kfsone,项目名称:KSP-EVA-Transfer,代码行数:41,代码来源:TransferableResource.cs

示例12: PersistentPropellant

 // Constructor
 PersistentPropellant(Propellant p)
 {
     propellant = p;
     definition = PartResourceLibrary.Instance.GetDefinition(propellant.name);
     density = definition.density;
     ratio = propellant.ratio;
 }
开发者ID:Kerbas-ad-astra,项目名称:PersistentThrust,代码行数:8,代码来源:Propellant.cs

示例13: ResourceInfo

 public ResourceInfo(ConfigNode node)
 {
     node.TryGetValue("name", ref this.name);
     resource = PartResourceLibrary.Instance.GetDefinition(this.Name);
     node.TryGetValue("realName", ref this.realName);
     node.TryGetValue("colour", ref this.colour);
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:7,代码来源:ResourceInfoLibrary.cs

示例14: Load

 public void Load(ConfigNode node)
 {
     int resourceID = node.GetValue("name").GetHashCode();
     if (PartResourceLibrary.Instance.resourceDefinitions.Any(rd => rd.id == resourceID))
     {
         resource = PartResourceLibrary.Instance.resourceDefinitions[resourceID];
         float.TryParse(node.GetValue("ratio"), out ratio);
     }
 }
开发者ID:01010101lzy,项目名称:B9-PWings-Fork,代码行数:9,代码来源:WingTankResource.cs

示例15: Load

 public void Load(ConfigNode node)
 {
     string resourceID = node.GetValue("name");
     if (PartResourceLibrary.Instance.resourceDefinitions.Contains(resourceID))
     {
         resource = PartResourceLibrary.Instance.resourceDefinitions[resourceID];
         float.TryParse(node.GetValue("ratio"), out ratio);
     }
 }
开发者ID:Crzyrndm,项目名称:ProceduralWings,代码行数:9,代码来源:WingTankResource.cs


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