public override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "PlayerStartsWith") { yield return(GenLabel.ThingLabel(this.thingDef, this.stuff, this.count).CapitalizeFirst()); } }
public override void ProcessInput(Event ev) { if (!base.CheckCanInteract()) { return; } ThingDef thingDef = this.entDef as ThingDef; if (thingDef == null || !thingDef.MadeFromStuff) { base.ProcessInput(ev); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thingDef2 in base.Map.resourceCounter.AllCountedAmounts.Keys) { if (thingDef2.IsStuff && thingDef2.stuffProps.CanMake(thingDef) && (DebugSettings.godMode || base.Map.listerThings.ThingsOfDef(thingDef2).Count > 0)) { ThingDef localStuffDef = thingDef2; string label = GenLabel.ThingLabel(this.entDef, localStuffDef, 1).CapitalizeFirst(); list.Add(new FloatMenuOption(label, delegate() { this.< ProcessInput > __BaseCallProxy0(ev); Find.DesignatorManager.Select(this); this.stuffDef = localStuffDef; this.writeStuff = true; }, MenuOptionPriority.Default, null, null, 0f, null, null) { tutorTag = "SelectStuff-" + thingDef.defName + "-" + localStuffDef.defName });
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(StatRequest req) { using (IEnumerator <StatDrawEntry> enumerator = base.SpecialDisplayStats(req).GetEnumerator()) { if (enumerator.MoveNext()) { StatDrawEntry s = enumerator.Current; yield return(s); /*Error: Unable to find new state assignment for yield return*/; } } if (((ThingDef)req.Def).building.IsTurret) { StatCategoryDef building = StatCategoryDefOf.Building; string label = "RearmCost".Translate(); string valueString = GenLabel.ThingLabel(fuelFilter.AnyAllowedDef, null, (int)(fuelCapacity / FuelMultiplierCurrentDifficulty)).CapitalizeFirst(); string overrideReportText = "RearmCostExplanation".Translate(); yield return(new StatDrawEntry(building, label, valueString, 0, overrideReportText)); /*Error: Unable to find new state assignment for yield return*/; } yield break; IL_01be: /*Error near IL_01bf: Unexpected return in MoveNext()*/; }
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 static string ThingLabel(Thing t, int stackCount, bool includeHp = true) { GenLabel.LabelRequest key = default(GenLabel.LabelRequest); key.entDef = t.def; key.stuffDef = t.Stuff; key.stackCount = stackCount; t.TryGetQuality(out key.quality); if (t.def.useHitPoints && includeHp) { key.health = t.HitPoints; key.maxHealth = t.MaxHitPoints; } Apparel apparel = t as Apparel; if (apparel != null) { key.wornByCorpse = apparel.WornByCorpse; } string text; if (!GenLabel.labelDictionary.TryGetValue(key, out text)) { if (GenLabel.labelDictionary.Count > 2000) { GenLabel.labelDictionary.Clear(); } text = GenLabel.NewThingLabel(t, stackCount, includeHp); GenLabel.labelDictionary.Add(key, text); } return(text); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: if (tag == "PlayerStartsWith") { this.$current = GenLabel.ThingLabel(this.thingDef, this.stuff, this.count).CapitalizeFirst(); if (!this.$disposing) { this.$PC = 1; } return(true); } break; case 1u: break; default: return(false); } this.$PC = -1; return(false); }
private static string NewThingLabel(Thing t) { string text = GenLabel.ThingLabel(t.def, t.Stuff, 1); QualityCategory cat = default(QualityCategory); bool flag = t.TryGetQuality(out cat); int hitPoints = t.HitPoints; int maxHitPoints = t.MaxHitPoints; bool flag2 = t.def.useHitPoints && hitPoints < maxHitPoints && t.def.stackLimit == 1; Apparel apparel = t as Apparel; bool flag3 = apparel != null && apparel.WornByCorpse; if (flag || flag2 || flag3) { text += " ("; if (flag) { text += cat.GetLabel(); } if (flag2) { if (flag) { text += " "; } text += ((float)hitPoints / (float)maxHitPoints).ToStringPercent(); } if (flag3) { text = text + " " + "WornByCorpseChar".Translate(); } text += ")"; } return(text); }
public override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "MapScatteredWith") { yield return(GenLabel.ThingLabel(thingDef, stuff, count).CapitalizeFirst()); } }
public static string PawnKindsToCommaList(IEnumerable <PawnKindDef> pawnKinds, bool useAnd = false) { PawnUtility.tmpPawnKinds.Clear(); PawnUtility.tmpPawnKinds.AddRange(pawnKinds); if (PawnUtility.tmpPawnKinds.Count >= 2) { PawnUtility.tmpPawnKinds.SortBy((PawnKindDef x) => !x.RaceProps.Humanlike, (PawnKindDef x) => GenLabel.BestKindLabel(x, Gender.None, true, -1)); } PawnUtility.tmpAddedPawnKinds.Clear(); PawnUtility.tmpPawnKindsStr.Clear(); for (int i = 0; i < PawnUtility.tmpPawnKinds.Count; i++) { if (!PawnUtility.tmpAddedPawnKinds.Contains(PawnUtility.tmpPawnKinds[i])) { PawnUtility.tmpAddedPawnKinds.Add(PawnUtility.tmpPawnKinds[i]); int num = 0; for (int j = 0; j < PawnUtility.tmpPawnKinds.Count; j++) { if (PawnUtility.tmpPawnKinds[j] == PawnUtility.tmpPawnKinds[i]) { num++; } } if (num == 1) { PawnUtility.tmpPawnKindsStr.Add("1 " + GenLabel.BestKindLabel(PawnUtility.tmpPawnKinds[i], Gender.None, false, -1)); } else { PawnUtility.tmpPawnKindsStr.Add(num + " " + GenLabel.BestKindLabel(PawnUtility.tmpPawnKinds[i], Gender.None, true, num)); } } } return(PawnUtility.tmpPawnKindsStr.ToCommaList(useAnd)); }
public override string CompInspectStringExtra() { if (PropsSpawner.writeTimeLeftToSpawn && (!PropsSpawner.requiresPower || PowerOn)) { return("NextSpawnedItemIn".Translate(GenLabel.ThingLabel(PropsSpawner.thingToSpawn, null, PropsSpawner.spawnCount)) + ": " + ticksUntilSpawn.ToStringTicksToPeriod()); } return(null); }
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); }
public override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "MapScatteredWith") { yield return(GenLabel.ThingLabel(thingDef, stuff, count).CapitalizeFirst()); /*Error: Unable to find new state assignment for yield return*/; } }
public override IEnumerable <string> GetSummaryListEntries(string tag) { if (!(tag == "PlayerStartsWith")) { yield break; } yield return(GenLabel.ThingLabel(base.thingDef, base.stuff, base.count).CapitalizeFirst()); /*Error: Unable to find new state assignment for yield return*/; }
public override void Notify_GeneratedByQuestGen(SitePart part, Slate slate, List <Rule> outExtraDescriptionRules, Dictionary <string, string> outExtraDescriptionConstants) { base.Notify_GeneratedByQuestGen(part, slate, outExtraDescriptionRules, outExtraDescriptionConstants); int animalsCount = GetAnimalsCount(part.parms); string output = GenLabel.BestKindLabel(part.parms.animalKind, Gender.None, plural: true, animalsCount); outExtraDescriptionRules.Add(new Rule_String("count", animalsCount.ToString())); outExtraDescriptionRules.Add(new Rule_String("kindLabel", output)); outExtraDescriptionConstants.Add("count", animalsCount.ToString()); }
private string GenerateMessageText(Faction enemyFaction, int attackerCount, List <Thing> demands) { return("CaravanDemand".Translate(new object[] { enemyFaction.Name, attackerCount, GenLabel.ThingsLabel(demands), enemyFaction.def.pawnsPlural })); }
public static string ThingsLabel(List <ThingCount> things, string prefix = " - ") { GenLabel.tmpThingsLabelElements.Clear(); foreach (ThingCount thing in things) { GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements where thing.Thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.Thing.def && elem.thingTemplate.Stuff == thing.Thing.Stuff select elem).FirstOrDefault <GenLabel.LabelElement>(); if (labelElement != null) { labelElement.count += thing.Count; } else { GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement { thingTemplate = thing.Thing, count = thing.Count }); } } GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs) { int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def); if (num != 0) { return(num); } return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue)); }); StringBuilder stringBuilder = new StringBuilder(); foreach (GenLabel.LabelElement current in GenLabel.tmpThingsLabelElements) { string str = string.Empty; if (current.thingTemplate.ParentHolder is Pawn_ApparelTracker) { str = " (" + "WornBy".Translate(((Pawn)current.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)current.thingTemplate.ParentHolder.ParentHolder) + ")"; } else if (current.thingTemplate.ParentHolder is Pawn_EquipmentTracker) { str = " (" + "EquippedBy".Translate(((Pawn)current.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)current.thingTemplate.ParentHolder.ParentHolder) + ")"; } if (current.count == 1) { stringBuilder.AppendLine(prefix + current.thingTemplate.LabelCap + str); } else { stringBuilder.AppendLine(prefix + GenLabel.ThingLabel(current.thingTemplate.def, current.thingTemplate.Stuff, current.count).CapitalizeFirst() + str); } } GenLabel.tmpThingsLabelElements.Clear(); return(stringBuilder.ToString().TrimEndNewlines()); }
/// <summary> /// Helper method that returns GenLabel of the ThingDefs /// </summary> /// <returns>GenLabel of the ThingDefs</returns> private string GenLabels() { List <string> labels = new List <string>(); foreach (ThingDef def in this.things) { labels.Add(GenLabel.ThingLabel(def, null, this.count)); } return(String.Join(" or ".Translate(), labels.ToArray())); }
public override string CompInspectStringExtra() { if (this.PropsSpawner.writeTimeLeftToSpawn && (!this.PropsSpawner.requiresPower || this.PowerOn)) { return("NextSpawnedItemIn".Translate(new object[] { GenLabel.ThingLabel(this.PropsSpawner.thingToSpawn, null, this.PropsSpawner.spawnCount) }) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true)); } return(null); }
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 void DoThingRow(ThingDef thingDef, int count, List <Thing> things, float width, ref float curY) { Rect rect = new Rect(0f, curY, width, 28f); if (things.Count == 1) { Widgets.InfoCardButton(rect.width - 24f, curY, things[0]); } else { Widgets.InfoCardButton(rect.width - 24f, curY, thingDef); } rect.width -= 24f; if (Mouse.IsOver(rect)) { GUI.color = ThingHighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thingDef.DrawMatSingle != null && thingDef.DrawMatSingle.mainTexture != null) { Rect rect2 = new Rect(4f, curY, 28f, 28f); if (things.Count == 1) { Widgets.ThingIcon(rect2, things[0]); } else { Widgets.ThingIcon(rect2, thingDef); } } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect rect3 = new Rect(36f, curY, rect.width - 36f, rect.height); string str = (things.Count != 1) ? GenLabel.ThingLabel(thingDef, null, count).CapitalizeFirst() : things[0].LabelCap; Text.WordWrap = false; Widgets.Label(rect3, str.Truncate(rect3.width)); Text.WordWrap = true; Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, str); if (Widgets.ButtonInvisible(rect)) { SelectLater(things); } if (Mouse.IsOver(rect)) { for (int i = 0; i < things.Count; i++) { TargetHighlighter.Highlight(things[i]); } } curY += 28f; }
public override string GetPostProcessedThreatLabel(Site site, SiteCoreOrPartBase siteCoreOrPart) { int animalsCount = this.GetAnimalsCount(siteCoreOrPart.parms); return(string.Concat(new object[] { base.GetPostProcessedThreatLabel(site, siteCoreOrPart), " (", animalsCount, " ", GenLabel.BestKindLabel(siteCoreOrPart.parms.animalKind, Gender.None, true, animalsCount), ")" })); }
public override void ProcessInput(Event ev) { if (!base.CheckCanInteract()) { return; } ThingDef thingDef = this.entDef as ThingDef; if (thingDef == null || !thingDef.MadeFromStuff) { base.ProcessInput(ev); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef current in base.Map.resourceCounter.AllCountedAmounts.Keys) { if (current.IsStuff && current.stuffProps.CanMake(thingDef) && (DebugSettings.godMode || base.Map.listerThings.ThingsOfDef(current).Count > 0)) { ThingDef localStuffDef = current; string label = GenLabel.ThingLabel(this.entDef, localStuffDef, 1).CapitalizeFirst(); list.Add(new FloatMenuOption(label, delegate { base.ProcessInput(ev); Find.DesignatorManager.Select(this); this.stuffDef = localStuffDef; this.writeStuff = true; }, MenuOptionPriority.Default, null, null, 0f, null, null) { tutorTag = "SelectStuff-" + thingDef.defName + "-" + localStuffDef.defName }); } } if (list.Count == 0) { Messages.Message("NoStuffsToBuildWith".Translate(), MessageTypeDefOf.RejectInput, false); } else { FloatMenu floatMenu = new FloatMenu(list); floatMenu.vanishIfMouseDistant = true; floatMenu.onCloseCallback = delegate { this.writeStuff = true; }; Find.WindowStack.Add(floatMenu); Find.DesignatorManager.Select(this); } } }
private void TakeWearoutDamageForDay(Thing ap) { int num = GenMath.RoundRandom(ap.def.apparel.wearPerDay); if (num > 0) { ap.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, (float)num)); } if (ap.Destroyed && PawnUtility.ShouldSendNotificationAbout(pawn) && !pawn.Dead) { string str = "MessageWornApparelDeterioratedAway".Translate(GenLabel.ThingLabel(ap.def, ap.Stuff), pawn); str = str.CapitalizeFirst(); Messages.Message(str, pawn, MessageTypeDefOf.NegativeEvent); } }
private void TakeWearoutDamageForDay(Thing ap) { int num = GenMath.RoundRandom(ap.def.apparel.wearPerDay); if (num > 0) { ap.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, (float)num, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); } if (ap.Destroyed && PawnUtility.ShouldSendNotificationAbout(this.pawn) && !this.pawn.Dead) { string text = "MessageWornApparelDeterioratedAway".Translate(GenLabel.ThingLabel(ap.def, ap.Stuff, 1), this.pawn); text = text.CapitalizeFirst(); Messages.Message(text, this.pawn, MessageTypeDefOf.NegativeEvent, true); } }
public override string Label(Room r = null) { bool flag = !labelKey.NullOrEmpty(); string text = (flag ? ((string)labelKey.Translate()) : thingDef.label); if (r != null) { return(text + " " + Count(r) + "/" + count); } if (!flag) { return(GenLabel.ThingLabel(thingDef, null, count)); } return(text + " x" + count); }
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); }
public override void ProcessInput(Event ev) { if (!CheckCanInteract()) { return; } ThingDef thingDef = entDef as ThingDef; if (thingDef == null || !thingDef.MadeFromStuff) { base.ProcessInput(ev); return; } List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef key in base.Map.resourceCounter.AllCountedAmounts.Keys) { if (key.IsStuff && key.stuffProps.CanMake(thingDef) && (DebugSettings.godMode || base.Map.listerThings.ThingsOfDef(key).Count > 0)) { ThingDef localStuffDef = key; FloatMenuOption floatMenuOption = new FloatMenuOption(GenLabel.ThingLabel(entDef, localStuffDef).CapitalizeFirst(), delegate { base.ProcessInput(ev); Find.DesignatorManager.Select(this); stuffDef = localStuffDef; writeStuff = true; }, key); floatMenuOption.tutorTag = "SelectStuff-" + thingDef.defName + "-" + localStuffDef.defName; list.Add(floatMenuOption); } } if (list.Count == 0) { Messages.Message("NoStuffsToBuildWith".Translate(), MessageTypeDefOf.RejectInput, historical: false); return; } FloatMenu floatMenu = new FloatMenu(list); floatMenu.vanishIfMouseDistant = true; floatMenu.onCloseCallback = delegate { writeStuff = true; }; Find.WindowStack.Add(floatMenu); Find.DesignatorManager.Select(this); }