Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to fulfill the requirements to complete an orbital logistics transfer.
        /// </summary>
        /// <param name="vessel"></param>
        /// <param name="resourceUnits">The amount of the transport resource required for the transfer.</param>
        /// <returns><c>true</c> if the requirements were met, <c>false</c> otherwise.</returns>
        public static bool DeductTransportCost(this Vessel vessel, double resourceUnits)
        {
            if (!vessel.CanAffordTransport(resourceUnits))
            {
                return(false);
            }

            // Deduct resource units from vessel
            PartResourceDefinition transportCredits = PartResourceLibrary.Instance.GetDefinition("TransportCredits");

            vessel.ExchangeResources(transportCredits.id, -resourceUnits);

            return(true);
        }
Ejemplo n.º 2
0
 public static double ExchangeResources(this Vessel vessel, string resourceName, double amount)
 {
     return(vessel.ExchangeResources(PartResourceLibrary.Instance.GetDefinition(resourceName), amount));
 }