示例#1
0
        public override void consumeNeeds()
        {
            base.consumeNeeds();
            if (artisansProduction != null)
            {
                PayWithoutRecord(artisansProduction, Cash);

                // take loan if don't have enough money to buy inputs
                if (Country.Invented(Invention.Banking) && !artisansProduction.isAllInputProductsCollected() &&
                    artisansProduction.Type.getPossibleProfit(Country.market).isNotZero())
                {
                    var needs = artisansProduction.getRealAllNeeds();
                    if (!artisansProduction.CanAfford(needs))
                    {
                        var loanSize = Country.market.getCost(needs); // takes little more than really need, could be fixed
                        Bank.GiveCredit(this, loanSize);
                        PayWithoutRecord(artisansProduction, Cash);
                    }
                }

                artisansProduction.consumeNeeds();
                artisansProduction.PayWithoutRecord(this, artisansProduction.Cash);

                // consuming made in artisansProduction.consumeNeeds()
                // here is data transferring
                // todo rework data transferring from artisans?
                foreach (var item in artisansProduction.getAllConsumedInMarket())
                {
                    consumedInMarket.Add(item);
                }

                foreach (var item in artisansProduction.getConsumed())
                {
                    consumed.Add(item);
                }

                getConsumedLastTurn().Add(artisansProduction.getConsumedLastTurn());
            }
        }