Esempio n. 1
0
        /// <summary>
        /// Supplies the given IResourceSink with the given resource type.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="type"></param>
        /// <param name="supplyAvailableThisUpdate"></param>
        /// <param name="elapsedMS"></param>
        void _supplyResource(IResourceSink s, ResourceTypes type, ref float supplyAvailableThisUpdate, float elapsedMS)
        {
            float supplyAmount = GetSupplyRate(s) * elapsedMS;

            //Set proper supply amount, according to the thorium supply available
            if (supplyAmount > _model.Resources[type].NumUnits)
            {
                supplyAmount = _model.Resources[type].NumUnits;
            }

            //Make sure supplyAmount doesn't exceed how much can be supplied this update
            if (supplyAmount > supplyAvailableThisUpdate)
            {
                supplyAmount = supplyAvailableThisUpdate;
            }

            float amountUnstored = supplyAmount;

            s.StoreResources(type, ref amountUnstored);
            supplyAvailableThisUpdate -= (supplyAmount - amountUnstored);
            _model.Resources[type].TakeResource(supplyAmount - amountUnstored);

            if (_model.Resources[type].NumUnits <= 0)//If we've supplied all the resources that we can
            {
#if DEBUG
                if (_model.Resources[type].NumUnits < 0)
                {
                    ConsoleManager.WriteLine("Remaining resource amount is less than 0", ConsoleMessageType.Warning);//This shouldn't happen, but just in case
                }
#endif
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Supplies the given IResourceSink with the given resource type.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="type"></param>
        /// <param name="supplyAvailableThisUpdate"></param>
        /// <param name="elapsedMS"></param>
        void _supplyResource(IResourceSink s, ResourceTypes type, ref float supplyAvailableThisUpdate, float elapsedMS)
        {
            float supplyAmount = GetSupplyRate(s) * elapsedMS;

            //Make sure supplyAmount doesn't exceed how much can be supplied this update
            if (supplyAmount > supplyAvailableThisUpdate)
            {
                supplyAmount = supplyAvailableThisUpdate;
            }

            float amountUnstored = supplyAmount;

            s.StoreResources(type, ref amountUnstored);
            supplyAvailableThisUpdate -= (supplyAmount - amountUnstored);
        }