public static void CreateAgreement(Alliance alliance, Settlement settlement, int totalCost, int agreementDelay, List <AgreementGood> items, FactionInteraction signer, int trust, Window windowToClose, int formCaravanDelay) { if (totalCost == 0) { return; } if (agreementDelay == 0) { return; } if (items == null) { return; } Map targetMap = Find.Maps.Where(x => x.IsPlayerHome).First(x2 => x2.resourceCounter.Silver >= totalCost); if (PriceUtils.TakeSilverFromPlayer(totalCost, targetMap)) { List <Thing> toBuy = new List <Thing>(); foreach (var item in items) { if (item.Thing is Pawn pawn) { toBuy.Add(item.Thing); settlement.trader.StockListForReading.Remove(item.Thing); if (Find.WorldPawns.Contains(pawn)) { Find.WorldPawns.RemovePawn(pawn); } } else { toBuy.Add(item.Thing.SplitOff(item.CountToTransfer)); if (item.Thing.stackCount == 0) { settlement.trader.StockListForReading.Remove(item.Thing); } } } signer.Trust -= trust; TradeSchedulingAgreementComp comp = new TradeSchedulingAgreementComp(alliance, signer, toBuy, settlement, targetMap, agreementDelay * 60000, formCaravanDelay * 60000); alliance.AddAgreement(comp); Find.LetterStack.ReceiveLetter("TradeSchedulingAgreement_CreateSucessTitle".Translate(), "TradeSchedulingAgreement_CreateSucessDesc".Translate(settlement.Faction.Name, totalCost, settlement.Name, agreementDelay), LetterDefOf.PositiveEvent); if (windowToClose != null) { windowToClose.Close(); } } }
public void CreateAgreement() { faction.Trust -= totalCost; DefenseContractComp defenseContractComp = new DefenseContractComp(alliance, faction, playerInteraction, fightersType, contractDaysDuration); alliance.AddAgreement(defenseContractComp); Find.LetterStack.ReceiveLetter("DefenseContractCompWindow_CreatedTitle".Translate(), "DefenseContractCompWindow_CreatedDesc".Translate(contractDaysDuration, faction.Faction.Name), LetterDefOf.PositiveEvent); }