コード例 #1
0
        /// <summary>
        /// Approves and registers the transfer for delivery.
        /// </summary>
        /// <param name="transferList"></param>
        /// <returns></returns>
        public bool Launch(List <OrbitalLogisticsTransferRequest> transferList, out string result)
        {
            if (transferList.Contains(this))
            {
                result = "This transfer has already been launched.";
                return(true);
            }

            bool success = false;

            // If we are resuming a previously cancelled launch, do just the final launch tasks
            if (Status == DeliveryStatus.Returning)
            {
                DoFinalLaunchTasks(transferList);
                result  = "Resumed!";
                success = true;
            }
            // For a new launch, do all the launch tasks
            else
            {
                // Determine if the fuel requirements can be met
                float fuelUnits = CalculateFuelUnits();
                if (Origin.CanAffordTransport(fuelUnits))
                {
                    // Deduct the cost of the transfer and do other launch tasks
                    Origin.DeductTransportCost(fuelUnits);

                    success = DoLaunchTasks(transferList);
                    result  = "Launched!";
                }
                else
                {
                    result = "Insufficient funds!";
                }
            }

            return(success);
        }