public override string CompInspectStringExtra() { string txt = ""; bool holeHere = true; Thing thingHole = this.parent.Map.thingGrid.ThingAt(this.parent.Position, ThingDef.Named("AB_TarHole")); if (thingHole == null || thingHole.Position != this.parent.Position) { txt += "AB_WarningLowEfficiency".Translate(); holeHere = false; } if (this.PropsSpawner.writeTimeLeftToSpawn && (!this.PropsSpawner.requiresPower || this.PowerOn)) { if (!holeHere) { txt += "\n" + "NextSpawnedItemIn".Translate(GenLabel.ThingLabel(this.PropsSpawner.thingToSpawn, null, (int)(this.PropsSpawner.spawnCount / 3))) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true) + "\n" + "NextSpawnedItemIn".Translate(GenLabel.ThingLabel(this.PropsSpawner.SecondaryThingToSpawn, null, (int)(this.PropsSpawner.secondarySpawnCount / 3))) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true); } else { txt += "NextSpawnedItemIn".Translate(GenLabel.ThingLabel(this.PropsSpawner.thingToSpawn, null, this.PropsSpawner.spawnCount)) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true) + "\n" + "NextSpawnedItemIn".Translate(GenLabel.ThingLabel(this.PropsSpawner.SecondaryThingToSpawn, null, this.PropsSpawner.secondarySpawnCount)) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true); } } if (txt != "") { return(txt); } else { return(null); } }
public static void TradeRequests() { Map currentMap = Find.CurrentMap; IncidentWorker_QuestTradeRequest incidentWorker_QuestTradeRequest = (IncidentWorker_QuestTradeRequest)IncidentDefOf.Quest_TradeRequest.Worker; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Randomly-generated trade requests for map " + currentMap.ToString() + ":"); stringBuilder.AppendLine(); for (int i = 0; i < 50; i++) { SettlementBase settlementBase = IncidentWorker_QuestTradeRequest.RandomNearbyTradeableSettlement(currentMap.Tile); if (settlementBase == null) { break; } stringBuilder.AppendLine("Settlement: " + settlementBase.LabelCap); TradeRequestComp component = settlementBase.GetComponent <TradeRequestComp>(); if (incidentWorker_QuestTradeRequest.TryGenerateTradeRequest(component, currentMap)) { stringBuilder.AppendLine("Duration: " + (component.expiration - Find.TickManager.TicksGame).ToStringTicksToDays("F1")); string str = GenLabel.ThingLabel(component.requestThingDef, null, component.requestCount) + " ($" + (component.requestThingDef.BaseMarketValue * (float)component.requestCount).ToString("F0") + ")"; stringBuilder.AppendLine("Request: " + str); string str2 = GenThing.ThingsToCommaList(component.rewards, false, true, -1) + " ($" + (from t in component.rewards select t.MarketValue * (float)t.stackCount).Sum().ToString("F0") + ")"; stringBuilder.AppendLine("Reward: " + str2); } else { stringBuilder.AppendLine("TryGenerateTradeRequest failed."); } stringBuilder.AppendLine(); settlementBase.GetComponent <TradeRequestComp>().Disable(); } Log.Message(stringBuilder.ToString(), false); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map; bool result; if (!this.TryGetRandomAvailableTargetMap(out map)) { result = false; } else { Settlement settlement = IncidentWorker_ArcaneScriptCaravan.RandomNearbyTradeableSettlement(parms.target.Tile); if (settlement == null) { return(false); } else { TradeRequestComp component = settlement.GetComponent <TradeRequestComp>(); if (!this.GenerateCaravanRequest(component, (Map)parms.target)) { return(false); } Find.LetterStack.ReceiveLetter("LetterLabelArcaneScriptCaravan".Translate(), "LetterArcaneScriptCaravan".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); } } return(result); }
private string GetTitle() { string result; if (this.thing != null) { result = this.thing.LabelCapNoCount; } else if (this.worldObject != null) { result = this.worldObject.LabelCap; } else { ThingDef thingDef = this.Def as ThingDef; if (thingDef != null) { result = GenLabel.ThingLabel(thingDef, this.stuff, 1).CapitalizeFirst(); } else { result = this.Def.LabelCap; } } return(result); }
public static bool PatchMethod_Prefix(ref Thing ap, Pawn_ApparelTracker __instance) { if ((bool)DurableClothes_Settings.toggleFullRepair) // Only do full repair if the setting is enabled { ap.HitPoints = ap.MaxHitPoints; //Log.Message("Repair to full"); return(false); } if (DurableClothes_Settings.wearPercent == 0) { //Log.Message("No deterioraton"); return(false); } var num = GenMath.RoundRandom(ap.def.apparel.wearPerDay * DurableClothes_Settings.wearPercent / 100); //Log.Message("Take damage "+ num); 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(__instance.pawn) && !__instance.pawn.Dead) { Messages.Message("MessageWornApparelDeterioratedAway".Translate(GenLabel.ThingLabel(ap.def, ap.Stuff, 1), __instance.pawn).CapitalizeFirst(), __instance.pawn, MessageTypeDefOf.NegativeEvent, true); } return(false); // don't run the original logic to degrade apparel either way }
private string GetTitle() { if (thing != null) { return(thing.LabelCapNoCount); } if (worldObject != null) { return(worldObject.LabelCap); } ThingDef thingDef = Def as ThingDef; if (thingDef != null) { return(GenLabel.ThingLabel(thingDef, stuff).CapitalizeFirst()); } AbilityDef abilityDef = Def as AbilityDef; if (abilityDef != null) { return(abilityDef.LabelCap); } if (titleDef != null) { return(titleDef.GetLabelCapForBothGenders()); } if (faction != null) { return(faction.Name); } return(Def.LabelCap); }
public override string CompInspectStringExtra() { if (this.ActiveRequest) { return("CaravanRequestInfo".Translate(GenLabel.ThingLabel(this.requestThingDef, null, this.requestCount).CapitalizeFirst(), this.rewards[0].LabelCap, (this.expiration - Find.TickManager.TicksGame).ToStringTicksToDays("F1"))); } return(null); }
// Token: 0x0600575B RID: 22363 RVA: 0x001D481C File Offset: 0x001D2A1C public override string CompInspectStringExtra() { if (this.PropsSpawner.writeTimeLeftToSpawn && (!this.PropsSpawner.requiresPower || this.PowerOn)) { return("NextSpawnedItemIn".Translate(GenLabel.ThingLabel(this.PropsSpawner.thingToSpawn, null, this.PropsSpawner.spawnCount)) + ": " + this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true)); } return(null); }
public override string CompInspectStringExtra() { if (Props.writeTimeLeftToSpawn && (!Props.requiresPower || PowerOn)) { return("NextSpawnedItemIn".Translate(GenLabel.ThingLabel(Props.thingToSpawn, null, Props.spawnCount)) + ": " + ticksUntilSpawn.ToStringTicksToPeriod()); } return(null); }
public static string RequestedThingLabel(ThingDef def, int count) { string text = GenLabel.ThingLabel(def, null, count); if (def.HasComp(typeof(CompQuality))) { text = text + " (" + "NormalQualityOrBetter".Translate() + ")"; } return(text); }
public static string GetThingDefLabel(ThingDef thingDef, int count = 1, bool capitalizeFirst = true) { string label = GenLabel.ThingLabel(thingDef, null, count); if (capitalizeFirst) { label = label.CapitalizeFirst(); } return(label); }
protected void LogInventory() { foreach (InventoryRecord current in this.allRecords.Values) { if (current.count != 0) { Log.Message(GenLabel.ThingLabel(current.thingDef, current.stuffDef, current.count)); } } }
internal string RewardsText() { string stringBuilder = ""; foreach (Thing current in GetReward()) { string stringLabel = GenLabel.ThingLabel(current.def, null, current.stackCount).CapitalizeFirst(); stringBuilder += (" -" + stringLabel + "\n"); } return(stringBuilder); }
public override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "PlayerStartsWith") { return(new List <string> { GenText.CapitalizeFirst(GenLabel.ThingLabel(thingDef, stuff, count)) }); } return(Enumerable.Empty <string>()); }
public override string GetInspectString() { StringBuilder builder = new StringBuilder(); string str = base.GetInspectString(); if (!string.IsNullOrEmpty(str)) { builder.AppendLine(str); } builder.Append("NextSpawnedItemIn".Translate(GenLabel.ThingLabel(PRFDefOf.Paperclip, null, 10000)) + ": " + ((250 - workDone) * 10).ToStringTicksToPeriod()); return(builder.ToString().TrimEndNewlines()); }
public override IEnumerable <string> GetSummaryListEntries(string tag) { if (tag == "PlayerStartsWith") { List <string> entries = new List <string>(); entries.Add(GenLabel.ThingLabel(thingDef, stuff, count).CapitalizeFirst()); return(entries); } else { return(Enumerable.Empty <string>()); } }
private string GetTitle() { if (_apparel != null) { return(_apparel.LabelCap); } if (Def is ThingDef thingDef) { return(GenLabel.ThingLabel(thingDef, _stuff).CapitalizeFirst()); } return(Def?.LabelCap); }
public static void Postfix(Designator_Build __instance, Event ev) { var _Map = ((Map)Traverse.Create(__instance).Property("Map").GetValue()); var _entDef = (BuildableDef)Traverse.Create(__instance).Field("entDef").GetValue(); ThingDef thingDef = _entDef as ThingDef; if (thingDef == null || !thingDef.MadeFromStuff) { return; } FloatMenu floatMenu = (FloatMenu)Find.WindowStack.Windows.LastOrDefault(x => x.GetType() == typeof(FloatMenu) && !x.GetType().IsSubclassOf(typeof(FloatMenu))); if (floatMenu == null) { return; } List <FloatMenuOption> optionsList = (List <FloatMenuOption>)AccessTools.Field(typeof(FloatMenu), "options").GetValue(floatMenu); foreach (ThingDef thingDef2 in _Map.resourceCounter.AllCountedAmounts.Keys) { if (thingDef2.IsStuff && thingDef2.stuffProps.CanMake(thingDef) && _Map.listerThings.ThingsOfDef(thingDef2).Count > 0) { ThingDef localStuffDef = thingDef2; string label = GenLabel.ThingLabel(_entDef, localStuffDef, 1).CapitalizeFirst(); FloatMenuOption option; try { option = optionsList.SingleOrDefault(x => x.Label == label); } catch (InvalidOperationException e) { option = null; Log.Warning("StuffCount: Two or more different stuff with same name " + label + "!"); } if (option != null) { int stuffCount = (localStuffDef.CountAsResource) ? _Map.resourceCounter.GetCount(localStuffDef) : _Map.listerThings.ThingsOfDef(localStuffDef).Count; string labelCapNew = label + " (" + stuffCount + ")"; option.Label = labelCapNew; } } } Traverse.Create(floatMenu).Method("SetInitialSizeAndPosition").GetValue(); }
public override string GetReport() { string text = JobDefOf.Sow.reportString; if (job.plantDefToSow != null) { text = text.Replace("TargetA", GenLabel.ThingLabel(job.plantDefToSow, null, 1)); } else { text = text.Replace("TargetA", "area"); } return(text); }
private string GetTitle() { if (this._apparel != null) { return(this._apparel.LabelCap); } ThingDef thingDef = this.Def as ThingDef; if (thingDef != null) { return(GenLabel.ThingLabel(thingDef, this._stuff).CapitalizeFirst()); } return(this.Def?.LabelCap); }
/// <summary> /// Degrades an item /// </summary> /// <param name="item">The item in question</param> /// <param name="pawn">The pawn with the item</param> /// <param name="damageIncrease">Extra damage</param> /// <param name="random">If damage should be randomized</param> public static void Degrade(Thing item, Pawn pawn, float damageIncrease, bool random) { float damage = random && damageIncrease >= 1 ? Rand.Range(1, damageIncrease) : damageIncrease; if (damage > 0) { item.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, damage)); } if (item != null && item.Destroyed && PawnUtility.ShouldSendNotificationAbout(pawn) && !pawn.Dead) { pawn.jobs.ClearQueuedJobs(); string str = "MessageWornApparelDeterioratedAway".Translate(GenLabel.ThingLabel(item.def, item.Stuff), pawn); str = str.CapitalizeFirst(); Messages.Message(str, pawn, MessageTypeDefOf.NegativeEvent); } }
private string GetTitle() { if (this.thing != null) { return(this.thing.LabelCapNoCount); } if (this.worldObject != null) { return(this.worldObject.LabelCap); } ThingDef thingDef = this.Def as ThingDef; if (thingDef != null) { return(GenLabel.ThingLabel(thingDef, this.stuff, 1).CapitalizeFirst()); } return(this.Def.LabelCap); }
private Command FulfillRequestCommand(Caravan caravan) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate(); command_Action.defaultDesc = "CommandFulfillTradeOfferDesc".Translate(); command_Action.icon = TradeRequestComp.TradeCommandTex; command_Action.action = delegate() { if (!this.ActiveRequest) { Log.Error("Attempted to fulfill an unavailable request", false); } else if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive))) { Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(new object[] { TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount) }), MessageTypeDefOf.RejectInput, false); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(new object[] { GenLabel.ThingLabel(this.requestThingDef, null, this.requestCount), GenThing.ThingsToCommaList(this.rewards, true, true, -1) }), delegate { this.Fulfill(caravan); }, false, null)); } }; if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive))) { command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(new object[] { TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount) })); } return(command_Action); }
public void Complete() { def.IsFinished = true; ChallengeManager.instance.ClearChallenge(); Controller.ChallengeComplete(def); IEnumerable <Thing> reward = def.GetReward(); string rewardText = ""; foreach (Thing thing in reward) { rewardText += " - " + GenLabel.ThingLabel(thing.def, thing.Stuff, thing.stackCount).CapitalizeFirst() + "\n"; } EndGameDialogMessage("ChallengeCompletedEndDialog".Translate(new[] { def.label, def.description, rewardText })); IntVec3 dropSpot = DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap); // drop around base DropPodUtility.DropThingsNear(dropSpot, Find.AnyPlayerHomeMap, reward); }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (this.CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); string tipString = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? "ConsumeThing".Translate(new object[] { thing.LabelShort }) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); TooltipHandler.TipRegion(rect3, tipString); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); this.InterfaceEatThis(thing); } rect.width -= 24f; } if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(thingLabelRect, thingLabel); y += _thingRowHeight; TooltipHandler.TipRegion(thingLabelRect, thing.GetWeightAndBulkTip()); // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action dropApparel = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); }; Action dropApparelHaul = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }; if (this.CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceEatThis(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? "ConsumeThing".Translate(new object[] { thing.LabelShort }) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); floatOptionList.Add(new FloatMenuOption(label, eatFood)); } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel)); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), dropApparelHaul)); if (this.CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
public virtual string GetCustomLabelNoCount(bool includeHp = true) { return(GenLabel.ThingLabel(this, 1, includeHp)); }
private bool DoWork(Slate slate) { Map map = slate.Get <Map>("map"); if (map == null) { return(false); } float x2 = slate.Get("points", 0f); SimpleCurve value = pointsToMaxItemMarketValueCurve.GetValue(slate); float num = maxMarketValueFactor.GetValue(slate) ?? 1f; float maxMarketValue = value.Evaluate(x2) * num; SimpleCurve value2 = pointsToRequiredWorkCurve.GetValue(slate); float randomInRange = (workAmountRandomFactorRange.GetValue(slate) ?? FloatRange.One).RandomInRange; float num2 = value2.Evaluate(x2) * randomInRange; tmpCandidates.Clear(); for (int j = 0; j < allWorkTables.Count; j++) { if (BuildCopyCommandUtility.FindAllowedDesignator(allWorkTables[j]) == null) { continue; } List <RecipeDef> recipes = allWorkTables[j].AllRecipes; for (int i = 0; i < recipes.Count; i++) { if (!recipes[i].AvailableNow || !recipes[i].products.Any() || recipes[i].PotentiallyMissingIngredients(null, map).Any()) { continue; } foreach (ThingDef stuff in recipes[i].products[0].thingDef.MadeFromStuff ? GenStuff.AllowedStuffsFor(recipes[i].products[0].thingDef) : Gen.YieldSingle <ThingDef>(null)) { if (stuff != null && (!map.listerThings.ThingsOfDef(stuff).Any() || stuff.stuffProps.commonality < minStuffCommonality.GetValue(slate))) { continue; } int num3 = 0; if (stuff != null) { List <Thing> list = map.listerThings.ThingsOfDef(stuff); for (int k = 0; k < list.Count; k++) { num3 += list[k].stackCount; } } float num4 = recipes[i].WorkAmountTotal(stuff); if (!(num4 > 0f)) { continue; } int num5 = Mathf.FloorToInt(num2 / num4); if (stuff != null) { IngredientCount ingredientCount = recipes[i].ingredients.Where((IngredientCount x) => x.filter.Allows(stuff)).MaxByWithFallback((IngredientCount x) => x.CountRequiredOfFor(stuff, recipes[i])); num5 = Mathf.Min(num5, Mathf.FloorToInt((float)num3 / (float)ingredientCount.CountRequiredOfFor(stuff, recipes[i]))); } if (num5 > 0) { tmpCandidates.Add(new Pair <ThingStuffPair, int>(new ThingStuffPair(recipes[i].products[0].thingDef, stuff), recipes[i].products[0].count * num5)); } } } } tmpCandidates.RemoveAll((Pair <ThingStuffPair, int> x) => x.Second <= 0); tmpCandidates.RemoveAll((Pair <ThingStuffPair, int> x) => StatDefOf.MarketValue.Worker.GetValueAbstract(x.First.thing, x.First.stuff) > maxMarketValue); if (!tmpCandidates.Any()) { return(false); } Pair <ThingStuffPair, int> pair = tmpCandidates.RandomElement(); int num6 = Mathf.Min(Mathf.RoundToInt(maxMarketValue / StatDefOf.MarketValue.Worker.GetValueAbstract(pair.First.thing, pair.First.stuff)), pair.Second); float randomInRange2 = (productionItemCountRandomFactorRange.GetValue(slate) ?? FloatRange.One).RandomInRange; num6 = Mathf.RoundToInt((float)num6 * randomInRange2); num6 = Mathf.Max(num6, 1); slate.Set(storeProductionItemDefAs.GetValue(slate), pair.First.thing); slate.Set(storeProductionItemStuffAs.GetValue(slate), pair.First.stuff); slate.Set(storeProductionItemCountAs.GetValue(slate), num6); string value3 = storeProductionItemLabelAs.GetValue(slate); if (!string.IsNullOrEmpty(value3)) { slate.Set(value3, GenLabel.ThingLabel(pair.First.thing, pair.First.stuff, num6)); } return(true); }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { var dropForbidden = IsItemDropForbidden(thing); Color color = dropForbidden ? Color.grey : Color.white; Color mouseoverColor = dropForbidden ? Color.grey : GenUI.MouseoverColor; Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, dropForbidden ? "DropThingLocked".Translate() : "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop, color, mouseoverColor) && !dropForbidden) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null)); Text.WordWrap = true; string text2 = string.Concat(new object[] { thing.LabelCap, "\n", thing.DescriptionDetailed, "\n", thing.GetWeightAndBulkTip() }); if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", "HitPointsBasic".Translate().CapitalizeFirst(), ": ", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(thingLabelRect, text2); y += 28f; // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); CompBiocodable compBiocoded = eq.TryGetComp <CompBiocodable>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null); } else if (SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear)) { var forbiddenEquipOrPutAway = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(eqLabel) : "CannotEquip".Translate(eqLabel); equipOption = new FloatMenuOption(forbiddenEquipOrPutAway + ": " + "CE_CannotChangeEquipment".Translate(), null); } else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null); } else { string equipOptionLabel = "Equip".Translate(eqLabel); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption( equipOptionLabel, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } //Reload apparel option IEnumerable <Apparel> worn_apparel = SelPawnForGear?.apparel?.WornApparel ?? Enumerable.Empty <Apparel>(); foreach (var apparel in worn_apparel) { var compReloadable = apparel.TryGetComp <CompReloadable>(); if (compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true)) { if (!SelPawnForGear.Drafted) //TODO-1.2 This should be doable for drafted pawns as well, but the job does nothing. Figure out what's wrong and remove this condition. { FloatMenuOption reloadApparelOption = new FloatMenuOption( "CE_ReloadApparel".Translate(apparel.Label, thing.Label), new Action(delegate { //var reloadJob = JobMaker.MakeJob(JobDefOf.Reload, apparel, thing); //SelPawnForGear.jobs.StartJob(reloadJob, JobCondition.InterruptForced, null, SelPawnForGear.CurJob?.def != reloadJob.def, true); SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing)); }) ); floatOptionList.Add(reloadApparelOption); } } } // Consume option if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceIngest(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug) { floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null)); } else { floatOptionList.Add(new FloatMenuOption(label, eatFood)); } } // Drop, and drop&haul options if (IsItemDropForbidden(eq)) { floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null)); floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null)); } else { floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); }))); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }))); } // Stop holding in inventory option if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
private void DrawThingRow(ref float y, float width, Thing thing) { Rect rect = new Rect(0f, y, width, 28f); TooltipHandler.TipRegion(rect, thing.GetWeightAndBulkTip()); if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (Widgets.ButtonInvisible(rect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Medium, null, null)); if (this.CanEdit) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { ThingWithComps oldEq; SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action action = null; Apparel ap = thing as Apparel; if (ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap)) { Apparel unused; action = delegate { this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true); }; } else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq)) { ThingWithComps unused; action = delegate { this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true); }; } else if (!thing.def.destroyOnDrop) { Thing unused; action = delegate { this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused); }; } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null)); } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect rect2 = new Rect(36f, y, width - 36f, 28f); string text = thing.LabelCap; if (thing is Apparel && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) { text = text + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(rect2, text); y += 28f; }
static public string GetSetFullStuffLabel(this CompLootAffixableThing comp, string label) { List <LootAffixDef> affixes = comp.affixes; List <Rule> affixRules = comp.affixRules; ThingWithComps thing = comp.parent; // Make sure we're not saving color tag information label = label.StripTags(); // Short-circuit: No affixes if (comp.AffixCount == 0) { return(label); } // Short-circuit: Already calculated the full label and no replacement required string stuffLabel = GenLabel.ThingLabel(thing.def, thing.Stuff, 1).StripTags(); if (comp.fullStuffLabel != null && stuffLabel == label) { return(comp.fullStuffLabel); } // Short-circuit: Still have the calculated full label string preExtra = ""; string postExtra = ""; int pos = label.IndexOf(stuffLabel); if (pos >= 0) { preExtra = label.Substring(0, pos); postExtra = label.Substring(pos + stuffLabel.Length); } if (comp.fullStuffLabel != null) { return(preExtra + comp.fullStuffLabel + postExtra); } // Need the calculate the label then... var namerDef = DefDatabase <LootAffixNamerRulePackDef> .GetNamed("RimLoot_LootAffixNamer"); GrammarRequest request = new GrammarRequest(); request.Includes.Add(namerDef); // Word class counter set-up Dictionary <string, int> maxWordClasses = namerDef.maxWordClasses; Dictionary <string, int> curWordClasses = new Dictionary <string, int> (); for (int i = 0; i < 5; i++) { curWordClasses = maxWordClasses.ToDictionary(k => k.Key, v => 0); // shallow clone to k=0 // Add in the affixes foreach (LootAffixDef affix in affixes) { foreach (Rule rule in affix.PickAffixRulesForLabeling(curWordClasses, maxWordClasses)) { if (rule.keyword.StartsWith("AFFIX_")) { comp.affixRules.Add(rule); } request.Rules.Add(rule); if (rule.keyword.StartsWith("AFFIXPROP_")) { request.Constants.Add(rule.keyword, rule.Generate()); } } } // Double-check we didn't hit one of those disallowed combinations if (namerDef.IsWordClassComboAllowed(affixRules)) { break; } else { affixRules.Clear(); continue; } } if (affixRules.Count != comp.AffixCount) { Log.Error("Chosen affix words for " + thing + " don't match the number of affixes:\n" + string.Join( "\nvs.\n", string.Join(" | ", affixRules), string.Join(", ", affixes) )); } // Add a few types of labels for maximum language flexibility request.Rules.Add(new Rule_String("STUFF_label", thing.Stuff != null ? thing.Stuff.LabelAsStuff : "")); request.Rules.Add(new Rule_String("THING_defLabel", thing.def.label)); request.Rules.Add(new Rule_String("THING_stuffLabel", stuffLabel)); string rootKeyword = "r_affix" + comp.AffixCount; comp.fullStuffLabel = NameGenerator.GenerateName(request, null, false, rootKeyword, rootKeyword); // It's possible we might end up hitting this later than we expected, and run into affixes/word // desyncs, so clear the cache, just in case. comp.ClearAffixCaches(); return(preExtra + comp.fullStuffLabel + postExtra); }