public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                SettlementBase settlementBase = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlementBase != null && settlementBase.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlementBase, false));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlementBase.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
Пример #2
0
        public override void Arrived(Caravan caravan)
        {
            CameraJumper.TryJumpAndSelect(caravan);
            Pawn playerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);

            Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, settlement, giftsOnly: true));
        }
Пример #3
0
        public static Command TradeCommand(Caravan caravan, Faction faction = null, TraderKindDef trader = null)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan, faction, trader);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement settlement = SettlementVisitedNow(caravan);
                if (settlement != null && settlement.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlement.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent);
                }
            };
            if (bestNegotiator == null)
            {
                if (trader != null && trader.permitRequiredForTrading != null && !caravan.PawnsListForReading.Any((Pawn p) => p.royalty != null && p.royalty.HasPermit(trader.permitRequiredForTrading, faction)))
                {
                    command_Action.Disable("CommandTradeFailNeedPermit".Translate(trader.permitRequiredForTrading.LabelCap));
                }
                else
                {
                    command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
                }
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
        public static string GenerateCaravanName(Caravan caravan)
        {
            Pawn arg_4D_0;

            if ((arg_4D_0 = BestCaravanPawnUtility.FindBestNegotiator(caravan)) == null)
            {
                arg_4D_0 = (BestCaravanPawnUtility.FindBestDiplomat(caravan) ?? caravan.PawnsListForReading.Find((Pawn x) => caravan.IsOwner(x)));
            }
            Pawn   pawn = arg_4D_0;
            string text = (pawn == null) ? caravan.def.label : "CaravanLeaderCaravanName".Translate(pawn.LabelShort, pawn).CapitalizeFirst();

            for (int i = 1; i <= 1000; i++)
            {
                string text2 = text;
                if (i != 1)
                {
                    text2 = text2 + " " + i;
                }
                if (!CaravanNameGenerator.CaravanNameInUse(text2))
                {
                    return(text2);
                }
            }
            Log.Error("Ran out of caravan names.", false);
            return(caravan.def.label);
        }
Пример #5
0
        public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement settlement = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlement != null && settlement.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(settlement.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithSettlement".Translate(), false, true);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, settlement, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
Пример #6
0
        private static bool HasNegotiator(Caravan caravan)
        {
            Pawn pawn = BestCaravanPawnUtility.FindBestNegotiator(caravan);

            if (pawn != null)
            {
                return(!pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled);
            }
            return(false);
        }
Пример #7
0
        private static bool HasNegotiator(Caravan caravan, Settlement settlement)
        {
            Pawn pawn = BestCaravanPawnUtility.FindBestNegotiator(caravan, settlement.Faction, settlement.TraderKind);

            if (pawn != null)
            {
                return(!pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled);
            }
            return(false);
        }
Пример #8
0
 public static Command OfferGiftsCommand(Caravan caravan, SettlementBase settlement)
 {
     return(new Command_Action
     {
         defaultLabel = "CommandOfferGifts".Translate(),
         defaultDesc = "CommandOfferGiftsDesc".Translate(),
         icon = FactionGiftUtility.OfferGiftsCommandTex,
         action = delegate()
         {
             Pawn playerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
             Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, settlement, true));
         }
     });
 }
Пример #9
0
        public static Command OfferGiftsCommand(Caravan caravan, SettlementBase settlement)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandOfferGifts".Translate();
            command_Action.defaultDesc  = "CommandOfferGiftsDesc".Translate();
            command_Action.icon         = OfferGiftsCommandTex;
            command_Action.action       = delegate
            {
                Pawn playerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
                Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, settlement, giftsOnly: true));
            };
            return(command_Action);
        }
Пример #10
0
        private void DoRows(ref float curY, Rect scrollViewRect, Rect scrollOutRect)
        {
            List <Pawn> pawns = this.Pawns;
            Pawn        pawn  = BestCaravanPawnUtility.FindBestNegotiator(base.SelCaravan);

            GUI.color = new Color(0.8f, 0.8f, 0.8f, 1f);
            Widgets.Label(new Rect(0f, curY, scrollViewRect.width, 24f), string.Format("{0}: {1}", "Negotiator".Translate(), (pawn == null) ? "NoneCapable".Translate() : pawn.LabelShort));
            curY += 24f;
            if (this.specificSocialTabForPawn != null && !pawns.Contains(this.specificSocialTabForPawn))
            {
                this.specificSocialTabForPawn = null;
            }
            bool flag = false;

            for (int i = 0; i < pawns.Count; i++)
            {
                Pawn pawn2 = pawns[i];
                if (pawn2.RaceProps.IsFlesh)
                {
                    if (pawn2.IsColonist)
                    {
                        if (!flag)
                        {
                            Widgets.ListSeparator(ref curY, scrollViewRect.width, "CaravanColonists".Translate());
                            flag = true;
                        }
                        this.DoRow(ref curY, scrollViewRect, scrollOutRect, pawn2);
                    }
                }
            }
            bool flag2 = false;

            for (int j = 0; j < pawns.Count; j++)
            {
                Pawn pawn3 = pawns[j];
                if (pawn3.RaceProps.IsFlesh)
                {
                    if (!pawn3.IsColonist)
                    {
                        if (!flag2)
                        {
                            Widgets.ListSeparator(ref curY, scrollViewRect.width, "CaravanPrisonersAndAnimals".Translate());
                            flag2 = true;
                        }
                        this.DoRow(ref curY, scrollViewRect, scrollOutRect, pawn3);
                    }
                }
            }
        }
Пример #11
0
        public static string GenerateCaravanName(Caravan caravan)
        {
            Pawn         pawn         = BestCaravanPawnUtility.FindBestNegotiator(caravan) ?? BestCaravanPawnUtility.FindBestDiplomat(caravan) ?? caravan.PawnsListForReading.Find((Pawn x) => caravan.IsOwner(x));
            TaggedString taggedString = (pawn != null) ? "CaravanLeaderCaravanName".Translate(pawn.LabelShort, pawn).CapitalizeFirst() : ((TaggedString)caravan.def.label);

            for (int i = 1; i <= 1000; i++)
            {
                TaggedString taggedString2 = taggedString;
                if (i != 1)
                {
                    taggedString2 += " " + i;
                }
                if (!CaravanNameInUse(taggedString2))
                {
                    return(taggedString2);
                }
            }
            Log.Error("Ran out of caravan names.");
            return(caravan.def.label);
        }
Пример #12
0
            internal void <> m__0()
            {
                Pawn playerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(this.caravan);

                Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, this.settlement, true));
            }