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); }
private int TryGainRoyalFavor(Caravan caravan) { int num = 0; if (base.Faction.def.HasRoyalTitles) { num = DiplomacyTuning.RoyalFavor_PeaceTalksSuccessRange.RandomInRange; BestCaravanPawnUtility.FindBestDiplomat(caravan)?.royalty.GainFavor(base.Faction, num); } return(num); }
private string GetLetterText(string baseText, Caravan caravan) { string text = baseText; Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan); if (pawn != null) { text = text + "\n\n" + "PeaceTalksSocialXPGain".Translate(pawn.LabelShort, 6000f); } return(text); }
private string GetLetterText(string baseText, Caravan caravan, FactionRelationKind previousRelationKind) { string text = baseText; Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan); if (pawn != null) { text = text + "\n\n" + "PeaceTalksSocialXPGain".Translate(pawn.LabelShort, 6000f.ToString("F0"), pawn.Named("PAWN")); } base.Faction.TryAppendRelationKindChangedInfo(ref text, previousRelationKind, base.Faction.PlayerRelationKind); return(text); }
public void Notify_CaravanArrived(Caravan caravan) { Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan); if (pawn == null) { Messages.Message("MessagePeaceTalksNoDiplomat".Translate(), caravan, MessageTypeDefOf.NegativeEvent, false); return; } float badOutcomeWeightFactor = PeaceTalks.GetBadOutcomeWeightFactor(pawn); float num = 1f / badOutcomeWeightFactor; PeaceTalks.tmpPossibleOutcomes.Clear(); PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate() { this.Outcome_Disaster(caravan); }, 0.05f * badOutcomeWeightFactor)); PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate() { this.Outcome_Backfire(caravan); }, 0.1f * badOutcomeWeightFactor)); PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate() { this.Outcome_TalksFlounder(caravan); }, 0.2f)); PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate() { this.Outcome_Success(caravan); }, 0.55f * num)); PeaceTalks.tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate() { this.Outcome_Triumph(caravan); }, 0.1f * num)); Action first = PeaceTalks.tmpPossibleOutcomes.RandomElementByWeight((Pair <Action, float> x) => x.Second).First; first(); pawn.skills.Learn(SkillDefOf.Social, 6000f, true); Find.WorldObjects.Remove(this); }
public void Notify_CaravanArrived(Caravan caravan) { Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan); if (pawn == null) { Messages.Message("MessagePeaceTalksNoDiplomat".Translate(), caravan, MessageTypeDefOf.NegativeEvent, historical: false); return; } float badOutcomeWeightFactor = GetBadOutcomeWeightFactor(pawn); float num = 1f / badOutcomeWeightFactor; tmpPossibleOutcomes.Clear(); tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate { Outcome_Disaster(caravan); }, 0.05f * badOutcomeWeightFactor)); tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate { Outcome_Backfire(caravan); }, 0.1f * badOutcomeWeightFactor)); tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate { Outcome_TalksFlounder(caravan); }, 0.2f)); tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate { Outcome_Success(caravan); }, 0.55f * num)); tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate { Outcome_Triumph(caravan); }, 0.1f * num)); tmpPossibleOutcomes.RandomElementByWeight((Pair <Action, float> x) => x.Second).First(); pawn.skills.Learn(SkillDefOf.Social, 6000f, direct: true); QuestUtility.SendQuestTargetSignals(questTags, "Resolved", this.Named("SUBJECT")); Destroy(); }
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); }