// Do I use where need to? Yes, I do. It goes to Market.Buy() public void consumeFromMarket(Storage what) { consumed.Add(what); consumedInMarket.Add(what); World.market.sentToMarket.Subtract(what); if (Game.logMarket) { Debug.Log(this + " consumed from market " + what + " costing " + World.market.getCost(what)); } }
// Do I use where need to? Yes, I do. It called from this.Buy() protected virtual void Buy_utility(Market market, MoneyView cost, Storage what) { this.Pay(market, cost); consumed.Add(what); consumedInMarket.Add(new KeyValuePair <Market, Storage>(market, what)); market.SendGoods(what); if (Game.logMarket) { Debug.Log(this + " consumed from " + market + " " + what + " costing " + Country.market.getCost(what)); } }
/// <summary> /// Do checks outside /// </summary> public void sell(Storage what) { sentToMarket.Add(what); //countryStorageSet.subtract(what); countryStorageSet.subtractNoStatistic(what); // to avoid getting what in "howMuchUsed" statistics Game.market.sentToMarket.Add(what); }
public void consume(Country owner) { var needs = getRealNeeds(owner); float shortage = 0f; Storage realConsumption = Storage.EmptyProduct; foreach (var need in needs) { if (owner.countryStorageSet.has(need)) { if (need.isAbstractProduct()) { // convertToBiggestStorageProduct here are duplicated in this.getConsumptionProcent() (getBiggestStorage()) realConsumption = owner.countryStorageSet.convertToBiggestStorage(need); } else { realConsumption = need; } if (realConsumption.isNotZero()) { owner.consumeFromCountryStorage(realConsumption, owner); //owner.countryStorageSet.subtract(realConsumption); consumption.Add(realConsumption); } } else { shortage += need.get(); } } float moraleChange = getConsumptionProcent(Product.Food, owner).get() - morale.get(); moraleChange = Mathf.Clamp(moraleChange, Options.ArmyMaxMoralChangePerTic * -1f, Options.ArmyMaxMoralChangePerTic); if (morale.get() + moraleChange < 0) { morale.Set(0f); } else { morale.Add(moraleChange); } if (this.origin.Type == PopType.Soldiers && morale.isBiggerThan(origin.loyalty)) { morale.Set(origin.loyalty); } if (morale.isBiggerThan(Procent.HundredProcent)) { morale.Set(1f); } //if (getPopUnit().loyalty.isSmallerThan(Options.PopMinLoyaltyToMobilizeForGovernment)) // Country.demobilize(x => x.getPopUnit() == this); }
public List <Storage> getNeeds() { // StorageSet used for faster calculation StorageSet res = new StorageSet(); foreach (var item in personal) { res.Add(item.Value.getRealNeeds(getOwner().Country)); } return(res.ToList()); }
internal void upgrade(IShareOwner byWhom) { currentInvestor = byWhom; upgrading = true; constructionNeeds.Add(getUpgradeNeeds()); if ((byWhom as Agent).GetCountry().economy.getValue() != Economy.PlannedEconomy) { var cost = Game.market.getCost(getUpgradeNeeds()); (byWhom as Agent).payWithoutRecord(this, cost); ownership.Add(byWhom, cost); //Debug.Log(byWhom + " invested " + cost + " in upgrading " + this); } //else // Debug.Log(byWhom + " invested in upgrading " + this); }
private StorageSet getConsumption() { var consumption = new StorageSet(); foreach (var item in personal) { consumption.Add(item.Value.getConsumption()); } // Procent res = new Procent(0f); //int calculatedSize = 0; //foreach (var item in personal) //{ // res.addPoportionally(calculatedSize, item.Value.getSize(), item.Value.getConsumption()); // calculatedSize += item.Value.getSize(); //} //return res; return(consumption); }
// Do I use where need to? Yes, I do. It goes to Market.Buy() public void consumeFromMarket(Storage what) { consumed.Add(what); consumedInMarket.Add(what); Game.market.sentToMarket.Subtract(what); }
public void ReceiveProducts(Storage what) { receivedGoods.Add(what); }