示例#1
0
        protected override void recoverResourceCost(string resourceName, double recycleAmount)
        {
            //Do we have sufficient space in the vessel to store the recycled parts?
            double availableStorage = ResourceHelper.GetTotalResourceSpaceAvailable(resourceName, this.part.vessel);

            if (availableStorage < recycleAmount)
            {
                double amountLost = recycleAmount - availableStorage;
                ScreenMessages.PostScreenMessage(string.Format("Module deflated, {0:f2} {1:s} lost due to insufficient storage.", amountLost, resourceName), 5.0f, ScreenMessageStyle.UPPER_CENTER);

                //We'll only recycle what we have room to store.
                recycleAmount = availableStorage;
            }

            //Yup, we have the space
            this.part.RequestResource(resourceName, -recycleAmount, ResourceFlowMode.ALL_VESSEL);
        }
示例#2
0
        protected override void recoverResourceCost(string resourceName, double recycleAmount)
        {
            double availableStorage = ResourceHelper.GetTotalResourceSpaceAvailable(resourceName, this.part.vessel);

            //Do we have sufficient space in the vessel to store the recycled parts?
            //If not, distrubute what we don't have space for.
            if (availableStorage < recycleAmount)
            {
                double amountRemaining = recycleAmount - availableStorage;
                string recycleMessage;

                //We'll only recycle what we have room to store aboard the vessel.
                recycleAmount = availableStorage;

                //Distribute the rest.
                List <DistributedResource> recycledResources = new List <DistributedResource>();
                recycleMessage = string.Format(kResourceDistributed, amountRemaining, resourceName);
                recycledResources.Add(new DistributedResource(resourceName, amountRemaining, recycleMessage));
                WBIDistributionManager.Instance.DistributeResources(recycledResources);
            }

            //Store what we have space for.
            this.part.RequestResource(resourceName, -recycleAmount, ResourceFlowMode.ALL_VESSEL);
        }