示例#1
0
        /// <summary>
        /// Attempts to reserve resource storage in this warehouse, returning a boolean indicating whether the operation was successful
        /// </summary>
        /// <param name="reserver">GameObject to which this reservation should be attached</param>
        /// <param name="resourceKind">Resource type tag</param>
        /// <param name="amount">Amount to reserve</param>
        /// <returns>true on success, false on failure</returns>
        public bool ReserveStorage(GameObject reserver, ResourceKind resourceKind, double amount)
        {
            if (GetAvailableStorage(resourceKind) < amount)
            {
                return(false);
            }

            StorageReservation r = Factory.AddComponent <StorageReservation>(reserver);

            r.warehouse    = this;
            r.amount       = amount;
            r.resourceKind = resourceKind;
            r.Ready        = true;
            storageReservations.Add(r);
            return(true);
        }
示例#2
0
 /// <summary>
 /// Deposits the contents of the given reservation into this warehouse
 /// </summary>
 /// <param name="res">A reservation (for this warehosue)</param>
 public void DepositReservation(StorageReservation res)
 {
     if (!res.Ready)
     {
         throw new Exception("Reservation is not ready");
     }
     foreach (ResourceProfile rp in resourceContents)
     {
         if (rp.ResourceKind == res.resourceKind)
         {
             res.Released = true;
             rp.Amount   += res.amount;
             storageReservations.Remove(res);
             SendMessage("OnResourceDeposited", SendMessageOptions.DontRequireReceiver);
             return;
         }
     }
     throw new Exception("Unable to deposit reservation");
 }
 public StoreReservationOrder(ActorController a, StorageReservation r) : base()
 {
     res = r;
 }