private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, Site site, SitePart sitePart) { string text = string.Format(this.def.letterText, new object[] { alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items).TrimEndNewlines(), days.ToString(), SitePartUtility.GetDescriptionDialogue(site, sitePart) }).CapitalizeFirst(); if (items.Count == 1 || (items.Count >= 2 && items.All((Thing x) => x.def == items[0].def))) { string text2 = text; text = string.Concat(new string[] { text2, "\n\n---\n\n", items[0].LabelCapNoCount, ": ", items[0].DescriptionFlavor }); } return(text); }
public override string GetDescription(RewardsGeneratorParams parms) { if (parms.giveToCaravan) { return("Reward_Items_Caravan".Translate(GenLabel.ThingsLabel(items), TotalMarketValue.ToStringMoney())); } return("Reward_Items".Translate(GenLabel.ThingsLabel(items), TotalMarketValue.ToStringMoney())); }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (!(signal.tag == inSignal)) { return; } pawns.RemoveAll((Pawn x) => x.Destroyed); if (mapParent == null || !mapParent.HasMap || !pawns.Any()) { return; } for (int i = 0; i < pawns.Count; i++) { if (joinPlayer && pawns[i].Faction != Faction.OfPlayer) { pawns[i].SetFaction(Faction.OfPlayer); } } IncidentParms incidentParms = new IncidentParms(); incidentParms.target = mapParent.Map; incidentParms.spawnCenter = spawnNear; PawnsArrivalModeDef obj = arrivalMode ?? PawnsArrivalModeDefOf.EdgeWalkIn; obj.Worker.TryResolveRaidSpawnCenter(incidentParms); obj.Worker.Arrive(pawns, incidentParms); if (!sendStandardLetter) { return; } TaggedString title; TaggedString text; if (joinPlayer && pawns.Count == 1 && pawns[0].RaceProps.Humanlike) { text = "LetterRefugeeJoins".Translate(pawns[0].Named("PAWN")); title = "LetterLabelRefugeeJoins".Translate(pawns[0].Named("PAWN")); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawns[0]); } else { if (joinPlayer) { text = "LetterPawnsArriveAndJoin".Translate(GenLabel.ThingsLabel(pawns.Cast <Thing>())); title = "LetterLabelPawnsArriveAndJoin".Translate(); } else { text = "LetterPawnsArrive".Translate(GenLabel.ThingsLabel(pawns.Cast <Thing>())); title = "LetterLabelPawnsArrive".Translate(); } PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref title, ref text, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); } title = (customLetterLabel.NullOrEmpty() ? title : customLetterLabel.Formatted(title.Named("BASELABEL"))); text = (customLetterText.NullOrEmpty() ? text : customLetterText.Formatted(text.Named("BASETEXT"))); Find.LetterStack.ReceiveLetter(title, text, customLetterDef ?? LetterDefOf.PositiveEvent, pawns[0], null, quest); }
private string GenerateMessageText(Faction enemyFaction, int attackerCount, List <Thing> demands) { return("CaravanDemand".Translate(new object[] { enemyFaction.Name, attackerCount, GenLabel.ThingsLabel(demands), enemyFaction.def.pawnsPlural })); }
private string GenerateMessageText(Faction enemyFaction, int attackerCount, List <ThingCount> demands, Caravan caravan) { return("CaravanDemand".Translate(new object[] { caravan.Name, enemyFaction.Name, attackerCount, GenLabel.ThingsLabel(demands, " - "), enemyFaction.def.pawnsPlural }).CapitalizeFirst()); }
public static string ThingsLabel(List <Thing> things, string prefix = " - ") { GenLabel.tmpThingCounts.Clear(); for (int i = 0; i < things.Count; i++) { GenLabel.tmpThingCounts.Add(new ThingCount(things[i], things[i].stackCount)); } string result = GenLabel.ThingsLabel(GenLabel.tmpThingCounts, prefix); GenLabel.tmpThingCounts.Clear(); return(result); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, Site site, SitePart sitePart) { string result = string.Format(this.def.letterText, new object[] { alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items, " - "), days.ToString(), SitePartUtility.GetDescriptionDialogue(site, sitePart), GenThing.GetMarketValue(items).ToStringMoney(null) }).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref result, items); return(result); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, SitePartDef sitePart, bool sitePartsKnown, int fee) { string text; if (sitePartsKnown) { text = this.GetSitePartInfo(sitePart, alliedFaction.leader.LabelShort).CapitalizeFirst(); } else { text = "ItemStashSitePart_Unknown".Translate(new object[] { alliedFaction.leader.LabelShort }).CapitalizeFirst(); } string text2 = string.Format(this.def.letterText, new object[] { alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items).TrimEndNewlines(), days.ToString(), text }).CapitalizeFirst(); if (fee > 0) { text2 = text2 + "\n\n" + "ItemStashQuestFeeDemand".Translate(new object[] { alliedFaction.leader.LabelShort, fee }).CapitalizeFirst(); } if (items.Count == 1) { string text3 = text2; text2 = string.Concat(new string[] { text3, "\n\n---\n\n", items[0].LabelCap, ": ", items[0].GetDescription() }); } return(text2); }
protected override bool TryExecuteWorker(IncidentParms parms) { Faction faction; Faction faction2; if (!this.TryFindFactions(out faction, out faction2)) { return(false); } int tile; if (!this.TryFindTile(out tile)) { return(false); } Site site = SiteMaker.MakeSite(SiteCoreDefOf.Nothing, SitePartDefOf.Outpost, tile, faction2, true, null); site.sitePartsKnown = true; List <Thing> list = this.GenerateRewards(faction, site.desiredThreatPoints); site.GetComponent <DefeatAllEnemiesQuestComp>().StartQuest(faction, 18, list); int randomInRange = SiteTuning.QuestSiteTimeoutDaysRange.RandomInRange; site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000); Find.WorldObjects.Add(site); string text = string.Format(this.def.letterText, new object[] { faction.leader.LabelShort, faction.def.leaderTitle, faction.Name, GenLabel.ThingsLabel(list, string.Empty), randomInRange.ToString(), SitePartUtility.GetDescriptionDialogue(site, site.parts.FirstOrDefault <SitePart>()), GenThing.GetMarketValue(list).ToStringMoney(null) }).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref text, list); Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, this.def.letterDef, site, faction, null); return(true); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, Site site, SitePart sitePart) { string text = def.letterText.Formatted(alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items), days.ToString(), SitePartUtility.GetDescriptionDialogue(site, sitePart), GenThing.GetMarketValue(items).ToStringMoney()).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref text, items); return(text); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, SitePartDef sitePart, bool sitePartsKnown, int fee) { string text = (!sitePartsKnown) ? "ItemStashSitePart_Unknown".Translate(alliedFaction.leader.LabelShort).CapitalizeFirst() : this.GetSitePartInfo(sitePart, alliedFaction.leader.LabelShort).CapitalizeFirst(); string text2 = string.Format(base.def.letterText, alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items).TrimEndNewlines(), days.ToString(), text).CapitalizeFirst(); if (fee > 0) { text2 = text2 + "\n\n" + "ItemStashQuestFeeDemand".Translate(alliedFaction.leader.LabelShort, fee).CapitalizeFirst(); } if (items.Count == 1) { string text3 = text2; text2 = text3 + "\n\n---\n\n" + items[0].LabelCap + ": " + items[0].GetDescription(); } return(text2); }
public List <Thing> ApplyRewardsForTitle(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool onlyForNewestTitle = false) { List <Thing> list = new List <Thing>(); List <ThingCount> list2 = new List <ThingCount>(); if (newTitle != null && newTitle.Awardable && pawn.IsColonist && NewHighestTitle(faction, newTitle)) { int num = ((currentTitle != null) ? faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) : 0) + 1; int num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle); if (onlyForNewestTitle) { num = num2; } IntVec3 result = IntVec3.Invalid; Map mapHeld = pawn.MapHeld; if (mapHeld != null) { if (mapHeld.IsPlayerHome) { result = DropCellFinder.TradeDropSpot(mapHeld); } else if (!DropCellFinder.TryFindDropSpotNear(pawn.Position, mapHeld, out result, allowFogged: false, canRoofPunch: false)) { result = DropCellFinder.RandomDropSpot(mapHeld); } } for (int i = num; i <= num2; i++) { RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading[i]; if (royalTitleDef.rewards == null) { continue; } List <Thing> list3 = royalTitleDef.rewards.Select(delegate(ThingDefCountClass r) { Thing thing = ThingMaker.MakeThing(r.thingDef); thing.stackCount = r.count; return(thing); }).ToList(); for (int j = 0; j < list3.Count; j++) { if (list3[j].def == ThingDefOf.PsychicAmplifier) { Find.History.Notify_PsylinkAvailable(); break; } } if (pawn.Spawned) { DropPodUtility.DropThingsNear(result, mapHeld, list3, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false, forbid: false); } else { foreach (Thing item in list3) { pawn.inventory.TryAddItemNotForSale(item); } } for (int k = 0; k < list3.Count; k++) { list2.Add(new ThingCount(list3[k], list3[k].stackCount)); } list.AddRange(list3); } if (list.Count > 0) { TaggedString text = "LetterRewardsForNewTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE")) + "\n\n" + GenLabel.ThingsLabel(list2, " - ", ignoreStackLimit: true) + "\n\n" + (pawn.Spawned ? "LetterRewardsForNewTitleDeliveryBase" : "LetterRewardsForNewTitleDeliveryDirect").Translate(pawn.Named("PAWN")); Find.LetterStack.ReceiveLetter("LetterLabelRewardsForNewTitle".Translate(), text, LetterDefOf.PositiveEvent, list); } } return(list); }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (!(signal.tag == inSignal)) { return; } pawns.RemoveAll((Pawn x) => x.Destroyed); items.RemoveAll((Thing x) => x.Destroyed); Thing thing = Things.Where((Thing x) => x is Pawn).MaxByWithFallback((Thing x) => x.MarketValue); Thing thing2 = Things.MaxByWithFallback((Thing x) => x.MarketValue * (float)x.stackCount); if (mapParent != null && mapParent.HasMap && Things.Any()) { Map map = mapParent.Map; IntVec3 intVec = (dropSpot.IsValid ? dropSpot : GetRandomDropSpot()); if (sendStandardLetter) { TaggedString title; TaggedString text; if (joinPlayer && pawns.Count == 1 && pawns[0].RaceProps.Humanlike) { text = "LetterRefugeeJoins".Translate(pawns[0].Named("PAWN")); title = "LetterLabelRefugeeJoins".Translate(pawns[0].Named("PAWN")); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawns[0]); } else { text = "LetterQuestDropPodsArrived".Translate(GenLabel.ThingsLabel(Things)); title = "LetterLabelQuestDropPodsArrived".Translate(); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref title, ref text, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); } title = (customLetterLabel.NullOrEmpty() ? title : customLetterLabel.Formatted(title.Named("BASELABEL"))); text = (customLetterText.NullOrEmpty() ? text : customLetterText.Formatted(text.Named("BASETEXT"))); Find.LetterStack.ReceiveLetter(title, text, customLetterDef ?? LetterDefOf.PositiveEvent, new TargetInfo(intVec, map), null, quest); } if (joinPlayer) { for (int i = 0; i < pawns.Count; i++) { if (pawns[i].Faction != Faction.OfPlayer) { pawns[i].SetFaction(Faction.OfPlayer); } } } else if (makePrisoners) { for (int j = 0; j < pawns.Count; j++) { if (pawns[j].RaceProps.Humanlike) { if (!pawns[j].IsPrisonerOfColony) { pawns[j].guest.SetGuestStatus(Faction.OfPlayer, prisoner: true); } HealthUtility.TryAnesthetize(pawns[j]); } } } for (int k = 0; k < pawns.Count; k++) { pawns[k].needs.SetInitialLevels(); } DropPodUtility.DropThingsNear(intVec, map, Things, 110, canInstaDropDuringInit: false, leaveSlag: false, !useTradeDropSpot, forbid: false); importantLookTarget = items.Find((Thing x) => x.GetInnerIfMinified() is MonumentMarker).GetInnerIfMinified(); items.Clear(); } if (!outSignalResult.NullOrEmpty()) { if (thing != null) { Find.SignalManager.SendSignal(new Signal(outSignalResult, thing.Named("SUBJECT"))); } else if (thing2 != null) { Find.SignalManager.SendSignal(new Signal(outSignalResult, thing2.Named("SUBJECT"))); } else { Find.SignalManager.SendSignal(new Signal(outSignalResult)); } } }