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 override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "PlayerStartsWith") { yield return(GenLabel.ThingLabel(this.thingDef, this.stuff, this.count).CapitalizeFirst()); } }
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()*/; }
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 string CompInspectStringExtra() { if (PropsSpawner.writeTimeLeftToSpawn && (!PropsSpawner.requiresPower || PowerOn)) { return("NextSpawnedItemIn".Translate(GenLabel.ThingLabel(PropsSpawner.thingToSpawn, null, PropsSpawner.spawnCount)) + ": " + ticksUntilSpawn.ToStringTicksToPeriod()); } return(null); }
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 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()); }
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); }
/// <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())); }
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 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); }
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); }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(StatRequest req) { foreach (StatDrawEntry s in base.SpecialDisplayStats(req)) { yield return(s); } if (((ThingDef)req.Def).building.IsTurret) { StatCategoryDef building = StatCategoryDefOf.Building; string text = "RearmCost".Translate(); string valueString = GenLabel.ThingLabel(this.fuelFilter.AnyAllowedDef, null, (int)(this.fuelCapacity / this.FuelMultiplierCurrentDifficulty)).CapitalizeFirst(); string text2 = "RearmCostExplanation".Translate(); yield return(new StatDrawEntry(building, text, valueString, 0, text2)); building = StatCategoryDefOf.Building; text2 = "ShotsBeforeRearm".Translate(); valueString = ((int)this.fuelCapacity).ToString(); text = "ShotsBeforeRearmExplanation".Translate(); yield return(new StatDrawEntry(building, text2, valueString, 0, text)); } }
protected override bool TryExecuteWorker(IncidentParms parms) { Settlement settlement = IncidentWorker_CaravanRequest.RandomNearbyTradeableSettlement(parms.target.Tile); if (settlement == null) { return(false); } CaravanRequestComp component = settlement.GetComponent <CaravanRequestComp>(); if (!this.TryGenerateCaravanRequest(component, (Map)parms.target)) { return(false); } Find.LetterStack.ReceiveLetter("LetterLabelCaravanRequest".Translate(), "LetterCaravanRequest".Translate(new object[] { settlement.Label, GenLabel.ThingLabel(component.requestThingDef, null, component.requestCount).CapitalizeFirst(), component.rewards[0].LabelCap, (component.expiration - Find.TickManager.TicksGame).ToStringTicksToDays("F0") }), LetterDefOf.PositiveEvent, settlement, null); return(true); }
public static string ThingsLabel(List <Thing> things) { GenLabel.tmpThingsLabelElements.Clear(); using (List <Thing> .Enumerator enumerator = things.GetEnumerator()) { while (enumerator.MoveNext()) { Thing thing = enumerator.Current; GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements where thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.def && elem.thingTemplate.Stuff == thing.Stuff select elem).FirstOrDefault <GenLabel.LabelElement>(); if (labelElement != null) { labelElement.count += thing.stackCount; } else { GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement { thingTemplate = thing, count = thing.stackCount }); } } } GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs) { int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def); int result; if (num != 0) { result = num; } else { result = lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue); } return(result); }); StringBuilder stringBuilder = new StringBuilder(); foreach (GenLabel.LabelElement labelElement2 in GenLabel.tmpThingsLabelElements) { string str = ""; if (labelElement2.thingTemplate.ParentHolder is Pawn_ApparelTracker) { str = " (" + "WornBy".Translate(new object[] { (labelElement2.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort }) + ")"; } else if (labelElement2.thingTemplate.ParentHolder is Pawn_EquipmentTracker) { str = " (" + "EquippedBy".Translate(new object[] { (labelElement2.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort }) + ")"; } if (labelElement2.count == 1) { stringBuilder.AppendLine(" " + labelElement2.thingTemplate.LabelCap + str); } else { stringBuilder.AppendLine(" " + GenLabel.ThingLabel(labelElement2.thingTemplate.def, labelElement2.thingTemplate.Stuff, labelElement2.count).CapitalizeFirst() + str); } } GenLabel.tmpThingsLabelElements.Clear(); return(stringBuilder.ToString()); }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats(StatRequest req) { foreach (StatDrawEntry item in base.SpecialDisplayStats(req)) { yield return(item); } if (((ThingDef)req.Def).building.IsTurret) { yield return(new StatDrawEntry(StatCategoryDefOf.Building, "RearmCost".Translate(), GenLabel.ThingLabel(fuelFilter.AnyAllowedDef, null, (int)(fuelCapacity / FuelMultiplierCurrentDifficulty)).CapitalizeFirst(), "RearmCostExplanation".Translate(), 3171)); yield return(new StatDrawEntry(StatCategoryDefOf.Building, "ShotsBeforeRearm".Translate(), ((int)fuelCapacity).ToString(), "ShotsBeforeRearmExplanation".Translate(), 3171)); } }
private void DoThingRow(ThingDef thingDef, int count, List <Thing> things, float width, ref float curY, Action <int> discardAction) { Rect rect = new Rect(0f, curY, width, 28f); if (count != 1) { Rect butRect = new Rect(rect.x + rect.width - 24f, rect.y + (rect.height - 24f) / 2f, 24f, 24f); if (Widgets.ButtonImage(butRect, CaravanThingsTabUtility.AbandonSpecificCountButtonTex)) { Find.WindowStack.Add(new Dialog_Slider("RemoveSliderText".Translate(thingDef.label), 1, count, discardAction, -2147483648)); } } rect.width -= 24f; Rect butRect2 = new Rect(rect.x + rect.width - 24f, rect.y + (rect.height - 24f) / 2f, 24f, 24f); if (Widgets.ButtonImage(butRect2, CaravanThingsTabUtility.AbandonButtonTex)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmRemoveItemDialog".Translate(thingDef.label), delegate { discardAction(count); }, false, null)); } rect.width -= 24f; 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 = ITab_TransporterContents.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], 1f); } else { Widgets.ThingIcon(rect2, thingDef); } } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_TransporterContents.ThingLabelColor; Rect rect3 = new Rect(36f, curY, rect.width - 36f, rect.height); string str; if (things.Count == 1) { str = things[0].LabelCap; } else { str = GenLabel.ThingLabel(thingDef, null, count).CapitalizeFirst(); } Text.WordWrap = false; Widgets.Label(rect3, str.Truncate(rect3.width, null)); Text.WordWrap = true; Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, str); if (Widgets.ButtonInvisible(rect, false)) { this.SelectLater(things); } if (Mouse.IsOver(rect)) { for (int i = 0; i < things.Count; i++) { TargetHighlighter.Highlight(things[i], true, true, false); } } curY += 28f; }