示例#1
0
        public bool Paid(Map map)
        {
            CompetitionTableRecord playerRecord = competitionTableRecords?.FirstOrDefault(x => x.Faction == Faction.OfPlayer);

            if (playerRecord == null)
            {
                Messages.Message("Competitions_NeedToStartForPaid".Translate(), MessageTypeDefOf.NeutralEvent);
                return(false);
            }

            if (playerRecord.Paid)
            {
                Messages.Message("Competitions_AlreadyPaid".Translate(), MessageTypeDefOf.NeutralEvent);
                return(false);
            }

            if (PriceUtils.TakeSilverFromPlayer(600, map))
            {
                playerRecord.Paid = true;

                Find.LetterStack.ReceiveLetter("Competitions_JudgPaidTitle".Translate(), "Competitions_JudgPaidDesc".Translate(), LetterDefOf.PositiveEvent);

                return(true);
            }

            return(false);
        }
        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();
                }
            }
        }